Commit 1780a0bb by 张富康

chore(logging): 增加员工提成计算相关日志输出

- 在员工提成计算开始和完成时添加标识性日志
- 详细记录订单数据和日常数据的JSON信息
- 增加关键计算步骤的日志,如主计数、目标触达数、提成金额等
- 记录条件计算额外提成参数时的流程和判断日志
- 在处理品类或指定商品数据计算时打印详细订单信息
- 将部分调试级别日志调整为信息级别以便跟踪执行过程
- 输出上下文对象和商品定义的序列化信息便于问题定位
1 parent 5fe26b24
...@@ -103,7 +103,7 @@ public class StaffPerformanceCalService { ...@@ -103,7 +103,7 @@ public class StaffPerformanceCalService {
throw new RpcServiceException(DefaultErrorEnum.DATA_INVALID, "月份格式错误,应为yyyy-MM"); throw new RpcServiceException(DefaultErrorEnum.DATA_INVALID, "月份格式错误,应为yyyy-MM");
} }
log.info("开始计算员工提成: staffPhone={}, month={}", staffPhone, month); log.info("=====================开始计算员工提成: staffPhone={}, month={}", staffPhone, month);
List<StaffPerformanceSubOrderDTO> orders = listStaffMonthSubOrders(staffPhone, month); List<StaffPerformanceSubOrderDTO> orders = listStaffMonthSubOrders(staffPhone, month);
if (CollectionUtils.isEmpty(orders)) { if (CollectionUtils.isEmpty(orders)) {
...@@ -132,7 +132,7 @@ public class StaffPerformanceCalService { ...@@ -132,7 +132,7 @@ public class StaffPerformanceCalService {
} }
} }
log.info("员工提成计算完成: staffPhone={}", staffPhone); log.info("=====================员工提成计算完成: staffPhone={}", staffPhone);
StaffPerformanceDTO dto = StaffPerformanceDTO.builder() StaffPerformanceDTO dto = StaffPerformanceDTO.builder()
.staffPhone(staffPhone) .staffPhone(staffPhone)
.month(month) .month(month)
...@@ -492,6 +492,9 @@ public class StaffPerformanceCalService { ...@@ -492,6 +492,9 @@ public class StaffPerformanceCalService {
thirdLevelGoodsType, productDefineId); thirdLevelGoodsType, productDefineId);
AssessmentFactorOrderDataDTO orderData = context.getAssessmentFactorDependencyData().getOrderData(); AssessmentFactorOrderDataDTO orderData = context.getAssessmentFactorDependencyData().getOrderData();
AssessmentFactorDailyDataDTO dailyData = context.getAssessmentFactorDependencyData().getDailyData(); AssessmentFactorDailyDataDTO dailyData = context.getAssessmentFactorDependencyData().getDailyData();
log.info("orderData:{},", JSONUtil.toJsonStr(orderData));
log.info("dailyData:{},", JSONUtil.toJsonStr(dailyData));
AssessmentFactorEnum factorEnum = AssessmentFactorEnum.getByCode(assessmentFactor); AssessmentFactorEnum factorEnum = AssessmentFactorEnum.getByCode(assessmentFactor);
if (factorEnum == null) { if (factorEnum == null) {
...@@ -514,6 +517,7 @@ public class StaffPerformanceCalService { ...@@ -514,6 +517,7 @@ public class StaffPerformanceCalService {
.orElse(0)); .orElse(0));
BigDecimal targetTouch = Optional.ofNullable(dailyData.getPersonalTargetTouchCount()) BigDecimal targetTouch = Optional.ofNullable(dailyData.getPersonalTargetTouchCount())
.orElse(BigDecimal.ZERO); .orElse(BigDecimal.ZERO);
log.info("mainCount:{},targetTouch:{}", mainCount, targetTouch);
return DataCalUtil.divideToPercent(mainCount, targetTouch); return DataCalUtil.divideToPercent(mainCount, targetTouch);
} }
case PERSONAL_SINGLE_PRODUCT_PENETRATION_RATE: { case PERSONAL_SINGLE_PRODUCT_PENETRATION_RATE: {
...@@ -523,6 +527,7 @@ public class StaffPerformanceCalService { ...@@ -523,6 +527,7 @@ public class StaffPerformanceCalService {
.orElse(0)); .orElse(0));
BigDecimal targetTouch = Optional.ofNullable(dailyData.getPersonalTargetTouchCount()) BigDecimal targetTouch = Optional.ofNullable(dailyData.getPersonalTargetTouchCount())
.orElse(BigDecimal.ZERO); .orElse(BigDecimal.ZERO);
log.info("subCount:{},targetTouch:{}", subCount, targetTouch);
return DataCalUtil.divideToPercent(subCount, targetTouch); return DataCalUtil.divideToPercent(subCount, targetTouch);
} }
case HIGH_CUSTOMER_UNIT_PRICE: case HIGH_CUSTOMER_UNIT_PRICE:
...@@ -536,6 +541,7 @@ public class StaffPerformanceCalService { ...@@ -536,6 +541,7 @@ public class StaffPerformanceCalService {
BigDecimal totalTouch = new BigDecimal( BigDecimal totalTouch = new BigDecimal(
Optional.ofNullable(dailyData.getPersonalTotalPreSalesTouchCount()) Optional.ofNullable(dailyData.getPersonalTotalPreSalesTouchCount())
.orElse(0)); .orElse(0));
log.info("totalOutput:{},totalTouch:{}", totalOutput, totalTouch);
return DataCalUtil.divide(totalOutput, totalTouch); return DataCalUtil.divide(totalOutput, totalTouch);
} }
case CUSTOMER_CONTACT_UNIT_PRICE: { case CUSTOMER_CONTACT_UNIT_PRICE: {
...@@ -545,6 +551,7 @@ public class StaffPerformanceCalService { ...@@ -545,6 +551,7 @@ public class StaffPerformanceCalService {
BigDecimal storePersonalTouch = new BigDecimal( BigDecimal storePersonalTouch = new BigDecimal(
Optional.ofNullable(dailyData.getStorePersonalPreSalesTouchCount()) Optional.ofNullable(dailyData.getStorePersonalPreSalesTouchCount())
.orElse(0)); .orElse(0));
log.info("storeOutput:{},storePersonalTouch:{}", storeOutput, storePersonalTouch);
return DataCalUtil.divide(storeOutput, storePersonalTouch); return DataCalUtil.divide(storeOutput, storePersonalTouch);
} }
case UPGRADE_UNIT_PRICE: { case UPGRADE_UNIT_PRICE: {
...@@ -553,6 +560,7 @@ public class StaffPerformanceCalService { ...@@ -553,6 +560,7 @@ public class StaffPerformanceCalService {
.orElse(BigDecimal.ZERO); .orElse(BigDecimal.ZERO);
BigDecimal mainOrderCount = new BigDecimal( BigDecimal mainOrderCount = new BigDecimal(
Optional.ofNullable(orderData.getMainOrderCountByBrand()).orElse(0)); Optional.ofNullable(orderData.getMainOrderCountByBrand()).orElse(0));
log.info("storeOutput:{},mainOrderCount:{}", storeOutput, mainOrderCount);
return DataCalUtil.divide(storeOutput, mainOrderCount); return DataCalUtil.divide(storeOutput, mainOrderCount);
} }
case DELIVERY_UNIT_PRICE: { case DELIVERY_UNIT_PRICE: {
...@@ -561,6 +569,7 @@ public class StaffPerformanceCalService { ...@@ -561,6 +569,7 @@ public class StaffPerformanceCalService {
.orElse(BigDecimal.ZERO); .orElse(BigDecimal.ZERO);
BigDecimal targetTouch = Optional.ofNullable(dailyData.getPersonalTargetTouchCount()) BigDecimal targetTouch = Optional.ofNullable(dailyData.getPersonalTargetTouchCount())
.orElse(BigDecimal.ZERO); .orElse(BigDecimal.ZERO);
log.info("storeOutput:{},targetTouch:{}", storeOutput, targetTouch);
return DataCalUtil.divide(storeOutput, targetTouch); return DataCalUtil.divide(storeOutput, targetTouch);
} }
case STORE_CUSTOMER_CONTACT_RATE_DELIVERY: { case STORE_CUSTOMER_CONTACT_RATE_DELIVERY: {
...@@ -569,6 +578,7 @@ public class StaffPerformanceCalService { ...@@ -569,6 +578,7 @@ public class StaffPerformanceCalService {
Optional.ofNullable(dailyData.getStoreTotalTouchCount()).orElse(0)); Optional.ofNullable(dailyData.getStoreTotalTouchCount()).orElse(0));
BigDecimal storeDelivery = new BigDecimal( BigDecimal storeDelivery = new BigDecimal(
Optional.ofNullable(dailyData.getStoreDeliveryCount()).orElse(0)); Optional.ofNullable(dailyData.getStoreDeliveryCount()).orElse(0));
log.info("storeTotalTouch:{},storeDelivery:{}", storeTotalTouch, storeDelivery);
return DataCalUtil.divideToPercent(storeTotalTouch, storeDelivery); return DataCalUtil.divideToPercent(storeTotalTouch, storeDelivery);
} }
case STORE_CUSTOMER_CONTACT_RATE_EFFECTIVE_REFERRAL: { case STORE_CUSTOMER_CONTACT_RATE_EFFECTIVE_REFERRAL: {
...@@ -578,6 +588,7 @@ public class StaffPerformanceCalService { ...@@ -578,6 +588,7 @@ public class StaffPerformanceCalService {
BigDecimal storeValidReferral = new BigDecimal( BigDecimal storeValidReferral = new BigDecimal(
Optional.ofNullable(dailyData.getStoreValidRecommendationCount()) Optional.ofNullable(dailyData.getStoreValidRecommendationCount())
.orElse(0)); .orElse(0));
log.info("storeTotalTouch:{},storeValidReferral:{}", storeTotalTouch, storeValidReferral);
return DataCalUtil.divideToPercent(storeTotalTouch, storeValidReferral); return DataCalUtil.divideToPercent(storeTotalTouch, storeValidReferral);
} }
case UPGRADE_ORDER_QUANTITY: case UPGRADE_ORDER_QUANTITY:
...@@ -658,6 +669,7 @@ public class StaffPerformanceCalService { ...@@ -658,6 +669,7 @@ public class StaffPerformanceCalService {
if (Objects.equals(detailDTO.getCommissionType(), CommissionTypeEnum.GDJE.getCode())) { if (Objects.equals(detailDTO.getCommissionType(), CommissionTypeEnum.GDJE.getCode())) {
if (detailDTO.getCommissionTypeValue() != null && detailDTO.getUpgradeOrderNum() != null) { if (detailDTO.getCommissionTypeValue() != null && detailDTO.getUpgradeOrderNum() != null) {
commission = detailDTO.getCommissionTypeValue().multiply(BigDecimal.valueOf(detailDTO.getUpgradeOrderNum())); commission = detailDTO.getCommissionTypeValue().multiply(BigDecimal.valueOf(detailDTO.getUpgradeOrderNum()));
log.info("commission:{},commissionTypeValue:{},upgradeOrderNum:{}", commission, detailDTO.getCommissionTypeValue(), detailDTO.getUpgradeOrderNum());
}else{ }else{
log.warn("按固定金额计算,提成类型值或升级订单数为空"); log.warn("按固定金额计算,提成类型值或升级订单数为空");
} }
...@@ -666,10 +678,12 @@ public class StaffPerformanceCalService { ...@@ -666,10 +678,12 @@ public class StaffPerformanceCalService {
commission = detailDTO.getGmvOutput() commission = detailDTO.getGmvOutput()
.multiply(detailDTO.getCommissionTypeValue()) .multiply(detailDTO.getCommissionTypeValue())
.divide(CommonConstants.ONEHUNDRED_BIGDECIMAL, 2, BigDecimal.ROUND_HALF_UP); .divide(CommonConstants.ONEHUNDRED_BIGDECIMAL, 2, BigDecimal.ROUND_HALF_UP);
log.info("commission:{},commissionTypeValue:{}", commission, detailDTO.getCommissionTypeValue());
} }
// 加上额外奖惩金额(扣减或奖励) // 加上额外奖惩金额(扣减或奖励)
if (commission != null && detailDTO.getExtraPerformanceAmount() != null) { if (commission != null && detailDTO.getExtraPerformanceAmount() != null) {
commission = commission.add(detailDTO.getExtraPerformanceAmount()); commission = commission.add(detailDTO.getExtraPerformanceAmount());
log.info("commission:{},extraPerformanceAmount:{}", commission,detailDTO.getExtraPerformanceAmount());
} }
detailDTO.setPerformanceAmount(commission); detailDTO.setPerformanceAmount(commission);
} }
...@@ -684,7 +698,9 @@ public class StaffPerformanceCalService { ...@@ -684,7 +698,9 @@ public class StaffPerformanceCalService {
*/ */
private void calculateByConditions(StaffPerformanceDetailDTO detailDTO, PerformanceParamConfigDTO paramConfig, private void calculateByConditions(StaffPerformanceDetailDTO detailDTO, PerformanceParamConfigDTO paramConfig,
List<PerformanceParamConfigDTO> paramConfigs, StaffPerformanceCalContextDTO context) { List<PerformanceParamConfigDTO> paramConfigs, StaffPerformanceCalContextDTO context) {
log.info("进入条件计算额外的提成参数(如扣减、奖励、降档等)");
if (CollectionUtils.isEmpty(paramConfig.getPerformanceParamConfigConditions())) { if (CollectionUtils.isEmpty(paramConfig.getPerformanceParamConfigConditions())) {
log.info("无处理-条件计算额外的提成参数(如扣减、奖励、降档等)");
return; return;
} }
if (!Objects.equals(paramConfig.getAssessmentFactor(), if (!Objects.equals(paramConfig.getAssessmentFactor(),
...@@ -705,7 +721,7 @@ public class StaffPerformanceCalService { ...@@ -705,7 +721,7 @@ public class StaffPerformanceCalService {
// 是否跳过渗透率限制条件类型的继续判断 // 是否跳过渗透率限制条件类型的继续判断
boolean skipPenetrationRateCondition = false; boolean skipPenetrationRateCondition = false;
log.info("= 开始计算条件: paramConfigId={}", paramConfig.getId()); log.info("= 根据条件计算额外的提成参数(如扣减、奖励、降档等)- 开始计算条件: paramConfigId={}", paramConfig.getId());
for (PerformanceParamConfigConditionDTO condition : paramConfig.getPerformanceParamConfigConditions()) { for (PerformanceParamConfigConditionDTO condition : paramConfig.getPerformanceParamConfigConditions()) {
log.info("==处理条件: conditionId={}, conditionType={}", condition.getId(), log.info("==处理条件: conditionId={}, conditionType={}", condition.getId(),
...@@ -1252,6 +1268,7 @@ public class StaffPerformanceCalService { ...@@ -1252,6 +1268,7 @@ public class StaffPerformanceCalService {
log.info("开始提成配置计算: staffPhone={}, month={}, merchantName={}, businessType={}, brandName={}, childBrandName={}", log.info("开始提成配置计算: staffPhone={}, month={}, merchantName={}, businessType={}, brandName={}, childBrandName={}",
context.getStaffPhone(), context.getPerformanceMonth(), context.getMerchantName(), context.getStaffPhone(), context.getPerformanceMonth(), context.getMerchantName(),
context.getBusinessType(), context.getBrandName(), context.getChildBrandName()); context.getBusinessType(), context.getBrandName(), context.getChildBrandName());
log.info("上下文-context:{}", JSONUtil.toJsonStr(context));
// 配置按照考核因子+品类信息分组 // 配置按照考核因子+品类信息分组
List<StaffPerformanceDetailDTO> groupResults = new ArrayList<>(); List<StaffPerformanceDetailDTO> groupResults = new ArrayList<>();
Map<String, List<PerformanceParamConfigDTO>> paramConfigGroupMap = context.getPerformanceConfig() Map<String, List<PerformanceParamConfigDTO>> paramConfigGroupMap = context.getPerformanceConfig()
...@@ -1351,6 +1368,7 @@ public class StaffPerformanceCalService { ...@@ -1351,6 +1368,7 @@ public class StaffPerformanceCalService {
// 1. 获取圈定商品定义(如果有) // 1. 获取圈定商品定义(如果有)
MerchantPerformanceProductDefineDTO productDefine = getMerchantPerformanceProductDefine(goodsConfigType, MerchantPerformanceProductDefineDTO productDefine = getMerchantPerformanceProductDefine(goodsConfigType,
productDefineId); productDefineId);
log.info("获取圈定商品定义-productDefine:{}", JSONUtil.toJsonStr(productDefine));
// 2. 获取有效订单类型配置 // 2. 获取有效订单类型配置
final List<Byte> validOrderTypes = getValidDjOrderTypesForCommissionBasic(); final List<Byte> validOrderTypes = getValidDjOrderTypesForCommissionBasic();
...@@ -1421,7 +1439,11 @@ public class StaffPerformanceCalService { ...@@ -1421,7 +1439,11 @@ public class StaffPerformanceCalService {
MerchantPerformanceProductDefineDTO productDefine, MerchantPerformanceProductDefineDTO productDefine,
List<Byte> validOrderTypes) { List<Byte> validOrderTypes) {
log.info("处理品类/单品数据: orders.size={}", orders.size()); log.info("处理品类/单品数据: orders.size={}", orders.size());
if (CollUtil.isNotEmpty(orders)) {
for (StaffPerformanceSubOrderDTO order : orders) {
log.info("处理品类或指定商品的数据计算:orderCode:{},subOrderCode:{}", order.getOrderCode(), order.getSubOrderCode());
}
}
// 筛选符合条件的订单 // 筛选符合条件的订单
List<StaffPerformanceSubOrderDTO> filteredOrders = orders.stream() List<StaffPerformanceSubOrderDTO> filteredOrders = orders.stream()
.filter(o -> StaffPerformanceOrderUtil.isOrderMatchCategory(o, goodsConfigType, .filter(o -> StaffPerformanceOrderUtil.isOrderMatchCategory(o, goodsConfigType,
...@@ -1446,7 +1468,7 @@ public class StaffPerformanceCalService { ...@@ -1446,7 +1468,7 @@ public class StaffPerformanceCalService {
orderData.setSubOrderCountByBrandAndCategory(subOrderCount); orderData.setSubOrderCountByBrandAndCategory(subOrderCount);
orderData.setCategoryOrderOutputTotalByBrandAndCategory(outputTotal); orderData.setCategoryOrderOutputTotalByBrandAndCategory(outputTotal);
log.debug("品类/单品基础数据: mainOrderCount={}, subOrderCount={}, outputTotal={}", mainOrderCount, log.info("品类/单品基础数据: mainOrderCount={}, subOrderCount={}, outputTotal={}", mainOrderCount,
subOrderCount, subOrderCount,
outputTotal); outputTotal);
...@@ -1463,7 +1485,7 @@ public class StaffPerformanceCalService { ...@@ -1463,7 +1485,7 @@ public class StaffPerformanceCalService {
orderData.setCommissionBaseSubOrderCountByBrandAndCategory(commissionBaseSubOrderCount); orderData.setCommissionBaseSubOrderCountByBrandAndCategory(commissionBaseSubOrderCount);
orderData.setCommissionBaseCategoryOrderOutputTotalByBrandAndCategory(commissionBaseOutputTotal); orderData.setCommissionBaseCategoryOrderOutputTotalByBrandAndCategory(commissionBaseOutputTotal);
log.debug("品类/单品提成基数数据: baseSubOrderCount={}, baseOutputTotal={}", commissionBaseSubOrderCount, log.info("品类/单品提成基数数据: baseSubOrderCount={}, baseOutputTotal={}", commissionBaseSubOrderCount,
commissionBaseOutputTotal); commissionBaseOutputTotal);
} }
...@@ -1507,7 +1529,7 @@ public class StaffPerformanceCalService { ...@@ -1507,7 +1529,7 @@ public class StaffPerformanceCalService {
orderData.setSubOrderCountByBrandAndCategory(subOrderCount); orderData.setSubOrderCountByBrandAndCategory(subOrderCount);
orderData.setCategoryOrderOutputTotalByBrandAndCategory(outputTotal); orderData.setCategoryOrderOutputTotalByBrandAndCategory(outputTotal);
log.debug("套系基础数据: mainOrderCount={}, outputTotal={}", mainOrderCount, outputTotal); log.info("套系基础数据: mainOrderCount={}, outputTotal={}", mainOrderCount, outputTotal);
// 计算提成基数相关数据 (过滤特定订单类型) // 计算提成基数相关数据 (过滤特定订单类型)
// 注意:这里原文是 filter groupedOrders.values() 再 filter matchPackage,这里直接复用 // 注意:这里原文是 filter groupedOrders.values() 再 filter matchPackage,这里直接复用
...@@ -1527,7 +1549,7 @@ public class StaffPerformanceCalService { ...@@ -1527,7 +1549,7 @@ public class StaffPerformanceCalService {
orderData.setCommissionBaseSubOrderCountByBrandAndCategory(commissionBaseMainOrderCount); orderData.setCommissionBaseSubOrderCountByBrandAndCategory(commissionBaseMainOrderCount);
orderData.setCommissionBaseCategoryOrderOutputTotalByBrandAndCategory(commissionBaseOutputTotal); orderData.setCommissionBaseCategoryOrderOutputTotalByBrandAndCategory(commissionBaseOutputTotal);
log.debug("套系提成基数数据: baseMainOrderCount={}, baseOutputTotal={}", commissionBaseMainOrderCount, log.info("套系提成基数数据: baseMainOrderCount={}, baseOutputTotal={}", commissionBaseMainOrderCount,
commissionBaseOutputTotal); commissionBaseOutputTotal);
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!