From 9798c03888f802f1714b8ae4c541cd7450033dfb Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Tue, 12 Dec 2023 17:22:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=88=86=E5=8C=85=E6=B4=BD?= =?UTF-8?q?=E5=95=86=E5=90=88=E5=90=8C=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ntractingContractNegotiationController.php | 108 +++++++++++++++ ...SubcontractingContractNegotiationLists.php | 77 +++++++++++ ...SubcontractingContractNegotiationLogic.php | 126 ++++++++++++++++++ ...contractingContractNegotiationValidate.php | 94 +++++++++++++ .../SubcontractingContractNegotiation.php | 34 +++++ 5 files changed, 439 insertions(+) create mode 100644 app/adminapi/controller/contract/SubcontractingContractNegotiationController.php create mode 100644 app/adminapi/lists/contract/SubcontractingContractNegotiationLists.php create mode 100644 app/adminapi/logic/contract/SubcontractingContractNegotiationLogic.php create mode 100644 app/adminapi/validate/contract/SubcontractingContractNegotiationValidate.php create mode 100644 app/common/model/contract/SubcontractingContractNegotiation.php diff --git a/app/adminapi/controller/contract/SubcontractingContractNegotiationController.php b/app/adminapi/controller/contract/SubcontractingContractNegotiationController.php new file mode 100644 index 000000000..266e53242 --- /dev/null +++ b/app/adminapi/controller/contract/SubcontractingContractNegotiationController.php @@ -0,0 +1,108 @@ +dataLists(new SubcontractingContractNegotiationLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/12 17:21 + */ + public function add() + { + $params = (new SubcontractingContractNegotiationValidate())->post()->goCheck('add'); + $result = SubcontractingContractNegotiationLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(SubcontractingContractNegotiationLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/12 17:21 + */ + public function edit() + { + $params = (new SubcontractingContractNegotiationValidate())->post()->goCheck('edit'); + $result = SubcontractingContractNegotiationLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(SubcontractingContractNegotiationLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/12 17:21 + */ + public function delete() + { + $params = (new SubcontractingContractNegotiationValidate())->post()->goCheck('delete'); + SubcontractingContractNegotiationLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/12 17:21 + */ + public function detail() + { + $params = (new SubcontractingContractNegotiationValidate())->goCheck('detail'); + $result = SubcontractingContractNegotiationLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/contract/SubcontractingContractNegotiationLists.php b/app/adminapi/lists/contract/SubcontractingContractNegotiationLists.php new file mode 100644 index 000000000..d08afcece --- /dev/null +++ b/app/adminapi/lists/contract/SubcontractingContractNegotiationLists.php @@ -0,0 +1,77 @@ + ['contract_id', 'negotiation_name', 'negotiation_no', 'negotiation_type'], + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/12/12 17:21 + */ + public function lists(): array + { + return SubcontractingContractNegotiation::where($this->searchWhere) + ->field(['id', 'contract_id', 'negotiation_name', 'negotiation_no', 'negotiation_amount', 'negotiation_type', 'warranty_amount', 'Warranty_expire_date', 'negotiation_content', 'negotiation_detail', 'negotiation_quotation', 'negotiation_basis']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author likeadmin + * @date 2023/12/12 17:21 + */ + public function count(): int + { + return SubcontractingContractNegotiation::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/contract/SubcontractingContractNegotiationLogic.php b/app/adminapi/logic/contract/SubcontractingContractNegotiationLogic.php new file mode 100644 index 000000000..05876a0bb --- /dev/null +++ b/app/adminapi/logic/contract/SubcontractingContractNegotiationLogic.php @@ -0,0 +1,126 @@ + $params['contract_id'], + 'negotiation_name' => $params['negotiation_name'], + 'negotiation_no' => $params['negotiation_no'], + 'negotiation_amount' => $params['negotiation_amount'], + 'negotiation_type' => $params['negotiation_type'], + 'warranty_amount' => $params['warranty_amount'], + 'Warranty_expire_date' => $params['Warranty_expire_date'], + 'negotiation_content' => $params['negotiation_content'], + 'negotiation_detail' => $params['negotiation_detail'], + 'negotiation_quotation' => $params['negotiation_quotation'], + 'negotiation_basis' => $params['negotiation_basis'], + ]); + + 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 17:21 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + SubcontractingContractNegotiation::where('id', $params['id'])->update([ + 'contract_id' => $params['contract_id'], + 'negotiation_name' => $params['negotiation_name'], + 'negotiation_no' => $params['negotiation_no'], + 'negotiation_amount' => $params['negotiation_amount'], + 'negotiation_type' => $params['negotiation_type'], + 'warranty_amount' => $params['warranty_amount'], + 'Warranty_expire_date' => $params['Warranty_expire_date'], + 'negotiation_content' => $params['negotiation_content'], + 'negotiation_detail' => $params['negotiation_detail'], + 'negotiation_quotation' => $params['negotiation_quotation'], + 'negotiation_basis' => $params['negotiation_basis'], + ]); + + 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 17:21 + */ + public static function delete(array $params): bool + { + return SubcontractingContractNegotiation::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/12 17:21 + */ + public static function detail($params): array + { + return SubcontractingContractNegotiation::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/contract/SubcontractingContractNegotiationValidate.php b/app/adminapi/validate/contract/SubcontractingContractNegotiationValidate.php new file mode 100644 index 000000000..3f33dfa0e --- /dev/null +++ b/app/adminapi/validate/contract/SubcontractingContractNegotiationValidate.php @@ -0,0 +1,94 @@ + 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + ]; + + + /** + * @notes 添加场景 + * @return SubcontractingContractNegotiationValidate + * @author likeadmin + * @date 2023/12/12 17:21 + */ + public function sceneAdd() + { + return $this->remove('id', true); + } + + + /** + * @notes 编辑场景 + * @return SubcontractingContractNegotiationValidate + * @author likeadmin + * @date 2023/12/12 17:21 + */ + public function sceneEdit() + { + return $this->only(['id']); + } + + + /** + * @notes 删除场景 + * @return SubcontractingContractNegotiationValidate + * @author likeadmin + * @date 2023/12/12 17:21 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return SubcontractingContractNegotiationValidate + * @author likeadmin + * @date 2023/12/12 17:21 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/common/model/contract/SubcontractingContractNegotiation.php b/app/common/model/contract/SubcontractingContractNegotiation.php new file mode 100644 index 000000000..7eaed633b --- /dev/null +++ b/app/common/model/contract/SubcontractingContractNegotiation.php @@ -0,0 +1,34 @@ +