|
@@ -0,0 +1,132 @@
|
|
|
+package com.zanxiang.manage.service.Impl;
|
|
|
+
|
|
|
+import com.alibaba.nacos.common.utils.CollectionUtils;
|
|
|
+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.zanxiang.common.utils.StringUtils;
|
|
|
+import com.zanxiang.common.utils.bean.BeanUtils;
|
|
|
+import com.zanxiang.manage.domain.params.OrderCompleteParam;
|
|
|
+import com.zanxiang.manage.domain.vo.OrderCompleteListVO;
|
|
|
+import com.zanxiang.manage.domain.vo.OrderCompleteVO;
|
|
|
+import com.zanxiang.manage.service.CpService;
|
|
|
+import com.zanxiang.manage.service.OrderCompleteService;
|
|
|
+import com.zanxiang.mybatis.entity.Cp;
|
|
|
+import com.zanxiang.mybatis.entity.OrderComplete;
|
|
|
+import com.zanxiang.mybatis.entity.User;
|
|
|
+import com.zanxiang.mybatis.entity.UserExt;
|
|
|
+import com.zanxiang.mybatis.mapper.OrderCompleteMapper;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import org.apache.logging.log4j.util.Strings;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.LocalTime;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 游戏订单全量宽表 服务实现类
|
|
|
+ *
|
|
|
+ * @author xufeng
|
|
|
+ * @date 2022-07-04 11:45
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class OrderCompleteServiceImpl extends ServiceImpl<OrderCompleteMapper, OrderComplete> implements OrderCompleteService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CpService cpService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public OrderCompleteListVO list(OrderCompleteParam param) {
|
|
|
+
|
|
|
+ IPage<OrderCompleteVO> page = page(param.toPage(), getListWrapper(param, "*")).convert(this::toVo);
|
|
|
+ if (page.getTotal() == 0) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ //统计:订单金额与实付金额
|
|
|
+ OrderComplete total = super.getOne(getListWrapper(param, "IFNULL(SUM(order_amount),0) orderAmount, IFNULL(SUM(real_amount),0) realAmount"));
|
|
|
+ HashMap<String, BigDecimal> totalData = new HashMap<>();
|
|
|
+ if (total == null) {
|
|
|
+ totalData.put("totalOrderAmount", new BigDecimal("0.00"));
|
|
|
+ totalData.put("totalRealAmount", new BigDecimal("0.00"));
|
|
|
+ } else {
|
|
|
+ totalData.put("totalOrderAmount", total.getOrderAmount());
|
|
|
+ totalData.put("totalRealAmount", total.getRealAmount());
|
|
|
+ }
|
|
|
+
|
|
|
+ //批量获取cp信息
|
|
|
+ Map<Long, String> cpMap = null;
|
|
|
+ List<Long> cpIdList = page.getRecords().stream().filter(t -> t.getCpId() != null).map(t -> t.getCpId()).collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isNotEmpty(cpIdList)) {
|
|
|
+ List<Cp> cpList = cpService.list(new QueryWrapper<Cp>().lambda().in(Cp::getId, cpIdList));
|
|
|
+ if (CollectionUtils.isNotEmpty(cpList)) {
|
|
|
+ cpMap = cpList.stream().collect(Collectors.toMap(Cp::getId, Cp::getCpName));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Map<Long, String> finalCpMap = cpMap;
|
|
|
+ page.getRecords().stream().forEach(t -> {
|
|
|
+ t.setId(t.getOrderId());
|
|
|
+ if (finalCpMap != null) {
|
|
|
+ if (StringUtils.isNotEmpty(finalCpMap.get(t.getCpId()))) {
|
|
|
+ t.setCpName(finalCpMap.get(t.getCpId()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ OrderCompleteListVO orderCompleteListVO = new OrderCompleteListVO();
|
|
|
+ orderCompleteListVO.setTotal(page.getTotal());
|
|
|
+ orderCompleteListVO.setSize(page.getSize());
|
|
|
+ orderCompleteListVO.setCurrent(page.getCurrent());
|
|
|
+ orderCompleteListVO.setPages(page.getPages());
|
|
|
+ orderCompleteListVO.setData(page.getRecords());
|
|
|
+ orderCompleteListVO.setTotalData(totalData);
|
|
|
+ return orderCompleteListVO;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private LambdaQueryWrapper<OrderComplete> getListWrapper(OrderCompleteParam param, String select) {
|
|
|
+ LambdaQueryWrapper<OrderComplete> wrapper = new QueryWrapper<OrderComplete>().select(select).lambda()
|
|
|
+ .like(Strings.isNotBlank(param.getCpOrderId()), OrderComplete::getCpOrderId, param.getCpOrderId())
|
|
|
+ .like(Strings.isNotBlank(param.getOrderId()), OrderComplete::getOrderId, param.getOrderId())
|
|
|
+ .like(Strings.isNotBlank(param.getCpOrderId()), OrderComplete::getCpOrderId, param.getCpOrderId())
|
|
|
+ .like(Strings.isNotBlank(param.getUserId()), OrderComplete::getUserId, param.getUserId())
|
|
|
+ .like(Strings.isNotBlank(param.getUserAccount()), OrderComplete::getUserAccount, param.getUserAccount())
|
|
|
+ .like(Strings.isNotBlank(param.getGameRole()), OrderComplete::getGameRole, param.getGameRole())
|
|
|
+ .like(Strings.isNotBlank(param.getCpId()), OrderComplete::getCpId, param.getCpId())
|
|
|
+ .like(Strings.isNotBlank(param.getUserRegisterGameId()), OrderComplete::getUserRegisterGameId, param.getUserRegisterGameId())
|
|
|
+ .like(Strings.isNotBlank(param.getUserRegisterGame()), OrderComplete::getUserRegisterGame, param.getUserRegisterGame())
|
|
|
+ .like(Strings.isNotBlank(param.getGameId()), OrderComplete::getGameId, param.getGameId())
|
|
|
+ .ge(param.getUserRegisterTimeStart() != null, OrderComplete::getUserRegisterTime, param.getUserRegisterTimeStart() == null ? null : LocalDateTime.of(param.getUserRegisterTimeStart(), LocalTime.MIN))
|
|
|
+ .le(param.getUserRegisterTimeEnd() != null, OrderComplete::getUserRegisterTime, param.getUserRegisterTimeEnd() == null ? null : LocalDateTime.of(param.getUserRegisterTimeEnd(), LocalTime.MAX))
|
|
|
+ .like(Strings.isNotBlank(param.getAgentAccount()), OrderComplete::getAgentAccount, param.getAgentAccount())
|
|
|
+ .like(Strings.isNotBlank(param.getAgentId()), OrderComplete::getAgentId, param.getAgentId())
|
|
|
+ .eq(Strings.isNotBlank(param.getFromDevice()), OrderComplete::getFromDevice, param.getFromDevice())
|
|
|
+ .eq(param.getIsSwitch() != null, OrderComplete::getIsSwitch, param.getIsSwitch())
|
|
|
+ .like(Strings.isNotBlank(param.getProductName()), OrderComplete::getProductName, param.getProductName())
|
|
|
+ .like(Strings.isNotBlank(param.getPayWayId()), OrderComplete::getPayWayId, param.getPayWayId())
|
|
|
+ .eq(Strings.isNotBlank(param.getMerchantNo()), OrderComplete::getMerchantNo, param.getMerchantNo())
|
|
|
+ .eq(param.getStatus() != null, OrderComplete::getStatus, param.getStatus())
|
|
|
+ .eq(param.getCpStatus() != null, OrderComplete::getCpStatus, param.getCpStatus())
|
|
|
+ .eq(param.getIsFirstRecharge() != null, OrderComplete::getIsFirstRecharge, param.getIsFirstRecharge())
|
|
|
+ .orderByDesc(OrderComplete::getOrderId);
|
|
|
+ return wrapper;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private OrderCompleteVO toVo(OrderComplete orderComplete) {
|
|
|
+ if (Objects.isNull(orderComplete)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return BeanUtils.copy(orderComplete, OrderCompleteVO.class);
|
|
|
+ }
|
|
|
+}
|