From 80d1af3d0dadd77fc743d141dd920c3518e4a026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=90=8C?= <494089941@qq.com> Date: Wed, 8 Mar 2023 14:42:29 +0800 Subject: [PATCH] bug fix --- application/admin/model/ExamineStep.php | 367 +++++++++++--------- application/crm/controller/CustomerPool.php | 4 +- 2 files changed, 207 insertions(+), 164 deletions(-) diff --git a/application/admin/model/ExamineStep.php b/application/admin/model/ExamineStep.php index 1bc99bd..6e26902 100644 --- a/application/admin/model/ExamineStep.php +++ b/application/admin/model/ExamineStep.php @@ -13,59 +13,59 @@ use think\Validate; class ExamineStep extends Common { - /** + /** * 为了数据库的整洁,同时又不影响Model和Controller的名称 * 我们约定每个模块的数据表都加上相同的前缀,比如CRM模块用crm作为数据表前缀 */ - protected $name = 'admin_examine_step'; + protected $name = 'admin_examine_step'; /** * 获取有效审批步骤列表 - * @param flow_id 审批流程ID - * @param user_id 审批申请人ID + * @param flow_id 审批流程ID + * @param user_id 审批申请人ID * @return - */ + */ public function getDataList($flow_id) { $userModel = new \app\admin\model\User(); $list = $this->where(['flow_id' => $flow_id])->order('order_id asc')->select(); - foreach ($list as $k=>$v) { + foreach ($list as $k => $v) { $list[$k]['user_id_info'] = $userModel->getListByStr($v['user_id']); } - return $list ? : []; - } + return $list ?: []; + } - /** + /** * 审批步骤(创建、编辑) - * @param flow_id 审批流程ID + * @param flow_id 审批流程ID * @param status 1负责人主管,2指定用户(任意一人),3指定用户(多人会签),4上一级审批人主管 - * @return + * @return */ public function createStepData($data, $flow_id) { - if (!intval($flow_id)) { - $this->error = '审批流程创建失败'; - return false; - } + if (!intval($flow_id)) { + $this->error = '审批流程创建失败'; + return false; + } //处理数据 $resSuccess = true; $dataStep = []; - foreach ($data as $k=>$v) { - if (!intval($v['status']) || (in_array($v['status'],[2,3]) && !$v['user_id'])) { + foreach ($data as $k => $v) { + if (!intval($v['status']) || (in_array($v['status'], [2, 3]) && !$v['user_id'])) { $resSuccess = false; } $dataStep[$k]['relation'] = 1; - if (in_array($v['status'],[2,3])) { + if (in_array($v['status'], [2, 3])) { $dataStep[$k]['user_id'] = $v['user_id'] ? arrayToString($v['user_id']) : ''; //处理user_id $dataStep[$k]['relation'] = ($v['status'] == 3) ? 1 : 2; } if ($v['step']) { $dataStep[$k]['step_id'] = $v['step']; } - $dataStep[$k]['order_id'] = $k+1; + $dataStep[$k]['order_id'] = $k + 1; $dataStep[$k]['flow_id'] = $flow_id; $dataStep[$k]['status'] = $v['status']; - $dataStep[$k]['create_time'] = time(); + $dataStep[$k]['create_time'] = time(); } if ($resSuccess) { //提交事务 @@ -74,59 +74,59 @@ class ExamineStep extends Common $this->where(['flow_id' => $flow_id])->delete(); $this->saveAll($dataStep); $this->commit(); - return true; - } catch(\Exception $e) { + return true; + } catch (\Exception $e) { $this->error = '审批步骤创建失败'; $this->rollback(); return false; - } + } } else { $this->error = '参数错误'; - return false; - } + return false; + } } - /** + /** * 审批步骤(排序,防止位置情况造成排序错乱) - * @param flow_id 审批流程ID - * @return - */ + * @param flow_id 审批流程ID + * @return + */ public function orderData($flow_id) { - $step_list = db('admin_examine_step')->where(['flow_id' => $flow_id])->order('order_id')->select(); - foreach ($step_list as $k=>$v) { - $data = []; - $data = ['step_id' => $v['step_id'],'order_id' => $k]; - db('admin_examine_step')->update($data); - } - } + $step_list = db('admin_examine_step')->where(['flow_id' => $flow_id])->order('order_id')->select(); + foreach ($step_list as $k => $v) { + $data = []; + $data = ['step_id' => $v['step_id'], 'order_id' => $k]; + db('admin_examine_step')->update($data); + } + } - /** + /** * 下一审批人(审批是否结束) - * @param user_id 审批申请人ID - * @param flow_id 审批流ID - * @param types 关联对象 - * @param types_id 联对象ID - * @param order_id 审批排序ID + * @param user_id 审批申请人ID + * @param flow_id 审批流ID + * @param types 关联对象 + * @param types_id 联对象ID + * @param order_id 审批排序ID * @param status 1负责人主管,2指定用户(任意一人),3指定用户(多人会签),4上一级审批人主管 - * @param check_user_id 当前审核人ID - */ + * @param check_user_id 当前审核人ID + */ public function nextStepUser($user_id, $flow_id, $types, $types_id, $order_id, $check_user_id) { $res = nextCheckData($user_id, $flow_id, $types, $types_id, $order_id, $check_user_id); - return $res ? : []; + return $res ?: []; } - /** + /** * 审批步骤权限 - * @param step_id 审批步骤ID - * @param user_id 审批人ID(当前登录人) - * @param create_user_id 申请人ID - * @param types 关联对象 - * @param types_id 联对象ID - * @param status 1负责人主管,2指定用户(任意一人),3指定用户(多人会签),4上一级审批人主管 - * @return - */ + * @param step_id 审批步骤ID + * @param user_id 审批人ID(当前登录人) + * @param create_user_id 申请人ID + * @param types 关联对象 + * @param types_id 联对象ID + * @param status 1负责人主管,2指定用户(任意一人),3指定用户(多人会签),4上一级审批人主管 + * @return + */ public function checkExamine($user_id, $types, $types_id) { $data = $this->getDataByTypes($types, $types_id); @@ -134,19 +134,19 @@ class ExamineStep extends Common $stepInfo = $data['stepInfo']; //审批步骤信息 if (!$dataInfo) { $this->error = '参数错误!'; - return false; + return false; } - if (in_array($dataInfo['check_status'], ['2','3'])) { + if (in_array($dataInfo['check_status'], ['2', '3'])) { $this->error = '审批已经结束!'; return false; - } + } if ($dataInfo['flow_id'] > 0) { //固定流程 //当前步骤已审批user_id $check_user_ids = $this->getUserByCheck($types, $types_id, $dataInfo['order_id']); if (in_array($user_id, $check_user_ids)) { $this->error = '您已审核,请勿重复操作!'; - return false; + return false; } $examine_user_id_arr = array(); // $examine_user_id_arr = $this->getUserByStep($stepInfo['step_id'], $dataInfo['create_user_id']); //获取审批步骤审批人 @@ -155,61 +155,93 @@ class ExamineStep extends Common } else { $examine_user_id_arr = $this->getUserByPer($types); } - if (!in_array($user_id, $examine_user_id_arr)) { - $this->error = '没有权限'; - return false; - } + if (!in_array($user_id, $examine_user_id_arr)) { + $this->error = '没有权限'; + return false; + } return true; } - /** + /** * 审批对象获取审批相关信息 - * @param types 关联对象 - * @param types_id 联对象ID - * @return - */ + * @param types 关联对象 + * @param types_id 联对象ID + * @return + */ public function getDataByTypes($types, $types_id) { - if (empty($types) || empty($types_id)) { - $this->error = '参数错误'; - return false; - } + if (empty($types) || empty($types_id)) { + $this->error = '参数错误'; + return false; + } - switch (trim($types)) { - case 'oa_examine' : $dataInfo = db('oa_examine')->where(['examine_id' => intval($types_id)])->field('create_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); break; - case 'crm_contract' : $dataInfo = db('crm_contract')->where(['contract_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); break; - case 'crm_receivables' : $dataInfo = db('crm_receivables')->where(['receivables_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); break; - case 'crm_invoice': $dataInfo = db('crm_invoice')->where(['invoice_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); break; - case 'jxc_purchase': $dataInfo = db('jxc_purchase')->where(['purchase_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); break; - case 'jxc_retreat': $dataInfo = db('jxc_retreat')->where(['retreat_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); break; - case 'jxc_sale': $dataInfo = db('jxc_sale')->where(['sale_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); break; - case 'jxc_salereturn': $dataInfo = db('jxc_salereturn')->where(['salereturn_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); break; - case 'jxc_payment': $dataInfo = db('jxc_payment')->where(['payment_note_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); break; - case 'jxc_collection': $dataInfo = db('jxc_collection')->where(['collection_note_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); break; - case 'jxc_inventory': $dataInfo = db('jxc_inventory')->where(['inventory_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); break; - case 'jxc_allocation': $dataInfo = db('jxc_allocation')->where(['allocation_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); break; - case 'crm_customer_check': $dataInfo = db('crm_customer_check')->where(['customer_check_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); break; - case 'crm_business': $dataInfo = db('crm_business')->where(['business_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); break; + switch (trim($types)) { + case 'oa_examine' : + $dataInfo = db('oa_examine')->where(['examine_id' => intval($types_id)])->field('create_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); + break; + case 'crm_contract' : + $dataInfo = db('crm_contract')->where(['contract_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); + break; + case 'crm_receivables' : + $dataInfo = db('crm_receivables')->where(['receivables_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); + break; + case 'crm_invoice': + $dataInfo = db('crm_invoice')->where(['invoice_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); + break; + case 'jxc_purchase': + $dataInfo = db('jxc_purchase')->where(['purchase_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); + break; + case 'jxc_retreat': + $dataInfo = db('jxc_retreat')->where(['retreat_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); + break; + case 'jxc_sale': + $dataInfo = db('jxc_sale')->where(['sale_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); + break; + case 'jxc_salereturn': + $dataInfo = db('jxc_salereturn')->where(['salereturn_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); + break; + case 'jxc_payment': + $dataInfo = db('jxc_payment')->where(['payment_note_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); + break; + case 'jxc_collection': + $dataInfo = db('jxc_collection')->where(['collection_note_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); + break; + case 'jxc_inventory': + $dataInfo = db('jxc_inventory')->where(['inventory_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); + break; + case 'jxc_allocation': + $dataInfo = db('jxc_allocation')->where(['allocation_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); + break; + case 'crm_customer_check': + $dataInfo = db('crm_customer_check')->where(['customer_check_id' => intval($types_id)])->field('user_id,create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); + break; + case 'crm_business': + $dataInfo = db('crm_business')->where(['business_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); + break; } $stepInfo = []; - if ($dataInfo['flow_id'] && !in_array($dataInfo['check_status'],['5'])) { + if ($dataInfo['flow_id'] && !in_array($dataInfo['check_status'], ['5'])) { //固定审批流 - $stepInfo = db('admin_examine_step')->where(['flow_id' => $dataInfo['flow_id'],'order_id' => $dataInfo['order_id']])->find(); + $stepInfo = db('admin_examine_step')->where(['flow_id' => $dataInfo['flow_id'], 'order_id' => $dataInfo['order_id']])->find(); + } + if ($types=="crm_customer_check"){ + $dataInfo['create_user_id']=$dataInfo['user_id']; + $dataInfo['owner_user_id']=$dataInfo['user_id']; } - $data = []; - $data['stepInfo'] = $stepInfo; - $data['step_id'] = $stepInfo['step_id'] ? : ''; - $data['dataInfo'] = $dataInfo; - return $data; - } + $data = []; + $data['stepInfo'] = $stepInfo; + $data['step_id'] = $stepInfo['step_id'] ?: ''; + $data['dataInfo'] = $dataInfo; + return $data; + } /** * 获取审批步骤审批人信息 - * @param step_id 审批步骤ID - * @param status 1负责人主管,2指定用户(任意一人),3指定用户(多人会签),4上一级审批人主管 - * @param user_id 审批主体,申请人user_id + * @param step_id 审批步骤ID + * @param status 1负责人主管,2指定用户(任意一人),3指定用户(多人会签),4上一级审批人主管 + * @param user_id 审批主体,申请人user_id * @return - */ + */ public function getUserByStep($step_id, $user_id) { $stepInfo = db('admin_examine_step')->where(['step_id' => $step_id])->find(); @@ -224,11 +256,13 @@ class ExamineStep extends Common $examine_user_id_arr[] = 1; } break; - case 2 : - case 3 :$examine_user_id_arr = stringToArray($stepInfo['user_id']); break; - case 4 : - $order_id = $stepInfo['order_id'] ? $stepInfo['order_id']-1 : 0; - $last_step_id = db('admin_examine_step')->where(['flow_id' => $stepInfo['flow_id'],'order_id' => $order_id])->value('step_id'); + case 2 : + case 3 : + $examine_user_id_arr = stringToArray($stepInfo['user_id']); + break; + case 4 : + $order_id = $stepInfo['order_id'] ? $stepInfo['order_id'] - 1 : 0; + $last_step_id = db('admin_examine_step')->where(['flow_id' => $stepInfo['flow_id'], 'order_id' => $order_id])->value('step_id'); $last_step_info = db('admin_examine_step')->where(['step_id' => $last_step_id])->find(); $last_user_id = $this->getUserByStep($last_step_id, $user_id); if (count(stringToArray($last_user_id)) !== 1) { @@ -241,17 +275,18 @@ class ExamineStep extends Common $examine_user_id_arr = []; if ($examine_user_id) { $examine_user_id_arr = stringToArray($examine_user_id); - } + } break; - default : $examine_user_id_arr = []; + default : + $examine_user_id_arr = []; } - return array_unique($examine_user_id_arr) ? ','.implode(',',array_filter(array_unique($examine_user_id_arr))).',' : ''; - } + return array_unique($examine_user_id_arr) ? ',' . implode(',', array_filter(array_unique($examine_user_id_arr))) . ',' : ''; + } /** * 获取当前步骤已审批的user_id - * @param step_id 审批步骤ID - * @param status 1审核通过0审核失败2撤销 + * @param step_id 审批步骤ID + * @param status 1审核通过0审核失败2撤销 * @return */ public function getUserByCheck($types, $types_id = 0, $order_id = 0, $status = 1) @@ -259,20 +294,20 @@ class ExamineStep extends Common if ($types_id == 0 && $order_id == 0) { $check_user_ids = []; } else { - $check_user_ids = db('admin_examine_record')->where(['types' => $types,'types_id' => $types_id,'order_id' => $order_id,'is_end' => 0,'status' => $status])->column('check_user_id'); + $check_user_ids = db('admin_examine_record')->where(['types' => $types, 'types_id' => $types_id, 'order_id' => $order_id, 'is_end' => 0, 'status' => $status])->column('check_user_id'); } - return $check_user_ids ? : []; - } + return $check_user_ids ?: []; + } /** * 获取授权审批的user_id - * @param step_id 审批步骤ID - * @param + * @param step_id 审批步骤ID + * @param * @return - */ + */ public function getUserByPer($types) { - if (!in_array($types,['oa_examine','crm_contract','crm_receivables'])) { + if (!in_array($types, ['oa_examine', 'crm_contract', 'crm_receivables'])) { $this->error = '参数错误'; return false; } @@ -280,43 +315,51 @@ class ExamineStep extends Common $adminUserId = model('User')->getAdminId(); //管理员ID //获取有审核权限的user_id switch ($types) { - case 'oa_examine' : $examine_user_id_arr = $userModel->getUserByPer('oa', 'examine', 'check'); break; - case 'crm_contract' : $examine_user_id_arr = $userModel->getUserByPer('crm', 'contract', 'check'); break; - case 'crm_receivables' : $examine_user_id_arr = $userModel->getUserByPer('crm', 'receivables', 'check'); break; - case 'crm_invoice' : $examine_user_id_arr = $userModel->getUserByPer('crm', 'invoice', 'check'); break; + case 'oa_examine' : + $examine_user_id_arr = $userModel->getUserByPer('oa', 'examine', 'check'); + break; + case 'crm_contract' : + $examine_user_id_arr = $userModel->getUserByPer('crm', 'contract', 'check'); + break; + case 'crm_receivables' : + $examine_user_id_arr = $userModel->getUserByPer('crm', 'receivables', 'check'); + break; + case 'crm_invoice' : + $examine_user_id_arr = $userModel->getUserByPer('crm', 'invoice', 'check'); + break; } $examine_user_id_arr = $examine_user_id_arr ? array_merge($examine_user_id_arr, $adminUserId) : $adminUserId; return $examine_user_id_arr; - } + } /** * 获取审批步骤相关userId - * @param flow_id 流程ID - * @param order_id 排序ID + * @param flow_id 流程ID + * @param order_id 排序ID * @return */ public function getStepUserByOrder($flow_id, $order_id, $user_id) { $user_ids = []; if ($flow_id && $order_id) { - $stepInfo = db('admin_examine_step')->where(['flow_id' => $flow_id,'order_id' => $order_id])->find(); + $stepInfo = db('admin_examine_step')->where(['flow_id' => $flow_id, 'order_id' => $order_id])->find(); $user_ids = $this->getUserByStep($stepInfo['step_id'], $user_id); } - return $user_ids ? : []; + return $user_ids ?: []; } /** * 获取有效审批步骤列表(固定审批) - * @param flow_id 审批流程ID - * @param user_id 审批申请人ID - * @param check_user_id 当前操作人ID + * @param flow_id 审批流程ID + * @param user_id 审批申请人ID + * @param check_user_id 当前操作人ID * @return - */ + */ public function getStepList($flow_id, $user_id, $types, $types_id = 0, $check_user_id = 0, $action = '', $category_id = '') { $userModel = new \app\admin\model\User(); $newlist = []; - + $dataInfo['order_id'] = 0; if ($types_id) { $typesInfo = $this->getDataByTypes($types, $types_id); @@ -330,11 +373,11 @@ class ExamineStep extends Common //创建人或负责人或管理员有撤销权限 //if ($dataInfo['create_user_id'] == $check_user_id || $dataInfo['owner_user_id'] == $check_user_id || in_array($check_user_id, $admin_user_ids)) { if ($dataInfo['create_user_id'] == $check_user_id || $dataInfo['owner_user_id'] == $check_user_id) { - if (!in_array($dataInfo['check_status'],['2','3','4','6'])) { + if (!in_array($dataInfo['check_status'], ['2', '3', '4', '6'])) { $is_recheck = 1; } } - if (in_array($check_user_id, stringToArray($dataInfo['check_user_id'])) && !in_array($dataInfo['check_status'],['2','3','4','6'])) { + if (in_array($check_user_id, stringToArray($dataInfo['check_user_id'])) && !in_array($dataInfo['check_status'], ['2', '3', '4', '6'])) { $is_check = 1; } @@ -342,7 +385,7 @@ class ExamineStep extends Common $createUserInfo = $userModel->getUserById($dataInfo['create_user_id']); $createUserInfo['check_time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null; - if ($dataInfo['check_status'] == 4 && $dataInfo['create_user_id']!=trim( $dataInfo['check_status'], ',')) { + if ($dataInfo['check_status'] == 4 && $dataInfo['create_user_id'] != trim($dataInfo['check_status'], ',')) { $createUserInfo['check_type'] = 2; $newlist[1]['type'] = '2'; //撤销 $newlist[1]['status'] = '5'; //创建,前端要求给创建人加一个status字段,定义为5 @@ -353,7 +396,7 @@ class ExamineStep extends Common $newlist[0]['time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null; $newlist[1]['user_id_info'] = array($createUserInfo); $newlist[1]['time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null; - } elseif ($dataInfo['check_status'] == 4 && $dataInfo['create_user_id']==trim( $dataInfo['check_status'], ',')){ + } elseif ($dataInfo['check_status'] == 4 && $dataInfo['create_user_id'] == trim($dataInfo['check_status'], ',')) { $createUserInfo['check_type'] = 3; $newlist[0]['type'] = '3'; //创建 $newlist[0]['status'] = '5'; //创建,前端要求给创建人加一个status字段,定义为5 @@ -376,7 +419,7 @@ class ExamineStep extends Common if ($dataInfo['check_status'] !== 4 || $action !== 'view') { $list = db('admin_examine_step')->where(['flow_id' => $flow_id])->order('order_id asc')->select(); $is_break = false; - foreach ($list as $k=>$v) { + foreach ($list as $k => $v) { $type = 4; $examine_user_ids = ''; //判断步骤审批人是否存在 @@ -385,7 +428,7 @@ class ExamineStep extends Common if ($examine_user_arr) { $newStepInfo = $v; $user_id_info_arr = []; - foreach ($examine_user_arr as $key=>$val) { + foreach ($examine_user_arr as $key => $val) { $user_id_info = []; $user_id_info = $userModel->getUserById($val); $check_type = 4; //type 0失败,1通过,2撤销,3创建,4待审核,5未提交 @@ -396,7 +439,7 @@ class ExamineStep extends Common $check_type = 1; $type = !empty($dataInfo['check_user_id']) ? 4 : 1; } - if(in_array($val, $check_user_ids) && $dataInfo['check_status'] == 2){ + if (in_array($val, $check_user_ids) && $dataInfo['check_status'] == 2) { $check_type = 1; $type = 1; } @@ -410,7 +453,7 @@ class ExamineStep extends Common } $fail_check_user_ids = $this->getUserByCheck($types, $types_id, $v['order_id'], 0); //拒绝人员 if ($dataInfo['check_status'] == 3) { - if (in_array($val,$fail_check_user_ids)) { + if (in_array($val, $fail_check_user_ids)) { $is_break = true; $check_type = 0; $type = 0; @@ -419,7 +462,7 @@ class ExamineStep extends Common } $user_id_info['check_type'] = $check_type; $check_time = ''; - $check_time = db('admin_examine_record')->where(['types' => $types,'types_id' => $types_id,'flow_id' => $flow_id,'order_id' => $v['order_id'],'check_user_id' => $val,'is_end' =>0])->value('check_time'); + $check_time = db('admin_examine_record')->where(['types' => $types, 'types_id' => $types_id, 'flow_id' => $flow_id, 'order_id' => $v['order_id'], 'check_user_id' => $val, 'is_end' => 0])->value('check_time'); $user_id_info['check_time'] = !empty($check_time) ? date('Y-m-d H:i:s', $check_time) : ''; $user_id_info_arr[] = $user_id_info; } @@ -429,10 +472,10 @@ class ExamineStep extends Common $type = 1; } //if ($is_break !== false) break; - $newStepInfo['type'] = $type; + $newStepInfo['type'] = $type; $stepList[] = $newStepInfo; } - } + } } $newStepList = []; if ($newlist && $stepList) { @@ -442,31 +485,31 @@ class ExamineStep extends Common } else { $newStepList = $newlist; } - $data['steplist'] = $newStepList ? : []; + $data['steplist'] = $newStepList ?: []; $data['is_check'] = $is_check; $data['is_recheck'] = $is_recheck; - return $data ? : []; + return $data ?: []; } /** * 根据order_id获取审批步骤 - * @param flow_id 审批流程ID - * @param order_id 审批排序ID + * @param flow_id 审批流程ID + * @param order_id 审批排序ID * @return - */ + */ public function getStepByOrder($flow_id, $order_id) { - $data = db('admin_examine_step')->where(['flow_id' => $flow_id,'order_id' => $order_id])->find(); - return $data ? : []; - } + $data = db('admin_examine_step')->where(['flow_id' => $flow_id, 'order_id' => $order_id])->find(); + return $data ?: []; + } /** * 获取有效审批步骤列表(自选审批) - * @param types 类型 - * @param types_id 类型ID - * @param action 操作类型: view、save + * @param types 类型 + * @param types_id 类型ID + * @param action 操作类型: view、save * @return - */ + */ public function getPerStepList($types, $types_id, $user_id, $check_user_id, $action = '') { $examineRecordModel = new \app\admin\model\ExamineRecord(); @@ -482,13 +525,13 @@ class ExamineStep extends Common $dataInfo = $typeInfo['dataInfo']; //type 0失败,1通过,2撤销,3创建,4待审核,5未提交 $i = 0; - if(empty($recordList)){ + if (empty($recordList)) { $createUserInfo = $userModel->getUserById($dataInfo['create_user_id']); $userList[0]['userInfo'] = $createUserInfo; $userList[0]['type'] = 3; //创建 - $userList[0]['time'] = $dataInfo['update_time'] ? : ''; - }else{ - foreach ($recordList as $k=>$v) { + $userList[0]['time'] = $dataInfo['update_time'] ?: ''; + } else { + foreach ($recordList as $k => $v) { $userList[$i]['userInfo'] = $userModel->getUserById($v['check_user_id']); $userList[$i]['type'] = $v['status']; $userList[$i]['time'] = $v['check_time']; @@ -505,7 +548,7 @@ class ExamineStep extends Common $check_user_id_arr = stringToArray($dataInfo['check_user_id']); $userList[0]['userInfo'] = $userModel->getUserById($check_user_id_arr[0]); $userList[0]['type'] = '5'; - } + } $is_check = 0; //审批权限(1有) $is_recheck = 0; //撤销审批权限(1有) @@ -513,17 +556,17 @@ class ExamineStep extends Common //创建人或负责人或管理员有撤销权限 // if ($dataInfo['create_user_id'] == $check_user_id || $dataInfo['owner_user_id'] == $check_user_id || in_array($check_user_id, $admin_user_ids)) { if ($dataInfo['create_user_id'] == $check_user_id || $dataInfo['owner_user_id'] == $check_user_id) { - if (!in_array($dataInfo['check_status'],['2','3','4','5','6'])) { + if (!in_array($dataInfo['check_status'], ['2', '3', '4', '5', '6'])) { $is_recheck = 1; } } - if (in_array($check_user_id, stringToArray($dataInfo['check_user_id'])) && !in_array($dataInfo['check_status'],['2','3','4','5','6'])) { + if (in_array($check_user_id, stringToArray($dataInfo['check_user_id'])) && !in_array($dataInfo['check_status'], ['2', '3', '4', '5', '6'])) { $is_check = 1; } $data['steplist'] = $userList; $data['is_check'] = $is_check; $data['is_recheck'] = $is_recheck; - return $data ? : []; - } + return $data ?: []; + } } \ No newline at end of file diff --git a/application/crm/controller/CustomerPool.php b/application/crm/controller/CustomerPool.php index ac95f7b..5c7cc48 100644 --- a/application/crm/controller/CustomerPool.php +++ b/application/crm/controller/CustomerPool.php @@ -424,11 +424,11 @@ class CustomerPool extends ApiCommon $customerCheckData['update_time'] = time(); $customerCheckData['check_status'] = 1; //0待审核,1审核通中,2审核通过,3审核未通过 //权限判断 - if (!$examineStepModel->checkExamine($user_id, 'crm_contract', $param['id'])) { + if (!$examineStepModel->checkExamine($user_id, 'crm_customer_check', $param['id'])) { return resultArray(['error' => $examineStepModel->getError()]); } //审批主体详情 - $dataInfo = db('crm_customer_check')->where('customer_check_id', 'in', $param['customer_check_id'])->find(); + $dataInfo = db('crm_customer_check')->where('customer_check_id', 'in', $param['id'])->find(); $flowInfo = $examineFlowModel->getDataById($dataInfo['flow_id']); $is_end = 0; // 1审批结束