From 0289dce0f1ecc1bfa27e40d2473d9b1765425d7e Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Wed, 20 Dec 2023 16:06:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=93=B6=E8=A1=8C=E6=94=B6?= =?UTF-8?q?=E6=94=AF=E6=B5=81=E6=B0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RevenueExpenditureStatementController.php | 108 ++++++++++++++ app/adminapi/lists/bank/BankAccountLists.php | 4 +- .../bank/RevenueExpenditureStatementLists.php | 90 ++++++++++++ .../bank/RevenueExpenditureStatementLogic.php | 136 ++++++++++++++++++ .../RevenueExpenditureStatementValidate.php | 102 +++++++++++++ .../bank/RevenueExpenditureStatement.php | 45 ++++++ 6 files changed, 483 insertions(+), 2 deletions(-) create mode 100644 app/adminapi/controller/bank/RevenueExpenditureStatementController.php create mode 100644 app/adminapi/lists/bank/RevenueExpenditureStatementLists.php create mode 100644 app/adminapi/logic/bank/RevenueExpenditureStatementLogic.php create mode 100644 app/adminapi/validate/bank/RevenueExpenditureStatementValidate.php create mode 100644 app/common/model/bank/RevenueExpenditureStatement.php diff --git a/app/adminapi/controller/bank/RevenueExpenditureStatementController.php b/app/adminapi/controller/bank/RevenueExpenditureStatementController.php new file mode 100644 index 000000000..625c6af75 --- /dev/null +++ b/app/adminapi/controller/bank/RevenueExpenditureStatementController.php @@ -0,0 +1,108 @@ +dataLists(new RevenueExpenditureStatementLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/20 15:51 + */ + public function add() + { + $params = (new RevenueExpenditureStatementValidate())->post()->goCheck('add'); + $result = RevenueExpenditureStatementLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(RevenueExpenditureStatementLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/20 15:51 + */ + public function edit() + { + $params = (new RevenueExpenditureStatementValidate())->post()->goCheck('edit'); + $result = RevenueExpenditureStatementLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(RevenueExpenditureStatementLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/20 15:51 + */ + public function delete() + { + $params = (new RevenueExpenditureStatementValidate())->post()->goCheck('delete'); + RevenueExpenditureStatementLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/20 15:51 + */ + public function detail() + { + $params = (new RevenueExpenditureStatementValidate())->goCheck('detail'); + $result = RevenueExpenditureStatementLogic::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 index 7b263ea1e..bbc0b48f1 100644 --- a/app/adminapi/lists/bank/BankAccountLists.php +++ b/app/adminapi/lists/bank/BankAccountLists.php @@ -15,7 +15,7 @@ namespace app\adminapi\lists\bank; -use app\adminapi\lists\BaseAdminDataLists; +use app\adminapi\lists\BaseAdminDataLists; use app\common\model\bank\BankAccount; use app\common\lists\ListsSearchInterface; @@ -38,7 +38,7 @@ class BankAccountLists extends BaseAdminDataLists implements ListsSearchInterfac public function setSearch(): array { return [ - '=' => ['org_id', 'dept_id', 'account_sn', 'account'], + '=' => ['org_id', 'dept_id', 'account_sn', 'account'], ]; } diff --git a/app/adminapi/lists/bank/RevenueExpenditureStatementLists.php b/app/adminapi/lists/bank/RevenueExpenditureStatementLists.php new file mode 100644 index 000000000..96c7b918b --- /dev/null +++ b/app/adminapi/lists/bank/RevenueExpenditureStatementLists.php @@ -0,0 +1,90 @@ + ['org_id', 'dept_id', 'document_type'], + ]; + } + + + /** + * @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:51 + */ + public function lists(): array + { + return Db::name('RevenueExpenditureStatement')->alias('res') + ->where($this->searchWhere) + ->whereNull('res.delete_time') + ->leftJoin('orgs o','o.id = res.org_id') + ->leftJoin('dept d','d.id = res.dept_id') + ->leftJoin('bank_account ba','ba.id = res.bank_account_id') + ->field('res.*, ba.account_sn, ba.deposit_bank, ba.account_name, ba.account, d.name as dept_name, o.name as org_name') + ->limit($this->limitOffset, $this->limitLength) + ->order(['res.id' => 'desc']) + ->select()->each(function($item, $key){ + //关联数据后续添加 + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author likeadmin + * @date 2023/12/20 15:51 + */ + public function count(): int + { + return Db::name('RevenueExpenditureStatement')->alias('res') + ->where($this->searchWhere) + ->whereNull('res.delete_time') + ->leftJoin('orgs o','o.id = res.org_id') + ->leftJoin('dept d','d.id = res.dept_id') + ->leftJoin('bank_account ba','ba.id = res.bank_account_id')->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/bank/RevenueExpenditureStatementLogic.php b/app/adminapi/logic/bank/RevenueExpenditureStatementLogic.php new file mode 100644 index 000000000..eefcbd57b --- /dev/null +++ b/app/adminapi/logic/bank/RevenueExpenditureStatementLogic.php @@ -0,0 +1,136 @@ + $params['org_id'] ?? 0, + 'dept_id' => $params['dept_id'] ?? 0, + 'document_type' => $params['document_type'] ?? 0, + 'document_no' => $params['document_no'] ?? '', + 'contract_id' => $params['contract_id'] ?? 0, + 'contract_type' => $params['contract_type'] ?? 0, + 'bank_account_id' => $params['bank_account_id'] ?? 0, + 'create_date' => $params['create_date'] ?? '', + 'handled_by' => $params['handled_by'] ?? 0, + 'amount' => $params['amount'] ?? 0, + 'is_generate_vouchers' => $params['is_generate_vouchers'] ?? 0, + 'vouchers_sn' => $params['vouchers_sn'] ?? '', + 'is_interest' => $params['is_interest'] ?? 0, + 'interest_date' => $params['interest_date'] ?? '', + 'remark' => $params['remark'] ?? '', + 'annex' => $params['annex'] ?? '', + ]); + + 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:51 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + RevenueExpenditureStatement::where('id', $params['id'])->update([ + 'org_id' => $params['org_id'] ?? 0, + 'dept_id' => $params['dept_id'] ?? 0, + 'document_type' => $params['document_type'] ?? 0, + 'document_no' => $params['document_no'] ?? '', + 'contract_id' => $params['contract_id'] ?? 0, + 'contract_type' => $params['contract_type'] ?? 0, + 'bank_account_id' => $params['bank_account_id'] ?? 0, + 'create_date' => $params['create_date'] ?? '', + 'handled_by' => $params['handled_by'] ?? 0, + 'amount' => $params['amount'] ?? 0, + 'is_generate_vouchers' => $params['is_generate_vouchers'] ?? 0, + 'vouchers_sn' => $params['vouchers_sn'] ?? '', + 'is_interest' => $params['is_interest'] ?? 0, + 'interest_date' => $params['interest_date'] ?? '', + 'remark' => $params['remark'] ?? '', + 'annex' => $params['annex'] ?? '', + ]); + + 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:51 + */ + public static function delete(array $params): bool + { + return RevenueExpenditureStatement::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/20 15:51 + */ + public static function detail($params): array + { + return RevenueExpenditureStatement::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/bank/RevenueExpenditureStatementValidate.php b/app/adminapi/validate/bank/RevenueExpenditureStatementValidate.php new file mode 100644 index 000000000..a8d5b0ef2 --- /dev/null +++ b/app/adminapi/validate/bank/RevenueExpenditureStatementValidate.php @@ -0,0 +1,102 @@ + 'require', + 'org_id' => 'require', + 'dept_id' => 'require', + 'document_type' => 'require', + 'amount' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'org_id' => '组织id', + 'dept_id' => '部门id', + 'document_type' => '单据类型', + 'amount' => '金额', + ]; + + + /** + * @notes 添加场景 + * @return RevenueExpenditureStatementValidate + * @author likeadmin + * @date 2023/12/20 15:51 + */ + public function sceneAdd() + { + return $this->only(['org_id','dept_id','document_type','amount']); + } + + + /** + * @notes 编辑场景 + * @return RevenueExpenditureStatementValidate + * @author likeadmin + * @date 2023/12/20 15:51 + */ + public function sceneEdit() + { + return $this->only(['id','org_id','dept_id','document_type','amount']); + } + + + /** + * @notes 删除场景 + * @return RevenueExpenditureStatementValidate + * @author likeadmin + * @date 2023/12/20 15:51 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return RevenueExpenditureStatementValidate + * @author likeadmin + * @date 2023/12/20 15:51 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/common/model/bank/RevenueExpenditureStatement.php b/app/common/model/bank/RevenueExpenditureStatement.php new file mode 100644 index 000000000..e76052ad7 --- /dev/null +++ b/app/common/model/bank/RevenueExpenditureStatement.php @@ -0,0 +1,45 @@ +hasOne(\app\common\model\bank\BankAccount::class, 'id', 'bank_account_id'); + } + +} \ No newline at end of file