[更新]修改系统用户管理

This commit is contained in:
Anyon 2019-08-19 10:36:03 +08:00
parent 564797cb83
commit f258e2cccc
3 changed files with 85 additions and 78 deletions

View File

@ -11,7 +11,7 @@
Target Server Version : 50562 Target Server Version : 50562
File Encoding : 65001 File Encoding : 65001
Date: 14/08/2019 10:33:20 Date: 19/08/2019 10:34:31
*/ */
SET NAMES utf8mb4; SET NAMES utf8mb4;
@ -676,7 +676,7 @@ CREATE TABLE `system_user` (
`is_deleted` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '删除(1删除,0未删)', `is_deleted` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '删除(1删除,0未删)',
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `index_system_user_username`(`username`) USING BTREE, INDEX `index_system_user_username`(`username`) USING BTREE,
INDEX `index_system_user_status`(`status`) USING BTREE, INDEX `index_system_user_status`(`status`) USING BTREE,
INDEX `index_system_user_deleted`(`is_deleted`) USING BTREE INDEX `index_system_user_deleted`(`is_deleted`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 10001 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统-用户'; ) ENGINE = InnoDB AUTO_INCREMENT = 10001 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统-用户';
@ -684,7 +684,7 @@ CREATE TABLE `system_user` (
-- ---------------------------- -- ----------------------------
-- Records of system_user -- Records of system_user
-- ---------------------------- -- ----------------------------
INSERT INTO `system_user` VALUES (10000, 'admin', '21232f297a57a5a743894a0e4a801fc3', '22222222', '', '', '2019-08-14 10:07:34', '127.0.0.1', 659, '', '', '', 1, 0, '2015-11-13 15:14:22'); INSERT INTO `system_user` VALUES (10000, 'admin', '21232f297a57a5a743894a0e4a801fc3', '22222222', '', '', '2019-08-18 18:34:14', '127.0.0.1', 661, '', '', '', 1, 0, '2015-11-13 15:14:22');
-- ---------------------------- -- ----------------------------
-- Table structure for wechat_fans -- Table structure for wechat_fans

View File

@ -118,12 +118,14 @@ class User extends Controller
public function _form_filter(&$data) public function _form_filter(&$data)
{ {
if ($this->request->isPost()) { if ($this->request->isPost()) {
// 刷新系统授权
NodeService::applyUserAuth(); NodeService::applyUserAuth();
// 用户权限处理
$data['authorize'] = (isset($data['authorize']) && is_array($data['authorize'])) ? join(',', $data['authorize']) : ''; $data['authorize'] = (isset($data['authorize']) && is_array($data['authorize'])) ? join(',', $data['authorize']) : '';
if (isset($data['id'])) { // 用户账号重复检查
unset($data['username']); if (isset($data['id'])) unset($data['username']);
} elseif (Db::name($this->table)->where(['username' => $data['username']])->count() > 0) { elseif (Db::name($this->table)->where(['username' => $data['username'], 'is_deleted' => '0'])->count() > 0) {
$this->error('用户账号已经存在,请使用其它账号!'); $this->error("账号{$data['username']}已经存在,请使用其它账号!");
} }
} else { } else {
$data['authorize'] = explode(',', isset($data['authorize']) ? $data['authorize'] : ''); $data['authorize'] = explode(',', isset($data['authorize']) ? $data['authorize'] : '');

View File

@ -15,14 +15,23 @@
namespace app\store\command; namespace app\store\command;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Db; use think\Db;
use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException;
use think\Exception;
use think\exception\DbException;
use think\exception\PDOException;
use We;
/** /**
* 商城数据处理指令 * 商城数据处理指令
* Class AutoRun * Class AutoRun
* @package app\store\command * @package app\store\command
*/ */
class AutoRun extends \think\console\Command class AutoRun extends Command
{ {
/** /**
@ -35,15 +44,15 @@ class AutoRun extends \think\console\Command
/** /**
* 业务指令执行 * 业务指令执行
* @param \think\console\Input $input * @param Input $input
* @param \think\console\Output $output * @param Output $output
* @throws \think\Exception * @throws Exception
* @throws \think\db\exception\DataNotFoundException * @throws DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException * @throws ModelNotFoundException
* @throws \think\exception\DbException * @throws DbException
* @throws \think\exception\PDOException * @throws PDOException
*/ */
protected function execute(\think\console\Input $input, \think\console\Output $output) protected function execute(Input $input, Output $output)
{ {
// 自动取消30分钟未支付的订单 // 自动取消30分钟未支付的订单
$this->autoCancelOrder(); $this->autoCancelOrder();
@ -57,8 +66,8 @@ class AutoRun extends \think\console\Command
/** /**
* 自动取消30分钟未支付的订单 * 自动取消30分钟未支付的订单
* @throws \think\Exception * @throws Exception
* @throws \think\exception\PDOException * @throws PDOException
*/ */
private function autoCancelOrder() private function autoCancelOrder()
{ {
@ -79,11 +88,11 @@ class AutoRun extends \think\console\Command
/** /**
* 清理一天前未支付的订单 * 清理一天前未支付的订单
* @throws \think\Exception * @throws Exception
* @throws \think\db\exception\DataNotFoundException * @throws DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException * @throws ModelNotFoundException
* @throws \think\exception\DbException * @throws DbException
* @throws \think\exception\PDOException * @throws PDOException
*/ */
private function autoRemoveOrder() private function autoRemoveOrder()
{ {
@ -101,19 +110,18 @@ class AutoRun extends \think\console\Command
/** /**
* 订单自动退款操作 * 订单自动退款操作
* @throws \think\Exception * @throws Exception
* @throws \think\db\exception\DataNotFoundException * @throws DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException * @throws ModelNotFoundException
* @throws \think\exception\DbException * @throws DbException
* @throws \think\exception\PDOException * @throws PDOException
*/ */
private function autoRefundOrder() private function autoRefundOrder()
{ {
// 未完成退款的订单,执行微信退款操作 // 未完成退款的订单,执行微信退款操作
foreach (Db::name('StoreOrder')->where(['refund_state' => '1'])->select() as $order) { foreach (Db::name('StoreOrder')->where(['refund_state' => '1'])->select() as $order) try {
try {
$this->output->writeln("正在为 {$order['order_no']} 执行退款操作..."); $this->output->writeln("正在为 {$order['order_no']} 执行退款操作...");
$result = \We::WePayRefund(config('wechat.wxpay'))->create([ $result = We::WePayRefund(config('wechat.wxpay'))->create([
'transaction_id' => $order['pay_no'], 'transaction_id' => $order['pay_no'],
'out_refund_no' => $order['refund_no'], 'out_refund_no' => $order['refund_no'],
'total_fee' => $order['price_total'] * 100, 'total_fee' => $order['price_total'] * 100,
@ -133,24 +141,22 @@ class AutoRun extends \think\console\Command
$this->output->writeln("订单 {$order['order_no']} 执行退款失败,{$e->getMessage()}"); $this->output->writeln("订单 {$order['order_no']} 执行退款失败,{$e->getMessage()}");
Db::name('StoreOrder')->where(['order_no' => $order['order_no']])->update(['refund_desc' => $e->getMessage()]); Db::name('StoreOrder')->where(['order_no' => $order['order_no']])->update(['refund_desc' => $e->getMessage()]);
} }
}
$this->output->writeln('自动检测退款订单执行完成!'); $this->output->writeln('自动检测退款订单执行完成!');
} }
/** /**
* 自动企业打款操作 * 自动企业打款操作
* @throws \think\Exception * @throws Exception
* @throws \think\db\exception\DataNotFoundException * @throws DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException * @throws ModelNotFoundException
* @throws \think\exception\DbException * @throws DbException
* @throws \think\exception\PDOException * @throws PDOException
*/ */
private function autoTransfer() private function autoTransfer()
{ {
# 批量企业打款 # 批量企业打款
foreach (Db::name('StoreProfitUsed')->where(['status' => '1'])->select() as $vo) { foreach (Db::name('StoreProfitUsed')->where(['status' => '1'])->select() as $vo) try {
try { $wechat = We::WePayTransfers(config('wechat.wxpay'));
$wechat = \We::WePayTransfers(config('wechat.wxpay'));
$result = $wechat->create([ $result = $wechat->create([
'partner_trade_no' => $vo['trs_no'], 'partner_trade_no' => $vo['trs_no'],
'openid' => $vo['openid'], 'openid' => $vo['openid'],
@ -173,14 +179,13 @@ class AutoRun extends \think\console\Command
Db::name('StoreProfitUsed')->where(['trs_no' => $vo['trs_no']])->update(['pay_desc' => $e->getMessage()]); Db::name('StoreProfitUsed')->where(['trs_no' => $vo['trs_no']])->update(['pay_desc' => $e->getMessage()]);
} }
} }
}
/** /**
* 获取配置时间 * 获取配置时间
* @param string $code * @param string $code
* @return string * @return string
* @throws \think\Exception * @throws Exception
* @throws \think\exception\PDOException * @throws PDOException
*/ */
private function getDatetime($code) private function getDatetime($code)
{ {