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;
}
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);
}
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;
}
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;
}
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;
}
Aggregations