修改分佣算法添加异常费率判断处理

This commit is contained in:
韩鹏辉 2023-07-14 16:41:37 +08:00
parent 22179ce8de
commit 542a1079a0
1 changed files with 15 additions and 20 deletions

View File

@ -139,7 +139,18 @@ public class MerchantProfitServiceImpl extends ServiceImpl<MerchantProfitMapper,
// return;
// }
createUserV3Profit(order,order.getUserId().toString(),profitList,order.getRate());
UserPromotion userPromotion= userPromotionMapper.selectByUserId(order.getUserId().toString());
if(ObjectUtil.isEmpty(userPromotion)){
log.error("订单号:{},用户信息不存在",order.getOrderNumber());
return;
}
if("SO".equals(userPromotion.getTypeCode())||"FO".equals(userPromotion.getTypeCode())||"MG".equals(userPromotion.getTypeCode())){
log.error("此为系统用户不参与分润");
return;
}
createUserV3Profit(order,userPromotion.getParentUserId(),profitList,order.getRate().divide(BigDecimal.valueOf(100)));
if (!profitList.isEmpty()) {
log.info("【分润计算完成】开始批量插入分润数据,生成分润的订单编号:{},分润条数:{}", order.getOrderNumber(), profitList.size());
@ -194,18 +205,10 @@ public class MerchantProfitServiceImpl extends ServiceImpl<MerchantProfitMapper,
return;
}
QueryWrapper<UserApp> queryWrapper=new QueryWrapper<>();
queryWrapper.eq("userId",userPromotion.getParentUserId());
UserApp pUserApp=userAppMapper.selectOne(queryWrapper);
if(ObjectUtil.isEmpty(pUserApp)){
log.error("订单号:{},分润结束,获取分润数为:{}",order.getOrderNumber(),profits.size());
return;
}
BigDecimal profitAmt = profitRate.divide(BigDecimal.valueOf(100)).multiply(BigDecimal.valueOf(order.getConsumeFee())).setScale(4, BigDecimal.ROUND_DOWN);
MerchantProfit profit = new MerchantProfit(nowUserApp, pUserApp, order, profitAmt, profitRate, "5", "1");
MerchantProfit profit = new MerchantProfit(nowUserApp, nowUserApp, order, profitAmt, profitRate, "5", "1");
profits.add(profit);
sendProfitMessage(pUserApp, profitAmt, order.getOrderNumber());
sendProfitMessage(nowUserApp, profitAmt, order.getOrderNumber());
createUserV3Profit(order,userPromotion.getParentUserId(),profits,new BigDecimal(userPromotion.getCurrentFee()));
}else {
@ -229,16 +232,8 @@ public class MerchantProfitServiceImpl extends ServiceImpl<MerchantProfitMapper,
return;
}
// QueryWrapper<UserApp> queryWrapper=new QueryWrapper<>();
// queryWrapper.eq("userId",userPromotion.getParentUserId());
// UserApp pUserApp=userAppMapper.selectOne(queryWrapper);
// if(ObjectUtil.isEmpty(pUserApp)){
// log.error("订单号:{},分润结束,获取分润数为:{}",order.getOrderNumber(),profits.size());
// return;
// }
BigDecimal profitAmt = profitRate.divide(BigDecimal.valueOf(100)).multiply(BigDecimal.valueOf(order.getConsumeFee())).setScale(4, BigDecimal.ROUND_DOWN);
MerchantProfit profit = new MerchantProfit(nowUserApp, nowUserApp, order, profitAmt, profitRate, "5", "1");
MerchantProfit profit = new MerchantProfit(nowUserApp,nowUserApp , order, profitAmt, profitRate, "5", "1");
profits.add(profit);
sendProfitMessage(nowUserApp, profitAmt, order.getOrderNumber());
createUserV3Profit(order,userPromotion.getParentUserId(),profits,new BigDecimal(userPromotion.getCurrentFee()));