Commit 09801629 by 吕明尚

优化订单导出

parent 8187d59e
...@@ -47,6 +47,7 @@ import share.system.service.*; ...@@ -47,6 +47,7 @@ import share.system.service.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -680,36 +681,37 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -680,36 +681,37 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
List<SOrder> sOrders = selectSOrderList(sOrder); List<SOrder> sOrders = selectSOrderList(sOrder);
List<SOrderVo> sOrderVos = convertDosToVos(sOrders); List<SOrderVo> sOrderVos = convertDosToVos(sOrders);
List<SaobeiApiLog> saobeiApiLogs = saobeiApiLogService.list(); List<SaobeiApiLog> saobeiApiLogs = saobeiApiLogService.list();
//list转HashMap
List<SConsumerCoupon> sConsumerCoupons = consumerCouponService.queryList(); List<SConsumerCoupon> sConsumerCoupons = consumerCouponService.queryList();
Map<Long, SConsumerCoupon> map = sConsumerCoupons.stream().collect(Collectors.toMap(SConsumerCoupon::getId, Function.identity()));
List<SCoupon> list = sCouponService.list(); List<SCoupon> list = sCouponService.list();
Map<Long, SCoupon> sCouponMap = list.stream().collect(Collectors.toMap(SCoupon::getId, Function.identity()));
if (CollectionUtils.isNotEmpty(sOrderVos)) { if (CollectionUtils.isNotEmpty(sOrderVos)) {
for (SOrderVo item : sOrderVos) { sOrderVos.stream().forEach(item -> {
sConsumerCoupons.stream().filter(sConsumerCoupon -> sConsumerCoupon.getId().equals(item.getCouponId())).findFirst().ifPresent(sConsumerCoupon -> { if (ObjectUtil.isNotEmpty(item.getCouponId())) {
item.setCouponPayPrice(sConsumerCoupon.getCouponPayPrice()); SConsumerCoupon sConsumerCoupon = map.get(item.getCouponId());
item.setPlatformType(sConsumerCoupon.getPlatformType()); if (ObjectUtil.isNotEmpty(sConsumerCoupon)) {
if (sConsumerCoupon.getPlatformType().equals(PlatformTypeEnum.MEITUAN.getCode())) { item.setCouponPayPrice(sConsumerCoupon.getCouponPayPrice());
if (!ObjectUtils.isEmpty(sConsumerCoupon.getDealgroupId())) { item.setPlatformType(sConsumerCoupon.getPlatformType());
item.setCouponSkuId(String.valueOf(sConsumerCoupon.getDealgroupId())); if (sConsumerCoupon.getPlatformType().equals(PlatformTypeEnum.MEITUAN.getCode())) {
} else { if (!ObjectUtils.isEmpty(sConsumerCoupon.getDealgroupId())) {
list.stream().filter(sCoupon -> sCoupon.getId().equals(sConsumerCoupon.getCouponId())).findFirst().ifPresent(sConsumer -> { item.setCouponSkuId(String.valueOf(sConsumerCoupon.getDealgroupId()));
item.setCouponSkuId(String.valueOf(sConsumer.getDealgroupId())); } else {
}); item.setCouponSkuId(String.valueOf(sCouponMap.get(sConsumerCoupon.getCouponId()).getDealgroupId()));
} }
} else if (sConsumerCoupon.getPlatformType().equals(PlatformTypeEnum.TIKTOK.getCode())) { } else if (sConsumerCoupon.getPlatformType().equals(PlatformTypeEnum.TIKTOK.getCode())) {
if (!ObjectUtils.isEmpty(sConsumerCoupon.getTiktokSkuId())) { if (!ObjectUtils.isEmpty(sConsumerCoupon.getTiktokSkuId())) {
item.setCouponSkuId(sConsumerCoupon.getTiktokSkuId()); item.setCouponSkuId(sConsumerCoupon.getTiktokSkuId());
} else { } else {
list.stream().filter(sCoupon -> sCoupon.getId().equals(sConsumerCoupon.getCouponId())).findFirst().ifPresent(sConsumer -> { item.setCouponSkuId(sCouponMap.get(sConsumerCoupon.getCouponId()).getTiktokSkuId());
item.setCouponSkuId(sConsumer.getTiktokSkuId()); }
});
} }
} }
}); }
if (StringUtils.isNoneEmpty(item.getOutTradeNo())) { 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()); sOrderVos.sort(Comparator.comparing(SOrderVo::getCreateTime).reversed());
return sOrderVos; 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