From 86e6714f974547ed2a6f6f9c9adde52562502703 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Thu, 30 Oct 2025 17:59:55 +0800 Subject: [PATCH] =?UTF-8?q?=E9=82=80=E8=AF=B7=E4=BA=BA=E5=88=97=E8=A1=A8?= =?UTF-8?q?=20=E6=9D=A1=E4=BB=B6=20=E6=B7=BB=E5=8A=A0=E9=82=80=E8=AF=B7?= =?UTF-8?q?=E4=BA=BA=20=E9=82=80=E8=AF=B7=E8=BA=AB=E4=BB=BD=20=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E6=9C=89=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/DistributionUserController.java | 3 +- .../user/UDistributionController.java | 2 +- .../java/com/czg/account/entity/ShopUser.java | 44 +++--- .../czg/account/service/ShopUserService.java | 2 +- .../service/MkDistributionUserService.java | 2 +- .../java/com/czg/market/vo/InviteUserVO.java | 2 +- .../account/mapper/ShopUserMapper.java | 2 +- .../service/impl/ShopUserServiceImpl.java | 4 +- .../main/resources/mapper/ShopUserMapper.xml | 134 +++++++++--------- .../impl/MkDistributionUserServiceImpl.java | 61 +++++--- 10 files changed, 136 insertions(+), 120 deletions(-) diff --git a/cash-api/market-server/src/main/java/com/czg/controller/admin/DistributionUserController.java b/cash-api/market-server/src/main/java/com/czg/controller/admin/DistributionUserController.java index 990b5bfa4..ebcb27cab 100644 --- a/cash-api/market-server/src/main/java/com/czg/controller/admin/DistributionUserController.java +++ b/cash-api/market-server/src/main/java/com/czg/controller/admin/DistributionUserController.java @@ -44,10 +44,11 @@ public class DistributionUserController { public CzgResult> getInviteUser( @RequestParam Long id, @RequestParam(required = false) Long shopUserId, + @RequestParam(required = false) Long distributionLevelId, @RequestParam(required = false, defaultValue = "1") Integer page, @RequestParam(required = false, defaultValue = "10") Integer size) { AssertUtil.isNull(id, "邀请人ID"); - return CzgResult.success(distributionUserService.getInviteUser(id, shopUserId, page, size)); + return CzgResult.success(distributionUserService.getInviteUser(id, shopUserId, distributionLevelId, page, size)); } /** diff --git a/cash-api/market-server/src/main/java/com/czg/controller/user/UDistributionController.java b/cash-api/market-server/src/main/java/com/czg/controller/user/UDistributionController.java index 6dc39e797..d42478922 100644 --- a/cash-api/market-server/src/main/java/com/czg/controller/user/UDistributionController.java +++ b/cash-api/market-server/src/main/java/com/czg/controller/user/UDistributionController.java @@ -122,7 +122,7 @@ public class UDistributionController { @RequestParam(required = false, defaultValue = "1") Integer page, @RequestParam(required = false, defaultValue = "10") Integer size) { AssertUtil.isNull(id, "邀请人ID"); - return CzgResult.success(distributionUserService.getInviteUser(id, null, page, size)); + return CzgResult.success(distributionUserService.getInviteUser(id, null, null, page, size)); } /** diff --git a/cash-common/cash-common-service/src/main/java/com/czg/account/entity/ShopUser.java b/cash-common/cash-common-service/src/main/java/com/czg/account/entity/ShopUser.java index 3833e93ad..591d925a2 100644 --- a/cash-common/cash-common-service/src/main/java/com/czg/account/entity/ShopUser.java +++ b/cash-common/cash-common-service/src/main/java/com/czg/account/entity/ShopUser.java @@ -171,44 +171,38 @@ public class ShopUser implements Serializable { @JSONField(format = "yyyy-MM-dd HH:mm:ss") private LocalDateTime inviteTime; - /** - * 检查分销店铺是否包含当前店铺 + * 添加或更新分销店铺:若shopId已存在(无论后缀),则替换为新的id_后缀;否则插入 + * + * @param shopId 店铺ID + * @param suffix 新后缀 */ - public boolean checkDistributionShops(String shopId) { - if (distributionShops == null || StrUtil.isEmpty(shopId)) { - return false; - } - // 按逗号分割并检查每个元素是否完全匹配 - String[] shopIds = distributionShops.split(","); - for (String id : shopIds) { - if (shopId.equals(id.trim())) { - return true; - } - } - return false; - } - - public void addDistributionShop(Long shopId) { + public void upDistributionShop(Long shopId, int suffix) { if (shopId == null) { return; } - String targetId = shopId.toString().trim(); - if (targetId.isEmpty()) { + String shopIdStr = shopId.toString().trim(); + if (shopIdStr.isEmpty()) { return; } - // 解析原有字符串为Set(去重+方便判断) + // 解析原有字符串为Set Set shopSet = new HashSet<>(); if (distributionShops != null && !distributionShops.trim().isEmpty()) { - for (String id : distributionShops.split(",")) { - String trimmedId = id.trim(); - if (!trimmedId.isEmpty()) { - shopSet.add(trimmedId); + for (String idWithSuffix : distributionShops.split(",")) { + String trimmed = idWithSuffix.trim(); + if (trimmed.isEmpty()) { + continue; + } + // 判断:如果不是以 "shopId_" 开头的记录,则保留 + if (!trimmed.startsWith(shopIdStr + "_")) { + shopSet.add(trimmed); } } } - shopSet.add(targetId); + // 添加新的id_后缀 + shopSet.add(shopIdStr + "_" + suffix); + // 重新拼接字符串 distributionShops = String.join(",", shopSet); } } diff --git a/cash-common/cash-common-service/src/main/java/com/czg/account/service/ShopUserService.java b/cash-common/cash-common-service/src/main/java/com/czg/account/service/ShopUserService.java index e27859f02..2e1e2b050 100644 --- a/cash-common/cash-common-service/src/main/java/com/czg/account/service/ShopUserService.java +++ b/cash-common/cash-common-service/src/main/java/com/czg/account/service/ShopUserService.java @@ -29,7 +29,7 @@ public interface ShopUserService extends IService { /** * 获取邀请用户列表 */ - Page getInviteUser(Long getDistributionUserId, Long shopUserId, Integer page, Integer size); + Page getInviteUser(Long getDistributionUserId, Long shopUserId, Long distributionLevelId, Integer page, Integer size); boolean updateInfo(ShopUser shopUser); diff --git a/cash-common/cash-common-service/src/main/java/com/czg/market/service/MkDistributionUserService.java b/cash-common/cash-common-service/src/main/java/com/czg/market/service/MkDistributionUserService.java index 026a32085..621fbacdb 100644 --- a/cash-common/cash-common-service/src/main/java/com/czg/market/service/MkDistributionUserService.java +++ b/cash-common/cash-common-service/src/main/java/com/czg/market/service/MkDistributionUserService.java @@ -66,7 +66,7 @@ public interface MkDistributionUserService extends IService /** * 获取分销员邀请人分页列表 */ - Page getInviteUser(Long id, Long shopUserId, Integer page, Integer size); + Page getInviteUser(Long id, Long shopUserId, Long distributionLevelId, Integer page, Integer size); /** * 分销员:按消费金额升级等级 diff --git a/cash-common/cash-common-service/src/main/java/com/czg/market/vo/InviteUserVO.java b/cash-common/cash-common-service/src/main/java/com/czg/market/vo/InviteUserVO.java index 2353275f3..2a88f3c64 100644 --- a/cash-common/cash-common-service/src/main/java/com/czg/market/vo/InviteUserVO.java +++ b/cash-common/cash-common-service/src/main/java/com/czg/market/vo/InviteUserVO.java @@ -54,5 +54,5 @@ public class InviteUserVO implements Serializable { /** * 是否分销员 */ - private Integer isDistribution; + private String distributionShops; } diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/mapper/ShopUserMapper.java b/cash-service/account-service/src/main/java/com/czg/service/account/mapper/ShopUserMapper.java index 9f173b0ef..d8500c0c2 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/mapper/ShopUserMapper.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/mapper/ShopUserMapper.java @@ -70,7 +70,7 @@ public interface ShopUserMapper extends BaseMapper { * @param distributionUserId 分销员ID * @return 分页结果 */ - List getInviteUser(Long distributionUserId, Long shopUserId); + List getInviteUser(Long distributionUserId, Long shopUserId, Long distributionLevelId); void updateOneOrTwoAmount(Long userId, Long mainShopId, BigDecimal amount, Integer isOne); diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopUserServiceImpl.java b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopUserServiceImpl.java index 53deeec3e..d2ddfe3ac 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopUserServiceImpl.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopUserServiceImpl.java @@ -99,9 +99,9 @@ public class ShopUserServiceImpl extends ServiceImpl i } @Override - public Page getInviteUser(Long distributionUserId, Long shopUserId, Integer page, Integer size) { + public Page getInviteUser(Long distributionUserId, Long shopUserId, Long distributionLevelId, Integer page, Integer size) { PageHelper.startPage(page, size); - List inviteUser = mapper.getInviteUser(distributionUserId, shopUserId); + List inviteUser = mapper.getInviteUser(distributionUserId, shopUserId, distributionLevelId); return PageUtil.convert(new PageInfo<>(inviteUser)); } diff --git a/cash-service/account-service/src/main/resources/mapper/ShopUserMapper.xml b/cash-service/account-service/src/main/resources/mapper/ShopUserMapper.xml index ea96ec910..4baa78225 100644 --- a/cash-service/account-service/src/main/resources/mapper/ShopUserMapper.xml +++ b/cash-service/account-service/src/main/resources/mapper/ShopUserMapper.xml @@ -5,7 +5,7 @@ update tb_shop_user - set amount = COALESCE(amount, 0) + #{money}, + set amount = COALESCE(amount, 0) + #{money}, update_time = #{time} where id = #{id} @@ -32,7 +32,6 @@ - - + OR order_count = 0 + OR order_count = 1 + OR order_count >= 5 + + + order by u.create_time desc + diff --git a/cash-service/market-service/src/main/java/com/czg/service/market/service/impl/MkDistributionUserServiceImpl.java b/cash-service/market-service/src/main/java/com/czg/service/market/service/impl/MkDistributionUserServiceImpl.java index 5afa4a318..6cbad7c61 100644 --- a/cash-service/market-service/src/main/java/com/czg/service/market/service/impl/MkDistributionUserServiceImpl.java +++ b/cash-service/market-service/src/main/java/com/czg/service/market/service/impl/MkDistributionUserServiceImpl.java @@ -282,7 +282,15 @@ public class MkDistributionUserServiceImpl extends ServiceImpl= 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 getInviteUser(Long id, Long shopUserId, Integer page, Integer size) { - return shopUserService.getInviteUser(id, shopUserId, page, size); + public Page 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