|
|
|
|
@@ -579,6 +579,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|
|
|
|
|
|
|
|
|
MkDistributionLevelConfig level = levelConfigService.getById(distributionUser.getDistributionLevelId());
|
|
|
|
|
AssertUtil.isNull(level, "分销等级不存在");
|
|
|
|
|
log.info("当前分销员: {}, 上级分销员: {}, 分销等级: {}", distributionUser.getId(), sourceShopUser.getDistributionUserParentId(), level.getId());
|
|
|
|
|
|
|
|
|
|
if (config.getRewardCount() != null && config.getRewardCount() > 0) {
|
|
|
|
|
long count = distributionFlowService.count(new QueryWrapper().eq(MkDistributionFlow::getSourceShopUserId, sourceShopUser.getId())
|
|
|
|
|
@@ -617,7 +618,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|
|
|
|
distributionFlowService.save(mkDistributionFlow);
|
|
|
|
|
|
|
|
|
|
updateIncome(!flag ? rewardAmount : BigDecimal.ZERO,
|
|
|
|
|
flag ? rewardAmount : BigDecimal.ZERO, BigDecimal.ZERO, distributionUser.getId(), shopUser.getUserId());
|
|
|
|
|
flag ? rewardAmount : BigDecimal.ZERO, BigDecimal.ZERO, distributionUser.getId(), shopUser.getUserId(), currentLevel == 1 ? 1 : 2);
|
|
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
|
distributionAmountFlowService.save(new MkDistributionAmountFlow()
|
|
|
|
|
@@ -640,6 +641,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|
|
|
|
if (sourceShopUserInfo.getDistributionUserId() == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
log.info("开始分销, 当前来源用户: {}, shopId: {}, 邀请人id: {}", sourceUserId, shopId, sourceShopUserInfo.getDistributionUserId());
|
|
|
|
|
|
|
|
|
|
ShopUser parentUserInfo = shopUserService.getById(sourceShopUserInfo.getDistributionUserId());
|
|
|
|
|
deepReward(config, parentUserInfo, amount, sourceId, type, orderNo, 1);
|
|
|
|
|
@@ -647,8 +649,8 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void updateIncome(BigDecimal pendingIncome, BigDecimal receivedIncome, BigDecimal withdrawIncome, Long id, Long userId) {
|
|
|
|
|
userInfoService.updateDistributionAmount(userId, receivedIncome);
|
|
|
|
|
public void updateIncome(BigDecimal pendingIncome, BigDecimal receivedIncome, BigDecimal withdrawIncome, Long id, Long userId, Integer isOne) {
|
|
|
|
|
userInfoService.updateDistributionAmount(userId, receivedIncome, isOne);
|
|
|
|
|
boolean flag = mapper.updateIncome(pendingIncome, receivedIncome, withdrawIncome, id);
|
|
|
|
|
if (!flag) {
|
|
|
|
|
throw new CzgException("操作失败");
|
|
|
|
|
@@ -674,7 +676,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|
|
|
|
JSONObject jsonObject = appWxService.transferBalance(userInfo.getWechatOpenId(), userInfo.getRealName(), finalAmount, "提现", withdrawFlow.getBillNo());
|
|
|
|
|
withdrawFlow.setPackageInfo(jsonObject.getString("package_info"));
|
|
|
|
|
// 扣减余额
|
|
|
|
|
userInfoService.updateDistributionAmount(userId, withdrawFlowDTO.getAmount().negate());
|
|
|
|
|
userInfoService.updateDistributionAmount(userId, withdrawFlowDTO.getAmount().negate(), null);
|
|
|
|
|
return withdrawFlowService.save(withdrawFlow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -705,7 +707,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|
|
|
|
case "CANCELLED":
|
|
|
|
|
flow.setStatus(TableValueConstant.DistributionWithdrawFlow.Status.FAIL.getCode());
|
|
|
|
|
// 扣减余额
|
|
|
|
|
userInfoService.updateDistributionAmount(flow.getUserId(), flow.getAmount().add(flow.getServiceFee()));
|
|
|
|
|
userInfoService.updateDistributionAmount(flow.getUserId(), flow.getAmount().add(flow.getServiceFee()), null);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|