|
|
@@ -861,13 +861,21 @@ class ServiceWorkLogic extends BaseLogic
|
|
|
if((int)$serviceWorkInfo['work_pay_status'] !== 3){
|
|
|
throw new \Exception('该工单非待结算状态');
|
|
|
}
|
|
|
- if(ServiceWorkSpareAudit::where('service_work_id',$serviceWorkInfo->id)->findOrEmpty()->isEmpty()){
|
|
|
- $serviceWorkInfo->user_confirm_status = 5;
|
|
|
- $serviceWorkInfo->work_status = 7;
|
|
|
- $serviceWorkInfo->work_pay_status = 1;
|
|
|
- $serviceWorkInfo->save();
|
|
|
+ $ratio = 0;
|
|
|
+ $commissionConfig = MasterWorkerCommissionConfig::where('master_worker_id',$serviceWorkInfo->master_worker_id)->where('voucher_status',2)->findOrEmpty();
|
|
|
+ !$commissionConfig->isEmpty() && $ratio = MasterWorkerCommissionRatio::where('commission_config_id',$commissionConfig['id'])->where('goods_category_id',$serviceWorkInfo->goods_category_id)->value('ratio')?:0;
|
|
|
+ if($commissionConfig->isEmpty() || empty($ratio)){
|
|
|
+ //获取工单对应的商品id
|
|
|
+ $order_sns = \app\common\model\orders\RechargeOrder::where('work_id',$serviceWorkInfo->id)->column('sn');
|
|
|
+ $goods_id = OrderGoods::whereIn('sn',$order_sns)->value('goods_id');
|
|
|
+ $rule = PerformanceRules::whereFindInSet('goods_id',$goods_id)->findOrEmpty();
|
|
|
+ if($rule->isEmpty()){
|
|
|
+ throw new \Exception('请配置商品业绩规则');
|
|
|
+ }
|
|
|
+ PerformanceLogic::calculatePerformance($serviceWorkInfo);
|
|
|
}else{
|
|
|
- throw new \Exception('请完成配件审核');
|
|
|
+ // 存在服务分类比例进行结算
|
|
|
+ PerformanceLogic::calculatePerformanceCommission($serviceWorkInfo);
|
|
|
}
|
|
|
Db::commit();
|
|
|
return true;
|