From 307c8e5628e4c822db4d2a465cc65ede0b54cfc4 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期二, 14 一月 2025 15:18:46 +0800
Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/qijisheng
---
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/VipCenterServiceImpl.java | 254 +++++++++++++++++++++++++-------------------------
1 files changed, 128 insertions(+), 126 deletions(-)
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/VipCenterServiceImpl.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/VipCenterServiceImpl.java
index 2ec3a0c..402bd5d 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/VipCenterServiceImpl.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/VipCenterServiceImpl.java
@@ -1,6 +1,7 @@
package com.ruoyi.account.service.impl;
import cn.hutool.core.collection.CollectionUtil;
+import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.account.api.model.AppUser;
@@ -16,6 +17,7 @@
import com.ruoyi.other.api.domain.Shop;
import com.ruoyi.other.api.domain.VipGood;
import com.ruoyi.other.api.domain.VipSetting;
+import com.ruoyi.other.api.feignClient.GoodsClient;
import com.ruoyi.other.api.feignClient.ShopClient;
import com.ruoyi.other.api.feignClient.VipGoodClient;
import com.ruoyi.system.api.model.LoginUser;
@@ -41,6 +43,8 @@
private ShopClient shopClient;
@Resource
private TokenService tokenService;
+ @Resource
+ private GoodsClient goodsClient;
@Override
@@ -54,50 +58,44 @@
VipSetting vipSetting = vipSettingService.getVipSettingById(4);
// 获取通过消费积分达成会员等级的开关
Integer vipLevelUpShopRole = vipSetting.getVipLevelUpShopRole();
- if (vipLevelUpShopRole == 1){
+
+ // 获取指定购买商品
+ boolean b = false;
+ String[] split = vipSetting.getGoodIds().split(",");
+ for (String s : split) {
+ R<List<Order>> orderListByUserIdAndGoodsId = remoteOrderGoodsClient.getOrderListByUserIdAndGoodsId(userId, Integer.valueOf(s));
+ if (R.isSuccess(orderListByUserIdAndGoodsId)){
+ List<Order> orderList = orderListByUserIdAndGoodsId.getData();
+ if (orderList.size() > 0){
+ b = true;
+ break;
+ }
+ }
+ }
+ if (b && null != vipLevelUpShopRole && vipLevelUpShopRole == 1){
// 消费积分阈值
Integer vipLevelUpShop = vipSetting.getVipLevelUpShop();
// 返佣积分阈值
Integer vipLevelUpShare = vipSetting.getVipLevelUpShare();
// 判断是否满足消费积分和返佣积分
- if (shopPoint >=vipLevelUpShop && sharePoint >= vipLevelUpShare){
+ if (shopPoint.compareTo(vipLevelUpShop) >= 0 && sharePoint.compareTo(vipLevelUpShare) >= 0){
return true;
}
}
Integer vipLevelUpNumRole = vipSetting.getVipLevelUpNumRole();
- if (vipLevelUpNumRole == 1){
+ if (b && null != vipLevelUpNumRole && vipLevelUpNumRole == 1){
// 直推钻石用户数阈值
Integer vipDirectNum = vipSetting.getVipDirectNum();
// 获取用户直推钻石用户数量
long userDiamondsCount = appUserService.count(new LambdaQueryWrapper<AppUser>()
.eq(AppUser::getInviteUserId, userId)
- .eq(AppUser::getVipId, 3));
+ .eq(AppUser::getDelFlag, 0)
+ .eq(AppUser::getStatus, 1)
+ .gt(AppUser::getVipId, 2));
// 判断是否满足直推钻石用户数量
- if (userDiamondsCount >= vipDirectNum){
- return true;
- }
+ return userDiamondsCount >= vipDirectNum.longValue();
}
- // 获取指定购买商品
- R<List<VipGood>> vipGoodsByVipId = vipGoodClient.getVipGoodsByVipId(4);
- if (R.isSuccess(vipGoodsByVipId)){
- List<VipGood> vipGoods = vipGoodsByVipId.getData();
- if (CollectionUtil.isNotEmpty(vipGoods)){
- for (VipGood vipGood : vipGoods) {
- String goodJson = vipGood.getGoodJson();
- Goods goods = JSONObject.parseObject(goodJson, Goods.class);
- R<List<Order>> orderListByUserIdAndGoodsId = remoteOrderGoodsClient.getOrderListByUserIdAndGoodsId(userId, goods.getId());
- if (R.isSuccess(orderListByUserIdAndGoodsId)){
- List<Order> orderList = orderListByUserIdAndGoodsId.getData();
- if (CollectionUtil.isEmpty(orderList)){
- return false;
- }
- }
- }
- return true;
- }
- }
-
return false;
}
@@ -112,19 +110,32 @@
VipSetting vipSetting = vipSettingService.getVipSettingById(5);
// 获取通过消费积分达成会员等级的开关
Integer vipLevelUpShopRole = vipSetting.getVipLevelUpShopRole();
- if (vipLevelUpShopRole == 1){
+
+ boolean b = false;
+ String[] split = vipSetting.getGoodIds().split(",");
+ for (String s : split) {
+ R<List<Order>> orderListByUserIdAndGoodsId = remoteOrderGoodsClient.getOrderListByUserIdAndGoodsId(userId, Integer.valueOf(s));
+ if (R.isSuccess(orderListByUserIdAndGoodsId)){
+ List<Order> orderList = orderListByUserIdAndGoodsId.getData();
+ if (orderList.size() > 0){
+ b = true;
+ break;
+ }
+ }
+ }
+ if (b && null != vipLevelUpShopRole && vipLevelUpShopRole == 1){
// 消费积分阈值
Integer vipLevelUpShop = vipSetting.getVipLevelUpShop();
// 返佣积分阈值
Integer vipLevelUpShare = vipSetting.getVipLevelUpShare();
// 判断是否满足消费积分和返佣积分
- if (shopPoint >=vipLevelUpShop && sharePoint >= vipLevelUpShare){
+ if (shopPoint.compareTo(vipLevelUpShop) >= 0 && sharePoint.compareTo(vipLevelUpShare) >= 0){
return true;
}
}
Integer vipLevelUpNumRole = vipSetting.getVipLevelUpNumRole();
- if (vipLevelUpNumRole == 1){
+ if (b && null != vipLevelUpNumRole && vipLevelUpNumRole == 1){
// 直推钻石用户数阈值
Integer vipDirectNum = vipSetting.getVipDirectNum();
// 获取用户直推钻石用户数量
@@ -132,30 +143,8 @@
.eq(AppUser::getInviteUserId, userId)
.eq(AppUser::getVipId, 3));
// 判断是否满足直推钻石用户数量
- if (userDiamondsCount >= vipDirectNum){
- return true;
- }
+ return userDiamondsCount >= vipDirectNum.longValue();
}
-
- R<List<VipGood>> vipGoodsByVipId = vipGoodClient.getVipGoodsByVipId(5);
- if (R.isSuccess(vipGoodsByVipId)){
- List<VipGood> vipGoods = vipGoodsByVipId.getData();
- if (CollectionUtil.isNotEmpty(vipGoods)){
- for (VipGood vipGood : vipGoods) {
- String goodJson = vipGood.getGoodJson();
- Goods goods = JSONObject.parseObject(goodJson, Goods.class);
- R<List<Order>> orderListByUserIdAndGoodsId = remoteOrderGoodsClient.getOrderListByUserIdAndGoodsId(userId, goods.getId());
- if (R.isSuccess(orderListByUserIdAndGoodsId)){
- List<Order> orderList = orderListByUserIdAndGoodsId.getData();
- if (CollectionUtil.isEmpty(orderList)){
- return false;
- }
- }
- }
- return true;
- }
- }
-
return false;
}
@@ -164,9 +153,24 @@
AppUser appUser = appUserService.getById(userId);
// 获取总代会员设置
VipSetting vipSetting = vipSettingService.getVipSettingById(6);
+
+ // 获取指定购买商品
+ boolean b = false;
+ String[] split = vipSetting.getGoodIds().split(",");
+ for (String s : split) {
+ R<List<Order>> orderListByUserIdAndGoodsId = remoteOrderGoodsClient.getOrderListByUserIdAndGoodsId(userId, Integer.valueOf(s));
+ if (R.isSuccess(orderListByUserIdAndGoodsId)){
+ List<Order> orderList = orderListByUserIdAndGoodsId.getData();
+ if (orderList.size() > 0){
+ b = true;
+ break;
+ }
+ }
+ }
+
// 获取会员等级是否必须达到代理
Integer vipLevelUpProxyRole = vipSetting.getVipLevelUpProxyRole();
- if (vipLevelUpProxyRole == 1 && appUser.getVipId() == 5){
+ if (b && vipLevelUpProxyRole == 1 && appUser.getVipId() == 5){
return true;
}
@@ -176,19 +180,19 @@
Integer sharePoint = appUser.getSharePoint();
// 获取通过消费积分达成会员等级的开关
Integer vipLevelUpShopRole = vipSetting.getVipLevelUpShopRole();
- if (vipLevelUpShopRole == 1){
+ if (b && null != vipLevelUpShopRole && vipLevelUpShopRole == 1){
// 消费积分阈值
Integer vipLevelUpShop = vipSetting.getVipLevelUpShop();
// 返佣积分阈值
Integer vipLevelUpShare = vipSetting.getVipLevelUpShare();
// 判断是否满足消费积分和返佣积分
- if (shopPoint >=vipLevelUpShop && sharePoint >= vipLevelUpShare){
+ if (shopPoint.compareTo(vipLevelUpShop) >= 0 && sharePoint.compareTo(vipLevelUpShare) >= 0){
return true;
}
}
Integer vipLevelUpNumRole = vipSetting.getVipLevelUpNumRole();
- if (vipLevelUpNumRole == 1){
+ if (b && null != vipLevelUpNumRole && vipLevelUpNumRole == 1){
// 直推代理用户数阈值
Integer vipDirectNum = vipSetting.getVipDirectNum();
// 准代理用户数阈值
@@ -200,35 +204,16 @@
// 代理下的准代理数量
List<Long> userQuasiAgent = userAgentList.stream().map(AppUser::getId).collect(Collectors.toList());
- long userQuasiAgentCount = appUserService.count(new LambdaQueryWrapper<AppUser>()
- .in(AppUser::getInviteUserId, userQuasiAgent)
- .eq(AppUser::getVipId, 4));
+ long userQuasiAgentCount = 0;
+ if(userQuasiAgent.size() > 0){
+ userQuasiAgentCount = appUserService.count(new LambdaQueryWrapper<AppUser>()
+ .in(AppUser::getInviteUserId, userQuasiAgent)
+ .eq(AppUser::getVipId, 4));
+ }
// 判断是否满足直推代理用户数量和准代理数量
- if (userAgentList.size() >= vipDirectNum && userQuasiAgentCount >= vipDirectVipNum){
- return true;
- }
+ return userAgentList.size() >= vipDirectNum && userQuasiAgentCount >= vipDirectVipNum.longValue();
}
- // 获取指定购买商品
- R<List<VipGood>> vipGoodsByVipId = vipGoodClient.getVipGoodsByVipId(5);
- if (R.isSuccess(vipGoodsByVipId)){
- List<VipGood> vipGoods = vipGoodsByVipId.getData();
- if (CollectionUtil.isNotEmpty(vipGoods)){
- for (VipGood vipGood : vipGoods) {
- String goodJson = vipGood.getGoodJson();
- Goods goods = JSONObject.parseObject(goodJson, Goods.class);
- R<List<Order>> orderListByUserIdAndGoodsId = remoteOrderGoodsClient.getOrderListByUserIdAndGoodsId(userId, goods.getId());
- if (R.isSuccess(orderListByUserIdAndGoodsId)){
- List<Order> orderList = orderListByUserIdAndGoodsId.getData();
- if (CollectionUtil.isEmpty(orderList)){
- return false;
- }
- }
- }
- return true;
- }
- }
-
return false;
}
@@ -241,66 +226,83 @@
Integer sharePoint = appUser.getSharePoint();
// 合伙人会员设置
VipSetting vipSetting = vipSettingService.getVipSettingById(7);
+ // 获取指定购买商品
+ boolean b = false;
+ String[] split = vipSetting.getGoodIds().split(",");
+ for (String s : split) {
+ R<List<Order>> orderListByUserIdAndGoodsId = remoteOrderGoodsClient.getOrderListByUserIdAndGoodsId(userId, Integer.valueOf(s));
+ if (R.isSuccess(orderListByUserIdAndGoodsId)){
+ List<Order> orderList = orderListByUserIdAndGoodsId.getData();
+ if (orderList.size() > 0){
+ b = true;
+ break;
+ }
+ }
+ }
+
// 获取通过消费积分达成会员等级的开关
Integer vipLevelUpShopRole = vipSetting.getVipLevelUpShopRole();
- if (vipLevelUpShopRole == 1){
+ if (b && null != vipLevelUpShopRole && vipLevelUpShopRole == 1){
// 消费积分阈值
Integer vipLevelUpShop = vipSetting.getVipLevelUpShop();
// 返佣积分阈值
Integer vipLevelUpShare = vipSetting.getVipLevelUpShare();
// 判断是否满足消费积分和返佣积分
- if (shopPoint >=vipLevelUpShop && sharePoint >= vipLevelUpShare){
+ if (shopPoint.compareTo(vipLevelUpShop) >= 0 && sharePoint.compareTo(vipLevelUpShare) >= 0){
return true;
}
+ }
- Integer vipLevelUpNumRole = vipSetting.getVipLevelUpNumRole();
- if (vipLevelUpNumRole == 1){
- // 直推代理用户数阈值
- Integer vipDirectNum = vipSetting.getVipDirectNum();
- // 准代理用户数阈值
- Integer vipDirectVipNum = vipSetting.getVipDirectVipNum();
- // 总代用户数阈值
- Integer vipTeamVipNum = vipSetting.getVipTeamVipNum();
- // 获取开店数量阈值
- Integer vipOpenShopNum = vipSetting.getVipOpenShopNum();
+ Integer vipLevelUpNumRole = vipSetting.getVipLevelUpNumRole();
+ if (b && null != vipLevelUpNumRole && vipLevelUpNumRole == 1){
+ // 直推代理用户数阈值
+ Integer vipDirectNum = vipSetting.getVipDirectNum();
+ // 准代理用户数阈值
+ Integer vipDirectVipNum = vipSetting.getVipDirectVipNum();
+ // 总代用户数阈值
+ Integer vipTeamVipNum = vipSetting.getVipTeamVipNum();
+ // 获取开店数量阈值
+ Integer vipOpenShopNum = vipSetting.getVipOpenShopNum();
- // 获取直推用户有超过指定门店数量的用户
- List<Long> userShopList = appUserService.list(new LambdaQueryWrapper<AppUser>()
- .eq(AppUser::getInviteUserId, userId))
- .stream().map(AppUser::getId).collect(Collectors.toList());
- if (CollectionUtil.isNotEmpty(userShopList)){
- R<List<Shop>> r = shopClient.getShopByUserIds(userShopList);
- List<Shop> shopList = r.getData();
- if (CollectionUtil.isNotEmpty(shopList)){
- Map<Long, List<Shop>> shopUserMap = shopList.stream().collect(Collectors.groupingBy(Shop::getAppUserId));
+ // 获取直推用户有超过指定门店数量的用户
+ List<Long> userShopList = appUserService.list(new LambdaQueryWrapper<AppUser>()
+ .eq(AppUser::getInviteUserId, userId))
+ .stream().map(AppUser::getId).collect(Collectors.toList());
+ if (CollectionUtil.isNotEmpty(userShopList)){
+ R<List<Shop>> r = shopClient.getShopByUserIds(userShopList);
+ List<Shop> shopList = r.getData();
+ if (CollectionUtil.isNotEmpty(shopList)){
+ Map<Long, List<Shop>> shopUserMap = shopList.stream().collect(Collectors.groupingBy(Shop::getAppUserId));
- // 查找 list 长度大于 3 的 key
- Set<Long> shopUserIdSet = shopUserMap.entrySet().stream()
- .filter(entry -> entry.getValue().size() >= vipOpenShopNum)
- .map(Map.Entry::getKey)
- .collect(Collectors.toSet());
+ // 查找 list 长度大于 3 的 key
+ Set<Long> shopUserIdSet = shopUserMap.entrySet().stream()
+ .filter(entry -> entry.getValue().size() >= vipOpenShopNum)
+ .map(Map.Entry::getKey)
+ .collect(Collectors.toSet());
- // 获取用户直推总代理数量
- List<AppUser> userTotalAgentList = appUserService.list(new LambdaQueryWrapper<AppUser>()
- .in(AppUser::getInviteUserId, shopUserIdSet)
- .eq(AppUser::getVipId, 6));
+ // 获取用户直推总代理数量
+ List<AppUser> userTotalAgentList = appUserService.list(new LambdaQueryWrapper<AppUser>()
+ .in(AppUser::getId, shopUserIdSet)
+ .eq(AppUser::getVipId, 6));
- // 获取用户直推代理用户数量
- List<AppUser> userAgentList = appUserService.list(new LambdaQueryWrapper<AppUser>()
- .in(AppUser::getInviteUserId, shopUserIdSet)
- .eq(AppUser::getVipId, 5));
- // 代理下的准代理数量
- List<Long> userQuasiAgent = userAgentList.stream().map(AppUser::getId).collect(Collectors.toList());
- long userQuasiAgentCount = appUserService.count(new LambdaQueryWrapper<AppUser>()
+ // 获取用户直推代理用户数量
+ List<AppUser> userAgentList = appUserService.list(new LambdaQueryWrapper<AppUser>()
+ .in(AppUser::getId, userShopList)
+ .eq(AppUser::getVipId, 5));
+
+ // 代理下的准代理数量
+ List<Long> userQuasiAgent = userAgentList.stream().map(AppUser::getId).collect(Collectors.toList());
+ long userQuasiAgentCount = 0;
+ if(userQuasiAgent.size() > 0){
+ userQuasiAgentCount = appUserService.count(new LambdaQueryWrapper<AppUser>()
.in(AppUser::getInviteUserId, userQuasiAgent)
.eq(AppUser::getVipId, 4));
-
- // 判断是否满足直推代理用户数量和准代理数量
- return userTotalAgentList.size() >= vipTeamVipNum && userAgentList.size() >= vipDirectNum &&
- userQuasiAgentCount >= vipDirectVipNum;
-
}
+
+ // 判断是否满足直推代理用户数量和准代理数量
+ return userTotalAgentList.size() >= vipTeamVipNum && userAgentList.size() >= vipDirectNum &&
+ userQuasiAgentCount >= vipDirectVipNum;
}
}
@@ -310,7 +312,7 @@
@Override
public Boolean check(Integer type) {
- LoginUser loginUser = tokenService.getLoginUser();
+ LoginUser loginUser = tokenService.getLoginUserApplet();
Long userid = loginUser.getUserid();
if (type == 4){
return checkReadyToBeProxy(userid, type);
--
Gitblit v1.7.1