|
@@ -309,7 +309,7 @@ class Good extends Base
|
|
|
$condition = [["a.is_del","=",0]];
|
|
|
$type_code = isset($this->post['type_code']) &&$this->post['type_code'] !=="" ? trim($this->post['type_code']):"";
|
|
|
if($type_code!==""){
|
|
|
- $condition[]=["a.good_type_code","=",$type_code];
|
|
|
+ $condition[]=["a.spuCode","=",$type_code];
|
|
|
}
|
|
|
$wsm_code = isset($this->post['wsm_code']) &&$this->post['wsm_code'] !=="" ? trim($this->post['wsm_code'])
|
|
|
:"";
|
|
@@ -343,7 +343,7 @@ class Good extends Base
|
|
|
$condition = [["is_del","=",0]];
|
|
|
$type_code = isset($this->post['type_code']) &&$this->post['type_code'] !=="" ? trim($this->post['type_code']):"";
|
|
|
if($type_code!==""){
|
|
|
- $condition[]=["good_type_code","like","%{$type_code}%"];
|
|
|
+ $condition[]=["spuCode","like","%{$type_code}%"];
|
|
|
}
|
|
|
$wsm_code = isset($this->post['wsm_code']) &&$this->post['wsm_code'] !=="" ? trim($this->post['wsm_code'])
|
|
|
:"";
|
|
@@ -450,8 +450,7 @@ class Good extends Base
|
|
|
(['a.wsm_code'=>$value['wsm_code'],"a.is_del"=>0])->field("a.name as wsm_name,wsm_code,b.code,b.name")
|
|
|
->find();
|
|
|
$good = Db::name("good_stock")->alias("a")
|
|
|
- ->join("good c","c.spuCode=a.spuCode","left")->where(["a.wsm_code"=>$value['wsm_code'],"a
|
|
|
- .is_del"=>0,"c.is_del"=>0])->select();
|
|
|
+ ->join("good c","c.spuCode=a.spuCode","left")->where(["a.wsm_code"=>$value['wsm_code'],"a.is_del"=>0,"c.is_del"=>0])->select();
|
|
|
}
|
|
|
$temp['wsm_name'] = isset($wsm['wsm_name'])?$wsm['wsm_name']:"";
|
|
|
$temp['wsm_code']=$value['wsm_code'];
|
|
@@ -478,31 +477,31 @@ class Good extends Base
|
|
|
if($type_code!==""){
|
|
|
$condition[]=["b.type_code","like","%{$type_code}%"];
|
|
|
}
|
|
|
- $count = Db::name("good_type")->alias("b")
|
|
|
- ->join("good a","a.good_code = b.good_code","left")
|
|
|
- ->join("good_stock c","c.good_type_code = b.type_code","left")
|
|
|
- ->where($condition)->group("a.good_code,a.good_name,a.unit,a.sort_f,b.type_code,b.attribute,a.addtime")->count();
|
|
|
+ $count = Db::name("good")->alias("b")
|
|
|
+ ->join("good_stock c","c.spuCode = b.spuCode","left")
|
|
|
+ ->where($condition)->group("b.spuCode,b.good_name,b.good_unit,b.cat_id,b.craft_desc,b.addtime")
|
|
|
+ ->count();
|
|
|
$page>=ceil($count/$size) ? $page=ceil($count/$size) :"";
|
|
|
- $list = Db::name("good_type")->alias("b")
|
|
|
- ->join("good a","a.good_code = b.good_code","left")
|
|
|
- ->join("good_stock c","c.good_type_code = b.type_code","left")
|
|
|
- ->where($condition)->field("a.good_code,a.good_name,a.unit,a.sort_f,b.type_code,b.attribute,a.addtime,sum(c.wait_in_stock) wait_in_stock,
|
|
|
+ $list = Db::name("good")->alias("b")
|
|
|
+ ->join("good_stock c","c.spuCode = b.spuCode","left")
|
|
|
+ ->where($condition)->field("b.spuCode,b.good_name,b.good_unit,b.cat_id,b.craft_desc,b.addtime,sum(c.wait_in_stock) wait_in_stock,
|
|
|
sum(c.wait_out_stock) wait_out_stock,sum(c.usable_stock) usable_stock,sum(c.intra_stock) intra_stock,sum(c.warn_stock) warn_stock,sum(c.total_stock) total_stock")
|
|
|
- ->page($page,$size)->order("a.addtime desc")->group("a.good_code,a.good_name,a.unit,a.sort_f,b.type_code,b.attribute,a.addtime")->select();
|
|
|
+ ->page($page,$size)->order("b.addtime desc")->group("b.spuCode,b.good_name,b.good_unit,b.cat_id,b.craft_desc,b.addtime")->select();
|
|
|
// echo Db::name("good_type")->getLastSql();
|
|
|
$data=[];
|
|
|
foreach ($list as $key=>$value){
|
|
|
$temp=[];
|
|
|
- if($value['type_code']!=""){
|
|
|
+ if($value['spuCode']!=""){
|
|
|
$child = Db::name("good_stock")->alias("a")->join("warehouse_info b","a.wsm_code=b.wsm_code","left")
|
|
|
- ->where(['a.good_type_code'=>$value['type_code'],"b.wsm_type"=>1,"a.is_del"=>0])->field("a.wsm_code,b.name wsm_name,a.wait_in_stock,a.wait_out_stock,a.usable_stock,a.intra_stock,a.total_stock,a.warn_stock")->select();
|
|
|
+ ->where(['a.spuCode'=>$value['spuCode'],"b.wsm_type"=>1,"a.is_del"=>0])->field("a.wsm_code,b.name wsm_name,a.wait_in_stock,a.wait_out_stock,a.usable_stock,a.intra_stock,a.total_stock,a.warn_stock")->select();
|
|
|
}
|
|
|
$temp['good_name'] = $value['good_name'];
|
|
|
- $temp['good_code'] = $value['good_code'];
|
|
|
- $temp['type_code'] = $value['type_code'];
|
|
|
- $temp['unit'] = $value['unit'];
|
|
|
- $temp['sort_f']=$value['sort_f'];
|
|
|
- $temp['attribute']=$value['attribute'];
|
|
|
+ $temp['good_code'] = $value['spuCode'];
|
|
|
+ $temp['type_code'] ='';
|
|
|
+ $unit = Db::name("unit")->where(['id'=>$value['good_unit']])->find();
|
|
|
+ $temp['unit'] = isset($unit['unit'])?$unit['unit']:"";
|
|
|
+ $temp['sort_f']=isset($value['cat_id'])?made($value['cat_id']):[];
|
|
|
+ $temp['attribute']=$value['craft_desc'];
|
|
|
$temp['addtime']=$value['addtime'];
|
|
|
$temp['usable_stock'] = isset($value['usable_stock'])? $value['usable_stock']:"";
|
|
|
$temp['wait_in_stock'] = isset($value['wait_in_stock'])? $value['wait_in_stock']:"";
|