|
|
@@ -51,10 +51,18 @@ class PropertyCommissionLogic extends BaseLogic
|
|
|
if(empty($propertyUserId)){
|
|
|
throw new Exception("非物业负责人,该工单无需物业分成:".json_encode($service_work->toArray()));
|
|
|
}
|
|
|
+ $isPropertyOrder = PropertyOrder::where(['property_user_id' => $propertyUserId,'work_id'=>$work_id])->findOrEmpty();
|
|
|
+ if($isPropertyOrder->isEmpty()){
|
|
|
+ throw new Exception("非物业单:".json_encode(['property_user_id' => $propertyUserId,'work_id'=>$work_id]));
|
|
|
+ }
|
|
|
// 以工单服务费-优惠费 为基准,计算物业分成金额
|
|
|
$coupon_price = RechargeOrder::where('work_id',$work_id)->sum('coupon_price');
|
|
|
$work_amount = $service_work->service_fee - $coupon_price;
|
|
|
- $propertyOrderInfo = PropertyOrder::where(['property_user_id' => $propertyUserId,'order_status' => 1,'work_id'=>$work_id])->findOrEmpty()->toArray();
|
|
|
+ $propertyOrderInfo = PropertyOrder::where(['property_user_id' => $propertyUserId,'order_status' => 1,'work_id'=>$work_id])->findOrEmpty();
|
|
|
+ if($propertyOrderInfo->isEmpty()){
|
|
|
+ throw new Exception("未接单不存在:".json_encode(['property_user_id' => $propertyUserId,'work_id'=>$work_id]));
|
|
|
+ }
|
|
|
+ $propertyOrderInfo = $propertyOrderInfo->toArray();
|
|
|
//计算分成金额
|
|
|
$ratio = PropertyHead::where('id',$propertyOrderInfo['property_head_id'])->value('ratio');
|
|
|
$commission_amount = bcmul($work_amount, bcdiv($ratio, 100, 4),2);
|