|
|
@@ -253,14 +253,14 @@ class ServiceWorkLogic extends BaseLogic
|
|
|
|
|
|
// 关联配件信息.计算配件总价 id company_price original_price offering_price number
|
|
|
$spare_total = 0;
|
|
|
-
|
|
|
+ $work->spare_total = 0;
|
|
|
isset($params['spare_parts']) && $params['spare_parts'] && $params['spare_parts'] = json_decode($params['spare_parts'], true);
|
|
|
if(isset($params['spare_parts']) && $params['spare_parts']){
|
|
|
$spare_parts = $params['spare_parts'];
|
|
|
foreach ($spare_parts as $spare){
|
|
|
$spare_total += $spare['company_price']*$spare['number'];
|
|
|
}
|
|
|
- $work->spare_total = $spare_total;
|
|
|
+ $work->spare_total += $spare_total;
|
|
|
|
|
|
$service_work_spare = ServiceWorkSpare::where(['service_work_id'=>$work['id']])->findOrEmpty();
|
|
|
if($service_work_spare->isEmpty()){
|
|
|
@@ -276,7 +276,21 @@ class ServiceWorkLogic extends BaseLogic
|
|
|
$service_work_spare->save();
|
|
|
}
|
|
|
$work->service_work_spare_id = $service_work_spare->id;
|
|
|
+ }elseif (isset($params['spare_total']) && $params['spare_total']){
|
|
|
+ $work->spare_total += $params['spare_total'];
|
|
|
+ }
|
|
|
+ // 添加工单尾款报价记录 - 即配件费用
|
|
|
+ if(isset($params['price_content'])){
|
|
|
+ !is_array($params['price_content']) && $params['price_content'] = json_decode($params['price_content'], true);
|
|
|
+ ServiceWorkDeterminedPrice::where('work_id',$work->id)->delete();
|
|
|
+ ServiceWorkDeterminedPrice::create([
|
|
|
+ 'work_id'=>$work->id,
|
|
|
+ 'content'=>$params['price_content']??[],
|
|
|
+ ]);
|
|
|
+ $work->spare_total += array_sum('price');
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
// order_amount 原 = $params['amount'] 修改为 = 配件总价 + 服务尾款
|
|
|
$order_amount = $params['amount'] + $spare_total;
|
|
|
|
|
|
@@ -335,15 +349,7 @@ class ServiceWorkLogic extends BaseLogic
|
|
|
];
|
|
|
ServiceWorkLogLogic::add($work_log);
|
|
|
|
|
|
- // 添加工单尾款报价记录
|
|
|
- if(isset($params['price_content'])){
|
|
|
- !is_array($params['price_content']) && $params['price_content'] = json_decode($params['price_content'], true);
|
|
|
- ServiceWorkDeterminedPrice::where('work_id',$work->id)->delete();
|
|
|
- ServiceWorkDeterminedPrice::create([
|
|
|
- 'work_id'=>$work->id,
|
|
|
- 'content'=>$params['price_content']??[],
|
|
|
- ]);
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
Db::commit();
|
|
|
// 商家报价通知外部平台 即报价
|