|
@@ -1,14 +1,17 @@
|
|
|
package com.zanxiang.game.module.manage.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.zanxiang.advertising.tencent.base.AdvertisingTencentServer;
|
|
|
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.pojo.vo.SysUserRpcVO;
|
|
|
+import com.zanxiang.erp.base.rpc.ISysUserRpc;
|
|
|
import com.zanxiang.erp.security.util.SecurityUtil;
|
|
|
-import com.zanxiang.game.module.base.utils.StringUtils;
|
|
|
import com.zanxiang.game.module.manage.pojo.dto.AgentDTO;
|
|
|
import com.zanxiang.game.module.manage.pojo.dto.AgentListDTO;
|
|
|
import com.zanxiang.game.module.manage.pojo.enums.AccountTypeEnum;
|
|
@@ -17,12 +20,12 @@ import com.zanxiang.game.module.manage.pojo.vo.GameInfoVO;
|
|
|
import com.zanxiang.game.module.manage.service.IAgentService;
|
|
|
import com.zanxiang.game.module.manage.service.IGameService;
|
|
|
import com.zanxiang.game.module.mybatis.entity.Agent;
|
|
|
-import com.zanxiang.game.module.mybatis.entity.Game;
|
|
|
import com.zanxiang.game.module.mybatis.mapper.AgentMapper;
|
|
|
import com.zanxiang.module.util.bean.BeanUtil;
|
|
|
import com.zanxiang.module.util.exception.BaseException;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -51,6 +54,8 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent>
|
|
|
private IAdAccountRpc adAccountRpc;
|
|
|
@DubboReference(providedBy = AdvertisingTencentServer.SERVER_DUBBO_NAME)
|
|
|
private IUserActionSetRpc userActionSetRpc;
|
|
|
+ @Autowired
|
|
|
+ private ISysUserRpc sysUserRpc;
|
|
|
|
|
|
public IPage<AgentVO> listOfPage(AgentListDTO dto) {
|
|
|
IPage<Agent> agentIPage = page(dto.toPage(), new LambdaQueryWrapper<Agent>()
|
|
@@ -62,8 +67,14 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent>
|
|
|
.eq(dto.getPutStatus() != null, Agent::getPutStatus, dto.getPutStatus())
|
|
|
.ge(dto.getCreateBeginTime() != null, Agent::getCreateTime, dto.getCreateBeginTime() == null ? null : LocalDateTime.of(dto.getCreateBeginTime(), LocalTime.MIDNIGHT))
|
|
|
.le(dto.getCreateEndTime() != null, Agent::getCreateTime, dto.getCreateEndTime() == null ? null : LocalDateTime.of(dto.getCreateEndTime(), LocalTime.MIDNIGHT))
|
|
|
+ .eq(Agent::getCreateBy, dto.getPutUserId() == null ? SecurityUtil.getUserId() : dto.getPutUserId())
|
|
|
.orderByDesc(Agent::getCreateTime)
|
|
|
);
|
|
|
+ IPage<AgentVO> result = new Page<>(agentIPage.getCurrent(), agentIPage.getSize(), agentIPage.getTotal());
|
|
|
+ if (CollectionUtils.isNotEmpty(agentIPage.getRecords())) {
|
|
|
+ result.setRecords(toVOBatch(agentIPage.getRecords()));
|
|
|
+ }
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -75,17 +86,40 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent>
|
|
|
) > 0) {
|
|
|
throw new BaseException("一个账号只能建一个渠道,投一个游戏!!!");
|
|
|
}
|
|
|
- Agent agent = Agent.builder()
|
|
|
+ return save(Agent.builder()
|
|
|
.agentName(dto.getAgentName())
|
|
|
.agentKey(UUID.randomUUID().toString().replaceAll("-", ""))
|
|
|
.accountType(dto.getAccountType())
|
|
|
.accountId(dto.getAccountId())
|
|
|
.gameId(dto.getGameId())
|
|
|
.userActionSetId(dto.getUserActionSetId())
|
|
|
+ .backPolicyId(dto.getBackPolicyId())
|
|
|
+ .putStatus(dto.getPutStatus())
|
|
|
.createTime(LocalDateTime.now())
|
|
|
.createBy(SecurityUtil.getUserId())
|
|
|
- .build();
|
|
|
- return save(agent);
|
|
|
+ .build());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public boolean configPutStatus(List<Long> agentIdList, Integer putStatus) {
|
|
|
+ return update(new LambdaUpdateWrapper<Agent>()
|
|
|
+ .set(Agent::getPutStatus, putStatus)
|
|
|
+ .set(Agent::getUpdateBy, SecurityUtil.getUserId())
|
|
|
+ .set(Agent::getUpdateTime, agentIdList)
|
|
|
+ .in(Agent::getId, agentIdList)
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public boolean configBackPolicy(List<Long> agentIdList, Long backPolicyId) {
|
|
|
+ return update(new LambdaUpdateWrapper<Agent>()
|
|
|
+ .set(Agent::getBackPolicyId, backPolicyId)
|
|
|
+ .set(Agent::getUpdateBy, SecurityUtil.getUserId())
|
|
|
+ .set(Agent::getUpdateTime, agentIdList)
|
|
|
+ .in(Agent::getId, agentIdList)
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
private List<AgentVO> toVOBatch(List<Agent> agentList) {
|
|
@@ -94,31 +128,36 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent>
|
|
|
}
|
|
|
Set<Long> gameIds = new HashSet<>(agentList.size());
|
|
|
Set<Long> txAccountIds = new HashSet<>(agentList.size());
|
|
|
- Set<Long> txUserActionSetIds = new HashSet<>(agentList.size());
|
|
|
- Set<Long> byteAccountIds = new HashSet<>(agentList.size());
|
|
|
+ Set<Long> userIds = new HashSet<>(1);
|
|
|
agentList.forEach(agent -> {
|
|
|
gameIds.add(agent.getGameId());
|
|
|
if (AccountTypeEnum.TENCENT.getValue().equals(agent.getAccountType())) {
|
|
|
txAccountIds.add(agent.getAccountId());
|
|
|
- txUserActionSetIds.add(agent.getUserActionSetId());
|
|
|
- } else {
|
|
|
- byteAccountIds.add(agent.getAccountId());
|
|
|
}
|
|
|
+ userIds.add(agent.getCreateBy());
|
|
|
});
|
|
|
- Map<Long, UserActionSetRpcVO> userActionSetMap = new HashMap<>(0);
|
|
|
+ Map<String, UserActionSetRpcVO> userActionSetMap = new HashMap<>();
|
|
|
if (CollectionUtils.isNotEmpty(txAccountIds)) {
|
|
|
- for(Long txAccountId : txAccountIds) {
|
|
|
- userActionSetMap = userActionSetRpc.getByAccount(txAccountId).getData();
|
|
|
+ for (Long txAccountId : txAccountIds) {
|
|
|
+ List<UserActionSetRpcVO> userActionSetList = userActionSetRpc.getByAccount(txAccountId).getData();
|
|
|
+ if (CollectionUtils.isEmpty(userActionSetList)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ userActionSetMap.putAll(userActionSetList.stream().collect(Collectors.toMap(obj -> obj.getAccountId() + "_" + obj.getUserActionSetId(), Function.identity())));
|
|
|
}
|
|
|
}
|
|
|
Map<Long, GameInfoVO> gameMap = gameService.infoByIds(gameIds).stream().collect(Collectors.toMap(GameInfoVO::getId, Function.identity()));
|
|
|
+ Map<Long, SysUserRpcVO> userMap = sysUserRpc.userInfoByIds(SecurityUtil.getCompanyId(), new ArrayList<>(userIds)).getData().stream()
|
|
|
+ .collect(Collectors.toMap(SysUserRpcVO::getUserId, Function.identity()));
|
|
|
return agentList.stream().map(agent -> {
|
|
|
AgentVO vo = BeanUtil.copy(agent, AgentVO.class);
|
|
|
vo.setGameInfo(gameMap.get(agent.getGameId()));
|
|
|
- vo.setUserActionSet();
|
|
|
+ if (AccountTypeEnum.TENCENT.getValue().equals(agent.getAccountType())) {
|
|
|
+ vo.setUserActionSet(userActionSetMap.get(agent.getAccountId() + "_" + agent.getUserActionSetId()));
|
|
|
+ }
|
|
|
+ vo.setUserInfo(userMap.get(agent.getCreateBy()));
|
|
|
return vo;
|
|
|
}).collect(Collectors.toList());
|
|
|
-
|
|
|
}
|
|
|
|
|
|
private AgentVO toVOSimple(Agent agent) {
|