修改分佣算法添加异常费率判断处理
This commit is contained in:
@@ -68,11 +68,14 @@ public class MerchantProfitServiceImpl extends ServiceImpl<MerchantProfitMapper,
|
|||||||
boolean flag = true;
|
boolean flag = true;
|
||||||
String amt = "0.0";
|
String amt = "0.0";
|
||||||
try {
|
try {
|
||||||
|
if(profitMoney.compareTo(new BigDecimal(0.009))<0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
//解决通知分润带有科学计数法
|
//解决通知分润带有科学计数法
|
||||||
amt = profitMoney.stripTrailingZeros().toPlainString();
|
amt = profitMoney.stripTrailingZeros().toPlainString();
|
||||||
Notice notice = new Notice(0, 6, userApp);
|
Notice notice = new Notice(0, 6, userApp);
|
||||||
|
|
||||||
amt = String.format("%.2f", amt);
|
amt = String.format("%.2f", Double.valueOf(amt));
|
||||||
|
|
||||||
notice.setConrtent("您有一笔" + amt + "元的推广分润");
|
notice.setConrtent("您有一笔" + amt + "元的推广分润");
|
||||||
notice.setUniqueKey(userApp.getUserId() + orderNumber + "profit");
|
notice.setUniqueKey(userApp.getUserId() + orderNumber + "profit");
|
||||||
@@ -167,44 +170,81 @@ public class MerchantProfitServiceImpl extends ServiceImpl<MerchantProfitMapper,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if("0".equals(userPromotion.getParentUserId())){
|
// if("0".equals(userPromotion.getParentUserId())){
|
||||||
log.error("订单号:{} 父级为:{},父级类型:{},分润结束,获取分润数为:{},",order.getOrderNumber(),userPromotion.getParentUserId(),userPromotion.getTypeCode(),profits.size());
|
// log.error("订单号:{} 父级为:{},父级类型:{},分润结束,获取分润数为:{},",order.getOrderNumber(),userPromotion.getParentUserId(),userPromotion.getTypeCode(),profits.size());
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
BigDecimal profitRate = BigDecimal.ZERO;
|
if("MC".equals(userPromotion.getTypeCode())){
|
||||||
|
if("1".equals(userPromotion.getIsExtend())||"2".equals(userPromotion.getIsExtend())){
|
||||||
|
BigDecimal profitRate = BigDecimal.ZERO;
|
||||||
|
|
||||||
if (nowRate.compareTo(new BigDecimal(userPromotion.getCurrentFee())) >= 0) {
|
if (nowRate.compareTo(new BigDecimal(userPromotion.getCurrentFee())) >= 0) {
|
||||||
profitRate = nowRate.subtract(new BigDecimal(userPromotion.getCurrentFee()));
|
profitRate = nowRate.subtract(new BigDecimal(userPromotion.getCurrentFee()));
|
||||||
nowRate = 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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");
|
||||||
|
profits.add(profit);
|
||||||
|
sendProfitMessage(pUserApp, profitAmt, order.getOrderNumber());
|
||||||
|
createUserV3Profit(order,userPromotion.getParentUserId(),profits,new BigDecimal(userPromotion.getCurrentFee()));
|
||||||
|
|
||||||
|
}else {
|
||||||
|
createUserV3Profit(order,userPromotion.getParentUserId(),profits,new BigDecimal(userPromotion.getCurrentFee()));
|
||||||
|
}
|
||||||
}else {
|
}else {
|
||||||
return;
|
BigDecimal profitRate = BigDecimal.ZERO;
|
||||||
}
|
|
||||||
|
|
||||||
if(!"1".equals(userPromotion.getIsExtend())||!"2".equals(userPromotion.getIsExtend())){
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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");
|
||||||
|
profits.add(profit);
|
||||||
|
sendProfitMessage(nowUserApp, profitAmt, order.getOrderNumber());
|
||||||
createUserV3Profit(order,userPromotion.getParentUserId(),profits,new BigDecimal(userPromotion.getCurrentFee()));
|
createUserV3Profit(order,userPromotion.getParentUserId(),profits,new BigDecimal(userPromotion.getCurrentFee()));
|
||||||
}
|
|
||||||
|
|
||||||
UserApp nowUserApp = userAppMapper.selectByUserId(userId);
|
|
||||||
if(ObjectUtil.isEmpty(nowUserApp)){
|
|
||||||
log.error("订单号:{},分润结束,获取分润数为:{}",order.getOrderNumber(),profits.size());
|
|
||||||
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(10000)).multiply(BigDecimal.valueOf(order.getConsumeFee())).setScale(4, BigDecimal.ROUND_DOWN);
|
|
||||||
MerchantProfit profit = new MerchantProfit(nowUserApp, pUserApp, order, profitAmt, profitRate, "5", "1");
|
|
||||||
profits.add(profit);
|
|
||||||
sendProfitMessage(pUserApp, profitAmt, order.getOrderNumber());
|
|
||||||
createUserV3Profit(order,userPromotion.getParentUserId(),profits,new BigDecimal(userPromotion.getCurrentFee()));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -197,6 +197,7 @@ public class NotifyMessageServiceImpl implements NotifyMessageService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void sendPayMessage(MerchantOrder order, String type, JSONObject params, String mercId) {
|
public void sendPayMessage(MerchantOrder order, String type, JSONObject params, String mercId) {
|
||||||
|
logger.info(">>>>>>>>>>>>>>>>>>>>发送支付消息: {}",order.getMercNotifyUrl());
|
||||||
sendLowerPayNotifyCallback(order);
|
sendLowerPayNotifyCallback(order);
|
||||||
String orderType = order.getOrderType();
|
String orderType = order.getOrderType();
|
||||||
int val = PayMessageType.PLAIN_PAY.getValue();
|
int val = PayMessageType.PLAIN_PAY.getValue();
|
||||||
|
|||||||
Reference in New Issue
Block a user