Commit 09801629 by 吕明尚

优化订单导出

parent 8187d59e
......@@ -47,6 +47,7 @@ import share.system.service.*;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
......@@ -680,36 +681,37 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
List<SOrder> sOrders = selectSOrderList(sOrder);
List<SOrderVo> sOrderVos = convertDosToVos(sOrders);
List<SaobeiApiLog> saobeiApiLogs = saobeiApiLogService.list();
//list转HashMap
List<SConsumerCoupon> sConsumerCoupons = consumerCouponService.queryList();
Map<Long, SConsumerCoupon> map = sConsumerCoupons.stream().collect(Collectors.toMap(SConsumerCoupon::getId, Function.identity()));
List<SCoupon> list = sCouponService.list();
Map<Long, SCoupon> sCouponMap = list.stream().collect(Collectors.toMap(SCoupon::getId, Function.identity()));
if (CollectionUtils.isNotEmpty(sOrderVos)) {
for (SOrderVo item : sOrderVos) {
sConsumerCoupons.stream().filter(sConsumerCoupon -> sConsumerCoupon.getId().equals(item.getCouponId())).findFirst().ifPresent(sConsumerCoupon -> {
item.setCouponPayPrice(sConsumerCoupon.getCouponPayPrice());
item.setPlatformType(sConsumerCoupon.getPlatformType());
if (sConsumerCoupon.getPlatformType().equals(PlatformTypeEnum.MEITUAN.getCode())) {
if (!ObjectUtils.isEmpty(sConsumerCoupon.getDealgroupId())) {
item.setCouponSkuId(String.valueOf(sConsumerCoupon.getDealgroupId()));
} else {
list.stream().filter(sCoupon -> sCoupon.getId().equals(sConsumerCoupon.getCouponId())).findFirst().ifPresent(sConsumer -> {
item.setCouponSkuId(String.valueOf(sConsumer.getDealgroupId()));
});
}
} else if (sConsumerCoupon.getPlatformType().equals(PlatformTypeEnum.TIKTOK.getCode())) {
if (!ObjectUtils.isEmpty(sConsumerCoupon.getTiktokSkuId())) {
item.setCouponSkuId(sConsumerCoupon.getTiktokSkuId());
} else {
list.stream().filter(sCoupon -> sCoupon.getId().equals(sConsumerCoupon.getCouponId())).findFirst().ifPresent(sConsumer -> {
item.setCouponSkuId(sConsumer.getTiktokSkuId());
});
sOrderVos.stream().forEach(item -> {
if (ObjectUtil.isNotEmpty(item.getCouponId())) {
SConsumerCoupon sConsumerCoupon = map.get(item.getCouponId());
if (ObjectUtil.isNotEmpty(sConsumerCoupon)) {
item.setCouponPayPrice(sConsumerCoupon.getCouponPayPrice());
item.setPlatformType(sConsumerCoupon.getPlatformType());
if (sConsumerCoupon.getPlatformType().equals(PlatformTypeEnum.MEITUAN.getCode())) {
if (!ObjectUtils.isEmpty(sConsumerCoupon.getDealgroupId())) {
item.setCouponSkuId(String.valueOf(sConsumerCoupon.getDealgroupId()));
} else {
item.setCouponSkuId(String.valueOf(sCouponMap.get(sConsumerCoupon.getCouponId()).getDealgroupId()));
}
} else if (sConsumerCoupon.getPlatformType().equals(PlatformTypeEnum.TIKTOK.getCode())) {
if (!ObjectUtils.isEmpty(sConsumerCoupon.getTiktokSkuId())) {
item.setCouponSkuId(sConsumerCoupon.getTiktokSkuId());
} else {
item.setCouponSkuId(sCouponMap.get(sConsumerCoupon.getCouponId()).getTiktokSkuId());
}
}
}
});
}
if (StringUtils.isNoneEmpty(item.getOutTradeNo())) {
item.setOutTradeNo(saobeiApiLogs.stream().filter(s -> s.getTerminalTrace().equals(item.getOutTradeNo())).findFirst().orElse(null).getOutTradeNo());
item.setOutTradeNo(saobeiApiLogs.stream().filter(saobeiApiLog -> saobeiApiLog.getTerminalTrace().equals(item.getOutTradeNo())).findFirst().orElse(null).getOutTradeNo());
}
}
});
}
sOrderVos.sort(Comparator.comparing(SOrderVo::getCreateTime).reversed());
return sOrderVos;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment