From 83a95c77708457da349d4842f661aaf335d7938f Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Mon, 20 Nov 2023 15:26:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/OaApprove.php | 330 ------------------------------- 1 file changed, 330 deletions(-) diff --git a/app/api/controller/OaApprove.php b/app/api/controller/OaApprove.php index b0c49fa..84df62d 100644 --- a/app/api/controller/OaApprove.php +++ b/app/api/controller/OaApprove.php @@ -323,336 +323,6 @@ class OaApprove extends ApiController $this->apiSuccess('操作成功'); } - //流程审核 - public function flow_check() - { - $param = get_params(); - $this->uid = JWT_UID; - $loginAdmin = Db::name('Admin')->where(['id' => $this->uid])->find(); - $this->did = $loginAdmin['did']; - if (empty($param['id'])) { - $this->apiError("审批流程id不能为空"); - } - if (empty($param['type'])) { - $this->apiError("审批流程类型不能为空"); - } - // 1同意 2拒绝 3撤销 - if (empty($param['check'])) { - $this->apiError("审批状态不能为空"); - } - if ($param['check'] != 3) { - if (empty($param['content'])) { - $this->apiError("审批内容不能为空"); - } - //1审核结束 2下一审批人 - if (empty($param['check_node'])) { - $this->apiError("审批节点不能为空"); - } - } - - $id = $param['id']; - $type = $param['type']; - $detail = []; - $subject = '一个审批'; - if($type==1){ - //日常审核 - $detail = Db::name('Approve')->where(['id' => $id])->find(); - $subject = '一个日常审批'; - $msg_title_type = $detail['type']; - } - else if($type==2){ - //报销审核 - $detail = Db::name('Expense')->where(['id' => $id])->find(); - $subject = '一个报销审批'; - $msg_title_type = 22; - } - else if($type==3){ - //发票审核 - $detail = Db::name('Invoice')->where(['id' => $id])->find(); - $subject = '一个发票审批'; - $msg_title_type = 23; - } - else if($type==4){ - //合同审核 - $detail = Db::name('Contract')->where(['id' => $id])->find(); - $subject = '一个合同审批'; - $msg_title_type = 24; - } - if (empty($detail)){ - $this->apiError("审批数据错误"); - } - //当前审核节点详情 - $step = Db::name('FlowStep')->where(['action_id'=>$id,'type'=>$type,'sort'=>$detail['check_step_sort'],'delete_time'=>0])->find(); - - //审核通过 - if($param['check'] == 1){ - $check_admin_ids = explode(",", strval($detail['check_admin_ids'])); - if (!in_array($this->uid, $check_admin_ids)){ - $this->apiError("您没权限审核该审批", [], 2); - } - - //多人会签审批 - if($step['flow_type'] == 4){ - //查询当前会签记录数 - $check_count = Db::name('FlowRecord')->where(['action_id'=>$id,'type'=>$type,'step_id'=>$step['id']])->count(); - //当前会签记应有记录数 - $flow_count = explode(',', $step['flow_uids']); - if(($check_count+1) >=count($flow_count)){ - $next_step = Db::name('FlowStep')->where(['action_id'=>$id,'type'=>$type,'sort'=>($detail['check_step_sort']+1),'delete_time'=>0])->find(); - if($next_step){ - //存在下一步审核 - if($next_step['flow_type'] == 1){ - $param['check_admin_ids'] = get_department_manager($detail['admin_id']); - } - else if($next_step['flow_type'] == 2){ - $param['check_admin_ids'] = get_department_manager($detail['admin_id'],1); - } - else if($next_step['flow_type'] == 7){ - $param['check_admin_ids'] = get_department_leader($detail['admin_id']); - } - else if($next_step['flow_type'] == 6){ - $param['check_admin_ids'] = get_department_leader($detail['admin_id'],1); - } - else{ - $param['check_admin_ids'] = $next_step['flow_uids']; - } - $param['check_step_sort'] = $detail['check_step_sort']+1; - $param['check_status'] = 1; - } - else{ - //不存在下一步审核,审核结束 - $param['check_status'] = 2; - $param['check_admin_ids'] =''; - } - } - else{ - $param['check_status'] = 1; - $param['check_admin_ids'] = $step['flow_uids']; - } - } - else if($step['flow_type'] == 0){ - //自由人审批 - if($param['check_node'] == 2){ - $next_step = $detail['check_step_sort']+1; - $flow_step = array( - 'action_id' => $id, - 'sort' => $next_step, - 'type' => $type, - 'flow_uids' => $param['check_admin_ids'], - 'create_time' => time() - ); - $fid = Db::name('FlowStep')->strict(false)->field(true)->insertGetId($flow_step); - //下一步审核步骤 - $param['check_admin_ids'] = $param['check_admin_ids']; - $param['check_step_sort'] = $next_step; - $param['check_status'] = 1; - } - else{ - //不存在下一步审核,审核结束 - $param['check_status'] = 2; - $param['check_admin_ids'] =''; - } - } - else{ - $next_step = Db::name('FlowStep')->where(['action_id'=>$id,'type'=>$type,'sort'=>($detail['check_step_sort']+1),'delete_time'=>0])->find(); - if($next_step){ - //存在下一步审核 - if($next_step['flow_type'] == 1){ - $param['check_admin_ids'] = get_department_manager($detail['admin_id']); - } - else if($next_step['flow_type'] == 2){ - $param['check_admin_ids'] = get_department_manager($detail['admin_id'],1); - } - else if($next_step['flow_type'] == 7){ - $param['check_admin_ids'] = get_department_leader($detail['admin_id']); - } - else if($next_step['flow_type'] == 6){ - $param['check_admin_ids'] = get_department_leader($detail['admin_id'],1); - } - else{ - $param['check_admin_ids'] = $next_step['flow_uids']; - } - $param['check_step_sort'] = $detail['check_step_sort']+1; - $param['check_status'] = 1; - } - else{ - //不存在下一步审核,审核结束 - $param['check_status'] = 2; - $param['check_admin_ids'] =''; - } - } - if($param['check_status'] == 1 && empty($param['check_admin_ids'])){ - $this->apiError("找不到下一步的审批人,该审批流程设置有问题,请联系HR或者管理员"); - } - //审核通过数据操作 - $param['last_admin_id'] = $this->uid; - $param['flow_admin_ids'] = $detail['flow_admin_ids'].$this->uid.','; - - if($type==1){ - //日常审核 - $res = Db::name('Approve')->strict(false)->field('check_step_sort,check_status,last_admin_id,flow_admin_ids,check_admin_ids')->update($param); - } - else if($type==2){ - //报销审核 - $res = Db::name('Expense')->strict(false)->field('check_step_sort,check_status,last_admin_id,flow_admin_ids,check_admin_ids')->update($param); - } - else if($type==3){ - //发票审核 - $res = Db::name('Invoice')->strict(false)->field('check_step_sort,check_status,last_admin_id,flow_admin_ids,check_admin_ids')->update($param); - } - else if($type==4){ - //合同审核 - $res = Db::name('Contract')->strict(false)->field('check_step_sort,check_status,last_admin_id,flow_admin_ids,check_admin_ids')->update($param); - } - - if($res!==false){ - $checkData=array( - 'action_id' => $id, - 'step_id' => $step['id'], - 'check_user_id' => $this->uid, - 'type' => $type, - 'check_time' => time(), - 'status' => $param['check'], - 'content' => $param['content'], - 'create_time' => time() - ); - $aid = Db::name('FlowRecord')->strict(false)->field(true)->insertGetId($checkData); - add_log('check', $param['id'], $param,$subject); - //发送消息通知 - $msg=[ - 'create_time'=>date('Y-m-d H:i:s',$detail['create_time']), - 'action_id'=>$id, - 'title' => Db::name('FlowType')->where('id',$msg_title_type)->value('title'), - 'from_uid'=>$detail['admin_id'] - ]; - if($param['check_status'] == 1){ - $users = $param['check_admin_ids']; - sendMessage($users,($type*10+11),$msg); - } - if($param['check_status'] == 2){ - $users = $detail['admin_id']; - sendMessage($users,($type*10+12),$msg); - } - $this->apiSuccess('操作成功'); - } - else{ - $this->apiError("操作失败"); - } - } - else if($param['check'] == 2){ - $check_admin_ids = explode(",", strval($detail['check_admin_ids'])); - if (!in_array($this->uid, $check_admin_ids)){ - $this->apiError("您没权限审核该审批", [], 2); - } - //拒绝审核,数据操作 - $param['check_status'] = 3; - $param['last_admin_id'] = $this->uid; - $param['flow_admin_ids'] = $detail['flow_admin_ids'].$this->uid.','; - $param['check_admin_ids'] =''; - if($step['flow_type'] == 5){ - //获取上一步的审核信息 - $prev_step = Db::name('FlowStep')->where(['action_id'=>$id,'type'=>$type,'sort'=>($detail['check_step_sort']-1),'delete_time'=>0])->find(); - if($prev_step){ - //存在上一步审核 - $param['check_step_sort'] = $prev_step['sort']; - $param['check_admin_ids'] = $prev_step['flow_uids']; - $param['check_status'] = 1; - } - else{ - //不存在上一步审核,审核初始化步骤 - $param['check_step_sort'] = 0; - $param['check_admin_ids'] = ''; - $param['check_status'] = 0; - } - } - if($type==1){ - //日常审核 - $res = Db::name('Approve')->strict(false)->field('check_step_sort,check_status,last_admin_id,flow_admin_ids,check_admin_ids')->update($param); - } - else if($type==2){ - //报销审核 - $res = Db::name('Expense')->strict(false)->field('check_step_sort,check_status,last_admin_id,flow_admin_ids,check_admin_ids')->update($param); - } - else if($type==3){ - //发票审核 - $res = Db::name('Invoice')->strict(false)->field('check_step_sort,check_status,last_admin_id,flow_admin_ids,check_admin_ids')->update($param); - } - else if($type==4){ - //合同审核 - $res = Db::name('Contract')->strict(false)->field('check_step_sort,check_status,last_admin_id,flow_admin_ids,check_admin_ids')->update($param); - } - if($res!==false){ - $checkData=array( - 'action_id' => $id, - 'step_id' => $step['id'], - 'check_user_id' => $this->uid, - 'type' => $type, - 'check_time' => time(), - 'status' => $param['check'], - 'content' => $param['content'], - 'create_time' => time() - ); - $aid = Db::name('FlowRecord')->strict(false)->field(true)->insertGetId($checkData); - add_log('refue', $param['id'], $param,$subject); - //发送消息通知 - $msg=[ - 'create_time'=>date('Y-m-d H:i:s',$detail['create_time']), - 'action_id'=>$detail['id'], - 'title' => Db::name('FlowType')->where('id',$msg_title_type)->value('title'), - 'from_uid'=>$detail['admin_id'] - ]; - $users = $detail['admin_id']; - sendMessage($users,($type*10+13),$msg); - $this->apiSuccess('操作成功'); - } - else{ - $this->apiError("操作失败"); - } - } - else if($param['check'] == 3){ - if($detail['admin_id'] != $this->uid){ - $this->apiError("你没权限操作", [], 2); - } - //撤销审核,数据操作 - $param['check_status'] = 4; - $param['check_admin_ids'] =''; - $param['check_step_sort'] =0; - if($type==1){ - //日常审核 - $res = Db::name('Approve')->strict(false)->field('check_step_sort,check_status,check_admin_ids')->update($param); - } - else if($type==2){ - //报销审核 - $res = Db::name('Expense')->strict(false)->field('check_step_sort,check_status,check_admin_ids')->update($param); - } - else if($type==3){ - //发票审核 - $res = Db::name('Invoice')->strict(false)->field('check_step_sort,check_status,check_admin_ids')->update($param); - } - else if($type==4){ - //合同审核 - $res = Db::name('Contract')->strict(false)->field('check_step_sort,check_status,check_admin_ids')->update($param); - } - if($res!==false){ - $checkData=array( - 'action_id' => $id, - 'step_id' => 0, - 'check_user_id' => $this->uid, - 'type' => $type, - 'check_time' => time(), - 'status' => $param['check'], - 'content' => $param['content'], - 'create_time' => time() - ); - $aid = Db::name('FlowRecord')->strict(false)->field(true)->insertGetId($checkData); - add_log('back', $param['id'], $param,$subject); - $this->apiSuccess('操作成功'); - }else{ - $this->apiError("操作失败"); - } - } - } - //查看流程 public function view() {