|
@@ -11,13 +11,15 @@ import com.zanxiang.advertising.tencent.base.pojo.vo.UserActionSetRpcVO;
|
|
|
import com.zanxiang.advertising.tencent.base.rpc.IAdAccountRpc;
|
|
|
import com.zanxiang.advertising.tencent.base.rpc.IUserActionSetRpc;
|
|
|
import com.zanxiang.erp.base.ErpServer;
|
|
|
-import com.zanxiang.erp.base.rpc.ISysUserGroupRpc;
|
|
|
+import com.zanxiang.erp.base.pojo.vo.SysGameUserGroupRpcVO;
|
|
|
+import com.zanxiang.erp.base.rpc.ISysGameUserGroupRpc;
|
|
|
import com.zanxiang.erp.base.rpc.ISysUserRpc;
|
|
|
import com.zanxiang.erp.security.util.SecurityUtil;
|
|
|
import com.zanxiang.game.back.base.ServerInfo;
|
|
|
import com.zanxiang.game.back.base.pojo.vo.GameBackPolicyRpcVO;
|
|
|
import com.zanxiang.game.back.base.rpc.IGameBackPolicyRpc;
|
|
|
import com.zanxiang.game.module.base.pojo.enums.AccountTypeEnum;
|
|
|
+import com.zanxiang.game.module.base.pojo.enums.GameAuthEnum;
|
|
|
import com.zanxiang.game.module.manage.pojo.dto.AgentDTO;
|
|
|
import com.zanxiang.game.module.manage.pojo.params.AgentAddParam;
|
|
|
import com.zanxiang.game.module.manage.pojo.params.AgentListParam;
|
|
@@ -26,8 +28,11 @@ import com.zanxiang.game.module.manage.pojo.vo.AgentChoiceVO;
|
|
|
import com.zanxiang.game.module.manage.pojo.vo.AgentVO;
|
|
|
import com.zanxiang.game.module.manage.pojo.vo.GameInfoVO;
|
|
|
import com.zanxiang.game.module.manage.service.IAgentService;
|
|
|
+import com.zanxiang.game.module.manage.service.IGameAuthRoleService;
|
|
|
+import com.zanxiang.game.module.manage.service.IGameAuthService;
|
|
|
import com.zanxiang.game.module.manage.service.IGameService;
|
|
|
import com.zanxiang.game.module.mybatis.entity.Agent;
|
|
|
+import com.zanxiang.game.module.mybatis.entity.GameAuthRole;
|
|
|
import com.zanxiang.game.module.mybatis.mapper.AgentMapper;
|
|
|
import com.zanxiang.module.util.JsonUtil;
|
|
|
import com.zanxiang.module.util.bean.BeanUtil;
|
|
@@ -72,7 +77,13 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
|
|
|
private IGameBackPolicyRpc gameBackPolicyRpc;
|
|
|
|
|
|
@DubboReference(providedBy = ErpServer.SERVER_DUBBO_NAME)
|
|
|
- private ISysUserGroupRpc sysUserGroupRpc;
|
|
|
+ private ISysGameUserGroupRpc sysGameUserGroupRpc;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IGameAuthRoleService gameAuthRoleService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IGameAuthService gameAuthService;
|
|
|
|
|
|
@Override
|
|
|
public IPage<AgentVO> listOfPage(AgentListParam param) {
|
|
@@ -212,73 +223,75 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
|
|
|
|
|
|
@Override
|
|
|
public Tuple2<List<Long>, List<AgentDTO>> getUserAgent(String account, String pitcherId, Long agentId) {
|
|
|
- //组成员列表
|
|
|
- List<Long> memberUserIdList = sysUserGroupRpc.memberUserId(SecurityUtil.getCompanyId(), SecurityUtil.getUserId()).getData();
|
|
|
-
|
|
|
- log.error("查询组员 userId : {}, list : {}", SecurityUtil.getUserId(), JsonUtil.toString(memberUserIdList));
|
|
|
-
|
|
|
+ //判断是否是组长
|
|
|
+ SysGameUserGroupRpcVO sysGameUserGroupRpcVO = sysGameUserGroupRpc.getByGroupUser(SecurityUtil.getCompanyId(),
|
|
|
+ SecurityUtil.getUserId()).getData();
|
|
|
+ log.error("判断是否是组长, sysGameUserGroupRpcVO : {}", JsonUtil.toString(sysGameUserGroupRpcVO));
|
|
|
+ //判断运营
|
|
|
+ GameAuthRole gameAuthRole = gameAuthRoleService.getOne(new LambdaQueryWrapper<GameAuthRole>()
|
|
|
+ .eq(GameAuthRole::getUserId, SecurityUtil.getUserId()));
|
|
|
//自然量查询
|
|
|
if (Objects.equals(agentId, Agent.DEFAULT_AGENT)) {
|
|
|
- //判断管理员或者组长
|
|
|
- if (SecurityUtil.isAdmin() || CollectionUtils.isNotEmpty(memberUserIdList)) {
|
|
|
+ //超管, 运营, 组长可以查询自然量
|
|
|
+ if (SecurityUtil.isAdmin() || sysGameUserGroupRpcVO != null
|
|
|
+ || Objects.equals(gameAuthRole.getAuthType(), GameAuthEnum.OPERATE.getValue())) {
|
|
|
return Tuples.of(Collections.singletonList(Agent.DEFAULT_AGENT), Collections.emptyList());
|
|
|
}
|
|
|
//非管理员或者组长不允许查询自然量
|
|
|
return Tuples.of(Collections.emptyList(), Collections.emptyList());
|
|
|
}
|
|
|
//渠道列表
|
|
|
- List<Agent> agentList;
|
|
|
- List<AgentDTO> agentDTOList = new ArrayList<>();
|
|
|
- boolean groupLeader = false;
|
|
|
- //超管权限
|
|
|
+ List<Agent> agentList = new ArrayList<>();
|
|
|
+ //是否需要自然量
|
|
|
+ boolean defaultAgent = true;
|
|
|
+ //超管权限, 返回所有渠道
|
|
|
if (SecurityUtil.isAdmin()) {
|
|
|
agentList = super.list(new LambdaQueryWrapper<Agent>()
|
|
|
.eq(Strings.isNotBlank(account), Agent::getAccountId, account)
|
|
|
.eq(Strings.isNotBlank(pitcherId), Agent::getCreateBy, pitcherId)
|
|
|
.eq(agentId != null, Agent::getId, agentId));
|
|
|
- } else {
|
|
|
- //组长, 可查看自己或者组员数据
|
|
|
- if (CollectionUtils.isNotEmpty(memberUserIdList)) {
|
|
|
- groupLeader = true;
|
|
|
- if (!memberUserIdList.contains(SecurityUtil.getUserId())) {
|
|
|
- memberUserIdList.add(SecurityUtil.getUserId());
|
|
|
- }
|
|
|
+ } else if (Objects.equals(gameAuthRole.getAuthType(), GameAuthEnum.OPERATE.getValue())) {
|
|
|
+ //运营权限, 获取拥有的游戏的所有渠道
|
|
|
+ Tuple2<String, List<Long>> tuple2 = gameAuthService.getUserGameList(null);
|
|
|
+ if (CollectionUtils.isNotEmpty(tuple2.getT2())) {
|
|
|
agentList = super.list(new LambdaQueryWrapper<Agent>()
|
|
|
+ .in(Agent::getGameId, tuple2.getT2())
|
|
|
.eq(Strings.isNotBlank(account), Agent::getAccountId, account)
|
|
|
.eq(Strings.isNotBlank(pitcherId), Agent::getCreateBy, pitcherId)
|
|
|
- .in(Strings.isBlank(pitcherId), Agent::getCreateBy, memberUserIdList)
|
|
|
- .eq(agentId != null, Agent::getId, agentId));
|
|
|
- } else {
|
|
|
- //组员, 只允许查看自己的数据
|
|
|
- agentList = super.list(new LambdaQueryWrapper<Agent>()
|
|
|
- .eq(Strings.isNotBlank(account), Agent::getAccountId, account)
|
|
|
- .eq(Agent::getCreateBy, SecurityUtil.getUserId())
|
|
|
.eq(agentId != null, Agent::getId, agentId));
|
|
|
}
|
|
|
+ } else if (sysGameUserGroupRpcVO != null) {
|
|
|
+ //组长权限, 获取组员id, 查询组内所有渠道
|
|
|
+ Collection<Long> memberUserIdList = sysGameUserGroupRpc.memberUserIds(SecurityUtil.getCompanyId(),
|
|
|
+ SecurityUtil.getUserId()).getData();
|
|
|
+ log.error("获取组员信息, userId : {}, memberUserIdList : {}", SecurityUtil.getUserId(), JsonUtil.toString(memberUserIdList));
|
|
|
+ agentList = super.list(new LambdaQueryWrapper<Agent>()
|
|
|
+ .eq(Strings.isNotBlank(account), Agent::getAccountId, account)
|
|
|
+ .eq(Strings.isNotBlank(pitcherId), Agent::getCreateBy, pitcherId)
|
|
|
+ .in(Strings.isBlank(pitcherId), Agent::getCreateBy, memberUserIdList)
|
|
|
+ .eq(agentId != null, Agent::getId, agentId));
|
|
|
+ } else {
|
|
|
+ //组员, 只允许查看自己的数据
|
|
|
+ agentList = super.list(new LambdaQueryWrapper<Agent>()
|
|
|
+ .eq(Strings.isNotBlank(account), Agent::getAccountId, account)
|
|
|
+ .eq(Agent::getCreateBy, SecurityUtil.getUserId())
|
|
|
+ .eq(agentId != null, Agent::getId, agentId));
|
|
|
+ defaultAgent = false;
|
|
|
}
|
|
|
- if (CollectionUtils.isNotEmpty(agentList)) {
|
|
|
- //设置归属投手
|
|
|
- List<Long> createByList = agentList.stream().map(Agent::getCreateBy).collect(Collectors.toList());
|
|
|
- Map<Long, String> userMap = sysUserRpc.getUserNameByIds(createByList).getData();
|
|
|
- agentDTOList = agentList.stream().map(agent -> {
|
|
|
- AgentDTO agentDTO = BeanUtil.copy(agent, AgentDTO.class);
|
|
|
- agentDTO.setCreateByName(userMap.get(agent.getCreateBy()));
|
|
|
- return agentDTO;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- }
|
|
|
- //根据条件, 匹配渠道
|
|
|
- if (CollectionUtils.isEmpty(agentDTOList) && !SecurityUtil.isAdmin()) {
|
|
|
- return Tuples.of(Collections.emptyList(), Collections.emptyList());
|
|
|
+ //未指定搜索条件, 且可见自然量
|
|
|
+ if (Strings.isBlank(account) && Strings.isBlank(pitcherId) && agentId == null && defaultAgent) {
|
|
|
+ agentList.add(Agent.builder().id(Agent.DEFAULT_AGENT).agentName(Agent.DEFAULT_AGENT_NAME).build());
|
|
|
}
|
|
|
+ //设置归属投手
|
|
|
+ List<Long> createByList = agentList.stream().map(Agent::getCreateBy).collect(Collectors.toList());
|
|
|
+ Map<Long, String> userMap = sysUserRpc.getUserNameByIds(createByList).getData();
|
|
|
+ List<AgentDTO> agentDTOList = agentList.stream().map(agent -> {
|
|
|
+ AgentDTO agentDTO = BeanUtil.copy(agent, AgentDTO.class);
|
|
|
+ agentDTO.setCreateByName(userMap.get(agent.getCreateBy()));
|
|
|
+ return agentDTO;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
//渠道id列表
|
|
|
List<Long> agentIds = agentDTOList.stream().map(AgentDTO::getId).collect(Collectors.toList());
|
|
|
- //未指定搜索条件
|
|
|
- if (Strings.isBlank(account) && Strings.isBlank(pitcherId) && agentId == null) {
|
|
|
- //管理员和组长可见自然量
|
|
|
- if (SecurityUtil.isAdmin() || groupLeader) {
|
|
|
- agentIds.add(Agent.DEFAULT_AGENT);
|
|
|
- }
|
|
|
- }
|
|
|
//返回渠道列表
|
|
|
return Tuples.of(agentIds, agentDTOList);
|
|
|
}
|
|
@@ -292,16 +305,51 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
|
|
|
|
|
|
@Override
|
|
|
public List<AgentChoiceVO> agentChoiceList() {
|
|
|
- List<AgentChoiceVO> choiceVOList = super.list(new LambdaQueryWrapper<Agent>()
|
|
|
- .eq(!SecurityUtil.isAdmin(), Agent::getCreateBy, SecurityUtil.getUserId())
|
|
|
- ).stream().map(agent -> BeanUtil.copy(agent, AgentChoiceVO.class)).collect(Collectors.toList());
|
|
|
-
|
|
|
- //组成员列表
|
|
|
- List<Long> memberUserIdList = sysUserGroupRpc.memberUserId(SecurityUtil.getCompanyId(), SecurityUtil.getUserId()).getData();
|
|
|
- if (CollectionUtils.isNotEmpty(memberUserIdList)) {
|
|
|
- choiceVOList.add(AgentChoiceVO.builder().id(Agent.DEFAULT_AGENT).agentName(Agent.DEFAULT_AGENT_NAME).build());
|
|
|
+ //判断是否是组长
|
|
|
+ SysGameUserGroupRpcVO sysGameUserGroupRpcVO = sysGameUserGroupRpc.getByGroupUser(SecurityUtil.getCompanyId(),
|
|
|
+ SecurityUtil.getUserId()).getData();
|
|
|
+ //判断运营
|
|
|
+ GameAuthRole gameAuthRole = gameAuthRoleService.getOne(new LambdaQueryWrapper<GameAuthRole>()
|
|
|
+ .eq(GameAuthRole::getUserId, SecurityUtil.getUserId()));
|
|
|
+ //渠道列表
|
|
|
+ List<Agent> agentList = new ArrayList<>();
|
|
|
+ //是否需要自然量
|
|
|
+ boolean defaultAgent = true;
|
|
|
+ //超管权限, 返回所有渠道
|
|
|
+ if (SecurityUtil.isAdmin()) {
|
|
|
+ agentList = super.list();
|
|
|
+ } else if (Objects.equals(gameAuthRole.getAuthType(), GameAuthEnum.OPERATE.getValue())) {
|
|
|
+ //运营权限, 获取拥有的游戏的所有渠道
|
|
|
+ Tuple2<String, List<Long>> tuple2 = gameAuthService.getUserGameList(null);
|
|
|
+ if (CollectionUtils.isNotEmpty(tuple2.getT2())) {
|
|
|
+ agentList = super.list(new LambdaQueryWrapper<Agent>().in(Agent::getGameId, tuple2.getT2()));
|
|
|
+ }
|
|
|
+ } else if (sysGameUserGroupRpcVO != null) {
|
|
|
+ //组长权限, 获取组员id, 查询组内所有渠道
|
|
|
+ Collection<Long> memberUserIdList = sysGameUserGroupRpc.memberUserIds(SecurityUtil.getCompanyId(),
|
|
|
+ SecurityUtil.getUserId()).getData();
|
|
|
+ agentList = super.list(new LambdaQueryWrapper<Agent>().in(!SecurityUtil.isAdmin(), Agent::getCreateBy, memberUserIdList));
|
|
|
+ } else {
|
|
|
+ //组员权限, 组员返回自己拥有的渠道
|
|
|
+ agentList = super.list(new LambdaQueryWrapper<Agent>()
|
|
|
+ .eq(!SecurityUtil.isAdmin(), Agent::getCreateBy, SecurityUtil.getUserId()));
|
|
|
+ defaultAgent = false;
|
|
|
+ }
|
|
|
+ //超管, 组长, 运营权限可以存在自然量搜索
|
|
|
+ if (defaultAgent) {
|
|
|
+ agentList.add(Agent.builder().id(Agent.DEFAULT_AGENT).agentName(Agent.DEFAULT_AGENT_NAME).build());
|
|
|
}
|
|
|
- return choiceVOList;
|
|
|
+ //返回渠道列表
|
|
|
+ return agentList.stream().map(agent -> BeanUtil.copy(agent, AgentChoiceVO.class)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AgentDTO getAgentById(long agentId) {
|
|
|
+ Agent agent = super.getById(agentId);
|
|
|
+ Map<Long, String> userMap = sysUserRpc.getUserNameByIds(Collections.singletonList(agent.getCreateBy())).getData();
|
|
|
+ AgentDTO agentDTO = BeanUtil.copy(agent, AgentDTO.class);
|
|
|
+ agentDTO.setCreateByName(userMap.get(agent.getCreateBy()));
|
|
|
+ return agentDTO;
|
|
|
}
|
|
|
|
|
|
@Override
|