Przeglądaj źródła

第三方重复通知的限制

shish 5 lat temu
rodzic
commit
991b854032

+ 6 - 1
biz-hd/order/classes/OrderClass.php

@@ -163,12 +163,17 @@ class OrderClass extends BaseClass
             Yii::info($msg);
             util::fail($msg);
         }
+
+        //临时解决微信一秒内通知二次问题
+        $id = $order->id;
+        $order = self::getLockById($id);
+
         $date = date("Y-m-d H:i:s");
         $order->payTime = $date;
         $order->thirdPay = dict::getDict('thirdPay', 'onlineWay');
         $order->save();
         self::complete($order, $payWay);
-		//订单全部流程走完了再通知
+        //订单全部流程走完了再通知
         if ($order->fromType == dict::getDict("fromType", "shop")) {
             $shopAdminIds = \bizGhs\shop\classes\ShopAdminClass::getRemindAdminIdsByShopId($order->shopId);
             if ($shopAdminIds) {

+ 5 - 0
biz-hd/purchase/classes/PurchaseClearClass.php

@@ -95,6 +95,11 @@ class PurchaseClearClass extends BaseClass
             Yii::info($msg);
             util::fail($msg);
         }
+
+        //临时解决微信一秒内通知二次问题
+        $id = $info->id;
+        $info = self::getLockById($id);
+
         self::complete($info, $payWay);
     }
 

+ 5 - 0
biz-hd/purchase/services/PurchaseService.php

@@ -203,6 +203,11 @@ class PurchaseService extends BaseService
             Yii::info($msg);
             util::fail($msg);
         }
+
+        //临时解决微信一秒内通知二次问题
+        $id = $info->id;
+        $info = PurchaseClass::getLockById($id);
+
         $info->thirdPay = dict::getDict('thirdPay', 'onlineWay');
         $info->thirdNo = $transactionId;
         $info->save();

+ 5 - 0
biz-hd/px/services/PxApplyService.php

@@ -36,6 +36,11 @@ class PxApplyService extends BaseService
             Yii::info($msg);
             util::fail($msg);
         }
+
+        //临时解决微信一秒内通知二次问题
+        $id = $order->id;
+        $order = PxApplyClass::getLockById($id);
+
         PxApplyClass::complete($order, $payWay);
     }
 

+ 5 - 0
biz/recharge/classes/RechargeClass.php

@@ -80,6 +80,11 @@ class RechargeClass extends BaseClass
             noticeUtil::push("充值付款成功,收到回调,但订单是已经支付过了,orderSn:" . $orderSn, '15280215347');
             return false;
         }
+
+        //临时解决微信一秒内通知二次问题
+        $id = $recharge->id;
+        $recharge = RechargeClass::getLockById($id);
+
         parse_str($attach);
         //是否充值免费续期
         $rechargeRenew = isset($rechargeRenew) ? $rechargeRenew : 0;

+ 5 - 0
biz/renew/classes/RenewClass.php

@@ -34,6 +34,11 @@ class RenewClass extends BaseClass
         if ($order->status != self::STATUS_UN_PAY) {
             util::fail('订单不是待付款状态');
         }
+
+        //临时解决微信一秒内通知二次问题
+        $id = $order->id;
+        $order = self::getLockById($id);
+
         parse_str($attach);
         //是否充值免费续期
         $sjId = isset($sjId) ? $sjId : 0;

+ 11 - 0
common/components/payUtil.php

@@ -15,6 +15,17 @@ class payUtil
 
     public static function thirdPay($payWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId = '')
     {
+
+        //2秒内不允许第三方重复通知
+        $cacheKey = 'third_pay_' . $orderSn;
+        $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
+        if (!empty($has)) {
+            Yii::info("第三方2秒内重复通知:{$capitalType} {$orderSn}");
+            return false;
+        }
+        Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 2, 'has']);
+
+
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
         try {