diff --git a/pluss-service-bundle/src/main/java/cn/pluss/platform/merchantProfit/impl/MerchantProfitServiceImpl.java b/pluss-service-bundle/src/main/java/cn/pluss/platform/merchantProfit/impl/MerchantProfitServiceImpl.java index fb17b0a..e875802 100644 --- a/pluss-service-bundle/src/main/java/cn/pluss/platform/merchantProfit/impl/MerchantProfitServiceImpl.java +++ b/pluss-service-bundle/src/main/java/cn/pluss/platform/merchantProfit/impl/MerchantProfitServiceImpl.java @@ -351,33 +351,39 @@ public class MerchantProfitServiceImpl extends ServiceImpl= 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; @@ -416,11 +422,22 @@ public class MerchantProfitServiceImpl extends ServiceImpl