Prechádzať zdrojové kódy

feat : 订单列表修改

bilingfeng 2 rokov pred
rodič
commit
62e5e2d3f4

+ 5 - 4
game-module/game-manage/src/main/java/com/zanxiang/manage/domain/vo/OrderVO.java

@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.math.BigDecimal;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 
 /**
@@ -18,10 +19,10 @@ public class OrderVO {
     private String id;
 
     @ApiModelProperty(notes = "日期")
-    private Long dateTime;
+    private LocalDate dateTime;
 
     @ApiModelProperty(notes = "订单ID:订单号")
-    private Long orderId;
+    private String orderId;
 
     @ApiModelProperty(notes = "cp订单号")
     private String cpOrderId;
@@ -51,7 +52,7 @@ public class OrderVO {
     private Long regGameId;
 
     @ApiModelProperty(notes = "注册游戏名称")
-    private Long regGameName;
+    private String regGameName;
 
     @ApiModelProperty(notes = "cpId")
     private Long cpId;
@@ -93,7 +94,7 @@ public class OrderVO {
     private String gameName;
 
     @ApiModelProperty(notes = "充值游戏类型")
-    private String gameCategoryId;
+    private Long gameCategoryId;
 
     @ApiModelProperty(notes = "充值游戏类型")
     private String gameCategory;

+ 9 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/service/GameService.java

@@ -7,6 +7,7 @@ import com.zanxiang.manage.domain.params.*;
 import com.zanxiang.manage.domain.vo.*;
 import com.zanxiang.mybatis.entity.Game;
 
+import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
@@ -129,4 +130,12 @@ public interface GameService extends IService<Game> {
      * @return : 返回删除结果
      */
     Boolean statusUpdate(Long id, Integer status);
+
+    /**
+     * 游戏列表
+     *
+     * @param gameIds 游戏id列表
+     * @return {@link Map}<{@link Long}, {@link GameDTO}>
+     */
+    Map<Long, GameDTO> gameMap(Collection<Long> gameIds);
 }

+ 19 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/service/Impl/GameServiceImpl.java

@@ -522,6 +522,25 @@ public class GameServiceImpl extends ServiceImpl<GameMapper, Game> implements Ga
         return BeanUtils.copyList(gameList, GameDTO.class);
     }
 
