|
@@ -31,69 +31,50 @@ class Good extends \app\BaseController
|
|
|
{
|
|
|
parent::__construct($app);
|
|
|
$this->post = $this->request->post();
|
|
|
- $token = isset($this->post['token']) ? trim($this->post['token']) : "";
|
|
|
- if($token==""){
|
|
|
- return error_show(101,'token不能为空');
|
|
|
- }
|
|
|
- $effetc = VerifyTokens($token);
|
|
|
- if(!empty($effetc) && $effetc['code']!=0){
|
|
|
- return error_show($effetc['code'],$effetc['message']);
|
|
|
- }
|
|
|
+// $token = isset($this->post['token']) ? trim($this->post['token']) : "";
|
|
|
+// if($token==""){
|
|
|
+// return error_show(101,'token不能为空');
|
|
|
+// }
|
|
|
+// $effetc = VerifyTokens($token);
|
|
|
+// if(!empty($effetc) && $effetc['code']!=0){
|
|
|
+// return error_show($effetc['code'],$effetc['message']);
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
public function list(){
|
|
|
- $page = isset($this->post['page']) &&$this->post['page'] !=="" ? intval($this->post['page']):1;
|
|
|
- $size = isset($this->post['size']) &&$this->post['size'] !=="" ? intval($this->post['size']):10;
|
|
|
- $condtion=[['a.is_del',"=",0],['b.is_del',"=",0]];
|
|
|
- $wsmcode =isset($this->post['wsm_code']) &&$this->post['wsm_code'] !=="" ? trim($this->post['wsm_code']):"";
|
|
|
- if($wsmcode!=""){
|
|
|
- $typecode= Db::name("good_stock")->where(["wsm_code"=>$wsmcode,'is_del'=>0])->column("good_type_code");
|
|
|
- $condtion[]=["b.type_code",'in',$typecode];
|
|
|
+ $page = isset($this->post['page']) && $this->post['page'] !==""? intval($this->post['page']):"1";
|
|
|
+ $size = isset($this->post['size']) && $this->post['size'] !==""? intval($this->post['size']):"10";
|
|
|
+ $where =[["is_del","=",0]];
|
|
|
+ $cat_id = isset($this->post['cat_id']) && $this->post['cat_id'] !=="" ? trim($this->post['cat_id']):"";
|
|
|
+ if($cat_id!==""){
|
|
|
+ $where[]=['cat_id',"=",$cat_id];
|
|
|
}
|
|
|
- $good_code =isset($this->post['type_code']) &&$this->post['type_code'] !=="" ? trim($this->post['type_code']):"";
|
|
|
- if($good_code!=""){
|
|
|
- //$condtion['b.type_code'] = $good_code;
|
|
|
- $condtion[]=["b.type_code",'=',$good_code];
|
|
|
+ $good_name = isset($this->post['good_name']) && $this->post['good_name'] !=="" ? trim($this->post['good_name']):"";
|
|
|
+ if($good_name!==""){
|
|
|
+ $where[]=['good_name',"like","$good_name"];
|
|
|
}
|
|
|
- $goodcode =isset($this->post['good_code']) &&$this->post['good_code'] !=="" ? trim($this->post['good_code'])
|
|
|
- :"";
|
|
|
- if($goodcode!=""){
|
|
|
- //$condtion['a.good_code'] = Db::raw("like '%{$goodcode}%'");
|
|
|
- $condtion[]=["a.good_code",'like',"%{$goodcode}%"];
|
|
|
+// $good_code = isset($this->post['good_code']) && $this->post['good_code'] !=="" ? trim($this->post['good_code']):"";
|
|
|
+// if($good_code!==""){
|
|
|
+// $where [] = ['good_code',"like",$good_code];
|
|
|
+// }
|
|
|
+ $start = isset($this->post['start']) && $this->post['start']!=="" ? $this->post['start']:"";
|
|
|
+ if($start!==""){
|
|
|
+ $where[]=['addtime',">=",date('Y-m-d H:i:s',strtotime($start))];
|
|
|
}
|
|
|
- $good_name =isset($this->post['good_name']) &&$this->post['good_name'] !=="" ? trim($this->post['good_name'])
|
|
|
- :"";
|
|
|
- if($good_name!=""){
|
|
|
- // $condtion['a.good_name'] = Db::raw("like '%{$good_name}%'");
|
|
|
- $condtion[]=["a.good_name",'like',"%{$good_name}%"];
|
|
|
+ $end = isset($this->post['end']) && $this->post['end']!=="" ? $this->post['end']:"";
|
|
|
+ if($end!==""){
|
|
|
+ $where[]=['addtime',"<",date('Y-m-d H:i:s',strtotime($end)+24*3600)];
|
|
|
}
|
|
|
- $supplierNo =isset($this->post['supplierNo']) &&$this->post['supplierNo'] !=="" ? trim($this->post['supplierNo']):"";
|
|
|
- if($supplierNo!=""){
|
|
|
- $supplier = Db::name("supplier")->where(["code"=>$supplierNo])->find();
|
|
|
- if(empty($supplier)){
|
|
|
- return error_show(1004,"未找到供应商信息");
|
|
|
- }
|
|
|
- $condtion[]=["a.gys_code",'=',$supplierNo];
|
|
|
- }
|
|
|
-
|
|
|
- $count = Db::name("good_type")->alias("b")->join("good a","a.good_code = b.good_code","left")
|
|
|
- ->where($condtion)->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")
|
|
|
- ->where($condtion)->field("b.id,a.good_code,a.good_name,a.good_desc,a.brand,a.original_price,a.cg_saler,a.good_type,a.market_fee,a.gys_code,a.unit,
|
|
|
- a.sort_f,a.sort_s,a.sort_t,b.color,b.material,b.specs,b.is_main,b.type_code,b.attribute,b.status as bstatus,a.addtime,a.updatetime,a.cat_id")
|
|
|
- ->page($page,$size)->select();
|
|
|
+ $count = Db::name('good')->where($where)->count();
|
|
|
+ $total = ceil($count / $size);
|
|
|
+ $page = $page >= $total ? $total : $page;
|
|
|
+ $list = Db::name('good')->where($where)->page($page,$size)->order("addtime desc")->select();
|
|
|
$data=[];
|
|
|
- foreach ($list as $key=>$value){
|
|
|
- $stock = Db::name("good_stock")->where(["good_type_code"=>$value['type_code'],"is_del"=>0])->sum("usable_stock");
|
|
|
- $value['usable_stock']=$stock;
|
|
|
- $supplier = Db::name("supplier")->where(["code"=>$value['gys_code']])->find();
|
|
|
- $value['supplier_name'] =isset($supplier['name']) ?$supplier['name'] :"";
|
|
|
- $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
|
|
|
+ foreach ($list as $value){
|
|
|
+ $value['cat_info']= made($value['cat_id'],[]);
|
|
|
$data[]=$value;
|
|
|
}
|
|
|
-
|
|
|
- return app_show(0,"获取成功",["list"=>$data,"count"=>$count]);
|
|
|
+ return app_show(0,"获取成功",['list'=>$data,'count'=>$count]);
|
|
|
}
|
|
|
public function SetWarn(){
|
|
|
$condition=["is_del"=>0];
|