邀请人列表 条件 添加邀请人 邀请身份 是否有效
This commit is contained in:
@@ -282,7 +282,15 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
newDistributionUser.setInviteCount(parent.getInviteCount() + 1);
|
||||
MkDistributionConfig mkDistributionConfig = mkDistributionConfigService.getOne(QueryWrapper.create()
|
||||
.eq(MkDistributionConfig::getShopId, parent.getShopId()));
|
||||
if (mkDistributionConfig != null && parent.getIsAssignLevel() == 0) {
|
||||
if ("自主申请".equals(parent.getOpeningMethod()) && parent.getStatus() == 0 && mkDistributionConfig != null) {
|
||||
if (newDistributionUser.getInviteCount() >= mkDistributionConfig.getInviteCount()) {
|
||||
ShopUser parentShopUser1 = new ShopUser();
|
||||
parentShopUser1.setId(shopUser.getId());
|
||||
parentShopUser1.upDistributionShop(param.getShopId(), 1);
|
||||
shopUserService.updateById(parentShopUser1);
|
||||
}
|
||||
}
|
||||
if (mkDistributionConfig != null && !"not_upgrade".equals(mkDistributionConfig.getUpgradeType()) && parent.getIsAssignLevel() == 0) {
|
||||
if ("invite".equals(mkDistributionConfig.getUpgradeType())) {
|
||||
if (mkDistributionConfig.getInviteConsume() == 1) {
|
||||
long count = orderInfoService.count(QueryWrapper.create()
|
||||
@@ -296,8 +304,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
MkDistributionLevelConfig levelConfig = levelConfigService.getOne(QueryWrapper.create()
|
||||
.eq(MkDistributionLevelConfig::getShopId, parent.getShopId())
|
||||
.le(MkDistributionLevelConfig::getInviteCount, newDistributionUser.getInviteCount())
|
||||
.gt(MkDistributionLevelConfig::getId, parent.getDistributionLevelId())
|
||||
.orderBy(MkDistributionLevelConfig::getId).asc().limit(1));
|
||||
.orderBy(MkDistributionLevelConfig::getId).desc().limit(1));
|
||||
if (levelConfig != null) {
|
||||
newDistributionUser.setDistributionLevelId(levelConfig.getId());
|
||||
newDistributionUser.setDistributionLevelName(levelConfig.getName());
|
||||
@@ -392,8 +399,8 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<InviteUserVO> getInviteUser(Long id, Long shopUserId, Integer page, Integer size) {
|
||||
return shopUserService.getInviteUser(id, shopUserId, page, size);
|
||||
public Page<InviteUserVO> getInviteUser(Long id, Long shopUserId, Long distributionLevelId, Integer page, Integer size) {
|
||||
return shopUserService.getInviteUser(id, shopUserId, distributionLevelId, page, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -403,25 +410,39 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
AssertUtil.isNull(param.getId(), "店铺用户ID不能为空");
|
||||
ShopUser shopUser = shopUserService.getById(param.getId());
|
||||
AssertUtil.isNull(shopUser, "店铺用户ID不能为空");
|
||||
boolean isExits = shopUser.checkDistributionShops(param.getShopId().toString());
|
||||
if (isExits) {
|
||||
throw new CzgException("该用户已被添加为分销员,不可重复添加");
|
||||
MkDistributionUser distributionUser = getOne(QueryWrapper.create()
|
||||
.eq(MkDistributionUser::getId, param.getId())
|
||||
.eq(MkDistributionUser::getShopId, param.getShopId()));
|
||||
if (distributionUser != null && distributionUser.getStatus() != 0) {
|
||||
throw new CzgException("该用户已是分销员,不可重复添加");
|
||||
}
|
||||
MkDistributionConfig config = mkDistributionConfigService.getOne(
|
||||
QueryWrapper.create().eq(MkDistributionConfig::getShopId, param.getShopId())
|
||||
.eq(MkDistributionConfig::getIsEnable, 1));
|
||||
AssertUtil.isNull(config, "店铺未配置分销");
|
||||
param.setStatus(0);
|
||||
param.setId(param.getId());
|
||||
param.setUserId(shopUser.getUserId());
|
||||
param.setInviteCode(CzgRandomUtils.randomString(10));
|
||||
if (!"自主申请".equals(param.getOpeningMethod()) || config.getInviteCount() == 0) {
|
||||
initLevel(config, param);
|
||||
}
|
||||
save(param);
|
||||
if (distributionUser != null) {
|
||||
distributionUser.setOpeningMethod("手动添加");
|
||||
distributionUser.setDistributionLevelId(param.getDistributionLevelId());
|
||||
distributionUser.setDistributionLevelName(param.getDistributionLevelName());
|
||||
distributionUser.setStatus(1);
|
||||
saveOrUpdate(distributionUser);
|
||||
}else {
|
||||
param.setStatus(0);
|
||||
param.setId(param.getId());
|
||||
param.setUserId(shopUser.getUserId());
|
||||
param.setInviteCode(CzgRandomUtils.randomString(10));
|
||||
saveOrUpdate(param);
|
||||
}
|
||||
ShopUser shopUser2 = new ShopUser();
|
||||
shopUser2.setId(shopUser.getId());
|
||||
shopUser2.addDistributionShop(param.getShopId());
|
||||
if (param.getStatus() == 0) {
|
||||
shopUser2.upDistributionShop(param.getShopId(), 0);
|
||||
} else {
|
||||
shopUser2.upDistributionShop(param.getShopId(), 1);
|
||||
}
|
||||
shopUserService.updateById(shopUser2);
|
||||
return param;
|
||||
}
|
||||
@@ -523,7 +544,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
addDistributionUser(new MkDistributionUser().setShopId(shopId)
|
||||
.setUserId(shopUserInfo.getUserId())
|
||||
.setId(shopUserInfo.getId()).setOpeningMethod("付费开通"));
|
||||
}catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
log.error("分销员开通失败", e);
|
||||
}
|
||||
}
|
||||
@@ -610,18 +631,18 @@ 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.getMainShopId(), 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.getMainShopId(), currentLevel == 1 ? 1 : 2);
|
||||
distributionFlowService.updateById(mkDistributionFlow);
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
mkDistributionFlow.setDeliverTime(delayTime);
|
||||
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.getMainShopId(), currentLevel == 1 ? 1 : 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -654,7 +675,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
item.setStatus(TableValueConstant.DistributionFlow.Status.SUCCESS.getCode());
|
||||
updateIncome(item.getRewardAmount().negate(), BigDecimal.ZERO, BigDecimal.ZERO, item.getDistributionUserId(), item.getUserId(), item.getShopId(), item.getLevel());
|
||||
distributionFlowService.updateById(item);
|
||||
}else {
|
||||
} else {
|
||||
// 执行扣款
|
||||
updateIncome(BigDecimal.ZERO, item.getRewardAmount().negate(), BigDecimal.ZERO, item.getDistributionUserId(), item.getUserId(), item.getShopId(), item.getLevel());
|
||||
updateShopInfoAmount(item.getShopId(), item.getRewardAmount(), orderId, TableValueConstant.DistributionAmountFlow.Type.REFUND, "分销回退");
|
||||
|
||||
Reference in New Issue
Block a user