修改可提金额判断

This commit is contained in:
韩鹏辉
2023-08-26 15:46:14 +08:00
parent 01e435f575
commit 8e0b1627b4
2 changed files with 46 additions and 29 deletions

View File

@@ -337,33 +337,39 @@ public class MerchantProfitServiceImpl extends ServiceImpl<MerchantProfitMapper,
// }
if("MC".equals(userPromotion.getTypeCode())){
createUserV3Profit(order,userPromotion.getParentUserId(),profits,accounts,accountFlows,new BigDecimal(userPromotion.getCurrentFee()));
// if("1".equals(userPromotion.getIsExtend())||"2".equals(userPromotion.getIsExtend())){
// BigDecimal profitRate = BigDecimal.ZERO;
//
// if (nowRate.compareTo(new BigDecimal(userPromotion.getCurrentFee())) >= 0) {
// profitRate = nowRate.subtract(new BigDecimal(userPromotion.getCurrentFee()));
// nowRate = new BigDecimal(userPromotion.getCurrentFee());
// }else {
// return;
// }
//
// UserApp nowUserApp = userAppMapper.selectByUserId(userId);
// if(ObjectUtil.isEmpty(nowUserApp)){
// log.error("订单号:{},分润结束,获取分润数为:{}",order.getOrderNumber(),profits.size());
// return;
// }
//
// log.info("userId:{},rate:{},amount:{}",nowUserApp.getUserId(),profitRate,order.getConsumeFee());
// 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");
// profits.add(profit);
// sendProfitMessage(nowUserApp, profitAmt, order.getOrderNumber());
// createUserV3Profit(order,userPromotion.getParentUserId(),profits,new BigDecimal(userPromotion.getCurrentFee()));
//
// }else {
// createUserV3Profit(order,userPromotion.getParentUserId(),profits,new BigDecimal(userPromotion.getCurrentFee()));
// }
// createUserV3Profit(order,userPromotion.getParentUserId(),profits,accounts,accountFlows,new BigDecimal(userPromotion.getCurrentFee()));
if("1".equals(userPromotion.getIsExtend())){
userPromotion= getUserPromotion(Long.valueOf(userPromotion.getParentUserId()));
BigDecimal profitRate = BigDecimal.ZERO;
if (nowRate.compareTo(new BigDecimal(userPromotion.getCurrentFee())) >= 0) {
profitRate = nowRate.subtract(new BigDecimal(userPromotion.getCurrentFee()));
nowRate = new BigDecimal(userPromotion.getCurrentFee());
}else {
return;
}
UserApp nowUserApp = userAppMapper.selectByUserId(userId);
if(ObjectUtil.isEmpty(nowUserApp)){
log.error("订单号:{},分润结束,获取分润数为:{}",order.getOrderNumber(),profits.size());
return;
}
log.info("userId:{},rate:{},amount:{}",nowUserApp.getUserId(),profitRate,order.getConsumeFee());
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");
profits.add(profit);
sendProfitMessage(nowUserApp, profitAmt, order.getOrderNumber());
createUserV3Profit(order,userPromotion.getParentUserId(),profits,accounts,accountFlows,new BigDecimal(userPromotion.getCurrentFee()));
}else {
createUserV3Profit(order,userPromotion.getParentUserId(),profits,accounts,accountFlows,new BigDecimal(userPromotion.getCurrentFee()));
}
}else {
BigDecimal profitRate = BigDecimal.ZERO;
@@ -402,11 +408,22 @@ public class MerchantProfitServiceImpl extends ServiceImpl<MerchantProfitMapper,
sendProfitMessage(nowUserApp, profitAmt, order.getOrderNumber());
createUserV3Profit(order,userPromotion.getParentUserId(),profits,accounts,accountFlows,new BigDecimal(userPromotion.getCurrentFee()));
}
}
private UserPromotion getUserPromotion(Long userId){
UserPromotion userPromotion= userPromotionMapper.selectByPrimaryKey(userId);
if(ObjectUtil.isNotEmpty(userPromotion)&&"MC".equals(userPromotion.getTypeCode())){
getUserPromotion(Long.valueOf(userPromotion.getParentUserId()));
}
return userPromotion;
}
/**
* 创建2.0分润
*