From 5ad72a36b2f722a1cff30eaad85e2c41f7615c52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=8A=80=E6=9C=AF=E8=80=81=E8=83=A1?= <1094551889@qq.com> Date: Fri, 6 Sep 2024 09:49:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=94=B6=E6=AC=BE=E7=9B=91?= =?UTF-8?q?=E5=90=AC=E6=A8=A1=E5=BC=8F=E5=89=8D=E7=AB=AF=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/PayController.php | 20 ++++++- app/controller/api/PayManageController.php | 17 ------ app/controller/api/PluginController.php | 25 ++++++++- config/extendconfig/platform.php | 11 ++++ route/app.php | 2 + runtime/order.json | 2 +- view/pay/console.html | 64 +++++++++++++++++++++- 7 files changed, 118 insertions(+), 23 deletions(-) create mode 100644 config/extendconfig/platform.php diff --git a/app/controller/PayController.php b/app/controller/PayController.php index b08fe15..6c5bb57 100644 --- a/app/controller/PayController.php +++ b/app/controller/PayController.php @@ -90,10 +90,12 @@ class PayController public function console($order_id = '') { if ($order_id) { - $act_order = Order::where('order_id', $order_id)->field(['out_trade_no', 'name', 'really_price', 'close_time', 'type', 'order_id', 'cid'])->find(); + $act_order = Order::where('order_id', $order_id)->find(); if ($act_order) { $qrcode = PayChannel::where('id', $act_order->cid)->value('qrcode'); View::assign($act_order->toArray()); + $passtime = strtotime($act_order->close_time) - time(); + View::assign('passtime', $passtime > 0 ? $passtime : 0); View::assign('payUrl', $qrcode); return View::fetch(); } else { @@ -139,6 +141,22 @@ class PayController return '订单号参数错误'; } } + // 验证支付结果 + public function validatePayResult(Request $request) + { + $data = $request->post(); + $order = Order::find($data['id']); + if (\strtotime($order->close_time) < \time()) { + return \json(\backMsg(1, '订单已关闭')); + } + $up_data = ['id' => $data['id'], 'patt' => $data['patt']]; + $up_res = Order::update($up_data); + if ($up_res) { + return \json(\backMsg(0, '更新成功')); + } else { + return \json(\backMsg(1, '更新失败')); + } + } // 处理收款通知 public function payHeart($pid = '', $aid = '', $sign = '') { diff --git a/app/controller/api/PayManageController.php b/app/controller/api/PayManageController.php index d7ba26b..140a1fc 100644 --- a/app/controller/api/PayManageController.php +++ b/app/controller/api/PayManageController.php @@ -131,21 +131,4 @@ class PayManageController extends BaseController $path = "../config/payconfig/{$name}.php"; \file_put_contents($path, $config); } - // 生成平台列表配置 - public function crtPlfConfig() - { - $info = Platform::where('state', 1)->field('platform, name')->select()->toArray(); - $data = []; - foreach ($info as $value) { - $data[$value['platform']] = $value['name']; - } - $config = View::fetch('tpl/platform_config', $data); - $path = "../config/extendconfig/platform.php"; - $res = \file_put_contents($path, $config); - if ($res) { - return \json(\backMsg(msg: '创建成功')); - } else { - return \json(\backMsg(1, '创建成功')); - } - } } diff --git a/app/controller/api/PluginController.php b/app/controller/api/PluginController.php index e95ff74..4398bb1 100644 --- a/app/controller/api/PluginController.php +++ b/app/controller/api/PluginController.php @@ -6,6 +6,7 @@ namespace app\controller\api; use app\BaseController; use app\model\Platform; +use think\facade\View; class PluginController extends BaseController { @@ -34,7 +35,29 @@ class PluginController extends BaseController // 插件选项 public function pluginOption() { - $option = Platform::field('platform,name')->where('state', 1)->select(); + // 加载平台配置 + $platform = \think\facade\Config::load("extendconfig/platform", 'extendconfig'); + $option = []; + foreach ($platform as $key => $value) { + $option[] = ['platform' => $key, 'name' => $value]; + } return json($option); } + // 生成插件配置 + public function crtPlfConfig() + { + $info = Platform::where('state', 1)->field('platform, name')->select()->toArray(); + $data = []; + foreach ($info as $value) { + $data[$value['platform']] = $value['name']; + } + $config = View::fetch('tpl/platform_config', $data); + $path = "../config/extendconfig/platform.php"; + $res = \file_put_contents($path, $config); + if ($res) { + return \json(\backMsg(msg: '创建成功')); + } else { + return \json(\backMsg(1, '创建成功')); + } + } } diff --git a/config/extendconfig/platform.php b/config/extendconfig/platform.php new file mode 100644 index 0000000..d5c8fd8 --- /dev/null +++ b/config/extendconfig/platform.php @@ -0,0 +1,11 @@ + '收钱吧', + 'storepay' => '数字门店', + 'ysepay' => '小Y经营', + 'mqpay' => '码钱', +); \ No newline at end of file diff --git a/route/app.php b/route/app.php index 4ff506a..3f42c6b 100644 --- a/route/app.php +++ b/route/app.php @@ -16,6 +16,8 @@ Route::rule('checkOrder/[:pid]/[:sign]', 'Pay/checkOrder'); Route::rule('payHeart/[:pid]/[:aid]/[:sign]', 'Pay/payHeart'); // 监听收款通知 Route::rule('checkPayResult', 'Pay/checkPayResult'); +// 验证支付结果 +Route::rule('validatePayResult', 'Pay/validatePayResult'); // API多级控制器 Route::rule('api/:controller/:methon', 'api.:controller/:methon'); diff --git a/runtime/order.json b/runtime/order.json index 78a6dd1..51b4235 100644 --- a/runtime/order.json +++ b/runtime/order.json @@ -1 +1 @@ -{"code":1,"msg":"\u67091\u4e2a\u65b0\u8ba2\u5355","orders":[{"id":27428,"pid":1001,"aid":1,"cid":1,"patt":1}]} \ No newline at end of file +{"code":0,"msg":"没有新订单"} \ No newline at end of file diff --git a/view/pay/console.html b/view/pay/console.html index 497632e..55d924f 100644 --- a/view/pay/console.html +++ b/view/pay/console.html @@ -5,7 +5,7 @@