123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?php
- namespace app\admin\controller;
- use app\BaseController;
- use think\App;
- use think\facade\Db;
- class Process 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;
- $count = Db::name("process")->where('is_del',0)->count();
- $total = ceil($count/$size);
- $page = $page>$total ? $total:$page;
- $list = Db::name("process")->where('is_del', 0)->page($page, $size)->select();
- return app_show(0,"获取成功",["list"=>$list,"count"=>$count]);
- }
-
- public function info(){
- $id =isset($this->post['id']) &&$this->post['id']!="" ? intval($this->post['id']) : "";
- if($id==""){
- return error_show(1004,"参数id 不能为空");
- }
- $info = Db::name("process")->where(['id'=>$id,"is_del"=>0])->find();
- if(empty($info)){
- return error_show(1004,"流程信息未找到");
- }
- $list=Db::name("action_process")->where(["pid"=>$id,"is_del"=>0])->order("weight,id")->select();
- $info['item'] = empty($list) ? []:$list;
- return app_show(0,"获取成功",$info);
- }
-
- public function process()
- {
- $process_type = isset($this->post['type']) && $this->post['type'] != "" ? $this->post['type'] : "";
- if ($process_type == "") {
- return error_show(1004, "参数type 不能为空");
- }
- $orderCode = isset($this->post['orderCode']) && $this->post['orderCode'] != "" ? $this->post['orderCode'] : "";
- if ($orderCode == "") {
- return error_show(1004, "参数orderCode不能为空");
- }
- $list = Db::name("action_process")
- ->where(['order_type' => $process_type, "is_del" => 0, "status" => 1])
- ->order("weight desc,id desc")
- ->column('*', 'order_process');
-
- $order_process_s = array_column($list, 'order_process');
- $rs = Db::name("process_order")
- ->where(["order_type" => $process_type])
- ->whereIn('action_process', $order_process_s)
- ->field('id,action_uid,action_name,addtime,action_process,order_type');
- if(is_numeric($orderCode)) $rs->where('order_id',$orderCode);
- else $rs->where('order_code',$orderCode);
- $node = $rs
- ->select()
- ->toArray();
- foreach ($node as &$value) {
- $value['order_process'] = isset($list[$value['action_process']]['order_process']) ? $list[$value['action_process']]['order_process'] : 0;
- $value['order_name'] = isset($list[$value['action_process']]['order_name']) ? $list[$value['action_process']]['order_name'] : '';
- $value['pid'] = isset($list[$value['action_process']]['pid']) ? $list[$value['action_process']]['pid'] : '';
- $value['status_name'] = isset($list[$value['action_process']]['status_name']) ? $list[$value['action_process']]['status_name'] : '';
- $value['roleid'] = isset($list[$value['action_process']]['roleid']) ? $list[$value['action_process']]['roleid'] : '';
- $value['status'] = isset($list[$value['action_process']]['status']) ? $list[$value['action_process']]['status'] : '';
- $value['weight'] = isset($list[$value['action_process']]['weight']) ? $list[$value['action_process']]['weight'] : '';
- $value['is_del'] = isset($list[$value['action_process']]['is_del']) ? $list[$value['action_process']]['is_del'] : '';
- }
- return app_show(0, "获取成功", $node);
- }
- }
|