ProcessOrder.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace app\admin\model;
  3. use think\facade\Config;
  4. class ProcessOrder extends \think\Model
  5. {
  6. //记录流程
  7. public static function AddProcess($token,$order){
  8. if (is_string($token)) {
  9. $user = GetUserInfo($token);
  10. $uid = isset($user['data']['id']) ? $user['data']['id'] : 0;
  11. $name = isset($user['data']['nickname']) ? $user['data']['nickname'] : '';
  12. } else {
  13. //主要是某些脚本调用时没有token
  14. $uid = isset($token['id']) ? $token['id'] : 0;
  15. $name = isset($token['nickname']) ? $token['nickname'] : '';
  16. }
  17. $conf =Config::get("process");
  18. $action = isset($conf[$order['order_type']]) ? $conf[$order['order_type']]:[];
  19. $header =reset($action);
  20. if((is_array($header)&&in_array($order['order_status'],$header))||$header==$order['order_status']){
  21. $order_status=1; //流程新建
  22. }else{
  23. $order_status=2;
  24. }
  25. $data=[
  26. "order_type"=>$order['order_type'],
  27. "order_code"=>$order['order_code'],
  28. "order_id"=>isset($order['order_id']) ?$order['order_id']:0 ,
  29. "order_status"=>$order_status,
  30. "action_process"=>$order['order_status'],
  31. "action_status"=>$order['before_status'],
  32. "action_uid"=>$uid,
  33. "action_name"=>$name,
  34. "addtime"=>date("Y-m-d H:i:s"),
  35. // 'holder_id'=>$order['holder_id'],//数据所有人
  36. ];
  37. OrderMsg::addmsg($data);
  38. //手动排除竞价单ZXD
  39. if($order['order_type']!='ZXD') {
  40. 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']??'');
  41. }
  42. $insert = $data;
  43. //如果是【供应商】应用,即abutment,增加字段source==2(操作来源为供应商)
  44. if (strtolower(app('http')->getName()) == 'abutment') $insert['source'] = 2;
  45. if (self::insert($insert)) {
  46. Workflow::SaveFlow($data);
  47. };
  48. }
  49. public static function workdel($order){
  50. Workflow::where(["order_type"=>$order['order_type'],"order_code"=>$order['order_code']])->save(["is_del"=>1,"updatetime"=>date("y-m-d H:i:s")]);
  51. }
  52. }