| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | @Autowired |
| | | private CouponRecordService couponRecordService; |
| | | |
| | | @Autowired |
| | | private FlowerCommentService flowerCommentService; |
| | | |
| | | |
| | | public void changeFlower2Cart(CartSaveDTO dto) { |
| | | String userId = SecurityUtils.getUserId(); |
| | |
| | | Integer completeNumToday=getFlowerCompleteNumToday(userId,c.getFlowerId()); |
| | | Integer tmp=completeNumToday+c.getNum(); |
| | | if(null!=tmp && null!=flowerDetail.getLimited() |
| | | && tmp.compareTo(flowerDetail.getLimited())>0){ |
| | | && tmp.compareTo(flowerDetail.getLimited())>0){ |
| | | throw new ValidationException("当天的订单的花数量加上购物车的数量不能超过限售数量!"); |
| | | } |
| | | |
| | |
| | | |
| | | // 限购 1.首先查看购物车中的数量是否已经超过限售数量 |
| | | if(null!=c.getNum() && null!=flowerDetail.getLimited() |
| | | && c.getNum().compareTo(flowerDetail.getLimited())>0){ |
| | | && c.getNum().compareTo(flowerDetail.getLimited())>0){ |
| | | throw new ValidationException("数量不能超过限售数量!"); |
| | | } |
| | | |
| | |
| | | Integer completeNumToday=getFlowerCompleteNumToday(userId,c.getFlowerId()); |
| | | Integer tmp=completeNumToday+c.getNum(); |
| | | if(null!=tmp && null!=flowerDetail.getLimited() |
| | | && tmp.compareTo(flowerDetail.getLimited())>0){ |
| | | && tmp.compareTo(flowerDetail.getLimited())>0){ |
| | | throw new ValidationException("当天的订单的花数量加上购物车的数量不能超过限售数量!"); |
| | | } |
| | | |
| | |
| | | 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) { |
| | |
| | | |
| | | 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() { |
| | |
| | | // 新增 |
| | | cartMapper.updateById(cart); |
| | | }else{ |
| | | // 更新 |
| | | // 更新 |
| | | cartMapper.insert(cart); |
| | | } |
| | | } |