From 529b8cc2b31c2a460faf00ea9f10d5daa6fc0ec1 Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Tue, 19 Dec 2023 14:57:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=A1=8C=E6=94=BF=E6=94=B6?= =?UTF-8?q?=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AdministrativePaymentsController.php | 108 ++++++++++++++ .../AdministrativePaymentsLists.php | 94 +++++++++++++ .../AdministrativePaymentsLogic.php | 132 ++++++++++++++++++ .../AdministrativePaymentsValidate.php | 104 ++++++++++++++ .../administrative/AdministrativePayments.php | 45 ++++++ 5 files changed, 483 insertions(+) create mode 100644 app/adminapi/controller/administrative/AdministrativePaymentsController.php create mode 100644 app/adminapi/lists/administrative/AdministrativePaymentsLists.php create mode 100644 app/adminapi/logic/administrative/AdministrativePaymentsLogic.php create mode 100644 app/adminapi/validate/administrative/AdministrativePaymentsValidate.php create mode 100644 app/common/model/administrative/AdministrativePayments.php diff --git a/app/adminapi/controller/administrative/AdministrativePaymentsController.php b/app/adminapi/controller/administrative/AdministrativePaymentsController.php new file mode 100644 index 000000000..f8b758c42 --- /dev/null +++ b/app/adminapi/controller/administrative/AdministrativePaymentsController.php @@ -0,0 +1,108 @@ +dataLists(new AdministrativePaymentsLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/19 14:50 + */ + public function add() + { + $params = (new AdministrativePaymentsValidate())->post()->goCheck('add'); + $result = AdministrativePaymentsLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(AdministrativePaymentsLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/19 14:50 + */ + public function edit() + { + $params = (new AdministrativePaymentsValidate())->post()->goCheck('edit'); + $result = AdministrativePaymentsLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(AdministrativePaymentsLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/19 14:50 + */ + public function delete() + { + $params = (new AdministrativePaymentsValidate())->post()->goCheck('delete'); + AdministrativePaymentsLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/19 14:50 + */ + public function detail() + { + $params = (new AdministrativePaymentsValidate())->goCheck('detail'); + $result = AdministrativePaymentsLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/administrative/AdministrativePaymentsLists.php b/app/adminapi/lists/administrative/AdministrativePaymentsLists.php new file mode 100644 index 000000000..2e59af68d --- /dev/null +++ b/app/adminapi/lists/administrative/AdministrativePaymentsLists.php @@ -0,0 +1,94 @@ + ['ap.org_id', 'ap.dept_id', 'ap.approve_id', 'ap.administrative_contract_id', 'ap.pay_type'], + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/12/19 14:50 + */ + public function lists(): array + { + return Db::name('AdministrativePayments')->alias('ap') + ->where($this->searchWhere) + ->whereNull('ap.delete_time') + ->leftJoin('orgs o','o.id = ap.org_id') + ->leftJoin('dept d','d.id = ap.dept_id') + ->leftJoin('administrative_contract ac','ac.id = ap.administrative_contract_id') + ->field('ap.*, d.name as dept_name, o.name as org_name, ac.supplier_id, ac.contract_no, ac.contract_name') + ->limit($this->limitOffset, $this->limitLength) + ->order(['ap.id' => 'desc']) + ->select()->each(function($item, $key){ + //关联数据后续添加 + $item['supplier_name'] = '供应商名称'; + $item['approve_no'] = '付款单号'; + $item['approve_step'] = '流程步骤'; + $item['approve_settle_status'] = 1; + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author likeadmin + * @date 2023/12/19 14:50 + */ + public function count(): int + { + return Db::name('AdministrativePayments')->alias('ap') + ->where($this->searchWhere) + ->whereNull('ap.delete_time') + ->leftJoin('orgs o','o.id = ap.org_id') + ->leftJoin('dept d','d.id = ap.dept_id') + ->leftJoin('administrative_contract ac','ac.id = ap.administrative_contract_id')->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/administrative/AdministrativePaymentsLogic.php b/app/adminapi/logic/administrative/AdministrativePaymentsLogic.php new file mode 100644 index 000000000..4a65d33ca --- /dev/null +++ b/app/adminapi/logic/administrative/AdministrativePaymentsLogic.php @@ -0,0 +1,132 @@ + $params['org_id'] ?? 0, + 'dept_id' => $params['dept_id'] ?? 0, + 'approve_id' => $params['approve_id'] ?? 0, + 'administrative_contract_id' => $params['administrative_contract_id'] ?? 0, + 'applier' => $params['applier'] ?? '', + 'apply_date' => $params['apply_date'] ?? '', + 'pay_type' => $params['pay_type'] ?? 0, + 'payment_rate' => $params['payment_rate'] ?? 0, + 'payment_amount' => $params['payment_amount'] ?? 0, + 'remark' => $params['remark'] ?? '', + 'annex' => $params['annex'] ?? '', + 'deposit_bank' => $params['deposit_bank'] ?? '', + 'account_name' => $params['account_name'] ?? '', + 'account' => $params['account'] ?? '', + ]); + + 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/19 14:50 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + AdministrativePayments::where('id', $params['id'])->update([ + 'org_id' => $params['org_id'], + 'dept_id' => $params['dept_id'], + 'approve_id' => $params['approve_id'], + 'administrative_contract_id' => $params['administrative_contract_id'], + 'applier' => $params['applier'], + 'apply_date' => $params['apply_date'], + 'pay_type' => $params['pay_type'], + 'payment_rate' => $params['payment_rate'], + 'payment_amount' => $params['payment_amount'], + 'remark' => $params['remark'], + 'annex' => $params['annex'], + 'deposit_bank' => $params['deposit_bank'], + 'account_name' => $params['account_name'], + 'account' => $params['account'], + ]); + + 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/19 14:50 + */ + public static function delete(array $params): bool + { + return AdministrativePayments::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/19 14:50 + */ + public static function detail($params): array + { + return AdministrativePayments::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/administrative/AdministrativePaymentsValidate.php b/app/adminapi/validate/administrative/AdministrativePaymentsValidate.php new file mode 100644 index 000000000..8f1fa7859 --- /dev/null +++ b/app/adminapi/validate/administrative/AdministrativePaymentsValidate.php @@ -0,0 +1,104 @@ + 'require', + 'org_id' => 'require', + 'dept_id' => 'require', + 'approve_id' => 'require', + 'pay_type' => 'require', + 'payment_amount' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'org_id' => '组织id', + 'dept_id' => '部门id', + 'approve_id' => '审批id', + 'pay_type' => '付款方式', + 'payment_amount' => '本次支付金额', + ]; + + + /** + * @notes 添加场景 + * @return AdministrativePaymentsValidate + * @author likeadmin + * @date 2023/12/19 14:50 + */ + public function sceneAdd() + { + return $this->only(['org_id','dept_id','approve_id','pay_type','payment_amount']); + } + + + /** + * @notes 编辑场景 + * @return AdministrativePaymentsValidate + * @author likeadmin + * @date 2023/12/19 14:50 + */ + public function sceneEdit() + { + return $this->only(['id','org_id','dept_id','approve_id','pay_type','payment_amount']); + } + + + /** + * @notes 删除场景 + * @return AdministrativePaymentsValidate + * @author likeadmin + * @date 2023/12/19 14:50 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return AdministrativePaymentsValidate + * @author likeadmin + * @date 2023/12/19 14:50 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/common/model/administrative/AdministrativePayments.php b/app/common/model/administrative/AdministrativePayments.php new file mode 100644 index 000000000..ef4554323 --- /dev/null +++ b/app/common/model/administrative/AdministrativePayments.php @@ -0,0 +1,45 @@ +hasOne(\app\common\model\contract\AdministrativeContract::class, 'id', 'administrative_contract_id'); + } + +} \ No newline at end of file