Procházet zdrojové kódy

花卉宝-扫码支付bug处理

ouyang před 15 hodinami
rodič
revize
6e654fc895
1 změnil soubory, kde provedl 16 přidání a 6 odebrání
  1. 16 6
      app-mall/controllers/OrderController.php

+ 16 - 6
app-mall/controllers/OrderController.php

@@ -1497,13 +1497,18 @@ class OrderController extends BaseController
         }
     }
 
-    //下单要用到的相关信息 ssh 2019.12.6
+    /**
+     * 下单相关信息(门店名、区域树等)
+     * 扫码付款页常用;换店后若仍带上一家 hdId,BaseController 会清空 shop,须 recover 后再取属性,否则前端拼分享会出现 account=undefined
+     */
     public function actionOrderRelate()
     {
         $regionTree = RegionService::tree();
 
-        //门店名称
-        $shop = !empty($this->shop) ? $this->shop->attributes : [];
+        // 按 account 恢复门店(跨店残留 hdId 被越权清空后仍能取到扫码目标店)
+        $ctx = $this->recoverShopContext();
+        $shopModel = $ctx['shop'];
+        $shop = !empty($shopModel) ? $shopModel->attributes : [];
         $sjName = $shop['merchantName'] ?? '';
         $shopName = $shop['shopName'] ?? '';
         $shop['showName'] = $shopName == '首店' ? $sjName : $sjName . ' ' . $shopName;
@@ -1773,14 +1778,19 @@ class OrderController extends BaseController
         util::success($new);
     }
 
-    //快捷付款订单
+    /**
+     * 快捷付款(扫码输入金额)
+     * 换店扫码时前端可能仍带上一家 hdId,BaseController 会清空 shop;此处按 account 恢复门店后再下单。
+     */
     public function actionFastPay()
     {
         ini_set('date.timezone', 'Asia/Shanghai');
         $post = Yii::$app->request->post();
         $payWay = $post['payWay'] ?? 0;
-        $shopId = $this->shopId;
-        $shop = $this->shop;
+        // 跨店残留 hdId 导致 shop 被清空时,仍以 account 恢复目标门店
+        $ctx = $this->recoverShopContext();
+        $shopId = $ctx['shopId'];
+        $shop = $ctx['shop'];
         if (empty($shop)) {
             util::fail('没有门店信息');
         }