ProcessWait.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace app\admin\model;
  3. use think\facade\Db;
  4. use think\Model;
  5. //待办已办
  6. class ProcessWait extends Model
  7. {
  8. protected $table = 'wsm_process_wait';
  9. protected $pk = 'id';
  10. protected $autoWriteTimestamp = false;
  11. public static $status_wait_handle = 1;//状态,1待处理
  12. public static $status_handle_finish = 2;//状态,2待处理
  13. //添加待办记录
  14. public static function add(array $data = [])
  15. {
  16. // $data数据格式实例
  17. // $data=[
  18. // "order_type"=>'',
  19. // "order_code"=>'',
  20. // "order_id"=>'',
  21. // "order_status"=>'',
  22. // "action_process"=>'',
  23. // "action_status"=>'',
  24. // "action_uid"=>'',
  25. // "action_name"=>'',
  26. // "addtime"=>'',
  27. // ];
  28. //把上一个节点改成已完成
  29. Db::name('process_wait')
  30. ->where(['order_type' => $data['order_type'], 'order_process' => $data['action_status'], 'order_code' => $data['order_code'], 'order_id' => $data['order_id'], 'status' => self::$status_wait_handle])
  31. ->update(['status' => self::$status_handle_finish, 'updatetime' => date('Y-m-d H:i:s')]);
  32. //查询流程下该节点值的id
  33. $id = Db::name('process')
  34. ->alias('a')
  35. ->join('action_process p', 'p.process_id=a.id AND p.order_process=' . $data['action_process'] . ' AND p.operation_type = ' . ActionProcess::$operation_type_approval)
  36. ->where(['a.process_type' => $data['order_type'], 'a.status' => Process::$status_normal, 'a.is_del' => Process::$is_del_normal])->value('p.id', 0);
  37. if ($id) {
  38. //查询该节点值对应的角色id
  39. $roleid = Db::name('role_process')->whereFindInSet('action_data', $id)->where('is_del', 0)->column('role_id');
  40. //增加新的节点
  41. return self::create([
  42. 'order_type' => $data['order_type'],
  43. 'order_code' => $data['order_code'],
  44. 'order_id' => $data['order_id'],
  45. 'action_uid' => $data['action_uid'],
  46. 'action_name' => $data['action_name'],
  47. 'roleid' => implode(',', $roleid),
  48. 'status' => self::$status_wait_handle,
  49. 'order_process' => $data['action_process'],
  50. ])->save();
  51. }
  52. }
  53. }