123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <?php
- namespace app\admin\model;
- use think\facade\Config;
- //记录操作流程
- class Workflow extends \think\Model
- {
- public static function SaveFlow($data){
- $conf =Config::get("process");
- $action = isset($conf[$data['order_type']]) ? $conf[$data['order_type']]:[];
- $last =end($action);
- $order_status=2;//默认进行中
- if((is_array($last)&&in_array($data['action_process'],$last))||$last==$data['action_process']){
- $order_status=3; //流程结束
- }
- $header =reset($action);
- if((is_array($header)&&in_array($data['action_process'],$header))||$header==$data['action_process']){
- $order_status=1; //流程新建
- }
- $proces = self::where(["order_type"=>$data['order_type'],"order_id"=>$data['order_id'],"is_del"=>0])->find();
- if($proces){
- $info=[
- "order_process"=>$data['order_status'],
- "order_status"=>$order_status,
- "action_uid"=>$data['action_uid'],
- "action_name"=>$data['action_name'],
- "updatetime"=>date("Y-m-d H:i:s")
- ];
- self::where(["id"=>$proces['id']])->update($info);
- }else{
- $proces=[
- "order_type"=>$data['order_type'],
- "order_code"=>$data['order_code'],
- "order_id"=>$data['order_id'],
- "order_process"=>$data['order_status'],
- "order_status"=>$order_status,
- "apply_id"=>$data['action_uid'],
- "apply_name"=>$data['action_name'],
- "action_uid"=>$data['action_uid'],
- "action_name"=>$data['action_name'],
- "addtime"=>date("Y-m-d H:i:s"),
- "updatetime"=>date("Y-m-d H:i:s")
- ];
- self::insert($proces);
- }
- // self::Addwait($data);
- }
- /**
- * 待办事项新建
- *
- */
- public static function Addwait($data){
- $conf =Config::get("process");
- $action = isset($conf[$data['order_type']]) ? $conf[$data['order_type']]:[];
- $order_status=1 ;
- if(!empty($action)){
- $last =end($action);
- $wait="";
- foreach ($action as $key=>$value){
- if((is_array($value)&&in_array($data['action_process'],$value))||$value==$data['action_process']){
- if($value!=$last){
- $order_status=1;
- $index=$key+1;
- $wait= is_array($action[$index])? $action[$index][0]:$action[$index];
- break;
- }else{
- $wait=$data['action_process'];
- $order_status=2;
- }
- }
- }
- $orderp =ActionProcess::where(["order_type"=>$data['order_type'],"order_process"=>$wait])->find();
- if($orderp!=false){
- $data=[
- "order_type"=>$data['order_type'],
- "order_code"=>$data['order_code'],
- "order_id"=>$data['order_id'],
- "order_process"=>$wait,
- "order_status"=>$data['action_process'],
- "wait_id"=>$orderp['uid'],
- "wait_name"=>$orderp['uname'],
- "roleid"=>$orderp['roleid'],
- "action_uid"=>$data['action_uid'],
- "action_name"=>$data['action_name'],
- "status"=>$order_status,
- "addtime"=>date("Y-m-d H:i:s"),
- "updatetime"=>date("Y-m-d H:i:s")
- ];
- $da=ProcessWait::where(['order_code'=>$data['order_code'],"order_type"=>$data['order_type']])
- ->find();
- if($da==false){
- ProcessWait::insert($data);
- }else{
- ProcessWait::where(['order_code'=>$data['order_code'],"order_type"=>$data['order_type']])->update
- ($data);
- }
- }
- }
- }
- public function checkStatus(){
- }
- }
|