diff --git a/app/adminapi/controller/channel/AppSettingController.php b/app/adminapi/controller/channel/AppSettingController.php deleted file mode 100644 index c2d00369b..000000000 --- a/app/adminapi/controller/channel/AppSettingController.php +++ /dev/null @@ -1,53 +0,0 @@ -data($result); - } - - - /** - * @notes App设置 - * @return \think\response\Json - * @author 段誉 - * @date 2022/3/29 10:25 - */ - public function setConfig() - { - $params = $this->request->post(); - AppSettingLogic::setConfig($params); - return $this->success('操作成功', [], 1, 1); - } -} \ No newline at end of file diff --git a/app/adminapi/controller/channel/MnpSettingsController.php b/app/adminapi/controller/channel/MnpSettingsController.php deleted file mode 100644 index 82ff61d1c..000000000 --- a/app/adminapi/controller/channel/MnpSettingsController.php +++ /dev/null @@ -1,52 +0,0 @@ -getConfig(); - return $this->data($result); - } - - /** - * @notes 设置小程序配置 - * @return \think\response\Json - * @author ljj - * @date 2022/2/16 9:51 上午 - */ - public function setConfig() - { - $params = (new MnpSettingsValidate())->post()->goCheck(); - (new MnpSettingsLogic())->setConfig($params); - return $this->success('操作成功', [], 1, 1); - } -} \ No newline at end of file diff --git a/app/adminapi/controller/channel/WebPageSettingController.php b/app/adminapi/controller/channel/WebPageSettingController.php deleted file mode 100644 index 57f2e4c2a..000000000 --- a/app/adminapi/controller/channel/WebPageSettingController.php +++ /dev/null @@ -1,54 +0,0 @@ -data($result); - } - - - /** - * @notes H5设置 - * @return \think\response\Json - * @author 段誉 - * @date 2022/3/29 10:36 - */ - public function setConfig() - { - $params = (new WebPageSettingValidate())->post()->goCheck(); - WebPageSettingLogic::setConfig($params); - return $this->success('操作成功', [], 1, 1); - } -} \ No newline at end of file diff --git a/app/adminapi/controller/decorate/DataController.php b/app/adminapi/controller/decorate/DataController.php deleted file mode 100644 index cc004cf68..000000000 --- a/app/adminapi/controller/decorate/DataController.php +++ /dev/null @@ -1,47 +0,0 @@ -request->get('limit/d', 10); - $result = DecorateDataLogic::getArticleLists($limit); - return $this->success('获取成功', $result); - } - - - -} \ No newline at end of file diff --git a/app/adminapi/controller/decorate/PageController.php b/app/adminapi/controller/decorate/PageController.php deleted file mode 100644 index f76d8099b..000000000 --- a/app/adminapi/controller/decorate/PageController.php +++ /dev/null @@ -1,61 +0,0 @@ -request->get('id/d'); - $result = DecoratePageLogic::getDetail($id); - return $this->success('获取成功', $result); - } - - - /** - * @notes 保存装修配置 - * @return \think\response\Json - * @author 段誉 - * @date 2022/9/15 9:57 - */ - public function save() - { - $params = (new DecoratePageValidate())->post()->goCheck(); - $result = DecoratePageLogic::save($params); - if (false === $result) { - return $this->fail(DecoratePageLogic::getError()); - } - return $this->success('操作成功', [], 1, 1); - } - - -} \ No newline at end of file diff --git a/app/adminapi/controller/decorate/TabbarController.php b/app/adminapi/controller/decorate/TabbarController.php deleted file mode 100644 index f2ff9e0ae..000000000 --- a/app/adminapi/controller/decorate/TabbarController.php +++ /dev/null @@ -1,58 +0,0 @@ -success('', $data); - } - - - /** - * @notes 底部导航保存 - * @return \think\response\Json - * @author 段誉 - * @date 2022/9/6 9:58 - */ - public function save() - { - $params = $this->request->post(); - DecorateTabbarLogic::save($params); - return $this->success('操作成功', [], 1, 1); - } - - -} \ No newline at end of file diff --git a/app/adminapi/controller/finance/AccountLogController.php b/app/adminapi/controller/finance/AccountLogController.php deleted file mode 100644 index 5c8227982..000000000 --- a/app/adminapi/controller/finance/AccountLogController.php +++ /dev/null @@ -1,54 +0,0 @@ -dataLists(new AccountLogLists()); - } - - - /** - * @notes 用户余额变动类型 - * @return \think\response\Json - * @author 段誉 - * @date 2023/2/24 15:25 - */ - public function getUmChangeType() - { - return $this->data(AccountLogEnum::getUserMoneyChangeTypeDesc()); - } - - -} \ No newline at end of file diff --git a/app/adminapi/controller/finance/RefundController.php b/app/adminapi/controller/finance/RefundController.php deleted file mode 100644 index 6a81e1447..000000000 --- a/app/adminapi/controller/finance/RefundController.php +++ /dev/null @@ -1,72 +0,0 @@ -success('', $result); - } - - - /** - * @notes 退款记录 - * @return \think\response\Json - * @author 段誉 - * @date 2023/3/1 9:47 - */ - public function record() - { - return $this->dataLists(new RefundRecordLists()); - } - - - /** - * @notes 退款日志 - * @return \think\response\Json - * @author 段誉 - * @date 2023/3/1 9:47 - */ - public function log() - { - $recordId = $this->request->get('record_id', 0); - $result = RefundLogic::refundLog($recordId); - return $this->success('', $result); - } - -} \ No newline at end of file diff --git a/app/adminapi/controller/recharge/RechargeController.php b/app/adminapi/controller/recharge/RechargeController.php deleted file mode 100644 index 56a1079a6..000000000 --- a/app/adminapi/controller/recharge/RechargeController.php +++ /dev/null @@ -1,107 +0,0 @@ -data($result); - } - - - /** - * @notes 充值设置 - * @return \think\response\Json - * @author 段誉 - * @date 2023/2/22 16:48 - */ - public function setConfig() - { - $params = $this->request->post(); - $result = RechargeLogic::setConfig($params); - if($result) { - return $this->success('操作成功', [], 1, 1); - } - return $this->fail(RechargeLogic::getError()); - } - - - /** - * @notes 充值记录 - * @return \think\response\Json - * @author 段誉 - * @date 2023/2/24 16:01 - */ - public function lists() - { - return $this->dataLists(new RechargeLists()); - } - - - /** - * @notes 退款 - * @return \think\response\Json - * @author 段誉 - * @date 2023/2/28 17:29 - */ - public function refund() - { - $params = (new RechargeRefundValidate())->post()->goCheck('refund'); - $result = RechargeLogic::refund($params, $this->adminId); - list($flag, $msg) = $result; - if(false === $flag) { - return $this->fail($msg); - } - return $this->success($msg, [], 1, 1); - } - - - /** - * @notes 重新退款 - * @return \think\response\Json - * @author 段誉 - * @date 2023/2/28 19:17 - */ - public function refundAgain() - { - $params = (new RechargeRefundValidate())->post()->goCheck('again'); - $result = RechargeLogic::refundAgain($params, $this->adminId); - list($flag, $msg) = $result; - if(false === $flag) { - return $this->fail($msg); - } - return $this->success($msg, [], 1, 1); - } - -} \ No newline at end of file diff --git a/app/adminapi/controller/setting/HotSearchController.php b/app/adminapi/controller/setting/HotSearchController.php deleted file mode 100644 index 772c457b0..000000000 --- a/app/adminapi/controller/setting/HotSearchController.php +++ /dev/null @@ -1,56 +0,0 @@ -data($result); - } - - - /** - * @notes 设置热门搜索 - * @return \think\response\Json - * @author 段誉 - * @date 2022/9/5 19:00 - */ - public function setConfig() - { - $params = $this->request->post(); - $result = HotSearchLogic::setConfig($params); - if (false === $result) { - return $this->fail(HotSearchLogic::getError() ?: '系统错误'); - } - return $this->success('设置成功', [], 1, 1); - } -} \ No newline at end of file diff --git a/app/adminapi/controller/setting/TransactionSettingsController.php b/app/adminapi/controller/setting/TransactionSettingsController.php deleted file mode 100644 index 406a6f22f..000000000 --- a/app/adminapi/controller/setting/TransactionSettingsController.php +++ /dev/null @@ -1,53 +0,0 @@ -data($result); - } - - /** - * @notes 设置交易设置 - * @return \think\response\Json - * @author ljj - * @date 2022/2/15 11:50 上午 - */ - public function setConfig() - { - $params = (new TransactionSettingsValidate())->post()->goCheck('setConfig'); - TransactionSettingsLogic::setConfig($params); - return $this->success('操作成功',[],1,1); - } -} \ No newline at end of file diff --git a/app/adminapi/controller/setting/pay/PayConfigController.php b/app/adminapi/controller/setting/pay/PayConfigController.php deleted file mode 100644 index 32df53baa..000000000 --- a/app/adminapi/controller/setting/pay/PayConfigController.php +++ /dev/null @@ -1,70 +0,0 @@ -post()->goCheck(); - PayConfigLogic::setConfig($params); - return $this->success('设置成功', [], 1, 1); - } - - - /** - * @notes 获取支付配置 - * @return \think\response\Json - * @author 段誉 - * @date 2023/2/23 16:14 - */ - public function getConfig() - { - $id = (new PayConfigValidate())->goCheck('get'); - $result = PayConfigLogic::getConfig($id); - return $this->success('获取成功', $result); - } - - - /** - * @notes - * @return \think\response\Json - * @author 段誉 - * @date 2023/2/23 16:15 - */ - public function lists() - { - return $this->dataLists(new PayConfigLists()); - } -} \ No newline at end of file diff --git a/app/adminapi/controller/setting/pay/PayWayController.php b/app/adminapi/controller/setting/pay/PayWayController.php deleted file mode 100644 index e2e91475c..000000000 --- a/app/adminapi/controller/setting/pay/PayWayController.php +++ /dev/null @@ -1,61 +0,0 @@ -success('获取成功',$result); - } - - - /** - * @notes 设置支付方式 - * @return \think\response\Json - * @throws \Exception - * @author 段誉 - * @date 2023/2/23 16:27 - */ - public function setPayWay() - { - $params = $this->request->post(); - $result = (new PayWayLogic())->setPayWay($params); - if (true !== $result) { - return $this->fail($result); - } - return $this->success('操作成功',[],1, 1); - } -} \ No newline at end of file diff --git a/app/adminapi/controller/user/UserController.php b/app/adminapi/controller/user/UserController.php index 41d2b4eda..f79b23820 100644 --- a/app/adminapi/controller/user/UserController.php +++ b/app/adminapi/controller/user/UserController.php @@ -67,20 +67,4 @@ class UserController extends BaseAdminController } - /** - * @notes 调整用户余额 - * @return \think\response\Json - * @author 段誉 - * @date 2023/2/23 14:33 - */ - public function adjustMoney() - { - $params = (new AdjustUserMoney())->post()->goCheck(); - $res = UserLogic::adjustUserMoney($params); - if (true === $res) { - return $this->success('操作成功', [], 1, 1); - } - return $this->fail($res); - } - } \ No newline at end of file diff --git a/app/adminapi/lists/decorate/NavigationLists.php b/app/adminapi/lists/decorate/NavigationLists.php deleted file mode 100644 index 42abde805..000000000 --- a/app/adminapi/lists/decorate/NavigationLists.php +++ /dev/null @@ -1,52 +0,0 @@ -select()->toArray(); - } - - /** - * @notes 底部导航总数 - * @return int - * @author ljj - * @date 2022/2/14 10:13 上午 - */ - public function count(): int - { - return (new Navigation())->count(); - } -} \ No newline at end of file diff --git a/app/adminapi/lists/finance/AccountLogLists.php b/app/adminapi/lists/finance/AccountLogLists.php deleted file mode 100644 index dd4f44459..000000000 --- a/app/adminapi/lists/finance/AccountLogLists.php +++ /dev/null @@ -1,119 +0,0 @@ - ['al.change_type'], - ]; - } - - - /** - * @notes 搜索条件 - * @author 段誉 - * @date 2023/2/24 15:26 - */ - public function queryWhere() - { - $where = []; - // 用户余额 - if (isset($this->params['type']) && $this->params['type'] == 'um') { - $where[] = ['change_type', 'in', AccountLogEnum::getUserMoneyChangeType()]; - } - - if (!empty($this->params['user_info'])) { - $where[] = ['u.sn|u.nickname|u.mobile', 'like', '%' . $this->params['user_info'] . '%']; - } - - if (!empty($this->params['start_time'])) { - $where[] = ['al.create_time', '>=', strtotime($this->params['start_time'])]; - } - - if (!empty($this->params['end_time'])) { - $where[] = ['al.create_time', '<=', strtotime($this->params['end_time'])]; - } - - return $where; - } - - - /** - * @notes 获取列表 - * @return array - * @author 段誉 - * @date 2023/2/24 15:31 - */ - public function lists(): array - { - $field = 'u.nickname,u.sn,u.avatar,u.mobile,al.action,al.change_amount,al.left_amount,al.change_type,al.source_sn,al.create_time'; - $lists = UserAccountLog::alias('al') - ->join('user u', 'u.id = al.user_id') - ->field($field) - ->where($this->searchWhere) - ->where($this->queryWhere()) - ->order('al.id', 'desc') - ->limit($this->limitOffset, $this->limitLength) - ->select() - ->toArray(); - - foreach ($lists as &$item) { - $item['avatar'] = FileService::getFileUrl($item['avatar']); - $item['change_type_desc'] = AccountLogEnum::getChangeTypeDesc($item['change_type']); - $symbol = $item['action'] == AccountLogEnum::INC ? '+' : '-'; - $item['change_amount'] = $symbol . $item['change_amount']; - } - - return $lists; - } - - - /** - * @notes 获取数量 - * @return int - * @author 段誉 - * @date 2023/2/24 15:36 - */ - public function count(): int - { - return UserAccountLog::alias('al') - ->join('user u', 'u.id = al.user_id') - ->where($this->queryWhere()) - ->where($this->searchWhere) - ->count(); - } -} \ No newline at end of file diff --git a/app/adminapi/lists/finance/RefundLogLists.php b/app/adminapi/lists/finance/RefundLogLists.php deleted file mode 100644 index 2809bab35..000000000 --- a/app/adminapi/lists/finance/RefundLogLists.php +++ /dev/null @@ -1,79 +0,0 @@ -params['record_id'] ?? 0]; - return $where; - } - - - /** - * @notes 获取列表 - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - * @author 段誉 - * @date 2023/3/1 9:56 - */ - public function lists(): array - { - $lists = (new RefundLog()) - ->order(['id' => 'desc']) - ->where($this->queryWhere()) - ->limit($this->limitOffset, $this->limitLength) - ->hidden(['refund_msg']) - ->append(['handler', 'refund_status_text']) - ->select() - ->toArray(); - return $lists; - } - - - /** - * @notes 获取数量 - * @return int - * @author 段誉 - * @date 2023/3/1 9:56 - */ - public function count(): int - { - return (new RefundLog()) - ->where($this->queryWhere()) - ->count(); - } - -} diff --git a/app/adminapi/lists/finance/RefundRecordLists.php b/app/adminapi/lists/finance/RefundRecordLists.php deleted file mode 100644 index c6193aa79..000000000 --- a/app/adminapi/lists/finance/RefundRecordLists.php +++ /dev/null @@ -1,143 +0,0 @@ - ['r.sn', 'r.order_sn', 'r.refund_type'], - ]; - } - - - /** - * @notes 查询条件 - * @param bool $flag - * @return array - * @author 段誉 - * @date 2023/3/1 9:51 - */ - public function queryWhere($flag = true) - { - $where = []; - if (!empty($this->params['user_info'])) { - $where[] = ['u.sn|u.nickname|u.mobile', 'like', '%' . $this->params['user_info'] . '%']; - } - if (!empty($this->params['start_time'])) { - $where[] = ['r.create_time', '>=', strtotime($this->params['start_time'])]; - } - if (!empty($this->params['end_time'])) { - $where[] = ['r.create_time', '<=', strtotime($this->params['end_time'])]; - } - - if ($flag == true) { - if (isset($this->params['refund_status']) && $this->params['refund_status'] != '') { - $where[] = ['r.refund_status', '=', $this->params['refund_status']]; - } - } - - return $where; - } - - - /** - * @notes 获取列表 - * @return array - * @author 段誉 - * @date 2023/3/1 9:51 - */ - public function lists(): array - { - $lists = (new RefundRecord())->alias('r') - ->field('r.*,u.nickname,u.avatar') - ->join('user u', 'u.id = r.user_id') - ->order(['r.id' => 'desc']) - ->where($this->searchWhere) - ->where($this->queryWhere()) - ->limit($this->limitOffset, $this->limitLength) - ->append(['refund_type_text', 'refund_status_text', 'refund_way_text']) - ->select() - ->toArray(); - - foreach ($lists as &$item) { - $item['avatar'] = FileService::getFileUrl($item['avatar']); - } - - return $lists; - } - - - /** - * @notes 获取数量 - * @return int - * @author 段誉 - * @date 2023/3/1 9:51 - */ - public function count(): int - { - return (new RefundRecord())->alias('r') - ->join('user u', 'u.id = r.user_id') - ->where($this->searchWhere) - ->where($this->queryWhere()) - ->count(); - } - - - /** - * @notes 额外参数 - * @return mixed|null - * @author 段誉 - * @date 2023/3/1 9:51 - */ - public function extend() - { - $count = (new RefundRecord())->alias('r') - ->join('user u', 'u.id = r.user_id') - ->field([ - 'count(r.id) as total', - 'count(if(r.refund_status='.RefundEnum::REFUND_ING.', true, null)) as ing', - 'count(if(r.refund_status='.RefundEnum::REFUND_SUCCESS.', true, null)) as success', - 'count(if(r.refund_status='.RefundEnum::REFUND_ERROR.', true, null)) as error', - ]) - ->where($this->searchWhere) - ->where($this->queryWhere(false)) - ->select()->toArray(); - - return array_shift($count); - } -} diff --git a/app/adminapi/lists/recharge/RechargeLists.php b/app/adminapi/lists/recharge/RechargeLists.php deleted file mode 100644 index 32ff94a66..000000000 --- a/app/adminapi/lists/recharge/RechargeLists.php +++ /dev/null @@ -1,145 +0,0 @@ - '充值单号', - 'nickname' => '用户昵称', - 'order_amount' => '充值金额', - 'pay_way' => '支付方式', - 'pay_status' => '支付状态', - 'pay_time' => '支付时间', - 'create_time' => '下单时间', - ]; - } - - - /** - * @notes 导出表名 - * @return string - * @author 段誉 - * @date 2023/2/24 16:07 - */ - public function setFileName(): string - { - return '充值记录'; - } - - - /** - * @notes 搜索条件 - * @return \string[][] - * @author 段誉 - * @date 2023/2/24 16:08 - */ - public function setSearch(): array - { - return [ - '=' => ['ro.sn', 'ro.pay_way', 'ro.pay_status'], - ]; - } - - - /** - * @notes 搜索条件 - * @author 段誉 - * @date 2023/2/24 16:08 - */ - public function queryWhere() - { - $where = []; - // 用户编号 - if (!empty($this->params['user_info'])) { - $where[] = ['u.sn|u.nickname|u.mobile', 'like', '%' . $this->params['user_info'] . '%']; - } - - // 下单时间 - if (!empty($this->params['start_time']) && !empty($this->params['end_time'])) { - $time = [strtotime($this->params['start_time']), strtotime($this->params['end_time'])]; - $where[] = ['ro.create_time', 'between', $time]; - } - - return $where; - } - - - /** - * @notes 获取列表 - * @return array - * @author 段誉 - * @date 2023/2/24 16:13 - */ - public function lists(): array - { - $field = 'ro.id,ro.sn,ro.order_amount,ro.pay_way,ro.pay_time,ro.pay_status,ro.create_time,ro.refund_status'; - $field .= ',u.avatar,u.nickname'; - $lists = RechargeOrder::alias('ro') - ->join('user u', 'u.id = ro.user_id') - ->field($field) - ->where($this->queryWhere()) - ->where($this->searchWhere) - ->order('ro.id', 'desc') - ->limit($this->limitOffset, $this->limitLength) - ->append(['pay_status_text', 'pay_way_text']) - ->select() - ->toArray(); - - foreach ($lists as &$item) { - $item['avatar'] = FileService::getFileUrl($item['avatar']); - $item['pay_time'] = empty($item['pay_time']) ? '' : date('Y-m-d H:i:s', $item['pay_time']); - } - - return $lists; - } - - - /** - * @notes 获取数量 - * @return int - * @author 段誉 - * @date 2023/2/24 16:13 - */ - public function count(): int - { - return RechargeOrder::alias('ro') - ->join('user u', 'u.id = ro.user_id') - ->where($this->queryWhere()) - ->where($this->searchWhere) - ->count(); - } - - -} \ No newline at end of file diff --git a/app/adminapi/lists/setting/pay/PayConfigLists.php b/app/adminapi/lists/setting/pay/PayConfigLists.php deleted file mode 100644 index 6dcca6744..000000000 --- a/app/adminapi/lists/setting/pay/PayConfigLists.php +++ /dev/null @@ -1,62 +0,0 @@ -append(['pay_way_name']) - ->order('sort','asc') - ->select() - ->toArray(); - - return $lists; - } - - - /** - * @notes 获取数量 - * @return int - * @author 段誉 - * @date 2023/2/23 16:15 - */ - public function count(): int - { - return PayConfig::count(); - } - - - -} \ No newline at end of file diff --git a/app/adminapi/logic/finance/RefundLogic.php b/app/adminapi/logic/finance/RefundLogic.php deleted file mode 100644 index e43232553..000000000 --- a/app/adminapi/logic/finance/RefundLogic.php +++ /dev/null @@ -1,95 +0,0 @@ -toArray(); - - $total = 0; - $ing = 0; - $success = 0; - $error = 0; - - foreach ($records as $record) { - $total += $record['order_amount']; - switch ($record['refund_status']) { - case RefundEnum::REFUND_ING: - $ing += $record['order_amount']; - break; - case RefundEnum::REFUND_SUCCESS: - $success += $record['order_amount']; - break; - case RefundEnum::REFUND_ERROR: - $error += $record['order_amount']; - break; - } - } - - return [ - 'total' => round($total, 2), - 'ing' => round($ing, 2), - 'success' => round($success, 2), - 'error' => round($error, 2), - ]; - } - - - /** - * @notes 退款日志 - * @param $recordId - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - * @author 段誉 - * @date 2023/3/3 14:25 - */ - public static function refundLog($recordId) - { - return (new RefundLog()) - ->order(['id' => 'desc']) - ->where('record_id', $recordId) - ->hidden(['refund_msg']) - ->append(['handler', 'refund_status_text']) - ->select() - ->toArray(); - } - -} \ No newline at end of file diff --git a/app/adminapi/logic/recharge/RechargeLogic.php b/app/adminapi/logic/recharge/RechargeLogic.php deleted file mode 100644 index d269dc9b0..000000000 --- a/app/adminapi/logic/recharge/RechargeLogic.php +++ /dev/null @@ -1,186 +0,0 @@ - ConfigService::get('recharge', 'status', 0), - 'min_amount' => ConfigService::get('recharge', 'min_amount', 0) - ]; - - return $config; - } - - - /** - * @notes 充值设置 - * @param $params - * @return bool - * @author 段誉 - * @date 2023/2/22 16:54 - */ - public static function setConfig($params) - { - try { - if (isset($params['status'])) { - ConfigService::set('recharge', 'status', $params['status']); - } - if (isset($params['min_amount'])) { - ConfigService::set('recharge', 'min_amount', $params['min_amount']); - } - return true; - } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; - } - } - - - /** - * @notes 退款 - * @param $params - * @param $adminId - * @return array|false - * @author 段誉 - * @date 2023/3/3 11:42 - */ - public static function refund($params, $adminId) - { - Db::startTrans(); - try { - $order = RechargeOrder::findOrEmpty($params['recharge_id']); - - // 更新订单信息, 标记已发起退款状态,具体退款成功看退款日志 - RechargeOrder::update([ - 'id' => $order['id'], - 'refund_status' => YesNoEnum::YES, - ]); - - // 更新用户余额及累计充值金额 - User::where(['id' => $order['user_id']]) - ->dec('total_recharge_amount', $order['order_amount']) - ->dec('user_money', $order['order_amount']) - ->update(); - - // 记录日志 - AccountLogLogic::add( - $order['user_id'], - AccountLogEnum::UM_INC_ADMIN, - AccountLogEnum::DEC, - $order['order_amount'], - $order['sn'], - '充值订单退款' - ); - - // 生成退款记录 - $recordSn = generate_sn(RefundRecord::class, 'sn'); - $record = RefundRecord::create([ - 'sn' => $recordSn, - 'user_id' => $order['user_id'], - 'order_id' => $order['id'], - 'order_sn' => $order['sn'], - 'order_type' => RefundEnum::ORDER_TYPE_RECHARGE, - 'order_amount' => $order['order_amount'], - 'refund_amount' => $order['order_amount'], - 'refund_type' => RefundEnum::TYPE_ADMIN, - 'transaction_id' => $order['transaction_id'] ?? '', - 'refund_way' => RefundEnum::getRefundWayByPayWay($order['pay_way']), - ]); - - // 退款 - $result = RefundLogic::refund($order, $record['id'], $order['order_amount'], $adminId); - - $flag = true; - $resultMsg = '操作成功'; - if ($result !== true) { - $flag = false; - $resultMsg = RefundLogic::getError(); - } - - Db::commit(); - return [$flag, $resultMsg]; - } catch (\Exception $e) { - Db::rollback(); - self::$error = $e->getMessage(); - return [false, $e->getMessage()]; - } - } - - - /** - * @notes 重新退款 - * @param $params - * @param $adminId - * @return array - * @author 段誉 - * @date 2023/3/3 11:44 - */ - public static function refundAgain($params, $adminId) - { - Db::startTrans(); - try { - $record = RefundRecord::findOrEmpty($params['record_id']); - $order = RechargeOrder::findOrEmpty($record['order_id']); - - // 退款 - $result = RefundLogic::refund($order, $record['id'], $order['order_amount'], $adminId); - - $flag = true; - $resultMsg = '操作成功'; - if ($result !== true) { - $flag = false; - $resultMsg = RefundLogic::getError(); - } - - Db::commit(); - return [$flag, $resultMsg]; - } catch (\Exception $e) { - Db::rollback(); - self::$error = $e->getMessage(); - return [false, $e->getMessage()]; - } - } - -} \ No newline at end of file diff --git a/app/adminapi/logic/setting/HotSearchLogic.php b/app/adminapi/logic/setting/HotSearchLogic.php deleted file mode 100644 index 684cf46ed..000000000 --- a/app/adminapi/logic/setting/HotSearchLogic.php +++ /dev/null @@ -1,75 +0,0 @@ - ConfigService::get('hot_search', 'status', 0), - // 热门搜索数据 - 'data' => HotSearch::field(['name', 'sort'])->order(['sort' => 'desc', 'id' =>'desc'])->select()->toArray(), - ]; - } - - - /** - * @notes 设置热门搜搜 - * @param $params - * @return bool - * @author 段誉 - * @date 2022/9/5 18:58 - */ - public static function setConfig($params) - { - try { - if (!empty($params['data'])) { - $model = (new HotSearch()); - $model->where('id', '>', 0)->delete(); - $model->saveAll($params['data']); - } - - $status = empty($params['status']) ? 0 : $params['status']; - ConfigService::set('hot_search', 'status', $status); - - return true; - } catch (\Exception $e) { - self::$error = $e->getMessage(); - return false; - } - } - - -} \ No newline at end of file diff --git a/app/adminapi/logic/setting/pay/PayConfigLogic.php b/app/adminapi/logic/setting/pay/PayConfigLogic.php deleted file mode 100644 index 8c5241f5c..000000000 --- a/app/adminapi/logic/setting/pay/PayConfigLogic.php +++ /dev/null @@ -1,91 +0,0 @@ - $params['config']['interface_version'], - 'merchant_type' => $params['config']['merchant_type'], - 'mch_id' => $params['config']['mch_id'], - 'pay_sign_key' => $params['config']['pay_sign_key'], - 'apiclient_cert' => $params['config']['apiclient_cert'], - 'apiclient_key' => $params['config']['apiclient_key'], - ]; - } - if ($payConfig['pay_way'] == PayEnum::ALI_PAY) { - $config = [ - 'mode' => $params['config']['mode'], - 'merchant_type' => $params['config']['merchant_type'], - 'app_id' => $params['config']['app_id'], - 'private_key' => $params['config']['private_key'], - 'ali_public_key' => $params['config']['ali_public_key'], - ]; - } - - $payConfig->name = $params['name']; - $payConfig->icon = $params['icon']; - $payConfig->sort = $params['sort']; - $payConfig->config = $config; - $payConfig->remark = $params['remark'] ?? ''; - return $payConfig->save(); - } - - - /** - * @notes 获取配置 - * @param $params - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - * @author 段誉 - * @date 2023/2/23 16:16 - */ - public static function getConfig($params) - { - $payConfig = PayConfig::find($params['id'])->toArray(); - $payConfig['domain'] = request()->domain(); - return $payConfig; - } - -} diff --git a/app/adminapi/logic/setting/pay/PayWayLogic.php b/app/adminapi/logic/setting/pay/PayWayLogic.php deleted file mode 100644 index fe5bd2ba7..000000000 --- a/app/adminapi/logic/setting/pay/PayWayLogic.php +++ /dev/null @@ -1,111 +0,0 @@ -append(['pay_way_name']) - ->toArray(); - - if (empty($payWay)) { - return []; - } - - $lists = []; - for ($i = 1; $i <= max(array_column($payWay, 'scene')); $i++) { - foreach ($payWay as $val) { - if ($val['scene'] == $i) { - $val['icon'] = FileService::getFileUrl(PayConfig::where('id', $val['pay_config_id'])->value('icon')); - $lists[$i][] = $val; - } - } - } - - return $lists; - } - - - /** - * @notes 设置支付方式 - * @param $params - * @return bool|string - * @throws \Exception - * @author 段誉 - * @date 2023/2/23 16:26 - */ - public static function setPayWay($params) - { - $payWay = new PayWay; - $data = []; - foreach ($params as $key => $value) { - $isDefault = array_column($value, 'is_default'); - $isDefaultNum = array_count_values($isDefault); - $status = array_column($value, 'status'); - $sceneName = PayEnum::getPaySceneDesc($key); - if (!in_array(YesNoEnum::YES, $isDefault)) { - return $sceneName . '支付场景缺少默认支付'; - } - if ($isDefaultNum[YesNoEnum::YES] > 1) { - return $sceneName . '支付场景的默认值只能存在一个'; - } - if (!in_array(YesNoEnum::YES, $status)) { - return $sceneName . '支付场景至少开启一个支付状态'; - } - - foreach ($value as $val) { - $result = PayWay::where('id', $val['id'])->findOrEmpty(); - if ($result->isEmpty()) { - continue; - } - if ($val['is_default'] == YesNoEnum::YES && $val['status'] == YesNoEnum::NO) { - return $sceneName . '支付场景的默认支付未开启支付状态'; - } - $data[] = [ - 'id' => $val['id'], - 'is_default' => $val['is_default'], - 'status' => $val['status'], - ]; - } - } - $payWay->saveAll($data); - return true; - } -} - diff --git a/app/adminapi/validate/channel/MnpSettingsValidate.php b/app/adminapi/validate/channel/MnpSettingsValidate.php deleted file mode 100644 index a49bdaaf6..000000000 --- a/app/adminapi/validate/channel/MnpSettingsValidate.php +++ /dev/null @@ -1,36 +0,0 @@ - 'require', - 'app_secret' => 'require', - ]; - - protected $message = [ - 'app_id.require' => '请填写AppID', - 'app_secret.require' => '请填写AppSecret', - ]; -} \ No newline at end of file diff --git a/app/adminapi/validate/channel/WebPageSettingValidate.php b/app/adminapi/validate/channel/WebPageSettingValidate.php deleted file mode 100644 index 3b8f8c0e1..000000000 --- a/app/adminapi/validate/channel/WebPageSettingValidate.php +++ /dev/null @@ -1,33 +0,0 @@ - 'require|in:0,1' - ]; - - protected $message = [ - 'status.require' => '请选择启用状态', - 'status.in' => '启用状态值有误', - ]; -} \ No newline at end of file diff --git a/app/adminapi/validate/decorate/DecoratePageValidate.php b/app/adminapi/validate/decorate/DecoratePageValidate.php deleted file mode 100644 index eee8ee7ec..000000000 --- a/app/adminapi/validate/decorate/DecoratePageValidate.php +++ /dev/null @@ -1,40 +0,0 @@ - 'require', - 'type' => 'require', - 'data' => 'require', - ]; - - - protected $message = [ - 'id.require' => '参数缺失', - 'type.require' => '装修类型参数缺失', - 'data.require' => '装修信息参数缺失', - ]; - -} \ No newline at end of file diff --git a/app/adminapi/validate/recharge/RechargeRefundValidate.php b/app/adminapi/validate/recharge/RechargeRefundValidate.php deleted file mode 100644 index e394ac2ff..000000000 --- a/app/adminapi/validate/recharge/RechargeRefundValidate.php +++ /dev/null @@ -1,122 +0,0 @@ - 'require|checkRecharge', - 'record_id' => 'require|checkRecord', - ]; - - protected $message = [ - 'recharge_id.require' => '参数缺失', - 'record_id.require' => '参数缺失', - ]; - - - public function sceneRefund() - { - return $this->only(['recharge_id']); - } - - - public function sceneAgain() - { - return $this->only(['record_id']); - } - - - /** - * @notes 校验充值订单能否发起退款 - * @param $rechargeId - * @param $rule - * @param $data - * @return bool|string - * @author 段誉 - * @date 2023/2/28 17:00 - */ - protected function checkRecharge($rechargeId, $rule, $data) - { - $order = RechargeOrder::findOrEmpty($rechargeId); - - if ($order->isEmpty()) { - return '充值订单不存在'; - } - - if ($order['pay_status'] != PayEnum::ISPAID) { - return '当前订单不可退款'; - } - - // 校验订单是否已退款 - if ($order['refund_status'] == YesNoEnum::YES) { - return '订单已发起退款,退款失败请到退款记录重新退款'; - } - - // 校验余额 - $user = User::findOrEmpty($order['user_id']); - if ($user['user_money'] < $order['order_amount']) { - return '退款失败:用户余额已不足退款金额'; - } - - return true; - } - - - /** - * @notes 校验退款记录 - * @param $recordId - * @param $rule - * @param $data - * @return bool|string - * @author 段誉 - * @date 2023/3/1 9:40 - */ - protected function checkRecord($recordId, $rule, $data) - { - $record = RefundRecord::findOrEmpty($recordId); - if ($record->isEmpty()) { - return '退款记录不存在'; - } - - if($record['refund_status'] == RefundEnum::REFUND_SUCCESS) { - return '该退款记录已退款成功'; - } - - $order = RechargeOrder::findOrEmpty($record['order_id']); - $user = User::findOrEmpty($record['user_id']); - - if ($user['user_money'] < $order['order_amount']) { - return '退款失败:用户余额已不足退款金额'; - } - - return true; - } - -} \ No newline at end of file diff --git a/app/adminapi/validate/setting/PayConfigValidate.php b/app/adminapi/validate/setting/PayConfigValidate.php deleted file mode 100644 index 8addd780c..000000000 --- a/app/adminapi/validate/setting/PayConfigValidate.php +++ /dev/null @@ -1,128 +0,0 @@ - 'require', - 'name' => 'require|checkName', - 'icon' => 'require', - 'sort' => 'require|number|max:5', - 'config' => 'require|checkConfig', - ]; - - protected $message = [ - 'id.require' => 'id不能为空', - 'name.require' => '支付名称不能为空', - 'icon.require' => '支付图标不能为空', - 'sort.require' => '排序不能为空', - 'sort,number' => '排序必须是纯数字', - 'sort.max' => '排序最大不能超过五位数', - 'config.require' => '支付参数缺失', - ]; - - public function sceneGet() - { - return $this->only(['id']); - } - - - /** - * @notes 校验支付配置记录 - * @param $value - * @param $rule - * @param $data - * @return bool|string - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - * @author 段誉 - * @date 2023/2/23 16:19 - */ - public function checkConfig($config, $rule, $data) - { - $result = PayConfig::where('id', $data['id'])->find(); - if (empty($result)) { - return '支付方式不存在'; - } - - if ($result['pay_way'] == PayEnum::WECHAT_PAY) { - if (empty($config['interface_version'])) { - return '微信支付接口版本不能为空'; - } - if (empty($config['merchant_type'])) { - return '商户类型不能为空'; - } - if (empty($config['mch_id'])) { - return '微信支付商户号不能为空'; - } - if (empty($config['pay_sign_key'])) { - return '商户API密钥不能为空'; - } - if (empty($config['apiclient_cert'])) { - return '微信支付证书不能为空'; - } - if (empty($config['apiclient_key'])) { - return '微信支付证书密钥不能为空'; - } - } - if ($result['pay_way'] == PayEnum::ALI_PAY) { - if (empty($config['mode'])) { - return '模式不能为空'; - } - if (empty($config['merchant_type'])) { - return '商户类型不能为空'; - } - if (empty($config['app_id'])) { - return '应用ID不能为空'; - } - if (empty($config['private_key'])) { - return '应用私钥不能为空'; - } - if (empty($config['ali_public_key'])) { - return '支付宝公钥不能为空'; - } - } - return true; - } - - - /** - * @notes 校验支付名 - * @param $value - * @param $rule - * @param $data - * @return bool|string - * @author 段誉 - * @date 2023/2/23 16:19 - */ - public function checkName($value, $rule, $data) - { - $result = PayConfig::where('name', $value) - ->where('id', '<>', $data['id']) - ->findOrEmpty(); - if (!$result->isEmpty()) { - return '支付名称已存在'; - } - return true; - } -} \ No newline at end of file diff --git a/app/adminapi/validate/setting/TransactionSettingsValidate.php b/app/adminapi/validate/setting/TransactionSettingsValidate.php deleted file mode 100644 index 5c7506264..000000000 --- a/app/adminapi/validate/setting/TransactionSettingsValidate.php +++ /dev/null @@ -1,51 +0,0 @@ - 'require|in:0,1', - 'cancel_unpaid_orders_times' => 'requireIf:cancel_unpaid_orders,1|integer|gt:0', - 'verification_orders' => 'require|in:0,1', - 'verification_orders_times' => 'requireIf:verification_orders,1|integer|gt:0', - ]; - - protected $message = [ - 'cancel_unpaid_orders.require' => '请选择系统取消待付款订单方式', - 'cancel_unpaid_orders.in' => '系统取消待付款订单状态值有误', - 'cancel_unpaid_orders_times.requireIf' => '系统取消待付款订单时间未填写', - 'cancel_unpaid_orders_times.integer' => '系统取消待付款订单时间须为整型', - 'cancel_unpaid_orders_times.gt' => '系统取消待付款订单时间须大于0', - - 'verification_orders.require' => '请选择系统自动核销订单方式', - 'verification_orders.in' => '系统自动核销订单状态值有误', - 'verification_orders_times.requireIf' => '系统自动核销订单时间未填写', - 'verification_orders_times.integer' => '系统自动核销订单时间须为整型', - 'verification_orders_times.gt' => '系统自动核销订单时间须大于0', - ]; - - public function sceneSetConfig() - { - return $this->only(['cancel_unpaid_orders','cancel_unpaid_orders_times','verification_orders','verification_orders_times']); - } -} \ No newline at end of file diff --git a/app/api/config/route.php b/app/api/config/route.php deleted file mode 100644 index e6a26425e..000000000 --- a/app/api/config/route.php +++ /dev/null @@ -1,19 +0,0 @@ - [ - app\api\http\middleware\InitMiddleware::class, // 初始化 - app\api\http\middleware\LoginMiddleware::class, // 登录验证 - ], -]; diff --git a/app/api/controller/AccountLogController.php b/app/api/controller/AccountLogController.php deleted file mode 100644 index 4c61299af..000000000 --- a/app/api/controller/AccountLogController.php +++ /dev/null @@ -1,36 +0,0 @@ -dataLists(new AccountLogLists()); - } -} \ No newline at end of file diff --git a/app/api/controller/ArticleController.php b/app/api/controller/ArticleController.php deleted file mode 100644 index 0e7f7a631..000000000 --- a/app/api/controller/ArticleController.php +++ /dev/null @@ -1,111 +0,0 @@ -dataLists(new ArticleLists()); - } - - - /** - * @notes 文章分类列表 - * @return \think\response\Json - * @author 段誉 - * @date 2022/9/20 15:30 - */ - public function cate() - { - return $this->data(ArticleLogic::cate()); - } - - - /** - * @notes 收藏列表 - * @return \think\response\Json - * @author 段誉 - * @date 2022/9/20 16:31 - */ - public function collect() - { - return $this->dataLists(new ArticleCollectLists()); - } - - - /** - * @notes 文章详情 - * @return \think\response\Json - * @author 段誉 - * @date 2022/9/20 17:09 - */ - public function detail() - { - $id = $this->request->get('id/d'); - $result = ArticleLogic::detail($id, $this->userId); - return $this->data($result); - } - - - /** - * @notes 加入收藏 - * @return \think\response\Json - * @author 段誉 - * @date 2022/9/20 17:01 - */ - public function addCollect() - { - $articleId = $this->request->post('id/d'); - ArticleLogic::addCollect($articleId, $this->userId); - return $this->success('操作成功'); - } - - - /** - * @notes 取消收藏 - * @return \think\response\Json - * @author 段誉 - * @date 2022/9/20 17:01 - */ - public function cancelCollect() - { - $articleId = $this->request->post('id/d'); - ArticleLogic::cancelCollect($articleId, $this->userId); - return $this->success('操作成功'); - } - - -} \ No newline at end of file diff --git a/app/api/controller/BaseApiController.php b/app/api/controller/BaseApiController.php deleted file mode 100644 index 365105865..000000000 --- a/app/api/controller/BaseApiController.php +++ /dev/null @@ -1,31 +0,0 @@ -request->userInfo) && $this->request->userInfo) { - $this->userInfo = $this->request->userInfo; - $this->userId = $this->request->userInfo['user_id']; - } - } -} \ No newline at end of file diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php deleted file mode 100644 index c9954803b..000000000 --- a/app/api/controller/IndexController.php +++ /dev/null @@ -1,94 +0,0 @@ -data($result); - } - - - /** - * @notes 全局配置 - * @return Json - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - * @author 段誉 - * @date 2022/9/21 19:41 - */ - public function config() - { - $result = IndexLogic::getConfigData(); - return $this->data($result); - } - - - /** - * @notes 政策协议 - * @return Json - * @author 段誉 - * @date 2022/9/20 20:00 - */ - public function policy() - { - $type = $this->request->get('type/s', ''); - $result = IndexLogic::getPolicyByType($type); - return $this->data($result); - } - - - /** - * @notes 装修信息 - * @return Json - * @author 段誉 - * @date 2022/9/21 18:37 - */ - public function decorate() - { - $id = $this->request->get('id/d'); - $result = IndexLogic::getDecorate($id); - return $this->data($result); - } - - -} \ No newline at end of file diff --git a/app/api/controller/LoginController.php b/app/api/controller/LoginController.php deleted file mode 100644 index a71445b18..000000000 --- a/app/api/controller/LoginController.php +++ /dev/null @@ -1,216 +0,0 @@ -post()->goCheck('register'); - $result = LoginLogic::register($params); - if (true === $result) { - return $this->success('注册成功', [], 1, 1); - } - return $this->fail(LoginLogic::getError()); - } - - - /** - * @notes 账号密码/手机号密码/手机号验证码登录 - * @return \think\response\Json - * @author 段誉 - * @date 2022/9/16 10:42 - */ - public function account() - { - $params = (new LoginAccountValidate())->post()->goCheck(); - $result = LoginLogic::login($params); - if (false === $result) { - return $this->fail(LoginLogic::getError()); - } - return $this->data($result); - } - - - /** - * @notes 退出登录 - * @return \think\response\Json - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - * @author 段誉 - * @date 2022/9/16 10:42 - */ - public function logout() - { - LoginLogic::logout($this->userInfo); - return $this->success(); - } - - - /** - * @notes 获取微信请求code的链接 - * @return \think\response\Json - * @author 段誉 - * @date 2022/9/15 18:27 - */ - public function codeUrl() - { - $url = $this->request->get('url'); - $result = ['url' => LoginLogic::codeUrl($url)]; - return $this->success('获取成功', $result); - } - - - /** - * @notes 公众号登录 - * @return \think\response\Json - * @throws \GuzzleHttp\Exception\GuzzleException - * @author 段誉 - * @date 2022/9/20 19:48 - */ - public function oaLogin() - { - $params = (new WechatLoginValidate())->post()->goCheck('oa'); - $res = LoginLogic::oaLogin($params); - if (false === $res) { - return $this->fail(LoginLogic::getError()); - } - return $this->success('', $res); - } - - - /** - * @notes 小程序-登录接口 - * @return \think\response\Json - * @author 段誉 - * @date 2022/9/20 19:48 - */ - public function mnpLogin() - { - $params = (new WechatLoginValidate())->post()->goCheck('mnpLogin'); - $res = LoginLogic::mnpLogin($params); - if (false === $res) { - return $this->fail(LoginLogic::getError()); - } - return $this->success('', $res); - } - - - /** - * @notes 小程序绑定微信 - * @return \think\response\Json - * @author 段誉 - * @date 2022/9/20 19:48 - */ - public function mnpAuthBind() - { - $params = (new WechatLoginValidate())->post()->goCheck("wechatAuth"); - $params['user_id'] = $this->userId; - $result = LoginLogic::mnpAuthLogin($params); - if ($result === false) { - return $this->fail(LoginLogic::getError()); - } - return $this->success('绑定成功', [], 1, 1); - } - - - - /** - * @notes 公众号绑定微信 - * @return \think\response\Json - * @throws \GuzzleHttp\Exception\GuzzleException - * @author 段誉 - * @date 2022/9/20 19:48 - */ - public function oaAuthBind() - { - $params = (new WechatLoginValidate())->post()->goCheck("wechatAuth"); - $params['user_id'] = $this->userId; - $result = LoginLogic::oaAuthLogin($params); - if ($result === false) { - return $this->fail(LoginLogic::getError()); - } - return $this->success('绑定成功', [], 1, 1); - } - - - /** - * @notes 获取扫码地址 - * @return \think\response\Json - * @author 段誉 - * @date 2022/10/20 18:25 - */ - public function getScanCode() - { - $redirectUri = $this->request->get('url/s'); - $result = LoginLogic::getScanCode($redirectUri); - if (false === $result) { - return $this->fail(LoginLogic::getError() ?? '未知错误'); - } - return $this->success('', $result); - } - - - /** - * @notes 网站扫码登录 - * @return \think\response\Json - * @author 段誉 - * @date 2022/10/21 10:28 - */ - public function scanLogin() - { - $params = (new WebScanLoginValidate())->post()->goCheck(); - $result = LoginLogic::scanLogin($params); - if (false === $result) { - return $this->fail(LoginLogic::getError() ?? '登录失败'); - } - return $this->success('', $result); - } - - - /** - * @notes 更新用户头像昵称 - * @return \think\response\Json - * @author 段誉 - * @date 2023/2/22 11:15 - */ - public function updateUser() - { - $params = (new WechatLoginValidate())->post()->goCheck("updateUser"); - LoginLogic::updateUser($params, $this->userId); - return $this->success('操作成功', [], 1, 1); - } - - -} \ No newline at end of file diff --git a/app/api/controller/PayController.php b/app/api/controller/PayController.php deleted file mode 100644 index 08288e112..000000000 --- a/app/api/controller/PayController.php +++ /dev/null @@ -1,123 +0,0 @@ -goCheck('payway'); - $result = PaymentLogic::getPayWay($this->userId, $this->userInfo['terminal'], $params); - if ($result === false) { - return $this->fail(PaymentLogic::getError()); - } - return $this->data($result); - } - - - /** - * @notes 预支付 - * @return \think\response\Json - * @author 段誉 - * @date 2023/2/28 14:21 - */ - public function prepay() - { - $params = (new PayValidate())->post()->goCheck(); - //订单信息 - $order = PaymentLogic::getPayOrderInfo($params); - if (false === $order) { - return $this->fail(PaymentLogic::getError(), $params); - } - //支付流程 - $redirectUrl = $params['redirect'] ?? '/pages/payment/payment'; - $result = PaymentLogic::pay($params['pay_way'], $params['from'], $order, $this->userInfo['terminal'], $redirectUrl); - if (false === $result) { - return $this->fail(PaymentLogic::getError(), $params); - } - return $this->success('', $result); - } - - - /** - * @notes 获取支付状态 - * @return \think\response\Json - * @author 段誉 - * @date 2023/3/1 16:23 - */ - public function payStatus() - { - $params = (new PayValidate())->goCheck('status', ['user_id' => $this->userId]); - $result = PaymentLogic::getPayStatus($params); - if ($result === false) { - return $this->fail(PaymentLogic::getError()); - } - return $this->data($result); - } - - - /** - * @notes 小程序支付回调 - * @return \Psr\Http\Message\ResponseInterface - * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException - * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException - * @throws \ReflectionException - * @throws \Throwable - * @author 段誉 - * @date 2023/2/28 14:21 - */ - public function notifyMnp() - { - return (new WeChatPayService(UserTerminalEnum::WECHAT_MMP))->notify(); - } - - - /** - * @notes 公众号支付回调 - * @return \Psr\Http\Message\ResponseInterface - * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException - * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException - * @throws \ReflectionException - * @throws \Throwable - * @author 段誉 - * @date 2023/2/28 14:21 - */ - public function notifyOa() - { - return (new WeChatPayService(UserTerminalEnum::WECHAT_OA))->notify(); - } - - -} diff --git a/app/api/controller/PcController.php b/app/api/controller/PcController.php deleted file mode 100644 index e43453a96..000000000 --- a/app/api/controller/PcController.php +++ /dev/null @@ -1,95 +0,0 @@ -data($result); - } - - - /** - * @notes 全局配置 - * @return Json - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - * @author 段誉 - * @date 2022/9/21 19:41 - */ - public function config() - { - $result = PcLogic::getConfigData(); - return $this->data($result); - } - - - /** - * @notes 资讯中心 - * @return Json - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - * @author 段誉 - * @date 2022/10/19 16:55 - */ - public function infoCenter() - { - $result = PcLogic::getInfoCenter(); - return $this->data($result); - } - - - /** - * @notes 获取文章详情 - * @return Json - * @author 段誉 - * @date 2022/10/20 15:18 - */ - public function articleDetail() - { - $id = $this->request->get('id/d', 0); - $source = $this->request->get('source/s', 'default'); - $result = PcLogic::getArticleDetail($this->userId, $id, $source); - return $this->data($result); - } - -} \ No newline at end of file diff --git a/app/api/controller/RechargeController.php b/app/api/controller/RechargeController.php deleted file mode 100644 index b63c35f44..000000000 --- a/app/api/controller/RechargeController.php +++ /dev/null @@ -1,73 +0,0 @@ -dataLists(new RechargeLists()); - } - - - /** - * @notes 充值 - * @return \think\response\Json - * @author 段誉 - * @date 2023/2/23 18:56 - */ - public function recharge() - { - $params = (new RechargeValidate())->post()->goCheck('recharge', [ - 'user_id' => $this->userId, - 'terminal' => $this->userInfo['terminal'], - ]); - $result = RechargeLogic::recharge($params); - if (false === $result) { - return $this->fail(RechargeLogic::getError()); - } - return $this->data($result); - } - - - /** - * @notes 充值配置 - * @return \think\response\Json - * @author 段誉 - * @date 2023/2/24 16:56 - */ - public function config() - { - return $this->data(RechargeLogic::config($this->userId)); - } - - -} \ No newline at end of file diff --git a/app/api/controller/SearchController.php b/app/api/controller/SearchController.php deleted file mode 100644 index 3932f7677..000000000 --- a/app/api/controller/SearchController.php +++ /dev/null @@ -1,41 +0,0 @@ -data(SearchLogic::hotLists()); - } - -} \ No newline at end of file diff --git a/app/api/controller/SmsController.php b/app/api/controller/SmsController.php deleted file mode 100644 index 00e7905b1..000000000 --- a/app/api/controller/SmsController.php +++ /dev/null @@ -1,49 +0,0 @@ -post()->goCheck(); - $result = SmsLogic::sendCode($params); - if (true === $result) { - return $this->success('发送成功'); - } - return $this->fail(SmsLogic::getError()); - } - -} \ No newline at end of file diff --git a/app/api/controller/UploadController.php b/app/api/controller/UploadController.php deleted file mode 100644 index ea2a31516..000000000 --- a/app/api/controller/UploadController.php +++ /dev/null @@ -1,48 +0,0 @@ -userId,FileEnum::SOURCE_USER); - return $this->success('上传成功', $result); - } catch (Exception $e) { - return $this->fail($e->getMessage()); - } - } - - - -} \ No newline at end of file diff --git a/app/api/controller/UserController.php b/app/api/controller/UserController.php deleted file mode 100644 index 53dea7b8e..000000000 --- a/app/api/controller/UserController.php +++ /dev/null @@ -1,147 +0,0 @@ -userInfo); - return $this->success('', $data); - } - - - /** - * @notes 获取个人信息 - * @return \think\response\Json - * @author 段誉 - * @date 2022/9/20 19:46 - */ - public function info() - { - $result = UserLogic::info($this->userId); - return $this->data($result); - } - - - /** - * @notes 重置密码 - * @return \think\response\Json - * @author 段誉 - * @date 2022/9/16 18:06 - */ - public function resetPassword() - { - $params = (new PasswordValidate())->post()->goCheck('resetPassword'); - $result = UserLogic::resetPassword($params); - if (true === $result) { - return $this->success('操作成功', [], 1, 1); - } - return $this->fail(UserLogic::getError()); - } - - - /** - * @notes 修改密码 - * @return \think\response\Json - * @author 段誉 - * @date 2022/9/20 19:16 - */ - public function changePassword() - { - $params = (new PasswordValidate())->post()->goCheck('changePassword'); - $result = UserLogic::changePassword($params, $this->userId); - if (true === $result) { - return $this->success('操作成功', [], 1, 1); - } - return $this->fail(UserLogic::getError()); - } - - - /** - * @notes 获取小程序手机号 - * @return \think\response\Json - * @author 段誉 - * @date 2022/9/21 16:46 - */ - public function getMobileByMnp() - { - $params = (new UserValidate())->post()->goCheck('getMobileByMnp'); - $params['user_id'] = $this->userId; - $result = UserLogic::getMobileByMnp($params); - if ($result === false) { - return $this->fail(UserLogic::getError()); - } - return $this->success('绑定成功', [], 1, 1); - } - - - /** - * @notes 编辑用户信息 - * @return \think\response\Json - * @author 段誉 - * @date 2022/9/21 17:01 - */ - public function setInfo() - { - $params = (new SetUserInfoValidate())->post()->goCheck(null, ['id' => $this->userId]); - $result = UserLogic::setInfo($this->userId, $params); - if (false === $result) { - return $this->fail(UserLogic::getError()); - } - return $this->success('操作成功', [], 1, 1); - } - - - /** - * @notes 绑定/变更 手机号 - * @return \think\response\Json - * @author 段誉 - * @date 2022/9/21 17:29 - */ - public function bindMobile() - { - $params = (new UserValidate())->post()->goCheck('bindMobile'); - $params['user_id'] = $this->userId; - $result = UserLogic::bindMobile($params); - if($result) { - return $this->success('绑定成功', [], 1, 1); - } - return $this->fail(UserLogic::getError()); - } - -} \ No newline at end of file diff --git a/app/api/controller/WechatController.php b/app/api/controller/WechatController.php deleted file mode 100644 index fad89d320..000000000 --- a/app/api/controller/WechatController.php +++ /dev/null @@ -1,46 +0,0 @@ -goCheck('jsConfig'); - $result = WechatLogic::jsConfig($params); - if ($result === false) { - return $this->fail(WechatLogic::getError(), [], 0, 0); - } - return $this->data($result); - } -} \ No newline at end of file diff --git a/app/api/http/middleware/InitMiddleware.php b/app/api/http/middleware/InitMiddleware.php deleted file mode 100644 index f49d22f8d..000000000 --- a/app/api/http/middleware/InitMiddleware.php +++ /dev/null @@ -1,56 +0,0 @@ -controller()); - $controller = '\\app\\api\\controller\\' . $controller . 'Controller'; - $controllerClass = invoke($controller); - if (($controllerClass instanceof BaseApiController) === false) { - throw new ControllerExtendException($controller, '404'); - } - } catch (ClassNotFoundException $e) { - throw new HttpException(404, 'controller not exists:' . $e->getClass()); - } - //创建控制器对象 - $request->controllerObject = invoke($controller); - - return $next($request); - } - -} \ No newline at end of file diff --git a/app/api/http/middleware/LoginMiddleware.php b/app/api/http/middleware/LoginMiddleware.php deleted file mode 100644 index bf69da415..000000000 --- a/app/api/http/middleware/LoginMiddleware.php +++ /dev/null @@ -1,74 +0,0 @@ -header('token'); - //判断接口是否免登录 - $isNotNeedLogin = $request->controllerObject->isNotNeedLogin(); - - //不直接判断$isNotNeedLogin结果,使不需要登录的接口通过,为了兼容某些接口可以登录或不登录访问 - if (empty($token) && !$isNotNeedLogin) { - //没有token并且该地址需要登录才能访问, 指定show为0,前端不弹出此报错 - return JsonService::fail('请求参数缺token', [], 0, 0); - } - - $userInfo = (new UserTokenCache())->getUserInfo($token); - - if (empty($userInfo) && !$isNotNeedLogin) { - //token过期无效并且该地址需要登录才能访问 - return JsonService::fail('登录超时,请重新登录', [], -1, 0); - } - - //token临近过期,自动续期 - if ($userInfo) { - //获取临近过期自动续期时长 - $beExpireDuration = Config::get('project.user_token.be_expire_duration'); - //token续期 - if (time() > ($userInfo['expire_time'] - $beExpireDuration)) { - $result = UserTokenService::overtimeToken($token); - //续期失败(数据表被删除导致) - if (empty($result)) { - return JsonService::fail('登录过期', [], -1); - } - } - } - - //给request赋值,用于控制器 - $request->userInfo = $userInfo; - $request->userId = $userInfo['user_id'] ?? 0; - - return $next($request); - } - -} \ No newline at end of file diff --git a/app/api/lists/AccountLogLists.php b/app/api/lists/AccountLogLists.php deleted file mode 100644 index 3109fafe3..000000000 --- a/app/api/lists/AccountLogLists.php +++ /dev/null @@ -1,93 +0,0 @@ -userId]; - - // 用户月明细 - if (isset($this->params['type']) && $this->params['type'] == 'um') { - $where[] = ['change_type', 'in', AccountLogEnum::getUserMoneyChangeType()]; - } - - // 变动类型 - if (!empty($this->params['action'])) { - $where[] = ['action', '=', $this->params['action']]; - } - - return $where; - } - - - /** - * @notes 获取列表 - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - * @author 段誉 - * @date 2023/2/24 14:43 - */ - public function lists(): array - { - $field = 'change_type,change_amount,action,create_time,remark'; - $lists = UserAccountLog::field($field) - ->where($this->queryWhere()) - ->order('id', 'desc') - ->limit($this->limitOffset, $this->limitLength) - ->select() - ->toArray(); - - foreach ($lists as &$item) { - $item['type_desc'] = AccountLogEnum::getChangeTypeDesc($item['change_type']); - $symbol = $item['action'] == AccountLogEnum::DEC ? '-' : '+'; - $item['change_amount_desc'] = $symbol . $item['change_amount']; - } - - return $lists; - } - - - /** - * @notes 获取数量 - * @return int - * @author 段誉 - * @date 2023/2/24 14:44 - */ - public function count(): int - { - return UserAccountLog::where($this->queryWhere())->count(); - } -} \ No newline at end of file diff --git a/app/api/lists/BaseApiDataLists.php b/app/api/lists/BaseApiDataLists.php deleted file mode 100644 index ff7699115..000000000 --- a/app/api/lists/BaseApiDataLists.php +++ /dev/null @@ -1,37 +0,0 @@ -request->userInfo) && $this->request->userInfo) { - $this->userInfo = $this->request->userInfo; - $this->userId = $this->request->userId; - } - $this->export = $this->request->get('export', ''); - } - - -} \ No newline at end of file diff --git a/app/api/lists/article/ArticleCollectLists.php b/app/api/lists/article/ArticleCollectLists.php deleted file mode 100644 index 87fe5b2f4..000000000 --- a/app/api/lists/article/ArticleCollectLists.php +++ /dev/null @@ -1,79 +0,0 @@ -alias('a') - ->join('article_collect c', 'c.article_id = a.id') - ->field($field) - ->where([ - 'c.user_id' => $this->userId, - 'c.status' => YesNoEnum::YES, - 'a.is_show' => YesNoEnum::YES, - ]) - ->order(['sort' => 'desc', 'c.id' => 'desc']) - ->limit($this->limitOffset, $this->limitLength) - ->append(['click']) - ->hidden(['click_virtual', 'click_actual']) - ->select()->toArray(); - - foreach ($lists as &$item) { - $item['collect_time'] = date('Y-m-d H:i', $item['collect_time']); - } - - return $lists; - } - - - /** - * @notes 获取收藏数量 - * @return int - * @author 段誉 - * @date 2022/9/20 16:29 - */ - public function count(): int - { - return (new Article())->alias('a') - ->join('article_collect c', 'c.article_id = a.id') - ->where([ - 'c.user_id' => $this->userId, - 'c.status' => YesNoEnum::YES, - 'a.is_show' => YesNoEnum::YES, - ]) - ->count(); - } -} \ No newline at end of file diff --git a/app/api/lists/article/ArticleLists.php b/app/api/lists/article/ArticleLists.php deleted file mode 100644 index d27539333..000000000 --- a/app/api/lists/article/ArticleLists.php +++ /dev/null @@ -1,120 +0,0 @@ - ['cid'] - ]; - } - - - /** - * @notes 自定查询条件 - * @return array - * @author 段誉 - * @date 2022/10/25 16:53 - */ - public function queryWhere() - { - $where[] = ['is_show', '=', 1]; - if (!empty($this->params['keyword'])) { - $where[] = ['title', 'like', '%' . $this->params['keyword'] . '%']; - } - return $where; - } - - - /** - * @notes 获取文章列表 - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - * @author 段誉 - * @date 2022/9/16 18:55 - */ - public function lists(): array - { - $orderRaw = 'sort desc, id desc'; - $sortType = $this->params['sort'] ?? 'default'; - // 最新排序 - if ($sortType == 'new') { - $orderRaw = 'id desc'; - } - // 最热排序 - if ($sortType == 'hot') { - $orderRaw = 'click_actual + click_virtual desc, id desc'; - } - - $field = 'id,cid,title,desc,image,click_virtual,click_actual,create_time'; - $result = Article::field($field) - ->where($this->queryWhere()) - ->where($this->searchWhere) - ->orderRaw($orderRaw) - ->append(['click']) - ->hidden(['click_virtual', 'click_actual']) - ->limit($this->limitOffset, $this->limitLength) - ->select()->toArray(); - - $articleIds = array_column($result, 'id'); - - $collectIds = ArticleCollect::where(['user_id' => $this->userId, 'status' => YesNoEnum::YES]) - ->whereIn('article_id', $articleIds) - ->column('article_id'); - - foreach ($result as &$item) { - $item['collect'] = in_array($item['id'], $collectIds); - } - - return $result; - } - - - /** - * @notes 获取文章数量 - * @return int - * @author 段誉 - * @date 2022/9/16 18:55 - */ - public function count(): int - { - return Article::where($this->searchWhere) - ->where($this->queryWhere()) - ->count(); - } -} \ No newline at end of file diff --git a/app/api/lists/recharge/RechargeLists.php b/app/api/lists/recharge/RechargeLists.php deleted file mode 100644 index 7ebb7099c..000000000 --- a/app/api/lists/recharge/RechargeLists.php +++ /dev/null @@ -1,72 +0,0 @@ -where([ - 'user_id' => $this->userId, - 'pay_status' => PayEnum::ISPAID - ]) - ->order('id', 'desc') - ->select() - ->toArray(); - - foreach($lists as &$item) { - $item['tips'] = '充值' . format_amount($item['order_amount']) . '元'; - } - - return $lists; - } - - - /** - * @notes 获取数量 - * @return int - * @author 段誉 - * @date 2023/2/23 18:43 - */ - public function count(): int - { - return RechargeOrder::where([ - 'user_id' => $this->userId, - 'pay_status' => PayEnum::ISPAID - ]) - ->count(); - } - -} \ No newline at end of file diff --git a/app/api/logic/ArticleLogic.php b/app/api/logic/ArticleLogic.php deleted file mode 100644 index 693fa54de..000000000 --- a/app/api/logic/ArticleLogic.php +++ /dev/null @@ -1,111 +0,0 @@ - $userId, 'article_id' => $articleId]; - $collect = ArticleCollect::where($where)->findOrEmpty(); - if ($collect->isEmpty()) { - ArticleCollect::create([ - 'user_id' => $userId, - 'article_id' => $articleId, - 'status' => YesNoEnum::YES - ]); - } else { - ArticleCollect::update([ - 'id' => $collect['id'], - 'status' => YesNoEnum::YES - ]); - } - } - - - /** - * @notes 取消收藏 - * @param $articleId - * @param $userId - * @author 段誉 - * @date 2022/9/20 16:59 - */ - public static function cancelCollect($articleId, $userId) - { - ArticleCollect::update(['status' => YesNoEnum::NO], [ - 'user_id' => $userId, - 'article_id' => $articleId, - 'status' => YesNoEnum::YES - ]); - } - - - /** - * @notes 文章分类 - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - * @author 段誉 - * @date 2022/9/23 14:11 - */ - public static function cate() - { - return ArticleCate::field('id,name') - ->where('is_show', '=', 1) - ->order(['sort' => 'desc', 'id' => 'desc']) - ->select()->toArray(); - } - -} \ No newline at end of file diff --git a/app/api/logic/IndexLogic.php b/app/api/logic/IndexLogic.php deleted file mode 100644 index 6a9c215eb..000000000 --- a/app/api/logic/IndexLogic.php +++ /dev/null @@ -1,155 +0,0 @@ -where(['is_show' => 1]) - ->order(['id' => 'desc']) - ->limit(20)->append(['click']) - ->hidden(['click_actual', 'click_virtual']) - ->select()->toArray(); - - return [ - 'page' => $decoratePage, - 'article' => $article - ]; - } - - - /** - * @notes 获取政策协议 - * @param string $type - * @return array - * @author 段誉 - * @date 2022/9/20 20:00 - */ - public static function getPolicyByType(string $type) - { - return [ - 'title' => ConfigService::get('agreement', $type . '_title', ''), - 'content' => ConfigService::get('agreement', $type . '_content', ''), - ]; - } - - - /** - * @notes 装修信息 - * @param $id - * @return array - * @author 段誉 - * @date 2022/9/21 18:37 - */ - public static function getDecorate($id) - { - return DecoratePage::field(['type', 'name', 'data']) - ->findOrEmpty($id)->toArray(); - } - - - /** - * @notes 获取配置 - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - * @author 段誉 - * @date 2022/9/21 19:38 - */ - public static function getConfigData() - { - // 底部导航 - $tabbar = DecorateTabbar::getTabbarLists(); - // 导航颜色 - $style = ConfigService::get('tabbar', 'style', config('project.decorate.tabbar_style')); - // 登录配置 - $loginConfig = [ - // 登录方式 - 'login_way' => ConfigService::get('login', 'login_way', config('project.login.login_way')), - // 注册强制绑定手机 - 'coerce_mobile' => ConfigService::get('login', 'coerce_mobile', config('project.login.coerce_mobile')), - // 政策协议 - 'login_agreement' => ConfigService::get('login', 'login_agreement', config('project.login.login_agreement')), - // 第三方登录 开关 - 'third_auth' => ConfigService::get('login', 'third_auth', config('project.login.third_auth')), - // 微信授权登录 - 'wechat_auth' => ConfigService::get('login', 'wechat_auth', config('project.login.wechat_auth')), - // qq授权登录 - 'qq_auth' => ConfigService::get('login', 'qq_auth', config('project.login.qq_auth')), - ]; - // 网址信息 - $website = [ - 'shop_name' => ConfigService::get('website', 'shop_name'), - 'shop_logo' => FileService::getFileUrl(ConfigService::get('website', 'shop_logo')), - ]; - // H5配置 - $webPage = [ - // 渠道状态 0-关闭 1-开启 - 'status' => ConfigService::get('web_page', 'status', 1), - // 关闭后渠道后访问页面 0-空页面 1-自定义链接 - 'page_status' => ConfigService::get('web_page', 'page_status', 0), - // 自定义链接 - 'page_url' => ConfigService::get('web_page', 'page_url', ''), - 'url' => request()->domain() . '/mobile' - ]; - - return [ - 'domain' => FileService::getFileUrl(), - 'style' => $style, - 'tabbar' => $tabbar, - 'login' => $loginConfig, - 'website' => $website, - 'webPage' => $webPage, - 'version'=> config('project.version') - ]; - } - -} \ No newline at end of file diff --git a/app/api/logic/LoginLogic.php b/app/api/logic/LoginLogic.php deleted file mode 100644 index 1a9263bf0..000000000 --- a/app/api/logic/LoginLogic.php +++ /dev/null @@ -1,433 +0,0 @@ - $userSn, - 'avatar' => $avatar, - 'nickname' => '用户' . $userSn, - 'account' => $params['account'], - 'password' => $password, - 'channel' => $params['channel'], - ]); - - return true; - } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; - } - } - - - /** - * @notes 账号/手机号登录,手机号验证码 - * @param $params - * @return array|false - * @author 段誉 - * @date 2022/9/6 19:26 - */ - public static function login($params) - { - try { - // 账号/手机号 密码登录 - $where = ['account|mobile' => $params['account']]; - if ($params['scene'] == LoginEnum::MOBILE_CAPTCHA) { - //手机验证码登录 - $where = ['mobile' => $params['account']]; - } - - $user = User::where($where)->findOrEmpty(); - if ($user->isEmpty()) { - throw new \Exception('用户不存在'); - } - - //更新登录信息 - $user->login_time = time(); - $user->login_ip = request()->ip(); - $user->save(); - - //设置token - $userInfo = UserTokenService::setToken($user->id, $params['terminal']); - - //返回登录信息 - $avatar = $user->avatar ?: Config::get('project.default_image.user_avatar'); - $avatar = FileService::getFileUrl($avatar); - - return [ - 'nickname' => $userInfo['nickname'], - 'sn' => $userInfo['sn'], - 'mobile' => $userInfo['mobile'], - 'avatar' => $avatar, - 'token' => $userInfo['token'], - ]; - } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; - } - } - - - /** - * @notes 退出登录 - * @param $userInfo - * @return bool - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - * @author 段誉 - * @date 2022/9/16 17:56 - */ - public static function logout($userInfo) - { - //token不存在,不注销 - if (!isset($userInfo['token'])) { - return false; - } - - //设置token过期 - return UserTokenService::expireToken($userInfo['token']); - } - - - /** - * @notes 获取微信请求code的链接 - * @param string $url - * @return string - * @author 段誉 - * @date 2022/9/20 19:47 - */ - public static function codeUrl(string $url) - { - return (new WeChatOaService())->getCodeUrl($url); - } - - - /** - * @notes 公众号登录 - * @param array $params - * @return array|false - * @throws \GuzzleHttp\Exception\GuzzleException - * @author 段誉 - * @date 2022/9/20 19:47 - */ - public static function oaLogin(array $params) - { - Db::startTrans(); - try { - //通过code获取微信 openid - $response = (new WeChatOaService())->getOaResByCode($params['code']); - $userServer = new WechatUserService($response, UserTerminalEnum::WECHAT_OA); - $userInfo = $userServer->getResopnseByUserInfo()->authUserLogin()->getUserInfo(); - - // 更新登录信息 - self::updateLoginInfo($userInfo['id']); - - Db::commit(); - return $userInfo; - - } catch (\Exception $e) { - Db::rollback(); - self::$error = $e->getMessage(); - return false; - } - } - - - /** - * @notes 小程序-静默登录 - * @param array $params - * @return array|false - * @author 段誉 - * @date 2022/9/20 19:47 - */ - public static function silentLogin(array $params) - { - try { - //通过code获取微信 openid - $response = (new WeChatMnpService())->getMnpResByCode($params['code']); - $userServer = new WechatUserService($response, UserTerminalEnum::WECHAT_MMP); - $userInfo = $userServer->getResopnseByUserInfo('silent')->getUserInfo(); - - if (!empty($userInfo)) { - // 更新登录信息 - self::updateLoginInfo($userInfo['id']); - } - - return $userInfo; - } catch (\Exception $e) { - self::$error = $e->getMessage(); - return false; - } - } - - - /** - * @notes 小程序-授权登录 - * @param array $params - * @return array|false - * @author 段誉 - * @date 2022/9/20 19:47 - */ - public static function mnpLogin(array $params) - { - Db::startTrans(); - try { - //通过code获取微信 openid - $response = (new WeChatMnpService())->getMnpResByCode($params['code']); - $userServer = new WechatUserService($response, UserTerminalEnum::WECHAT_MMP); - $userInfo = $userServer->getResopnseByUserInfo()->authUserLogin()->getUserInfo(); - - // 更新登录信息 - self::updateLoginInfo($userInfo['id']); - - Db::commit(); - return $userInfo; - } catch (\Exception $e) { - Db::rollback(); - self::$error = $e->getMessage(); - return false; - } - } - - - /** - * @notes 更新登录信息 - * @param $userId - * @throws \Exception - * @author 段誉 - * @date 2022/9/20 19:46 - */ - public static function updateLoginInfo($userId) - { - $user = User::findOrEmpty($userId); - if ($user->isEmpty()) { - throw new \Exception('用户不存在'); - } - - $time = time(); - $user->login_time = $time; - $user->login_ip = request()->ip(); - $user->update_time = $time; - $user->save(); - } - - - /** - * @notes 小程序端绑定微信 - * @param array $params - * @return bool - * @author 段誉 - * @date 2022/9/20 19:46 - */ - public static function mnpAuthLogin(array $params) - { - try { - //通过code获取微信openid - $response = (new WeChatMnpService())->getMnpResByCode($params['code']); - $response['user_id'] = $params['user_id']; - $response['terminal'] = UserTerminalEnum::WECHAT_MMP; - - return self::createAuth($response); - - } catch (\Exception $e) { - self::$error = $e->getMessage(); - return false; - } - } - - - /** - * @notes 公众号端绑定微信 - * @param array $params - * @return bool - * @throws \GuzzleHttp\Exception\GuzzleException - * @author 段誉 - * @date 2022/9/16 10:43 - */ - public static function oaAuthLogin(array $params) - { - try { - //通过code获取微信openid - $response = (new WeChatOaService())->getOaResByCode($params['code']); - $response['user_id'] = $params['user_id']; - $response['terminal'] = UserTerminalEnum::WECHAT_OA; - - return self::createAuth($response); - - } catch (\Exception $e) { - self::$error = $e->getMessage(); - return false; - } - } - - - /** - * @notes 生成授权记录 - * @param $response - * @return bool - * @throws \Exception - * @author 段誉 - * @date 2022/9/16 10:43 - */ - public static function createAuth($response) - { - //先检查openid是否有记录 - $isAuth = UserAuth::where('openid', '=', $response['openid'])->findOrEmpty(); - if (!$isAuth->isEmpty()) { - throw new \Exception('该微信已被绑定'); - } - - if (isset($response['unionid']) && !empty($response['unionid'])) { - //在用unionid找记录,防止生成两个账号,同个unionid的问题 - $userAuth = UserAuth::where(['unionid' => $response['unionid']]) - ->findOrEmpty(); - if (!$userAuth->isEmpty() && $userAuth->user_id != $response['user_id']) { - throw new \Exception('该微信已被绑定'); - } - } - - //如果没有授权,直接生成一条微信授权记录 - UserAuth::create([ - 'user_id' => $response['user_id'], - 'openid' => $response['openid'], - 'unionid' => $response['unionid'] ?? '', - 'terminal' => $response['terminal'], - ]); - return true; - } - - - /** - * @notes 获取扫码登录地址 - * @return array|false - * @author 段誉 - * @date 2022/10/20 18:23 - */ - public static function getScanCode($redirectUri) - { - try { - $config = WeChatConfigService::getOpConfig(); - $appId = $config['app_id']; - $redirectUri = UrlEncode($redirectUri); - - // 设置有效时间标记状态, 超时扫码不可登录 - $state = MD5(time().rand(10000, 99999)); - (new WebScanLoginCache())->setScanLoginState($state); - - // 扫码地址 - $url = WeChatRequestService::getScanCodeUrl($appId, $redirectUri, $state); - return ['url' => $url]; - - } catch (\Exception $e) { - self::$error = $e->getMessage(); - return false; - } - } - - - /** - * @notes 网站扫码登录 - * @param $params - * @return array|false - * @author 段誉 - * @date 2022/10/21 10:28 - */ - public static function scanLogin($params) - { - Db::startTrans(); - try { - // 通过code 获取 access_token,openid,unionid等信息 - $userAuth = WeChatRequestService::getUserAuthByCode($params['code']); - - if (empty($userAuth['openid']) || empty($userAuth['access_token'])) { - throw new \Exception('获取用户授权信息失败'); - } - - // 获取微信用户信息 - $response = WeChatRequestService::getUserInfoByAuth($userAuth['access_token'], $userAuth['openid']); - - // 生成用户或更新用户信息 - $userServer = new WechatUserService($response, UserTerminalEnum::PC); - $userInfo = $userServer->getResopnseByUserInfo()->authUserLogin()->getUserInfo(); - - // 更新登录信息 - self::updateLoginInfo($userInfo['id']); - - Db::commit(); - return $userInfo; - - } catch (\Exception $e) { - Db::rollback(); - self::$error = $e->getMessage(); - return false; - } - } - - - /** - * @notes 更新用户信息 - * @param $params - * @param $userId - * @return User - * @author 段誉 - * @date 2023/2/22 11:19 - */ - public static function updateUser($params, $userId) - { - return User::where(['id' => $userId])->update([ - 'nickname' => $params['nickname'], - 'avatar' => FileService::setFileUrl($params['avatar']), - 'is_new_user' => YesNoEnum::NO - ]); - } -} \ No newline at end of file diff --git a/app/api/logic/PcLogic.php b/app/api/logic/PcLogic.php deleted file mode 100644 index c9a18804c..000000000 --- a/app/api/logic/PcLogic.php +++ /dev/null @@ -1,240 +0,0 @@ - $decoratePage, - 'all' => $allArticle, - 'new' => $newArticle, - 'hot' => $hotArticle - ]; - } - - - /** - * @notes 获取文章 - * @param string $sortType - * @param int $limit - * @return mixed - * @author 段誉 - * @date 2022/10/19 9:53 - */ - public static function getLimitArticle(string $sortType, int $limit = 0, int $cate = 0, int $excludeId = 0) - { - // 查询字段 - $field = [ - 'id', 'cid', 'title', 'desc', 'abstract', 'image', - 'author', 'click_actual', 'click_virtual', 'create_time' - ]; - - // 排序条件 - $orderRaw = 'sort desc, id desc'; - if ($sortType == 'new') { - $orderRaw = 'id desc'; - } - if ($sortType == 'hot') { - $orderRaw = 'click_actual + click_virtual desc, id desc'; - } - - // 查询条件 - $where[] = ['is_show', '=', YesNoEnum::YES]; - if (!empty($cate)) { - $where[] = ['cid', '=', $cate]; - } - if (!empty($excludeId)) { - $where[] = ['id', '<>', $excludeId]; - } - - $article = Article::field($field) - ->where($where) - ->append(['click']) - ->orderRaw($orderRaw) - ->hidden(['click_actual', 'click_virtual']); - - if ($limit) { - $article->limit($limit); - } - - return $article->select()->toArray(); - } - - - /** - * @notes 获取配置 - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - * @author 段誉 - * @date 2022/9/21 19:38 - */ - public static function getConfigData() - { - // 登录配置 - $loginConfig = [ - // 登录方式 - 'login_way' => ConfigService::get('login', 'login_way', config('project.login.login_way')), - // 注册强制绑定手机 - 'coerce_mobile' => ConfigService::get('login', 'coerce_mobile', config('project.login.coerce_mobile')), - // 政策协议 - 'login_agreement' => ConfigService::get('login', 'login_agreement', config('project.login.login_agreement')), - // 第三方登录 开关 - 'third_auth' => ConfigService::get('login', 'third_auth', config('project.login.third_auth')), - // 微信授权登录 - 'wechat_auth' => ConfigService::get('login', 'wechat_auth', config('project.login.wechat_auth')), - // qq授权登录 - 'qq_auth' => ConfigService::get('login', 'qq_auth', config('project.login.qq_auth')), - ]; - - // 网站信息 - $website = [ - 'shop_name' => ConfigService::get('website', 'shop_name'), - 'shop_logo' => FileService::getFileUrl(ConfigService::get('website', 'shop_logo')), - 'pc_logo' => FileService::getFileUrl(ConfigService::get('website', 'pc_logo')), - 'pc_title' => ConfigService::get('website', 'pc_title'), - 'pc_ico' => FileService::getFileUrl(ConfigService::get('website', 'pc_ico')), - 'pc_desc' => ConfigService::get('website', 'pc_desc'), - 'pc_keywords' => ConfigService::get('website', 'pc_keywords'), - ]; - - // 备案信息 - $copyright = ConfigService::get('copyright', 'config', []); - - // 公众号二维码 - $oaQrCode = ConfigService::get('oa_setting', 'qr_code', ''); - $oaQrCode = empty($oaQrCode) ? $oaQrCode : FileService::getFileUrl($oaQrCode); - // 小程序二维码 - $mnpQrCode = ConfigService::get('mnp_setting', 'qr_code', ''); - $mnpQrCode = empty($mnpQrCode) ? $mnpQrCode : FileService::getFileUrl($mnpQrCode); - - return [ - 'domain' => FileService::getFileUrl(), - 'login' => $loginConfig, - 'website' => $website, - 'version' => config('project.version'), - 'copyright' => $copyright, - 'admin_url' => request()->domain() . '/admin', - 'qrcode' => [ - 'oa' => $oaQrCode, - 'mnp' => $mnpQrCode, - ] - ]; - } - - - /** - * @notes 资讯中心 - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - * @author 段誉 - * @date 2022/10/19 16:55 - */ - public static function getInfoCenter() - { - $data = ArticleCate::field(['id', 'name']) - ->with(['article' => function ($query) { - $query->hidden(['content', 'click_virtual', 'click_actual']) - ->order(['sort' => 'desc', 'id' => 'desc']) - ->append(['click']) - ->limit(10); - }]) - ->where(['is_show' => YesNoEnum::YES]) - ->order(['sort' => 'desc', 'id' => 'desc']) - ->select() - ->toArray(); - - return $data; - } - - - /** - * @notes 获取文章详情 - * @param $userId - * @param $articleId - * @param string $source - * @return array - * @author 段誉 - * @date 2022/10/20 15:18 - */ - public static function getArticleDetail($userId, $articleId, $source = 'default') - { - // 文章详情 - $detail = Article::getArticleDetailArr($articleId); - - // 根据来源列表查找对应列表 - $nowIndex = 0; - $lists = self::getLimitArticle($source, 0, $detail['cid']); - foreach ($lists as $key => $item) { - if ($item['id'] == $articleId) { - $nowIndex = $key; - } - } - // 上一篇 - $detail['last'] = $lists[$nowIndex - 1] ?? []; - // 下一篇 - $detail['next'] = $lists[$nowIndex + 1] ?? []; - - // 最新资讯 - $detail['new'] = self::getLimitArticle('new', 8, $detail['cid'], $detail['id']); - // 关注状态 - $detail['collect'] = ArticleCollect::isCollectArticle($userId, $articleId); - // 分类名 - $detail['cate_name'] = ArticleCate::where('id', $detail['cid'])->value('name'); - - return $detail; - } - -} \ No newline at end of file diff --git a/app/api/logic/RechargeLogic.php b/app/api/logic/RechargeLogic.php deleted file mode 100644 index 3fe2e45e8..000000000 --- a/app/api/logic/RechargeLogic.php +++ /dev/null @@ -1,85 +0,0 @@ - generate_sn(RechargeOrder::class, 'sn'), - 'order_terminal' => $params['terminal'], - 'user_id' => $params['user_id'], - 'pay_status' => PayEnum::UNPAID, - 'order_amount' => $params['money'], - ]; - $order = RechargeOrder::create($data); - - return [ - 'order_id' => (int)$order['id'], - 'from' => 'recharge' - ]; - } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; - } - } - - - /** - * @notes 充值配置 - * @param $userId - * @return array - * @author 段誉 - * @date 2023/2/24 16:56 - */ - public static function config($userId) - { - $userMoney = User::where(['id' => $userId])->value('user_money'); - $minAmount = ConfigService::get('recharge', 'min_amount', 0); - $status = ConfigService::get('recharge', 'status', 0); - - return [ - 'status' => $status, - 'min_amount' => $minAmount, - 'user_money' => $userMoney, - ]; - } - - - - -} \ No newline at end of file diff --git a/app/api/logic/SearchLogic.php b/app/api/logic/SearchLogic.php deleted file mode 100644 index fe18abd7e..000000000 --- a/app/api/logic/SearchLogic.php +++ /dev/null @@ -1,53 +0,0 @@ -order(['sort' => 'desc', 'id' => 'desc']) - ->select()->toArray(); - - return [ - // 功能状态 0-关闭 1-开启 - 'status' => ConfigService::get('hot_search', 'status', 0), - // 热门搜索数据 - 'data' => $data, - ]; - } - -} \ No newline at end of file diff --git a/app/api/logic/SmsLogic.php b/app/api/logic/SmsLogic.php deleted file mode 100644 index fa6b6670a..000000000 --- a/app/api/logic/SmsLogic.php +++ /dev/null @@ -1,60 +0,0 @@ - $scene, - 'params' => [ - 'mobile' => $params['mobile'], - 'code' => mt_rand(1000, 9999), - ] - ]); - - return $result[0]; - - } catch (\Exception $e) { - self::$error = $e->getMessage(); - return false; - } - } - -} \ No newline at end of file diff --git a/app/api/logic/UserLogic.php b/app/api/logic/UserLogic.php deleted file mode 100644 index ca040b1ec..000000000 --- a/app/api/logic/UserLogic.php +++ /dev/null @@ -1,286 +0,0 @@ - $userInfo['user_id']]) - ->field('id,sn,sex,account,nickname,real_name,avatar,mobile,create_time,is_new_user,user_money,password') - ->findOrEmpty(); - - if (in_array($userInfo['terminal'], [UserTerminalEnum::WECHAT_MMP, UserTerminalEnum::WECHAT_OA])) { - $auth = UserAuth::where(['user_id' => $userInfo['user_id'], 'terminal' => $userInfo['terminal']])->find(); - $user['is_auth'] = $auth ? YesNoEnum::YES : YesNoEnum::NO; - } - - $user['has_password'] = !empty($user['password']); - $user->hidden(['password']); - return $user->toArray(); - } - - - /** - * @notes 个人信息 - * @param $userId - * @return array - * @author 段誉 - * @date 2022/9/20 19:45 - */ - public static function info(int $userId) - { - $user = User::where(['id' => $userId]) - ->field('id,sn,sex,account,password,nickname,real_name,avatar,mobile,create_time,user_money') - ->findOrEmpty(); - $user['has_password'] = !empty($user['password']); - $user['has_auth'] = self::hasWechatAuth($userId); - $user['version'] = config('project.version'); - $user->hidden(['password']); - return $user->toArray(); - } - - - /** - * @notes 设置用户信息 - * @param int $userId - * @param array $params - * @return User|false - * @author 段誉 - * @date 2022/9/21 16:53 - */ - public static function setInfo(int $userId, array $params) - { - try { - return User::update([ - 'id' => $userId, - $params['field'] => $params['value']] - ); - } catch (\Exception $e) { - self::$error = $e->getMessage(); - return false; - } - } - - - /** - * @notes 是否有微信授权信息 - * @param $userId - * @return bool - * @author 段誉 - * @date 2022/9/20 19:36 - */ - public static function hasWechatAuth(int $userId) - { - //是否有微信授权登录 - $terminal = [UserTerminalEnum::WECHAT_MMP, UserTerminalEnum::WECHAT_OA,UserTerminalEnum::PC]; - $auth = UserAuth::where(['user_id' => $userId]) - ->whereIn('terminal', $terminal) - ->findOrEmpty(); - return !$auth->isEmpty(); - } - - - /** - * @notes 重置登录密码 - * @param $params - * @return bool - * @author 段誉 - * @date 2022/9/16 18:06 - */ - public static function resetPassword(array $params) - { - try { - // 校验验证码 - $smsDriver = new SmsDriver(); - if (!$smsDriver->verify($params['mobile'], $params['code'], NoticeEnum::FIND_LOGIN_PASSWORD_CAPTCHA)) { - throw new \Exception('验证码错误'); - } - - // 重置密码 - $passwordSalt = Config::get('project.unique_identification'); - $password = create_password($params['password'], $passwordSalt); - - // 更新 - User::where('mobile', $params['mobile'])->update([ - 'password' => $password - ]); - - return true; - } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; - } - } - - - /** - * @notes 修稿密码 - * @param $params - * @param $userId - * @return bool - * @author 段誉 - * @date 2022/9/20 19:13 - */ - public static function changePassword(array $params, int $userId) - { - try { - $user = User::findOrEmpty($userId); - if ($user->isEmpty()) { - throw new \Exception('用户不存在'); - } - - // 密码盐 - $passwordSalt = Config::get('project.unique_identification'); - - if (!empty($user['password'])) { - if (empty($params['old_password'])) { - throw new \Exception('请填写旧密码'); - } - $oldPassword = create_password($params['old_password'], $passwordSalt); - if ($oldPassword != $user['password']) { - throw new \Exception('原密码不正确'); - } - } - - // 保存密码 - $password = create_password($params['password'], $passwordSalt); - $user->password = $password; - $user->save(); - - return true; - } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; - } - } - - - /** - * @notes 获取小程序手机号 - * @param array $params - * @return bool - * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface - * @author 段誉 - * @date 2023/2/27 11:49 - */ - public static function getMobileByMnp(array $params) - { - try { - $response = (new WeChatMnpService())->getUserPhoneNumber($params['code']); - $phoneNumber = $response['phone_info']['purePhoneNumber'] ?? ''; - if (empty($phoneNumber)) { - throw new \Exception('获取手机号码失败'); - } - - $user = User::where([ - ['mobile', '=', $phoneNumber], - ['id', '<>', $params['user_id']] - ])->findOrEmpty(); - - if (!$user->isEmpty()) { - throw new \Exception('手机号已被其他账号绑定'); - } - - // 绑定手机号 - User::update([ - 'id' => $params['user_id'], - 'mobile' => $phoneNumber - ]); - - return true; - } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; - } - } - - - /** - * @notes 绑定手机号 - * @param $params - * @return bool - * @author 段誉 - * @date 2022/9/21 17:28 - */ - public static function bindMobile(array $params) - { - try { - // 变更手机号场景 - $sceneId = NoticeEnum::CHANGE_MOBILE_CAPTCHA; - $where = [ - ['id', '=', $params['user_id']], - ['mobile', '=', $params['mobile']] - ]; - - // 绑定手机号场景 - if ($params['type'] == 'bind') { - $sceneId = NoticeEnum::BIND_MOBILE_CAPTCHA; - $where = [ - ['mobile', '=', $params['mobile']] - ]; - } - - // 校验短信 - $checkSmsCode = (new SmsDriver())->verify($params['mobile'], $params['code'], $sceneId); - if (!$checkSmsCode) { - throw new \Exception('验证码错误'); - } - - $user = User::where($where)->findOrEmpty(); - if (!$user->isEmpty()) { - throw new \Exception('该手机号已被使用'); - } - - User::update([ - 'id' => $params['user_id'], - 'mobile' => $params['mobile'], - ]); - - return true; - } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; - } - } - -} \ No newline at end of file diff --git a/app/api/logic/WechatLogic.php b/app/api/logic/WechatLogic.php deleted file mode 100644 index 6cda0b533..000000000 --- a/app/api/logic/WechatLogic.php +++ /dev/null @@ -1,65 +0,0 @@ -getJsConfig($url, [ - 'onMenuShareTimeline', - 'onMenuShareAppMessage', - 'onMenuShareQQ', - 'onMenuShareWeibo', - 'onMenuShareQZone', - 'openLocation', - 'getLocation', - 'chooseWXPay', - 'updateAppMessageShareData', - 'updateTimelineShareData', - 'openAddress', - 'scanQRCode' - ]); - } catch (Exception $e) { - self::setError('获取jssdk失败:' . $e->getMessage()); - return false; - } - } -} \ No newline at end of file diff --git a/app/api/service/UserTokenService.php b/app/api/service/UserTokenService.php deleted file mode 100644 index 50e0da10c..000000000 --- a/app/api/service/UserTokenService.php +++ /dev/null @@ -1,117 +0,0 @@ -find(); - - //获取token延长过期的时间 - $expireTime = $time + Config::get('project.user_token.expire_duration'); - $userTokenCache = new UserTokenCache(); - - //token处理 - if ($userSession) { - //清空缓存 - $userTokenCache->deleteUserInfo($userSession->token); - //重新获取token - $userSession->token = create_token($userId); - $userSession->expire_time = $expireTime; - $userSession->update_time = $time; - $userSession->save(); - } else { - //找不到在该终端的token记录,创建token记录 - $userSession = UserSession::create([ - 'user_id' => $userId, - 'terminal' => $terminal, - 'token' => create_token($userId), - 'expire_time' => $expireTime - ]); - } - - return $userTokenCache->setUserInfo($userSession->token); - } - - - /** - * @notes 延长token过期时间 - * @param $token - * @return array|false|mixed - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - * @author 段誉 - * @date 2022/9/16 10:10 - */ - public static function overtimeToken($token) - { - $time = time(); - $adminSession = UserSession::where('token', '=', $token)->find(); - //延长token过期时间 - $adminSession->expire_time = $time + Config::get('project.user_token.expire_duration'); - $adminSession->update_time = $time; - $adminSession->save(); - - return (new UserTokenCache())->setUserInfo($adminSession->token); - } - - - /** - * @notes 设置token为过期 - * @param $token - * @return bool - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - * @author 段誉 - * @date 2022/9/16 10:10 - */ - public static function expireToken($token) - { - $userSession = UserSession::where('token', '=', $token) - ->find(); - if (empty($userSession)) { - return false; - } - - $time = time(); - $userSession->expire_time = $time; - $userSession->update_time = $time; - $userSession->save(); - - return (new UserTokenCache())->deleteUserInfo($token); - } - -} \ No newline at end of file diff --git a/app/api/service/WechatUserService.php b/app/api/service/WechatUserService.php deleted file mode 100644 index dddfa03ab..000000000 --- a/app/api/service/WechatUserService.php +++ /dev/null @@ -1,266 +0,0 @@ -terminal = $terminal; - $this->setParams($response); - } - - - /** - * @notes 设置微信返回的用户信息 - * @param $response - * @author cjhao - * @date 2021/8/2 11:49 - */ - private function setParams($response): void - { - $this->response = $response; - $this->openid = $response['openid']; - $this->unionid = $response['unionid'] ?? ''; - $this->nickname = $response['nickname'] ?? ''; - $this->headimgurl = $response['headimgurl'] ?? ''; - } - - - /** - * @notes 根据opendid或unionid获取系统用户信息 - * @return $this - * @author 段誉 - * @date 2022/9/23 16:09 - */ - public function getResopnseByUserInfo(): self - { - $openid = $this->openid; - $unionid = $this->unionid; - - $user = User::alias('u') - ->field('u.id,u.sn,u.mobile,u.nickname,u.avatar,u.mobile,u.is_disable,u.is_new_user') - ->join('user_auth au', 'au.user_id = u.id') - ->where(function ($query) use ($openid, $unionid) { - $query->whereOr(['au.openid' => $openid]); - if (isset($unionid) && $unionid) { - $query->whereOr(['au.unionid' => $unionid]); - } - }) - ->findOrEmpty(); - - $this->user = $user; - return $this; - } - - - /** - * @notes 获取用户信息 - * @param bool $isCheck 是否验证账号是否可用 - * @return array - * @throws Exception - * @author cjhao - * @date 2021/8/3 11:42 - */ - public function getUserInfo($isCheck = true): array - { - if (!$this->user->isEmpty() && $isCheck) { - $this->checkAccount(); - } - if (!$this->user->isEmpty()) { - $this->getToken(); - } - return $this->user->toArray(); - } - - - /** - * @notes 校验账号 - * @throws Exception - * @author 段誉 - * @date 2022/9/16 10:14 - */ - private function checkAccount() - { - if ($this->user->is_disable) { - throw new Exception('您的账号异常,请联系客服。'); - } - } - - - /** - * @notes 创建用户 - * @throws Exception - * @author 段誉 - * @date 2022/9/16 10:06 - */ - private function createUser(): void - { - //设置头像 - if (empty($this->headimgurl)) { - // 默认头像 - $defaultAvatar = config('project.default_image.user_avatar'); - $avatar = ConfigService::get('default_image', 'user_avatar', $defaultAvatar); - } else { - // 微信获取到的头像信息 - $avatar = $this->getAvatarByWechat(); - } - - $userSn = User::createUserSn(); - $this->user->sn = $userSn; - $this->user->account = 'u' . $userSn; - $this->user->nickname = "用户" . $userSn; - $this->user->avatar = $avatar; - $this->user->channel = $this->terminal; - $this->user->is_new_user = YesNoEnum::YES; - - if ($this->terminal != UserTerminalEnum::WECHAT_MMP && !empty($this->nickname)) { - $this->user->nickname = $this->nickname; - } - - $this->user->save(); - - UserAuth::create([ - 'user_id' => $this->user->id, - 'openid' => $this->openid, - 'unionid' => $this->unionid, - 'terminal' => $this->terminal, - ]); - } - - - /** - * @notes 更新用户信息 - * @throws Exception - * @author 段誉 - * @date 2022/9/16 10:06 - * @remark 该端没授权信息,重新写入一条该端的授权信息 - */ - private function updateUser(): void - { - // 无头像需要更新头像 - if (empty($this->user->avatar)) { - $this->user->avatar = $this->getAvatarByWechat(); - $this->user->save(); - } - - $userAuth = UserAuth::where(['user_id' => $this->user->id, 'openid' => $this->openid]) - ->findOrEmpty(); - - // 无该端授权信息,新增一条 - if ($userAuth->isEmpty()) { - $userAuth->user_id = $this->user->id; - $userAuth->openid = $this->openid; - $userAuth->unionid = $this->unionid; - $userAuth->terminal = $this->terminal; - $userAuth->save(); - } else { - if (empty($userAuth['unionid']) && !empty($this->unionid)) { - $userAuth->unionid = $this->unionid; - $userAuth->save(); - } - } - } - - - /** - * @notes 获取token - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - * @author cjhao - * @date 2021/8/2 16:45 - */ - private function getToken(): void - { - $user = UserTokenService::setToken($this->user->id, $this->terminal); - $this->user->token = $user['token']; - } - - - /** - * @notes 用户授权登录, - * 如果用户不存在,创建用户;用户存在,更新用户信息,并检查该端信息是否需要写入 - * @return WechatUserService - * @throws Exception - * @author cjhao - * @date 2021/8/2 16:35 - */ - public function authUserLogin(): self - { - if ($this->user->isEmpty()) { - $this->createUser(); - } else { - $this->updateUser(); - } - return $this; - } - - - /** - * @notes 处理从微信获取到的头像信息 - * @return string - * @throws Exception - * @author 段誉 - * @date 2022/9/16 9:50 - */ - public function getAvatarByWechat(): string - { - // 存储引擎 - $config = [ - 'default' => ConfigService::get('storage', 'default', 'local'), - 'engine' => ConfigService::get('storage') - ]; - if ($config['default'] == 'local') { - // 本地存储 - $file_name = md5($this->openid . time()) . '.jpeg'; - $avatar = download_file($this->headimgurl, 'uploads/user/avatar/', $file_name); - } else { - // 第三方存储 - $avatar = 'uploads/user/avatar/' . md5($this->openid . time()) . '.jpeg'; - $StorageDriver = new StorageDriver($config); - if (!$StorageDriver->fetch($this->headimgurl, $avatar)) { - throw new Exception('头像保存失败:' . $StorageDriver->getError()); - } - } - return $avatar; - } - - -} \ No newline at end of file diff --git a/app/api/validate/LoginAccountValidate.php b/app/api/validate/LoginAccountValidate.php deleted file mode 100644 index 7cbde9839..000000000 --- a/app/api/validate/LoginAccountValidate.php +++ /dev/null @@ -1,161 +0,0 @@ - 'require|in:' . UserTerminalEnum::WECHAT_MMP . ',' . UserTerminalEnum::WECHAT_OA . ',' - . UserTerminalEnum::H5 . ',' . UserTerminalEnum::PC . ',' . UserTerminalEnum::IOS . - ',' . UserTerminalEnum::ANDROID, - 'scene' => 'require|in:' . LoginEnum::ACCOUNT_PASSWORD . ',' . LoginEnum::MOBILE_CAPTCHA . '|checkConfig', - 'account' => 'require', - ]; - - - protected $message = [ - 'terminal.require' => '终端参数缺失', - 'terminal.in' => '终端参数状态值不正确', - 'scene.require' => '场景不能为空', - 'scene.in' => '场景值错误', - 'account.require' => '请输入账号', - 'password.require' => '请输入密码', - ]; - - - /** - * @notes 登录场景相关校验 - * @param $scene - * @param $rule - * @param $data - * @return bool|string - * @author 段誉 - * @date 2022/9/15 14:37 - */ - public function checkConfig($scene, $rule, $data) - { - $config = ConfigService::get('login', 'login_way'); - if (!in_array($scene, $config)) { - return '不支持的登录方式'; - } - - // 账号密码登录 - if (LoginEnum::ACCOUNT_PASSWORD == $scene) { - if (!isset($data['password'])) { - return '请输入密码'; - } - return $this->checkPassword($data['password'], [], $data); - } - - // 手机验证码登录 - if (LoginEnum::MOBILE_CAPTCHA == $scene) { - if (!isset($data['code'])) { - return '请输入手机验证码'; - } - return $this->checkCode($data['code'], [], $data); - } - - return true; - } - - - /** - * @notes 登录密码校验 - * @param $password - * @param $other - * @param $data - * @return bool|string - * @author 段誉 - * @date 2022/9/15 14:39 - */ - public function checkPassword($password, $other, $data) - { - //账号安全机制,连续输错后锁定,防止账号密码暴力破解 - $userAccountSafeCache = new UserAccountSafeCache(); - if (!$userAccountSafeCache->isSafe()) { - return '密码连续' . $userAccountSafeCache->count . '次输入错误,请' . $userAccountSafeCache->minute . '分钟后重试'; - } - - $where = []; - if ($data['scene'] == LoginEnum::ACCOUNT_PASSWORD) { - // 手机号密码登录 - $where = ['account|mobile' => $data['account']]; - } - - $userInfo = User::where($where) - ->field(['password,is_disable']) - ->findOrEmpty(); - - if ($userInfo->isEmpty()) { - return '用户不存在'; - } - - if ($userInfo['is_disable'] === YesNoEnum::YES) { - return '用户已禁用'; - } - - if (empty($userInfo['password'])) { - $userAccountSafeCache->record(); - return '用户不存在'; - } - - $passwordSalt = Config::get('project.unique_identification'); - if ($userInfo['password'] !== create_password($password, $passwordSalt)) { - $userAccountSafeCache->record(); - return '密码错误'; - } - - $userAccountSafeCache->relieve(); - - return true; - } - - - /** - * @notes 校验验证码 - * @param $code - * @param $rule - * @param $data - * @return bool|string - * @author Tab - * @date 2021/8/25 15:43 - */ - public function checkCode($code, $rule, $data) - { - $smsDriver = new SmsDriver(); - $result = $smsDriver->verify($data['account'], $code, NoticeEnum::LOGIN_CAPTCHA); - if ($result) { - return true; - } - return '验证码错误'; - } -} \ No newline at end of file diff --git a/app/api/validate/PasswordValidate.php b/app/api/validate/PasswordValidate.php deleted file mode 100644 index ca1d775bc..000000000 --- a/app/api/validate/PasswordValidate.php +++ /dev/null @@ -1,69 +0,0 @@ - 'require|mobile', - 'code' => 'require', - 'password' => 'require|length:6,20|alphaNum', - 'password_confirm' => 'require|confirm', - ]; - - - protected $message = [ - 'mobile.require' => '请输入手机号', - 'mobile.mobile' => '请输入正确手机号', - 'code.require' => '请填写验证码', - 'password.require' => '请输入密码', - 'password.length' => '密码须在6-25位之间', - 'password.alphaNum' => '密码须为字母数字组合', - 'password_confirm.require' => '请确认密码', - 'password_confirm.confirm' => '两次输入的密码不一致' - ]; - - - /** - * @notes 重置登录密码 - * @return PasswordValidate - * @author 段誉 - * @date 2022/9/16 18:11 - */ - public function sceneResetPassword() - { - return $this->only(['mobile', 'code', 'password', 'password_confirm']); - } - - - /** - * @notes 修改密码场景 - * @return PasswordValidate - * @author 段誉 - * @date 2022/9/20 19:14 - */ - public function sceneChangePassword() - { - return $this->only(['password', 'password_confirm']); - } - -} \ No newline at end of file diff --git a/app/api/validate/PayValidate.php b/app/api/validate/PayValidate.php deleted file mode 100644 index 9f8070953..000000000 --- a/app/api/validate/PayValidate.php +++ /dev/null @@ -1,68 +0,0 @@ - 'require', - 'pay_way' => 'require|in:' . PayEnum::BALANCE_PAY . ',' . PayEnum::WECHAT_PAY . ',' . PayEnum::ALI_PAY, - 'order_id' => 'require' - ]; - - - protected $message = [ - 'from.require' => '参数缺失', - 'pay_way.require' => '支付方式参数缺失', - 'pay_way.in' => '支付方式参数错误', - 'order_id.require' => '订单参数缺失' - ]; - - - /** - * @notes 支付方式场景 - * @return PayValidate - * @author 段誉 - * @date 2023/2/24 17:43 - */ - public function scenePayway() - { - return $this->only(['from', 'order_id']); - } - - - /** - * @notes 支付状态 - * @return PayValidate - * @author 段誉 - * @date 2023/3/1 16:17 - */ - public function sceneStatus() - { - return $this->only(['from', 'order_id']); - } - - - -} \ No newline at end of file diff --git a/app/api/validate/RechargeValidate.php b/app/api/validate/RechargeValidate.php deleted file mode 100644 index f617a9289..000000000 --- a/app/api/validate/RechargeValidate.php +++ /dev/null @@ -1,72 +0,0 @@ - 'require|gt:0|checkMoney', - ]; - - - protected $message = [ - 'money.require' => '请填写充值金额', - 'money.gt' => '请填写大于0的充值金额', - ]; - - - public function sceneRecharge() - { - return $this->only(['money']); - } - - - - /** - * @notes 校验金额 - * @param $money - * @param $rule - * @param $data - * @return bool|string - * @author 段誉 - * @date 2023/2/24 10:42 - */ - protected function checkMoney($money, $rule, $data) - { - $status = ConfigService::get('recharge', 'status', 0); - if (!$status) { - return '充值功能已关闭'; - } - - $minAmount = ConfigService::get('recharge', 'min_amount', 0); - - if ($money < $minAmount) { - return '最低充值金额' . $minAmount . "元"; - } - - return true; - } - -} \ No newline at end of file diff --git a/app/api/validate/RegisterValidate.php b/app/api/validate/RegisterValidate.php deleted file mode 100644 index 39b4d5c01..000000000 --- a/app/api/validate/RegisterValidate.php +++ /dev/null @@ -1,53 +0,0 @@ - '^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]+$', - 'password' => '/^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)(?!([^(0-9a-zA-Z)]|[\(\)])+$)([^(0-9a-zA-Z)]|[\(\)]|[a-z]|[A-Z]|[0-9]){6,20}$/' - ]; - - protected $rule = [ - 'channel' => 'require', - 'account' => 'require|length:3,12|unique:' . User::class . '|regex:register', - 'password' => 'require|length:6,20|regex:password', - 'password_confirm' => 'require|confirm' - ]; - - protected $message = [ - 'channel.require' => '注册来源参数缺失', - 'account.require' => '请输入账号', - 'account.regex' => '账号须为字母数字组合', - 'account.length' => '账号须为3-12位之间', - 'account.unique' => '账号已存在', - 'password.require' => '请输入密码', - 'password.length' => '密码须在6-25位之间', - 'password.regex' => '密码须为数字,字母或符号组合', - 'password_confirm.require' => '请确认密码', - 'password_confirm.confirm' => '两次输入的密码不一致' - ]; - -} \ No newline at end of file diff --git a/app/api/validate/SendSmsValidate.php b/app/api/validate/SendSmsValidate.php deleted file mode 100644 index d8b949417..000000000 --- a/app/api/validate/SendSmsValidate.php +++ /dev/null @@ -1,39 +0,0 @@ - 'require|mobile', - 'scene' => 'require', - ]; - - protected $message = [ - 'mobile.require' => '请输入手机号', - 'mobile.mobile' => '请输入正确手机号', - 'scene.require' => '请输入场景值', - ]; -} \ No newline at end of file diff --git a/app/api/validate/SetUserInfoValidate.php b/app/api/validate/SetUserInfoValidate.php deleted file mode 100644 index b16c9907b..000000000 --- a/app/api/validate/SetUserInfoValidate.php +++ /dev/null @@ -1,73 +0,0 @@ - 'require|checkField', - 'value' => 'require', - ]; - - protected $message = [ - 'field.require' => '参数缺失', - 'value.require' => '值不存在', - ]; - - - /** - * @notes 校验字段内容 - * @param $value - * @param $rule - * @param $data - * @return bool|string - * @author 段誉 - * @date 2022/9/21 17:01 - */ - protected function checkField($value, $rule, $data) - { - $allowField = [ - 'nickname', 'account', 'sex', 'avatar', 'real_name', - ]; - - if (!in_array($value, $allowField)) { - return '参数错误'; - } - - if ($value == 'account') { - $user = User::where([ - ['account', '=', $data['value']], - ['id', '<>', $data['id']] - ])->findOrEmpty(); - if (!$user->isEmpty()) { - return '账号已被使用!'; - } - } - - return true; - } - - -} \ No newline at end of file diff --git a/app/api/validate/UserValidate.php b/app/api/validate/UserValidate.php deleted file mode 100644 index ef622e6b9..000000000 --- a/app/api/validate/UserValidate.php +++ /dev/null @@ -1,61 +0,0 @@ - 'require', - ]; - - protected $message = [ - 'code.require' => '参数缺失', - ]; - - - /** - * @notes 获取小程序手机号场景 - * @return UserValidate - * @author 段誉 - * @date 2022/9/21 16:44 - */ - public function sceneGetMobileByMnp() - { - return $this->only(['code']); - } - - - /** - * @notes 绑定/变更 手机号 - * @return UserValidate - * @author 段誉 - * @date 2022/9/21 17:37 - */ - public function sceneBindMobile() - { - return $this->only(['mobile', 'code']); - } - - -} \ No newline at end of file diff --git a/app/api/validate/WebScanLoginValidate.php b/app/api/validate/WebScanLoginValidate.php deleted file mode 100644 index 3523c6f3e..000000000 --- a/app/api/validate/WebScanLoginValidate.php +++ /dev/null @@ -1,59 +0,0 @@ - 'require', - 'state' => 'require|checkState', - ]; - - protected $message = [ - 'code.require' => '参数缺失', - 'state.require' => '昵称缺少', - ]; - - - /** - * @notes 校验登录状态标记 - * @param $value - * @param $rule - * @param $data - * @return bool|string - * @author 段誉 - * @date 2022/10/21 9:47 - */ - protected function checkState($value, $rule, $data) - { - $check = (new WebScanLoginCache())->getScanLoginState($value); - - if (empty($check)) { - return '二维码已失效或不存在,请重新扫码'; - } - - return true; - } - -} \ No newline at end of file diff --git a/app/api/validate/WechatLoginValidate.php b/app/api/validate/WechatLoginValidate.php deleted file mode 100644 index b84372b0c..000000000 --- a/app/api/validate/WechatLoginValidate.php +++ /dev/null @@ -1,96 +0,0 @@ - 'require', - 'nickname' => 'require', - 'headimgurl' => 'require', - 'openid' => 'require', - 'access_token' => 'require', - 'terminal' => 'require', - 'avatar' => 'require', - ]; - - protected $message = [ - 'code.require' => 'code缺少', - 'nickname.require' => '昵称缺少', - 'headimgurl.require' => '头像缺少', - 'openid.require' => 'opendid缺少', - 'access_token.require' => 'access_token缺少', - 'terminal.require' => '终端参数缺少', - 'avatar.require' => '头像缺少', - ]; - - - /** - * @notes 公众号登录场景 - * @return WechatLoginValidate - * @author 段誉 - * @date 2022/9/16 10:57 - */ - public function sceneOa() - { - return $this->only(['code']); - } - - - /** - * @notes 小程序-授权登录场景 - * @return WechatLoginValidate - * @author 段誉 - * @date 2022/9/16 11:15 - */ - public function sceneMnpLogin() - { - return $this->only(['code']); - } - - - /** - * @notes - * @return WechatLoginValidate - * @author 段誉 - * @date 2022/9/16 11:15 - */ - public function sceneWechatAuth() - { - return $this->only(['code']); - } - - - /** - * @notes 更新用户信息场景 - * @return WechatLoginValidate - * @author 段誉 - * @date 2023/2/22 11:14 - */ - public function sceneUpdateUser() - { - return $this->only(['nickname', 'avatar']); - } - - -} \ No newline at end of file diff --git a/app/api/validate/WechatValidate.php b/app/api/validate/WechatValidate.php deleted file mode 100644 index 3f2bb7219..000000000 --- a/app/api/validate/WechatValidate.php +++ /dev/null @@ -1,38 +0,0 @@ - 'require' - ]; - - public $message = [ - 'url.require' => '请提供url' - ]; - - public function sceneJsConfig() - { - return $this->only(['url']); - } -} \ No newline at end of file diff --git a/app/common/command/QueryRefund.php b/app/common/command/QueryRefund.php deleted file mode 100644 index 42fab38a6..000000000 --- a/app/common/command/QueryRefund.php +++ /dev/null @@ -1,202 +0,0 @@ -setName('query_refund') - ->setDescription('订单退款状态处理'); - } - - - protected function execute(Input $input, Output $output) - { - try { - // 查找退款中的退款记录(微信,支付宝支付) - $refundRecords = (new RefundLog())->alias('l') - ->join('refund_record r', 'r.id = l.record_id') - ->field([ - 'l.id' => 'log_id', 'l.sn' => 'log_sn', - 'r.id' => 'record_id', 'r.order_id', 'r.sn' => 'record_sn', 'r.order_type' - ]) - ->where(['l.refund_status' => RefundEnum::REFUND_ING]) - ->select()->toArray(); - - if (empty($refundRecords)) { - return false; - } - - // 分别处理各个类型订单 - $rechargeRecords = array_filter($refundRecords, function ($item) { - return $item['order_type'] == RefundEnum::ORDER_TYPE_RECHARGE; - }); - - if (!empty($rechargeRecords)) { - $this->handleRechargeOrder($rechargeRecords); - } - - return true; - } catch (\Exception $e) { - Log::write('订单退款状态查询失败,失败原因:' . $e->getMessage()); - return false; - } - } - - - /** - * @notes 处理充值订单 - * @param $refundRecords - * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException - * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException - * @author 段誉 - * @date 2023/3/1 15:55 - */ - public function handleRechargeOrder($refundRecords) - { - $orderIds = array_unique(array_column($refundRecords, 'order_id')); - $Orders = RechargeOrder::whereIn('id', $orderIds)->column('*', 'id'); - - foreach ($refundRecords as $record) { - if (!isset($Orders[$record['order_id']])) { - continue; - } - - $order = $Orders[$record['order_id']]; - if (!in_array($order['pay_way'], [PayEnum::WECHAT_PAY, PayEnum::ALI_PAY])) { - continue; - } - - $this->checkReFundStatus([ - 'record_id' => $record['record_id'], - 'log_id' => $record['log_id'], - 'log_sn' => $record['log_sn'], - 'pay_way' => $order['pay_way'], - 'order_terminal' => $order['order_terminal'], - ]); - } - } - - - /** - * @notes 校验退款状态 - * @param $refundData - * @return bool - * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException - * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException - * @author 段誉 - * @date 2023/3/1 15:54 - */ - public function checkReFundStatus($refundData) - { - $result = null; - switch ($refundData['pay_way']) { - case PayEnum::WECHAT_PAY: - $result = self::checkWechatRefund($refundData['order_terminal'], $refundData['log_sn']); - break; - } - - if (is_null($result)) { - return false; - } - - if (true === $result) { - $this->updateRefundSuccess($refundData['log_id'], $refundData['record_id']); - } else { - $this->updateRefundMsg($refundData['log_id'], $result); - } - return true; - } - - - /** - * @notes 查询微信支付退款状态 - * @param $orderTerminal - * @param $refundLogSn - * @return bool|string|null - * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException - * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException - * @author 段誉 - * @date 2023/3/1 15:47 - */ - public function checkWechatRefund($orderTerminal, $refundLogSn) - { - // 根据商户退款单号查询退款 - $result = (new WeChatPayService($orderTerminal))->queryRefund($refundLogSn); - - if (!empty($result['status']) && $result['status'] == 'SUCCESS') { - return true; - } - - if (!empty($result['code']) || !empty($result['message'])) { - return '微信:' . $result['code'] . '-' . $result['message']; - } - - return null; - } - - - /** - * @notes 更新记录为成功 - * @param $logId - * @param $recordId - * @author 段誉 - * @date 2023/3/1 15:38 - */ - public function updateRefundSuccess($logId, $recordId) - { - // 更新日志 - RefundLog::update([ - 'id' => $logId, - 'refund_status' => RefundEnum::REFUND_SUCCESS, - ]); - // 更新记录 - RefundRecord::update([ - 'id' => $recordId, - 'refund_status' => RefundEnum::REFUND_SUCCESS, - ]); - } - - - /** - * @notes 更新退款信息 - * @param $logId - * @param $msg - * @author 段誉 - * @date 2023/3/1 15:47 - */ - public function updateRefundMsg($logId, $msg) - { - // 更新日志 - RefundLog::update([ - 'id' => $logId, - 'refund_msg' => $msg, - ]); - } - -} \ No newline at end of file diff --git a/app/common/enum/PayEnum.php b/app/common/enum/PayEnum.php deleted file mode 100644 index d91def1a6..000000000 --- a/app/common/enum/PayEnum.php +++ /dev/null @@ -1,112 +0,0 @@ - '余额支付', - self::WECHAT_PAY => '微信支付', - self::ALI_PAY => '支付宝支付', - ]; - if ($value === true) { - return $data; - } - return $data[$value] ?? ''; - } - - - - /** - * @notes 支付状态 - * @param bool $value - * @return string|string[] - * @author 段誉 - * @date 2023/2/23 15:36 - */ - public static function getPayStatusDesc($value = true) - { - $data = [ - self::UNPAID => '未支付', - self::ISPAID => '已支付', - ]; - if ($value === true) { - return $data; - } - return $data[$value] ?? ''; - } - - - /** - * @notes 支付场景 - * @param bool $value - * @return string|string[] - * @author 段誉 - * @date 2023/2/23 15:36 - */ - public static function getPaySceneDesc($value = true) - { - $data = [ - self::SCENE_H5 => 'H5', - self::SCENE_OA => '微信公众号', - self::SCENE_MNP => '微信小程序', - self::SCENE_APP => 'APP', - self::SCENE_PC => 'PC', - ]; - if ($value === true) { - return $data; - } - return $data[$value] ?? ''; - } - - -} \ No newline at end of file diff --git a/app/common/enum/RefundEnum.php b/app/common/enum/RefundEnum.php deleted file mode 100644 index b85117241..000000000 --- a/app/common/enum/RefundEnum.php +++ /dev/null @@ -1,116 +0,0 @@ - '后台退款', - ]; - if ($value === true) { - return $data; - } - return $data[$value]; - } - - - /** - * @notes 退款状态 - * @param bool $value - * @return string|string[] - * @author 段誉 - * @date 2022/12/1 10:43 - */ - public static function getStatusDesc($value = true) - { - $data = [ - self::REFUND_ING => '退款中', - self::REFUND_SUCCESS => '退款成功', - self::REFUND_ERROR => '退款失败', - ]; - if ($value === true) { - return $data; - } - return $data[$value]; - } - - - - /** - * @notes 退款方式 - * @param bool $value - * @return string|string[] - * @author 段誉 - * @date 2022/12/1 10:43 - */ - public static function getWayDesc($value = true) - { - $data = [ - self::REFUND_ONLINE => '线上退款', - self::REFUND_OFFLINE => '线下退款', - ]; - if ($value === true) { - return $data; - } - return $data[$value]; - } - - - /** - * @notes 通过支付方式获取退款方式 - * @param $payWay - * @return int - * @author 段誉 - * @date 2022/12/6 10:31 - */ - public static function getRefundWayByPayWay($payWay) - { - if (in_array($payWay, [PayEnum::ALI_PAY, PayEnum::WECHAT_PAY])) { - return self::REFUND_ONLINE; - } - return self::REFUND_OFFLINE; - } - -} \ No newline at end of file diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php deleted file mode 100644 index 262fc513a..000000000 --- a/app/common/logic/PayNotifyLogic.php +++ /dev/null @@ -1,88 +0,0 @@ -getFile(), - $e->getLine(), - $e->getMessage() - ])); - self::setError($e->getMessage()); - return $e->getMessage(); - } - } - - - /** - * @notes 充值回调 - * @param $orderSn - * @param array $extra - * @author 段誉 - * @date 2023/2/27 15:28 - */ - public static function recharge($orderSn, $extra = []) - { - $order = RechargeOrder::where('sn', $orderSn)->findOrEmpty(); - // 增加用户累计充值金额及用户余额 - $user = User::findOrEmpty($order->user_id); - $user->total_recharge_amount += $order->order_amount; - $user->user_money += $order->order_amount; - $user->save(); - - // 记录账户流水 - AccountLogLogic::add( - $order->user_id, - AccountLogEnum::UM_INC_RECHARGE, - AccountLogEnum::INC, - $order->order_amount, - $order->sn, - '用户充值' - ); - - // 更新充值订单状态 - $order->transaction_id = $extra['transaction_id']; - $order->pay_status = PayEnum::ISPAID; - $order->pay_time = time(); - $order->save(); - } - - -} diff --git a/app/common/logic/PaymentLogic.php b/app/common/logic/PaymentLogic.php deleted file mode 100644 index ed7357295..000000000 --- a/app/common/logic/PaymentLogic.php +++ /dev/null @@ -1,234 +0,0 @@ -toArray(); - } - - if (empty($order)) { - throw new \Exception('待支付订单不存在'); - } - - //获取支付场景 - $pay_way = PayWay::alias('pw') - ->join('dev_pay_config dp', 'pw.pay_config_id = dp.id') - ->where(['pw.scene' => $terminal, 'pw.status' => YesNoEnum::YES]) - ->field('dp.id,dp.name,dp.pay_way,dp.icon,dp.sort,dp.remark,pw.is_default') - ->order('pw.is_default desc,dp.sort desc,id asc') - ->select() - ->toArray(); - - foreach ($pay_way as $k => &$item) { - if ($item['pay_way'] == PayEnum::WECHAT_PAY) { - $item['extra'] = '微信快捷支付'; - } - if ($item['pay_way'] == PayEnum::ALI_PAY) { - $item['extra'] = '支付宝快捷支付'; - } - if ($item['pay_way'] == PayEnum::BALANCE_PAY) { - $user_money = User::where(['id' => $userId])->value('user_money'); - $item['extra'] = '可用余额:' . $user_money; - } - // 充值时去除余额支付 - if ($params['from'] == 'recharge' && $item['pay_way'] == PayEnum::BALANCE_PAY) { - unset($pay_way[$k]); - } - } - - return [ - 'lists' => array_values($pay_way), - 'order_amount' => $order['order_amount'], - ]; - - } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; - } - } - - - /** - * @notes 获取支付状态 - * @param $params - * @return array|false - * @author 段誉 - * @date 2023/3/1 16:23 - */ - public static function getPayStatus($params) - { - try { - $order = []; - $orderInfo = []; - switch ($params['from']) { - case 'recharge': - $order = RechargeOrder::where(['user_id' => $params['user_id'], 'id' => $params['order_id']]) - ->findOrEmpty(); - $payTime = empty($order['pay_time']) ? '' : date('Y-m-d H:i:s', $order['pay_time']); - $orderInfo = [ - 'order_id' => $order['id'], - 'order_sn' => $order['sn'], - 'order_amount' => $order['order_amount'], - 'pay_way' => PayEnum::getPayDesc($order['pay_way']), - 'pay_status' => PayEnum::getPayStatusDesc($order['pay_status']), - 'pay_time' => $payTime, - ]; - break; - } - - if (empty($order)) { - throw new \Exception('订单不存在'); - } - - return [ - 'pay_status' => $order['pay_status'], - 'pay_way' => $order['pay_way'], - 'order' => $orderInfo - ]; - } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; - } - } - - - /** - * @notes 获取预支付订单信息 - * @param $params - * @return RechargeOrder|array|false|\think\Model - * @author 段誉 - * @date 2023/2/27 15:19 - */ - public static function getPayOrderInfo($params) - { - try { - switch ($params['from']) { - case 'recharge': - $order = RechargeOrder::findOrEmpty($params['order_id']); - if ($order->isEmpty()) { - throw new \Exception('充值订单不存在'); - } - break; - } - - if ($order['pay_status'] == PayEnum::ISPAID) { - throw new \Exception('订单已支付'); - } - return $order; - } catch (\Exception $e) { - self::$error = $e->getMessage(); - return false; - } - } - - - /** - * @notes 支付 - * @param $payWay - * @param $from - * @param $order - * @param $terminal - * @param $redirectUrl - * @return array|false|mixed|string - * @author 段誉 - * @date 2023/2/28 12:15 - */ - public static function pay($payWay, $from, $order, $terminal, $redirectUrl) - { - // 支付编号-仅为微信支付预置(同一商户号下不同客户端支付需使用唯一订单号) - $paySn = $order['sn']; - if ($payWay == PayEnum::WECHAT_PAY) { - $paySn = self::formatOrderSn($order['sn'], $terminal); - } - - //更新支付方式 - switch ($from) { - case 'recharge': - RechargeOrder::update(['pay_way' => $payWay, 'pay_sn' => $paySn], ['id' => $order['id']]); - break; - } - - if ($order['order_amount'] == 0) { - PayNotifyLogic::handle($from, $order['sn']); - return ['pay_way' => PayEnum::BALANCE_PAY]; - } - - switch ($payWay) { - case PayEnum::WECHAT_PAY: - $payService = (new WeChatPayService($terminal, $order['user_id'] ?? null)); - $order['pay_sn'] = $paySn; - $order['redirect_url'] = $redirectUrl; - $result = $payService->pay($from, $order); - break; - default: - self::$error = '订单异常'; - $result = false; - } - - if (false === $result && !self::hasError()) { - self::setError($payService->getError()); - } - return $result; - } - - - - - /** - * @notes 设置订单号 支付回调时截取前面的单号 18个 - * @param $orderSn - * @param $terminal - * @return string - * @author 段誉 - * @date 2023/3/1 16:31 - * @remark 回调时使用了不同的回调地址,导致跨客户端支付时(例如小程序,公众号)可能出现201,商户订单号重复错误 - */ - public static function formatOrderSn($orderSn, $terminal) - { - $suffix = mb_substr(time(), -4); - return $orderSn . $terminal . $suffix; - } - -} \ No newline at end of file diff --git a/app/common/logic/RefundLogic.php b/app/common/logic/RefundLogic.php deleted file mode 100644 index 21931203b..000000000 --- a/app/common/logic/RefundLogic.php +++ /dev/null @@ -1,166 +0,0 @@ -getMessage(); - self::refundFailHandle($refundRecordId, $e->getMessage()); - return false; - } - } - - - /** - * @notes 退款前校验 - * @param $refundAmount - * @throws \Exception - * @author 段誉 - * @date 2023/2/28 16:27 - */ - public static function refundBeforeCheck($refundAmount) - { - if ($refundAmount <= 0) { - throw new \Exception('订单金额异常'); - } - } - - - /** - * @notes 微信支付退款 - * @param $order - * @param $refundAmount - * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException - * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException - * @author 段誉 - * @date 2023/2/28 17:19 - */ - public static function wechatPayRefund($order, $refundAmount) - { - // 发起退款。 若发起退款请求返回明确错误,退款日志和记录标记状态为退款失败 - // 退款日志及记录的成功状态目前统一由定时任务查询退款结果为退款成功后才标记成功 - // 也可通过设置退款回调,在退款回调时处理退款记录状态为成功 - (new WeChatPayService($order['order_terminal']))->refund([ - 'transaction_id' => $order['transaction_id'], - 'refund_sn' => self::$refundLog['sn'], - 'refund_amount' => $refundAmount,// 退款金额 - 'total_amount' => $order['order_amount'],// 订单金额 - ]); - } - - - /** - * @notes 退款请求失败处理 - * @param $refundRecordId - * @author 段誉 - * @date 2023/2/28 16:00 - * @remark 【微信,支付宝】退款接口请求失败时,更新退款记录及日志为失败,在退款记录重新发起 - */ - public static function refundFailHandle($refundRecordId, $msg) - { - // 更新退款日志记录 - RefundLog::update([ - 'id' => self::$refundLog['id'], - 'refund_status' => RefundEnum::REFUND_ERROR, - 'refund_msg' => $msg, - ]); - - // 更新退款记录状态为退款失败 - RefundRecord::update([ - 'id' => $refundRecordId, - 'refund_status' => RefundEnum::REFUND_ERROR, - 'refund_msg' => $msg, - ]); - } - - - /** - * @notes 退款日志 - * @param $order - * @param $refundRecordId - * @param $refundAmount - * @param $handleId - * @param int $refundStatus - * @author 段誉 - * @date 2023/2/28 15:29 - */ - public static function log($order, $refundRecordId, $refundAmount, $handleId, $refundStatus = RefundEnum::REFUND_ING) - { - $sn = generate_sn(RefundLog::class, 'sn'); - - self::$refundLog = RefundLog::create([ - 'sn' => $sn, - 'record_id' => $refundRecordId, - 'user_id' => $order['user_id'], - 'handle_id' => $handleId, - 'order_amount' => $order['order_amount'], - 'refund_amount' => $refundAmount, - 'refund_status' => $refundStatus - ]); - } - -} \ No newline at end of file diff --git a/app/common/model/HotSearch.php b/app/common/model/HotSearch.php deleted file mode 100644 index 8b24c5b9a..000000000 --- a/app/common/model/HotSearch.php +++ /dev/null @@ -1,20 +0,0 @@ - $userId, - 'article_id' => $articleId, - 'status' => YesNoEnum::YES - ])->findOrEmpty(); - - return !$collect->isEmpty(); - } - -} \ No newline at end of file diff --git a/app/common/model/decorate/DecoratePage.php b/app/common/model/decorate/DecoratePage.php deleted file mode 100644 index ed5b4bbeb..000000000 --- a/app/common/model/decorate/DecoratePage.php +++ /dev/null @@ -1,28 +0,0 @@ -toArray(); - - if (empty($tabbar)) { - return $tabbar; - } - - foreach ($tabbar as &$item) { - if (!empty($item['selected'])) { - $item['selected'] = FileService::getFileUrl($item['selected']); - } - if (!empty($item['unselected'])) { - $item['unselected'] = FileService::getFileUrl($item['unselected']); - } - } - - return $tabbar; - } -} \ No newline at end of file diff --git a/app/common/model/pay/PayConfig.php b/app/common/model/pay/PayConfig.php deleted file mode 100644 index bb75f6c3a..000000000 --- a/app/common/model/pay/PayConfig.php +++ /dev/null @@ -1,56 +0,0 @@ -value('name'); - } - - /** - * @notes 关联支配配置模型 - * @return \think\model\relation\HasOne - * @author ljj - * @date 2021/10/11 3:04 下午 - */ - public function payConfig() - { - return $this->hasOne(PayConfig::class,'id','pay_config_id'); - } -} \ No newline at end of file diff --git a/app/common/model/recharge/RechargeOrder.php b/app/common/model/recharge/RechargeOrder.php deleted file mode 100644 index 6a7da9f42..000000000 --- a/app/common/model/recharge/RechargeOrder.php +++ /dev/null @@ -1,57 +0,0 @@ -value('name'); - } - - - /** - * @notes 退款状态描述 - * @param $value - * @param $data - * @return string|string[] - * @author 段誉 - * @date 2022/12/1 10:55 - */ - public function getRefundStatusTextAttr($value, $data) - { - return RefundEnum::getStatusDesc($data['refund_status']); - } - -} diff --git a/app/common/model/refund/RefundRecord.php b/app/common/model/refund/RefundRecord.php deleted file mode 100644 index d077114a3..000000000 --- a/app/common/model/refund/RefundRecord.php +++ /dev/null @@ -1,71 +0,0 @@ -error; - } - - - /** - * @notes 设置错误信息 - * @param $error - * @author 段誉 - * @date 2021/7/21 18:20 - */ - public function setError($error) - { - $this->error = $error; - } - - - /** - * @notes 是否存在错误 - * @return bool - * @author 段誉 - * @date 2021/7/21 18:32 - */ - public function hasError() - { - return !empty($this->error); - } - - - /** - * @notes 设置状态码 - * @param $code - * @author 段誉 - * @date 2021/7/28 17:05 - */ - public function setReturnCode($code) - { - $this->returnCode = $code; - } - - - /** - * @notes 特殊场景返回指定状态码,默认为0 - * @return int - * @author 段誉 - * @date 2021/7/28 15:14 - */ - public function getReturnCode() - { - return $this->returnCode; - } - -} \ No newline at end of file diff --git a/app/common/service/pay/WeChatPayService.php b/app/common/service/pay/WeChatPayService.php deleted file mode 100644 index cd1f72e13..000000000 --- a/app/common/service/pay/WeChatPayService.php +++ /dev/null @@ -1,397 +0,0 @@ -terminal = $terminal; - $this->config = WeChatConfigService::getPayConfigByTerminal($terminal); - $this->app = new Application($this->config); - if ($userId !== null) { - $this->auth = UserAuth::where(['user_id' => $userId, 'terminal' => $terminal])->findOrEmpty(); - } - } - - - /** - * @notes 发起微信支付统一下单 - * @param $from - * @param $order - * @return array|false|string - * @author 段誉 - * @date 2021/8/4 15:05 - */ - public function pay($from, $order) - { - try { - switch ($this->terminal) { - case UserTerminalEnum::WECHAT_MMP: - $config = WeChatConfigService::getMnpConfig(); - $result = $this->jsapiPay($from, $order, $config['app_id']); - break; - case UserTerminalEnum::WECHAT_OA: - $config = WeChatConfigService::getOaConfig(); - $result = $this->jsapiPay($from, $order, $config['app_id']); - break; - case UserTerminalEnum::IOS: - case UserTerminalEnum::ANDROID: - $config = WeChatConfigService::getOpConfig(); - $result = $this->appPay($from, $order, $config['app_id']); - break; - case UserTerminalEnum::H5: - $config = WeChatConfigService::getOaConfig(); - $result = $this->mwebPay($from, $order, $config['app_id']); - break; - case UserTerminalEnum::PC: - $config = WeChatConfigService::getOaConfig(); - $result = $this->nativePay($from, $order, $config['app_id']); - break; - default: - throw new \Exception('支付方式错误'); - } - - return [ - 'config' => $result, - 'pay_way' => PayEnum::WECHAT_PAY - ]; - } catch (\Exception $e) { - $this->setError($e->getMessage()); - return false; - } - } - - - /** - * @notes jsapiPay - * @param $from - * @param $order - * @param $appId - * @return mixed - * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException - * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException - * @author 段誉 - * @date 2023/2/28 12:12 - */ - public function jsapiPay($from, $order, $appId) - { - $response = $this->app->getClient()->postJson("v3/pay/transactions/jsapi", [ - "appid" => $appId, - "mchid" => $this->config['mch_id'], - "description" => $this->payDesc($from), - "out_trade_no" => $order['pay_sn'], - "notify_url" => $this->config['notify_url'], - "amount" => [ - "total" => intval($order['order_amount'] * 100), - ], - "payer" => [ - "openid" => $this->auth['openid'] - ], - 'attach' => $from - ]); - - $result = $response->toArray(false); - $this->checkResultFail($result); - return $this->getPrepayConfig($result['prepay_id'], $appId); - } - - - /** - * @notes 网站native - * @param $from - * @param $order - * @param $appId - * @return mixed - * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException - * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException - * @author 段誉 - * @date 2023/2/28 12:12 - */ - public function nativePay($from, $order, $appId) - { - $response = $this->app->getClient()->postJson('v3/pay/transactions/native', [ - 'appid' => $appId, - 'mchid' => $this->config['mch_id'], - 'description' => $this->payDesc($from), - 'out_trade_no' => $order['pay_sn'], - 'notify_url' => $this->config['notify_url'], - 'amount' => [ - 'total' => intval($order['order_amount'] * 100), - ], - 'attach' => $from - ]); - $result = $response->toArray(false); - $this->checkResultFail($result); - return $result['code_url']; - } - - - /** - * @notes appPay - * @param $from - * @param $order - * @param $appId - * @return mixed - * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException - * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException - * @author 段誉 - * @date 2023/2/28 12:12 - */ - public function appPay($from, $order, $appId) - { - $response = $this->app->getClient()->postJson('v3/pay/transactions/app', [ - 'appid' => $appId, - 'mchid' => $this->config['mch_id'], - 'description' => $this->payDesc($from), - 'out_trade_no' => $order['pay_sn'], - 'notify_url' => $this->config['notify_url'], - 'amount' => [ - 'total' => intval($order['order_amount'] * 100), - ], - 'attach' => $from - ]); - $result = $response->toArray(false); - $this->checkResultFail($result); - return $result['prepay_id']; - } - - - /** - * @notes h5 - * @param $from - * @param $order - * @param $appId - * @param $redirectUrl - * @return mixed - * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException - * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException - * @author 段誉 - * @date 2023/2/28 12:13 - */ - public function mwebPay($from, $order, $appId) - { - $response = $this->app->getClient()->postJson('v3/pay/transactions/h5', [ - 'appid' => $appId, - 'mchid' => $this->config['mch_id'], - 'description' => $this->payDesc($from), - 'out_trade_no' => $order['pay_sn'], - 'notify_url' => $this->config['notify_url'], - 'amount' => [ - 'total' => intval($order['order_amount'] * 100), - ], - 'attach' => $from, - 'scene_info' => [ - 'payer_client_ip' => request()->ip(), - 'h5_info' => [ - 'type' => 'Wap', - ] - ] - ]); - $result = $response->toArray(false); - $this->checkResultFail($result); - - $domain = request()->domain(); - if (!empty(env('project.test_web_domain')) && env('APP_DEBUG')) { - $domain = env('project.test_web_domain'); - } - $redirectUrl = $domain . '/mobile'. $order['redirect_url'] .'?id=' . $order['id'] . '&from='. $from . '&checkPay=true'; - return $result['h5_url'] . '&redirect_url=' . urlencode($redirectUrl); - } - - - /** - * @notes 退款 - * @param array $refundData - * @return mixed - * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException - * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException - * @author 段誉 - * @date 2023/2/28 16:53 - */ - public function refund(array $refundData) - { - $response = $this->app->getClient()->postJson('v3/refund/domestic/refunds', [ - 'transaction_id' => $refundData['transaction_id'], - 'out_refund_no' => $refundData['refund_sn'], - 'amount' => [ - 'refund' => intval($refundData['refund_amount'] * 100), - 'total' => intval($refundData['total_amount'] * 100), - 'currency' => 'CNY', - ] - ]); - $result = $response->toArray(false); - $this->checkResultFail($result); - return $result; - } - - - /** - * @notes 查询退款 - * @param $refundSn - * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException - * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException - * @author 段誉 - * @date 2023/3/1 11:16 - */ - public function queryRefund($refundSn) - { - $response = $this->app->getClient()->get("v3/refund/domestic/refunds/{$refundSn}"); - return $response->toArray(false); - } - - - /** - * @notes 支付描述 - * @param $from - * @return string - * @author 段誉 - * @date 2023/2/27 17:54 - */ - public function payDesc($from) - { - $desc = [ - 'order' => '商品', - 'recharge' => '充值', - ]; - return $desc[$from] ?? '商品'; - } - - - /** - * @notes 捕获错误 - * @param $result - * @throws \Exception - * @author 段誉 - * @date 2023/2/28 12:09 - */ - public function checkResultFail($result) - { - if (!empty($result['code']) || !empty($result['message'])) { - throw new \Exception('微信:'. $result['code'] . '-' . $result['message']); - } - } - - - /** - * @notes 预支付配置 - * @param $prepayId - * @param $appId - * @return mixed[] - * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException - * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException - * @author 段誉 - * @date 2023/2/28 17:38 - */ - public function getPrepayConfig($prepayId, $appId) - { - return $this->app->getUtils()->buildBridgeConfig($prepayId, $appId); - } - - - /** - * @notes 支付回调 - * @return \Psr\Http\Message\ResponseInterface - * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException - * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException - * @throws \ReflectionException - * @throws \Throwable - * @author 段誉 - * @date 2023/2/28 14:20 - */ - public function notify() - { - $server = $this->app->getServer(); - // 支付通知 - $server->handlePaid(function (Message $message) { - if ($message['trade_state'] === 'SUCCESS') { - $extra['transaction_id'] = $message['transaction_id']; - $attach = $message['attach']; - $message['out_trade_no'] = mb_substr($message['out_trade_no'], 0, 18); - switch ($attach) { - case 'recharge': - $order = RechargeOrder::where(['sn' => $message['out_trade_no']])->findOrEmpty(); - if($order->isEmpty() || $order->pay_status == PayEnum::ISPAID) { - return true; - } - PayNotifyLogic::handle('recharge', $message['out_trade_no'], $extra); - break; - } - } - return true; - }); - - // 退款通知 - $server->handleRefunded(function (Message $message) { - return true; - }); - return $server->serve(); - } - - - - - -} \ No newline at end of file diff --git a/route/app.php b/route/app.php index d8792d206..7b7abdc9a 100644 --- a/route/app.php +++ b/route/app.php @@ -16,16 +16,6 @@ Route::rule('admin/:any', function () { return view(app()->getRootPath() . 'public/admin/index.html'); })->pattern(['any' => '\w+']); -// 手机端 -Route::rule('mobile/:any', function () { - return view(app()->getRootPath() . 'public/mobile/index.html'); -})->pattern(['any' => '\w+']); - -// PC端 -Route::rule('pc/:any', function () { - return view(app()->getRootPath() . 'public/pc/index.html'); -})->pattern(['any' => '\w+']); - //定时任务 Route::rule('crontab', function () { Console::call('crontab');