Proorder.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\model\ProcessWait;
  4. use think\App;
  5. use think\facade\Db;
  6. //消息(已读未读)
  7. class Proorder extends Base
  8. {
  9. public function __construct(App $app)
  10. {
  11. parent::__construct($app);
  12. }
  13. //已读列表
  14. public function list()
  15. {
  16. /**暂时屏蔽
  17. * $page = isset($this->post['page']) && $this->post['page'] !==""? intval($this->post['page']) :"1";
  18. * $size = isset($this->post['size']) && $this->post['size'] !==""? intval($this->post['size']) :"10";
  19. * $where =[['is_del',"=",0],['a.order_status',"=",2]];
  20. * $role=$this->checkRole();
  21. * if(!empty($role['write'])){
  22. * $where[]=["a.action_uid","in",$role['write']];
  23. * }
  24. * $count = Db::name('process_order')->alias("a")->leftJoin("workflow b","a.order_type=b.order_type and a.order_code=b.order_code")->where($where)->count();
  25. * $total = ceil("$count/$size");
  26. * $page = $page>$total ? $total:$page;
  27. * $list = Db::name('process_order')->alias("a")->leftJoin("workflow b","a.order_type=b.order_type and a.order_code=b.order_code")
  28. * ->field("b.apply_id,b.apply_name,a.addtime,a.action_uid,a.action_name,a.order_status,a.action_status,a.order_type,a.action_process,a.order_code,a.order_id,a.id")
  29. * ->where($where)->page($page,$size)->order("a.addtime desc")->select();
  30. * $data=[];
  31. * foreach ($list as $value){
  32. * $str = Db::name("process")->where(['process_type' => $value['order_type']])->field("process_name,status")->find();
  33. * $var = Db::name("action_process")->where(['order_type'=>$value['order_type'],'order_process'=>$value['action_status']])->field("status_name,order_process,order_name,roleid")->find();
  34. * $value['process_name']=$str['process_name'];
  35. * $value['order_name']=$var['order_name'];
  36. * $value['status_name'] = $var['status_name'];
  37. * $data[]=$value;
  38. * }
  39. * return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
  40. * **/
  41. {
  42. $param = $this->request->filter('trim')->only(['token', 'apply_id' => '', 'action_uid' => '', 'order_code' => '', 'page' => 1, 'size' => 10], 'post');
  43. $db = ProcessWait::alias("a")
  44. ->leftJoin("workflow b", "a.order_type=b.order_type and a.order_code=b.order_code")
  45. ->where(['is_del' => 0, 'a.status' => ProcessWait::$status_finish]);
  46. $db->where(function ($query) use ($param) {
  47. //所属角色
  48. $role = $this->checkRole();
  49. // if (!empty($role['write']) || $role['roleid'] == 33) $query->whereFindInSet('roleid', $role['roleid']);
  50. $query->whereFindInSet('roleid', $role['roleid']);
  51. //本人id
  52. $user = GetUserInfo($param['token']);
  53. if (isset($user['data']['id'])) $query->whereOr('wait_id', $user['data']['id']);
  54. });
  55. if ($param['order_code'] != '') $db->whereLike("a.order_code", '%' . $param['order_code'] . '%');
  56. if ($param['action_uid'] != '') $db->where('a.action_uid', $param['action_uid']);
  57. $count = $db->count();
  58. $total = ceil($count / $param['size']);
  59. $page = $param['page'] > $total ? $total : $param['page'];
  60. $list = $db
  61. ->field("b.apply_id,b.apply_name,a.addtime,a.action_uid,a.action_name,a.order_status,a.order_type,a.order_process,a.order_code,a.order_id,a.id")
  62. ->page($page, $param['size'])
  63. ->order("a.addtime desc")
  64. ->select()
  65. ->toArray();
  66. //所有流程名称
  67. $all_process = Db::name("process")
  68. ->whereIn('process_type', array_column($list, 'order_type'))
  69. ->column("process_name", 'process_type');
  70. $data = [];
  71. foreach ($list as $value) {
  72. $var = Db::name("action_process")
  73. ->where(['order_type' => $value['order_type'], 'order_process' => $value['order_process']])
  74. ->field("status_name,order_process,order_name,roleid")
  75. ->find();
  76. $value['process_name'] = isset($all_process[$value['order_type']]) ? $all_process[$value['order_type']] : '';
  77. $value['order_name'] = $var['order_name'];
  78. $value['status_name'] = $var['status_name'];
  79. $data[] = $value;
  80. }
  81. return app_show(0, "获取成功", ["list" => $data, 'count' => $count]);
  82. }
  83. }
  84. //待处理列表
  85. public function waitlist()
  86. {
  87. $param = $this->request->filter('trim')->only(['token', 'apply_id' => '', 'action_uid' => '', 'order_code' => '', 'page' => 1, 'size' => 10], 'post');
  88. $db = ProcessWait::alias("a")
  89. ->leftJoin("workflow b", "a.order_type=b.order_type and a.order_code=b.order_code")
  90. ->where(['is_del' => 0, 'a.status' => ProcessWait::$status_wait]);
  91. $db->where(function ($query) use ($param) {
  92. //所属角色
  93. $role = $this->checkRole();
  94. // if (!empty($role['write']) || $role['roleid'] == 33) $query->whereFindInSet('roleid', $role['roleid']);
  95. $query->whereFindInSet('roleid', $role['roleid']);
  96. //本人id
  97. $user = GetUserInfo($param['token']);
  98. if (isset($user['data']['id'])) $query->whereOr('wait_id', $user['data']['id']);
  99. });
  100. if ($param['order_code'] != '') $db->whereLike('a.order_code', '%' . $param['order_code'] . '%');
  101. if ($param['action_uid'] != '') $db->where('a.action_uid', $param['action_uid']);
  102. $count = $db->count();
  103. $total = ceil($count / $param['size']);
  104. $page = $param['page'] > $total ? $total : $param['page'];
  105. $list = $db
  106. ->field("a.id,b.apply_id,b.apply_name,a.addtime,a.action_uid,a.action_name,a.order_status,a.order_type,a.order_process,a.order_code,a.order_id")
  107. ->page($page, $param['size'])
  108. ->order("a.addtime desc")
  109. ->select()
  110. ->toArray();
  111. //所有流程名称
  112. $all_process = Db::name("process")
  113. ->whereIn('process_type', array_column($list, 'order_type'))
  114. ->column("process_name", 'process_type');
  115. $data = [];
  116. foreach ($list as $value) {
  117. $var = Db::name("action_process")
  118. ->where(['order_type' => $value['order_type'], 'order_process' => $value['order_process']])
  119. ->field("status_name,order_process,order_name,roleid")
  120. ->find();
  121. $value['process_name'] = isset($all_process[$value['order_type']]) ? $all_process[$value['order_type']] : '';
  122. $value['order_name'] = $var['order_name'];
  123. $value['status_name'] = $var['status_name'];
  124. $data[] = $value;
  125. }
  126. return app_show(0, "获取成功", ["list" => $data, 'count' => $count]);
  127. }
  128. public function all(){
  129. $token = isset($this->post['token']) ? trim($this->post['token']) : "";
  130. if($token==""){
  131. return error_show(101,'token不能为空');
  132. }
  133. $effetc = VerifyTokens($token);
  134. if(!empty($effetc) && $effetc['code']!=0){
  135. return error_show($effetc['code'],$effetc['message']);
  136. }
  137. $where=[["is_del","=",0]];
  138. $process_name = isset($this->post['process_name']) && $this->post['process_name'] !==""? trim($this->post['process_name']) :"";
  139. if($process_name!=""){
  140. $where[]=["process_name","like","%$process_name%"];
  141. }
  142. $process_type = isset($this->post['process_type']) && $this->post['process_type'] !==""? trim($this->post['process_type']) :"";
  143. if($process_type!=""){
  144. $where[]=["process_type","like","%$process_type%"];
  145. }
  146. $list = Db::name('process')->where($where)->order("addtime desc")->select();
  147. return app_show(0,"获取成功",$list);
  148. }
  149. }