This commit is contained in:
weiz 2024-01-22 11:42:04 +08:00
parent ab2c41fa76
commit 4156fd1b63
2 changed files with 37 additions and 1 deletions

View File

@ -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) {

View File

@ -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{