|
@@ -1,11 +1,34 @@
|
|
|
package com.zanxiang.game.module.manage.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.zanxiang.game.module.manage.pojo.dto.AgentDTO;
|
|
|
+import com.zanxiang.game.module.manage.pojo.dto.GameDTO;
|
|
|
+import com.zanxiang.game.module.manage.pojo.params.GameRemitLogListParam;
|
|
|
+import com.zanxiang.game.module.manage.pojo.vo.GameRemitLogVO;
|
|
|
+import com.zanxiang.game.module.manage.service.IAgentService;
|
|
|
import com.zanxiang.game.module.manage.service.IGameRemitLogService;
|
|
|
+import com.zanxiang.game.module.manage.service.IGameService;
|
|
|
+import com.zanxiang.game.module.manage.service.IUserService;
|
|
|
import com.zanxiang.game.module.mybatis.entity.GameRemitLog;
|
|
|
+import com.zanxiang.game.module.mybatis.entity.User;
|
|
|
import com.zanxiang.game.module.mybatis.mapper.GameRemitLogMapper;
|
|
|
+import com.zanxiang.module.util.bean.BeanUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.logging.log4j.util.Strings;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import reactor.util.function.Tuple2;
|
|
|
+
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.LocalTime;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author : lingfeng
|
|
@@ -16,4 +39,50 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class GameRemitLogServiceImpl extends ServiceImpl<GameRemitLogMapper, GameRemitLog> implements IGameRemitLogService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IGameService gameService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IAgentService agentService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IUserService userService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<GameRemitLogVO> listOfPage(GameRemitLogListParam param) {
|
|
|
+ //渠道获取
|
|
|
+ Tuple2<List<Long>, List<AgentDTO>> tuple2 = agentService.getUserAgent(null, null, null);
|
|
|
+ if (CollectionUtils.isNotEmpty(tuple2.getT1())) {
|
|
|
+ return new Page<>();
|
|
|
+ }
|
|
|
+ //查询渠道的用户
|
|
|
+ List<Long> userIdList = userService.list(new LambdaQueryWrapper<User>()
|
|
|
+ .in(User::getAgentId, tuple2.getT1())
|
|
|
+ ).stream().map(User::getId).collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isEmpty(userIdList)) {
|
|
|
+ return new Page<>();
|
|
|
+ }
|
|
|
+ if (param.getUserId() != null && !userIdList.contains(param.getUserId())) {
|
|
|
+ return new Page<>();
|
|
|
+ }
|
|
|
+ return page(param.toPage(), new QueryWrapper<GameRemitLog>().lambda()
|
|
|
+ .in(CollectionUtils.isNotEmpty(userIdList), GameRemitLog::getUserId, userIdList)
|
|
|
+ .eq(param.getUserId() != null, GameRemitLog::getUserId, param.getUserId())
|
|
|
+ .eq(param.getGameId() != null, GameRemitLog::getGameId, param.getGameId())
|
|
|
+ .eq(Strings.isNotBlank(param.getMerchantOrderNo()), GameRemitLog::getMerchantOrderNo, param.getMerchantOrderNo())
|
|
|
+ .ge(param.getStartTime() != null, GameRemitLog::getCreatedTime, param.getStartTime() == null ? null : LocalDateTime.of(param.getStartTime(), LocalTime.MIN))
|
|
|
+ .le(param.getEndTime() != null, GameRemitLog::getCreatedTime, param.getEndTime() == null ? null : LocalDateTime.of(param.getEndTime(), LocalTime.MAX))
|
|
|
+ .orderByDesc(GameRemitLog::getCreatedTime)
|
|
|
+ ).convert(this::toVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ private GameRemitLogVO toVo(GameRemitLog gameRemitLog) {
|
|
|
+ if (Objects.isNull(gameRemitLog)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ GameRemitLogVO gameRemitLogVO = BeanUtil.copy(gameRemitLog, GameRemitLogVO.class);
|
|
|
+ GameDTO gameDTO = gameService.getById(gameRemitLog.getGameId());
|
|
|
+ gameRemitLogVO.setGameName(gameDTO == null ? null : gameDTO.getName());
|
|
|
+ return gameRemitLogVO;
|
|
|
+ }
|
|
|
}
|