From 8eb3f85c37188af87bf138f6454820181b2ef9ab 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: Thu, 29 Aug 2024 15:45:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8F=AF=E8=AF=BB=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/PayController.php | 70 ++++++++++++++++---------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/app/controller/PayController.php b/app/controller/PayController.php index 42081b3..58750e5 100644 --- a/app/controller/PayController.php +++ b/app/controller/PayController.php @@ -208,41 +208,6 @@ class PayController } } } - // [定时任务]监听新订单,生成JSON文件信息 - public function checkOrder($pid = '', $sign = '') - { - if (!($pid && $sign)) { - return '参数错误'; - } - $is_user = User::checkUser($pid, $sign); - $path = '../runtime/order.json'; - if ($is_user) { - $orders = Order::scope('activeOrder')->field('id,pid,aid,cid')->select(); - if (!file_exists($path)) { - file_put_contents($path, '[]'); - } - $old_info = file_get_contents($path); - $num = count($orders); - if ($num > 0) { - $info = ['code' => 1, 'msg' => "有{$num}个新订单"]; - $order_list = ['code' => 1, 'msg' => "有{$num}个新订单", 'orders' => $orders]; - if ($old_info !== json_encode($order_list)) { - file_put_contents($path, json_encode($order_list)); - } - return json($info); - } else { - $info = ['code' => 0, 'msg' => '没有新订单']; - if ($old_info !== json_encode($info, 320)) { - file_put_contents($path, json_encode($info, 320)); - } - return json($info); - } - } else { - $info = ['code' => 2, 'msg' => '签名错误']; - file_put_contents($path, json_encode($info, 320)); - return json($info); - } - } // 获取收款通知,提交收款订单明细 public function checkPayResult(Request $request) { @@ -307,6 +272,41 @@ class PayController return \json(['code' => 0, 'msg' => '查询空订单'], 320); } } + // [定时任务]监听新订单,生成JSON文件信息 + public function checkOrder($pid = '', $sign = '') + { + if (!($pid && $sign)) { + return '参数错误'; + } + $is_user = User::checkUser($pid, $sign); + $path = '../runtime/order.json'; + if ($is_user) { + $orders = Order::scope('activeOrder')->field('id,pid,aid,cid')->select(); + if (!file_exists($path)) { + file_put_contents($path, '[]'); + } + $old_info = file_get_contents($path); + $num = count($orders); + if ($num > 0) { + $info = ['code' => 1, 'msg' => "有{$num}个新订单"]; + $order_list = ['code' => 1, 'msg' => "有{$num}个新订单", 'orders' => $orders]; + if ($old_info !== json_encode($order_list)) { + file_put_contents($path, json_encode($order_list)); + } + return json($info); + } else { + $info = ['code' => 0, 'msg' => '没有新订单']; + if ($old_info !== json_encode($info, 320)) { + file_put_contents($path, json_encode($info, 320)); + } + return json($info); + } + } else { + $info = ['code' => 2, 'msg' => '签名错误']; + file_put_contents($path, json_encode($info, 320)); + return json($info); + } + } // 签名 private static function getSign(array $param = [], string $key = ''): string {