xieruidong 2 years ago
parent
commit
6adb285253
2 changed files with 9 additions and 6 deletions
  1. 4 2
      application/common/model/Goods.php
  2. 5 4
      application/common/service/OrderService.php

+ 4 - 2
application/common/model/Goods.php

@@ -35,9 +35,11 @@ class Goods Extends Model
         return $this->belongsTo(Category::class);
     }
 
+    const STATUS_NORMAL=1;
+    const STATUS_DOWN=2;
     public static $status=[
-        1=>'正常',
-        2=>'下架',
+        self::STATUS_NORMAL=>'正常',
+        self::STATUS_DOWN=>'下架',
     ];
 
     /**

+ 5 - 4
application/common/service/OrderService.php

@@ -2,6 +2,7 @@
 namespace app\common\service;
 
 use app\common\model\Admin;
+use app\common\model\Goods;
 use app\common\model\GoodsCart;
 use app\common\model\GoodsSku;
 use app\common\model\User;
@@ -157,9 +158,6 @@ class OrderService extends BaseService {
             'amount_install'=>0,
             'amount_discount'=>0,
             'amount_cmn'=>0,
-            'num'=>0,
-            'num_install'=>0,
-            'goods'=>[]
         ];
         $user=$this->getUser();
 
@@ -186,6 +184,9 @@ class OrderService extends BaseService {
             if(!$goods['sku']||!$goods['goods']){
                 $this->error('规格或商品不存在');
             }
+            if($goods['goods']['status']!=Goods::STATUS_NORMAL){
+                $this->error("商品[{$goods['goods']['name']}]已下架");
+            }
             list($amountReal,$amountKill,$amountOrigin)=$this->getAmount($goods['sku'],$goods['goods']);
             $goods['amount_pay']=0;
             $goods['amount_coupon']=0;
@@ -257,4 +258,4 @@ class OrderService extends BaseService {
         }
         return $amountArr;
     }
-}
+}