Search in sources :

Example 1 with OrderItem

use of com.whoiszxl.entity.OrderItem in project shopzz by whoiszxl.

the class OrderServiceImpl method buildOrderItem.

/**
 * 创建订单详情单个条目
 * @param cartDTO 购物车条目
 * @return 订单条目
 */
private OrderItem buildOrderItem(CartDTO cartDTO) {
    OrderItem orderItem = new OrderItem();
    Long skuId = cartDTO.getSkuId();
    // 配置sku信息
    orderItem.setSkuId(skuId);
    orderItem.setSkuName(cartDTO.getSkuName());
    orderItem.setSkuAttrs(cartDTO.getSaleAttr());
    orderItem.setSkuPic(cartDTO.getSkuPic());
    orderItem.setSkuPrice(cartDTO.getPrice());
    orderItem.setQuantity(cartDTO.getQuantity());
    // 配置spu信息
    orderItem.setProductId(cartDTO.getProductId());
    // TODO
    orderItem.setCategoryId(0L);
    return orderItem;
}
Also used : OrderItem(com.whoiszxl.entity.OrderItem)

Example 2 with OrderItem

use of com.whoiszxl.entity.OrderItem in project shopzz by whoiszxl.

the class OrderController method orderList.

@SaCheckLogin
@PostMapping("/list")
@ApiOperation(value = "获取当前用户的订单列表", notes = "获取当前用户的订单列表", response = String.class)
public ResponseResult<IPage<OrderVO>> orderList(@RequestBody OrderListQuery query) {
    long memberId = StpUtil.getLoginIdAsLong();
    LambdaQueryWrapper<Order> queryWrapper = new LambdaQueryWrapper<>();
    queryWrapper.eq(Order::getMemberId, memberId);
    if (query.getOrderStatus() != 0) {
        queryWrapper.eq(Order::getOrderStatus, query.getOrderStatus());
    }
    IPage<Order> orderList = orderService.page(new Page<>(query.getPage(), query.getSize()), queryWrapper);
    IPage<OrderVO> orderVOList = orderList.convert(order -> {
        OrderVO orderVO = dozerUtils.map(order, OrderVO.class);
        // 获取orderItem
        List<OrderItem> orderItemList = orderItemService.list(new LambdaQueryWrapper<OrderItem>().eq(OrderItem::getOrderId, orderVO.getId()));
        List<OrderItemVO> orderItemVOS = dozerUtils.mapList(orderItemList, OrderItemVO.class);
        orderVO.setOrderItemVOList(orderItemVOS);
        return orderVO;
    });
    return ResponseResult.buildSuccess(orderVOList);
}
Also used : Order(com.whoiszxl.entity.Order) OrderVO(com.whoiszxl.entity.vo.OrderVO) OrderItem(com.whoiszxl.entity.OrderItem) OrderItemVO(com.whoiszxl.entity.vo.OrderItemVO) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) SaCheckLogin(cn.dev33.satoken.annotation.SaCheckLogin) ApiOperation(io.swagger.annotations.ApiOperation)

Example 3 with OrderItem

use of com.whoiszxl.entity.OrderItem in project shopzz by whoiszxl.

the class OrderServiceImpl method buildOrderItems.

/**
 * 创建订单详情条目列表
 * @param orderId
 * @return
 */
private List<OrderItem> buildOrderItems(long orderId) {
    // 获取当前选中的购物车item列表
    CartDetailVO cartDetail = cartService.getCartDetail();
    List<CartItemVO> cartItemVOList = cartDetail.getCartItemVOList();
    if (ObjectUtils.isEmpty(cartItemVOList)) {
        ExceptionCatcher.catchValidateEx(ResponseResult.buildError("购物车不存在选中商品"));
    }
    List<OrderItem> result = new ArrayList<>();
    for (CartItemVO item : cartItemVOList) {
        if (item.getChecked() == 1) {
            OrderItem orderItem = buildOrderItem(item);
            orderItem.setOrderId(orderId);
            orderItem.setOrderSn(orderId + "");
            result.add(orderItem);
        }
    }
    return result;
}
Also used : CartDetailVO(com.whoiszxl.entity.vo.CartDetailVO) OrderItem(com.whoiszxl.entity.OrderItem) ArrayList(java.util.ArrayList) CartItemVO(com.whoiszxl.entity.vo.CartItemVO)

