陶杰
2024-10-01 bf2bffc884f00fd2ed2f16667ab6b91328012b8a
src/main/java/com/mzl/flower/service/payment/OrderService.java
@@ -12,8 +12,10 @@
import com.mzl.flower.config.security.SecurityUtils;
import com.mzl.flower.constant.Constants;
import com.mzl.flower.dto.PriceDTO;
import com.mzl.flower.dto.request.comment.QueryFlowerCommentDTO;
import com.mzl.flower.dto.request.menber.MemberGrowthRecordDTO;
import com.mzl.flower.dto.request.payment.*;
import com.mzl.flower.dto.response.comment.FlowerCommentVO;
import com.mzl.flower.dto.response.coupon.CouponRecordVO;
import com.mzl.flower.dto.response.flower.FlowerCartListDTO;
import com.mzl.flower.dto.response.flower.FlowerCartListWrapDTO;
@@ -43,6 +45,7 @@
import com.mzl.flower.mapper.system.UserWechatMapper;
import com.mzl.flower.mapper.warehouse.WarehouseLocationMapper;
import com.mzl.flower.service.BaseService;
import com.mzl.flower.service.comment.FlowerCommentService;
import com.mzl.flower.service.coupon.CouponRecordService;
import com.mzl.flower.service.flower.FlowerService;
import com.mzl.flower.service.menber.MemberGrowthRecordService;
@@ -163,6 +166,9 @@
    @Autowired
    private CouponRecordService couponRecordService;
    @Autowired
    private FlowerCommentService flowerCommentService;
    public void changeFlower2Cart(CartSaveDTO dto) {
@@ -1135,6 +1141,7 @@
                new QueryWrapper<OrderItem>().eq("order_id", id));
        Map<Long, String> stationMap = prepareStationMap();
        Map<String, FlowerCommentVO> commentMap=prepareCommentMap(id);
        List<OrderItemListDTO> result = new ArrayList<>();
        for (OrderItem oi : ls) {
@@ -1143,12 +1150,37 @@
            dto.setStationName(stationMap.get(oi.getStationId()));
            // 评论
            final FlowerCommentVO flowerCommentVO = commentMap.get(oi.getId());
            copyCommentInfo(dto,flowerCommentVO);
            result.add(dto);
        }
        return result;
    }
    private Map<String, FlowerCommentVO> prepareCommentMap(String orderId) {
        QueryFlowerCommentDTO queryFlowerCommentDTO = new QueryFlowerCommentDTO();
        queryFlowerCommentDTO.setOrderId(orderId);
        final List<FlowerCommentVO> list = flowerCommentService.getList(queryFlowerCommentDTO);
        if (list == null || list.isEmpty()) {
            return Collections.emptyMap();
        }
        // 将 List 转换为 Map,其中 key 为 FlowerCommentVO 的 id
        return list.stream().collect(Collectors.toMap(FlowerCommentVO::getOrderItemId, item -> item));
    }
    private void copyCommentInfo(OrderItemListDTO dto,FlowerCommentVO flowerCommentVO){
        if(null != dto && null!=flowerCommentVO){
            dto.setCommentGrade(flowerCommentVO.getCommentGrade());
            dto.setComment(flowerCommentVO.getComment());
            dto.setCommentImages(flowerCommentVO.getCommentImages());
            dto.setAnonymityFalg(flowerCommentVO.getAnonymityFalg());
        }
    }
    public List<Order> autoReceive() {
        int days = -5; //5天前的订单自动收货
        LocalDateTime endTime = LocalDateTime.now().plusDays(days);