From d74ed0c4b19dba0f300e17b3e430d62450143c28 Mon Sep 17 00:00:00 2001 From: xiaochong0302 Date: Tue, 20 May 2025 18:06:11 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E5=90=8E=E5=8F=B0=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E9=BB=98=E8=AE=A4=E5=80=BC=202.=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=BF=94=E5=9B=9E=E9=A1=B6=E9=83=A8=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=203.=E7=B2=BE=E7=AE=80=E4=BC=98=E5=8C=96=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Tasks/SyncAppInfoTask.php | 6 +- app/Http/Admin/Views/templates/main.volt | 3 +- .../Home/Controllers/ConnectController.php | 19 +++--- app/Validators/Order.php | 53 +++++----------- app/Validators/Trade.php | 2 +- config/errors.php | 10 ++- db/migrations/20210403184518.php | 63 +++++++------------ public/static/admin/js/fixbar.js | 7 +++ 8 files changed, 66 insertions(+), 97 deletions(-) create mode 100644 public/static/admin/js/fixbar.js diff --git a/app/Console/Tasks/SyncAppInfoTask.php b/app/Console/Tasks/SyncAppInfoTask.php index 361d029e..d2d73f6d 100644 --- a/app/Console/Tasks/SyncAppInfoTask.php +++ b/app/Console/Tasks/SyncAppInfoTask.php @@ -13,12 +13,12 @@ use GuzzleHttp\Client; class SyncAppInfoTask extends Task { + const API_BASE_URL = 'https://www.koogua.com/api'; + public function mainAction() { echo '------ start sync app info ------' . PHP_EOL; - $url = 'https://www.koogua.com/api/instance/collect'; - $site = $this->getSettings('site'); $serverHost = parse_url($site['url'], PHP_URL_HOST); @@ -38,6 +38,8 @@ class SyncAppInfoTask extends Task $client = new Client(); + $url = sprintf('%s/instance/collect', self::API_BASE_URL); + $client->request('POST', $url, ['form_params' => $params]); echo '------ end sync app info ------' . PHP_EOL; diff --git a/app/Http/Admin/Views/templates/main.volt b/app/Http/Admin/Views/templates/main.volt index 70658df7..c3053014 100644 --- a/app/Http/Admin/Views/templates/main.volt +++ b/app/Http/Admin/Views/templates/main.volt @@ -20,6 +20,7 @@ {{ js_include('lib/layui/layui.js') }} {{ js_include('admin/js/common.js') }} +{{ js_include('admin/js/fixbar.js') }} {% block include_js %}{% endblock %} {% block inline_js %}{% endblock %} @@ -33,4 +34,4 @@ {% endif %} - \ No newline at end of file + diff --git a/app/Http/Home/Controllers/ConnectController.php b/app/Http/Home/Controllers/ConnectController.php index 9653c43d..2a155f83 100644 --- a/app/Http/Home/Controllers/ConnectController.php +++ b/app/Http/Home/Controllers/ConnectController.php @@ -120,19 +120,16 @@ class ConnectController extends Controller $service = new ConnectService(); $openUser = $service->getOpenUserInfo($code, $state, $provider); - $connect = $service->getConnectRelation($openUser['id'], $openUser['provider']); - if ($this->authUser->id > 0) { - if ($openUser) { - $service->bindUser($openUser); - return $this->response->redirect(['for' => 'home.uc.account']); - } - } else { - if ($connect) { - $service->authConnectLogin($connect); - return $this->response->redirect(['for' => 'home.index']); - } + if ($this->authUser->id > 0 && $openUser) { + $service->bindUser($openUser); + return $this->response->redirect(['for' => 'home.uc.account']); + } + + if ($this->authUser->id == 0 && $connect) { + $service->authConnectLogin($connect); + return $this->response->redirect(['for' => 'home.index']); } $this->seo->prependTitle('绑定帐号'); diff --git a/app/Validators/Order.php b/app/Validators/Order.php index 9a390ba4..8cc3422f 100644 --- a/app/Validators/Order.php +++ b/app/Validators/Order.php @@ -11,10 +11,7 @@ use App\Exceptions\BadRequest as BadRequestException; use App\Models\Order as OrderModel; use App\Models\Refund as RefundModel; use App\Models\Trade as TradeModel; -use App\Repos\Course as CourseRepo; use App\Repos\Order as OrderRepo; -use App\Repos\Package as PackageRepo; -use App\Repos\Vip as VipRepo; class Order extends Validator { @@ -50,54 +47,36 @@ class Order extends Validator return $order; } - public function checkItemType($itemType) + public function checkItemType($type) { - $list = OrderModel::itemTypes(); + $types = OrderModel::itemTypes(); - if (!array_key_exists($itemType, $list)) { + if (!array_key_exists($type, $types)) { throw new BadRequestException('order.invalid_item_type'); } - return $itemType; + return $type; } - public function checkCourse($itemId) + public function checkCourse($id) { - $courseRepo = new CourseRepo(); + $validator = new Course(); - $course = $courseRepo->findById($itemId); - - if (!$course || $course->published == 0) { - throw new BadRequestException('order.item_not_found'); - } - - return $course; + return $validator->checkCourse($id); } - public function checkPackage($itemId) + public function checkPackage($id) { - $packageRepo = new PackageRepo(); + $validator = new Package(); - $package = $packageRepo->findById($itemId); - - if (!$package || $package->published == 0) { - throw new BadRequestException('order.item_not_found'); - } - - return $package; + return $validator->checkPackage($id); } - public function checkVip($itemId) + public function checkVip($id) { - $vipRepo = new VipRepo(); + $validator = new Vip(); - $vip = $vipRepo->findById($itemId); - - if (!$vip || $vip->deleted == 1) { - throw new BadRequestException('order.item_not_found'); - } - - return $vip; + return $validator->checkVip($id); } public function checkAmount($amount) @@ -105,7 +84,7 @@ class Order extends Validator $value = $this->filter->sanitize($amount, ['trim', 'float']); if ($value < 0.01 || $value > 100000) { - throw new BadRequestException('order.invalid_pay_amount'); + throw new BadRequestException('order.invalid_amount'); } return $value; @@ -148,7 +127,7 @@ class Order extends Validator ]; if (!in_array($order->item_type, $types)) { - throw new BadRequestException('order.refund_item_unsupported'); + throw new BadRequestException('order.refund_not_supported'); } $orderRepo = new OrderRepo(); @@ -167,7 +146,7 @@ class Order extends Validator ]; if ($refund && in_array($refund->status, $scopes)) { - throw new BadRequestException('order.refund_apply_existed'); + throw new BadRequestException('order.refund_request_existed'); } } diff --git a/app/Validators/Trade.php b/app/Validators/Trade.php index d69f94ba..66ad3e4f 100644 --- a/app/Validators/Trade.php +++ b/app/Validators/Trade.php @@ -91,7 +91,7 @@ class Trade extends Validator ]; if ($refund && in_array($refund->status, $scopes)) { - throw new BadRequestException('trade.refund_apply_existed'); + throw new BadRequestException('trade.refund_request_existed'); } } diff --git a/config/errors.php b/config/errors.php index 207c509d..062f81b6 100644 --- a/config/errors.php +++ b/config/errors.php @@ -363,17 +363,15 @@ $error['slide.invalid_publish_status'] = '无效的发布状态'; * 订单相关 */ $error['order.not_found'] = '订单不存在'; +$error['order.invalid_amount'] = '无效的支付金额'; $error['order.invalid_status'] = '无效的状态类型'; -$error['order.item_not_found'] = '商品不存在'; -$error['order.trade_expired'] = '交易已过期'; $error['order.is_delivering'] = '已经下过单了,正在准备发货中'; $error['order.has_bought_course'] = '已经购买过该课程'; $error['order.has_bought_package'] = '已经购买过该套餐'; $error['order.cancel_not_allowed'] = '当前不允许取消订单'; -$error['order.close_not_allowed'] = '当前不允许关闭订单'; $error['order.refund_not_allowed'] = '当前不允许申请退款'; -$error['order.refund_item_unsupported'] = '该品类不支持退款'; -$error['order.refund_apply_existed'] = '退款申请已经存在'; +$error['order.refund_not_supported'] = '该品类不支持退款'; +$error['order.refund_request_existed'] = '退款申请已经存在'; /** * 交易相关 @@ -384,7 +382,7 @@ $error['trade.invalid_channel'] = '无效的平台类型'; $error['trade.invalid_status'] = '无效的状态类型'; $error['trade.close_not_allowed'] = '当前不允许关闭交易'; $error['trade.refund_not_allowed'] = '当前不允许交易退款'; -$error['trade.refund_apply_existed'] = '退款申请已经存在,请等待处理结果'; +$error['trade.refund_request_existed'] = '退款申请已经存在,请等待处理结果'; /** * 退款相关 diff --git a/db/migrations/20210403184518.php b/db/migrations/20210403184518.php index 148bc846..3186f788 100644 --- a/db/migrations/20210403184518.php +++ b/db/migrations/20210403184518.php @@ -294,21 +294,6 @@ final class V20210403184518 extends AbstractMigration protected function initSettingData() { $rows = [ - [ - 'section' => 'captcha', - 'item_key' => 'enabled', - 'item_value' => '0', - ], - [ - 'section' => 'captcha', - 'item_key' => 'app_id', - 'item_value' => '', - ], - [ - 'section' => 'captcha', - 'item_key' => 'secret_key', - 'item_value' => '', - ], [ 'section' => 'live.push', 'item_key' => 'domain', @@ -392,7 +377,7 @@ final class V20210403184518 extends AbstractMigration [ 'section' => 'mail', 'item_key' => 'smtp_host', - 'item_value' => 'smtp.163.com', + 'item_value' => '', ], [ 'section' => 'mail', @@ -412,22 +397,22 @@ final class V20210403184518 extends AbstractMigration [ 'section' => 'mail', 'item_key' => 'smtp_username', - 'item_value' => 'xxx@163.com', + 'item_value' => '', ], [ 'section' => 'mail', 'item_key' => 'smtp_password', - 'item_value' => 'xxx', + 'item_value' => '', ], [ 'section' => 'mail', 'item_key' => 'smtp_from_email', - 'item_value' => 'xxx@163.com', + 'item_value' => '', ], [ 'section' => 'mail', 'item_key' => 'smtp_from_name', - 'item_value' => 'XXX有限公司', + 'item_value' => '', ], [ 'section' => 'pay.alipay', @@ -512,17 +497,17 @@ final class V20210403184518 extends AbstractMigration [ 'section' => 'secret', 'item_key' => 'secret_key', - 'item_value' => 'xxx', + 'item_value' => '', ], [ 'section' => 'secret', 'item_key' => 'secret_id', - 'item_value' => 'xxx', + 'item_value' => '', ], [ 'section' => 'secret', 'item_key' => 'app_id', - 'item_value' => 'xxx', + 'item_value' => '', ], [ 'section' => 'site', @@ -617,29 +602,29 @@ final class V20210403184518 extends AbstractMigration [ 'section' => 'sms', 'item_key' => 'signature', - 'item_value' => '酷瓜云课堂', + 'item_value' => '', ], [ 'section' => 'sms', 'item_key' => 'template', 'item_value' => json_encode([ - 'verify' => ['enabled' => 1, 'id' => ''], - 'order_finish' => ['enabled' => 1, 'id' => ''], - 'refund_finish' => ['enabled' => 1, 'id' => ''], - 'live_begin' => ['enabled' => 1, 'id' => ''], - 'consult_reply' => ['enabled' => 1, 'id' => ''], - 'goods_deliver' => ['enabled' => 1, 'id' => ''], + 'verify' => ['enabled' => 1, 'id' => 0], + 'order_finish' => ['enabled' => 0, 'id' => 0], + 'refund_finish' => ['enabled' => 0, 'id' => 0], + 'live_begin' => ['enabled' => 0, 'id' => 0], + 'consult_reply' => ['enabled' => 0, 'id' => 0], + 'goods_deliver' => ['enabled' => 0, 'id' => 0], ]), ], [ 'section' => 'cos', 'item_key' => 'bucket', - 'item_value' => 'course-1255691183', + 'item_value' => '', ], [ 'section' => 'cos', 'item_key' => 'region', - 'item_value' => 'ap-guangzhou', + 'item_value' => '', ], [ 'section' => 'cos', @@ -649,7 +634,7 @@ final class V20210403184518 extends AbstractMigration [ 'section' => 'cos', 'item_key' => 'domain', - 'item_value' => 'course-1255691183.file.myqcloud.com', + 'item_value' => '', ], [ 'section' => 'vod', @@ -835,12 +820,12 @@ final class V20210403184518 extends AbstractMigration 'section' => 'wechat.oa', 'item_key' => 'notice_template', 'item_value' => json_encode([ - 'account_login' => ['enabled' => 1, 'id' => ''], - 'order_finish' => ['enabled' => 1, 'id' => ''], - 'refund_finish' => ['enabled' => 1, 'id' => ''], - 'goods_deliver' => ['enabled' => 1, 'id' => ''], - 'consult_reply' => ['enabled' => 1, 'id' => ''], - 'live_begin' => ['enabled' => 1, 'id' => ''], + 'account_login' => ['enabled' => 0, 'id' => 0], + 'order_finish' => ['enabled' => 0, 'id' => 0], + 'refund_finish' => ['enabled' => 0, 'id' => 0], + 'goods_deliver' => ['enabled' => 0, 'id' => 0], + 'consult_reply' => ['enabled' => 0, 'id' => 0], + 'live_begin' => ['enabled' => 0, 'id' => 0], ]), ], [ diff --git a/public/static/admin/js/fixbar.js b/public/static/admin/js/fixbar.js new file mode 100644 index 00000000..ab5bccb6 --- /dev/null +++ b/public/static/admin/js/fixbar.js @@ -0,0 +1,7 @@ +layui.use(['util'], function () { + + var util = layui.util; + + util.fixbar(); + +}); \ No newline at end of file