分销金额

This commit is contained in:
张松
2025-10-29 19:29:41 +08:00
parent d6708cf5d3
commit 3995b95148
2 changed files with 9 additions and 5 deletions

View File

@@ -109,5 +109,7 @@ public class MkDistributionFlow implements Serializable {
private Long sourceShopUserId;
private String nickName;
private Long sourceDistributionUserId;
private LocalDateTime deliverTime;
}

View File

@@ -2,6 +2,7 @@ package com.czg.service.market.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.IdcardUtil;
import cn.hutool.core.util.StrUtil;
@@ -555,7 +556,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
}
private void deepReward(MkDistributionConfigVO config, ShopUser sourceShopUser, BigDecimal amount, Long sourceId, String type, String orderNo, Integer currentLevel) {
private void deepReward(ShopUser orderSourceShopUser, MkDistributionConfigVO config, ShopUser sourceShopUser, BigDecimal amount, Long sourceId, String type, String orderNo, Integer currentLevel) {
if (currentLevel > 2) {
return;
}
@@ -571,7 +572,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
return;
}
try {
deepReward(config, shopUserService.getById(parent.getId()), amount, sourceId, type, orderNo, ++currentLevel);
deepReward(orderSourceShopUser, config, shopUserService.getById(parent.getId()), amount, sourceId, type, orderNo, ++currentLevel);
} catch (Exception e) {
log.warn("分销奖励失败: {}", e.getMessage());
}
@@ -610,8 +611,9 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
MkDistributionFlow mkDistributionFlow = new MkDistributionFlow().setShopUserId(distributionUser.getId())
.setShopId(distributionUser.getShopId()).setDistributionUserId(distributionUser.getId())
.setNickName(shopUser.getNickName()).setSourceShopUserId(sourceShopUser.getId())
.setLevelId(distributionUser.getDistributionLevelId()).setLevel(currentLevel == 1 ? 1 : 2).setSourceNickName(sourceShopUser.getNickName()).setOrderNo(orderNo)
.setNickName(shopUser.getNickName()).setSourceShopUserId(orderSourceShopUser.getId()).setSourceNickName(orderSourceShopUser.getNickName())
.setSourceDistributionUserId(orderSourceShopUser.getId()).setDeliverTime(config.getSettlementDay() == 0 ? null : DateUtil.offsetDay(DateUtil.date(), config.getSettlementDay()).toLocalDateTime())
.setLevelId(distributionUser.getDistributionLevelId()).setLevel(currentLevel == 1 ? 1 : 2).setOrderNo(orderNo)
.setSourceId(sourceId).setAmount(amount).setType(type).setStatus(flag ? TableValueConstant.DistributionFlow.Status.SUCCESS.getCode() :
TableValueConstant.DistributionFlow.Status.PENDING.getCode())
.setRewardAmount(rewardAmount).setBillNo(IdUtil.simpleUUID());
@@ -644,7 +646,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
log.info("开始分销, 当前来源用户: {}, shopId: {}, 邀请人id: {}", sourceUserId, shopId, sourceShopUserInfo.getDistributionUserId());
ShopUser parentUserInfo = shopUserService.getById(sourceShopUserInfo.getDistributionUserId());
deepReward(config, parentUserInfo, amount, sourceId, type, orderNo, 1);
deepReward(sourceShopUserInfo, config, parentUserInfo, amount, sourceId, type, orderNo, 1);
});
}