提成计算相关-问题修复

1 parent 47cfb2e5
......@@ -68,6 +68,10 @@ public class StaffPerformance implements Serializable {
@Column(name = "month")
private String month;
@ApiModelProperty(notes = "提成方案配置ID(dj_car_life_performance_config.id)")
@Column(name = "performance_config_id")
private Integer performanceConfigId;
@ApiModelProperty(notes = "有效引荐量")
@Column(name = "effective_referral_quantity")
private Integer effectiveReferralQuantity;
......
......@@ -70,9 +70,9 @@ public class StaffPerformanceDetail implements Serializable {
@Column(name = "month")
private String month;
@ApiModelProperty(notes = "提成方案配置ID(dj_car_life_performance_config.id)")
@Column(name = "performance_config_id")
private Integer performanceConfigId;
@ApiModelProperty(notes = "门店工资绩效参数配置ID(dj_car_life_performance_param_config.id)")
@Column(name = "performance_param_config_id")
private Integer performanceParamConfigId;
@ApiModelProperty(notes = "考核因子")
@Column(name = "assessment_factor")
......
package cn.com.glsx.dj.staff.service.staffPerformance;
import cn.com.glsx.dj.smartcarlife.dto.merchantPerformanceConfig.MerchantPerformanceProductDefineDTO;
import cn.com.glsx.dj.smartcarlife.remote.MerchantPerformanceProductDefineRemote;
import cn.com.glsx.dj.staff.enums.GoodsConfigTypeEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@Slf4j
@Service
@Transactional(propagation = Propagation.SUPPORTS, rollbackFor = RpcServiceException.class)
public class MerchantPerformanceProductDefineService {
@Autowired
private MerchantPerformanceProductDefineRemote merchantPerformanceProductDefineRemote;
public MerchantPerformanceProductDefineDTO fetchProductDefine(Byte goodsConfigType, Integer productDefineId) {
if (goodsConfigType == null || productDefineId == null) {
return null;
}
GoodsConfigTypeEnum configTypeEnum = GoodsConfigTypeEnum.getByCode(goodsConfigType);
if (configTypeEnum == GoodsConfigTypeEnum.DESIGNATED_PRODUCT
|| configTypeEnum == GoodsConfigTypeEnum.DESIGNATED_PACKAGE) {
return merchantPerformanceProductDefineRemote
.getByIdWithRadicalUpgradeGoodsItem(productDefineId).getResult();
}
return null;
}
}
......@@ -63,6 +63,8 @@ public class StaffPerformanceCalService {
@Autowired
private StaffPerformanceDetailService staffPerformanceDetailService;
@Autowired
private MerchantPerformanceProductDefineService merchantPerformanceProductDefineService;
/**
* 计算员工提成
*
......@@ -487,7 +489,7 @@ public class StaffPerformanceCalService {
.brandName(context.getBrandName())
.childBrandId(context.getChildBrandId())
.childBrandName(context.getChildBrandName())
.performanceConfigId(paramConfig.getId())
.performanceParamConfigId(paramConfig.getId())
.assessmentFactor(paramConfig.getAssessmentFactor())
.goodsConfigType(paramConfig.getGoodsConfigType())
.goodsType(paramConfig.getGoodsType())
......@@ -575,7 +577,7 @@ public class StaffPerformanceCalService {
// 是否跳过渗透率限制条件类型的继续判断
boolean skipPenetrationRateCondition = false;
log.info("= 开始计算条件: configId={}", paramConfig.getId());
log.info("= 开始计算条件: paramConfigId={}", paramConfig.getId());
for (PerformanceParamConfigConditionDTO condition : paramConfig.getPerformanceParamConfigConditions()) {
log.info("==处理条件: conditionId={}, conditionType={}", condition.getId(),
......@@ -615,16 +617,11 @@ public class StaffPerformanceCalService {
throw new RpcServiceException("未处理的条件类型: " + conditionTypeEnum);
}
} catch (RpcServiceException e) {
// 业务异常主要针对渗透率限制的校验,需要抛出
log.warn("业务规则校验失败: {}", e.getMessage());
throw e;
} catch (Exception e) {
log.error("条件计算异常: conditionType={}, conditionId={}", condition.getConditionType(),
condition.getId(),
e);
resultLog.put("error", e.getMessage());
condition.getId(),
e);
throw e;
}
executionLog.put("result", resultLog);
conditionExecutions.add(executionLog);
}
......@@ -778,7 +775,7 @@ public class StaffPerformanceCalService {
boolean deduct = personalPenetrationRate.compareTo(conditionEndValue) < 0;
log.info("订单数不足扣减检查: realRate={}, targetRate={}, needDeduct={}", personalPenetrationRate,
conditionEndValue, deduct);
resultLog.put("needDeduct", deduct);
if (deduct) {
BigDecimal personalTargetTouchCount = context.getAssessmentFactorDependencyData()
.getDailyData().getPersonalTargetTouchCount();
......@@ -847,17 +844,24 @@ public class StaffPerformanceCalService {
StaffPerformanceCalContextDTO context, PerformanceParamConfigConditionDTO condition,
JSONObject resultLog) {
log.info("执行订单数剔除条件: conditionId={}", condition.getId());
MerchantPerformanceProductDefineDTO productDefine = null;
if (condition.getConditionProductDefineId() != null) {
productDefine = merchantPerformanceProductDefineService
.fetchProductDefine(condition.getConditionGoodsConfigType(),
condition.getConditionProductDefineId());
}
// 4.订单数剔除
String groupKey = generateGroupOrderMapKey(context.getMerchantId(),
context.getBusinessType(), context.getBrandId(),
context.getChildBrandId());
List<StaffPerformanceSubOrderDTO> orders = context.getGroupedOrdersMap().get(groupKey);
Integer excludedOrderCount = StaffPerformanceOrderUtil.countMatchingOrders(orders,
condition.getConditionGoodsConfigType(),
condition.getConditionGoodsType(),
condition.getConditionSecondaryGoodsType(),
condition.getConditionThirdLevelGoodsType(),
condition.getProductDefine());
productDefine);
log.info("订单剔除检查: excludedCount={}", excludedOrderCount);
......@@ -883,6 +887,12 @@ public class StaffPerformanceCalService {
*/
public BigDecimal calculateConditionProductPenetrationRate(PerformanceParamConfigConditionDTO condition,
StaffPerformanceCalContextDTO context) {
MerchantPerformanceProductDefineDTO productDefine = null;
if (condition.getConditionProductDefineId() != null) {
productDefine = merchantPerformanceProductDefineService
.fetchProductDefine(condition.getConditionGoodsConfigType(),
condition.getConditionProductDefineId());
}
// 计算条件定义的商品生成的子订单数
String groupKey = generateGroupOrderMapKey(context.getMerchantId(), context.getBusinessType(),
context.getBrandId(), context.getChildBrandId());
......@@ -896,7 +906,7 @@ public class StaffPerformanceCalService {
condition.getConditionGoodsType(),
condition.getConditionSecondaryGoodsType(),
condition.getConditionThirdLevelGoodsType(),
condition.getProductDefine());
productDefine);
BigDecimal targetTouchCount = context.getAssessmentFactorDependencyData().getDailyData()
.getPersonalTargetTouchCount();
......@@ -1140,7 +1150,7 @@ public class StaffPerformanceCalService {
thirdLevelGoodsType,
productDefineId);
log.debug("goodsConfigType:{}, goodsType:{},secondaryGoodsType:{},thirdLevelGoodsType:{},productDefineId:{},考核因子: {},实际值: {}",
log.info("goodsConfigType:{}, goodsType:{},secondaryGoodsType:{},thirdLevelGoodsType:{},productDefineId:{},assessmentFactor: {},实际值: {}",
goodsConfigType, goodsType,
secondaryGoodsType, thirdLevelGoodsType,
productDefineId, assessmentFactor, actualValue);
......
......@@ -140,6 +140,7 @@ public class StaffPerformanceService {
staffPerformance.setChildBrandId(first.getChildBrandId());
staffPerformance.setChildBrandName(first.getChildBrandName());
staffPerformance.setMonth(first.getMonth());
staffPerformance.setPerformanceConfigId(context.getPerformanceConfig().getId());
Date now = new Date();
staffPerformance.setCreatedBy(CommonConstants.DEFAULT_UPDATE_BY);
......
......@@ -2,8 +2,10 @@ package cn.com.glsx.dj.staff.service.staffPerformance;
import cn.com.glsx.dj.smartcarlife.constant.CommonConstants;
import cn.com.glsx.dj.smartcarlife.dto.merchantPerformanceConfig.MerchantPerformanceProductDefineDTO;
import cn.com.glsx.dj.smartcarlife.remote.MerchantPerformanceProductDefineRemote;
import cn.com.glsx.dj.staff.dto.*;
import cn.com.glsx.dj.staff.dto.StaffPerformanceCalContextDTO;
import cn.com.glsx.dj.staff.dto.StaffPerformanceDetailDTO;
import cn.com.glsx.dj.staff.dto.StaffPerformanceSubOrderDTO;
import cn.com.glsx.dj.staff.dto.StaffProductPerformanceDTO;
import cn.com.glsx.dj.staff.dto.performance.StaffPerformanceDTO;
import cn.com.glsx.dj.staff.dto.performance.StaffPerformanceGetDTO;
import cn.com.glsx.dj.staff.enums.CommissionTypeEnum;
......@@ -44,7 +46,7 @@ public class StaffProductPerformanceService {
@Autowired
private StaffProductPerformanceMapper staffProductPerformanceMapper;
@Autowired
private MerchantPerformanceProductDefineRemote merchantPerformanceProductDefineRemote;
private MerchantPerformanceProductDefineService merchantPerformanceProductDefineService;
@Autowired
private StaffPerformanceService staffPerformanceService;
......@@ -183,7 +185,7 @@ public class StaffProductPerformanceService {
Integer productDefineId = detailDTO.getProductDefineId();
// 1. 获取产品定义配置
MerchantPerformanceProductDefineDTO productDefine = fetchProductDefine(goodsConfigType, productDefineId);
MerchantPerformanceProductDefineDTO productDefine = merchantPerformanceProductDefineService.fetchProductDefine(goodsConfigType, productDefineId);
// 2. 获取当前层级关联的所有原始订单
List<StaffPerformanceSubOrderDTO> orders = getRelevantOrders(context);
......@@ -204,18 +206,7 @@ public class StaffProductPerformanceService {
productPerformance.setPersonalPenetrationRate(penetrationRate);
}
private MerchantPerformanceProductDefineDTO fetchProductDefine(Byte goodsConfigType, Integer productDefineId) {
if (goodsConfigType == null || productDefineId == null) {
return null;
}
GoodsConfigTypeEnum configTypeEnum = GoodsConfigTypeEnum.getByCode(goodsConfigType);
if (configTypeEnum == GoodsConfigTypeEnum.DESIGNATED_PRODUCT
|| configTypeEnum == GoodsConfigTypeEnum.DESIGNATED_PACKAGE) {
return merchantPerformanceProductDefineRemote
.getByIdWithRadicalUpgradeGoodsItem(productDefineId).getResult();
}
return null;
}
private List<StaffPerformanceSubOrderDTO> getRelevantOrders(StaffPerformanceCalContextDTO context) {
String groupKey = StaffPerformanceCalService.generateGroupOrderMapKey(context.getMerchantId(),
......
......@@ -16,7 +16,7 @@
<result column="child_brand_id" property="childBrandId" jdbcType="INTEGER" />
<result column="child_brand_name" property="childBrandName" jdbcType="VARCHAR" />
<result column="month" property="month" jdbcType="VARCHAR" />
<result column="performance_config_id" property="performanceConfigId" jdbcType="INTEGER" />
<result column="performance_param_config_id" property="performanceParamConfigId" jdbcType="INTEGER" />
<result column="assessment_factor" property="assessmentFactor" jdbcType="TINYINT" />
<result column="goods_config_type" property="goodsConfigType" jdbcType="TINYINT" />
<result column="goods_type" property="goodsType" jdbcType="INTEGER" />
......@@ -51,7 +51,7 @@
WARNING - @mbg.generated
-->
id, staff_name, staff_phone, merchant_id, merchant_name, business_type, brand_id,
brand_name, child_brand_id, child_brand_name, month, performance_config_id, assessment_factor,
brand_name, child_brand_id, child_brand_name, month, performance_param_config_id, assessment_factor,
goods_config_type, goods_type, goods_type_name, secondary_goods_type, secondary_goods_type_name,
third_level_goods_type, third_level_goods_type_name, product_define_id, product_define_name,
performance_amount, assessment_factor_value, commission_base, gmv_output, upgrade_order_num,
......
......@@ -16,6 +16,7 @@
<result column="child_brand_id" property="childBrandId" jdbcType="INTEGER" />
<result column="child_brand_name" property="childBrandName" jdbcType="VARCHAR" />
<result column="month" property="month" jdbcType="VARCHAR" />
<result column="performance_config_id" property="performanceConfigId" jdbcType="INTEGER" />
<result column="effective_referral_quantity" property="effectiveReferralQuantity" jdbcType="INTEGER" />
<result column="touch_number" property="touchNumber" jdbcType="INTEGER" />
<result column="performance_amount" property="performanceAmount" jdbcType="DECIMAL" />
......@@ -39,7 +40,7 @@
WARNING - @mbg.generated
-->
id, staff_name, staff_phone, merchant_id, merchant_name, business_type, brand_id,
brand_name, child_brand_id, child_brand_name, month, effective_referral_quantity,
brand_name, child_brand_id, child_brand_name, month, performance_config_id, effective_referral_quantity,
touch_number, performance_amount, created_by, created_date, updated_by, updated_date, deleted_flag
</sql>
<sql id="Blob_Column_List" >
......@@ -73,6 +74,7 @@
updated_date = now()
WHERE
merchant_id = #{merchantId}
AND staff_phone = #{staffPhone}
AND business_type = #{businessType}
AND brand_id = #{brandId}
AND child_brand_id = #{childBrandId}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!