|
@@ -8,30 +8,32 @@ 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");
|
|
|
- }
|
|
|
-
|
|
|
- public static function SaveFlow($data){
|
|
|
$conf =self::$conf;
|
|
|
$action = isset($conf[$data['order_type']]) ? $conf[$data['order_type']]:[];
|
|
|
$last =end($action);
|
|
|
- $order_status=2;//默认进行中
|
|
|
+ self::$order_status=2;//默认进行中
|
|
|
if((is_array($last)&&in_array($data['action_process'],$last))||$last==$data['action_process']){
|
|
|
- $order_status=3; //流程结束
|
|
|
+ self::$order_status=3; //流程结束
|
|
|
}
|
|
|
|
|
|
$header =reset($action);
|
|
|
if((is_array($header)&&in_array($data['action_process'],$header))||$header==$data['action_process']){
|
|
|
- $order_status=1; //流程新建
|
|
|
+ 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"=>$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")
|
|
@@ -43,7 +45,7 @@ class Workflow extends \think\Model
|
|
|
"order_code"=>$data['order_code'],
|
|
|
"order_id"=>$data['order_id'],
|
|
|
"order_process"=>$data['order_status'],
|
|
|
- "order_status"=>$order_status,
|
|
|
+ "order_status"=>self::$order_status,
|
|
|
"apply_id"=>$data['action_uid'],
|
|
|
"apply_name"=>$data['action_name'],
|
|
|
"action_uid"=>$data['action_uid'],
|
|
@@ -52,6 +54,7 @@ class Workflow extends \think\Model
|
|
|
"updatetime"=>date("Y-m-d H:i:s")
|
|
|
];
|
|
|
self::insert($proces);
|
|
|
+ self::Addwait($data);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -60,7 +63,44 @@ class Workflow extends \think\Model
|
|
|
* 待办事项新建
|
|
|
*
|
|
|
*/
|
|
|
- public function Addwait($data){
|
|
|
+ public static 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 =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'],
|
|
|
+ "apply_id"=>$data['action_uid'],
|
|
|
+ "apply_name"=>$data['action_name'],
|
|
|
+ "action_uid"=>$orderp['uid'],
|
|
|
+ "action_name"=>$orderp['uname'],
|
|
|
+ "status"=>self::$order_status==3?2:1,
|
|
|
+ "addtime"=>date("Y-m-d H:i:s"),
|
|
|
+ "updatetime"=>date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ ProcessWait::add($data);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|