123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace app\admin\model;
- use think\facade\Config;
- class ProcessOrder extends \think\Model
- {
- //记录流程
- public static function AddProcess($token,$order){
- if (is_string($token)) {
- $user = GetUserInfo($token);
- $uid = isset($user['data']['id']) ? $user['data']['id'] : 0;
- $name = isset($user['data']['nickname']) ? $user['data']['nickname'] : '';
- } else {
- //主要是某些脚本调用时没有token
- $uid = isset($token['id']) ? $token['id'] : 0;
- $name = isset($token['nickname']) ? $token['nickname'] : '';
- }
- $conf =Config::get("process");
- $action = isset($conf[$order['order_type']]) ? $conf[$order['order_type']]:[];
- $header =reset($action);
- if((is_array($header)&&in_array($order['order_status'],$header))||$header==$order['order_status']){
- $order_status=1; //流程新建
- }else{
- $order_status=2;
- }
- $data=[
- "order_type"=>$order['order_type'],
- "order_code"=>$order['order_code'],
- "order_id"=>isset($order['order_id']) ?$order['order_id']:0 ,
- "order_status"=>$order_status,
- "action_process"=>$order['order_status'],
- "action_status"=>$order['before_status'],
- "action_uid"=>$uid,
- "action_name"=>$name,
- "addtime"=>date("Y-m-d H:i:s"),
- // 'holder_id'=>$order['holder_id'],//数据所有人
- ];
- OrderMsg::addmsg($data);
- //手动排除竞价单ZXD
- if($order['order_type']!='ZXD') {
- ProcessWait::add(array_merge($data, ['holder_id' => $order['holder_id'] ?? 0,'person_id' => $order['person_id'] ?? 0]), isset($order['wait_id']) ? $order['wait_id'] : 0, isset($order['wait_name']) ? $order['wait_name'] : '',$order['handle_user_list']??'');
- }
- $insert = $data;
- //如果是【供应商】应用,即abutment,增加字段source==2(操作来源为供应商)
- if (strtolower(app('http')->getName()) == 'abutment') $insert['source'] = 2;
- //区分操作账号等级
- $insert['level'] = request()->level;
- if (self::insert($insert)) {
- Workflow::SaveFlow($data);
- };
- }
- public static function workdel($order){
- Workflow::where(["order_type"=>$order['order_type'],"order_code"=>$order['order_code']])->save(["is_del"=>1,"updatetime"=>date("y-m-d H:i:s")]);
- }
- }
|