From d25a0057e7215e6ac9498b8ed9b25606cb62172a Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Mon, 18 Dec 2023 10:35:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=80=80=E6=8A=95=E6=A0=87?= =?UTF-8?q?=E4=BF=9D=E8=AF=81=E9=87=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bid/BidSecurityRefundController.php | 108 +++++++++++++++ .../lists/bid/BidSecurityRefundLists.php | 87 ++++++++++++ .../logic/bid/BidSecurityRefundLogic.php | 131 ++++++++++++++++++ .../bid/BidSecurityRefundValidate.php | 102 ++++++++++++++ app/common/model/bid/BidSecurityRefund.php | 45 ++++++ 5 files changed, 473 insertions(+) create mode 100644 app/adminapi/controller/bid/BidSecurityRefundController.php create mode 100644 app/adminapi/lists/bid/BidSecurityRefundLists.php create mode 100644 app/adminapi/logic/bid/BidSecurityRefundLogic.php create mode 100644 app/adminapi/validate/bid/BidSecurityRefundValidate.php create mode 100644 app/common/model/bid/BidSecurityRefund.php diff --git a/app/adminapi/controller/bid/BidSecurityRefundController.php b/app/adminapi/controller/bid/BidSecurityRefundController.php new file mode 100644 index 000000000..b05cfeab4 --- /dev/null +++ b/app/adminapi/controller/bid/BidSecurityRefundController.php @@ -0,0 +1,108 @@ +dataLists(new BidSecurityRefundLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/18 10:29 + */ + public function add() + { + $params = (new BidSecurityRefundValidate())->post()->goCheck('add'); + $result = BidSecurityRefundLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(BidSecurityRefundLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/18 10:29 + */ + public function edit() + { + $params = (new BidSecurityRefundValidate())->post()->goCheck('edit'); + $result = BidSecurityRefundLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(BidSecurityRefundLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/18 10:29 + */ + public function delete() + { + $params = (new BidSecurityRefundValidate())->post()->goCheck('delete'); + BidSecurityRefundLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/18 10:29 + */ + public function detail() + { + $params = (new BidSecurityRefundValidate())->goCheck('detail'); + $result = BidSecurityRefundLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/bid/BidSecurityRefundLists.php b/app/adminapi/lists/bid/BidSecurityRefundLists.php new file mode 100644 index 000000000..3ffb9a4e1 --- /dev/null +++ b/app/adminapi/lists/bid/BidSecurityRefundLists.php @@ -0,0 +1,87 @@ + ['bidding_decision_id', 'refund_date', 'bank_account_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 10:29 + */ + public function lists(): array + { + return Db::name('BidSecurityRefund')->alias('bsr') + ->where($this->searchWhere) + ->leftJoin('bid_bidding_decision bbd','bbd.id = bsr.bidding_decision_id') + ->leftJoin('project p','p.id = bbd.project_id') + ->leftJoin('custom ct','ct.id = p.custom_id') + ->field('bsr.*, bbd.project_id, p.name as project_name, ct.name as customer_name') + ->limit($this->limitOffset, $this->limitLength) + ->order(['bsr.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 10:29 + */ + public function count(): int + { + return BidSecurityRefund::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/bid/BidSecurityRefundLogic.php b/app/adminapi/logic/bid/BidSecurityRefundLogic.php new file mode 100644 index 000000000..ad41cd47f --- /dev/null +++ b/app/adminapi/logic/bid/BidSecurityRefundLogic.php @@ -0,0 +1,131 @@ + $params['bidding_decision_id'] ?? 0, + 'refund_amount' => $params['refund_amount'] ?? 0, + 'refund_amount_daxie' => $params['refund_amount_daxie'] ?? '', + 'refund_date' => $params['refund_date'] ?? '', + 'remark' => $params['remark'] ?? '', + 'annex' => $params['annex'] ?? '', + 'bank_account_id' => $params['bank_account_id'] ?? 0, + 'is_calculate_interest' => $params['is_calculate_interest'] ?? 0, + 'interest_calculation_start_date' => $params['interest_calculation_start_date'] ?? '', + ]); + + 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 10:29 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + BidSecurityRefund::where('id', $params['id'])->update([ + 'bidding_decision_id' => $params['bidding_decision_id'] ?? 0, + 'refund_amount' => $params['refund_amount'] ?? 0, + 'refund_amount_daxie' => $params['refund_amount_daxie'] ?? '', + 'refund_date' => $params['refund_date'] ?? '', + 'remark' => $params['remark'] ?? '', + 'annex' => $params['annex'] ?? '', + 'bank_account_id' => $params['bank_account_id'] ?? 0, + 'is_calculate_interest' => $params['is_calculate_interest'] ?? 0, + 'interest_calculation_start_date' => $params['interest_calculation_start_date'] ?? '', + ]); + + 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 10:29 + */ + public static function delete(array $params): bool + { + return BidSecurityRefund::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/18 10:29 + */ + public static function detail($params): array + { + $bidSecurityRefund = BidSecurityRefund::findOrEmpty($params['id']); + $bidSecurityRefund->project = null; + $bidSecurityRefund->custom = null; + if (!empty($bidSecurityRefund->decision->project_id)) { + $bidSecurityRefund->project = Project::findOrEmpty($bidSecurityApply->decision->project_id); + } + if (!empty($bidSecurityRefund->project->custom_id)) { + $bidSecurityRefund->custom = Custom::findOrEmpty($bidSecurityApply->project->custom_id); + } + return $bidSecurityRefund->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/bid/BidSecurityRefundValidate.php b/app/adminapi/validate/bid/BidSecurityRefundValidate.php new file mode 100644 index 000000000..0cee6477d --- /dev/null +++ b/app/adminapi/validate/bid/BidSecurityRefundValidate.php @@ -0,0 +1,102 @@ + 'require', + 'bidding_decision_id' => 'require', + 'refund_amount' => 'require', + 'refund_date' => 'require', + 'bank_account_id' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'bidding_decision_id' => '投标决策id', + 'refund_amount' => '退款金额', + 'refund_date' => '退款日期', + 'bank_account_id' => '银行账号id', + ]; + + + /** + * @notes 添加场景 + * @return BidSecurityRefundValidate + * @author likeadmin + * @date 2023/12/18 10:29 + */ + public function sceneAdd() + { + return $this->only(['bidding_decision_id','refund_amount','refund_date','bank_account_id']); + } + + + /** + * @notes 编辑场景 + * @return BidSecurityRefundValidate + * @author likeadmin + * @date 2023/12/18 10:29 + */ + public function sceneEdit() + { + return $this->only(['id','bidding_decision_id','refund_amount','refund_date','bank_account_id']); + } + + + /** + * @notes 删除场景 + * @return BidSecurityRefundValidate + * @author likeadmin + * @date 2023/12/18 10:29 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return BidSecurityRefundValidate + * @author likeadmin + * @date 2023/12/18 10:29 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/common/model/bid/BidSecurityRefund.php b/app/common/model/bid/BidSecurityRefund.php new file mode 100644 index 000000000..12804ff09 --- /dev/null +++ b/app/common/model/bid/BidSecurityRefund.php @@ -0,0 +1,45 @@ +belongsTo(\app\common\model\bid\BidBiddingDecision::class, 'bidding_decision_id'); + } + +} \ No newline at end of file