WIN-2308041133\Administrator 3 днів тому
батько
коміт
fad8f65eb3
1 змінених файлів з 10 додано та 0 видалено
  1. 10 0
      app/services/order/StoreOrderServices.php

+ 10 - 0
app/services/order/StoreOrderServices.php

@@ -2566,6 +2566,15 @@ HTML;
                 $hasGift = 1;
                 $hasGift = 1;
                 $gift_price = bcmul($item['cart_num'],$item['productInfo']['price'],2);
                 $gift_price = bcmul($item['cart_num'],$item['productInfo']['price'],2);
                 $price = bcadd($price,$gift_price,2);
                 $price = bcadd($price,$gift_price,2);
+                    // 礼包商品只能购买一次检查
+                    /** @var StoreOrderCartInfoServices $cartInfoServices */
+                    $cartInfoServices = app()->make(StoreOrderCartInfoServices::class);
+                    // 直接查询用户是否购买过该礼包商品的已支付订单
+
+                    if ($cartInfoServices->hasUserPurchasedProduct($uid,$item['productInfo'] ['id'])) {
+                        return app('json')->fail('礼包商品只能购买一次');
+                    }
+
             }
             }
             if (isset($item['productInfo']['is_repeat']) && $item['productInfo']['is_repeat'] == 1) {
             if (isset($item['productInfo']['is_repeat']) && $item['productInfo']['is_repeat'] == 1) {
                 $hasRepeat = 1;
                 $hasRepeat = 1;
@@ -2576,6 +2585,7 @@ HTML;
             $arr[] = $item['productInfo']['logistics'];
             $arr[] = $item['productInfo']['logistics'];
 
 
         }
         }
+
         if ($price<200&&$hasGift==1){
         if ($price<200&&$hasGift==1){
             throw new ApiException('礼包商品订单金额不能小于200元');
             throw new ApiException('礼包商品订单金额不能小于200元');
         }
         }