request->param(["name"=>"","type"=>3,"status"=>"","companyNo"=>"",'relaComNo'=>'',"page"=>1,"size"=>15],"post","trim"); $conditon =[["is_del","=",0],["type","=",$param['type']]]; if($param['name']!='')$conditon[]=["name","like","%{$param['name']}%"]; if($param['status']!=='')$conditon[]=["status","=",$param['status']]; $count=Db::name("exec")->where($conditon)->count(); $total = ceil($count/$param['size']); $page =$param['page']>=$total ?intval($total) :intval($param['page']); $list=Db::name("exec")->where($conditon)->page($page,intval($param['size']))->select()->toArray(); return app_show(0,"获取成功",["list"=>$list,"count"=>$count]); } public function query(){ $param=$this->request->param(["name"=>"","status"=>"","companyNo"=>"",'relaComNo'=>'',"type"=>3],"post","trim"); $conditon =[["is_del","=",0],["type","=",$param['type']]]; if($param['name']!='')$conditon[]=["name","like","%{$param['name']}%"]; if($param['status']!=='')$conditon[]=["status","=",$param['status']]; $list=Db::name("exec")->where($conditon)->select()->toArray(); return app_show(0,"获取成功",$list); } public function add(){ $param=$this->request->param(["name"=>"","companyNo"=>"",'relaComNo'=>'',"action"=>'',"type"=>3],"post","trim"); $valid=Validate::rule([ "name|脚本名称"=>'require|max:255', ]); if($valid->check($param)==false) return error_show(1004,$valid->getError()); $ist =Db::name("exec")->where(["name"=>$param['name'],"type"=>3,"is_del"=>0])->findOrEmpty(); if(!empty($ist))return error_show(1004,"同类型脚本名称已存在"); $data=[ "name"=>$param['name'], "apply_name"=>$this->uname, "apply_id"=>$this->uid, "companyNo"=>'', "companyName"=>'', "action"=>$param["action"]??"", "type"=>$param['type'],//3行政业绩报表 4 仓库每日订单数据 "status"=>0, "addtime"=>date("Y-m-d H:i:s"), "updatetime"=>date("Y-m-d H:i:s") ]; $insert=Db::name("exec")->insert($data); return $insert? app_show("0","新建成功"):app_show("1004","新建失败"); } //新建脚本数据 public function addlog(){ $param=$this->request->param(["id"=>"","start"=>date("Y-m-d"),"end"=>date("Y-m-d"),"companyNo"=>"",'relaComNo'=>'',"type"=>""],"post","trim"); $valid=Validate::rule([ "id|脚本ID"=>'require|number|gt:0', "start|起始时间"=>'require|dateFormat:Y-m-d', "end|结束时间"=>'require|dateFormat:Y-m-d|egt:start', "type|执行类型"=>'require|number|in:3,4,5', ]); if($valid->check($param)==false) return error_show(1004,$valid->getError()); $exec =Db::name("exec")->where("id",$param['id'])->findOrEmpty(); if(empty($exec)) return error_show(1004,'未找到脚本数据'); if($exec['action']=='') return error_show(1004,'后端脚本还未上线'); $data=[ "name"=>$exec['name'], "companyNo"=>'', "companyName"=>'', "start"=>date("Y-m-d 00:00:00",strtotime($param['start'])), "end"=>date("Y-m-d 23:59:59",strtotime($param['end'])), "apply_id"=>$this->uid, "apply_name"=>$this->uname, "action"=>$exec['action'], "down_url"=>'', "status"=>1, "remark"=>'', "type"=>$param["type"], "expiretime"=>in_array($param["type"],[3,5])? date("Y-m-d H:i:s"):date("Y-m-d 22:00:00"), "addtime"=> date("Y-m-d H:i:s"), "updatetime"=> date("Y-m-d H:i:s") ]; $in=Db::name("exec_log")->insert($data); return $in? app_show("0","新建成功"):app_show("1004","新建失败"); } public function loglist(){ $param=$this->request->param(["name"=>"","apply_name"=>"","status"=>"","action"=>"","type"=>[3,4], "companyNo"=>"",'relaComNo'=>'',"page"=>1,"size"=>15],"post","trim"); $where=[["is_del","=",0],['type','in',$param['type']],["addtime",">=",date("Y-m-d H:i:s",strtotime("-30 day") )]]; if($param['name']!='')$where[]=["name","like","%{$param['name']}%"]; if($param['apply_name']!='')$where[]=["apply_name","like","%{$param['apply_name']}%"]; // if($param['type']!='')$where[]=["type","=",$param['type']]; if($param['status']!='')$where[]=["status","=",$param['status']]; if($param['action']!='')$where[]=["action","=",$param['action']]; $count=Db::name("exec_log")->where($where)->count(); $total = ceil($count/$param['size']); $page =$param['page']<=$total ? intval($param['page']):intval($total); $list=Db::name("exec_log")->where($where)->page($page,intval($param['size']))->order("id desc")->select() ->toArray(); return app_show(0,"获取成功",["list"=>$list,"count"=>$count]); } /** * @return \think\response\Json|void */ public function actionList(){ $ation=[ ["action"=>"R","name"=>'采购部门发货明细'], ["action"=>"L","name"=>'客服部提成业绩'], ["action"=>"S","name"=>'项目部新政策提成业绩'], ["action"=>"T","name"=>'新媒体回款明细'], ["action"=>"U","name"=>'项目部旧政策回款明细'], ["action"=>"V","name"=>'退货订单明细'], ["action"=>"Q","name"=>'销售订单明细'], ]; return app_show(0,"获取成功",$ation); } public function actioninfo(){ $ation=[ ['action'=>'X','name'=>'仓储物流日报'], ]; return app_show(0,'获取成功',$ation); } }