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']); } } 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],["cat_id","<>",0]]; $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : ""; if ($zxNo !== "") { $where[] = ['zxNo','=',$zxNo]; } $sequenceNo = isset($this->post['sequenceNo']) && $this->post['sequenceNo'] !== "" ? trim($this->post['sequenceNo']) : ""; if ($sequenceNo !== "") { $where[] = ['sequenceNo','like',"%$sequenceNo%"]; } $salesman = isset($this->post['salesman']) && $this->post['salesman'] !== "" ? trim($this->post['salesman']) : ""; if ($salesman !== "") { //$where["salesman"] =Db::Raw("like '%$salesman%'"); $where[]= ["salesman",'like',"%$salesman%"]; } $cpName = isset($this->post['cpName']) && $this->post['cpName'] !== "" ? trim($this->post['cpName']) : ""; if ($cpName !== "") { //$where["cpName"]= Db::Raw("like '%$cpName%'"); $where[]= ["cpName",'like',"%$cpName%"]; } $khNo = isset($this->post['khNo']) && $this->post['khNo'] !== "" ? trim($this->post['khNo']) : ""; if ($khNo !== "") { // $where['khNo'] = $khNo; $where[]= ["khNo",'like',"%$khNo%"]; } $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:""; if ($start !="") { //$where = ["zxtime"=>Db::raw(">= '{$start}'")]; $where[]= ["zxtime",'>=',$start]; } $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :""; if($end !=""){ $where[]= ["zxtime",'<=',$end]; } $status = isset($this->post['status']) && $this->post['status'] !== "" ? trim($this->post['status']) : ""; if ($status !== "") { $where[]= ["status",'=',$status]; } $count = Db::name('consult')->where($where)->count(); $total = ceil($count / $size); $page = $page >= $total ? $total : $page; $list = Db::name('consult')->where($where)->page($page,$size) ->select(); $data=[]; foreach ($list as $value){ $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[]; $data[]=$value; } return app_show(0,"获取成功",['count'=>$count,'list'=>$data]); } public function info(){ $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) : ""; if($id==""){ return error_show(1002,"咨询单编号不能为空"); } $fo = Db::name('consult')->where(['id'=>$id,'is_del'=>0])->find(); $in= isset($fo['cat_id']) && $fo['cat_id'] !=0 ? made($fo['cat_id']):[]; $fo['can']=$in; if(empty($fo)){ return error_show(1002,"未找到咨询单编号"); }else{ return app_show(0,"获取成功",$fo); } } public function del(){ $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) : ""; $de = Db::name('consult')->where(['id'=>$id,'is_del'=>0])->find(); if($de==false){ return error_show(1002,'咨询单编号未找到'); } $dell= Db::name('consult')->update(['id'=>$id,'is_del'=>1,'updatetime'=>date("Y-m-d H:i:s")]); if($dell){ return error_show(0,"删除成功"); }else return error_show(1002,"删除失败"); } }