更新付款计划

This commit is contained in:
yaooo 2023-12-15 11:23:05 +08:00
parent 40ba795813
commit 55b50279e0
3 changed files with 45 additions and 26 deletions

View File

@ -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();
}

View File

@ -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();
}
}

View File

@ -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');
}
}