Browse Source

跨境商品支付bug限制

kevin_zhangl 2 years ago
parent
commit
3cf4be0033
2 changed files with 13 additions and 0 deletions
  1. 6 0
      common/models/forms/ApproachOrderForm.php
  2. 7 0
      common/models/forms/OrderForm.php

+ 6 - 0
common/models/forms/ApproachOrderForm.php

@@ -300,12 +300,14 @@ class ApproachOrderForm extends Model
         $totalPv = 0;
         $totalRealPv = 0;
         $this->_remainPv = 0;
+        $cateId = [];
         foreach ($this->goodsNum as $k => $v) {
             if ($v) {
                 $goods = ShopGoods::findOneAsArray('ID=:ID AND STATUS=1',[':ID'=> $ids[$k]]);
                 if (!$goods) {
                     throw new Exception('商品已下架');
                 }
+                $cateId[] = $goods['CATE_ID'];
                 if ($goods['STORE_NUMS'] > 0) {
                     $discount = $goods['SELL_DISCOUNT'];
                     $realPrice = $goods['SELL_PRICE'] * $discount;
@@ -342,6 +344,10 @@ class ApproachOrderForm extends Model
             }
         }
 
+        if (count(array_unique($cateId)) > 1) {
+            throw new Exception('海内商品、海外商品只能选择一种');
+        }
+
         $this->_decAmount = $totalAmount;
         $this->_decPv = $totalPv;
         $this->_realPv = $totalRealPv;

+ 7 - 0
common/models/forms/OrderForm.php

@@ -310,12 +310,14 @@ class OrderForm extends Model
         $totalPv = 0;
         $totalRealPv = 0;
         $this->_remainPv = 0;
+        $cateId = [];
         foreach ($this->goodsNum as $k => $v) {
             if ($v) {
                 $goods = ShopGoods::findOneAsArray('ID=:ID AND STATUS=1',[':ID'=> $ids[$k]]);
                 if (!$goods) {
                     throw new Exception('商品不存在');
                 }
+                $cateId[] = $goods['CATE_ID'];
                 if($goods['STORE_NUMS']>0){
                     $discount = $goods['SELL_DISCOUNT'];
                     $realPrice = $goods['SELL_PRICE'] * $discount;
@@ -350,6 +352,11 @@ class OrderForm extends Model
                 }
             }
         }
+
+        if (count(array_unique($cateId)) > 1) {
+            throw new Exception('海内商品、海外商品只能选择一种');
+        }
+
         $this->_decAmount = $totalAmount;
         $this->_decPv = $totalPv;
         $this->_realPv = $totalRealPv;