|
|
@@ -21,6 +21,8 @@ use app\common\logic\WorkerAccountLogLogic;
|
|
|
use app\common\model\coupon\CouponCategory;
|
|
|
use app\common\model\coupon\UserCoupon;
|
|
|
use app\common\model\dict\DictData;
|
|
|
+use app\common\model\master_commission\MasterWorkerCommissionConfig;
|
|
|
+use app\common\model\master_commission\MasterWorkerCommissionRatio;
|
|
|
use app\common\model\master_worker\MasterWorker;
|
|
|
use app\common\model\master_worker\MasterWorkerAccountLog;
|
|
|
use app\common\model\master_worker\MasterWorkerRetentionMoneyLog;
|
|
|
@@ -667,14 +669,22 @@ class ServiceWorkLogic extends BaseLogic
|
|
|
if((int)$serviceWorkInfo['work_pay_status'] !== 3){
|
|
|
throw new \Exception('该工单非待结算状态');
|
|
|
}
|
|
|
- //获取工单对应的商品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('请配置商品业绩规则');
|
|
|
+ $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{
|
|
|
+ // 存在服务分类比例进行结算
|
|
|
+ PerformanceLogic::calculatePerformanceCommission($serviceWorkInfo);
|
|
|
}
|
|
|
- PerformanceLogic::calculatePerformance($serviceWorkInfo);
|
|
|
Db::commit();
|
|
|
return true;
|
|
|
} catch (\Exception $e) {
|