wugg 3 years ago
parent
commit
dc7875aee7
2 changed files with 19 additions and 13 deletions
  1. 12 6
      app/admin/controller/Good.php
  2. 7 7
      app/admin/controller/Resign.php

+ 12 - 6
app/admin/controller/Good.php

@@ -117,16 +117,22 @@ class Good extends \app\BaseController
     }
 
     public function GetStock(){
+        $condition=["a.is_del"=>0];
         $type_code = isset($this->post['type_code']) &&$this->post['type_code'] !=="" ? trim($this->post['type_code']):"";
-        if($type_code===""){
-            return error_show(1005,"参数type_code 不能为空");
+        if($type_code!==""){
+            $good= Db::name("good_type")->where(["type_code"=>$type_code,"is_del"=>0])->find();
+            if(empty($good)){
+                return error_show(1005,"未找到数据");
+            }
+          $condition["a.good_type_code"]=$type_code;
         }
-        $good= Db::name("good_type")->where(["type_code"=>$type_code,"is_del"=>0])->find();
-        if(empty($good)){
-            return error_show(1005,"未找到数据");
+        $wsm_code = isset($this->post['wsm_code']) &&$this->post['wsm_code'] !=="" ? trim($this->post['wsm_code'])
+            :"";
+        if($wsm_code!==""){
+            $condition["a.wsm_code"]=$wsm_code;
         }
        $list = Db::name("good_stock")->alias("a")->join("warehouse_info b","a.wsm_code=b.wsm_code","left")->join("supplier c","b.supplierNo=c.code","left")
-           ->where(["a.is_del"=>0,"good_type_code"=>$type_code])->field("a.id,b.name,c.code,c.name,a.wait_in_stock,a.wait_out_stock,a.usable_stock,a.intra_stock,a.total_stock,a.status,a.warn_stock")->select();
+           ->where($condition)->field("a.id,b.name,c.code,c.name,a.wait_in_stock,a.wait_out_stock,a.usable_stock,a.intra_stock,a.total_stock,a.status,a.warn_stock")->select();
      return app_show(0,"获取成功",$list);
     }
 

+ 7 - 7
app/admin/controller/Resign.php

@@ -90,14 +90,14 @@ class Resign extends BaseController
         }
         $good_type_code = isset($this->post['good_type_code'])&&$this->post['good_type_code']!="" ? trim($this->post['good_type_code'])
             :"";
-        if($good_type_code==""){
-            return error_show(1002,'参数good_type_code 不能为空');
-        }
-        $good_type= Db::name("good_type")->where(['good_code'=>$good_code,'is_del'=>0,'type_code'=>$good_type_code])
-            ->find();
-        if(empty($good_type)){
-            return error_show(1002,'未找到商品属性数据');
+        if($good_type_code!==""){
+            $good_type= Db::name("good_type")->where(['good_code'=>$good_code,'is_del'=>0,'type_code'=>$good_type_code])
+                ->find();
+            if(empty($good_type)){
+                return error_show(1002,'未找到商品属性数据');
+            }
         }
+
         $good_num = isset($this->post['good_num'])&&$this->post['good_num']!=="" ? intval($this->post['good_num']) :"";
         if($good_num==''){
             return error_show(1002,'参数good_num 不能为空或零');