123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- <?php
- namespace app\admin\controller;
- use app\admin\model\ProcessWait;
- use think\App;
- use think\facade\Db;
- //消息(已读未读)
- class Proorder extends Base
- {
- public function __construct(App $app)
- {
- parent::__construct($app);
- }
- //已读列表
- public function list()
- {
- /**暂时屏蔽
- * $page = isset($this->post['page']) && $this->post['page'] !==""? intval($this->post['page']) :"1";
- * $size = isset($this->post['size']) && $this->post['size'] !==""? intval($this->post['size']) :"10";
- * $where =[['is_del',"=",0],['a.order_status',"=",2]];
- * $role=$this->checkRole();
- * if(!empty($role['write'])){
- * $where[]=["a.action_uid","in",$role['write']];
- * }
- * $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();
- * $total = ceil("$count/$size");
- * $page = $page>$total ? $total:$page;
- * $list = Db::name('process_order')->alias("a")->leftJoin("workflow b","a.order_type=b.order_type and a.order_code=b.order_code")
- * ->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")
- * ->where($where)->page($page,$size)->order("a.addtime desc")->select();
- * $data=[];
- * foreach ($list as $value){
- * $str = Db::name("process")->where(['process_type' => $value['order_type']])->field("process_name,status")->find();
- * $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();
- * $value['process_name']=$str['process_name'];
- * $value['order_name']=$var['order_name'];
- * $value['status_name'] = $var['status_name'];
- * $data[]=$value;
- * }
- * return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
- * **/
- {
- $param = $this->request->filter('trim')->only(['token', 'apply_id' => '', 'action_uid' => '', 'order_code' => '', 'page' => 1, 'size' => 10], 'post');
- $db = ProcessWait::alias("a")
- ->leftJoin("workflow b", "a.order_type=b.order_type and a.order_code=b.order_code")
- ->where(['is_del' => 0, 'a.status' => ProcessWait::$status_finish]);
- $db->where(function ($query) use ($param) {
- //所属角色
- $role = $this->checkRole();
- // if (!empty($role['write']) || $role['roleid'] == 33) $query->whereFindInSet('roleid', $role['roleid']);
- $query->whereFindInSet('roleid', $role['roleid']);
- //本人id
- $user = GetUserInfo($param['token']);
- if (isset($user['data']['id'])) $query->whereOr('wait_id', $user['data']['id']);
- });
- if ($param['order_code'] != '') $db->whereLike("a.order_code", '%' . $param['order_code'] . '%');
- if ($param['action_uid'] != '') $db->where('a.action_uid', $param['action_uid']);
- $count = $db->count();
- $total = ceil($count / $param['size']);
- $page = $param['page'] > $total ? $total : $param['page'];
- $list = $db
- ->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")
- ->page($page, $param['size'])
- ->order("a.addtime desc")
- ->select()
- ->toArray();
- //所有流程名称
- $all_process = Db::name("process")
- ->whereIn('process_type', array_column($list, 'order_type'))
- ->column("process_name", 'process_type');
- $data = [];
- foreach ($list as $value) {
- $var = Db::name("action_process")
- ->where(['order_type' => $value['order_type'], 'order_process' => $value['order_process']])
- ->field("status_name,order_process,order_name,roleid")
- ->find();
- $value['process_name'] = isset($all_process[$value['order_type']]) ? $all_process[$value['order_type']] : '';
- $value['order_name'] = $var['order_name'];
- $value['status_name'] = $var['status_name'];
- $data[] = $value;
- }
- return app_show(0, "获取成功", ["list" => $data, 'count' => $count]);
- }
- }
- //待处理列表
- public function waitlist()
- {
- $param = $this->request->filter('trim')->only(['token', 'apply_id' => '', 'action_uid' => '', 'order_code' => '', 'page' => 1, 'size' => 10], 'post');
- $db = ProcessWait::alias("a")
- ->leftJoin("workflow b", "a.order_type=b.order_type and a.order_code=b.order_code")
- ->where(['is_del' => 0, 'a.status' => ProcessWait::$status_wait]);
- $db->where(function ($query) use ($param) {
- //所属角色
- $role = $this->checkRole();
- // if (!empty($role['write']) || $role['roleid'] == 33) $query->whereFindInSet('roleid', $role['roleid']);
- $query->whereFindInSet('roleid', $role['roleid']);
- //本人id
- $user = GetUserInfo($param['token']);
- if (isset($user['data']['id'])) $query->whereOr('wait_id', $user['data']['id']);
- });
- if ($param['order_code'] != '') $db->whereLike('a.order_code', '%' . $param['order_code'] . '%');
- if ($param['action_uid'] != '') $db->where('a.action_uid', $param['action_uid']);
- $count = $db->count();
- $total = ceil($count / $param['size']);
- $page = $param['page'] > $total ? $total : $param['page'];
- $list = $db
- ->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")
- ->page($page, $param['size'])
- ->order("a.addtime desc")
- ->select()
- ->toArray();
- //所有流程名称
- $all_process = Db::name("process")
- ->whereIn('process_type', array_column($list, 'order_type'))
- ->column("process_name", 'process_type');
- $data = [];
- foreach ($list as $value) {
- $var = Db::name("action_process")
- ->where(['order_type' => $value['order_type'], 'order_process' => $value['order_process']])
- ->field("status_name,order_process,order_name,roleid")
- ->find();
- $value['process_name'] = isset($all_process[$value['order_type']]) ? $all_process[$value['order_type']] : '';
- $value['order_name'] = $var['order_name'];
- $value['status_name'] = $var['status_name'];
- $data[] = $value;
- }
- return app_show(0, "获取成功", ["list" => $data, 'count' => $count]);
- }
- public function all(){
- $token = isset($this->post['token']) ? trim($this->post['token']) : "";
- if($token==""){
- return error_show(101,'token不能为空');
- }
- $effetc = VerifyTokens($token);
- if(!empty($effetc) && $effetc['code']!=0){
- return error_show($effetc['code'],$effetc['message']);
- }
- $where=[["is_del","=",0]];
- $process_name = isset($this->post['process_name']) && $this->post['process_name'] !==""? trim($this->post['process_name']) :"";
- if($process_name!=""){
- $where[]=["process_name","like","%$process_name%"];
- }
- $process_type = isset($this->post['process_type']) && $this->post['process_type'] !==""? trim($this->post['process_type']) :"";
- if($process_type!=""){
- $where[]=["process_type","like","%$process_type%"];
- }
- $list = Db::name('process')->where($where)->order("addtime desc")->select();
- return app_show(0,"获取成功",$list);
- }
- }
|