Search in sources :

Example 1 with OmcOrderDetail

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);
}
Also used : OmcOrderDetail(com.paascloud.provider.model.domain.OmcOrderDetail) OmcBizException(com.paascloud.provider.exceptions.OmcBizException) OmcOrder(com.paascloud.provider.model.domain.OmcOrder)

Example 2 with OmcOrderDetail

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;
}
Also used : OmcOrderDetail(com.paascloud.provider.model.domain.OmcOrderDetail) OmcBizException(com.paascloud.provider.exceptions.OmcBizException) OmcCart(com.paascloud.provider.model.domain.OmcCart) ProductDto(com.paascloud.provider.model.dto.ProductDto)

Example 3 with OmcOrderDetail

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;
}
Also used : OptGetUrlRequest(com.paascloud.provider.model.dto.oss.OptGetUrlRequest) OrderProductVo(com.paascloud.provider.model.vo.OrderProductVo) OmcOrderDetail(com.paascloud.provider.model.domain.OmcOrderDetail) OrderItemVo(com.paascloud.provider.model.vo.OrderItemVo) OmcCart(com.paascloud.provider.model.domain.OmcCart) BigDecimal(java.math.BigDecimal)

Example 4 with OmcOrderDetail

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;
}
Also used : OrderVo(com.paascloud.provider.model.vo.OrderVo) OmcOrderDetail(com.paascloud.provider.model.domain.OmcOrderDetail) OmcOrder(com.paascloud.provider.model.domain.OmcOrder)

Example 5 with OmcOrderDetail

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);
    }
}
Also used : OmcOrderDetail(com.paascloud.provider.model.domain.OmcOrderDetail) ProductDto(com.paascloud.provider.model.dto.ProductDto)

Aggregations

OmcOrderDetail (com.paascloud.provider.model.domain.OmcOrderDetail)10 OmcBizException (com.paascloud.provider.exceptions.OmcBizException)5 OmcOrder (com.paascloud.provider.model.domain.OmcOrder)4 OmcCart (com.paascloud.provider.model.domain.OmcCart)3 ProductDto (com.paascloud.provider.model.dto.ProductDto)2 OptGetUrlRequest (com.paascloud.provider.model.dto.oss.OptGetUrlRequest)2 OrderItemVo (com.paascloud.provider.model.vo.OrderItemVo)2 OrderVo (com.paascloud.provider.model.vo.OrderVo)2 BigDecimal (java.math.BigDecimal)2 AlipayTradePrecreateResponse (com.alipay.api.response.AlipayTradePrecreateResponse)1 ExtendParams (com.alipay.demo.trade.model.ExtendParams)1 GoodsDetail (com.alipay.demo.trade.model.GoodsDetail)1 AlipayTradePrecreateRequestBuilder (com.alipay.demo.trade.model.builder.AlipayTradePrecreateRequestBuilder)1 AlipayF2FPrecreateResult (com.alipay.demo.trade.model.result.AlipayF2FPrecreateResult)1 OmcShipping (com.paascloud.provider.model.domain.OmcShipping)1 OrderDetailDto (com.paascloud.provider.model.dto.OrderDetailDto)1 OrderDto (com.paascloud.provider.model.dto.OrderDto)1 OptUploadFileByteInfoReqDto (com.paascloud.provider.model.dto.attachment.OptUploadFileByteInfoReqDto)1 OptUploadFileReqDto (com.paascloud.provider.model.dto.oss.OptUploadFileReqDto)1 OptUploadFileRespDto (com.paascloud.provider.model.dto.oss.OptUploadFileRespDto)1