|
@@ -3,6 +3,7 @@ package com.zanxiang.game.back.serve.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.zanxiang.advertising.tencent.base.AdvertisingTencentServer;
|
|
import com.zanxiang.advertising.tencent.base.AdvertisingTencentServer;
|
|
import com.zanxiang.advertising.tencent.base.pojo.dto.DataReportOfAppIdRpcDTO;
|
|
import com.zanxiang.advertising.tencent.base.pojo.dto.DataReportOfAppIdRpcDTO;
|
|
@@ -13,15 +14,21 @@ import com.zanxiang.erp.base.rpc.ISysUserRpc;
|
|
import com.zanxiang.game.back.serve.dao.mapper.GameTencentUserMapper;
|
|
import com.zanxiang.game.back.serve.dao.mapper.GameTencentUserMapper;
|
|
import com.zanxiang.game.back.serve.pojo.dto.GameTencentUserDTO;
|
|
import com.zanxiang.game.back.serve.pojo.dto.GameTencentUserDTO;
|
|
import com.zanxiang.game.back.serve.pojo.entity.GameTencentBackLog;
|
|
import com.zanxiang.game.back.serve.pojo.entity.GameTencentBackLog;
|
|
|
|
+import com.zanxiang.game.back.serve.pojo.entity.GameTencentMiniGameUser;
|
|
import com.zanxiang.game.back.serve.pojo.entity.GameTencentUser;
|
|
import com.zanxiang.game.back.serve.pojo.entity.GameTencentUser;
|
|
import com.zanxiang.game.back.serve.pojo.enums.ActionTypeEnum;
|
|
import com.zanxiang.game.back.serve.pojo.enums.ActionTypeEnum;
|
|
import com.zanxiang.game.back.serve.pojo.enums.BackStatusEnum;
|
|
import com.zanxiang.game.back.serve.pojo.enums.BackStatusEnum;
|
|
|
|
+import com.zanxiang.game.back.serve.pojo.vo.GameTencentMiniGameUserVO;
|
|
import com.zanxiang.game.back.serve.pojo.vo.GameTencentUserVO;
|
|
import com.zanxiang.game.back.serve.pojo.vo.GameTencentUserVO;
|
|
import com.zanxiang.game.back.serve.service.IGameTencentBackLogService;
|
|
import com.zanxiang.game.back.serve.service.IGameTencentBackLogService;
|
|
import com.zanxiang.game.back.serve.service.IGameTencentUserService;
|
|
import com.zanxiang.game.back.serve.service.IGameTencentUserService;
|
|
|
|
+import com.zanxiang.game.module.base.ServerInfo;
|
|
|
|
+import com.zanxiang.game.module.base.pojo.vo.AgentRpcVO;
|
|
|
|
+import com.zanxiang.game.module.base.rpc.IAgentRpc;
|
|
import com.zanxiang.module.util.bean.BeanUtil;
|
|
import com.zanxiang.module.util.bean.BeanUtil;
|
|
import com.zanxiang.module.util.pojo.ResultVO;
|
|
import com.zanxiang.module.util.pojo.ResultVO;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -29,9 +36,14 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Collections;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.Set;
|
|
|
|
+import java.util.function.Function;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -51,6 +63,8 @@ public class GameTencentUserServiceImpl extends ServiceImpl<GameTencentUserMappe
|
|
private ISysUserRpc sysUserRpc;
|
|
private ISysUserRpc sysUserRpc;
|
|
@Autowired
|
|
@Autowired
|
|
private IGameTencentBackLogService gameTencentBackLogService;
|
|
private IGameTencentBackLogService gameTencentBackLogService;
|
|
|
|
+ @DubboReference(providedBy = ServerInfo.SERVER_DUBBO_NAME)
|
|
|
|
+ private IAgentRpc agentRpc;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -65,7 +79,7 @@ public class GameTencentUserServiceImpl extends ServiceImpl<GameTencentUserMappe
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public IPage<GameTencentUserVO> tencentUserLogList(GameTencentUserDTO dto) {
|
|
public IPage<GameTencentUserVO> tencentUserLogList(GameTencentUserDTO dto) {
|
|
- return page(dto.toPage(), new LambdaQueryWrapper<GameTencentUser>()
|
|
|
|
|
|
+ IPage<GameTencentUser> page = page(dto.toPage(), new LambdaQueryWrapper<GameTencentUser>()
|
|
.eq(StringUtils.isNotBlank(dto.getChannel()), GameTencentUser::getChannel, dto.getChannel())
|
|
.eq(StringUtils.isNotBlank(dto.getChannel()), GameTencentUser::getChannel, dto.getChannel())
|
|
.eq(null != dto.getGameId(), GameTencentUser::getGameId, dto.getGameId())
|
|
.eq(null != dto.getGameId(), GameTencentUser::getGameId, dto.getGameId())
|
|
.eq(null != dto.getAdAccountId(), GameTencentUser::getAdAccountId, dto.getAdAccountId())
|
|
.eq(null != dto.getAdAccountId(), GameTencentUser::getAdAccountId, dto.getAdAccountId())
|
|
@@ -73,11 +87,14 @@ public class GameTencentUserServiceImpl extends ServiceImpl<GameTencentUserMappe
|
|
.eq(StringUtils.isNotBlank(dto.getWechatOpenid()), GameTencentUser::getWechatOpenid, dto.getWechatOpenid())
|
|
.eq(StringUtils.isNotBlank(dto.getWechatOpenid()), GameTencentUser::getWechatOpenid, dto.getWechatOpenid())
|
|
.eq(null != dto.getIsBack(), GameTencentUser::getIsBack, dto.getIsBack())
|
|
.eq(null != dto.getIsBack(), GameTencentUser::getIsBack, dto.getIsBack())
|
|
.orderByDesc(GameTencentUser::getCreateTime)
|
|
.orderByDesc(GameTencentUser::getCreateTime)
|
|
- ).convert(item -> {
|
|
|
|
- GameTencentUserVO copy = BeanUtil.copy(item, GameTencentUserVO.class);
|
|
|
|
- copy.setUpdateName(null == item.getUpdateBy() ? null : sysUserRpc.getById(item.getUpdateBy()).getData().getNickName());
|
|
|
|
- return copy;
|
|
|
|
- });
|
|
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ IPage<GameTencentUserVO> result = new Page<>(page.getCurrent(), page.getSize(), page.getTotal());
|
|
|
|
+ if (CollectionUtils.isEmpty(page.getRecords())) {
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ result.setRecords(toVOBatch(page.getRecords()));
|
|
|
|
+ return result;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -92,6 +109,26 @@ public class GameTencentUserServiceImpl extends ServiceImpl<GameTencentUserMappe
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private List<GameTencentUserVO> toVOBatch(List<GameTencentUser> logList) {
|
|
|
|
+ if (CollectionUtils.isEmpty(logList)) {
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
+ }
|
|
|
|
+ Set<String> agentKeys = logList.stream().map(GameTencentUser::getChannel).filter(StringUtils::isNotBlank).collect(Collectors.toSet());
|
|
|
|
+ Map<String, AgentRpcVO> agentMap = CollectionUtils.isEmpty(agentKeys) ? Collections.emptyMap() : agentRpc.getByAgentKeys(new ArrayList<>(agentKeys))
|
|
|
|
+ .getData().stream().collect(Collectors.toMap(AgentRpcVO::getAgentKey, Function.identity()));
|
|
|
|
+ return logList.stream().map(log -> {
|
|
|
|
+ GameTencentUserVO vo = BeanUtil.copy(log, GameTencentUserVO.class);
|
|
|
|
+ if (StringUtils.isNotBlank(log.getChannel())) {
|
|
|
|
+ AgentRpcVO agent = agentMap.get(log.getChannel());
|
|
|
|
+ if (agent != null) {
|
|
|
|
+ vo.setAgentName(agent.getAgentName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return vo;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
private BackStatusEnum doCallback(GameTencentUser userLog, boolean mustBack) {
|
|
private BackStatusEnum doCallback(GameTencentUser userLog, boolean mustBack) {
|
|
boolean isBack = mustBack ? false : gameTencentBackLogService.count(new LambdaQueryWrapper<GameTencentBackLog>()
|
|
boolean isBack = mustBack ? false : gameTencentBackLogService.count(new LambdaQueryWrapper<GameTencentBackLog>()
|