From 7b885dd3f5b3ff80d9243f3e2cdcca7ccbb1e464 Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Fri, 15 Dec 2023 11:15:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=94=B6=E6=AC=BE=E8=AE=A1?= =?UTF-8?q?=E5=88=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../finance/FinancePaymentPlanController.php | 108 ++++++++++++++ .../FinanceReceiptRecordController.php | 108 ++++++++++++++ .../lists/finance/FinancePaymentPlanLists.php | 77 ++++++++++ .../finance/FinanceReceiptRecordLists.php | 86 +++++++++++ .../logic/finance/FinancePaymentPlanLogic.php | 122 +++++++++++++++ .../finance/FinanceReceiptRecordLogic.php | 139 ++++++++++++++++++ .../finance/FinancePaymentPlanValidate.php | 106 +++++++++++++ .../finance/FinanceReceiptRecordValidate.php | 96 ++++++++++++ .../model/finance/FinancePaymentPlan.php | 34 +++++ .../model/finance/FinanceReceiptRecord.php | 37 +++++ 10 files changed, 913 insertions(+) create mode 100644 app/adminapi/controller/finance/FinancePaymentPlanController.php create mode 100644 app/adminapi/controller/finance/FinanceReceiptRecordController.php create mode 100644 app/adminapi/lists/finance/FinancePaymentPlanLists.php create mode 100644 app/adminapi/lists/finance/FinanceReceiptRecordLists.php create mode 100644 app/adminapi/logic/finance/FinancePaymentPlanLogic.php create mode 100644 app/adminapi/logic/finance/FinanceReceiptRecordLogic.php create mode 100644 app/adminapi/validate/finance/FinancePaymentPlanValidate.php create mode 100644 app/adminapi/validate/finance/FinanceReceiptRecordValidate.php create mode 100644 app/common/model/finance/FinancePaymentPlan.php create mode 100644 app/common/model/finance/FinanceReceiptRecord.php diff --git a/app/adminapi/controller/finance/FinancePaymentPlanController.php b/app/adminapi/controller/finance/FinancePaymentPlanController.php new file mode 100644 index 000000000..d190f88b5 --- /dev/null +++ b/app/adminapi/controller/finance/FinancePaymentPlanController.php @@ -0,0 +1,108 @@ +dataLists(new FinancePaymentPlanLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/15 11:14 + */ + public function add() + { + $params = (new FinancePaymentPlanValidate())->post()->goCheck('add'); + $result = FinancePaymentPlanLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(FinancePaymentPlanLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/15 11:14 + */ + public function edit() + { + $params = (new FinancePaymentPlanValidate())->post()->goCheck('edit'); + $result = FinancePaymentPlanLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(FinancePaymentPlanLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/15 11:14 + */ + public function delete() + { + $params = (new FinancePaymentPlanValidate())->post()->goCheck('delete'); + FinancePaymentPlanLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/15 11:14 + */ + public function detail() + { + $params = (new FinancePaymentPlanValidate())->goCheck('detail'); + $result = FinancePaymentPlanLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/finance/FinanceReceiptRecordController.php b/app/adminapi/controller/finance/FinanceReceiptRecordController.php new file mode 100644 index 000000000..21b2c374d --- /dev/null +++ b/app/adminapi/controller/finance/FinanceReceiptRecordController.php @@ -0,0 +1,108 @@ +dataLists(new FinanceReceiptRecordLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/15 10:20 + */ + public function add() + { + $params = (new FinanceReceiptRecordValidate())->post()->goCheck('add'); + $result = FinanceReceiptRecordLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(FinanceReceiptRecordLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/15 10:20 + */ + public function edit() + { + $params = (new FinanceReceiptRecordValidate())->post()->goCheck('edit'); + $result = FinanceReceiptRecordLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(FinanceReceiptRecordLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/15 10:20 + */ + public function delete() + { + $params = (new FinanceReceiptRecordValidate())->post()->goCheck('delete'); + FinanceReceiptRecordLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/15 10:20 + */ + public function detail() + { + $params = (new FinanceReceiptRecordValidate())->goCheck('detail'); + $result = FinanceReceiptRecordLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/finance/FinancePaymentPlanLists.php b/app/adminapi/lists/finance/FinancePaymentPlanLists.php new file mode 100644 index 000000000..552a74a15 --- /dev/null +++ b/app/adminapi/lists/finance/FinancePaymentPlanLists.php @@ -0,0 +1,77 @@ + ['contract_id'], + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/12/15 11:14 + */ + public function lists(): array + { + return FinancePaymentPlan::where($this->searchWhere) + ->field(['id', 'supplier_id', 'contract_id', 'period', 'pay_date', 'amount', 'foreign_currency_remark', 'status', 'remark', 'annex']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author likeadmin + * @date 2023/12/15 11:14 + */ + public function count(): int + { + return FinancePaymentPlan::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/finance/FinanceReceiptRecordLists.php b/app/adminapi/lists/finance/FinanceReceiptRecordLists.php new file mode 100644 index 000000000..ffc786ca1 --- /dev/null +++ b/app/adminapi/lists/finance/FinanceReceiptRecordLists.php @@ -0,0 +1,86 @@ + ['frr.supplier_id', 'frr.contract_id', 'frr.commitor', 'frr.invoice_type', 'frr.invoice_no'], + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/12/15 10:20 + */ + public function lists(): array + { + return Db::name('FinanceReceiptRecord')->alias('frr') + ->where($this->searchWhere) + ->leftJoin('procurement_contract pc','pc.id = frr.contract_id') + ->leftJoin('project p','p.id = pc.project_id') + ->field('frr.*, p.name, p.id as project_id, p.name as project_name, pc.contract_no') + ->limit($this->limitOffset, $this->limitLength) + ->order(['frr.id' => 'desc']) + ->select()->each(function($item, $key){ + //关联数据 供应商后续添加 + $item['supplier_name'] = '供应商名称'; + $item['contract_type'] = '1'; + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author likeadmin + * @date 2023/12/15 10:20 + */ + public function count(): int + { + return FinanceReceiptRecord::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/finance/FinancePaymentPlanLogic.php b/app/adminapi/logic/finance/FinancePaymentPlanLogic.php new file mode 100644 index 000000000..b47f6bb61 --- /dev/null +++ b/app/adminapi/logic/finance/FinancePaymentPlanLogic.php @@ -0,0 +1,122 @@ + $params['supplier_id'], + 'contract_id' => $params['contract_id'], + 'period' => $params['period'], + 'pay_date' => $params['pay_date'], + 'amount' => $params['amount'], + 'foreign_currency_remark' => $params['foreign_currency_remark'], + 'status' => $params['status'], + '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/15 11:14 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + FinancePaymentPlan::where('id', $params['id'])->update([ + 'supplier_id' => $params['supplier_id'], + 'contract_id' => $params['contract_id'], + 'period' => $params['period'], + 'pay_date' => $params['pay_date'], + 'amount' => $params['amount'], + 'foreign_currency_remark' => $params['foreign_currency_remark'], + 'status' => $params['status'], + '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/15 11:14 + */ + public static function delete(array $params): bool + { + return FinancePaymentPlan::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/15 11:14 + */ + public static function detail($params): array + { + return FinancePaymentPlan::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/finance/FinanceReceiptRecordLogic.php b/app/adminapi/logic/finance/FinanceReceiptRecordLogic.php new file mode 100644 index 000000000..e6caa176b --- /dev/null +++ b/app/adminapi/logic/finance/FinanceReceiptRecordLogic.php @@ -0,0 +1,139 @@ + $params['supplier_id'] ?? 0, + 'contract_id' => $params['contract_id'] ?? 0, + 'invoicing_date' => $params['invoicing_date'] ?? '', + 'commitor' => $params['commitor'] ?? '', + 'invoice_type' => $params['invoice_type'] ?? 0, + 'invoice_no' => $params['invoice_no'] ?? '', + 'invoice_amount' => $params['invoice_amount'] ?? 0, + 'invoice_amount_daxie' => $params['invoice_amount_daxie'] ?? '', + 'invoice_tax_rate' => $params['invoice_tax_rate'] ?? 0, + 'tax' => $params['tax'] ?? 0, + 'amount_excluding_tax' => $params['amount_excluding_tax'] ?? 0, + 'receipt_date' => $params['receipt_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/15 10:20 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + FinanceReceiptRecord::where('id', $params['id'])->update([ + 'supplier_id' => $params['supplier_id'] ?? 0, + 'contract_id' => $params['contract_id'] ?? 0, + 'invoicing_date' => $params['invoicing_date'] ?? '', + 'commitor' => $params['commitor'] ?? '', + 'invoice_type' => $params['invoice_type'] ?? 0, + 'invoice_no' => $params['invoice_no'] ?? '', + 'invoice_amount' => $params['invoice_amount'] ?? 0, + 'invoice_amount_daxie' => $params['invoice_amount_daxie'] ?? '', + 'invoice_tax_rate' => $params['invoice_tax_rate'] ?? 0, + 'tax' => $params['tax'] ?? 0, + 'amount_excluding_tax' => $params['amount_excluding_tax'] ?? 0, + 'receipt_date' => $params['receipt_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/15 10:20 + */ + public static function delete(array $params): bool + { + return FinanceReceiptRecord::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/15 10:20 + */ + public static function detail($params): array + { + $financeReceiptRecord = FinanceReceiptRecord::findOrEmpty($params['id']); + $financeReceiptRecord->contract; + $financeReceiptRecord->project = null; + if (!empty($financeReceiptRecord->contract->project_id)) { + $financeReceiptRecord->project = Project::findOrEmpty($financeReceiptRecord->contract->project_id); + } + return $financeReceiptRecord->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/finance/FinancePaymentPlanValidate.php b/app/adminapi/validate/finance/FinancePaymentPlanValidate.php new file mode 100644 index 000000000..6f9da2f5f --- /dev/null +++ b/app/adminapi/validate/finance/FinancePaymentPlanValidate.php @@ -0,0 +1,106 @@ + 'require', + 'supplier_id' => 'require', + 'contract_id' => 'require', + 'period' => 'require', + 'pay_date' => 'require', + 'amount' => 'require', + 'status' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'supplier_id' => '供应商id', + 'contract_id' => '合同id', + 'period' => '期次', + 'pay_date' => '计划付款日期', + 'amount' => '金额', + 'status' => '状态', + ]; + + + /** + * @notes 添加场景 + * @return FinancePaymentPlanValidate + * @author likeadmin + * @date 2023/12/15 11:14 + */ + public function sceneAdd() + { + return $this->only(['supplier_id','contract_id','period','pay_date','amount','status']); + } + + + /** + * @notes 编辑场景 + * @return FinancePaymentPlanValidate + * @author likeadmin + * @date 2023/12/15 11:14 + */ + public function sceneEdit() + { + return $this->only(['id','supplier_id','contract_id','period','pay_date','amount','status']); + } + + + /** + * @notes 删除场景 + * @return FinancePaymentPlanValidate + * @author likeadmin + * @date 2023/12/15 11:14 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return FinancePaymentPlanValidate + * @author likeadmin + * @date 2023/12/15 11:14 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/finance/FinanceReceiptRecordValidate.php b/app/adminapi/validate/finance/FinanceReceiptRecordValidate.php new file mode 100644 index 000000000..963f303c1 --- /dev/null +++ b/app/adminapi/validate/finance/FinanceReceiptRecordValidate.php @@ -0,0 +1,96 @@ + 'require', + 'supplier_id' => 'require', + 'contract_id' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + ]; + + + /** + * @notes 添加场景 + * @return FinanceReceiptRecordValidate + * @author likeadmin + * @date 2023/12/15 10:20 + */ + public function sceneAdd() + { + return $this->remove('id', true); + } + + + /** + * @notes 编辑场景 + * @return FinanceReceiptRecordValidate + * @author likeadmin + * @date 2023/12/15 10:20 + */ + public function sceneEdit() + { + return $this->only(['id', 'supplier_id', 'contract_id']); + } + + + /** + * @notes 删除场景 + * @return FinanceReceiptRecordValidate + * @author likeadmin + * @date 2023/12/15 10:20 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return FinanceReceiptRecordValidate + * @author likeadmin + * @date 2023/12/15 10:20 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/common/model/finance/FinancePaymentPlan.php b/app/common/model/finance/FinancePaymentPlan.php new file mode 100644 index 000000000..1f5c562b5 --- /dev/null +++ b/app/common/model/finance/FinancePaymentPlan.php @@ -0,0 +1,34 @@ +belongsTo(\app\common\model\contract\ProcurementContract::class, 'contract_id'); + } +} \ No newline at end of file