新增合同变更
This commit is contained in:
parent
044faabfe1
commit
d5286325de
@ -16,6 +16,7 @@ namespace app\adminapi\logic\contract;
|
||||
|
||||
|
||||
use app\common\model\contract\ProcurementContractChange;
|
||||
use app\common\model\contract\ProcurementContractDetail;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
@ -59,7 +60,19 @@ class ProcurementContractChangeLogic extends BaseLogic
|
||||
'remark' => $params['remark'] ?? 0,
|
||||
'annex' => $params['annex'] ?? 0,
|
||||
]);
|
||||
|
||||
ProcurementContractDetail::where('procurement_contract_id', $params['procurement_contract_id'])->update(['delete_time' =>time()]);
|
||||
foreach ($params['material'] ?? [] as $item)
|
||||
{
|
||||
ProcurementContractDetail::create([
|
||||
'procurement_contract_id' => $params['procurement_contract_id'],
|
||||
'material_procurement_application_id' => $item['material_procurement_application_id'] ?? 0,
|
||||
'num' => $item['num'] ?? 0,
|
||||
'unit_price_including_tax' => $item['unit_price_including_tax'] ?? 0,
|
||||
'tax_rate' => $item['tax_rate'] ?? 0,
|
||||
'amount_excluding_tax' => $item['amount_excluding_tax'] ?? 0,
|
||||
'amount_including_tax' => $item['amount_including_tax'] ?? 0,
|
||||
]);
|
||||
}
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
@ -100,7 +113,19 @@ class ProcurementContractChangeLogic extends BaseLogic
|
||||
'remark' => $params['remark'] ?? 0,
|
||||
'annex' => $params['annex'] ?? 0,
|
||||
]);
|
||||
|
||||
ProcurementContractDetail::where('procurement_contract_id', $params['procurement_contract_id'])->update(['delete_time' =>time()]);
|
||||
foreach ($params['material'] ?? [] as $item)
|
||||
{
|
||||
ProcurementContractDetail::create([
|
||||
'procurement_contract_id' =>$params['procurement_contract_id'],
|
||||
'material_procurement_application_id' => $item['material_procurement_application_id'] ?? 0,
|
||||
'num' => $item['num'] ?? 0,
|
||||
'unit_price_including_tax' => $item['unit_price_including_tax'] ?? 0,
|
||||
'tax_rate' => $item['tax_rate'] ?? 0,
|
||||
'amount_excluding_tax' => $item['amount_excluding_tax'] ?? 0,
|
||||
'amount_including_tax' => $item['amount_including_tax'] ?? 0,
|
||||
]);
|
||||
}
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
@ -134,8 +159,8 @@ class ProcurementContractChangeLogic extends BaseLogic
|
||||
public static function detail($params): array
|
||||
{
|
||||
$procurementContractChange = ProcurementContractChange::findOrEmpty($params['id']);
|
||||
$procurementContractChange->contract = $procurementContractChange->contract;
|
||||
$procurementContractChange->project = $procurementContractChange->project;
|
||||
$procurementContractChange->material = $procurementContractChange->material;
|
||||
return $procurementContractChange->toArray();
|
||||
}
|
||||
}
|
@ -36,7 +36,7 @@ class ProcurementContractChangeValidate extends BaseValidate
|
||||
'supplier_id' => 'require',
|
||||
'approve_id' => 'require',
|
||||
'project_id' => 'require',
|
||||
'contract_no' => 'require',
|
||||
'material' => 'require|array|checkMaterial',
|
||||
];
|
||||
|
||||
|
||||
@ -95,4 +95,28 @@ class ProcurementContractChangeValidate extends BaseValidate
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkMaterial($value, $rule, $data)
|
||||
{
|
||||
$firstData = $value[0] ?? [];
|
||||
if (empty($firstData['material_procurement_application_id'])) {
|
||||
return '材料采购申请id不能为空!';
|
||||
}
|
||||
if (empty($firstData['num'])) {
|
||||
return '材料数量不能为空!';
|
||||
}
|
||||
if (empty($firstData['unit_price_including_tax'])) {
|
||||
return '材料含税单价不能为空!';
|
||||
}
|
||||
if (empty($firstData['tax_rate'])) {
|
||||
return '材料税率不能为空!';
|
||||
}
|
||||
if (empty($firstData['amount_excluding_tax'])) {
|
||||
return '材料不含税金额不能为空!';
|
||||
}
|
||||
if (empty($firstData['amount_including_tax'])) {
|
||||
return '材料含税金额不能为空!';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -40,6 +40,11 @@ class ProcurementContractChange extends BaseModel
|
||||
return $this->belongsTo(\app\common\model\contract\ProcurementContract::class, 'procurement_contract_id');
|
||||
}
|
||||
|
||||
public function material()
|
||||
{
|
||||
return $this->hasMany(\app\common\model\contract\ProcurementContractDetail::class, 'procurement_contract_id', 'procurement_contract_id');
|
||||
}
|
||||
|
||||
public function getSigningDateAttr($value)
|
||||
{
|
||||
return empty($value) ? '' : date('Y-m-d H:i:s', $value);
|
||||
|
Loading…
x
Reference in New Issue
Block a user