Commit af462e53 by 吕明尚

修改差异

parent e942d99d
......@@ -112,7 +112,7 @@ public class RoomStatusServiceImpl implements RoomStatusService {
queryWrapper.ge(SOrder::getEndDate, DateUtils.addMinutes(DateUtils.getNowDate(), -15));
SOrder one = orderService.getOne(queryWrapper);
if (ObjectUtils.isEmpty(one)) {
isAvailable = false;
isAvailable = true;
} else {
isAvailable = true;
}
......
......@@ -3098,4 +3098,146 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
return baseMapper.couponIds(sOrder);
}
@Override
public List<OrderVo> statisticsOrderList(OrderStatisticsRequest request) {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
if (!user.getRoleType().equals(RoleTypeEnum.CLEANER.getCode())) {
throw new RuntimeException("当前用户不是店员");
}
List<SOrder> orderList = baseMapper.selectList(new LambdaQueryWrapper<SOrder>()
.eq(SOrder::getStoreId, request.getStoreId())
.eq(SOrder::getIsDelete, YesNoEnum.no.getIndex())
.eq(SOrder::getPayStatus, YesNoEnum.yes.getIndex())
.ge(SOrder::getCreateTime, request.getStartTime())
.le(SOrder::getCreateTime, request.getEndTime())
.orderByDesc(SOrder::getCreateTime)
);
List<OrderVo> orderVoList = new ArrayList<>();
if (CollectionUtil.isEmpty(orderList)) {
return new ArrayList<>();
}
List<Long> longs = storeConsumerMapper.selectByConsumerId(user.getId(), PositionEnum.MANAGE.getCode());
if (CollectionUtils.isEmpty(longs)) {
throw new RuntimeException("当前用户不是门店管理人员");
}
//判断longs是否包含request.getStoreId()
if (!longs.contains(request.getStoreId())) {
throw new RuntimeException("当前用户不是该门店管理人员");
}
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()));
Map<Long, SConsumerCoupon> map = new HashMap<>();
//优惠券id集合,去掉为null的
List<Long> ids = orderList.stream().map(SOrder::getCouponId).filter(Objects::nonNull).collect(Collectors.toList());
List<Long> consumerIds = orderList.stream().map(SOrder::getConsumerId).filter(Objects::nonNull).collect(Collectors.toList());
Map<Long, SConsumer> consumerMap = sConsumerService.listByIds(consumerIds).stream().collect(Collectors.toMap(SConsumer::getId, Function.identity()));
if (CollectionUtil.isNotEmpty(ids)) {
map.putAll(consumerCouponService.selectByIds(ids).stream().collect(Collectors.toMap(SConsumerCoupon::getId, Function.identity())));
}
List<OrderVo> finalOrderVoList = orderVoList;
//计算开始时间和结束时间相差多少天
if (ObjectUtil.isNotEmpty(request.getStartTime()) && ObjectUtil.isNotEmpty(request.getEndTime())) {
long between = DateUtil.getTwoDateDays(request.getStartTime(), request.getEndTime());
//大于30天,截取结束时间减30天的订单
if (between > 30) {
Date date = DateUtil.addDay(request.getEndTime(), -30);
orderList = orderList.stream().filter(order -> order.getCreateTime().after(date)).collect(Collectors.toList());
}
}
orderList.stream().forEach(order -> {
OrderVo orderVo = new OrderVo();
SConsumer sConsumer = consumerMap.get(order.getConsumerId());
if (ObjectUtil.isNotEmpty(sConsumer)) {
orderVo.setNickName(sConsumer.getNickName());
orderVo.setAvatar(sConsumer.getAvatar());
}
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());
orderVo.setCouponPayPrice(BigDecimal.ZERO);
if (order.getStatus().equals(OrderStatusEnum.CANCEL.getCode()) && order.getRefundStatus().equals(RefundStatusEnum.REFUNDED.getCode())) {
if (!map.isEmpty()) {
if (ObjectUtil.isNotEmpty(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.getPlatformType().equals(PlatformTypeEnum.MEITUAN.getCode())) {
orderVo.setPlatformType(PlatformTypeEnum.MEITUAN.getCode());
if (sConsumerCoupon.getUseStatus().equals(UserStatusEnum.EXPIRED.getCode())) {
orderVo.setCouponPayPrice(BigDecimal.ZERO);
} else {
if (ObjectUtil.isNotEmpty(sConsumerCoupon.getCouponPayPrice())) {
orderVo.setCouponPayPrice(sConsumerCoupon.getCouponPayPrice());
} else {
SCoupon sCoupon = sCouponMap.get(sConsumerCoupon.getCouponId());
orderVo.setCouponPayPrice(sCoupon.getCouponPayPrice());
}
}
} else if (sConsumerCoupon.getPlatformType().equals(PlatformTypeEnum.TIKTOK.getCode())) {
orderVo.setPlatformType(PlatformTypeEnum.TIKTOK.getCode());
if (sConsumerCoupon.getUseStatus().equals(UserStatusEnum.EXPIRED.getCode())) {
orderVo.setCouponPayPrice(BigDecimal.ZERO);
} else {
if (ObjectUtil.isNotEmpty(sConsumerCoupon.getCouponPayPrice())) {
orderVo.setCouponPayPrice(sConsumerCoupon.getCouponPayPrice());
} else {
SCoupon sCoupon = sCouponMap.get(sConsumerCoupon.getCouponId());
orderVo.setCouponPayPrice(sCoupon.getCouponPayPrice());
}
}
}
}
}
}
}
if (!map.isEmpty()) {
if (ObjectUtil.isNotEmpty(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.getPlatformType().equals(PlatformTypeEnum.MEITUAN.getCode())) {
orderVo.setPlatformType(PlatformTypeEnum.MEITUAN.getCode());
if (sConsumerCoupon.getUseStatus().equals(UserStatusEnum.EXPIRED.getCode())) {
orderVo.setCouponPayPrice(BigDecimal.ZERO);
} else {
if (ObjectUtil.isNotEmpty(sConsumerCoupon.getCouponPayPrice())) {
orderVo.setCouponPayPrice(sConsumerCoupon.getCouponPayPrice());
} else {
SCoupon sCoupon = sCouponMap.get(sConsumerCoupon.getCouponId());
orderVo.setCouponPayPrice(sCoupon.getCouponPayPrice());
}
}
} else if (sConsumerCoupon.getPlatformType().equals(PlatformTypeEnum.TIKTOK.getCode())) {
orderVo.setPlatformType(PlatformTypeEnum.TIKTOK.getCode());
if (sConsumerCoupon.getUseStatus().equals(UserStatusEnum.EXPIRED.getCode())) {
orderVo.setCouponPayPrice(BigDecimal.ZERO);
} else {
if (ObjectUtil.isNotEmpty(sConsumerCoupon.getCouponPayPrice())) {
orderVo.setCouponPayPrice(sConsumerCoupon.getCouponPayPrice());
} else {
SCoupon sCoupon = sCouponMap.get(sConsumerCoupon.getCouponId());
orderVo.setCouponPayPrice(sCoupon.getCouponPayPrice());
}
}
}
}
}
}
finalOrderVoList.add(orderVo);
});
return orderVoList;
}
}
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