post=$this->request->post(); } 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"; $where =[['is_del',"=",0]]; $bkcode = isset($this->post['bk_code']) && $this->post['bk_code']!="" ? trim($this->post['bk_code']):""; if($bkcode!=""){ $where[]=['bkcode',"=", $bkcode]; } $status = isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']):""; if($status!==""){ // $where['status'] = $status; $where[]=['status',"=", $status]; } $cgdNo = isset($this->post['cgdNo']) && $this->post['cgdNo']!="" ? trim($this->post['cgdNo']) :""; if($cgdNo!=""){ //$where['cgdNo'] = Db::Raw("like '%{$cgdNo}%'"); $where[]=['cgdNo',"like", "%{$cgdNo}%"]; } $apply_name = isset($this->post['apply_name']) && $this->post['apply_name']!="" ? trim($this->post['apply_name']):""; if($apply_name!=""){ // $where['cgder'] =Db::Raw("like '%{$apply_name}%'"); $where[]=['cgder',"like", "%{$apply_name}%"]; } $wsm_code = isset($this->post['wsm_code']) && $this->post['wsm_code']!="" ? trim($this->post['wsm_code']):""; if($wsm_code!=""){ // $where['wsm_code'] = $wsm_code; $where[]=['wsm_code',"=", $wsm_code]; } $good_name = isset($this->post['good_name']) && $this->post['good_name']!="" ? trim($this->post['good_name']):""; if($good_name!=""){ //$where['good_name'] = Db::raw(" like %{$good_name}%"); $where[]=['good_name',"like", "%{$good_name}%"]; } $good_code = isset($this->post['good_code']) && $this->post['good_code']!="" ? trim($this->post['good_code']) :""; if($good_code!=""){ // $where['good_code'] = Db::raw(" like %{$good_code}%"); $where[]=['good_code',"like", "%{$good_code}%"]; } $start = isset($this->post['start']) && $this->post['start']!="" ?$this->post['start']:""; if($start!=""){ // $where['addtime'] = Db::raw(" >= '{$start}'"); $where[]=['addtime',">=", $start]; } $end = isset($this->post['end']) && $this->post['end']!="" ?$this->post['end']:""; if($end!=""){ $where[]=['addtime',"<=", $end]; } $last_start = isset($this->post['last_start']) && $this->post['last_start']!="" ?$this->post['last_start']:""; if($last_start!=""){ //$where['lasttime'] = Db::raw(" >= '{$last_start}'"); $where[]=['lasttime',">=", $last_start]; } $last_end = isset($this->post['last_end']) && $this->post['last_end']!="" ?$this->post['last_end']:""; if($last_end!=""){ //$where['lasttime'] = Db::raw(" <= '{$last_end}'"); $where[]=['lasttime',"<=", $last_end]; } $count=Db::name("purchease_order")->where($where)->count(); $total = ceil($count/$size); $page = $page >= $total ? $total : $page; $list = Db::name("purchease_order")->where($where)->page($page,$size)->order("addtime desc")->select(); $data=[]; foreach ($list as $value){ $value['wsm_name']=""; if($value['wsm_code']!=""){ $ware = Db::name("warehouse_info")->where(["wsm_code"=>$value['wsm_code'],"is_del"=>0])->find(); $value['wsm_name']=isset($ware['name'])? $ware['name']: ""; } $data[]=$value; } return app_show(0,"获取成功",["list"=>$data,"count"=>$count]); } public function info(){ $cgdNo = isset($this->post['cgdNo']) && $this->post['cgdNo']!="" ?trim($this->post['cgdNo']):""; if($cgdNo==""){ return error_show(1004,"参数cgdNo 不能为空"); } $data = Db::name("purchease_order")->where(["cgdNo"=>$cgdNo,"is_del"=>0])->find(); if(empty($data)){ return error_show(1004,"未找到数据"); } $data['wsm_name']=""; if($data['wsm_code']!=""){ $ware = Db::name("warehouse_info")->where(["wsm_code"=>$data['wsm_code'],"is_del"=>0])->find(); $data['wsm_name']=isset($ware['name'])? $ware['name']: ""; } return app_show(0,"获取成功",$data); } public function edit(){ $cgdNo = isset($this->post['cgdNo']) && $this->post['cgdNo']!="" ?trim($this->post['cgdNo']):""; if($cgdNo==""){ return error_show(1004,"参数cgdNo 不能为空"); } $data = Db::name("purchease_order")->where(["cgdNo"=>$cgdNo,"is_del"=>0])->find(); if(empty($data)){ return error_show(1004,"未找到数据"); } $wsm_code = isset($this->post['wsm_code'])&&$this->post['wsm_code']!=""? trim($this->post['wsm_code']):""; if($wsm_code==""){ return error_show(1004,"参数wsm_code 不能为空"); } $ware = Db::name("warehouse_info")->where(["wsm_code"=>$wsm_code,"is_del"=>0])->find(); if(empty($ware)){ return error_show(1004,"未找到仓库信息"); } $data['wsm_code'] = $wsm_code; $data['updatetime'] =date("Y-m-d H:i:s"); $upd=Db::name("purchease_order")->save($data); return $upd?app_show(0,"更新成功"):error_show(1004,'更新失败'); } public function status(){ $cgdNo = isset($this->post['cgdNo']) && $this->post['cgdNo']!="" ?trim($this->post['cgdNo']):""; if($cgdNo==""){ return error_show(1004,"参数cgdNo 不能为空"); } $data = Db::name("purchease_order")->where(["cgdNo"=>$cgdNo,"is_del"=>0])->find(); if(empty($data)){ return error_show(1004,"未找到数据"); } $remark= isset($this->post['remark']) && $this->post['remark']!="" ?trim($this->post['remark']):""; $status = isset($this->post['status'])&&$this->post['status']!=""? intval($this->post['status']):""; if($status==""){ return error_show(1004,"参数status 不能为空"); } $data['status'] = $status; $data['remark'] = $remark; $data['updatetime'] =date("Y-m-d H:i:s"); $upd=Db::name("purchease_order")->save($data); return $upd?app_show(0,"更新成功"):error_show(1004,'更新失败'); } }