xieruidong 2 年之前
父節點
當前提交
2e4c132369
共有 2 個文件被更改,包括 10 次插入1 次删除
  1. 1 1
      application/api/controller/mall/Goods.php
  2. 9 0
      application/common/model/GoodsSku.php

+ 1 - 1
application/api/controller/mall/Goods.php

@@ -149,7 +149,7 @@ class Goods extends Api
         $sku=GoodsSku::findOrFail($data['sku_id']);
         $info=[
             'goods'=>[],
-            'amount_total'=>$sku['amount'],
+            'amount_total'=>$sku->getRealAmount(),
         ];
         $category=Category::where('name','支架')->value('id',0);
         $info['goods']=\app\common\model\Goods::where('category_id',$category)

+ 9 - 0
application/common/model/GoodsSku.php

@@ -2,6 +2,7 @@
 
 namespace app\common\model;
 
+use app\common\validate\KillService;
 use think\db\Query;
 use think\Model;
 
@@ -29,6 +30,14 @@ class GoodsSku Extends Model
         return $this->belongsTo(Goods::class);
     }
 
+    public function getRealAmount(){
+        $open=KillService::open();
+        if($open){
+            return $this['amount_kill'];
+        }
+        return $this['amount'];
+    }
+
 
     protected static function init()
     {