From 363d278fe101c767df4e4059e743a13fea4dceb2 Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Mon, 18 Dec 2023 11:27:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=B4=B9=E7=94=A8=E9=A2=84?= =?UTF-8?q?=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/cost/CostBudgetController.php | 108 ++++++++++++++ .../cost/CostBudgetDetailController.php | 108 ++++++++++++++ .../lists/cost/CostBudgetDetailLists.php | 77 ++++++++++ app/adminapi/lists/cost/CostBudgetLists.php | 77 ++++++++++ .../logic/cost/CostBudgetDetailLogic.php | 134 ++++++++++++++++++ app/adminapi/logic/cost/CostBudgetLogic.php | 114 +++++++++++++++ .../cost/CostBudgetDetailValidate.php | 98 +++++++++++++ .../validate/cost/CostBudgetValidate.php | 98 +++++++++++++ app/common/model/cost/CostBudget.php | 45 ++++++ app/common/model/cost/CostBudgetDetail.php | 34 +++++ 10 files changed, 893 insertions(+) create mode 100644 app/adminapi/controller/cost/CostBudgetController.php create mode 100644 app/adminapi/controller/cost/CostBudgetDetailController.php create mode 100644 app/adminapi/lists/cost/CostBudgetDetailLists.php create mode 100644 app/adminapi/lists/cost/CostBudgetLists.php create mode 100644 app/adminapi/logic/cost/CostBudgetDetailLogic.php create mode 100644 app/adminapi/logic/cost/CostBudgetLogic.php create mode 100644 app/adminapi/validate/cost/CostBudgetDetailValidate.php create mode 100644 app/adminapi/validate/cost/CostBudgetValidate.php create mode 100644 app/common/model/cost/CostBudget.php create mode 100644 app/common/model/cost/CostBudgetDetail.php diff --git a/app/adminapi/controller/cost/CostBudgetController.php b/app/adminapi/controller/cost/CostBudgetController.php new file mode 100644 index 000000000..358774d84 --- /dev/null +++ b/app/adminapi/controller/cost/CostBudgetController.php @@ -0,0 +1,108 @@ +dataLists(new CostBudgetLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/18 11:26 + */ + public function add() + { + $params = (new CostBudgetValidate())->post()->goCheck('add'); + $result = CostBudgetLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(CostBudgetLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/18 11:26 + */ + public function edit() + { + $params = (new CostBudgetValidate())->post()->goCheck('edit'); + $result = CostBudgetLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(CostBudgetLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/18 11:26 + */ + public function delete() + { + $params = (new CostBudgetValidate())->post()->goCheck('delete'); + CostBudgetLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/18 11:26 + */ + public function detail() + { + $params = (new CostBudgetValidate())->goCheck('detail'); + $result = CostBudgetLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/cost/CostBudgetDetailController.php b/app/adminapi/controller/cost/CostBudgetDetailController.php new file mode 100644 index 000000000..10411bc9e --- /dev/null +++ b/app/adminapi/controller/cost/CostBudgetDetailController.php @@ -0,0 +1,108 @@ +dataLists(new CostBudgetDetailLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/18 11:22 + */ + public function add() + { + $params = (new CostBudgetDetailValidate())->post()->goCheck('add'); + $result = CostBudgetDetailLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(CostBudgetDetailLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/18 11:22 + */ + public function edit() + { + $params = (new CostBudgetDetailValidate())->post()->goCheck('edit'); + $result = CostBudgetDetailLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(CostBudgetDetailLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/18 11:22 + */ + public function delete() + { + $params = (new CostBudgetDetailValidate())->post()->goCheck('delete'); + CostBudgetDetailLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/18 11:22 + */ + public function detail() + { + $params = (new CostBudgetDetailValidate())->goCheck('detail'); + $result = CostBudgetDetailLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/cost/CostBudgetDetailLists.php b/app/adminapi/lists/cost/CostBudgetDetailLists.php new file mode 100644 index 000000000..648234082 --- /dev/null +++ b/app/adminapi/lists/cost/CostBudgetDetailLists.php @@ -0,0 +1,77 @@ + ['cost_subject_id', 'cost_budget_id'], + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/12/18 11:22 + */ + public function lists(): array + { + return CostBudgetDetail::where($this->searchWhere) + ->field(['id', 'cost_subject_id', 'cost_budget_id', 'dept_id', 'month1', 'month2', 'month3', 'month4', 'month5', 'month6', 'month7', 'month8', 'month9', 'month10', 'month11', 'month12']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author likeadmin + * @date 2023/12/18 11:22 + */ + public function count(): int + { + return CostBudgetDetail::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/cost/CostBudgetLists.php b/app/adminapi/lists/cost/CostBudgetLists.php new file mode 100644 index 000000000..26831e234 --- /dev/null +++ b/app/adminapi/lists/cost/CostBudgetLists.php @@ -0,0 +1,77 @@ + ['years', 'document_preparation_time'], + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/12/18 11:26 + */ + public function lists(): array + { + return CostBudget::where($this->searchWhere) + ->field(['id', 'years', 'document_preparation_time', 'total', 'remark', 'annex']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author likeadmin + * @date 2023/12/18 11:26 + */ + public function count(): int + { + return CostBudget::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/cost/CostBudgetDetailLogic.php b/app/adminapi/logic/cost/CostBudgetDetailLogic.php new file mode 100644 index 000000000..54ee0b4ce --- /dev/null +++ b/app/adminapi/logic/cost/CostBudgetDetailLogic.php @@ -0,0 +1,134 @@ + $params['cost_subject_id'], + 'cost_budget_id' => $params['cost_budget_id'], + 'dept_id' => $params['dept_id'], + 'month1' => $params['month1'], + 'month2' => $params['month2'], + 'month3' => $params['month3'], + 'month4' => $params['month4'], + 'month5' => $params['month5'], + 'month6' => $params['month6'], + 'month7' => $params['month7'], + 'month8' => $params['month8'], + 'month9' => $params['month9'], + 'month10' => $params['month10'], + 'month11' => $params['month11'], + 'month12' => $params['month12'], + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/12/18 11:22 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + CostBudgetDetail::where('id', $params['id'])->update([ + 'cost_subject_id' => $params['cost_subject_id'], + 'cost_budget_id' => $params['cost_budget_id'], + 'dept_id' => $params['dept_id'], + 'month1' => $params['month1'], + 'month2' => $params['month2'], + 'month3' => $params['month3'], + 'month4' => $params['month4'], + 'month5' => $params['month5'], + 'month6' => $params['month6'], + 'month7' => $params['month7'], + 'month8' => $params['month8'], + 'month9' => $params['month9'], + 'month10' => $params['month10'], + 'month11' => $params['month11'], + 'month12' => $params['month12'], + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/12/18 11:22 + */ + public static function delete(array $params): bool + { + return CostBudgetDetail::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/18 11:22 + */ + public static function detail($params): array + { + return CostBudgetDetail::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/cost/CostBudgetLogic.php b/app/adminapi/logic/cost/CostBudgetLogic.php new file mode 100644 index 000000000..fd6f3ae05 --- /dev/null +++ b/app/adminapi/logic/cost/CostBudgetLogic.php @@ -0,0 +1,114 @@ + $params['years'], + 'document_preparation_time' => $params['document_preparation_time'], + 'total' => $params['total'], + 'remark' => $params['remark'], + 'annex' => $params['annex'], + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/12/18 11:26 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + CostBudget::where('id', $params['id'])->update([ + 'years' => $params['years'], + 'document_preparation_time' => $params['document_preparation_time'], + 'total' => $params['total'], + 'remark' => $params['remark'], + 'annex' => $params['annex'], + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/12/18 11:26 + */ + public static function delete(array $params): bool + { + return CostBudget::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/18 11:26 + */ + public static function detail($params): array + { + return CostBudget::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/cost/CostBudgetDetailValidate.php b/app/adminapi/validate/cost/CostBudgetDetailValidate.php new file mode 100644 index 000000000..074b698af --- /dev/null +++ b/app/adminapi/validate/cost/CostBudgetDetailValidate.php @@ -0,0 +1,98 @@ + 'require', + 'cost_subject_id' => 'require', + 'gc_cost_budget_id' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'cost_subject_id' => '一级科目id', + 'gc_cost_budget_id' => '费用明细id', + ]; + + + /** + * @notes 添加场景 + * @return CostBudgetDetailValidate + * @author likeadmin + * @date 2023/12/18 11:22 + */ + public function sceneAdd() + { + return $this->only(['cost_subject_id','gc_cost_budget_id']); + } + + + /** + * @notes 编辑场景 + * @return CostBudgetDetailValidate + * @author likeadmin + * @date 2023/12/18 11:22 + */ + public function sceneEdit() + { + return $this->only(['id','cost_subject_id','gc_cost_budget_id']); + } + + + /** + * @notes 删除场景 + * @return CostBudgetDetailValidate + * @author likeadmin + * @date 2023/12/18 11:22 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return CostBudgetDetailValidate + * @author likeadmin + * @date 2023/12/18 11:22 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/cost/CostBudgetValidate.php b/app/adminapi/validate/cost/CostBudgetValidate.php new file mode 100644 index 000000000..0b001d96f --- /dev/null +++ b/app/adminapi/validate/cost/CostBudgetValidate.php @@ -0,0 +1,98 @@ + 'require', + 'years' => 'require', + 'document_preparation_time' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'years' => '年份', + 'document_preparation_time' => '制单时间', + ]; + + + /** + * @notes 添加场景 + * @return CostBudgetValidate + * @author likeadmin + * @date 2023/12/18 11:26 + */ + public function sceneAdd() + { + return $this->only(['years','document_preparation_time']); + } + + + /** + * @notes 编辑场景 + * @return CostBudgetValidate + * @author likeadmin + * @date 2023/12/18 11:26 + */ + public function sceneEdit() + { + return $this->only(['id','years','document_preparation_time']); + } + + + /** + * @notes 删除场景 + * @return CostBudgetValidate + * @author likeadmin + * @date 2023/12/18 11:26 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return CostBudgetValidate + * @author likeadmin + * @date 2023/12/18 11:26 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/common/model/cost/CostBudget.php b/app/common/model/cost/CostBudget.php new file mode 100644 index 000000000..c984cbeeb --- /dev/null +++ b/app/common/model/cost/CostBudget.php @@ -0,0 +1,45 @@ +hasMany(\app\common\model\cost\CostBudgetDetail::class, 'cost_budget_id', 'id'); + } + +} \ No newline at end of file diff --git a/app/common/model/cost/CostBudgetDetail.php b/app/common/model/cost/CostBudgetDetail.php new file mode 100644 index 000000000..44212698b --- /dev/null +++ b/app/common/model/cost/CostBudgetDetail.php @@ -0,0 +1,34 @@ +