|
|
@@ -10,6 +10,7 @@ import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
@@ -1433,7 +1434,28 @@ public class FsUserServiceImpl implements IFsUserService {
|
|
|
.stream()
|
|
|
.filter(fsAppRole -> fsAppRole.getRoleType() == 4)
|
|
|
.collect(Collectors.toList());
|
|
|
+ //标签+套餐包角色
|
|
|
+ List<FsAppRole> tagAndPackageRoleList = appRoleList
|
|
|
+ .stream()
|
|
|
+ .filter(fsAppRole -> fsAppRole.getRoleType() == 5)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ //标签+商城角色
|
|
|
+ List<FsAppRole> tagAndMallRoleList = appRoleList
|
|
|
+ .stream()
|
|
|
+ .filter(fsAppRole -> fsAppRole.getRoleType() == 6)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ //标签+套餐包+商城商品
|
|
|
+ List<FsAppRole> tagAndProductRoleList = appRoleList
|
|
|
+ .stream()
|
|
|
+ .filter(fsAppRole -> fsAppRole.getRoleType() == 7)
|
|
|
+ .collect(Collectors.toList());
|
|
|
//2.匹配添加角色
|
|
|
+ //用户标签
|
|
|
+ List<String> userTags = qwExternalContactService.selectTagsByFsUserId(userId);
|
|
|
+ //用户购买的套餐包id
|
|
|
+ List<Long> userBuyPackageId = fsStoreOrderMapper.selectUserBuyOrderList(userId);
|
|
|
+ //用户购买的商城商品id
|
|
|
+ List<Long> userProductIds = storeOrderMapper.selectUserBuyProductIds(userId);
|
|
|
//通用
|
|
|
if (CollectionUtils.isNotEmpty(commonRoleList)) {
|
|
|
List<Long> commonIds = commonRoleList.stream().map(FsAppRole::getId).collect(Collectors.toList());
|
|
|
@@ -1441,8 +1463,6 @@ public class FsUserServiceImpl implements IFsUserService {
|
|
|
}
|
|
|
//角色标签
|
|
|
if (CollectionUtils.isNotEmpty(tagRoleList)) {
|
|
|
- //用户标签
|
|
|
- List<String> userTags = qwExternalContactService.selectTagsByFsUserId(userId);
|
|
|
if (CollectionUtils.isNotEmpty(userTags)) {
|
|
|
tagRoleList.forEach(tagAppRole -> {
|
|
|
if (StringUtils.isNotEmpty(tagAppRole.getRoleTags())) {
|
|
|
@@ -1457,7 +1477,6 @@ public class FsUserServiceImpl implements IFsUserService {
|
|
|
}
|
|
|
//角色套餐包
|
|
|
if (CollectionUtils.isNotEmpty(packageRoleList)) {
|
|
|
- List<Long> userBuyPackageId = fsStoreOrderMapper.selectUserBuyOrderList(userId);
|
|
|
if (CollectionUtils.isNotEmpty(userBuyPackageId)) {
|
|
|
packageRoleList.forEach(packageAppRole -> {
|
|
|
if (StringUtils.isNotEmpty(packageAppRole.getRolePackageProductIds())) {
|
|
|
@@ -1476,7 +1495,6 @@ public class FsUserServiceImpl implements IFsUserService {
|
|
|
|
|
|
//角色商城商品
|
|
|
if (CollectionUtils.isNotEmpty(productRoleList)) {
|
|
|
- List<Long> userProductIds = storeOrderMapper.selectUserBuyProductIds(userId);
|
|
|
if (CollectionUtils.isNotEmpty(userProductIds)) {
|
|
|
productRoleList.forEach(productAppRole -> {
|
|
|
if (StringUtils.isNotEmpty(productAppRole.getRoleStoreProductIds())) {
|
|
|
@@ -1493,6 +1511,86 @@ public class FsUserServiceImpl implements IFsUserService {
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
+ //标签+套餐包
|
|
|
+ if (CollectionUtils.isNotEmpty(tagAndPackageRoleList)) {
|
|
|
+ if (CollectionUtils.isNotEmpty(userTags) && CollectionUtils.isNotEmpty(userBuyPackageId)) {
|
|
|
+ tagAndPackageRoleList.forEach(tagAndPackageRole -> {
|
|
|
+ boolean tagMatch = false;
|
|
|
+ boolean buyMatch = false;
|
|
|
+ if (StringUtils.isNotEmpty(tagAndPackageRole.getRoleTags())) {
|
|
|
+ List<String> tags = Arrays.stream(tagAndPackageRole.getRoleTags().split(",")).collect(Collectors.toList());
|
|
|
+ tagMatch = userTags.stream().anyMatch(tags::contains);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(tagAndPackageRole.getRolePackageProductIds())) {
|
|
|
+ List<Long> packages = Arrays.stream(tagAndPackageRole.getRolePackageProductIds().split(","))
|
|
|
+ .map(String::trim)
|
|
|
+ .map(Long::parseLong)
|
|
|
+ .collect(Collectors.toList());;
|
|
|
+ buyMatch = userBuyPackageId.stream().anyMatch(packages::contains);
|
|
|
+ }
|
|
|
+ if (tagMatch && buyMatch) {
|
|
|
+ addRoleList.add(tagAndPackageRole.getId());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //标签+商城商品
|
|
|
+ if (CollectionUtils.isNotEmpty(tagAndMallRoleList)) {
|
|
|
+ if (CollectionUtils.isNotEmpty(userTags) && CollectionUtils.isNotEmpty(userProductIds)) {
|
|
|
+ tagAndPackageRoleList.forEach(tagAndMallRole -> {
|
|
|
+ boolean tagMatch = false;
|
|
|
+ boolean productMatch = false;
|
|
|
+ if (StringUtils.isNotEmpty(tagAndMallRole.getRoleTags())) {
|
|
|
+ List<String> tags = Arrays.stream(tagAndMallRole.getRoleTags().split(",")).collect(Collectors.toList());
|
|
|
+ tagMatch = userTags.stream().anyMatch(tags::contains);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(tagAndMallRole.getRolePackageProductIds())) {
|
|
|
+ List<Long> packages = Arrays.stream(tagAndMallRole.getRoleStoreProductIds().split(","))
|
|
|
+ .map(String::trim)
|
|
|
+ .map(Long::parseLong)
|
|
|
+ .collect(Collectors.toList());;
|
|
|
+ productMatch = userProductIds.stream().anyMatch(packages::contains);
|
|
|
+ }
|
|
|
+ if (tagMatch && productMatch) {
|
|
|
+ addRoleList.add(tagAndMallRole.getId());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //标签+商城商品+套餐包
|
|
|
+ if (CollectionUtils.isNotEmpty(tagAndProductRoleList)) {
|
|
|
+ if (CollectionUtils.isNotEmpty(userTags) && CollectionUtils.isNotEmpty(userProductIds) && CollectionUtils.isNotEmpty(userBuyPackageId)) {
|
|
|
+ tagAndProductRoleList.forEach(tagAndProductRole -> {
|
|
|
+ boolean tagMatch = false;
|
|
|
+ boolean buyMatch = false;
|
|
|
+ boolean productMatch = false;
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(tagAndProductRole.getRoleTags())) {
|
|
|
+ List<String> tags = Arrays.stream(tagAndProductRole.getRoleTags().split(",")).collect(Collectors.toList());
|
|
|
+ tagMatch = userTags.stream().anyMatch(tags::contains);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(tagAndProductRole.getRolePackageProductIds())) {
|
|
|
+ List<Long> packages = Arrays.stream(tagAndProductRole.getRoleStoreProductIds().split(","))
|
|
|
+ .map(String::trim)
|
|
|
+ .map(Long::parseLong)
|
|
|
+ .collect(Collectors.toList());;
|
|
|
+ productMatch = userProductIds.stream().anyMatch(packages::contains);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(tagAndProductRole.getRolePackageProductIds())) {
|
|
|
+ List<Long> packages = Arrays.stream(tagAndProductRole.getRolePackageProductIds().split(","))
|
|
|
+ .map(String::trim)
|
|
|
+ .map(Long::parseLong)
|
|
|
+ .collect(Collectors.toList());;
|
|
|
+ buyMatch = userBuyPackageId.stream().anyMatch(packages::contains);
|
|
|
+ }
|
|
|
+ if (tagMatch && productMatch && buyMatch) {
|
|
|
+ addRoleList.add(tagAndProductRole.getId());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
//3.更新用户角色信息
|
|
|
if (CollectionUtils.isNotEmpty(addRoleList)) {
|
|
|
FsUser map = new FsUser();
|