kevin_zhangl před 3 roky
rodič
revize
58ed0332cd

+ 4 - 0
common/models/forms/DeclarationForm.php

@@ -641,6 +641,10 @@ class DeclarationForm extends Model
                 foreach ($this->goodsNum as $k => $v) {
                     if ($v) {
                         $goods = ShopGoods::findOneAsArray('ID=:ID AND STATUS=1',[':ID'=> $ids[$k]]);
+                        if (!$goods) {
+                            throw new Exception('商品已下架');
+                            return;
+                        }
                         if($goods['STORE_NUMS']>0){
                             $totalAmount += $goods['SELL_PRICE'] * intval($v);
                             $totalPv += $goods['PRICE_PV'] * intval($v);

+ 4 - 0
common/models/forms/DeclarationLoopForm.php

@@ -135,6 +135,10 @@ class DeclarationLoopForm extends Model
                 if (count($value['goodsId']) > 0 && (count($value['goodsId']) == count($value['goodsNum']))){
                     for ($i=0;$i<count($value['goodsId']);$i++){
                         $goods = ShopGoods::findOneAsArray('ID=:ID',[':ID'=> $value['goodsId'][$i]]);
+                        if (!$goods) {
+                            throw new Exception('商品已下架');
+                            return;
+                        }
                         if ($goods['STATUS'] == 1 ){
                             if($goods['STORE_NUMS'] < $value['goodsNum'][$i]){
                                 throw new Exception($goods['GOODS_NAME'].'商品库存不足');

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

@@ -386,6 +386,7 @@ class OrderForm extends Model
                     $goods = ShopGoods::findOneAsArray('ID=:ID AND STATUS=1',[':ID'=> $ids[$k]]);
                     if (!$goods) {
                         throw new Exception('商品不存在');
+                        return;
                     }
                     if ($goods['STORE_NUMS'] >= $this->goodsNum[$k]){
                         $data = ShopGoods::find()->where(['ID' => $ids[$k]])->one();
@@ -508,6 +509,10 @@ class OrderForm extends Model
         foreach ($this->goodsNum as $k => $v) {
             if ($v) {
                 $goods = ShopGoods::findOneAsArray('ID=:ID AND STATUS=1',[':ID'=> $ids[$k]]);
+                if (!$goods) {
+                    throw new Exception('商品已下架');
+                    return;
+                }
                 if($goods['STORE_NUMS']>0){
                     $discount = $goods['SELL_DISCOUNT'];
                     $realPrice = $goods['SELL_PRICE'] * $discount;
@@ -567,6 +572,10 @@ class OrderForm extends Model
             foreach ($this->goodsNum as $k => $v){
                 if ($v){
                     $goods = ShopGoods::findOneAsArray('ID=:ID AND STATUS=1',[':ID'=> $ids[$k]]);
+                    if (!$goods) {
+                        throw new Exception('商品已下架');
+                        return;
+                    }
                     if ($goods['STORE_NUMS'] >= $this->goodsNum[$k]){
                         $data = ShopGoods::find()->where(['ID' => $ids[$k]])->one();
                         $goods_store_nums = $data->STORE_NUMS - $this->goodsNum[$k];