Commit e916c699 by 吕明尚

修改数据统计

parent 5b287dad
...@@ -94,6 +94,9 @@ public class OrderVo { ...@@ -94,6 +94,9 @@ public class OrderVo {
private String packName; private String packName;
//优惠卷名称 //优惠卷名称
private String couponName; private String couponName;
private String couponCode;
private Integer platformType;
private BigDecimal couponPayPrice;
//订单状态 //订单状态
private Integer orderType; private Integer orderType;
......
...@@ -2,6 +2,7 @@ package share.system.response; ...@@ -2,6 +2,7 @@ package share.system.response;
import lombok.Data; import lombok.Data;
import share.system.domain.SOrder; import share.system.domain.SOrder;
import share.system.domain.vo.OrderVo;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List; import java.util.List;
...@@ -50,5 +51,6 @@ public class OrderStatisticsResponse { ...@@ -50,5 +51,6 @@ public class OrderStatisticsResponse {
private BigDecimal integralRefundFee = BigDecimal.ZERO; private BigDecimal integralRefundFee = BigDecimal.ZERO;
//订单集合 //订单集合
private List<SOrder> orderList; private List<SOrder> orderList;
private List<OrderVo> orderVoList;
} }
...@@ -2907,6 +2907,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2907,6 +2907,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
@Override @Override
public OrderStatisticsResponse statistics(OrderStatisticsRequest request) { public OrderStatisticsResponse statistics(OrderStatisticsRequest request) {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry(); SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
List<OrderVo> orderVoList = new ArrayList<>();
if (!user.getRoleType().equals(RoleTypeEnum.CLEANER.getCode())) { if (!user.getRoleType().equals(RoleTypeEnum.CLEANER.getCode())) {
throw new RuntimeException("当前用户不是店员"); throw new RuntimeException("当前用户不是店员");
} }
...@@ -2924,6 +2925,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2924,6 +2925,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
.eq(Recharge::getStatus, YesNoEnum.yes.getIndex()) .eq(Recharge::getStatus, YesNoEnum.yes.getIndex())
); );
Map<Long, SCoupon> sCouponMap = sCouponService.list().stream().collect(Collectors.toMap(SCoupon::getId, Function.identity())); Map<Long, SCoupon> sCouponMap = sCouponService.list().stream().collect(Collectors.toMap(SCoupon::getId, Function.identity()));
Map<Long, SStore> sStoreMap = storeService.list().stream().collect(Collectors.toMap(SStore::getId, Function.identity()));
Map<Long, SRoom> sRoomMap = roomService.list().stream().collect(Collectors.toMap(SRoom::getId, Function.identity()));
BigDecimal rechargeAmount = rechargeList.stream().map(Recharge::getRechargeAmount).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal rechargeAmount = rechargeList.stream().map(Recharge::getRechargeAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
OrderStatisticsResponse statisticsResponse = new OrderStatisticsResponse(); OrderStatisticsResponse statisticsResponse = new OrderStatisticsResponse();
Map<Long, SConsumerCoupon> map = new HashMap<>(); Map<Long, SConsumerCoupon> map = new HashMap<>();
...@@ -2940,7 +2943,16 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2940,7 +2943,16 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
if (CollectionUtil.isNotEmpty(ids)) { if (CollectionUtil.isNotEmpty(ids)) {
map.putAll(consumerCouponService.selectByIds(ids).stream().collect(Collectors.toMap(SConsumerCoupon::getId, Function.identity()))); map.putAll(consumerCouponService.selectByIds(ids).stream().collect(Collectors.toMap(SConsumerCoupon::getId, Function.identity())));
} }
List<OrderVo> finalOrderVoList = orderVoList;
orderList.stream().forEach(order -> { orderList.stream().forEach(order -> {
OrderVo orderVo = new OrderVo();
BeanUtils.copyProperties(order, orderVo);
orderVo.setOrderNo(order.getOrderNo());
orderVo.setPayType(order.getPayType());
orderVo.setOrderType(order.getOrderType());
orderVo.setStoreName(sStoreMap.get(order.getStoreId()).getName());
orderVo.setRoomName(sRoomMap.get(order.getRoomId()).getName());
orderVo.setCreateTime(order.getCreateTime());
if (order.getStatus().equals(OrderStatusEnum.CANCEL.getCode()) && order.getRefundStatus().equals(RefundStatusEnum.REFUNDED.getCode())) { if (order.getStatus().equals(OrderStatusEnum.CANCEL.getCode()) && order.getRefundStatus().equals(RefundStatusEnum.REFUNDED.getCode())) {
if (!map.isEmpty()) { if (!map.isEmpty()) {
if (ObjectUtil.isNotEmpty(order.getCouponId())) { if (ObjectUtil.isNotEmpty(order.getCouponId())) {
...@@ -2948,19 +2960,26 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2948,19 +2960,26 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
if (ObjectUtil.isEmpty(sConsumerCoupon)) { if (ObjectUtil.isEmpty(sConsumerCoupon)) {
return; return;
} }
orderVo.setCouponCode(sConsumerCoupon.getCouponCode());
if (sConsumerCoupon.getCouponType().equals(CouponTypeEnum.CASH.getCode())) { if (sConsumerCoupon.getCouponType().equals(CouponTypeEnum.CASH.getCode())) {
if (sConsumerCoupon.getPlatformType().equals(PlatformTypeEnum.MEITUAN.getCode())) { if (sConsumerCoupon.getPlatformType().equals(PlatformTypeEnum.MEITUAN.getCode())) {
orderVo.setPlatformType(PlatformTypeEnum.MEITUAN.getCode());
if (ObjectUtil.isNotEmpty(sConsumerCoupon.getCouponPayPrice())) { if (ObjectUtil.isNotEmpty(sConsumerCoupon.getCouponPayPrice())) {
orderVo.setCouponPayPrice(sConsumerCoupon.getCouponPayPrice());
statisticsResponse.setMeituanRefundFee(statisticsResponse.getMeituanRefundFee().add(sConsumerCoupon.getCouponPayPrice())); statisticsResponse.setMeituanRefundFee(statisticsResponse.getMeituanRefundFee().add(sConsumerCoupon.getCouponPayPrice()));
} else { } else {
SCoupon sCoupon = sCouponMap.get(sConsumerCoupon.getCouponId()); SCoupon sCoupon = sCouponMap.get(sConsumerCoupon.getCouponId());
orderVo.setCouponPayPrice(sCoupon.getCouponPayPrice());
statisticsResponse.setMeituanRefundFee(statisticsResponse.getMeituanRefundFee().add(sCoupon.getCouponPayPrice())); statisticsResponse.setMeituanRefundFee(statisticsResponse.getMeituanRefundFee().add(sCoupon.getCouponPayPrice()));
} }
} else if (sConsumerCoupon.getPlatformType().equals(PlatformTypeEnum.TIKTOK.getCode())) { } else if (sConsumerCoupon.getPlatformType().equals(PlatformTypeEnum.TIKTOK.getCode())) {
orderVo.setPlatformType(PlatformTypeEnum.TIKTOK.getCode());
if (ObjectUtil.isNotEmpty(sConsumerCoupon.getCouponPayPrice())) { if (ObjectUtil.isNotEmpty(sConsumerCoupon.getCouponPayPrice())) {
orderVo.setCouponPayPrice(sConsumerCoupon.getCouponPayPrice());
statisticsResponse.setDouyinRefundFee(statisticsResponse.getDouyinRefundFee().add(sConsumerCoupon.getCouponPayPrice())); statisticsResponse.setDouyinRefundFee(statisticsResponse.getDouyinRefundFee().add(sConsumerCoupon.getCouponPayPrice()));
} else { } else {
SCoupon sCoupon = sCouponMap.get(sConsumerCoupon.getCouponId()); SCoupon sCoupon = sCouponMap.get(sConsumerCoupon.getCouponId());
orderVo.setCouponPayPrice(sCoupon.getCouponPayPrice());
statisticsResponse.setDouyinRefundFee(statisticsResponse.getDouyinRefundFee().add(sCoupon.getCouponPayPrice())); statisticsResponse.setDouyinRefundFee(statisticsResponse.getDouyinRefundFee().add(sCoupon.getCouponPayPrice()));
} }
} }
...@@ -2975,19 +2994,29 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2975,19 +2994,29 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
if (!map.isEmpty()) { if (!map.isEmpty()) {
if (ObjectUtil.isNotEmpty(order.getCouponId())) { if (ObjectUtil.isNotEmpty(order.getCouponId())) {
SConsumerCoupon sConsumerCoupon = map.get(order.getCouponId()); SConsumerCoupon sConsumerCoupon = map.get(order.getCouponId());
if (ObjectUtil.isEmpty(sConsumerCoupon)) {
return;
}
orderVo.setCouponCode(sConsumerCoupon.getCouponCode());
if (sConsumerCoupon.getCouponType().equals(CouponTypeEnum.CASH.getCode())) { if (sConsumerCoupon.getCouponType().equals(CouponTypeEnum.CASH.getCode())) {
if (sConsumerCoupon.getPlatformType().equals(PlatformTypeEnum.MEITUAN.getCode())) { if (sConsumerCoupon.getPlatformType().equals(PlatformTypeEnum.MEITUAN.getCode())) {
orderVo.setPlatformType(PlatformTypeEnum.MEITUAN.getCode());
if (ObjectUtil.isNotEmpty(sConsumerCoupon.getCouponPayPrice())) { if (ObjectUtil.isNotEmpty(sConsumerCoupon.getCouponPayPrice())) {
orderVo.setCouponPayPrice(sConsumerCoupon.getCouponPayPrice());
statisticsResponse.setMeituanFee(statisticsResponse.getMeituanFee().add(sConsumerCoupon.getCouponPayPrice())); statisticsResponse.setMeituanFee(statisticsResponse.getMeituanFee().add(sConsumerCoupon.getCouponPayPrice()));
} else { } else {
SCoupon sCoupon = sCouponMap.get(sConsumerCoupon.getCouponId()); SCoupon sCoupon = sCouponMap.get(sConsumerCoupon.getCouponId());
orderVo.setCouponPayPrice(sCoupon.getCouponPayPrice());
statisticsResponse.setMeituanFee(statisticsResponse.getMeituanFee().add(sCoupon.getCouponPayPrice())); statisticsResponse.setMeituanFee(statisticsResponse.getMeituanFee().add(sCoupon.getCouponPayPrice()));
} }
} else if (sConsumerCoupon.getPlatformType().equals(PlatformTypeEnum.TIKTOK.getCode())) { } else if (sConsumerCoupon.getPlatformType().equals(PlatformTypeEnum.TIKTOK.getCode())) {
orderVo.setPlatformType(PlatformTypeEnum.TIKTOK.getCode());
if (ObjectUtil.isNotEmpty(sConsumerCoupon.getCouponPayPrice())) { if (ObjectUtil.isNotEmpty(sConsumerCoupon.getCouponPayPrice())) {
orderVo.setCouponPayPrice(sConsumerCoupon.getCouponPayPrice());
statisticsResponse.setDouyinFee(statisticsResponse.getDouyinFee().add(sConsumerCoupon.getCouponPayPrice())); statisticsResponse.setDouyinFee(statisticsResponse.getDouyinFee().add(sConsumerCoupon.getCouponPayPrice()));
} else { } else {
SCoupon sCoupon = sCouponMap.get(sConsumerCoupon.getCouponId()); SCoupon sCoupon = sCouponMap.get(sConsumerCoupon.getCouponId());
orderVo.setCouponPayPrice(sCoupon.getCouponPayPrice());
statisticsResponse.setDouyinFee(statisticsResponse.getDouyinFee().add(sCoupon.getCouponPayPrice())); statisticsResponse.setDouyinFee(statisticsResponse.getDouyinFee().add(sCoupon.getCouponPayPrice()));
} }
} }
...@@ -2995,6 +3024,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2995,6 +3024,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
} }
} }
} }
finalOrderVoList.add(orderVo);
}); });
//用户充值 //用户充值
statisticsResponse.setRechargeFee(rechargeAmount); statisticsResponse.setRechargeFee(rechargeAmount);
...@@ -3010,7 +3040,20 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -3010,7 +3040,20 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
statisticsResponse.setTotalFee(statisticsResponse.getGroupFee().add(statisticsResponse.getPlatformFee())); statisticsResponse.setTotalFee(statisticsResponse.getGroupFee().add(statisticsResponse.getPlatformFee()));
//门店交易-门店交易退款 //门店交易-门店交易退款
statisticsResponse.setActualFee(statisticsResponse.getStoreFee().subtract(statisticsResponse.getStoreRefundFee())); statisticsResponse.setActualFee(statisticsResponse.getStoreFee().subtract(statisticsResponse.getStoreRefundFee()));
statisticsResponse.setOrderList(orderList); //计算开始时间和结束时间相差多少天
if (ObjectUtil.isNotEmpty(request.getStartTime()) && ObjectUtil.isNotEmpty(request.getEndTime())) {
long between = DateUtil.getTwoDateDays(request.getStartTime(), request.getEndTime());
// ChronoUnit.DAYS.between((Temporal) request.getStartTime(), (Temporal) request.getEndTime());
//大于30天,截取结束时间减30天的订单
if (between > 30) {
Date date = DateUtil.addDay(request.getEndTime(), -30);
//截取orderList创建时间在结束时间和结束时间减30天的数据
// orderList = orderList.stream().filter(order -> order.getCreateTime().after(date)).collect(Collectors.toList());
orderVoList = orderVoList.stream().filter(order -> order.getCreateTime().after(date)).collect(Collectors.toList());
}
}
statisticsResponse.setOrderVoList(orderVoList);
// statisticsResponse.setOrderList(orderList);
return statisticsResponse; return statisticsResponse;
} }
......
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