12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- namespace app\admin\model;
- use think\facade\Db;
- use think\Model;
- //待办已办
- class ProcessWait extends Model
- {
- protected $table = 'wsm_process_wait';
- protected $pk = 'id';
- protected $autoWriteTimestamp = false;
- public static $status_wait_handle = 1;//状态,1待处理
- public static $status_handle_finish = 2;//状态,2待处理
- //添加待办记录
- public static function add(array $data = [], int $wait_id = 0, string $wait_name = '')
- {
- // $data数据格式实例
- // $data=[
- // "order_type"=>'',
- // "order_code"=>'',
- // "order_id"=>'',
- // "order_status"=>'',
- // "action_process"=>'',
- // "action_status"=>'',
- // "action_uid"=>'',
- // "action_name"=>'',
- // "addtime"=>'',
- // ];
- //把上一个节点改成已完成
- Db::name('process_wait')
- ->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])
- ->update(['status' => self::$status_handle_finish, 'updatetime' => date('Y-m-d H:i:s')]);
- //查询流程下该节点值的id
- $id = Db::name('process')
- ->alias('a')
- ->join('action_process p', 'p.process_id=a.id AND p.order_process=' . $data['action_process'] . ' AND p.operation_type = ' . ActionProcess::$operation_type_approval)
- ->where(['a.process_type' => $data['order_type'], 'a.status' => Process::$status_normal, 'a.is_del' => Process::$is_del_normal])->value('p.id', 0);
- if ($id) {
- $insert_data = [
- 'order_type' => $data['order_type'],
- 'order_code' => $data['order_code'],
- 'order_id' => $data['order_id'],
- 'action_uid' => $data['action_uid'],
- 'action_name' => $data['action_name'],
- 'status' => self::$status_wait_handle,
- 'order_process' => $data['action_process'],
- 'addtime' => date('Y-m-d H:i:s'),
- 'updatetime' => date('Y-m-d H:i:s'),
- ];
- if ($wait_id) {
- $insert_data['wait_id'] = $wait_id;
- $insert_data['wait_name'] = $wait_name;
- } else {
- //查询该节点值对应的角色id
- $roleid = Db::name('role_process')
- ->whereFindInSet('action_data', $id)
- ->where('is_del', 0)
- ->column('role_id');
- $insert_data['roleid'] = implode(',', $roleid);
- }
- //增加新的节点
- return self::create($insert_data)->save();
- }
- }
- }
|