diff --git a/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/MemberBasicInfoController.java b/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/MemberBasicInfoController.java index 0ae619f5e..24188560d 100644 --- a/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/MemberBasicInfoController.java +++ b/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/MemberBasicInfoController.java @@ -21,6 +21,7 @@ import com.jsowell.pile.dto.UniAppQueryMemberBalanceDTO; import com.jsowell.pile.service.IMemberBasicInfoService; import com.jsowell.pile.service.IMemberPlateNumberRelationService; import com.jsowell.pile.service.IMemberTransactionRecordService; +import com.jsowell.pile.util.UserUtils; import com.jsowell.pile.vo.base.MerchantInfoVO; import com.jsowell.pile.vo.uniapp.MemberVO; import com.jsowell.pile.vo.uniapp.MemberWalletLogVO; @@ -74,7 +75,8 @@ public class MemberBasicInfoController extends BaseController { public RestApiResponse getMerchantListByAuth() { RestApiResponse response = null; // List list = memberBasicInfoService.getMerchantListByAuth(deptIds); - List list = memberBasicInfoService.getMerchantListByAuth(); + // List list = memberBasicInfoService.getMerchantListByAuth(); + List list = UserUtils.getMerchantListByAuth(); if (CollectionUtils.isEmpty(list)) { list = new ArrayList<>(); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/IMemberBasicInfoService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/IMemberBasicInfoService.java index bde5cfbfc..b9e3c76cc 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/IMemberBasicInfoService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/IMemberBasicInfoService.java @@ -4,7 +4,6 @@ import com.jsowell.pile.domain.MemberBasicInfo; import com.jsowell.pile.dto.PlatformTesterDTO; import com.jsowell.pile.dto.QueryMemberInfoDTO; import com.jsowell.pile.dto.UniAppQueryMemberBalanceDTO; -import com.jsowell.pile.vo.base.MerchantInfoVO; import com.jsowell.pile.vo.uniapp.MemberBalanceVO; import com.jsowell.pile.vo.uniapp.MemberVO; import com.jsowell.pile.vo.uniapp.MemberWalletLogVO; @@ -147,10 +146,4 @@ public interface IMemberBasicInfoService { * @return */ List getMemberRefundAmount(List memberIds); - - - /** - * 获取当前会员中的运营商列表(带权限校验) - */ - List getMerchantListByAuth(); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/MemberBasicInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/MemberBasicInfoServiceImpl.java index 403b828d6..9041c8e50 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/MemberBasicInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/MemberBasicInfoServiceImpl.java @@ -4,14 +4,10 @@ import com.github.pagehelper.PageHelper; import com.google.common.collect.Lists; import com.jsowell.common.constant.CacheConstants; import com.jsowell.common.constant.Constants; -import com.jsowell.common.core.domain.entity.SysDept; -import com.jsowell.common.core.domain.entity.SysUser; -import com.jsowell.common.core.domain.model.LoginUser; import com.jsowell.common.core.domain.vo.AuthorizedDeptVO; import com.jsowell.common.core.redis.RedisCache; import com.jsowell.common.enums.MemberWalletEnum; import com.jsowell.common.util.DateUtils; -import com.jsowell.common.util.SecurityUtils; import com.jsowell.common.util.StringUtils; import com.jsowell.pile.domain.*; import com.jsowell.pile.dto.PlatformTesterDTO; @@ -23,7 +19,6 @@ import com.jsowell.pile.mapper.MemberWalletInfoMapper; import com.jsowell.pile.mapper.MemberWalletLogMapper; import com.jsowell.pile.service.*; import com.jsowell.pile.util.UserUtils; -import com.jsowell.pile.vo.base.MerchantInfoVO; import com.jsowell.pile.vo.uniapp.MemberBalanceVO; import com.jsowell.pile.vo.uniapp.MemberVO; import com.jsowell.pile.vo.uniapp.MemberWalletLogVO; @@ -39,7 +34,6 @@ import org.springframework.util.StopWatch; import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; -import java.util.Objects; /** * 会员基础信息Service业务层处理 @@ -425,54 +419,4 @@ public class MemberBasicInfoServiceImpl implements IMemberBasicInfoService { return memberWalletLogMapper.getMemberRefundAmount(memberIds); } - /** - * 获取当前会员中的运营商列表(带权限校验) - */ - @Override - public List getMerchantListByAuth() { - List resultList = Lists.newArrayList(); - // 获取登录用户 所有有权限运营商 - LoginUser loginUser = SecurityUtils.getLoginUser(); - if (Objects.isNull(loginUser)) { - return resultList; - } - // 获取登录用户对应的user对象 - SysUser user = loginUser.getUser(); - if (Objects.isNull(user)) { - return resultList; - } - // 获取所属部门id - SysDept dept = user.getDept(); - if (Objects.isNull(dept)) { - return resultList; - } - String deptLevel = dept.getDeptLevel(); - String deptId = String.valueOf(dept.getDeptId()); - if (Constants.ZERO.equals(deptLevel)) { - // 平台级权限 查询所有生效的运营商 - resultList = pileMerchantInfoService.selectAll(); - } else if (Constants.ONE.equals(deptLevel)) { - // 一级运营商权限 查询该一级运营商下面的所有运营商 - PileMerchantInfo merchantInfo = pileMerchantInfoService.queryInfoByDeptId(deptId); - resultList = pileMerchantInfoService.selectListByFirstMerchant(merchantInfo.getId() + ""); - } else if (Constants.TWO.equals(deptLevel) ) { - // 二级运营商权限 返回自身运营商 - MerchantInfoVO merchantInfoVO = pileMerchantInfoService.queryMerchantInfoVOByDeptId(deptId); - if (Objects.nonNull(merchantInfoVO)) { - resultList.add(merchantInfoVO); - } - } else if (Constants.THREE.equals(deptLevel)) { - // 站点权限 返回自身运营商 - PileStationInfo stationInfo = pileStationInfoService.queryInfoByDeptId(deptId); - if (Objects.nonNull(stationInfo)) { - MerchantInfoVO merchantInfoVO = pileMerchantInfoService.getMerchantInfoVO(stationInfo.getMerchantId() + ""); - if (Objects.nonNull(merchantInfoVO)) { - resultList.add(merchantInfoVO); - } - } - } - return resultList; - } - - } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/util/UserUtils.java b/jsowell-pile/src/main/java/com/jsowell/pile/util/UserUtils.java index bec522fde..3be9075e6 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/util/UserUtils.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/util/UserUtils.java @@ -2,17 +2,24 @@ package com.jsowell.pile.util; import com.alibaba.fastjson2.JSONObject; import com.google.common.collect.Lists; +import com.jsowell.common.constant.Constants; import com.jsowell.common.core.domain.entity.SysDept; import com.jsowell.common.core.domain.entity.SysUser; import com.jsowell.common.core.domain.model.LoginUser; import com.jsowell.common.core.domain.vo.AuthorizedDeptVO; import com.jsowell.common.util.SecurityUtils; +import com.jsowell.pile.domain.PileMerchantInfo; +import com.jsowell.pile.domain.PileStationInfo; import com.jsowell.pile.service.IMemberBasicInfoService; +import com.jsowell.pile.service.IPileMerchantInfoService; +import com.jsowell.pile.service.IPileStationInfoService; +import com.jsowell.pile.vo.base.MerchantInfoVO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.List; +import java.util.Objects; /** * 后管登录用户工具类 @@ -25,10 +32,17 @@ public class UserUtils { // 2.注入想引用的对象的静态实例 private static IMemberBasicInfoService memberBasicInfoService; + private static IPileMerchantInfoService pileMerchantInfoService; + + private static IPileStationInfoService pileStationInfoService; + // 3.初始化有参构造器 @Autowired - public UserUtils(IMemberBasicInfoService memberBasicInfoService) { + public UserUtils(IMemberBasicInfoService memberBasicInfoService, IPileMerchantInfoService pileMerchantInfoService, + IPileStationInfoService pileStationInfoService) { UserUtils.memberBasicInfoService = memberBasicInfoService; + UserUtils.pileMerchantInfoService = pileMerchantInfoService; + UserUtils.pileStationInfoService = pileStationInfoService; } // 4.使用 @@ -72,4 +86,52 @@ public class UserUtils { } return resultVO; } + + /** + * 获取当前会员中的运营商列表(带权限校验) + */ + public static List getMerchantListByAuth() { + List resultList = Lists.newArrayList(); + // 获取登录用户 所有有权限运营商 + LoginUser loginUser = SecurityUtils.getLoginUser(); + if (Objects.isNull(loginUser)) { + return resultList; + } + // 获取登录用户对应的user对象 + SysUser user = loginUser.getUser(); + if (Objects.isNull(user)) { + return resultList; + } + // 获取所属部门id + SysDept dept = user.getDept(); + if (Objects.isNull(dept)) { + return resultList; + } + String deptLevel = dept.getDeptLevel(); + String deptId = String.valueOf(dept.getDeptId()); + if (Constants.ZERO.equals(deptLevel)) { + // 平台级权限 查询所有生效的运营商 + resultList = pileMerchantInfoService.selectAll(); + } else if (Constants.ONE.equals(deptLevel)) { + // 一级运营商权限 查询该一级运营商下面的所有运营商 + PileMerchantInfo merchantInfo = pileMerchantInfoService.queryInfoByDeptId(deptId); + resultList = pileMerchantInfoService.selectListByFirstMerchant(merchantInfo.getId() + ""); + } else if (Constants.TWO.equals(deptLevel) ) { + // 二级运营商权限 返回自身运营商 + MerchantInfoVO merchantInfoVO = pileMerchantInfoService.queryMerchantInfoVOByDeptId(deptId); + if (Objects.nonNull(merchantInfoVO)) { + resultList.add(merchantInfoVO); + } + } else if (Constants.THREE.equals(deptLevel)) { + // 站点权限 返回自身运营商 + PileStationInfo stationInfo = pileStationInfoService.queryInfoByDeptId(deptId); + if (Objects.nonNull(stationInfo)) { + MerchantInfoVO merchantInfoVO = pileMerchantInfoService.getMerchantInfoVO(stationInfo.getMerchantId() + ""); + if (Objects.nonNull(merchantInfoVO)) { + resultList.add(merchantInfoVO); + } + } + } + return resultList; + } } \ No newline at end of file diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/vo/base/LoginUserDetailVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/base/LoginUserDetailVO.java new file mode 100644 index 000000000..beabfa2a3 --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/pile/vo/base/LoginUserDetailVO.java @@ -0,0 +1,25 @@ +package com.jsowell.pile.vo.base; + +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * 登录用户详情VO + */ +@Getter +@Setter +public class LoginUserDetailVO { + /** + * 有权限的一级运营商idList + * 平台级账号有多个一级运营商权限 + * 其他账号只有一个 + */ + private List firstMerchantIdList; + + /** + * 获取当前会员中的运营商列表 + */ + private List merchantInfoVOList; +}