diff --git a/app/adminapi/controller/cost/CostBudgetAdjustController.php b/app/adminapi/controller/cost/CostBudgetAdjustController.php new file mode 100644 index 000000000..9cbf5f304 --- /dev/null +++ b/app/adminapi/controller/cost/CostBudgetAdjustController.php @@ -0,0 +1,108 @@ +dataLists(new CostBudgetAdjustLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/18 15:17 + */ + public function add() + { + $params = (new CostBudgetAdjustValidate())->post()->goCheck('add'); + $result = CostBudgetAdjustLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(CostBudgetAdjustLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/18 15:17 + */ + public function edit() + { + $params = (new CostBudgetAdjustValidate())->post()->goCheck('edit'); + $result = CostBudgetAdjustLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(CostBudgetAdjustLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/18 15:17 + */ + public function delete() + { + $params = (new CostBudgetAdjustValidate())->post()->goCheck('delete'); + CostBudgetAdjustLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/18 15:17 + */ + public function detail() + { + $params = (new CostBudgetAdjustValidate())->goCheck('detail'); + $result = CostBudgetAdjustLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/cost/CostBudgetAdjustDetailController.php b/app/adminapi/controller/cost/CostBudgetAdjustDetailController.php new file mode 100644 index 000000000..d1b14b185 --- /dev/null +++ b/app/adminapi/controller/cost/CostBudgetAdjustDetailController.php @@ -0,0 +1,108 @@ +dataLists(new CostBudgetAdjustDetailLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/18 15:06 + */ + public function add() + { + $params = (new CostBudgetAdjustDetailValidate())->post()->goCheck('add'); + $result = CostBudgetAdjustDetailLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(CostBudgetAdjustDetailLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/18 15:06 + */ + public function edit() + { + $params = (new CostBudgetAdjustDetailValidate())->post()->goCheck('edit'); + $result = CostBudgetAdjustDetailLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(CostBudgetAdjustDetailLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/18 15:06 + */ + public function delete() + { + $params = (new CostBudgetAdjustDetailValidate())->post()->goCheck('delete'); + CostBudgetAdjustDetailLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/18 15:06 + */ + public function detail() + { + $params = (new CostBudgetAdjustDetailValidate())->goCheck('detail'); + $result = CostBudgetAdjustDetailLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/cost/CostBudgetAdjustDetailLists.php b/app/adminapi/lists/cost/CostBudgetAdjustDetailLists.php new file mode 100644 index 000000000..924eeceb0 --- /dev/null +++ b/app/adminapi/lists/cost/CostBudgetAdjustDetailLists.php @@ -0,0 +1,77 @@ + ['cost_subject_id', 'cost_budget_adjust_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 15:06 + */ + public function lists(): array + { + return CostBudgetAdjustDetail::where($this->searchWhere) + ->field(['id', 'cost_subject_id', 'cost_budget_adjust_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 15:06 + */ + public function count(): int + { + return CostBudgetAdjustDetail::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/cost/CostBudgetAdjustLists.php b/app/adminapi/lists/cost/CostBudgetAdjustLists.php new file mode 100644 index 000000000..8a957e55f --- /dev/null +++ b/app/adminapi/lists/cost/CostBudgetAdjustLists.php @@ -0,0 +1,83 @@ + ['approve_id', '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 15:17 + */ + public function lists(): array + { + return CostBudgetAdjust::where($this->searchWhere) + ->field(['id', 'approve_id', 'years', 'document_preparation_time', 'remark', 'annex']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($item, $key){ + //关联数据后续添加 + $item['approve_no'] = '付款单号'; + $item['approve_step'] = '流程步骤'; + $item['approve_settle_status'] = 1; + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author likeadmin + * @date 2023/12/18 15:17 + */ + public function count(): int + { + return CostBudgetAdjust::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/cost/CostBudgetAdjustDetailLogic.php b/app/adminapi/logic/cost/CostBudgetAdjustDetailLogic.php new file mode 100644 index 000000000..53b789e64 --- /dev/null +++ b/app/adminapi/logic/cost/CostBudgetAdjustDetailLogic.php @@ -0,0 +1,132 @@ + $params['cost_subject_id'], + 'cost_budget_adjust_id' => $params['cost_budget_adjust_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 15:06 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + CostBudgetAdjustDetail::where('id', $params['id'])->update([ + 'cost_subject_id' => $params['cost_subject_id'], + 'cost_budget_adjust_id' => $params['cost_budget_adjust_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 15:06 + */ + public static function delete(array $params): bool + { + return CostBudgetAdjustDetail::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/18 15:06 + */ + public static function detail($params): array + { + return CostBudgetAdjustDetail::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/cost/CostBudgetAdjustLogic.php b/app/adminapi/logic/cost/CostBudgetAdjustLogic.php new file mode 100644 index 000000000..5e8481fb8 --- /dev/null +++ b/app/adminapi/logic/cost/CostBudgetAdjustLogic.php @@ -0,0 +1,157 @@ + $params['approve_id'], + 'years' => $params['years'], + 'document_preparation_time' => $params['document_preparation_time'], + 'remark' => $params['remark'], + 'annex' => $params['annex'], + ]); + foreach ($params['detail'] ?? [] as $item) + { + CostBudgetAdjustDetail::create([ + 'cost_budget_adjust_id' => $costBudgetAdjust->id, + 'cost_subject_id' => $item['cost_subject_id'] ?? 0, + 'dept_id' => $item['dept_id'] ?? 0, + 'month1' => $item['month1'] ?? 0, + 'month2' => $item['month2'] ?? 0, + 'month3' => $item['month3'] ?? 0, + 'month4' => $item['month4'] ?? 0, + 'month5' => $item['month5'] ?? 0, + 'month6' => $item['month6'] ?? 0, + 'month7' => $item['month7'] ?? 0, + 'month8' => $item['month8'] ?? 0, + 'month9' => $item['month9'] ?? 0, + 'month10' => $item['month10'] ?? 0, + 'month11' => $item['month11'] ?? 0, + 'month12' => $item['month12'] ?? 0 + ]); + } + + 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 15:17 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + CostBudgetAdjust::where('id', $params['id'])->update([ + 'approve_id' => $params['approve_id'], + 'years' => $params['years'], + 'document_preparation_time' => $params['document_preparation_time'], + 'remark' => $params['remark'], + 'annex' => $params['annex'], + ]); + + CostBudgetAdjustDetail::where('cost_budget_adjust_id', $params['id'])->update(['delete_time' => time()]); + foreach ($params['detail'] ?? [] as $item) + { + CostBudgetAdjustDetail::where('cost_budget_adjust_id', $params['id'])->update([ + 'cost_subject_id' => $item['cost_subject_id'] ?? 0, + 'dept_id' => $item['dept_id'] ?? 0, + 'month1' => $item['month1'] ?? 0, + 'month2' => $item['month2'] ?? 0, + 'month3' => $item['month3'] ?? 0, + 'month4' => $item['month4'] ?? 0, + 'month5' => $item['month5'] ?? 0, + 'month6' => $item['month6'] ?? 0, + 'month7' => $item['month7'] ?? 0, + 'month8' => $item['month8'] ?? 0, + 'month9' => $item['month9'] ?? 0, + 'month10' => $item['month10'] ?? 0, + 'month11' => $item['month11'] ?? 0, + 'month12' => $item['month12'] ?? 0 + ]); + } + 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 15:17 + */ + public static function delete(array $params): bool + { + return CostBudgetAdjust::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/18 15:17 + */ + public static function detail($params): array + { + $costBudgetAdjust = CostBudgetAdjust::findOrEmpty($params['id']); + $costBudgetAdjust->detail; + return $costBudgetAdjust->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/cost/CostBudgetAdjustDetailValidate.php b/app/adminapi/validate/cost/CostBudgetAdjustDetailValidate.php new file mode 100644 index 000000000..82cbda4c0 --- /dev/null +++ b/app/adminapi/validate/cost/CostBudgetAdjustDetailValidate.php @@ -0,0 +1,98 @@ + 'require', + 'cost_subject_id' => 'require', + 'cost_budget_adjust_id' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'cost_subject_id' => 'cost_subject_id', + 'cost_budget_adjust_id' => '预算调整id', + ]; + + + /** + * @notes 添加场景 + * @return CostBudgetAdjustDetailValidate + * @author likeadmin + * @date 2023/12/18 15:06 + */ + public function sceneAdd() + { + return $this->only(['cost_subject_id','cost_budget_adjust_id']); + } + + + /** + * @notes 编辑场景 + * @return CostBudgetAdjustDetailValidate + * @author likeadmin + * @date 2023/12/18 15:06 + */ + public function sceneEdit() + { + return $this->only(['id','cost_subject_id','cost_budget_adjust_id']); + } + + + /** + * @notes 删除场景 + * @return CostBudgetAdjustDetailValidate + * @author likeadmin + * @date 2023/12/18 15:06 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return CostBudgetAdjustDetailValidate + * @author likeadmin + * @date 2023/12/18 15:06 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/cost/CostBudgetAdjustValidate.php b/app/adminapi/validate/cost/CostBudgetAdjustValidate.php new file mode 100644 index 000000000..97c95f5b1 --- /dev/null +++ b/app/adminapi/validate/cost/CostBudgetAdjustValidate.php @@ -0,0 +1,100 @@ + 'require', + 'approve_id' => 'require', + 'years' => 'require', + 'document_preparation_time' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'approve_id' => '审批id', + 'years' => '年份', + 'document_preparation_time' => '制单时间', + ]; + + + /** + * @notes 添加场景 + * @return CostBudgetAdjustValidate + * @author likeadmin + * @date 2023/12/18 15:17 + */ + public function sceneAdd() + { + return $this->only(['approve_id','years','document_preparation_time']); + } + + + /** + * @notes 编辑场景 + * @return CostBudgetAdjustValidate + * @author likeadmin + * @date 2023/12/18 15:17 + */ + public function sceneEdit() + { + return $this->only(['id','approve_id','years','document_preparation_time']); + } + + + /** + * @notes 删除场景 + * @return CostBudgetAdjustValidate + * @author likeadmin + * @date 2023/12/18 15:17 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return CostBudgetAdjustValidate + * @author likeadmin + * @date 2023/12/18 15:17 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/common/model/cost/CostBudgetAdjust.php b/app/common/model/cost/CostBudgetAdjust.php new file mode 100644 index 000000000..87cfcba8a --- /dev/null +++ b/app/common/model/cost/CostBudgetAdjust.php @@ -0,0 +1,45 @@ +hasMany(\app\common\model\cost\CostBudgetAdjustDetail::class, 'cost_budget_adjust_id', 'id'); + } + +} \ No newline at end of file diff --git a/app/common/model/cost/CostBudgetAdjustDetail.php b/app/common/model/cost/CostBudgetAdjustDetail.php new file mode 100644 index 000000000..5e7d62208 --- /dev/null +++ b/app/common/model/cost/CostBudgetAdjustDetail.php @@ -0,0 +1,34 @@ +