From c755ea1db7d45065b5b88d9e451d5373895a57e7 Mon Sep 17 00:00:00 2001 From: weiz <736250432@qq.com> Date: Thu, 28 Mar 2024 15:01:14 +0800 Subject: [PATCH] update --- ...FinancialTravelReimbursementController.php | 111 ++++++++++ ...ialTravelReimbursementDetailController.php | 108 ++++++++++ ...inancialTravelReimbursementDetailLists.php | 81 ++++++++ .../FinancialTravelReimbursementLists.php | 95 +++++++++ .../FinancialExpenseReimbursementLogic.php | 1 - ...inancialTravelReimbursementDetailLogic.php | 133 ++++++++++++ .../FinancialTravelReimbursementLogic.php | 194 ++++++++++++++++++ .../FinancialExpenseReimbursementValidate.php | 2 + ...ncialTravelReimbursementDetailValidate.php | 141 +++++++++++++ .../FinancialTravelReimbursementValidate.php | 177 ++++++++++++++++ .../FinancialExpenseReimbursement.php | 48 +++-- .../FinancialTravelReimbursement.php | 46 +++++ .../FinancialTravelReimbursementDetail.php | 38 ++++ 13 files changed, 1153 insertions(+), 22 deletions(-) create mode 100644 app/adminapi/controller/financial/FinancialTravelReimbursementController.php create mode 100644 app/adminapi/controller/financial/FinancialTravelReimbursementDetailController.php create mode 100644 app/adminapi/lists/financial/FinancialTravelReimbursementDetailLists.php create mode 100644 app/adminapi/lists/financial/FinancialTravelReimbursementLists.php create mode 100644 app/adminapi/logic/financial/FinancialTravelReimbursementDetailLogic.php create mode 100644 app/adminapi/logic/financial/FinancialTravelReimbursementLogic.php create mode 100644 app/adminapi/validate/financial/FinancialTravelReimbursementDetailValidate.php create mode 100644 app/adminapi/validate/financial/FinancialTravelReimbursementValidate.php create mode 100644 app/common/model/financial/FinancialTravelReimbursement.php create mode 100644 app/common/model/financial/FinancialTravelReimbursementDetail.php diff --git a/app/adminapi/controller/financial/FinancialTravelReimbursementController.php b/app/adminapi/controller/financial/FinancialTravelReimbursementController.php new file mode 100644 index 000000000..dfa3f93f8 --- /dev/null +++ b/app/adminapi/controller/financial/FinancialTravelReimbursementController.php @@ -0,0 +1,111 @@ +dataLists(new FinancialTravelReimbursementLists()); + } + + + /** + * @notes 添加财务管理--差旅费报销单 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/28 14:23 + */ + public function add() + { + $params = (new FinancialTravelReimbursementValidate())->post()->goCheck('add'); + $result = FinancialTravelReimbursementLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(FinancialTravelReimbursementLogic::getError()); + } + + + /** + * @notes 编辑财务管理--差旅费报销单 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/28 14:23 + */ + public function edit() + { + $params = (new FinancialTravelReimbursementValidate())->post()->goCheck('edit'); + $result = FinancialTravelReimbursementLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(FinancialTravelReimbursementLogic::getError()); + } + + + /** + * @notes 删除财务管理--差旅费报销单 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/28 14:23 + */ + public function delete() + { + $params = (new FinancialTravelReimbursementValidate())->post()->goCheck('delete'); + $result = FinancialTravelReimbursementLogic::delete($params); + if (true === $result) { + return $this->success('删除成功', [], 1, 1); + } + return $this->fail(FinancialTravelReimbursementLogic::getError()); + } + + + /** + * @notes 获取财务管理--差旅费报销单详情 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/28 14:23 + */ + public function detail() + { + $params = (new FinancialTravelReimbursementValidate())->goCheck('detail'); + $result = FinancialTravelReimbursementLogic::detail($params); + return $this->data($result); + } + + + } \ No newline at end of file diff --git a/app/adminapi/controller/financial/FinancialTravelReimbursementDetailController.php b/app/adminapi/controller/financial/FinancialTravelReimbursementDetailController.php new file mode 100644 index 000000000..cc8347f78 --- /dev/null +++ b/app/adminapi/controller/financial/FinancialTravelReimbursementDetailController.php @@ -0,0 +1,108 @@ +dataLists(new FinancialTravelReimbursementDetailLists()); + } + + + /** + * @notes 添加财务管理--差旅费报销单--报销明细 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/28 14:23 + */ + public function add() + { + $params = (new FinancialTravelReimbursementDetailValidate())->post()->goCheck('add'); + $result = FinancialTravelReimbursementDetailLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(FinancialTravelReimbursementDetailLogic::getError()); + } + + + /** + * @notes 编辑财务管理--差旅费报销单--报销明细 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/28 14:23 + */ + public function edit() + { + $params = (new FinancialTravelReimbursementDetailValidate())->post()->goCheck('edit'); + $result = FinancialTravelReimbursementDetailLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(FinancialTravelReimbursementDetailLogic::getError()); + } + + + /** + * @notes 删除财务管理--差旅费报销单--报销明细 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/28 14:23 + */ + public function delete() + { + $params = (new FinancialTravelReimbursementDetailValidate())->post()->goCheck('delete'); + FinancialTravelReimbursementDetailLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取财务管理--差旅费报销单--报销明细详情 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/28 14:23 + */ + public function detail() + { + $params = (new FinancialTravelReimbursementDetailValidate())->goCheck('detail'); + $result = FinancialTravelReimbursementDetailLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/financial/FinancialTravelReimbursementDetailLists.php b/app/adminapi/lists/financial/FinancialTravelReimbursementDetailLists.php new file mode 100644 index 000000000..3bf161075 --- /dev/null +++ b/app/adminapi/lists/financial/FinancialTravelReimbursementDetailLists.php @@ -0,0 +1,81 @@ + ['travel_reimbursement_id'], + ]; + } + + + /** + * @notes 获取财务管理--差旅费报销单--报销明细列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/03/28 14:23 + */ + public function lists(): array + { + return FinancialTravelReimbursementDetail::where($this->searchWhere) + ->field(['id', 'travel_reimbursement_id', 'dept_id', 'date', 'address', 'traffic_amount', 'stay_amount', 'stay_days', 'stay_price', 'subsidy_days', 'subsidy_price', 'subsidy_amount', 'subsidy_deduction', 'abstract']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function ($data) { + $dept = Dept::field('name')->where('id', $data['dept_id'])->findOrEmpty(); + $data['dept_name'] = $dept['name']; + }) + ->toArray(); + } + + + /** + * @notes 获取财务管理--差旅费报销单--报销明细数量 + * @return int + * @author likeadmin + * @date 2024/03/28 14:23 + */ + public function count(): int + { + return FinancialTravelReimbursementDetail::where($this->searchWhere)->count(); + } + + } \ No newline at end of file diff --git a/app/adminapi/lists/financial/FinancialTravelReimbursementLists.php b/app/adminapi/lists/financial/FinancialTravelReimbursementLists.php new file mode 100644 index 000000000..85cdc63f8 --- /dev/null +++ b/app/adminapi/lists/financial/FinancialTravelReimbursementLists.php @@ -0,0 +1,95 @@ + ['code', 'approve_dept', 'cost_type', 'pay_type', 'create_user'], + ]; + } + + + /** + * @notes 获取财务管理--差旅费报销单列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/03/28 14:23 + */ + public function lists(): array + { + $params = $this->request->get(); + $where = []; + if (!empty($params['create_time'])) { + $date = explode(',', $params['create_time']); + $where[] = ['create_time', 'between', [strtotime($date[0] . ' 00:00:00'), strtotime($date[1] . ' 23:59:59')]]; + } + return FinancialTravelReimbursement::where($this->searchWhere)->where($where) + ->field(['id', 'code', 'approve_dept', 'cost_type', 'pay_type', 'tax_deductible_amount', 'bill_num', 'fee_application_id', 'content', 'create_user', 'create_time']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function ($data) { + $dept = Dept::field('name')->where('id', $data['approve_dept'])->findOrEmpty(); + $data['approve_dept_name'] = $dept['name']; + $data['pay_type_text'] = $data->pay_type_text; + $data['cost_type_text'] = $data->cost_type_text; + }) + ->toArray(); + } + + + /** + * @notes 获取财务管理--差旅费报销单数量 + * @return int + * @author likeadmin + * @date 2024/03/28 14:23 + */ + public function count(): int + { + $params = $this->request->get(); + $where = []; + if (!empty($params['create_time'])) { + $date = explode(',', $params['create_time']); + $where[] = ['create_time', 'between', [strtotime($date[0] . ' 00:00:00'), strtotime($date[1] . ' 23:59:59')]]; + } + return FinancialTravelReimbursement::where($this->searchWhere)->where($where)->count(); + } + + } \ No newline at end of file diff --git a/app/adminapi/logic/financial/FinancialExpenseReimbursementLogic.php b/app/adminapi/logic/financial/FinancialExpenseReimbursementLogic.php index 12bace5e0..33086fc1f 100644 --- a/app/adminapi/logic/financial/FinancialExpenseReimbursementLogic.php +++ b/app/adminapi/logic/financial/FinancialExpenseReimbursementLogic.php @@ -168,7 +168,6 @@ $data['contract_type'] = !$contract->isEmpty() ? $contract['contract_type'] : 0; $data['contract_type_text'] = !$contract->isEmpty() ? $contract->contract_type_text : ''; $data['fee_application_theme'] = !$fee_application->isEmpty() ? $fee_application['theme'] : ''; - $data['pay_type'] = (string)$data['pay_type']; $data['pay_type_text'] = $data->pay_type_text; $data['total_amount'] = FinancialExpenseReimbursementDetail::where('expense_reimbursement_id', $data['id'])->sum('amount'); return $data->toArray(); diff --git a/app/adminapi/logic/financial/FinancialTravelReimbursementDetailLogic.php b/app/adminapi/logic/financial/FinancialTravelReimbursementDetailLogic.php new file mode 100644 index 000000000..f1069c72e --- /dev/null +++ b/app/adminapi/logic/financial/FinancialTravelReimbursementDetailLogic.php @@ -0,0 +1,133 @@ + $params['travel_reimbursement_id'], + 'dept_id' => $params['dept_id'], + 'date' => !empty($params['date']) ? strtotime($params['date']) : 0, + 'address' => $params['address'], + 'traffic_amount' => $params['traffic_amount'] ?? 0, + 'stay_amount' => $params['stay_amount'] ?? 0, + 'stay_days' => $params['stay_days'] ?? 0, + 'stay_price' => $params['stay_price'] ?? 0, + 'subsidy_days' => $params['subsidy_days'] ?? 0, + 'subsidy_price' => $params['subsidy_price'] ?? 0, + 'subsidy_amount' => $params['subsidy_amount'] ?? 0, + 'subsidy_deduction' => $params['subsidy_deduction'], + 'abstract' => $params['abstract'] ?? '', + ]); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑财务管理--差旅费报销单--报销明细 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/03/28 14:23 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + FinancialTravelReimbursementDetail::where('id', $params['id'])->update([ + 'travel_reimbursement_id' => $params['travel_reimbursement_id'], + 'dept_id' => $params['dept_id'], + 'date' => !empty($params['date']) ? strtotime($params['date']) : 0, + 'address' => $params['address'], + 'traffic_amount' => $params['traffic_amount'] ?? 0, + 'stay_amount' => $params['stay_amount'] ?? 0, + 'stay_days' => $params['stay_days'] ?? 0, + 'stay_price' => $params['stay_price'] ?? 0, + 'subsidy_days' => $params['subsidy_days'] ?? 0, + 'subsidy_price' => $params['subsidy_price'] ?? 0, + 'subsidy_amount' => $params['subsidy_amount'] ?? 0, + 'subsidy_deduction' => $params['subsidy_deduction'], + 'abstract' => $params['abstract'] ?? '', + 'update_time' => time() + ]); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除财务管理--差旅费报销单--报销明细 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/03/28 14:23 + */ + public static function delete(array $params): bool + { + return FinancialTravelReimbursementDetail::destroy($params['id']); + } + + + /** + * @notes 获取财务管理--差旅费报销单--报销明细详情 + * @param $params + * @return array + * @author likeadmin + * @date 2024/03/28 14:23 + */ + public static function detail($params): array + { + $data = FinancialTravelReimbursementDetail::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']); + $dept = Dept::field('name')->where('id', $data['dept_id'])->findOrEmpty(); + $data['dept_name'] = $dept['name']; + return $data->toArray(); + } + } \ No newline at end of file diff --git a/app/adminapi/logic/financial/FinancialTravelReimbursementLogic.php b/app/adminapi/logic/financial/FinancialTravelReimbursementLogic.php new file mode 100644 index 000000000..76950138a --- /dev/null +++ b/app/adminapi/logic/financial/FinancialTravelReimbursementLogic.php @@ -0,0 +1,194 @@ + data_unique_code('CLBX'), + 'approve_dept' => $params['approve_dept'], + 'cost_type' => $params['cost_type'], + 'pay_type' => $params['pay_type'], + 'tax_deductible_amount' => $params['tax_deductible_amount'] ?? 0, + 'bill_num' => $params['bill_num'], + 'fee_application_id' => $params['fee_application_id'] ?? 0, + 'content' => $params['content'] ?? '', + 'create_user' => $params['create_user'], + 'create_time' => !empty($params['create_time']) ? strtotime($params['create_time']) : time(), + ]); + if (!empty($params['detail'])) { + foreach ($params['detail'] as $v) { + FinancialTravelReimbursementDetail::create([ + 'travel_reimbursement_id' => $res->id, + 'dept_id' => $v['dept_id'], + 'date' => !empty($v['date']) ? strtotime($v['date']) : 0, + 'address' => $v['address'], + 'traffic_amount' => $v['traffic_amount'] ?? 0, + 'stay_amount' => $v['stay_amount'] ?? 0, + 'stay_days' => $v['stay_days'] ?? 0, + 'stay_price' => $v['stay_price'] ?? 0, + 'subsidy_days' => $v['subsidy_days'] ?? 0, + 'subsidy_price' => $v['subsidy_price'] ?? 0, + 'subsidy_amount' => $v['subsidy_amount'] ?? 0, + 'subsidy_deduction' => $v['subsidy_deduction'] ?? 0, + 'abstract' => $v['abstract'] ?? '', + ]); + } + } + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑财务管理--差旅费报销单 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/03/28 14:23 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + FinancialTravelReimbursement::where('id', $params['id'])->update([ + 'approve_dept' => $params['approve_dept'], + 'cost_type' => $params['cost_type'], + 'pay_type' => $params['pay_type'], + 'tax_deductible_amount' => $params['tax_deductible_amount'] ?? 0, + 'bill_num' => $params['bill_num'], + 'fee_application_id' => $params['fee_application_id'] ?? 0, + 'content' => $params['content'] ?? '', + 'create_user' => $params['create_user'], + 'create_time' => !empty($params['create_time']) ? strtotime($params['create_time']) : time(), + 'update_time' => time(), + ]); + if (!empty($params['detail'])) { + foreach ($params['detail'] as $v) { + if (!empty($v['id'])) { + FinancialTravelReimbursementDetail::where('id', $v['id'])->update([ + 'travel_reimbursement_id' => $params['id'], + 'dept_id' => $v['dept_id'], + 'date' => !empty($v['date']) ? strtotime($v['date']) : 0, + 'address' => $v['address'], + 'traffic_amount' => $v['traffic_amount'] ?? 0, + 'stay_amount' => $v['stay_amount'] ?? 0, + 'stay_days' => $v['stay_days'] ?? 0, + 'stay_price' => $v['stay_price'] ?? 0, + 'subsidy_days' => $v['subsidy_days'] ?? 0, + 'subsidy_price' => $v['subsidy_price'] ?? 0, + 'subsidy_amount' => $v['subsidy_amount'] ?? 0, + 'subsidy_deduction' => $v['subsidy_deduction'] ?? 0, + 'abstract' => $v['abstract'] ?? '', + 'update_time' => time(), + ]); + } else { + FinancialTravelReimbursementDetail::create([ + 'travel_reimbursement_id' => $params['id'], + 'dept_id' => $v['dept_id'], + 'date' => !empty($v['date']) ? strtotime($v['date']) : 0, + 'address' => $v['address'], + 'traffic_amount' => $v['traffic_amount'] ?? 0, + 'stay_amount' => $v['stay_amount'] ?? 0, + 'stay_days' => $v['stay_days'] ?? 0, + 'stay_price' => $v['stay_price'] ?? 0, + 'subsidy_days' => $v['subsidy_days'] ?? 0, + 'subsidy_price' => $v['subsidy_price'] ?? 0, + 'subsidy_amount' => $v['subsidy_amount'] ?? 0, + 'subsidy_deduction' => $v['subsidy_deduction'] ?? 0, + 'abstract' => $v['abstract'] ?? '', + ]); + } + } + } + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除财务管理--差旅费报销单 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/03/28 14:23 + */ + public static function delete(array $params): bool + { + $detail = FinancialTravelReimbursementDetail::where('expense_reimbursement_id', 'in', $params['id'])->findOrEmpty(); + if (!$detail->isEmpty()) { + self::setError('此数据关联了报销明细信息,需删除报销明细信息'); + return false; + } + return FinancialTravelReimbursement::destroy($params['id']); + } + + + /** + * @notes 获取财务管理--差旅费报销单详情 + * @param $params + * @return array + * @author likeadmin + * @date 2024/03/28 14:23 + */ + public static function detail($params): array + { + $data = FinancialTravelReimbursement::withoutField('update_time,delete_time')->findOrEmpty($params['id']); + $fee_application = FinancialFeeApplication::field('theme')->where('id', $data['fee_application_id'])->findOrEmpty(); + $dept = Dept::field('name')->where('id', $data['approve_dept'])->findOrEmpty(); + $data['fee_application_theme'] = !$fee_application->isEmpty() ? $fee_application['theme'] : ''; + $data['approve_dept_name'] = $dept['name']; + $data['pay_type_text'] = $data->pay_type_text; + $data['cost_type_text'] = $data->cost_type_text; + return $data->toArray(); + } + } \ No newline at end of file diff --git a/app/adminapi/validate/financial/FinancialExpenseReimbursementValidate.php b/app/adminapi/validate/financial/FinancialExpenseReimbursementValidate.php index d74bcfabb..e3551c411 100644 --- a/app/adminapi/validate/financial/FinancialExpenseReimbursementValidate.php +++ b/app/adminapi/validate/financial/FinancialExpenseReimbursementValidate.php @@ -123,12 +123,14 @@ public function checkContract($value): bool|string { + if (empty($value)) return true; $data = CostApprovedProject::where('id', $value)->findOrEmpty(); return $data->isEmpty() ? '合同信息不存在' : true; } public function checkFeeApplication($value): bool|string { + if (empty($value)) return true; $data = FinancialFeeApplication::where('id', $value)->findOrEmpty(); return $data->isEmpty() ? '费用申请信息不存在' : true; } diff --git a/app/adminapi/validate/financial/FinancialTravelReimbursementDetailValidate.php b/app/adminapi/validate/financial/FinancialTravelReimbursementDetailValidate.php new file mode 100644 index 000000000..46d898bbc --- /dev/null +++ b/app/adminapi/validate/financial/FinancialTravelReimbursementDetailValidate.php @@ -0,0 +1,141 @@ + 'require|checkData', + 'travel_reimbursement_id' => 'require|checkTravelReimbursement', + 'dept_id' => 'require|checkDept', + 'date' => 'require|dateFormat:Y-m-d', + 'address' => 'require', + 'traffic_amount' => 'float|egt:0', + 'stay_amount' => 'float|egt:0', + 'stay_days' => 'integer|egt:0', + 'stay_price' => 'float|egt:0', + 'subsidy_days' => 'integer|egt:0', + 'subsidy_price' => 'float|egt:0', + 'subsidy_amount' => 'float|egt:0', + 'subsidy_deduction' => 'float|egt:0', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'travel_reimbursement_id' => '差旅报销id', + 'dept_id' => '费用归属部门', + 'date' => '起止日期', + 'address' => '起止地点', + 'traffic_amount' => '交通费', + 'stay_amount' => '住宿费', + 'stay_days' => '住宿天数', + 'stay_price' => '住宿单价', + 'subsidy_days' => '补助天数', + 'subsidy_price' => '补助标准', + 'subsidy_amount' => '补助金额', + 'subsidy_deduction' => '补贴减扣', + 'abstract' => '摘要', + + ]; + + + /** + * @notes 添加场景 + * @return FinancialTravelReimbursementDetailValidate + * @author likeadmin + * @date 2024/03/28 14:23 + */ + public function sceneAdd() + { + return $this->only(['travel_reimbursement_id', 'dept_id', 'date', 'address', 'traffic_amount', 'stay_amount', 'stay_days', 'stay_price', 'subsidy_days', 'subsidy_price', 'subsidy_amount', 'subsidy_deduction', 'abstract']); + } + + + /** + * @notes 编辑场景 + * @return FinancialTravelReimbursementDetailValidate + * @author likeadmin + * @date 2024/03/28 14:23 + */ + public function sceneEdit() + { + return $this->only(['id', 'travel_reimbursement_id', 'dept_id', 'date', 'address', 'traffic_amount', 'stay_amount', 'stay_days', 'stay_price', 'subsidy_days', 'subsidy_price', 'subsidy_amount', 'subsidy_deduction', 'abstract']); + } + + + /** + * @notes 删除场景 + * @return FinancialTravelReimbursementDetailValidate + * @author likeadmin + * @date 2024/03/28 14:23 + */ + public function sceneDelete() + { + return $this->only(['id'])->remove('id', 'checkData'); + } + + + /** + * @notes 详情场景 + * @return FinancialTravelReimbursementDetailValidate + * @author likeadmin + * @date 2024/03/28 14:23 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkData($value): bool|string + { + $data = FinancialTravelReimbursementDetail::where('id', $value)->findOrEmpty(); + return $data->isEmpty() ? '数据不存在' : true; + } + + public function checkTravelReimbursement($value): bool|string + { + $data = FinancialTravelReimbursement::where('id', $value)->findOrEmpty(); + return $data->isEmpty() ? '差旅费报销单信息不存在' : true; + } + + public function checkDept($value): bool|string + { + $data = Dept::where('id', $value)->findOrEmpty(); + return $data->isEmpty() ? '审批部门信息不存在' : true; + } + + } \ No newline at end of file diff --git a/app/adminapi/validate/financial/FinancialTravelReimbursementValidate.php b/app/adminapi/validate/financial/FinancialTravelReimbursementValidate.php new file mode 100644 index 000000000..513984b3f --- /dev/null +++ b/app/adminapi/validate/financial/FinancialTravelReimbursementValidate.php @@ -0,0 +1,177 @@ + 'require|checkData', + 'approve_dept' => 'require|checkDept', + 'cost_type' => 'require|checkCostType', + 'pay_type' => 'require|checkPayType', + 'tax_deductible_amount' => 'float|egt:0', + 'bill_num' => 'require|integer|egt:0', + 'fee_application_id' => 'checkFeeApplication', + 'create_user' => 'require', + 'create_time' => 'require|dateFormat:Y-m-d H:i:s', + 'detail' => 'checkDetail' + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'code' => '单据编号', + 'approve_dept' => '审批部门', + 'cost_type' => '费用类别', + 'pay_type' => '支付方式', + 'tax_deductible_amount' => '可抵扣税额', + 'bill_num' => '附单据张数', + 'fee_application_id' => '关联费用申请', + 'content' => '事由', + 'create_user' => '申请人', + 'create_time' => '申请日期', + + ]; + + + /** + * @notes 添加场景 + * @return FinancialTravelReimbursementValidate + * @author likeadmin + * @date 2024/03/28 14:23 + */ + public function sceneAdd() + { + return $this->remove('id', true); + } + + + /** + * @notes 编辑场景 + * @return FinancialTravelReimbursementValidate + * @author likeadmin + * @date 2024/03/28 14:23 + */ + public function sceneEdit() + { + return $this->only(['id', 'approve_dept', 'cost_type', 'pay_type', 'tax_deductible_amount', 'bill_num', 'fee_application_id', 'content', 'create_user', 'create_time', 'detail']); + } + + + /** + * @notes 删除场景 + * @return FinancialTravelReimbursementValidate + * @author likeadmin + * @date 2024/03/28 14:23 + */ + public function sceneDelete() + { + return $this->only(['id'])->remove('id', 'checkData'); + } + + + /** + * @notes 详情场景 + * @return FinancialTravelReimbursementValidate + * @author likeadmin + * @date 2024/03/28 14:23 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkData($value): bool|string + { + $data = FinancialTravelReimbursement::where('id', $value)->findOrEmpty(); + return $data->isEmpty() ? '数据不存在' : true; + } + + public function checkDept($value): bool|string + { + $data = Dept::where('id', $value)->findOrEmpty(); + return $data->isEmpty() ? '审批部门信息不存在' : true; + } + + public function checkCostType($value): bool|string + { + $dict = DictData::where('type_value', 'cost_type')->column('value'); + return !in_array($value, $dict) ? '费用类别数据值无效' : true; + } + + public function checkPayType($value): bool|string + { + $dict = DictData::where('type_value', 'financial_pay_type')->column('value'); + return !in_array($value, $dict) ? '支付方式数据值无效' : true; + } + + public function checkFeeApplication($value): bool|string + { + if (empty($value)) return true; + $data = FinancialFeeApplication::where('id', $value)->findOrEmpty(); + return $data->isEmpty() ? '费用申请信息不存在' : true; + } + + public function checkDetail($value): bool|string + { + if (empty($value) || $value == '') return true; + if (!is_array($value)) return '报销明细数据格式错误'; + foreach ($value as $k => $v) { + if (isset($v['id']) && !empty($v['id'])) { + $data = FinancialTravelReimbursementDetail::where('id', $v['id'])->findOrEmpty(); + if ($data->isEmpty()) { + return '第' . ($k + 1) . '行报销明细信息不存在'; + } + } + if (empty($v['dept_id'])) { + return '第' . ($k + 1) . '行费用归属部门为空'; + } else { + $dept = Dept::where('id', $v['dept_id'])->findOrEmpty(); + if ($dept->isEmpty()) return '第' . ($k + 1) . '行费用归属部门信息不存在'; + } + if (empty($v['date'])) { + return '第' . ($k + 1) . '行起止日期为空'; + } + if (empty($v['address'])) { + return '第' . ($k + 1) . '行起止地点为空'; + } + } + return true; + } + + } \ No newline at end of file diff --git a/app/common/model/financial/FinancialExpenseReimbursement.php b/app/common/model/financial/FinancialExpenseReimbursement.php index 86659b3bb..b8388b66d 100644 --- a/app/common/model/financial/FinancialExpenseReimbursement.php +++ b/app/common/model/financial/FinancialExpenseReimbursement.php @@ -11,24 +11,30 @@ // +---------------------------------------------------------------------- // | author: likeadminTeam // +---------------------------------------------------------------------- - -namespace app\common\model\financial; - - -use app\common\model\BaseModel; -use think\model\concern\SoftDelete; - - -/** - * 财务管理--费用报销单模型 - * Class FinancialExpenseReimbursement - * @package app\common\model\financial - */ -class FinancialExpenseReimbursement extends BaseModel -{ - use SoftDelete; - protected $name = 'financial_expense_reimbursement'; - protected $deleteTime = 'delete_time'; - - -} \ No newline at end of file + + namespace app\common\model\financial; + + + use app\common\model\BaseModel; + use app\common\model\dict\DictData; + use think\model\concern\SoftDelete; + + + /** + * 财务管理--费用报销单模型 + * Class FinancialExpenseReimbursement + * @package app\common\model\financial + */ + class FinancialExpenseReimbursement extends BaseModel + { + use SoftDelete; + + protected $name = 'financial_expense_reimbursement'; + protected $deleteTime = 'delete_time'; + + public function getPayTypeTextAttr($value, $data) + { + $dictDate = DictData::where('type_value', 'financial_pay_type')->column('name', 'value'); + return $dictDate[$data['pay_type']]; + } + } \ No newline at end of file diff --git a/app/common/model/financial/FinancialTravelReimbursement.php b/app/common/model/financial/FinancialTravelReimbursement.php new file mode 100644 index 000000000..938c4ec8b --- /dev/null +++ b/app/common/model/financial/FinancialTravelReimbursement.php @@ -0,0 +1,46 @@ +column('name', 'value'); + return $dictDate[$data['pay_type']]; + } + + public function getCostTypeTextAttr($value, $data) + { + $dictDate = DictData::where('type_value', 'cost_type')->column('name', 'value'); + return $dictDate[$data['cost_type']]; + } + } \ No newline at end of file diff --git a/app/common/model/financial/FinancialTravelReimbursementDetail.php b/app/common/model/financial/FinancialTravelReimbursementDetail.php new file mode 100644 index 000000000..5e4df82b4 --- /dev/null +++ b/app/common/model/financial/FinancialTravelReimbursementDetail.php @@ -0,0 +1,38 @@ +