|
@@ -16,6 +16,7 @@ import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
+import com.fs.app.domain.FsAppRole;
|
|
|
import com.fs.common.constant.HttpStatus;
|
|
import com.fs.common.constant.HttpStatus;
|
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.domain.ResponseResult;
|
|
import com.fs.common.core.domain.ResponseResult;
|
|
@@ -23,6 +24,7 @@ import com.fs.common.core.domain.entity.SysDictData;
|
|
|
import com.fs.common.core.page.TableDataInfo;
|
|
import com.fs.common.core.page.TableDataInfo;
|
|
|
import com.fs.common.core.redis.RedisCache;
|
|
import com.fs.common.core.redis.RedisCache;
|
|
|
import com.fs.common.enums.ImTypeEnum;
|
|
import com.fs.common.enums.ImTypeEnum;
|
|
|
|
|
+import com.fs.common.exception.CustomException;
|
|
|
import com.fs.common.param.LoginMaWxParam;
|
|
import com.fs.common.param.LoginMaWxParam;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
import com.fs.common.utils.DateUtils;
|
|
|
import com.fs.common.utils.DictUtils;
|
|
import com.fs.common.utils.DictUtils;
|
|
@@ -69,8 +71,10 @@ import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
|
|
|
import com.fs.hisStore.service.IFsUserBillScrmService;
|
|
import com.fs.hisStore.service.IFsUserBillScrmService;
|
|
|
import com.fs.hisStore.vo.FsCompanyUserListQueryVO;
|
|
import com.fs.hisStore.vo.FsCompanyUserListQueryVO;
|
|
|
import com.fs.qw.cache.IQwExternalContactCacheService;
|
|
import com.fs.qw.cache.IQwExternalContactCacheService;
|
|
|
|
|
+import com.fs.qw.domain.QwExternalContact;
|
|
|
import com.fs.qw.dto.FsUserTransferParamDTO;
|
|
import com.fs.qw.dto.FsUserTransferParamDTO;
|
|
|
import com.fs.qw.param.QwFsUserParam;
|
|
import com.fs.qw.param.QwFsUserParam;
|
|
|
|
|
+import com.fs.qw.service.IQwExternalContactService;
|
|
|
import com.fs.qw.vo.QwFsUserVO;
|
|
import com.fs.qw.vo.QwFsUserVO;
|
|
|
import com.fs.store.domain.FsUserCourseCount;
|
|
import com.fs.store.domain.FsUserCourseCount;
|
|
|
import com.fs.store.mapper.FsUserCourseCountMapper;
|
|
import com.fs.store.mapper.FsUserCourseCountMapper;
|
|
@@ -86,8 +90,10 @@ import com.fs.watch.domain.vo.FsUserAndCompanyAndDoctorVo;
|
|
|
import com.fs.watch.service.WatchUserService;
|
|
import com.fs.watch.service.WatchUserService;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.http.util.Asserts;
|
|
import org.apache.http.util.Asserts;
|
|
|
|
|
+import org.checkerframework.checker.nullness.qual.Nullable;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -179,6 +185,9 @@ public class FsUserServiceImpl implements IFsUserService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IFsUserWxService fsUserWxService;
|
|
private IFsUserWxService fsUserWxService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IQwExternalContactService qwExternalContactService;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 查询用户
|
|
* 查询用户
|
|
@@ -1394,4 +1403,102 @@ public class FsUserServiceImpl implements IFsUserService {
|
|
|
return R.ok();
|
|
return R.ok();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void userAddAppRole(Long userId,List<FsAppRole> appRoleList) {
|
|
|
|
|
+ FsUser fsUser = fsUserMapper.selectFsUserByUserId(userId);
|
|
|
|
|
+ if (fsUser == null) {
|
|
|
|
|
+ throw new CustomException("未找到用户信息");
|
|
|
|
|
+ }
|
|
|
|
|
+ //1.角色数据
|
|
|
|
|
+ //用户添加角色数据
|
|
|
|
|
+ List<Long> addRoleList = Lists.newArrayList();
|
|
|
|
|
+
|
|
|
|
|
+ //通用角色
|
|
|
|
|
+ List<FsAppRole> commonRoleList = appRoleList
|
|
|
|
|
+ .stream()
|
|
|
|
|
+ .filter(fsAppRole -> fsAppRole.getRoleType() == 1)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ //标签角色
|
|
|
|
|
+ List<FsAppRole> tagRoleList = appRoleList
|
|
|
|
|
+ .stream()
|
|
|
|
|
+ .filter(fsAppRole -> fsAppRole.getRoleType() == 2)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ //套餐包角色
|
|
|
|
|
+ List<FsAppRole> packageRoleList = appRoleList
|
|
|
|
|
+ .stream()
|
|
|
|
|
+ .filter(fsAppRole -> fsAppRole.getRoleType() == 3)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ //商城商品角色
|
|
|
|
|
+ List<FsAppRole> productRoleList = appRoleList
|
|
|
|
|
+ .stream()
|
|
|
|
|
+ .filter(fsAppRole -> fsAppRole.getRoleType() == 4)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ //2.匹配添加角色
|
|
|
|
|
+ //通用
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(commonRoleList)) {
|
|
|
|
|
+ List<Long> commonIds = commonRoleList.stream().map(FsAppRole::getId).collect(Collectors.toList());
|
|
|
|
|
+ addRoleList.addAll(commonIds);
|
|
|
|
|
+ }
|
|
|
|
|
+ //角色标签
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(tagRoleList)) {
|
|
|
|
|
+ //用户标签
|
|
|
|
|
+ List<String> userTags = qwExternalContactService.selectTagsByFsUserId(userId);
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(userTags)) {
|
|
|
|
|
+ tagRoleList.forEach(tagAppRole -> {
|
|
|
|
|
+ if (StringUtils.isNotEmpty(tagAppRole.getRoleTags())) {
|
|
|
|
|
+ List<String> roleTags = Arrays.stream(tagAppRole.getRoleTags().split(",")).collect(Collectors.toList());
|
|
|
|
|
+ boolean matchTag = userTags.stream().anyMatch(roleTags::contains);
|
|
|
|
|
+ if (matchTag) {
|
|
|
|
|
+ addRoleList.add(tagAppRole.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //角色套餐包
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(packageRoleList)) {
|
|
|
|
|
+ List<Long> userBuyPackageId = fsStoreOrderMapper.selectUserBuyOrderList(userId);
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(userBuyPackageId)) {
|
|
|
|
|
+ packageRoleList.forEach(packageAppRole -> {
|
|
|
|
|
+ if (StringUtils.isNotEmpty(packageAppRole.getRolePackageProductIds())) {
|
|
|
|
|
+ List<Long> packageIds = Arrays.stream(packageAppRole.getRolePackageProductIds().split(","))
|
|
|
|
|
+ .map(String::trim)
|
|
|
|
|
+ .map(Long::parseLong)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ boolean matchPackage = userBuyPackageId.stream().anyMatch(packageIds::contains);
|
|
|
|
|
+ if (matchPackage) {
|
|
|
|
|
+ addRoleList.add(packageAppRole.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //角色商城商品
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(productRoleList)) {
|
|
|
|
|
+ List<Long> userProductIds = storeOrderMapper.selectUserBuyProductIds(userId);
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(userProductIds)) {
|
|
|
|
|
+ productRoleList.forEach(productAppRole -> {
|
|
|
|
|
+ if (StringUtils.isNotEmpty(productAppRole.getRoleStoreProductIds())) {
|
|
|
|
|
+ List<Long> productIds = Arrays.stream(productAppRole.getRoleStoreProductIds().split(","))
|
|
|
|
|
+ .map(String::trim)
|
|
|
|
|
+ .map(Long::parseLong)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ boolean matchProduct = userProductIds.stream().anyMatch(productIds::contains);
|
|
|
|
|
+ if (matchProduct) {
|
|
|
|
|
+ addRoleList.add(productAppRole.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //3.更新用户角色信息
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(addRoleList)) {
|
|
|
|
|
+ FsUser map = new FsUser();
|
|
|
|
|
+ map.setUserId(userId);
|
|
|
|
|
+ map.setAppRoles(StringUtils.join(addRoleList, ","));
|
|
|
|
|
+ fsUserMapper.updateFsUser(map);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|