|
@@ -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) {
|