123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <?php
- namespace app\admin\model;
- use think\facade\Config;
- //记录操作流程
- class Workflow extends \think\Model
- {
- public static $conf=[];
- public static $order_status=2;
- public function __construct(array $data = [])
- {
- parent::__construct($data);
- self::$conf=Config::get("process");
- $conf =self::$conf;
- $action = isset($conf[$data['order_type']]) ? $conf[$data['order_type']]:[];
- $last =end($action);
- self::$order_status=2;//默认进行中
- if((is_array($last)&&in_array($data['action_process'],$last))||$last==$data['action_process']){
- self::$order_status=3; //流程结束
- }
- $header =reset($action);
- if((is_array($header)&&in_array($data['action_process'],$header))||$header==$data['action_process']){
- self::$order_status=1; //流程新建
- }
- }
- public static function SaveFlow($data){
- $proces = self::where(["order_type"=>$data['order_type'],"order_code"=>$data['order_code'],"is_del"=>0])->find();
- if($proces){
- $info=[
- "order_process"=>$data['order_status'],
- "order_status"=>self::$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"=>self::$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);
- }
- }
- /**
- * 待办事项新建
- *
- */
- public function Addwait($data){
- $conf =self::$conf;
- $action = isset($conf[$data['order_type']]) ? $conf[$data['order_type']]:[];
- 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){
- $index=$key+1;
- $wait= is_array($action[$index])? $action[$index][0]:$action[$index];
- break;
- }
- }
- }
- $orderp =Db::name("action_prcess")->field("uid,uname")->where(["order_type"=>$data['order_type'],
- "order_process"=>$wait])->find();
- $data=[
- "order_type"=>$data['order_type'],
- "order_code"=>$data['order_code'],
- "order_id"=>$data['order_id'],
- "order_process"=>$wait,
- "order_status"=>$data['action_process'],
- "apply_id"=>$data['action_uid'],
- "apply_name"=>$data['action_name'],
- "action_uid"=>$orderp['uid'],
- "action_name"=>$orderp['uname'],
- "addtime"=>date("Y-m-d H:i:s"),
- "updatetime"=>date("Y-m-d H:i:s")
- ];
- }
- }
- public function checkStatus(){
- }
- }
|