From e58daa28d2e9f22f6bcd7eef89e5aabd24b00f2d Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Wed, 20 Dec 2023 15:09:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=93=B6=E8=A1=8C=E8=B4=A6?= =?UTF-8?q?=E6=88=B7=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/bank/BankAccountController.php | 108 ++++++++++++++++ app/adminapi/lists/bank/BankAccountLists.php | 77 +++++++++++ app/adminapi/logic/bank/BankAccountLogic.php | 122 ++++++++++++++++++ .../validate/bank/BankAccountValidate.php | 106 +++++++++++++++ app/common/model/bank/BankAccount.php | 34 +++++ 5 files changed, 447 insertions(+) create mode 100644 app/adminapi/controller/bank/BankAccountController.php create mode 100644 app/adminapi/lists/bank/BankAccountLists.php create mode 100644 app/adminapi/logic/bank/BankAccountLogic.php create mode 100644 app/adminapi/validate/bank/BankAccountValidate.php create mode 100644 app/common/model/bank/BankAccount.php diff --git a/app/adminapi/controller/bank/BankAccountController.php b/app/adminapi/controller/bank/BankAccountController.php new file mode 100644 index 000000000..5fe1a6336 --- /dev/null +++ b/app/adminapi/controller/bank/BankAccountController.php @@ -0,0 +1,108 @@ +dataLists(new BankAccountLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/20 15:04 + */ + public function add() + { + $params = (new BankAccountValidate())->post()->goCheck('add'); + $result = BankAccountLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(BankAccountLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/20 15:04 + */ + public function edit() + { + $params = (new BankAccountValidate())->post()->goCheck('edit'); + $result = BankAccountLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(BankAccountLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/20 15:04 + */ + public function delete() + { + $params = (new BankAccountValidate())->post()->goCheck('delete'); + BankAccountLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/20 15:04 + */ + public function detail() + { + $params = (new BankAccountValidate())->goCheck('detail'); + $result = BankAccountLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/bank/BankAccountLists.php b/app/adminapi/lists/bank/BankAccountLists.php new file mode 100644 index 000000000..7b263ea1e --- /dev/null +++ b/app/adminapi/lists/bank/BankAccountLists.php @@ -0,0 +1,77 @@ + ['org_id', 'dept_id', 'account_sn', 'account'], + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/12/20 15:04 + */ + public function lists(): array + { + return BankAccount::where($this->searchWhere) + ->field(['id', 'org_id', 'dept_id', 'account_sn', 'deposit_bank', 'account_name', 'account', 'account_opening_date', 'opening_amount', 'remark']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author likeadmin + * @date 2023/12/20 15:04 + */ + public function count(): int + { + return BankAccount::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/bank/BankAccountLogic.php b/app/adminapi/logic/bank/BankAccountLogic.php new file mode 100644 index 000000000..73b155b9d --- /dev/null +++ b/app/adminapi/logic/bank/BankAccountLogic.php @@ -0,0 +1,122 @@ + $params['org_id'] ?? 0, + 'dept_id' => $params['dept_id'] ?? 0, + 'account_sn' => $params['account_sn'] ?? '', + 'deposit_bank' => $params['deposit_bank'] ?? '', + 'account_name' => $params['account_name'] ?? '', + 'account' => $params['account'] ?? '', + 'account_opening_date' => $params['account_opening_date'] ?? '', + 'opening_amount' => $params['opening_amount'] ?? 0, + 'remark' => $params['remark'] ?? '', + ]); + + 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/20 15:04 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + BankAccount::where('id', $params['id'])->update([ + 'org_id' => $params['org_id'] ?? 0, + 'dept_id' => $params['dept_id'] ?? 0, + 'account_sn' => $params['account_sn'] ?? '', + 'deposit_bank' => $params['deposit_bank'] ?? '', + 'account_name' => $params['account_name'] ?? '', + 'account' => $params['account'] ?? '', + 'account_opening_date' => $params['account_opening_date'] ?? '', + 'opening_amount' => $params['opening_amount'] ?? 0, + 'remark' => $params['remark'] ?? '', + ]); + + 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/20 15:04 + */ + public static function delete(array $params): bool + { + return BankAccount::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/20 15:04 + */ + public static function detail($params): array + { + return BankAccount::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/bank/BankAccountValidate.php b/app/adminapi/validate/bank/BankAccountValidate.php new file mode 100644 index 000000000..966f02588 --- /dev/null +++ b/app/adminapi/validate/bank/BankAccountValidate.php @@ -0,0 +1,106 @@ + 'require', + 'org_id' => 'require', + 'dept_id' => 'require', + 'deposit_bank' => 'require', + 'account_name' => 'require', + 'account' => 'require', + 'opening_amount' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'org_id' => '组织id', + 'dept_id' => '部门id', + 'deposit_bank' => '开户银行', + 'account_name' => '开户名称', + 'account' => '账号', + 'opening_amount' => '期初金额', + ]; + + + /** + * @notes 添加场景 + * @return BankAccountValidate + * @author likeadmin + * @date 2023/12/20 15:04 + */ + public function sceneAdd() + { + return $this->only(['org_id','dept_id','deposit_bank','account_name','account','opening_amount']); + } + + + /** + * @notes 编辑场景 + * @return BankAccountValidate + * @author likeadmin + * @date 2023/12/20 15:04 + */ + public function sceneEdit() + { + return $this->only(['id','org_id','dept_id','deposit_bank','account_name','account','opening_amount']); + } + + + /** + * @notes 删除场景 + * @return BankAccountValidate + * @author likeadmin + * @date 2023/12/20 15:04 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return BankAccountValidate + * @author likeadmin + * @date 2023/12/20 15:04 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/common/model/bank/BankAccount.php b/app/common/model/bank/BankAccount.php new file mode 100644 index 000000000..dafd74ee2 --- /dev/null +++ b/app/common/model/bank/BankAccount.php @@ -0,0 +1,34 @@ +