+    /**
+     * 游戏列表
+     *
+     * @param gameIds 游戏id列表
+     * @return {@link Map}<{@link Long}, {@link GameDTO}>
+     */
+    @Override
+    public Map<Long, GameDTO> gameMap(Collection<Long> gameIds) {
+        if (CollectionUtils.isEmpty(gameIds)) {
+            return Collections.emptyMap();
+        }
+        List<Game> gameList = super.listByIds(gameIds);
+        if (CollectionUtils.isEmpty(gameList)) {
+            return Collections.emptyMap();
+        }
+        List<GameDTO> gameDTOList = BeanUtils.copyList(gameList, GameDTO.class);
+        return gameDTOList.stream().collect(Collectors.toMap(GameDTO::getId, Function.identity()));
+    }
+
     /**
      * 根据主键id删除
      *

+ 100 - 13
game-module/game-manage/src/main/java/com/zanxiang/manage/service/Impl/OrderServiceImpl.java

@@ -6,8 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.zanxiang.common.utils.bean.BeanUtils;
-import com.zanxiang.manage.domain.dto.GameDTO;
-import com.zanxiang.manage.domain.dto.GameUserRoleDTO;
+import com.zanxiang.manage.domain.dto.*;
 import com.zanxiang.manage.domain.params.OrderParam;
 import com.zanxiang.manage.domain.params.UserOrderListParam;
 import com.zanxiang.manage.domain.vo.GameCategoryVO;
@@ -25,10 +24,8 @@ import org.springframework.stereotype.Service;
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * @author : lingfeng
@@ -51,6 +48,15 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
     @Autowired
     private PromoChannelService promoChannelService;
 
+    @Autowired
+    private CpService cpService;
+
+    @Autowired
+    private PromoAccountService promoAccountService;
+
+    @Autowired
+    private UserService userService;
+
     /**
      * 获取用户下单记录
      *
@@ -105,22 +111,23 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
     @Override
     public OrderListVO orderList(OrderParam param) {
         //渠道列表
-        List<Long> agentIdList;
+        List<Long> agentIds;
         if (param.getChannelId() == null) {
-            agentIdList = promoChannelService.listByAccountOrPitcherId(param.getAccountId(), param.getPitcherId());
+            agentIds = promoChannelService.listByAccountOrPitcherId(param.getAccountId(), param.getPitcherId());
         } else {
-            agentIdList = Collections.singletonList(param.getChannelId());
+            agentIds = Collections.singletonList(param.getChannelId());
         }
         //根据条件, 匹配渠道
-        if (agentIdList != null && agentIdList.isEmpty()) {
+        if (agentIds != null && agentIds.isEmpty()) {
             return new OrderListVO(param.toPage().getSize());
         }
-        IPage<OrderVO> page = page(param.toPage(), getListWrapper(param, agentIdList, "*")).convert(this::orderToVo);
+        IPage<OrderVO> page = page(param.toPage(), getListWrapper(param, agentIds, "*")).convert(this::orderToVo);
+
         if (page.getTotal() == 0) {
             return new OrderListVO(param.toPage().getSize());
         }
         //统计:订单金额与实付金额
-        Order total = super.getOne(getListWrapper(param, agentIdList, "IFNULL(SUM(amount),0) amount, IFNULL(SUM(real_amount),0) realAmount"));
+        Order total = super.getOne(getListWrapper(param, agentIds, "IFNULL(SUM(amount),0) amount, IFNULL(SUM(real_amount),0) realAmount"));
         HashMap<String, BigDecimal> totalData = new HashMap<>();
         if (total == null) {
             totalData.put("totalOrderAmount", new BigDecimal("0.00"));
@@ -129,15 +136,95 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             totalData.put("totalOrderAmount", total.getAmount());
             totalData.put("totalRealAmount", total.getRealAmount());
         }
+        //分页数据
+        List<OrderVO> orderListVOList = page.getRecords();
+        //cp信息
+        Map<Long, CpDTO> cpMap = cpService.cpMap();
+        //玩家信息
+        List<Long> userIdList = orderListVOList.stream().map(OrderVO::getUserId).collect(Collectors.toList());
+        Map<Long, UserDTO> userMap = userService.getByUserIds(userIdList);
+        //渠道信息
+        List<Long> agentIdList = orderListVOList.stream().map(OrderVO::getAgentId).collect(Collectors.toList());
+        Map<Long, PromoChannelDTO> channelMap = promoChannelService.promoChannelMap(agentIdList);
+        //推广账号信息
+        Map<Long, PromoAccountDTO> promoAccountMap = promoAccountService.promoAccountMap();
+        //游戏信息
+        List<Long> gameIds = orderListVOList.stream().map(OrderVO::getGameId).collect(Collectors.toList());
+        List<Long> regGameIds = orderListVOList.stream().map(OrderVO::getRegGameId).collect(Collectors.toList());
+        Set<Long> gameIdSet = new HashSet<>();
+        gameIdSet.addAll(gameIds);
+        gameIdSet.addAll(regGameIds);
+        Map<Long, GameDTO> gameMap = gameService.gameMap(gameIdSet);
+        //游戏分类信息
+        Map<Long, GameCategoryDTO> gameCategoryMap = gameCategoryService.gameCategoryMap();
+        //字段信息补充更新
+        orderListVOList.forEach(vo -> this.update(vo, userMap, channelMap, gameMap, gameCategoryMap, cpMap, promoAccountMap));
+        //设置返回
         OrderListVO orderListVO = new OrderListVO();
-        orderListVO.setTotal(page.getTotal());
         orderListVO.setSize(page.getSize());
+        orderListVO.setTotal(page.getTotal());
         orderListVO.setCurrent(page.getCurrent());
         orderListVO.setPages(page.getPages());
         orderListVO.setData(page.getRecords());
         orderListVO.setTotalData(totalData);
         return orderListVO;
+    }
 
+    private void update(OrderVO orderVO, Map<Long, UserDTO> userMap, Map<Long, PromoChannelDTO> channelMap, Map<Long, GameDTO> gameMap,
+                        Map<Long, GameCategoryDTO> gameCategoryMap, Map<Long, CpDTO> cpMap, Map<Long, PromoAccountDTO> promoAccountMap) {
+        orderVO.setDateTime(orderVO.getCreateTime().toLocalDate());
+        orderVO.setOrderId(orderVO.getId());
+        //用户信息补充
+        UserDTO userDTO = userMap.get(orderVO.getUserId());
+        if (userDTO != null) {
+            //注册渠道
+            PromoChannelDTO promoChannelDTO = channelMap.get(userDTO.getAgentId());
+            if (promoChannelDTO != null) {
+                orderVO.setRegAgentId(userDTO.getAgentId());
+                orderVO.setRegChannel(promoChannelDTO.getChannel());
+            }
+        }
+        //渠道信息补充
+        PromoChannelDTO promoChannelDTO = channelMap.get(orderVO.getAgentId());
+        if (promoChannelDTO != null) {
+            orderVO.setChannel(promoChannelDTO.getChannel());
+            PromoAccountDTO promoAccountDTO = promoAccountMap.get(promoChannelDTO.getAccountId());
+            if (promoAccountDTO != null) {
+                orderVO.setAccountName(promoAccountDTO.getName());
+                orderVO.setAccountId(promoAccountDTO.getId());
+                orderVO.setPitcherId(promoAccountDTO.getPitcherId());
+                orderVO.setPitcherName(promoAccountDTO.getPitcherName());
+                orderVO.setMediaId(promoAccountDTO.getMediaId());
+                orderVO.setMediaName(promoAccountDTO.getMediaName());
+            }
+        }
+        //注册游戏
+        GameDTO regGameDTO = gameMap.get(orderVO.getRegGameId());
+        if (regGameDTO != null) {
+            orderVO.setRegGameName(regGameDTO.getName());
+            //注册游戏应用类型
+            GameCategoryDTO gameCategoryDTO = gameCategoryMap.get(regGameDTO.getCategory());
+            if (gameCategoryDTO != null) {
+                orderVO.setRegGameCategoryId(gameCategoryDTO.getId());
+                orderVO.setRegGameCategoryName(gameCategoryDTO.getName());
+            }
+        }
+        //CP
+        CpDTO cpDTO = cpMap.get(orderVO.getCpId());
+        if (cpDTO != null) {
+            orderVO.setCpName(cpDTO.getCpName());
+        }
+        //充值游戏
+        GameDTO gameDTO = gameMap.get(orderVO.getGameId());
+        if (gameDTO != null) {
+            orderVO.setRegGameName(gameDTO.getName());
+            //注册游戏应用类型
+            GameCategoryDTO gameCategoryDTO = gameCategoryMap.get(gameDTO.getCategory());
+            if (gameCategoryDTO != null) {
+                orderVO.setGameCategoryId(gameCategoryDTO.getId());
+                orderVO.setGameCategory(gameCategoryDTO.getName());
+            }
+        }
     }
 
     private LambdaQueryWrapper<Order> getListWrapper(OrderParam param, List<Long> agentIdList, String select) {

+ 15 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/service/Impl/PromoChannelServiceImpl.java

@@ -61,6 +61,21 @@ public class PromoChannelServiceImpl extends ServiceImpl<PromoChannelMapper, Pro
         return promoChannelDTOList.stream().collect(Collectors.toMap(PromoChannelDTO::getId, Function.identity()));
     }
 
+    /**
+     * 注册渠道信息
+     *
+     * @return : 返回所有渠道信息
+     */
+    @Override
+    public Map<Long, PromoChannelDTO> promoChannelMap(List<Long> agentIdList) {
+        List<PromoChannel> promoChannelList = super.listByIds(agentIdList);
+        if (CollectionUtils.isEmpty(promoChannelList)) {
+            return Collections.emptyMap();
+        }
+        List<PromoChannelDTO> promoChannelDTOList = BeanUtils.copyList(promoChannelList, PromoChannelDTO.class);
+        return promoChannelDTOList.stream().collect(Collectors.toMap(PromoChannelDTO::getId, Function.identity()));
+    }
+
     /**
      * 通过帐户或投手id列表
      *

+ 21 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/service/Impl/UserServiceImpl.java

@@ -321,6 +321,27 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
         return list.stream().collect(Collectors.toMap(UserDTO::getId, Function.identity()));
     }
 
+    /**
+     * 通过用户id
+     *
+     * @param userIdList 用户id列表
+     * @return {@link Map}<{@link Long}, {@link UserDTO}>
+     */
+    @Override
+    public Map<Long, UserDTO> getByUserIds(List<Long> userIdList) {
+        if (CollectionUtils.isEmpty(userIdList)) {
+            return Collections.emptyMap();
+        }
+        //查询
+        List<User> userList = super.listByIds(userIdList);
+        if (CollectionUtils.isEmpty(userList)) {
+            return Collections.emptyMap();
+        }
+        List<UserDTO> list = BeanUtils.copyList(userList, UserDTO.class);
+        //构造返回
+        return list.stream().collect(Collectors.toMap(UserDTO::getId, Function.identity()));
+    }
+
     /**
      * 根据用户id查询信息
      *

+ 7 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/service/PromoChannelService.java

@@ -29,6 +29,13 @@ public interface PromoChannelService extends IService<PromoChannel> {
      */
     Map<Long, PromoChannelDTO> promoChannelMap();
 
+    /**
+     * 注册渠道信息
+     *
+     * @return : 返回所有渠道信息
+     */
+    Map<Long, PromoChannelDTO> promoChannelMap(List<Long> agentIdList);
+
     /**
      * 通过帐户或投手id列表
      *

+ 8 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/service/UserService.java

@@ -63,4 +63,12 @@ public interface UserService extends IService<User> {
      * @return : 返回用户信息
      */
     UserDTO getById(Long userId);
+
+    /**
+     * 通过用户id
+     *
+     * @param userIdList 用户id列表
+     * @return {@link Map}<{@link Long}, {@link UserDTO}>
+     */
+    Map<Long, UserDTO> getByUserIds(List<Long> userIdList);
 }