Example 4 with OrderItem

use of com.whoiszxl.entity.OrderItem in project shopzz by whoiszxl.

the class OrderServiceImpl method createOrderInfo.

/**
 * 创建订单和订单条目信息
 * @param orderSubmitCommand 提交的订单信息
 * @return
 */
private OrderCreateInfoDTO createOrderInfo(OrderSubmitCommand orderSubmitCommand) {
    // 1. 创建订单id和编号
    String orderNo = OrderUtils.makeOrderNo();
    long orderId = idWorker.nextId();
    // 2. 创建订单和订单条目的基本信息
    Order order = buildOrder(orderId, orderNo, orderSubmitCommand);
    List<OrderItem> orderItems = buildOrderItems(orderId, orderNo);
    // 3. 创建返回实体
    OrderCreateInfoDTO orderCreateInfoDTO = new OrderCreateInfoDTO();
    orderCreateInfoDTO.setOrder(order);
    orderCreateInfoDTO.setOrderItemList(orderItems);
    orderCreateInfoDTO.setFare(BigDecimal.ZERO);
    return orderCreateInfoDTO;
}
Also used : Order(com.whoiszxl.entity.Order) OrderCreateInfoDTO(com.whoiszxl.cqrs.dto.OrderCreateInfoDTO) OrderItem(com.whoiszxl.entity.OrderItem)

Example 5 with OrderItem

use of com.whoiszxl.entity.OrderItem in project shopzz by whoiszxl.

the class OrderServiceImpl method getOrderInfo.

@Override
public OrderInfoDTO getOrderInfo(Long orderId) {
    // 获取订单信息
    Order order = this.getById(orderId);
    // 获取订单条目信息
    List<OrderItem> orderItemList = orderItemService.list(new LambdaQueryWrapper<OrderItem>().eq(OrderItem::getOrderId, orderId));
    List<OrderItemDTO> orderItemDTOList = dozerUtils.mapList(orderItemList, OrderItemDTO.class);
    OrderInfoDTO orderInfoDTO = new OrderInfoDTO();
    orderInfoDTO.setOrderId(order.getId());
    orderInfoDTO.setMemberId(order.getMemberId());
    orderInfoDTO.setTotalAmount(order.getTotalAmount());
    orderInfoDTO.setOrderItemDTOList(orderItemDTOList);
    return orderInfoDTO;
}
Also used : Order(com.whoiszxl.entity.Order) OrderItem(com.whoiszxl.entity.OrderItem) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Aggregations

OrderItem (com.whoiszxl.entity.OrderItem)10 Order (com.whoiszxl.entity.Order)5 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)2 OrderCreateInfo (com.whoiszxl.entity.vo.OrderCreateInfo)2 ArrayList (java.util.ArrayList)2 SaCheckLogin (cn.dev33.satoken.annotation.SaCheckLogin)1 OrderCreateInfoDTO (com.whoiszxl.cqrs.dto.OrderCreateInfoDTO)1 CartDetailApiResponse (com.whoiszxl.cqrs.response.CartDetailApiResponse)1 CartItemVO (com.whoiszxl.cqrs.response.CartItemVO)1 CartDetailVO (com.whoiszxl.entity.vo.CartDetailVO)1 CartItemVO (com.whoiszxl.entity.vo.CartItemVO)1 OrderItemVO (com.whoiszxl.entity.vo.OrderItemVO)1 OrderVO (com.whoiszxl.entity.vo.OrderVO)1 ApiOperation (io.swagger.annotations.ApiOperation)1 BigDecimal (java.math.BigDecimal)1