|
|
|
|
@@ -74,6 +74,8 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|
|
|
|
private MkDistributionWithdrawFlowService withdrawFlowService;
|
|
|
|
|
@Resource
|
|
|
|
|
private MkDistributionDeliverService distributionDeliverService;
|
|
|
|
|
@Resource
|
|
|
|
|
private ShopUserInviteService shopUserInviteService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private AppWxServiceImpl appWxService;
|
|
|
|
|
@@ -127,7 +129,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|
|
|
|
for (DistributionCenterShopVO unActivate : unActivates) {
|
|
|
|
|
if (unActivate.getOrderCount() == 1) {
|
|
|
|
|
unActivate.setLabelContent("在本店下单过");
|
|
|
|
|
}else if (unActivate.getShopUser() == 1) {
|
|
|
|
|
} else if (unActivate.getShopUser() == 1) {
|
|
|
|
|
unActivate.setLabelContent("曾进入过店铺");
|
|
|
|
|
}
|
|
|
|
|
// else if("manual".equals(unActivate.getOpenType())){
|
|
|
|
|
@@ -151,8 +153,9 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|
|
|
|
AssertUtil.isNull(shopUser, "店铺用户不存在");
|
|
|
|
|
UserInfo userInfo = userInfoService.getById(shopUser.getUserId());
|
|
|
|
|
result.put("cashOutAmount", userInfo.getDistributionAmount() == null ? 0.0 : userInfo.getDistributionAmount());
|
|
|
|
|
if (shopUser.getDistributionUserId() != null) {
|
|
|
|
|
MkDistributionUser mkDistributionUser = this.getById(shopUser.getDistributionUserId());
|
|
|
|
|
ShopUserInvite shopUserInvite = shopUserInviteService.getOneByShopIdAndShopUserId(shopId, shopUser.getId());
|
|
|
|
|
if (shopUserInvite != null && shopUserInvite.getDistributionUserId() != null) {
|
|
|
|
|
MkDistributionUser mkDistributionUser = this.getById(shopUserInvite.getDistributionUserId());
|
|
|
|
|
AssertUtil.isNull(mkDistributionUser, "上级分销员不存在");
|
|
|
|
|
ShopUser shopUserParent = shopUserService.getById(mkDistributionUser.getId());
|
|
|
|
|
result.put("parentName", shopUserParent.getNickName());
|
|
|
|
|
@@ -236,7 +239,8 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|
|
|
|
public void bindInviteUser(MkDistributionUserDTO param) {
|
|
|
|
|
ShopUser shopUser = shopUserService.getById(param.getId());
|
|
|
|
|
AssertUtil.isNull(shopUser, "店铺用户不存在");
|
|
|
|
|
if (shopUser.getDistributionUserId() != null) {
|
|
|
|
|
ShopUserInvite shopUserInvite = shopUserInviteService.getOneByShopIdAndShopUserId(param.getShopId(), shopUser.getId());
|
|
|
|
|
if (shopUserInvite != null && shopUserInvite.getDistributionUserId() != null) {
|
|
|
|
|
throw new CzgException("店铺用户已绑定分销员");
|
|
|
|
|
}
|
|
|
|
|
MkDistributionUser parent = getOne(QueryWrapper.create().eq(MkDistributionUser::getInviteCode, param.getInviteCode()));
|
|
|
|
|
@@ -252,24 +256,26 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|
|
|
|
}
|
|
|
|
|
ShopUser parentShopUser = shopUserService.getById(parent.getId());
|
|
|
|
|
AssertUtil.isNull(parentShopUser, "邀请人不存在");
|
|
|
|
|
if (parentShopUser.getDistributionUserId() != null && parentShopUser.getDistributionUserId().equals(shopUser.getId())) {
|
|
|
|
|
ShopUserInvite parentShopUserInvite = shopUserInviteService.getOneByShopIdAndShopUserId(param.getShopId(), parentShopUser.getId());
|
|
|
|
|
if (parentShopUserInvite != null && parentShopUserInvite.getDistributionUserId() != null && parentShopUserInvite.getDistributionUserId().equals(shopUser.getId())) {
|
|
|
|
|
throw new CzgException("存在绑定关系,不可绑定");
|
|
|
|
|
}
|
|
|
|
|
if (parentShopUser.getDistributionUserParentId() != null && parentShopUser.getDistributionUserParentId().equals(shopUser.getId())) {
|
|
|
|
|
if (parentShopUserInvite != null && parentShopUserInvite.getDistributionUserParentId() != null && parentShopUserInvite.getDistributionUserParentId().equals(shopUser.getId())) {
|
|
|
|
|
throw new CzgException("存在绑定关系,不可绑定");
|
|
|
|
|
}
|
|
|
|
|
//更新自己的上级
|
|
|
|
|
ShopUser newShopUser = new ShopUser();
|
|
|
|
|
newShopUser.setId(shopUser.getId());
|
|
|
|
|
newShopUser.setDistributionUserId(parentShopUser.getId());
|
|
|
|
|
newShopUser.setDistributionUserParentId(parentShopUser.getDistributionUserId());
|
|
|
|
|
newShopUser.setInviteTime(LocalDateTime.now());
|
|
|
|
|
shopUserService.updateById(newShopUser);
|
|
|
|
|
if (parentShopUser.getDistributionUserParentId() != null) {
|
|
|
|
|
ShopUserInvite newShopUserInvite = new ShopUserInvite();
|
|
|
|
|
newShopUserInvite.setShopId(param.getShopId());
|
|
|
|
|
newShopUserInvite.setShopUserId(shopUser.getId());
|
|
|
|
|
newShopUserInvite.setDistributionUserId(parentShopUser.getId());
|
|
|
|
|
newShopUserInvite.setDistributionUserParentId(parentShopUserInvite == null ? null : parentShopUserInvite.getDistributionUserParentId());
|
|
|
|
|
newShopUserInvite.setInviteTime(LocalDateTime.now());
|
|
|
|
|
shopUserInviteService.save(newShopUserInvite);
|
|
|
|
|
if (parentShopUserInvite != null && parentShopUserInvite.getDistributionUserParentId() != null) {
|
|
|
|
|
//更新自己的下级 的上级的上级 为自己的上级
|
|
|
|
|
ShopUser childShopUser = new ShopUser();
|
|
|
|
|
childShopUser.setDistributionUserParentId(parentShopUser.getDistributionUserParentId());
|
|
|
|
|
shopUserService.update(childShopUser, QueryWrapper.create().eq(ShopUser::getDistributionUserId, shopUser.getId()));
|
|
|
|
|
ShopUserInvite childShopUserInvite = new ShopUserInvite();
|
|
|
|
|
childShopUserInvite.setDistributionUserParentId(parentShopUser.getId());
|
|
|
|
|
shopUserInviteService.update(childShopUserInvite, QueryWrapper.create().eq(ShopUserInvite::getDistributionUserId, shopUser.getId()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MkDistributionUser newDistributionUser = new MkDistributionUser();
|
|
|
|
|
@@ -316,8 +322,9 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|
|
|
|
public void costUpgradeLevelBefore(Long userId, Long shopId) {
|
|
|
|
|
ShopUser shopUser = shopUserService.getShopUserInfo(shopId, userId);
|
|
|
|
|
costUpgradeLevel(shopUser.getId(), shopId);
|
|
|
|
|
if (shopUser.getDistributionUserId() != null) {
|
|
|
|
|
costUpgradeLevel(shopUser.getDistributionUserId(), shopId);
|
|
|
|
|
ShopUserInvite shopUserInvite = shopUserInviteService.getOneByShopIdAndShopUserId(shopId, shopUser.getId());
|
|
|
|
|
if (shopUserInvite != null && shopUserInvite.getDistributionUserId() != null) {
|
|
|
|
|
costUpgradeLevel(shopUserInvite.getDistributionUserId(), shopId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -474,7 +481,6 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void initLevel(MkDistributionConfig config, MkDistributionUser distributionUser) {
|
|
|
|
|
MkDistributionLevelConfig levelConfig = new MkDistributionLevelConfig();
|
|
|
|
|
|