ExecStat.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. namespace app\admin\controller;
  3. use think\App;
  4. use think\facade\Db;
  5. use think\facade\Validate;
  6. class ExecStat extends Base{
  7. public function __construct(App $app) {parent::__construct($app);}
  8. public function list(){
  9. $param=$this->request->param(["name"=>"","type"=>3,"status"=>"","companyNo"=>"",'relaComNo'=>'',"page"=>1,"size"=>15],"post","trim");
  10. $conditon =[["is_del","=",0],["type","=",$param['type']]];
  11. if($param['name']!='')$conditon[]=["name","like","%{$param['name']}%"];
  12. if($param['status']!=='')$conditon[]=["status","=",$param['status']];
  13. $count=Db::name("exec")->where($conditon)->count();
  14. $total = ceil($count/$param['size']);
  15. $page =$param['page']>=$total ?intval($total) :intval($param['page']);
  16. $list=Db::name("exec")->where($conditon)->page($page,intval($param['size']))->select()->toArray();
  17. return app_show(0,"获取成功",["list"=>$list,"count"=>$count]);
  18. }
  19. public function query(){
  20. $param=$this->request->param(["name"=>"","status"=>"","companyNo"=>"",'relaComNo'=>'',"type"=>3],"post","trim");
  21. $conditon =[["is_del","=",0],["type","=",$param['type']]];
  22. if($param['name']!='')$conditon[]=["name","like","%{$param['name']}%"];
  23. if($param['status']!=='')$conditon[]=["status","=",$param['status']];
  24. $list=Db::name("exec")->where($conditon)->select()->toArray();
  25. return app_show(0,"获取成功",$list);
  26. }
  27. public function add(){
  28. $param=$this->request->param(["name"=>"","companyNo"=>"",'relaComNo'=>'',"action"=>'',"type"=>3],"post","trim");
  29. $valid=Validate::rule([
  30. "name|脚本名称"=>'require|max:255',
  31. ]);
  32. if($valid->check($param)==false) return error_show(1004,$valid->getError());
  33. $ist =Db::name("exec")->where(["name"=>$param['name'],"type"=>3,"is_del"=>0])->findOrEmpty();
  34. if(!empty($ist))return error_show(1004,"同类型脚本名称已存在");
  35. $data=[
  36. "name"=>$param['name'],
  37. "apply_name"=>$this->uname,
  38. "apply_id"=>$this->uid,
  39. "companyNo"=>'',
  40. "companyName"=>'',
  41. "action"=>$param["action"]??"",
  42. "type"=>$param['type'],//3行政业绩报表 4 仓库每日订单数据
  43. "status"=>0,
  44. "addtime"=>date("Y-m-d H:i:s"),
  45. "updatetime"=>date("Y-m-d H:i:s")
  46. ];
  47. $insert=Db::name("exec")->insert($data);
  48. return $insert? app_show("0","新建成功"):app_show("1004","新建失败");
  49. }
  50. //新建脚本数据
  51. public function addlog(){
  52. $param=$this->request->param(["id"=>"","start"=>date("Y-m-d"),"end"=>date("Y-m-d"),"companyNo"=>"",'relaComNo'=>'',"type"=>""],"post","trim");
  53. $valid=Validate::rule([
  54. "id|脚本ID"=>'require|number|gt:0',
  55. "start|起始时间"=>'require|dateFormat:Y-m-d',
  56. "end|结束时间"=>'require|dateFormat:Y-m-d|egt:start',
  57. "type|执行类型"=>'require|number|in:3,4,5',
  58. ]);
  59. if($valid->check($param)==false) return error_show(1004,$valid->getError());
  60. $exec =Db::name("exec")->where("id",$param['id'])->findOrEmpty();
  61. if(empty($exec)) return error_show(1004,'未找到脚本数据');
  62. if($exec['action']=='') return error_show(1004,'后端脚本还未上线');
  63. $data=[
  64. "name"=>$exec['name'],
  65. "companyNo"=>'',
  66. "companyName"=>'',
  67. "start"=>date("Y-m-d 00:00:00",strtotime($param['start'])),
  68. "end"=>date("Y-m-d 23:59:59",strtotime($param['end'])),
  69. "apply_id"=>$this->uid,
  70. "apply_name"=>$this->uname,
  71. "action"=>$exec['action'],
  72. "down_url"=>'',
  73. "status"=>1,
  74. "remark"=>'',
  75. "type"=>$param["type"],
  76. "expiretime"=>in_array($param["type"],[3,5])? date("Y-m-d H:i:s"):date("Y-m-d 22:00:00"),
  77. "addtime"=> date("Y-m-d H:i:s"),
  78. "updatetime"=> date("Y-m-d H:i:s")
  79. ];
  80. $in=Db::name("exec_log")->insert($data);
  81. return $in? app_show("0","新建成功"):app_show("1004","新建失败");
  82. }
  83. public function loglist(){
  84. $param=$this->request->param(["name"=>"","apply_name"=>"","status"=>"","action"=>"","type"=>[3,4],
  85. "companyNo"=>"",'relaComNo'=>'',"page"=>1,"size"=>15],"post","trim");
  86. $where=[["is_del","=",0],['type','in',$param['type']],["addtime",">=",date("Y-m-d H:i:s",strtotime("-30 day")
  87. )]];
  88. if($param['name']!='')$where[]=["name","like","%{$param['name']}%"];
  89. if($param['apply_name']!='')$where[]=["apply_name","like","%{$param['apply_name']}%"];
  90. // if($param['type']!='')$where[]=["type","=",$param['type']];
  91. if($param['status']!='')$where[]=["status","=",$param['status']];
  92. if($param['action']!='')$where[]=["action","=",$param['action']];
  93. $count=Db::name("exec_log")->where($where)->count();
  94. $total = ceil($count/$param['size']);
  95. $page =$param['page']<=$total ? intval($param['page']):intval($total);
  96. $list=Db::name("exec_log")->where($where)->page($page,intval($param['size']))->order("id desc")->select()
  97. ->toArray();
  98. return app_show(0,"获取成功",["list"=>$list,"count"=>$count]);
  99. }
  100. /**
  101. * @return \think\response\Json|void
  102. */
  103. public function actionList(){
  104. $ation=[
  105. ["action"=>"R","name"=>'采购部门发货明细'],
  106. ["action"=>"L","name"=>'客服部提成业绩'],
  107. ["action"=>"S","name"=>'项目部新政策提成业绩'],
  108. ["action"=>"T","name"=>'新媒体回款明细'],
  109. ["action"=>"U","name"=>'项目部旧政策回款明细'],
  110. ["action"=>"V","name"=>'退货订单明细'],
  111. ["action"=>"Q","name"=>'销售订单明细'],
  112. ];
  113. return app_show(0,"获取成功",$ation);
  114. }
  115. public function actioninfo(){
  116. $ation=[
  117. ['action'=>'X','name'=>'仓储物流日报'],
  118. ];
  119. return app_show(0,'获取成功',$ation);
  120. }
  121. }