From 55b50279e02b7083ae2759e559bba83a092ca842 Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Fri, 15 Dec 2023 11:23:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BB=98=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 --- .../lists/finance/FinancePaymentPlanLists.php | 22 ++++++--- .../logic/finance/FinancePaymentPlanLogic.php | 45 +++++++++++-------- .../model/finance/FinancePaymentPlan.php | 4 ++ 3 files changed, 45 insertions(+), 26 deletions(-) diff --git a/app/adminapi/lists/finance/FinancePaymentPlanLists.php b/app/adminapi/lists/finance/FinancePaymentPlanLists.php index 552a74a15..d60a0c4a9 100644 --- a/app/adminapi/lists/finance/FinancePaymentPlanLists.php +++ b/app/adminapi/lists/finance/FinancePaymentPlanLists.php @@ -15,10 +15,10 @@ namespace app\adminapi\lists\finance; -use app\adminapi\lists\BaseAdminDataLists; +use app\adminapi\lists\BaseAdminDataLists; use app\common\model\finance\FinancePaymentPlan; use app\common\lists\ListsSearchInterface; - +use think\facade\Db; /** * FinancePaymentPlan列表 @@ -38,7 +38,7 @@ class FinancePaymentPlanLists extends BaseAdminDataLists implements ListsSearchI public function setSearch(): array { return [ - '=' => ['contract_id'], + '=' => ['fpp.contract_id'], ]; } @@ -54,11 +54,19 @@ class FinancePaymentPlanLists extends BaseAdminDataLists implements ListsSearchI */ 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']) + return Db::name('FinancePaymentPlan')->alias('fpp') + ->where($this->searchWhere) + ->leftJoin('procurement_contract pc','pc.id = fpp.contract_id') + ->leftJoin('project p','p.id = pc.project_id') + ->field('fpp.*, p.name, p.id as project_id, p.name as project_name, pc.contract_no') ->limit($this->limitOffset, $this->limitLength) - ->order(['id' => 'desc']) - ->select() + ->order(['fpp.id' => 'desc']) + ->select()->each(function($item, $key){ + //关联数据 供应商后续添加 + $item['supplier_name'] = '供应商名称'; + $item['contract_type'] = '1'; + return $item; + }) ->toArray(); } diff --git a/app/adminapi/logic/finance/FinancePaymentPlanLogic.php b/app/adminapi/logic/finance/FinancePaymentPlanLogic.php index b47f6bb61..813cbc1b5 100644 --- a/app/adminapi/logic/finance/FinancePaymentPlanLogic.php +++ b/app/adminapi/logic/finance/FinancePaymentPlanLogic.php @@ -16,6 +16,7 @@ namespace app\adminapi\logic\finance; use app\common\model\finance\FinancePaymentPlan; +use app\common\model\project\Project; use app\common\logic\BaseLogic; use think\facade\Db; @@ -41,15 +42,15 @@ class FinancePaymentPlanLogic extends BaseLogic Db::startTrans(); try { FinancePaymentPlan::create([ - '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'], + 'supplier_id' => $params['supplier_id'] ?? 0, + 'contract_id' => $params['contract_id'] ?? 0, + 'period' => $params['period'] ?? 0, + 'pay_date' => $params['pay_date'] ?? '', + 'amount' => $params['amount'] ?? 0, + 'foreign_currency_remark' => $params['foreign_currency_remark'] ?? '', + 'status' => $params['status'] ?? 0, + 'remark' => $params['remark'] ?? '', + 'annex' => $params['annex'] ?? '', ]); Db::commit(); @@ -74,15 +75,15 @@ class FinancePaymentPlanLogic extends BaseLogic 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'], + 'supplier_id' => $params['supplier_id'] ?? 0, + 'contract_id' => $params['contract_id'] ?? 0, + 'period' => $params['period'] ?? 0, + 'pay_date' => $params['pay_date'] ?? '', + 'amount' => $params['amount'] ?? 0, + 'foreign_currency_remark' => $params['foreign_currency_remark'] ?? '', + 'status' => $params['status'] ?? 0, + 'remark' => $params['remark'] ?? '', + 'annex' => $params['annex'] ?? '', ]); Db::commit(); @@ -117,6 +118,12 @@ class FinancePaymentPlanLogic extends BaseLogic */ public static function detail($params): array { - return FinancePaymentPlan::findOrEmpty($params['id'])->toArray(); + $financePaymentPlan = FinancePaymentPlan::findOrEmpty($params['id']); + $financePaymentPlan->contract; + $financePaymentPlan->project = null; + if (!empty($financePaymentPlan->contract->project_id)) { + $financePaymentPlan->project = Project::findOrEmpty($financePaymentPlan->contract->project_id); + } + return $financePaymentPlan->toArray(); } } \ No newline at end of file diff --git a/app/common/model/finance/FinancePaymentPlan.php b/app/common/model/finance/FinancePaymentPlan.php index 1f5c562b5..788873430 100644 --- a/app/common/model/finance/FinancePaymentPlan.php +++ b/app/common/model/finance/FinancePaymentPlan.php @@ -30,5 +30,9 @@ class FinancePaymentPlan extends BaseModel protected $name = 'finance_payment_plan'; protected $deleteTime = 'delete_time'; + public function contract() + { + return $this->belongsTo(\app\common\model\contract\ProcurementContract::class, 'contract_id'); + } } \ No newline at end of file