Process.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace app\admin\controller;
  3. use app\BaseController;
  4. use think\App;
  5. use think\facade\Db;
  6. class Process extends BaseController
  7. {
  8. public $post="";
  9. public function __construct(App $app)
  10. {
  11. parent::__construct($app);
  12. $this->post = $this->request->post();
  13. }
  14. /**
  15. * @return \think\response\Json|void
  16. * @throws \think\db\exception\DataNotFoundException
  17. * @throws \think\db\exception\DbException
  18. * @throws \think\db\exception\ModelNotFoundException
  19. */
  20. public function list(){
  21. $page =isset($this->post['page']) &&$this->post['page']!="" ? intval($this->post['page']) : 1;
  22. $size =isset($this->post['size']) &&$this->post['size']!="" ? intval($this->post['size']) : 10;
  23. $count = Db::name("process")->count();
  24. $total = ceil($count/$size);
  25. $page = $page>$total ? $total:$page;
  26. $list = Db::name("process")->page($page,$size)->select();
  27. return app_show(0,"获取成功",["list"=>$list,"count"=>$count]);
  28. }
  29. /**
  30. * @return \think\response\Json|void
  31. * @throws \think\db\exception\DataNotFoundException
  32. * @throws \think\db\exception\DbException
  33. * @throws \think\db\exception\ModelNotFoundException
  34. */
  35. public function info(){
  36. $id =isset($this->post['id']) &&$this->post['id']!="" ? intval($this->post['id']) : "";
  37. if($id==""){
  38. return error_show(1004,"参数id 不能为空");
  39. }
  40. $info = Db::name("process")->where(['id'=>$id,"is_del"=>0])->find();
  41. if(empty($info)){
  42. return error_show(1004,"流程信息未找到");
  43. }
  44. $list=Db::name("action_process")->where(["pid"=>$id,"is_del"=>0])->order("weight,id")->select();
  45. $info['item'] = empty($list) ? []:$list;
  46. return app_show(0,"获取成功",$info);
  47. }
  48. /**
  49. * @return \think\response\Json|void
  50. * @throws \think\db\exception\DataNotFoundException
  51. * @throws \think\db\exception\DbException
  52. * @throws \think\db\exception\ModelNotFoundException
  53. */
  54. public function process(){
  55. $process_type = isset($this->post['type'])&&$this->post['type']!="" ? $this->post['type']:"";
  56. if($process_type==""){
  57. return error_show(1004,"参数type 不能为空");
  58. }
  59. $orderCode = isset($this->post['orderCode'])&&$this->post['orderCode']!="" ? $this->post['orderCode']:"";
  60. if($orderCode==""){
  61. return error_show(1004,"参数orderCode不能为空");
  62. }
  63. $list = Db::name("action_process")->where(['order_type'=>$process_type,"is_del"=>0,"status"=>1])->order("weight desc,id desc")
  64. ->select();
  65. $data=[];
  66. foreach ($list as $value){
  67. $node = Db::name("process_order")->where(["order_type"=>$value['order_type'],"action_process"=>$value['order_process'],"order_code"=>$orderCode])->find();
  68. $value['action_uid']= isset($node['action_uid']) ? $node['action_uid']:'';
  69. $value['action_name']= isset($node['action_name']) ? $node['action_name']:'';
  70. $data[]=$value;
  71. }
  72. return app_show(0,"获取成功",$data);
  73. }
  74. }