From 86a88bf71d4994bb465cfda9b2729bdb86b924b2 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 20 Jul 2024 21:36:16 +0800 Subject: [PATCH 1/2] =?UTF-8?q?refactor(PayNotifyLogic):=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=94=AF=E4=BB=98=E9=80=9A=E7=9F=A5=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=AF=B9=E8=AE=A2=E5=8D=95=E6=9D=A5?= =?UTF-8?q?=E6=BA=90=E7=9A=84=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PayNotifyLogic.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 8a3fe80e..fc3b8c40 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -106,7 +106,7 @@ class PayNotifyLogic extends BaseLogic ]; self::dealGoodsLeft($checkArr, $order['uid'], $order['id']); } - if ($order && $order['store_id'] && $order['reservation'] !=1) { + if ($order && $order['store_id'] && $order['reservation'] !=1 && $order['source']==1) { $params = [ 'verify_code' => $order['verify_code'], 'store_id' => $order['store_id'], @@ -211,7 +211,7 @@ class PayNotifyLogic extends BaseLogic // } // self::addUserSing($order); self::afterPay($order); - if ($order && $order['store_id'] && $order['reservation'] !=1) { + if ($order && $order['store_id'] && $order['reservation'] !=1 && $order['source']==1) { $params = [ 'verify_code' => $order['verify_code'], 'store_id' => $order['store_id'], From d9bb85651eb5458d5537b00a882e79736c20c4ed Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 30 Jul 2024 10:25:21 +0800 Subject: [PATCH 2/2] 1 --- app/api/controller/order/OrderController.php | 6 +++-- process/Task.php | 26 ++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/app/api/controller/order/OrderController.php b/app/api/controller/order/OrderController.php index 299cbc2b..3fbb8e1f 100644 --- a/app/api/controller/order/OrderController.php +++ b/app/api/controller/order/OrderController.php @@ -16,6 +16,7 @@ use app\common\model\store_order\StoreOrder; use app\common\model\system_store\SystemStoreStaff; use app\common\model\user\User; use app\common\model\user\UserAddress; +use think\facade\Db; use Webman\RedisQueue\Redis; class OrderController extends BaseApiController @@ -181,7 +182,8 @@ class OrderController extends BaseApiController if (isset($result['trade_state_desc']) && $result['trade_state_desc'] == '支付成功') { PayNotifyLogic::handle('StoreOrder', $result['out_trade_no'], $result); } else { - Redis::send('send-code-pay', ['number' => $order['number']]); + Db::name('wechat_micropay')->insert(['order_id'=>$order['order_id'],'create_time'=>time(),'update_time'=>time()]); + Redis::send('send-code-pay',['order_id' => $order['order_id']]); return $this->success('用户支付中'); } return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::WECHAT_PAY_BARCODE, 'transaction_id' => $result['transaction_id']]); @@ -290,7 +292,7 @@ class OrderController extends BaseApiController if (isset($result['trade_state_desc']) && $result['trade_state_desc'] == '支付成功') { PayNotifyLogic::handle('StoreOrder', $result['out_trade_no'], $result); } else { - Redis::send('send-code-pay', ['number' => $order['number']]); + Redis::send('send-code-pay', ['order_id' => $order['order_id']]); return $this->success('用户支付中'); } return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::WECHAT_PAY_BARCODE, 'transaction_id' => $result['transaction_id']]); diff --git a/process/Task.php b/process/Task.php index 789c98e8..56a913db 100644 --- a/process/Task.php +++ b/process/Task.php @@ -2,13 +2,16 @@ namespace process; +use app\common\logic\PayNotifyLogic; use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_order\StoreOrder; use app\common\model\store_order_cart_info\StoreOrderCartInfo; use app\common\model\store_product\StoreProduct; use app\common\model\user_recharge\UserRecharge; +use think\facade\Db; use Webman\RedisQueue\Redis; use Workerman\Crontab\Crontab; +use app\common\service\pay\PayService; class Task { @@ -58,5 +61,28 @@ class Task Redis::send('task-recharge-query', ['order_id' => $v]); } }); + //每10秒执行一次 + // new Crontab('*/10 * * * * *', function () { + // $select=Db::name('wechat_micropay')->limit(100)->select(); + // $pay = new PayService(); + // foreach ($select as $k=>$v) { + // $time = time(); + // if ($time - $v['create_time'] > 60){ + // Db::name('wechat_micropay')->where('id',$v['id'])->delete(); + // continue; + // } + // $order = [ + // 'out_trade_no' => $v['order_id'], + // ]; + // $res = $pay->wechat->query($order); + // if ($res['trade_state'] == 'SUCCESS' && $res['trade_state_desc'] == '支付成功') { + // if(isset($data['pay_type']) && $data['pay_type']=='recharge'){ + // PayNotifyLogic::handle('recharge', $res['out_trade_no'], $res); + // }else{ + // PayNotifyLogic::handle('wechat_common', $res['out_trade_no'], $res); + // } + // } + // } + // }); } }