Process.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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")
  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['node']=!empty($node) ?$node:[];
  69. $data[]=$value;
  70. }
  71. return app_show(0,"获取成功",$data);
  72. }
  73. }