From 04555d198c4c04704bcb50173832383cd10a46ba Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Sat, 18 Nov 2023 15:39:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AE=A1=E6=A0=B8=E7=BB=86?= =?UTF-8?q?=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/FinanceExpense.php | 97 ++++++++++++--------------- app/api/controller/FinanceInvoice.php | 96 ++++++++++++-------------- app/api/controller/OaApprove.php | 1 - app/finance/controller/Expense.php | 97 ++++++++++++--------------- app/finance/controller/Invoice.php | 96 ++++++++++++-------------- 5 files changed, 176 insertions(+), 211 deletions(-) diff --git a/app/api/controller/FinanceExpense.php b/app/api/controller/FinanceExpense.php index fe9acd8..9509d82 100644 --- a/app/api/controller/FinanceExpense.php +++ b/app/api/controller/FinanceExpense.php @@ -149,43 +149,34 @@ class FinanceExpense extends ApiController foreach($flow as $item) { // 当前部门负责人 if ($item['flow_type'] == 1) { - $manager_id = Db::name('department')->where('id', $this->did)->value('manager_id'); - if (empty($manager_id)) { + $manager = get_department_manager($this->uid); + if (empty($manager)) { $this->apiError('当前部门负责人不存在'); } } - // 上一级部门负责人 + // 上级部门负责人 if ($item['flow_type'] == 2) { - $pid = Db::name('department')->where('id', $this->did)->value('pid'); - if (empty($pid)) { - $this->apiError('上一级部门不存在'); - } - $manager_id = Db::name('department')->where('id', $pid)->value('manager_id'); - if (empty($manager_id)) { - $this->apiError('上一级部门负责人不存在'); + $manager = get_department_manager($this->uid, 1); + if (empty($manager)) { + $this->apiError('上级部门负责人不存在'); } } // 当前部门分管领导 if ($item['flow_type'] == 5) { - $leader_id = Db::name('department')->where('id', $this->did)->value('leader_id'); - if (empty($leader_id)) { + $leader = get_department_leader($this->uid); + if (empty($leader)) { $this->apiError('当前部门分管领导不存在'); } } - // 上一级部门分管领导 + // 上级部门分管领导 if ($item['flow_type'] == 6) { - $pid = Db::name('department')->where('id', $this->did)->value('pid'); - if (empty($pid)) { - $this->apiError('上一级部门不存在'); - } - $leader_id = Db::name('department')->where('id', $pid)->value('leader_id'); - if (empty($leader_id)) { - $this->apiError('上一级部门分管领导不存在'); + $leader = get_department_leader($this->uid, 1); + if (empty($leader)) { + $this->apiError('上级部门分管领导不存在'); } } } } - $dbRes = false; if (!empty($param['id']) && $param['id'] > 0) { try { @@ -201,24 +192,24 @@ class FinanceExpense extends ApiController Db::name('FlowRecord')->where(['action_id'=>$param['id'],'type'=>2,'delete_time'=>0])->update(['delete_time'=>time()]); if (!isset($param['check_admin_ids'])) { if($flow[0]['flow_type'] == 1){ - //部门负责人 - $leader = get_department_leader($this->uid); - if($leader == 0){ - $this->apiError('审批流程设置有问题:当前部门负责人还未设置,请联系HR或者管理员'); - } - else{ - $param['check_admin_ids'] = $leader; - } + // 部门负责人 + $manager = get_department_manager($this->uid); + $param['check_admin_ids'] = $manager; } else if($flow[0]['flow_type'] == 2){ - //上级部门负责人 - $leader = get_department_leader($this->uid,1); - if($leader == 0){ - $this->apiError('审批流程设置有问题:上级部门负责人还未设置,请联系HR或者管理员'); - } - else{ - $param['check_admin_ids'] = $leader; - } + // 上级部门负责人 + $manager = get_department_manager($this->uid, 1); + $param['check_admin_ids'] = $manager; + } + else if($flow[0]['flow_type'] == 5){ + // 部门分管领导 + $leader = get_department_leader($this->uid); + $param['check_admin_ids'] = $leader; + } + else if($flow[0]['flow_type'] == 6){ + // 上级部门分管领导 + $leader = get_department_leader($this->uid, 1); + $param['check_admin_ids'] = $leader; } else{ $param['check_admin_ids'] = $flow[0]['flow_uids']; @@ -311,24 +302,24 @@ class FinanceExpense extends ApiController try { if (!isset($param['check_admin_ids'])) { if($flow[0]['flow_type'] == 1){ - //部门负责人 - $leader = get_department_leader($this->uid); - if($leader == 0){ - return to_assign(1,'审批流程设置有问题:当前部门负责人还未设置,请联系HR或者管理员'); - } - else{ - $param['check_admin_ids'] = $leader; - } + // 部门负责人 + $manager = get_department_manager($this->uid); + $param['check_admin_ids'] = $manager; } else if($flow[0]['flow_type'] == 2){ - //上级部门负责人 - $leader = get_department_leader($this->uid,1); - if($leader == 0){ - return to_assign(1,'审批流程设置有问题:上级部门负责人还未设置,请联系HR或者管理员'); - } - else{ - $param['check_admin_ids'] = $leader; - } + // 上级部门负责人 + $manager = get_department_manager($this->uid, 1); + $param['check_admin_ids'] = $manager; + } + else if($flow[0]['flow_type'] == 5){ + // 部门分管领导 + $leader = get_department_leader($this->uid); + $param['check_admin_ids'] = $leader; + } + else if($flow[0]['flow_type'] == 6){ + // 上级部门分管领导 + $leader = get_department_leader($this->uid, 1); + $param['check_admin_ids'] = $leader; } else{ $param['check_admin_ids'] = $flow[0]['flow_uids']; diff --git a/app/api/controller/FinanceInvoice.php b/app/api/controller/FinanceInvoice.php index f0a6cb1..3a3812a 100644 --- a/app/api/controller/FinanceInvoice.php +++ b/app/api/controller/FinanceInvoice.php @@ -177,38 +177,30 @@ class FinanceInvoice extends ApiController foreach($flow as $item) { // 当前部门负责人 if ($item['flow_type'] == 1) { - $manager_id = Db::name('department')->where('id', $this->did)->value('manager_id'); - if (empty($manager_id)) { + $manager = get_department_manager($this->uid); + if (empty($manager)) { $this->apiError('当前部门负责人不存在'); } } - // 上一级部门负责人 + // 上级部门负责人 if ($item['flow_type'] == 2) { - $pid = Db::name('department')->where('id', $this->did)->value('pid'); - if (empty($pid)) { - $this->apiError('上一级部门不存在'); - } - $manager_id = Db::name('department')->where('id', $pid)->value('manager_id'); - if (empty($manager_id)) { - $this->apiError('上一级部门负责人不存在'); + $manager = get_department_manager($this->uid, 1); + if (empty($manager)) { + $this->apiError('上级部门负责人不存在'); } } // 当前部门分管领导 if ($item['flow_type'] == 5) { - $leader_id = Db::name('department')->where('id', $this->did)->value('leader_id'); - if (empty($leader_id)) { + $leader = get_department_leader($this->uid); + if (empty($leader)) { $this->apiError('当前部门分管领导不存在'); } } - // 上一级部门分管领导 + // 上级部门分管领导 if ($item['flow_type'] == 6) { - $pid = Db::name('department')->where('id', $this->did)->value('pid'); - if (empty($pid)) { - $this->apiError('上一级部门不存在'); - } - $leader_id = Db::name('department')->where('id', $pid)->value('leader_id'); - if (empty($leader_id)) { - $this->apiError('上一级部门分管领导不存在'); + $leader = get_department_leader($this->uid, 1); + if (empty($leader)) { + $this->apiError('上级部门分管领导不存在'); } } } @@ -226,24 +218,24 @@ class FinanceInvoice extends ApiController Db::name('FlowRecord')->where(['action_id'=>$param['id'],'type'=>3,'delete_time'=>0])->update(['delete_time'=>time()]); if (!isset($param['check_admin_ids'])) { if($flow[0]['flow_type'] == 1){ - //部门负责人 - $leader = get_department_leader($this->uid); - if($leader == 0){ - $this->apiError("审批流程设置有问题:当前部门负责人还未设置,请联系HR或者管理员"); - } - else{ - $param['check_admin_ids'] = $leader; - } + // 部门负责人 + $manager = get_department_manager($this->uid); + $param['check_admin_ids'] = $manager; } else if($flow[0]['flow_type'] == 2){ - //上级部门负责人 - $leader = get_department_leader($this->uid,1); - if($leader == 0){ - $this->apiError('审批流程设置有问题:上级部门负责人还未设置,请联系HR或者管理员'); - } - else{ - $param['check_admin_ids'] = $leader; - } + // 上级部门负责人 + $manager = get_department_manager($this->uid, 1); + $param['check_admin_ids'] = $manager; + } + else if($flow[0]['flow_type'] == 5){ + // 部门分管领导 + $leader = get_department_leader($this->uid); + $param['check_admin_ids'] = $leader; + } + else if($flow[0]['flow_type'] == 6){ + // 上级部门分管领导 + $leader = get_department_leader($this->uid, 1); + $param['check_admin_ids'] = $leader; } else{ $param['check_admin_ids'] = $flow[0]['flow_uids']; @@ -305,24 +297,24 @@ class FinanceInvoice extends ApiController if (!isset($param['check_admin_ids'])) { if($flow[0]['flow_type'] == 1){ - //部门负责人 - $leader = get_department_leader($this->uid); - if($leader == 0){ - $this->apiError('审批流程设置有问题:当前部门负责人还未设置,请联系HR或者管理员'); - } - else{ - $param['check_admin_ids'] = $leader; - } + // 部门负责人 + $manager = get_department_manager($this->uid); + $param['check_admin_ids'] = $manager; } else if($flow[0]['flow_type'] == 2){ - //上级部门负责人 - $leader = get_department_leader($this->uid,1); - if($leader == 0){ - $this->apiError('审批流程设置有问题:上级部门负责人还未设置,请联系HR或者管理员'); - } - else{ - $param['check_admin_ids'] = $leader; - } + // 上级部门负责人 + $manager = get_department_manager($this->uid, 1); + $param['check_admin_ids'] = $manager; + } + else if($flow[0]['flow_type'] == 5){ + // 部门分管领导 + $leader = get_department_leader($this->uid); + $param['check_admin_ids'] = $leader; + } + else if($flow[0]['flow_type'] == 6){ + // 上级部门分管领导 + $leader = get_department_leader($this->uid, 1); + $param['check_admin_ids'] = $leader; } else{ $param['check_admin_ids'] = $flow[0]['flow_uids']; diff --git a/app/api/controller/OaApprove.php b/app/api/controller/OaApprove.php index 5159e6a..ae45e6d 100644 --- a/app/api/controller/OaApprove.php +++ b/app/api/controller/OaApprove.php @@ -147,7 +147,6 @@ class OaApprove extends ApiController } $flow_list = Db::name('Flow')->where('id',$param['flow_id'])->value('flow_list'); $flow = unserialize($flow_list); - if (!isset($param['check_admin_ids'])) { foreach($flow as $item) { // 当前部门负责人 diff --git a/app/finance/controller/Expense.php b/app/finance/controller/Expense.php index 0d04b4b..4b9aecb 100644 --- a/app/finance/controller/Expense.php +++ b/app/finance/controller/Expense.php @@ -156,43 +156,34 @@ class Expense extends BaseController foreach($flow as $item) { // 当前部门负责人 if ($item['flow_type'] == 1) { - $manager_id = Db::name('department')->where('id', $this->did)->value('manager_id'); - if (empty($manager_id)) { + $manager = get_department_manager($this->uid); + if (empty($manager)) { return to_assign(1,'当前部门负责人不存在'); } } - // 上一级部门负责人 + // 上级部门负责人 if ($item['flow_type'] == 2) { - $pid = Db::name('department')->where('id', $this->did)->value('pid'); - if (empty($pid)) { - return to_assign(1,'上一级部门不存在'); - } - $manager_id = Db::name('department')->where('id', $pid)->value('manager_id'); - if (empty($manager_id)) { - return to_assign(1,'上一级部门负责人不存在'); + $manager = get_department_manager($this->uid, 1); + if (empty($manager)) { + return to_assign(1,'上级部门负责人不存在'); } } // 当前部门分管领导 if ($item['flow_type'] == 5) { - $leader_id = Db::name('department')->where('id', $this->did)->value('leader_id'); - if (empty($leader_id)) { + $leader = get_department_leader($this->uid); + if (empty($leader)) { return to_assign(1,'当前部门分管领导不存在'); } } - // 上一级部门分管领导 + // 上级部门分管领导 if ($item['flow_type'] == 6) { - $pid = Db::name('department')->where('id', $this->did)->value('pid'); - if (empty($pid)) { - return to_assign(1,'上一级部门不存在'); - } - $leader_id = Db::name('department')->where('id', $pid)->value('leader_id'); - if (empty($leader_id)) { - return to_assign(1,'上一级部门分管领导不存在'); + $leader = get_department_leader($this->uid, 1); + if (empty($leader)) { + return to_assign(1,'上级部门分管领导不存在'); } } } } - $dbRes = false; if (!empty($param['id']) && $param['id'] > 0) { try { @@ -209,24 +200,24 @@ class Expense extends BaseController Db::name('FlowRecord')->where(['action_id'=>$param['id'],'type'=>2,'delete_time'=>0])->update(['delete_time'=>time()]); if (!isset($param['check_admin_ids'])) { if($flow[0]['flow_type'] == 1){ - //部门负责人 - $leader = get_department_leader($this->uid); - if($leader == 0){ - return to_assign(1,'审批流程设置有问题:当前部门负责人还未设置,请联系HR或者管理员'); - } - else{ - $param['check_admin_ids'] = $leader; - } + // 部门负责人 + $manager = get_department_manager($this->uid); + $param['check_admin_ids'] = $manager; } else if($flow[0]['flow_type'] == 2){ - //上级部门负责人 - $leader = get_department_leader($this->uid,1); - if($leader == 0){ - return to_assign(1,'审批流程设置有问题:上级部门负责人还未设置,请联系HR或者管理员'); - } - else{ - $param['check_admin_ids'] = $leader; - } + // 上级部门负责人 + $manager = get_department_manager($this->uid, 1); + $param['check_admin_ids'] = $manager; + } + else if($flow[0]['flow_type'] == 5){ + // 部门分管领导 + $leader = get_department_leader($this->uid); + $param['check_admin_ids'] = $leader; + } + else if($flow[0]['flow_type'] == 6){ + // 上级部门分管领导 + $leader = get_department_leader($this->uid, 1); + $param['check_admin_ids'] = $leader; } else{ $param['check_admin_ids'] = $flow[0]['flow_uids']; @@ -319,24 +310,24 @@ class Expense extends BaseController try { if (!isset($param['check_admin_ids'])) { if($flow[0]['flow_type'] == 1){ - //部门负责人 - $leader = get_department_leader($this->uid); - if($leader == 0){ - return to_assign(1,'审批流程设置有问题:当前部门负责人还未设置,请联系HR或者管理员'); - } - else{ - $param['check_admin_ids'] = $leader; - } + // 部门负责人 + $manager = get_department_manager($this->uid); + $param['check_admin_ids'] = $manager; } else if($flow[0]['flow_type'] == 2){ - //上级部门负责人 - $leader = get_department_leader($this->uid,1); - if($leader == 0){ - return to_assign(1,'审批流程设置有问题:上级部门负责人还未设置,请联系HR或者管理员'); - } - else{ - $param['check_admin_ids'] = $leader; - } + // 上级部门负责人 + $manager = get_department_manager($this->uid, 1); + $param['check_admin_ids'] = $manager; + } + else if($flow[0]['flow_type'] == 5){ + // 部门分管领导 + $leader = get_department_leader($this->uid); + $param['check_admin_ids'] = $leader; + } + else if($flow[0]['flow_type'] == 6){ + // 上级部门分管领导 + $leader = get_department_leader($this->uid, 1); + $param['check_admin_ids'] = $leader; } else{ $param['check_admin_ids'] = $flow[0]['flow_uids']; diff --git a/app/finance/controller/Invoice.php b/app/finance/controller/Invoice.php index a11fb3c..d114070 100644 --- a/app/finance/controller/Invoice.php +++ b/app/finance/controller/Invoice.php @@ -156,38 +156,30 @@ class Invoice extends BaseController foreach($flow as $item) { // 当前部门负责人 if ($item['flow_type'] == 1) { - $manager_id = Db::name('department')->where('id', $this->did)->value('manager_id'); - if (empty($manager_id)) { + $manager = get_department_manager($this->uid); + if (empty($manager)) { return to_assign(1,'当前部门负责人不存在'); } } - // 上一级部门负责人 + // 上级部门负责人 if ($item['flow_type'] == 2) { - $pid = Db::name('department')->where('id', $this->did)->value('pid'); - if (empty($pid)) { - return to_assign(1,'上一级部门不存在'); - } - $manager_id = Db::name('department')->where('id', $pid)->value('manager_id'); - if (empty($manager_id)) { - return to_assign(1,'上一级部门负责人不存在'); + $manager = get_department_manager($this->uid, 1); + if (empty($manager)) { + return to_assign(1,'上级部门负责人不存在'); } } // 当前部门分管领导 if ($item['flow_type'] == 5) { - $leader_id = Db::name('department')->where('id', $this->did)->value('leader_id'); - if (empty($leader_id)) { + $leader = get_department_leader($this->uid); + if (empty($leader)) { return to_assign(1,'当前部门分管领导不存在'); } } - // 上一级部门分管领导 + // 上级部门分管领导 if ($item['flow_type'] == 6) { - $pid = Db::name('department')->where('id', $this->did)->value('pid'); - if (empty($pid)) { - return to_assign(1,'上一级部门不存在'); - } - $leader_id = Db::name('department')->where('id', $pid)->value('leader_id'); - if (empty($leader_id)) { - return to_assign(1,'上一级部门分管领导不存在'); + $leader = get_department_leader($this->uid, 1); + if (empty($leader)) { + return to_assign(1,'上级部门分管领导不存在'); } } } @@ -206,24 +198,24 @@ class Invoice extends BaseController Db::name('FlowRecord')->where(['action_id'=>$param['id'],'type'=>3,'delete_time'=>0])->update(['delete_time'=>time()]); if (!isset($param['check_admin_ids'])) { if($flow[0]['flow_type'] == 1){ - //部门负责人 - $leader = get_department_leader($this->uid); - if($leader == 0){ - return to_assign(1,'审批流程设置有问题:当前部门负责人还未设置,请联系HR或者管理员'); - } - else{ - $param['check_admin_ids'] = $leader; - } + // 部门负责人 + $manager = get_department_manager($this->uid); + $param['check_admin_ids'] = $manager; } else if($flow[0]['flow_type'] == 2){ - //上级部门负责人 - $leader = get_department_leader($this->uid,1); - if($leader == 0){ - return to_assign(1,'审批流程设置有问题:上级部门负责人还未设置,请联系HR或者管理员'); - } - else{ - $param['check_admin_ids'] = $leader; - } + // 上级部门负责人 + $manager = get_department_manager($this->uid, 1); + $param['check_admin_ids'] = $manager; + } + else if($flow[0]['flow_type'] == 5){ + // 部门分管领导 + $leader = get_department_leader($this->uid); + $param['check_admin_ids'] = $leader; + } + else if($flow[0]['flow_type'] == 6){ + // 上级部门分管领导 + $leader = get_department_leader($this->uid, 1); + $param['check_admin_ids'] = $leader; } else{ $param['check_admin_ids'] = $flow[0]['flow_uids']; @@ -286,24 +278,24 @@ class Invoice extends BaseController if (!isset($param['check_admin_ids'])) { if($flow[0]['flow_type'] == 1){ - //部门负责人 - $leader = get_department_leader($this->uid); - if($leader == 0){ - return to_assign(1,'审批流程设置有问题:当前部门负责人还未设置,请联系HR或者管理员'); - } - else{ - $param['check_admin_ids'] = $leader; - } + // 部门负责人 + $manager = get_department_manager($this->uid); + $param['check_admin_ids'] = $manager; } else if($flow[0]['flow_type'] == 2){ - //上级部门负责人 - $leader = get_department_leader($this->uid,1); - if($leader == 0){ - return to_assign(1,'审批流程设置有问题:上级部门负责人还未设置,请联系HR或者管理员'); - } - else{ - $param['check_admin_ids'] = $leader; - } + // 上级部门负责人 + $manager = get_department_manager($this->uid, 1); + $param['check_admin_ids'] = $manager; + } + else if($flow[0]['flow_type'] == 5){ + // 部门分管领导 + $leader = get_department_leader($this->uid); + $param['check_admin_ids'] = $leader; + } + else if($flow[0]['flow_type'] == 6){ + // 上级部门分管领导 + $leader = get_department_leader($this->uid, 1); + $param['check_admin_ids'] = $leader; } else{ $param['check_admin_ids'] = $flow[0]['flow_uids'];