diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileMerchantInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileMerchantInfoServiceImpl.java index 1a8a33c64..3e7a1654a 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileMerchantInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileMerchantInfoServiceImpl.java @@ -334,6 +334,7 @@ public class PileMerchantInfoServiceImpl implements IPileMerchantInfoService { .merchantTel(pileMerchantInfo.getServicePhone()) .organizationCode(pileMerchantInfo.getOrganizationCode()) .deptId(pileMerchantInfo.getDeptId()) + .merchantLevel(pileMerchantInfo.getMerchantLevel()) .build(); return vo; } 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 3be9075e6..17727d482 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 @@ -13,6 +13,7 @@ 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.LoginUserDetailVO; import com.jsowell.pile.vo.base.MerchantInfoVO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -20,6 +21,7 @@ import org.springframework.stereotype.Component; import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; /** * 后管登录用户工具类 @@ -134,4 +136,69 @@ public class UserUtils { } return resultList; } + + public static LoginUserDetailVO getLoginUserDetail() { + LoginUserDetailVO resultVO = new LoginUserDetailVO(); + + // 获取登录用户 所有有权限运营商 + LoginUser loginUser = SecurityUtils.getLoginUser(); + if (Objects.isNull(loginUser)) { + return resultVO; + } + // 获取登录用户对应的user对象 + SysUser user = loginUser.getUser(); + if (Objects.isNull(user)) { + return resultVO; + } + // 获取所属部门 + SysDept dept = user.getDept(); + if (Objects.isNull(dept)) { + return resultVO; + } + // 所属部门等级 + String deptLevel = dept.getDeptLevel(); + // 所属部门id + String deptId = String.valueOf(dept.getDeptId()); + List merchantInfoVOList = Lists.newArrayList(); + List firstMerchantIdList = Lists.newArrayList(); + if (Constants.ZERO.equals(deptLevel)) { + // 平台级权限 查询所有生效的运营商 + merchantInfoVOList = pileMerchantInfoService.selectAll(); + + // 获取一级运营商id + List collect = merchantInfoVOList.stream() + .map(MerchantInfoVO::getMerchantLevel) + .filter("1"::equals) + .collect(Collectors.toList()); + firstMerchantIdList.addAll(collect); + } else if (Constants.ONE.equals(deptLevel)) { + // 一级运营商权限 查询该一级运营商下面的所有运营商 + PileMerchantInfo merchantInfo = pileMerchantInfoService.queryInfoByDeptId(deptId); + if (Objects.nonNull(merchantInfo)) { + String firstMerchantId = merchantInfo.getId().toString(); + // 获取一级运营商id + firstMerchantIdList.add(firstMerchantId); + merchantInfoVOList = pileMerchantInfoService.selectListByFirstMerchant(firstMerchantId); + } + } else if (Constants.TWO.equals(deptLevel)) { + // 二级运营商权限 返回自身运营商 + MerchantInfoVO merchantInfoVO = pileMerchantInfoService.queryMerchantInfoVOByDeptId(deptId); + if (Objects.nonNull(merchantInfoVO)) { + merchantInfoVOList.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)) { + merchantInfoVOList.add(merchantInfoVO); + } + } + } + resultVO.setMerchantInfoVOList(merchantInfoVOList); + + + return null; + } } \ No newline at end of file diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/vo/base/MerchantInfoVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/base/MerchantInfoVO.java index 5f83a220d..8a95d715b 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/vo/base/MerchantInfoVO.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/vo/base/MerchantInfoVO.java @@ -20,6 +20,11 @@ public class MerchantInfoVO { */ private String merchantName; + /** + * 运营商等级 + */ + private String merchantLevel; + /** * 商户电话 */