部分修改

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

@@ -150,14 +150,6 @@ public class ShopUser implements Serializable {
private LocalDateTime endTime;
private LocalDateTime deliverTime;
private LocalDateTime nextDeliverTime;
// 分销员ID 邀请人id
private Long distributionUserId;
// 分销员ID 邀请人上级id
private Long distributionUserParentId;
//邀请人累计收益/一级分润
private BigDecimal oneIncome;
//邀请人上级累计收益/二级分润
private BigDecimal twoIncome;
// 是否分销员
private String distributionShops;

View File

@@ -0,0 +1,70 @@
package com.czg.market.dto;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import com.alibaba.fastjson2.annotation.JSONField;
import lombok.experimental.Accessors;
import java.io.Serial;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 邀请与上级关联表 实体类。
*
* @author ww
* @since 2025-11-06
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class ShopUserInviteDTO implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* (随机)
*/
private Long id;
/**
* 店铺ID
*/
private Long shopId;
/**
* 店铺用户ID
*/
private Long shopUserId;
/**
* 邀请人ID mk_distribution_user.id
*/
private Long distributionUserId;
/**
* 邀请人上级ID mk_distribution_user.id
*/
private Long distributionUserParentId;
/**
* 邀请人收益/一级分润
*/
private BigDecimal oneIncome;
/**
* 邀请人上级收益/二级分润
*/
private BigDecimal twoIncome;
/**
* 邀请时间
*/
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime inviteTime;
}

View File

@@ -0,0 +1,74 @@
package com.czg.market.entity;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.io.Serial;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 邀请与上级关联表 实体类。
*
* @author ww
* @since 2025-11-06
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table("tb_shop_user_invite")
public class ShopUserInvite implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* (随机)
*/
@Id(keyType = KeyType.Auto)
private Long id;
/**
* 店铺ID
*/
private Long shopId;
/**
* 店铺用户ID
*/
private Long shopUserId;
/**
* 邀请人ID mk_distribution_user.id
*/
private Long distributionUserId;
/**
* 邀请人上级ID mk_distribution_user.id
*/
private Long distributionUserParentId;
/**
* 邀请人收益/一级分润
*/
private BigDecimal oneIncome;
/**
* 邀请人上级收益/二级分润
*/
private BigDecimal twoIncome;
/**
* 邀请时间
*/
private LocalDateTime inviteTime;
}

View File

@@ -0,0 +1,22 @@
package com.czg.market.service;
import com.mybatisflex.core.service.IService;
import com.czg.market.entity.ShopUserInvite;
/**
* 邀请与上级关联表 服务层。
*
* @author ww
* @since 2025-11-06
*/
public interface ShopUserInviteService extends IService<ShopUserInvite> {
/**
* 根据店铺ID和店铺用户ID查询邀请记录
*
* @param shopId 店铺ID
* @param shopUserId 店铺用户ID
* @return 邀请记录
*/
ShopUserInvite getOneByShopIdAndShopUserId(Long shopId, Long shopUserId);
}

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>