From 4156fd1b631e1c14d15dcf53ebe0830741c11db3 Mon Sep 17 00:00:00 2001 From: weiz <736250432@qq.com> Date: Mon, 22 Jan 2024 11:42:04 +0800 Subject: [PATCH] update --- app/adminapi/logic/contract/ContractLogic.php | 31 ++++++++++++++++++- .../validate/contract/ContractValidate.php | 7 +++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/app/adminapi/logic/contract/ContractLogic.php b/app/adminapi/logic/contract/ContractLogic.php index c81aa74a6..bb0141e4a 100644 --- a/app/adminapi/logic/contract/ContractLogic.php +++ b/app/adminapi/logic/contract/ContractLogic.php @@ -116,9 +116,10 @@ class ContractLogic extends BaseLogic public static function edit(array $params): bool { $buy_bidding_document = BidBuyBiddingDocument::field('project_id')->where('id',$params['buy_bidding_document_id'])->findOrEmpty(); + $returned_money = $params['returned_money']; Db::startTrans(); try { - Contract::where('approve_id', $params['approve_id'])->update([ + Contract::where('id', $params['id'])->update([ "org_id" => $params['org_id'], "dept_id" =>$params['dept_id'], "project_id" => $buy_bidding_document['project_id'], @@ -147,6 +148,34 @@ class ContractLogic extends BaseLogic "remark" => $params['remark'] ?? '', 'annex' => $params['annex']? json_encode($params['annex']) : null, ]); + foreach ($returned_money as $item) + { + if(isset($item['id']) && $item['id'] != ''){ + FinanceReturnedMoney::where('id',$item['id'])->update([ + 'project_id' => $buy_bidding_document['project_id'], + 'contract_id' => $params['id'], + 'return_date' => strtotime($item['return_date']), + 'period' => $item['period'], + 'amount' => $item['amount'], + 'return_status' => 2, + 'return_duty_id' => 0, + 'remark' => $item['remark'] ?? '', + 'annex' => null, + ]); + }else{ + FinanceReturnedMoney::create([ + 'project_id' => $buy_bidding_document['project_id'], + 'contract_id' => $params['id'], + 'return_date' => strtotime($item['return_date']), + 'period' => $item['period'], + 'amount' => $item['amount'], + 'return_status' => 2, + 'return_duty_id' => 0, + 'remark' => $item['remark'] ?? '', + 'annex' => null, + ]); + } + } Db::commit(); return true; } catch (\Exception $e) { diff --git a/app/adminapi/validate/contract/ContractValidate.php b/app/adminapi/validate/contract/ContractValidate.php index d8a84e990..704d1cc58 100644 --- a/app/adminapi/validate/contract/ContractValidate.php +++ b/app/adminapi/validate/contract/ContractValidate.php @@ -21,6 +21,7 @@ use app\common\model\custom\Custom; use app\common\model\dept\Dept; use app\common\model\dept\Orgs; use app\common\model\dict\DictData; +use app\common\model\finance\FinanceReturnedMoney; use app\common\model\project\Project; use app\common\validate\BaseValidate; @@ -231,6 +232,12 @@ class ContractValidate extends BaseValidate return '回款计划数据格式错误'; } foreach($detail as $v) { + if(isset($v['id']) && $v['id'] != ''){ + $info = FinanceReturnedMoney::where('id',$v['id'])->findOrEmpty(); + if($info->isEmpty()){ + return '回款计划信息不存在'; + } + } if(empty($v['period'])){ return '请选择期次'; }else{