123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369 |
- <?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()
- {
-
- {
- $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_id=b.order_id')
- ->where(['is_del' => 0, 'a.status' => ProcessWait::$status_finish]);
- $db->where(function ($query) use ($param) {
-
- $role = $this->checkRole();
- $query->whereFindInSet('roleid', $role['roleid']);
-
-
- $query->whereOr('wait_id', $this->uid);
- });
- 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
- ->group('a.order_type,a.order_id')
- ->count('a.id');
- $total = ceil($count / $param['size']);
- $page = $param['page'] > $total ? $total : $param['page'];
-
- $order_types = $db
- ->field("ANY_VALUE(`a`.`id`) id,`a`.order_type,`a`.order_id,GROUP_CONCAT(`a`.`id` ORDER BY `a`.`id` DESC) ids")
- ->group('a.order_type,a.order_id')
- ->order(['id' => 'desc'])
- ->withAttr('ids', function ($val) {
- $temp = explode(',', $val);
- return $temp[0];
- })
- ->page($page, $param['size'])
- ->select()
- ->toArray();
- $list = ProcessWait::alias("a")
- ->field([
- 'b.apply_id',
- 'b.apply_name',
- 'a.addtime',
- 'a.action_uid_finally' => 'action_uid',
- 'a.action_name_finally' => 'action_name',
- 'a.order_status',
- 'a.order_type',
- 'a.order_code',
- 'a.order_id',
- 'a.id',
- 'a.order_process_finally' => 'order_process',
- ])
- ->whereIn('a.id', array_column($order_types, 'ids'))
- ->leftJoin("workflow b", "a.order_type=b.order_type and a.order_id=b.order_id")
- ->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")
- ->findOrEmpty();
- $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, "获取成功", ['count' => $count, 'list' => $data]);
- }
- }
-
- 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_id=b.order_id')
- ->where(['a.status' => ProcessWait::$status_wait]);
-
- $role = $this->checkRole();
- if ($role['roleid'] != 1) $db->whereFindInSet('handle_user_list', $this->uid);
-
- 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,a.addtime,a.action_name,a.order_status,a.order_type,a.order_process,a.order_code,a.order_id,a.handle_user_list,b. apply_id,b.apply_name")
- ->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'];
-
-
-
- $uid = Db::name('user_role')
- ->field('uid')
- ->where([
- ['is_del', '=', 0],
- ['uid', 'in', $value['handle_user_list']],
- ['status', '=', 1],
- ])
- ->buildSql();
- $value['handle_user_list'] = Db::name('depart_user')
- ->where(['is_del' => 0, 'status' => 1])
- ->where('uid IN ' . $uid)
- ->column('nickname');
-
- $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);
- }
- }
|