From 37b79f5e2aa5568b9ea7fa252ff97cad43a06964 Mon Sep 17 00:00:00 2001 From: weiz <736250432@qq.com> Date: Sun, 4 Feb 2024 09:38:40 +0800 Subject: [PATCH] update approve --- .../MaterialPurchaseRequestController.php | 2 +- .../ProjectExpenseReimbursementController.php | 2 +- .../project/ProjectLoanApplyController.php | 2 +- .../ProjectTravelReimbursementController.php | 2 +- .../project/ProjectTripApplyController.php | 2 +- .../material/MaterialPurchaseRequestLogic.php | 15 ++++++++++++--- .../logic/project/ProjectCostAdjustmentLogic.php | 12 +++++++++++- .../project/ProjectExpenseReimbursementLogic.php | 12 +++++++++++- .../logic/project/ProjectLoanApplyLogic.php | 14 ++++++++++++-- .../project/ProjectTravelReimbursementLogic.php | 12 +++++++++++- .../logic/project/ProjectTripApplyLogic.php | 14 ++++++++++++-- .../material/MaterialPurchaseRequestValidate.php | 4 +++- .../project/ProjectCostAdjustmentValidate.php | 2 ++ .../ProjectExpenseReimbursementValidate.php | 2 ++ .../validate/project/ProjectLoanApplyValidate.php | 2 ++ .../ProjectTravelReimbursementValidate.php | 2 ++ .../validate/project/ProjectTripApplyValidate.php | 4 +++- 17 files changed, 88 insertions(+), 17 deletions(-) diff --git a/app/adminapi/controller/material/MaterialPurchaseRequestController.php b/app/adminapi/controller/material/MaterialPurchaseRequestController.php index d8387997e..e64ade504 100644 --- a/app/adminapi/controller/material/MaterialPurchaseRequestController.php +++ b/app/adminapi/controller/material/MaterialPurchaseRequestController.php @@ -52,7 +52,7 @@ class MaterialPurchaseRequestController extends BaseAdminController public function add() { $params = (new MaterialPurchaseRequestValidate())->post()->goCheck('add'); - $result = MaterialPurchaseRequestLogic::add($params); + $result = MaterialPurchaseRequestLogic::add($params,$this->adminId); if (true === $result) { return $this->success('添加成功', [], 1, 1); } diff --git a/app/adminapi/controller/project/ProjectExpenseReimbursementController.php b/app/adminapi/controller/project/ProjectExpenseReimbursementController.php index c5fe4d8be..8c5661836 100644 --- a/app/adminapi/controller/project/ProjectExpenseReimbursementController.php +++ b/app/adminapi/controller/project/ProjectExpenseReimbursementController.php @@ -52,7 +52,7 @@ class ProjectExpenseReimbursementController extends BaseAdminController public function add() { $params = (new ProjectExpenseReimbursementValidate())->post()->goCheck('add'); - $result = ProjectExpenseReimbursementLogic::add($params); + $result = ProjectExpenseReimbursementLogic::add($params,$this->adminId); if (true === $result) { return $this->success('添加成功', [], 1, 1); } diff --git a/app/adminapi/controller/project/ProjectLoanApplyController.php b/app/adminapi/controller/project/ProjectLoanApplyController.php index 74fcc8e5d..d97992255 100644 --- a/app/adminapi/controller/project/ProjectLoanApplyController.php +++ b/app/adminapi/controller/project/ProjectLoanApplyController.php @@ -52,7 +52,7 @@ class ProjectLoanApplyController extends BaseAdminController public function add() { $params = (new ProjectLoanApplyValidate())->post()->goCheck('add'); - $result = ProjectLoanApplyLogic::add($params); + $result = ProjectLoanApplyLogic::add($params,$this->adminId); if (true === $result) { return $this->success('添加成功', [], 1, 1); } diff --git a/app/adminapi/controller/project/ProjectTravelReimbursementController.php b/app/adminapi/controller/project/ProjectTravelReimbursementController.php index f6737b56a..623482d27 100644 --- a/app/adminapi/controller/project/ProjectTravelReimbursementController.php +++ b/app/adminapi/controller/project/ProjectTravelReimbursementController.php @@ -52,7 +52,7 @@ class ProjectTravelReimbursementController extends BaseAdminController public function add() { $params = (new ProjectTravelReimbursementValidate())->post()->goCheck('add'); - $result = ProjectTravelReimbursementLogic::add($params); + $result = ProjectTravelReimbursementLogic::add($params,$this->adminId); if (true === $result) { return $this->success('添加成功', [], 1, 1); } diff --git a/app/adminapi/controller/project/ProjectTripApplyController.php b/app/adminapi/controller/project/ProjectTripApplyController.php index abb5672f1..4c1480a8d 100644 --- a/app/adminapi/controller/project/ProjectTripApplyController.php +++ b/app/adminapi/controller/project/ProjectTripApplyController.php @@ -52,7 +52,7 @@ class ProjectTripApplyController extends BaseAdminController public function add() { $params = (new ProjectTripApplyValidate())->post()->goCheck('add'); - $result = ProjectTripApplyLogic::add($params); + $result = ProjectTripApplyLogic::add($params,$this->adminId); if (true === $result) { return $this->success('添加成功', [], 1, 1); } diff --git a/app/adminapi/logic/material/MaterialPurchaseRequestLogic.php b/app/adminapi/logic/material/MaterialPurchaseRequestLogic.php index eed519eb3..406fba403 100644 --- a/app/adminapi/logic/material/MaterialPurchaseRequestLogic.php +++ b/app/adminapi/logic/material/MaterialPurchaseRequestLogic.php @@ -41,9 +41,8 @@ class MaterialPurchaseRequestLogic extends BaseLogic * @author likeadmin * @date 2024/01/09 13:47 */ - public static function add(array $params): bool + public static function add(array $params,$admin_id): bool { - $detail =$params['purchase_request_detail'];// json_decode($params['purchase_request_detail'],true); Db::startTrans(); try { $MaterialPurchaseRequestRes = MaterialPurchaseRequest::create([ @@ -56,7 +55,7 @@ class MaterialPurchaseRequestLogic extends BaseLogic 'remark' => $params['remark'] ?? '', 'annex' => $params['annex']? json_encode($params['annex']) : null, ]); - foreach ($detail as $item) + foreach ($params['purchase_request_detail'] as $item) { MaterialPurchaseRequestDetail::create([ 'project_material_budget_detail_id' => $item['project_material_budget_detail_id'], @@ -72,6 +71,16 @@ class MaterialPurchaseRequestLogic extends BaseLogic ProjectMaterialBudgetDetail::where('id',$item['project_material_budget_detail_id'])->update(['is_residual'=>1,'update_time'=>time()]); } } + //添加审批信息 + addApprove( + '采购申请', + $MaterialPurchaseRequestRes->id, + 'app\common\model\material\MaterialPurchaseRequest', + 'app\adminapi\logic\material\MaterialPurchaseRequestLogic', + $params['approve_detail']['flow_type'], + $params['approve_detail']['flow_path'], + $admin_id + ); Db::commit(); return true; } catch (\Exception $e) { diff --git a/app/adminapi/logic/project/ProjectCostAdjustmentLogic.php b/app/adminapi/logic/project/ProjectCostAdjustmentLogic.php index fe159f416..867d4a19d 100644 --- a/app/adminapi/logic/project/ProjectCostAdjustmentLogic.php +++ b/app/adminapi/logic/project/ProjectCostAdjustmentLogic.php @@ -42,7 +42,7 @@ class ProjectCostAdjustmentLogic extends BaseLogic { Db::startTrans(); try { - ProjectCostAdjustment::create([ + $res = ProjectCostAdjustment::create([ 'project_id' => $params['project_id'], 'adjust_date' => strtotime($params['adjust_date']), 'adjust_amount' => $params['adjust_amount'], @@ -51,6 +51,16 @@ class ProjectCostAdjustmentLogic extends BaseLogic 'add_user' => $admin_id, 'update_user' => $admin_id, ]); + //添加审批信息 + addApprove( + '成本调整', + $res->id, + 'app\common\model\project\ProjectCostAdjustment', + 'app\adminapi\logic\project\ProjectCostAdjustmentLogic', + $params['approve_detail']['flow_type'], + $params['approve_detail']['flow_path'], + $admin_id + ); Db::commit(); return true; } catch (\Exception $e) { diff --git a/app/adminapi/logic/project/ProjectExpenseReimbursementLogic.php b/app/adminapi/logic/project/ProjectExpenseReimbursementLogic.php index 52694d582..5ba434b89 100644 --- a/app/adminapi/logic/project/ProjectExpenseReimbursementLogic.php +++ b/app/adminapi/logic/project/ProjectExpenseReimbursementLogic.php @@ -42,7 +42,7 @@ class ProjectExpenseReimbursementLogic extends BaseLogic * @author likeadmin * @date 2024/01/19 13:44 */ - public static function add(array $params): bool + public static function add(array $params,$admin_id): bool { //获取税率 $tax_rate = DictData::where('type_value','tax_rate')->column('name','value'); @@ -84,6 +84,16 @@ class ProjectExpenseReimbursementLogic extends BaseLogic 'remark' => $item['remark'] ?? '', ]); } + //添加审批信息 + addApprove( + '费用报销', + $res->id, + 'app\common\model\project\ProjectExpenseReimbursement', + 'app\adminapi\logic\project\ProjectExpenseReimbursementLogic', + $params['approve_detail']['flow_type'], + $params['approve_detail']['flow_path'], + $admin_id + ); Db::commit(); return true; } catch (\Exception $e) { diff --git a/app/adminapi/logic/project/ProjectLoanApplyLogic.php b/app/adminapi/logic/project/ProjectLoanApplyLogic.php index cdcf0c3fb..06b1ba007 100644 --- a/app/adminapi/logic/project/ProjectLoanApplyLogic.php +++ b/app/adminapi/logic/project/ProjectLoanApplyLogic.php @@ -38,11 +38,11 @@ class ProjectLoanApplyLogic extends BaseLogic * @author likeadmin * @date 2024/01/17 11:05 */ - public static function add(array $params): bool + public static function add(array $params,$admin_id): bool { Db::startTrans(); try { - ProjectLoanApply::create([ + $res = ProjectLoanApply::create([ 'loan_apply_code' => data_unique_code('项目借款'), 'project_id' => $params['project_id'], 'apply_user' => $params['apply_user'], @@ -55,6 +55,16 @@ class ProjectLoanApplyLogic extends BaseLogic 'annex' => $params['annex'] ? json_encode($params['annex']) : null, 'bank_account_id' => $params['bank_account_id'], ]); + //添加审批信息 + addApprove( + '借款申请', + $res->id, + 'app\common\model\project\ProjectLoanApply', + 'app\adminapi\logic\project\ProjectLoanApplyLogic', + $params['approve_detail']['flow_type'], + $params['approve_detail']['flow_path'], + $admin_id + ); Db::commit(); return true; } catch (\Exception $e) { diff --git a/app/adminapi/logic/project/ProjectTravelReimbursementLogic.php b/app/adminapi/logic/project/ProjectTravelReimbursementLogic.php index a829a8363..4d2174eeb 100644 --- a/app/adminapi/logic/project/ProjectTravelReimbursementLogic.php +++ b/app/adminapi/logic/project/ProjectTravelReimbursementLogic.php @@ -45,7 +45,7 @@ class ProjectTravelReimbursementLogic extends BaseLogic * @author likeadmin * @date 2024/01/18 13:57 */ - public static function add(array $params): bool + public static function add(array $params,$admin_id): bool { $trip_apply = ProjectTripApply::field('project_id')->where('id',$params['trip_apply_id'])->findOrEmpty(); //获取税率 @@ -94,6 +94,16 @@ class ProjectTravelReimbursementLogic extends BaseLogic 'remark' => $item['remark'] ?? '', ]); } + //添加审批信息 + addApprove( + '差旅报销', + $res->id, + 'app\common\model\project\ProjectTravelReimbursement', + 'app\adminapi\logic\project\ProjectTravelReimbursementLogic', + $params['approve_detail']['flow_type'], + $params['approve_detail']['flow_path'], + $admin_id + ); Db::commit(); return true; } catch (\Exception $e) { diff --git a/app/adminapi/logic/project/ProjectTripApplyLogic.php b/app/adminapi/logic/project/ProjectTripApplyLogic.php index 710365a3b..ab954ef7b 100644 --- a/app/adminapi/logic/project/ProjectTripApplyLogic.php +++ b/app/adminapi/logic/project/ProjectTripApplyLogic.php @@ -39,11 +39,11 @@ class ProjectTripApplyLogic extends BaseLogic * @author likeadmin * @date 2024/01/17 09:22 */ - public static function add(array $params): bool + public static function add(array $params,$admin_id): bool { Db::startTrans(); try { - ProjectTripApply::create([ + $res = ProjectTripApply::create([ 'project_id' => $params['project_id'], 'trip_apply_code' => data_unique_code('项目出差'), 'origin_address' => $params['origin_address'], @@ -56,6 +56,16 @@ class ProjectTripApplyLogic extends BaseLogic 'remark' => $params['remark'] ?? '', 'annex' => $params['annex'] ? json_encode($params['annex']) : null, ]); + //添加审批信息 + addApprove( + '出差申请', + $res->id, + 'app\common\model\project\ProjectTripApply', + 'app\adminapi\logic\project\ProjectTripApplyLogic', + $params['approve_detail']['flow_type'], + $params['approve_detail']['flow_path'], + $admin_id + ); Db::commit(); return true; } catch (\Exception $e) { diff --git a/app/adminapi/validate/material/MaterialPurchaseRequestValidate.php b/app/adminapi/validate/material/MaterialPurchaseRequestValidate.php index 608fef2d4..754169f91 100644 --- a/app/adminapi/validate/material/MaterialPurchaseRequestValidate.php +++ b/app/adminapi/validate/material/MaterialPurchaseRequestValidate.php @@ -43,7 +43,8 @@ class MaterialPurchaseRequestValidate extends BaseValidate 'apply_date' => 'require|dateFormat:Y-m-d', 'arrival_date' => 'require|dateFormat:Y-m-d', 'annex' => 'checkAnnex', - 'purchase_request_detail' => 'require|checkPurchaseRequestDetail' + 'purchase_request_detail' => 'require|checkPurchaseRequestDetail', + 'approve_detail' => 'require|checkApproveDetail', ]; protected $message = [ @@ -56,6 +57,7 @@ class MaterialPurchaseRequestValidate extends BaseValidate 'arrival_date.require' => '请选择希望到货日期', 'arrival_date.dateFormat' => '希望到货日期数据格式错误', 'purchase_request_detail.require' => '申购明细内容不能为空', + 'approve_detail.require' => '审批流程不能为空' ]; diff --git a/app/adminapi/validate/project/ProjectCostAdjustmentValidate.php b/app/adminapi/validate/project/ProjectCostAdjustmentValidate.php index 9591c9aea..7ac798b9e 100644 --- a/app/adminapi/validate/project/ProjectCostAdjustmentValidate.php +++ b/app/adminapi/validate/project/ProjectCostAdjustmentValidate.php @@ -37,6 +37,7 @@ class ProjectCostAdjustmentValidate extends BaseValidate 'adjust_date' => 'require|dateFormat:Y-m-d', 'adjust_amount' => 'require|float|gt:0', 'annex' => 'checkAnnex', + 'approve_detail' => 'require|checkApproveDetail', ]; @@ -49,6 +50,7 @@ class ProjectCostAdjustmentValidate extends BaseValidate 'project_id' => '项目id', 'adjust_date' => '调整日期', 'adjust_amount' => '调整金额', + 'approve_detail' => '审批流程' ]; diff --git a/app/adminapi/validate/project/ProjectExpenseReimbursementValidate.php b/app/adminapi/validate/project/ProjectExpenseReimbursementValidate.php index 57ce16a12..4fc05f3dc 100644 --- a/app/adminapi/validate/project/ProjectExpenseReimbursementValidate.php +++ b/app/adminapi/validate/project/ProjectExpenseReimbursementValidate.php @@ -52,6 +52,7 @@ class ProjectExpenseReimbursementValidate extends BaseValidate 'bank_account_id' => 'require|checkBankAccount', 'reimbursement_detail' => 'require|checkReimbursementDetail', 'invoice_detail' => 'require|checkInvoiceDetail', + 'approve_detail' => 'require|checkApproveDetail', ]; @@ -73,6 +74,7 @@ class ProjectExpenseReimbursementValidate extends BaseValidate 'bank_account_id' => '付款银行账户id', 'reimbursement_detail' => '报销明细', 'invoice_detail' => '发票明细', + 'approve_detail' => '审批流程' ]; diff --git a/app/adminapi/validate/project/ProjectLoanApplyValidate.php b/app/adminapi/validate/project/ProjectLoanApplyValidate.php index 26c22fb09..9b0f9bd62 100644 --- a/app/adminapi/validate/project/ProjectLoanApplyValidate.php +++ b/app/adminapi/validate/project/ProjectLoanApplyValidate.php @@ -43,6 +43,7 @@ class ProjectLoanApplyValidate extends BaseValidate 'payee_account' => 'require', 'annex' => 'checkAnnex', 'bank_account_id' => 'require|checkBankAccount', + 'approve_detail' => 'require|checkApproveDetail', ]; @@ -60,6 +61,7 @@ class ProjectLoanApplyValidate extends BaseValidate 'payee_bank' => '收款银行', 'payee_account' => '收款账号', 'bank_account_id' => '付款银行账户id', + 'approve_detail' => '审批流程' ]; diff --git a/app/adminapi/validate/project/ProjectTravelReimbursementValidate.php b/app/adminapi/validate/project/ProjectTravelReimbursementValidate.php index e7a9607fc..13a19b35e 100644 --- a/app/adminapi/validate/project/ProjectTravelReimbursementValidate.php +++ b/app/adminapi/validate/project/ProjectTravelReimbursementValidate.php @@ -52,6 +52,7 @@ class ProjectTravelReimbursementValidate extends BaseValidate 'bank_account_id' => 'require|checkBankAccount', 'reimbursement_detail' => 'require|checkReimbursementDetail', 'invoice_detail' => 'require|checkInvoiceDetail', + 'approve_detail' => 'require|checkApproveDetail', ]; @@ -73,6 +74,7 @@ class ProjectTravelReimbursementValidate extends BaseValidate 'bank_account_id' => '付款银行账户id', 'reimbursement_detail' => '报销明细', 'invoice_detail' => '发票明细', + 'approve_detail' => '审批流程' ]; diff --git a/app/adminapi/validate/project/ProjectTripApplyValidate.php b/app/adminapi/validate/project/ProjectTripApplyValidate.php index c537bdbef..ada306160 100644 --- a/app/adminapi/validate/project/ProjectTripApplyValidate.php +++ b/app/adminapi/validate/project/ProjectTripApplyValidate.php @@ -40,7 +40,8 @@ class ProjectTripApplyValidate extends BaseValidate 'traffic' => 'require|checkTraffic', 'start_date' => 'require|dateFormat:Y-m-d', 'end_date' => 'require|dateFormat:Y-m-d|checkEndDate', - 'annex' => 'checkAnnex' + 'annex' => 'checkAnnex', + 'approve_detail' => 'require|checkApproveDetail', ]; @@ -56,6 +57,7 @@ class ProjectTripApplyValidate extends BaseValidate 'traffic' => '交通工具', 'start_date' => '出差时间', 'end_date' => '结束时间', + 'approve_detail' => '审批流程' ];