use of com.whoiszxl.entity.OrderItem in project shopzz by whoiszxl.
the class OrderServiceImpl method createOrderInfo.
/**
* 创建订单和订单条目信息
* @param memberDetailDTO 用户信息
* @param orderSubmitVo 提交的订单信息
* @return
*/
private OrderCreateInfo createOrderInfo(MemberDetailDTO memberDetailDTO, OrderSubmitVO orderSubmitVo) {
MemberDTO member = memberDetailDTO.getMember();
// 1. 生成订单号
long orderId = idWorker.nextId();
// 2. 创建订单和订单条目的基本信息
Order order = buildOrder(member, orderId, orderSubmitVo);
List<OrderItem> orderItems = buildOrderItems(orderId);
// 3. 价格计算
assert orderItems != null;
computePrice(order, orderItems);
OrderCreateInfo orderCreateInfo = new OrderCreateInfo();
orderCreateInfo.setOrder(order);
orderCreateInfo.setOrderItemList(orderItems);
orderCreateInfo.setFare(BigDecimal.ZERO);
orderCreateInfo.setPayPrice(order.getTotalAmount());
return orderCreateInfo;
}
use of com.whoiszxl.entity.OrderItem in project shopzz by whoiszxl.
the class OrderServiceImpl method createOrderInfo.
/**
* 创建订单和订单条目信息
* @param memberDetailDTO 用户信息
* @param orderSubmitVo 提交的订单信息
* @return
*/
private OrderCreateInfo createOrderInfo(MemberDetailDTO memberDetailDTO, OrderSubmitRequest orderSubmitVo) {
MemberDTO member = memberDetailDTO.getMember();
// 1. 生成订单号
long orderId = idWorker.nextId();
// 2. 创建订单和订单条目的基本信息
Order order = buildOrder(member, orderId, orderSubmitVo);
List<OrderItem> orderItems = buildOrderItems(orderId);
// 3. 价格计算,计算订单总额
computePrice(order, orderItems);
OrderCreateInfo orderCreateInfo = new OrderCreateInfo();
orderCreateInfo.setOrder(order);
orderCreateInfo.setOrderItemList(orderItems);
orderCreateInfo.setFare(BigDecimal.ZERO);
orderCreateInfo.setPayPrice(order.getTotalAmount());
return orderCreateInfo;
}
use of com.whoiszxl.entity.OrderItem in project shopzz by whoiszxl.
the class OrderServiceImpl method computePrice.
/**
* 价格计算
* @param order 订单信息
* @param orderItems 订单条目信息
*/
private void computePrice(Order order, List<OrderItem> orderItems) {
// 运费,促销,积分,优惠券 TODO
order.setTotalAmount(new BigDecimal("0"));
order.setFreightAmount(new BigDecimal("0"));
order.setPromotionAmount(new BigDecimal("0"));
order.setPointAmount(new BigDecimal("0"));
order.setCouponAmount(new BigDecimal("0"));
BigDecimal total = BigDecimal.ZERO;
for (OrderItem orderItem : orderItems) {
// TODO 暂用sku价格
orderItem.setRealAmount(orderItem.getSkuPrice().multiply(new BigDecimal(orderItem.getQuantity().toString())));
total = total.add(orderItem.getRealAmount());
}
order.setTotalAmount(total);
}
use of com.whoiszxl.entity.OrderItem in project shopzz by whoiszxl.
the class OrderServiceImpl method buildOrderItems.
private List<OrderItem> buildOrderItems(long orderId, String orderNo) {
// 获取当前选中的购物车item列表
CartDetailApiResponse cartDetail = cartService.getCartDetail();
List<CartItemVO> cartItemVOList = cartDetail.getCartItemVOList();
List<OrderItem> result = new ArrayList<>();
for (CartItemVO item : cartItemVOList) {
if (item.getChecked() == 1) {
OrderItem orderItem = buildOrderItem(item);
orderItem.setOrderId(orderId);
orderItem.setOrderNo(orderNo);
result.add(orderItem);
}
}
return result;
}
use of com.whoiszxl.entity.OrderItem in project shopzz by whoiszxl.
the class OrderServiceImpl method buildOrderItem.
/**
* 创建订单详情单个条目
* @param cartDTO 购物车条目
* @return 订单条目
*/
private OrderItem buildOrderItem(CartItemVO cartDTO) {
OrderItem orderItem = new OrderItem();
Long skuId = cartDTO.getSkuId();
// 配置sku信息
orderItem.setSkuId(skuId);
orderItem.setSkuName(cartDTO.getSkuName());
// TODO 设置sku属性
orderItem.setSkuAttrs("default");
orderItem.setSkuPic(cartDTO.getSkuPic());
orderItem.setSkuPrice(cartDTO.getPrice());
orderItem.setQuantity(cartDTO.getQuantity());
// 配置spu信息
orderItem.setProductId(cartDTO.getProductId());
// TODO
orderItem.setCategoryId(0L);
orderItem.setCreatedBy("member");
orderItem.setUpdatedBy("member");
return orderItem;
}
Aggregations