WIN-2308041133\Administrator преди 2 месеца
родител
ревизия
47e4dded1e
променени са 1 файла, в които са добавени 17 реда и са изтрити 16 реда
  1. 17 16
      app/services/order/StoreOrderCreateServices.php

+ 17 - 16
app/services/order/StoreOrderCreateServices.php

@@ -232,6 +232,23 @@ class StoreOrderCreateServices extends BaseServices
             }
             }
 //                @file_put_contents('quanju.txt', json_encode($cart) . "-购物车\r\n", 8);
 //                @file_put_contents('quanju.txt', json_encode($cart) . "-购物车\r\n", 8);
 
 
+            }
+            if ($is_lb == 1){
+                if ($lb_spread_uid == 0){
+                    throw new ApiException('没有推荐关系或者推荐人的用户无法购买,请重新扫描推荐二维码');
+                }
+                /** @var StoreProductGiftGroupService  $storeProductGiftGroupService */
+                $storeProductGiftGroupService = app()->make(StoreProductGiftGroupService::class);
+
+                // 检查用户是否已在礼包关系表中存在(作为uid或pid)
+                $existsAsUid = $storeProductGiftGroupService->getOne(['uid' => $uid]);
+                $existsAsPid = $storeProductGiftGroupService->getOne(['pid' => $uid]);
+
+                // 如果两者都不存在,说明用户还没参与礼包推荐关系,无法购买
+                if (!$existsAsUid && !$existsAsPid) {
+                    throw new ApiException('没有推荐关系或者推荐人的用户无法购买,请重新扫描推荐二维码');
+                }
+
             }
             }
             if (count($cartInfo) == 1 && isset($cartInfo[0]['productInfo']['presale']) && $cartInfo[0]['productInfo']['presale'] == 1) {
             if (count($cartInfo) == 1 && isset($cartInfo[0]['productInfo']['presale']) && $cartInfo[0]['productInfo']['presale'] == 1) {
                 $advance_id = $cartInfo[0]['product_id'];
                 $advance_id = $cartInfo[0]['product_id'];
@@ -294,23 +311,7 @@ class StoreOrderCreateServices extends BaseServices
                 'lb_spread_uid' => $lb_spread_uid,
                 'lb_spread_uid' => $lb_spread_uid,
                 'is_lb' => $is_lb
                 'is_lb' => $is_lb
             ];
             ];
-            if ($is_lb == 1){
-                if ($lb_spread_uid == 0){
-                    throw new ApiException('没有推荐关系或者推荐人的用户无法购买,请重新扫描推荐二维码');
-                }
-                /** @var StoreProductGiftGroupService  $storeProductGiftGroupService */
-                $storeProductGiftGroupService = app()->make(StoreProductGiftGroupService::class);
-
-                // 检查用户是否已在礼包关系表中存在(作为uid或pid)
-                $existsAsUid = $storeProductGiftGroupService->getOne(['uid' => $uid]);
-                $existsAsPid = $storeProductGiftGroupService->getOne(['pid' => $uid]);
-
-                // 如果两者都不存在,说明用户还没参与礼包推荐关系,无法购买
-                if (!$existsAsUid && !$existsAsPid) {
-                    throw new ApiException('您还未参与礼包推荐关系,无法购买');
-                }
 
 
-            }
             if ($shippingType == 2) {
             if ($shippingType == 2) {
                 $orderInfo['verify_code'] = $this->getStoreCode();
                 $orderInfo['verify_code'] = $this->getStoreCode();
                 /** @var SystemStoreServices $storeServices */
                 /** @var SystemStoreServices $storeServices */