分销修改
This commit is contained in:
@@ -578,7 +578,8 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
AssertUtil.isNull(currentDistributionUser, "分销员不存在");
|
||||
AssertUtil.isTrue(currentDistributionUser.getStatus() != 1, "分销员未开启");
|
||||
|
||||
ShopUser currentShopUser = shopUserService.getById(currentDistributionUser.getId());
|
||||
// ShopUser currentShopUser = shopUserService.getById(currentDistributionUser.getId());
|
||||
ShopUserInvite currentShopUser = shopUserInviteService.getOneByShopIdAndShopUserId(config.getShopId(), currentDistributionUser.getId());
|
||||
MkDistributionLevelConfig level = levelConfigService.getById(currentDistributionUser.getDistributionLevelId());
|
||||
|
||||
// 校验剩余分成比例
|
||||
@@ -639,10 +640,10 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
log.info("即时分销开始");
|
||||
try {
|
||||
updateShopInfoAmount(currentDistributionUser.getShopId(), rewardAmount.negate(), sourceId, TableValueConstant.DistributionAmountFlow.Type.SUB, "分销扣除");
|
||||
updateIncome(BigDecimal.ZERO, rewardAmount, BigDecimal.ZERO, currentDistributionUser.getId(), shopUser.getUserId(), shopUser.getMainShopId(), currentLevel == 1 ? 1 : 2);
|
||||
updateIncome(BigDecimal.ZERO, rewardAmount, BigDecimal.ZERO, currentDistributionUser.getId(), shopUser.getUserId(), shopUser.getId(), config.getShopId(), currentLevel == 1 ? 1 : 2);
|
||||
} catch (Exception e) {
|
||||
mkDistributionFlow.setStatus(TableValueConstant.DistributionFlow.Status.PENDING.getCode());
|
||||
updateIncome(rewardAmount, BigDecimal.ZERO, BigDecimal.ZERO, currentDistributionUser.getId(), shopUser.getUserId(), shopUser.getMainShopId(), currentLevel == 1 ? 1 : 2);
|
||||
updateIncome(rewardAmount, BigDecimal.ZERO, BigDecimal.ZERO, currentDistributionUser.getId(), shopUser.getUserId(), shopUser.getId(), config.getShopId(), currentLevel == 1 ? 1 : 2);
|
||||
distributionFlowService.updateById(mkDistributionFlow);
|
||||
}
|
||||
} else {
|
||||
@@ -650,7 +651,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
mkDistributionFlow.setStatus(TableValueConstant.DistributionFlow.Status.PENDING.getCode());
|
||||
distributionFlowService.save(mkDistributionFlow);
|
||||
log.info("延时分销开始");
|
||||
updateIncome(rewardAmount, BigDecimal.ZERO, BigDecimal.ZERO, currentDistributionUser.getId(), shopUser.getUserId(), shopUser.getMainShopId(), currentLevel == 1 ? 1 : 2);
|
||||
updateIncome(rewardAmount, BigDecimal.ZERO, BigDecimal.ZERO, currentDistributionUser.getId(), shopUser.getUserId(), shopUser.getId(), config.getShopId(), currentLevel == 1 ? 1 : 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -681,11 +682,11 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
refundFlow.setUpdateTime(DateUtil.date().toLocalDateTime());
|
||||
if (TableValueConstant.DistributionFlow.Status.PENDING.getCode().equals(item.getStatus())) {
|
||||
item.setStatus(TableValueConstant.DistributionFlow.Status.SUCCESS.getCode());
|
||||
updateIncome(item.getRewardAmount().negate(), BigDecimal.ZERO, BigDecimal.ZERO, item.getDistributionUserId(), item.getUserId(), item.getShopId(), item.getLevel());
|
||||
updateIncome(item.getRewardAmount().negate(), BigDecimal.ZERO, BigDecimal.ZERO, item.getDistributionUserId(), item.getUserId(), item.getShopUserId(), item.getShopId(), item.getLevel());
|
||||
distributionFlowService.updateById(item);
|
||||
} else {
|
||||
// 执行扣款
|
||||
updateIncome(BigDecimal.ZERO, item.getRewardAmount().negate(), BigDecimal.ZERO, item.getDistributionUserId(), item.getUserId(), item.getShopId(), item.getLevel());
|
||||
updateIncome(BigDecimal.ZERO, item.getRewardAmount().negate(), BigDecimal.ZERO, item.getDistributionUserId(), item.getUserId(),item.getShopUserId(), item.getShopId(), item.getLevel());
|
||||
updateShopInfoAmount(item.getShopId(), item.getRewardAmount(), orderId, TableValueConstant.DistributionAmountFlow.Type.REFUND, "分销回退");
|
||||
}
|
||||
distributionFlowService.save(refundFlow);
|
||||
@@ -701,12 +702,13 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
AssertUtil.isTrue(config.getIsEnable() != 1, "分销未开启");
|
||||
// 当前用户上级分销员
|
||||
ShopUser sourceShopUserInfo = shopUserService.getShopUserInfo(shopId, sourceUserId);
|
||||
if (sourceShopUserInfo.getDistributionUserId() == null) {
|
||||
ShopUserInvite sourceInviteUser = shopUserInviteService.getOneByShopIdAndShopUserId(shopId, sourceShopUserInfo.getId());
|
||||
if (sourceInviteUser.getDistributionUserId() == null) {
|
||||
return;
|
||||
}
|
||||
log.info("开始分销, 当前来源用户: {}, shopId: {}, 邀请人id: {}", sourceUserId, shopId, sourceShopUserInfo.getDistributionUserId());
|
||||
log.info("开始分销, 当前来源用户: {}, shopId: {}, 邀请人id: {}", sourceUserId, shopId, sourceInviteUser.getDistributionUserId());
|
||||
|
||||
MkDistributionUser distributionUser = getById(sourceShopUserInfo.getDistributionUserId());
|
||||
MkDistributionUser distributionUser = getById(sourceInviteUser.getDistributionUserId());
|
||||
deepReward(sourceShopUserInfo, null, config, distributionUser, amount, sourceId, type, orderNo, 1);
|
||||
});
|
||||
distributionDeliverService.save(deliver);
|
||||
@@ -714,9 +716,9 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateIncome(BigDecimal pendingIncome, BigDecimal receivedIncome, BigDecimal withdrawIncome, Long id, Long userId, Long mainShopId, Integer isOne) {
|
||||
public void updateIncome(BigDecimal pendingIncome, BigDecimal receivedIncome, BigDecimal withdrawIncome, Long id, Long userId, Long shopUserId, Long shopId, Integer isOne) {
|
||||
// 用户收益信息
|
||||
shopUserService.updateOneOrTwoAmount(userId, mainShopId, receivedIncome, isOne);
|
||||
shopUserService.updateOneOrTwoAmount(shopUserId, shopId, receivedIncome, isOne);
|
||||
// 用户可提现余额
|
||||
userInfoService.updateDistributionAmount(userId, receivedIncome);
|
||||
//分销员余额
|
||||
|
||||
Reference in New Issue
Block a user