123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- namespace app\admin\controller;
- use app\BaseController;
- use think\App;
- use think\facade\Db;
- class Process extends BaseController
- {
- public $post="";
- public function __construct(App $app)
- {
- parent::__construct($app);
- $this->post = $this->request->post();
- }
- /**
- * @return \think\response\Json|void
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- 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")->count();
- $total = ceil($count/$size);
- $page = $page>$total ? $total:$page;
- $list = Db::name("process")->page($page,$size)->select();
- return app_show(0,"获取成功",["list"=>$list,"count"=>$count]);
- }
- /**
- * @return \think\response\Json|void
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- 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);
- }
- /**
- * @return \think\response\Json|void
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- 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")
- ->select();
- $data=[];
- foreach ($list as $value){
- $node = Db::name("process_order")->where(["order_type"=>$value['order_type'],"action_process"=>$value['order_process'],"order_code"=>$orderCode])->find();
- $value['node']=!empty($node) ?$node:[];
- $data[]=$value;
- }
- return app_show(0,"获取成功",$data);
- }
- }
|