部分修改

This commit is contained in:
2025-11-06 10:13:00 +08:00
parent ec27cec15e
commit 94f46b8894
8 changed files with 237 additions and 27 deletions

View File

@@ -0,0 +1,14 @@
package com.czg.service.market.mapper;
import com.mybatisflex.core.BaseMapper;
import com.czg.market.entity.ShopUserInvite;
/**
* 邀请与上级关联表 映射层。
*
* @author ww
* @since 2025-11-06
*/
public interface ShopUserInviteMapper extends BaseMapper<ShopUserInvite> {
}

View File

@@ -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();

View File

@@ -0,0 +1,25 @@
package com.czg.service.market.service.impl;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.czg.market.entity.ShopUserInvite;
import com.czg.market.service.ShopUserInviteService;
import com.czg.service.market.mapper.ShopUserInviteMapper;
import org.springframework.stereotype.Service;
/**
* 邀请与上级关联表 服务层实现。
*
* @author ww
* @since 2025-11-06
*/
@Service
public class ShopUserInviteServiceImpl extends ServiceImpl<ShopUserInviteMapper, ShopUserInvite> implements ShopUserInviteService {
@Override
public ShopUserInvite getOneByShopIdAndShopUserId(Long shopId, Long shopUserId) {
return getOne(QueryWrapper.create()
.eq(ShopUserInvite::getShopId, shopId)
.eq(ShopUserInvite::getShopUserId, shopUserId));
}
}

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.czg.service.market.mapper.ShopUserInviteMapper">
</mapper>