From 044faabfe1e6062f63237fb31e8aee3f92262c0c Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Tue, 12 Dec 2023 15:47:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=90=88=E5=90=8C=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProcurementContractChangeController.php | 108 ++++++++++++++ .../ProcurementContractChangeLists.php | 77 ++++++++++ .../ProcurementContractChangeLogic.php | 141 ++++++++++++++++++ .../ProcurementContractChangeValidate.php | 98 ++++++++++++ .../contract/ProcurementContractChange.php | 48 ++++++ 5 files changed, 472 insertions(+) create mode 100644 app/adminapi/controller/contract/ProcurementContractChangeController.php create mode 100644 app/adminapi/lists/contract/ProcurementContractChangeLists.php create mode 100644 app/adminapi/logic/contract/ProcurementContractChangeLogic.php create mode 100644 app/adminapi/validate/contract/ProcurementContractChangeValidate.php create mode 100644 app/common/model/contract/ProcurementContractChange.php diff --git a/app/adminapi/controller/contract/ProcurementContractChangeController.php b/app/adminapi/controller/contract/ProcurementContractChangeController.php new file mode 100644 index 000000000..eddadb036 --- /dev/null +++ b/app/adminapi/controller/contract/ProcurementContractChangeController.php @@ -0,0 +1,108 @@ +dataLists(new ProcurementContractChangeLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/12 15:31 + */ + public function add() + { + $params = (new ProcurementContractChangeValidate())->post()->goCheck('add'); + $result = ProcurementContractChangeLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(ProcurementContractChangeLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/12 15:31 + */ + public function edit() + { + $params = (new ProcurementContractChangeValidate())->post()->goCheck('edit'); + $result = ProcurementContractChangeLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(ProcurementContractChangeLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/12 15:31 + */ + public function delete() + { + $params = (new ProcurementContractChangeValidate())->post()->goCheck('delete'); + ProcurementContractChangeLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/12 15:31 + */ + public function detail() + { + $params = (new ProcurementContractChangeValidate())->goCheck('detail'); + $result = ProcurementContractChangeLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/contract/ProcurementContractChangeLists.php b/app/adminapi/lists/contract/ProcurementContractChangeLists.php new file mode 100644 index 000000000..936630293 --- /dev/null +++ b/app/adminapi/lists/contract/ProcurementContractChangeLists.php @@ -0,0 +1,77 @@ + ['procurement_contract_id', 'supplier_id', 'project_id', 'contract_no'], + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/12/12 15:31 + */ + public function lists(): array + { + return ProcurementContractChange::where($this->searchWhere) + ->field(['*']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author likeadmin + * @date 2023/12/12 15:31 + */ + public function count(): int + { + return ProcurementContractChange::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/contract/ProcurementContractChangeLogic.php b/app/adminapi/logic/contract/ProcurementContractChangeLogic.php new file mode 100644 index 000000000..2b2cf6a36 --- /dev/null +++ b/app/adminapi/logic/contract/ProcurementContractChangeLogic.php @@ -0,0 +1,141 @@ + $params['procurement_contract_id'] ?? 0, + 'supplier_id' => $params['supplier_id'] ?? 0, + 'approve_id' => $params['approve_id'] ?? 0, + 'project_id' => $params['project_id'] ?? 0, + 'contract_no' => $params['contract_no'] ?? '', + 'supplier_contract_no' => $params['supplier_contract_no'] ?? '', + 'contract_type' => $params['contract_type'] ?? 0, + 'signing_date' => strtotime($params['signing_date']), + 'pay_type' => $params['pay_type'] ?? 0, + 'account_period' => $params['account_period'] ?? 0, + 'amount' => $params['amount'] ?? 0, + 'amount_excluding_tax' => $params['amount_excluding_tax'] ?? 0, + 'amount_daxie' => $params['amount_daxie'] ?? '', + 'retention_money_rate' => $params['retention_money_rate'] ?? 0, + 'retention_money' => $params['retention_money'] ?? 0, + 'remark' => $params['remark'] ?? 0, + 'annex' => $params['annex'] ?? 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/12 15:31 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + ProcurementContractChange::where('id', $params['id'])->update([ + 'procurement_contract_id' => $params['procurement_contract_id'] ?? 0, + 'supplier_id' => $params['supplier_id'] ?? 0, + 'approve_id' => $params['approve_id'] ?? 0, + 'project_id' => $params['project_id'] ?? 0, + 'contract_no' => $params['contract_no'] ?? '', + 'supplier_contract_no' => $params['supplier_contract_no'] ?? '', + 'contract_type' => $params['contract_type'] ?? 0, + 'signing_date' => strtotime($params['signing_date']), + 'pay_type' => $params['pay_type'] ?? 0, + 'account_period' => $params['account_period'] ?? 0, + 'amount' => $params['amount'] ?? 0, + 'amount_excluding_tax' => $params['amount_excluding_tax'] ?? 0, + 'amount_daxie' => $params['amount_daxie'] ?? '', + 'retention_money_rate' => $params['retention_money_rate'] ?? 0, + 'retention_money' => $params['retention_money'] ?? 0, + 'remark' => $params['remark'] ?? 0, + 'annex' => $params['annex'] ?? 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/12 15:31 + */ + public static function delete(array $params): bool + { + return ProcurementContractChange::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/12 15:31 + */ + public static function detail($params): array + { + $procurementContractChange = ProcurementContractChange::findOrEmpty($params['id']); + $procurementContractChange->contract = $procurementContractChange->contract; + $procurementContractChange->project = $procurementContractChange->project; + return $procurementContractChange->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/contract/ProcurementContractChangeValidate.php b/app/adminapi/validate/contract/ProcurementContractChangeValidate.php new file mode 100644 index 000000000..80bd8d2fd --- /dev/null +++ b/app/adminapi/validate/contract/ProcurementContractChangeValidate.php @@ -0,0 +1,98 @@ + 'require', + 'procurement_contract_id' => 'require', + 'supplier_id' => 'require', + 'approve_id' => 'require', + 'project_id' => 'require', + 'contract_no' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + ]; + + + /** + * @notes 添加场景 + * @return ProcurementContractChangeValidate + * @author likeadmin + * @date 2023/12/12 15:31 + */ + public function sceneAdd() + { + return $this->remove('id', true); + } + + /** + * @notes 编辑场景 + * @return ProcurementContractChangeValidate + * @author likeadmin + * @date 2023/12/12 15:31 + */ + public function sceneEdit() + { + return $this->only(['id', 'procurement_contract_id', 'supplier_id', 'approve_id', 'project_id', 'contract_no']); + } + + + /** + * @notes 删除场景 + * @return ProcurementContractChangeValidate + * @author likeadmin + * @date 2023/12/12 15:31 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return ProcurementContractChangeValidate + * @author likeadmin + * @date 2023/12/12 15:31 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/common/model/contract/ProcurementContractChange.php b/app/common/model/contract/ProcurementContractChange.php new file mode 100644 index 000000000..510fa257f --- /dev/null +++ b/app/common/model/contract/ProcurementContractChange.php @@ -0,0 +1,48 @@ +belongsTo(\app\common\model\project\Project::class, 'project_id'); + } + + public function contract() + { + return $this->belongsTo(\app\common\model\contract\ProcurementContract::class, 'procurement_contract_id'); + } + + public function getSigningDateAttr($value) + { + return empty($value) ? '' : date('Y-m-d H:i:s', $value); + } + +} \ No newline at end of file