1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?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 = [])
- {
- // $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) {
- //查询该节点值对应的角色id
- $roleid = Db::name('role_process')->whereFindInSet('action_data', $id)->where('is_del', 0)->column('role_id');
- //增加新的节点
- return self::create([
- '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'],
- 'roleid' => implode(',', $roleid),
- 'status' => self::$status_wait_handle,
- 'order_process' => $data['action_process'],
- ])->save();
- }
- }
- }
|