use of com.paascloud.provider.model.domain.OmcOrderDetail in project paascloud-master by paascloud.
the class OmcOrderServiceImpl method getOrderDetail.
@Override
public OrderVo getOrderDetail(Long userId, String orderNo) {
logger.info("获取订单明细, userId={}, orderNo={}", userId, orderNo);
OmcOrder order = omcOrderMapper.selectByUserIdAndOrderNo(userId, orderNo);
if (null == order) {
throw new OmcBizException(ErrorCodeEnum.OMC10031005, orderNo);
}
List<OmcOrderDetail> orderItemList = omcOrderDetailService.getListByOrderNoUserId(orderNo, userId);
return assembleOrderVo(order, orderItemList);
}
use of com.paascloud.provider.model.domain.OmcOrderDetail in project paascloud-master by paascloud.
the class OmcCartServiceImpl method getCartOrderItem.
@Override
public List<OmcOrderDetail> getCartOrderItem(Long userId, List<OmcCart> cartList) {
List<OmcOrderDetail> orderItemList = Lists.newArrayList();
if (CollectionUtils.isEmpty(cartList)) {
throw new OmcBizException(ErrorCodeEnum.OMC10031001, userId);
}
// 校验购物车的数据,包括产品的状态和数量
for (OmcCart cartItem : cartList) {
OmcOrderDetail orderDetail = new OmcOrderDetail();
ProductDto product = mdcProductService.selectById(cartItem.getProductId());
if (MdcApiConstant.ProductStatusEnum.ON_SALE.getCode() != product.getStatus()) {
logger.error("商品不是在线售卖状态, productId={}", product.getId());
throw new OmcBizException(ErrorCodeEnum.MDC10021015, product.getId());
}
// 校验库存
if (cartItem.getQuantity() > product.getStock()) {
logger.error("商品库存不足, productId={}", product.getId());
throw new OmcBizException(ErrorCodeEnum.MDC10021016, product.getId());
}
orderDetail.setUserId(userId);
orderDetail.setProductId(product.getId());
orderDetail.setProductName(product.getName());
orderDetail.setProductImage(product.getMainImage());
orderDetail.setCurrentUnitPrice(product.getPrice());
orderDetail.setQuantity(cartItem.getQuantity());
orderDetail.setTotalPrice(BigDecimalUtil.mul(product.getPrice().doubleValue(), cartItem.getQuantity()));
orderItemList.add(orderDetail);
}
return orderItemList;
}
use of com.paascloud.provider.model.domain.OmcOrderDetail in project paascloud-master by paascloud.
the class OmcCartServiceImpl method getOrderCartProduct.
@Override
public OrderProductVo getOrderCartProduct(Long userId) {
Preconditions.checkArgument(userId != null, ErrorCodeEnum.UAC10011001.msg());
OrderProductVo orderProductVo = new OrderProductVo();
List<OmcCart> omcCartList = omcCartMapper.selectCheckedCartByUserId(userId);
List<OmcOrderDetail> orderItemList = this.getCartOrderItem(userId, omcCartList);
List<OrderItemVo> orderItemVoList = Lists.newArrayList();
BigDecimal payment = new BigDecimal("0");
for (OmcOrderDetail orderItem : orderItemList) {
payment = BigDecimalUtil.add(payment.doubleValue(), orderItem.getTotalPrice().doubleValue());
final OptGetUrlRequest request = new OptGetUrlRequest();
request.setAttachmentId(Long.valueOf(orderItem.getProductImage()));
request.setEncrypt(true);
String fileUrl = opcOssService.getFileUrl(request);
OrderItemVo orderItemVo = assembleOrderItemVo(orderItem);
orderItemVo.setProductImage(fileUrl);
orderItemVoList.add(orderItemVo);
}
orderProductVo.setProductTotalPrice(payment);
orderProductVo.setOrderItemVoList(orderItemVoList);
return orderProductVo;
}
use of com.paascloud.provider.model.domain.OmcOrderDetail in project paascloud-master by paascloud.
the class OmcOrderServiceImpl method assembleOrderVoList.
private List<OrderVo> assembleOrderVoList(List<OmcOrder> orderList, Long userId) {
List<OrderVo> orderVoList = Lists.newArrayList();
for (OmcOrder order : orderList) {
List<OmcOrderDetail> orderItemList;
if (userId == null) {
orderItemList = omcOrderDetailService.getListByOrderNo(order.getOrderNo());
} else {
orderItemList = omcOrderDetailService.getListByOrderNoUserId(order.getOrderNo(), userId);
}
OrderVo orderVo = assembleOrderVo(order, orderItemList);
orderVoList.add(orderVo);
}
return orderVoList;
}
use of com.paascloud.provider.model.domain.OmcOrderDetail in project paascloud-master by paascloud.
the class OmcOrderServiceImpl method reduceProductStock.
private void reduceProductStock(List<OmcOrderDetail> omcOrderDetailList) {
for (OmcOrderDetail orderItem : omcOrderDetailList) {
ProductDto product = mdcProductService.selectById(orderItem.getProductId());
product.setChangeStock(0 - orderItem.getQuantity());
mdcProductService.updateProductStockById(product);
}
}
Aggregations