Search in sources :

Example 1 with OmcOrder

use of com.paascloud.provider.model.domain.OmcOrder 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 OmcOrder

use of com.paascloud.provider.model.domain.OmcOrder in project paascloud-master by paascloud.

the class OmcOrderServiceImpl method cancelOrderDoc.

@Override
public int cancelOrderDoc(LoginAuthDto loginAuthDto, String orderNo) {
    Long userId = loginAuthDto.getUserId();
    OmcOrder order = omcOrderMapper.selectByUserIdAndOrderNo(userId, orderNo);
    if (order == null) {
        logger.error("该用户此订单不存在, userId={}, orderNo={}", userId, orderNo);
        throw new OmcBizException(ErrorCodeEnum.OMC10031003);
    }
    if (order.getStatus() != OmcApiConstant.OrderStatusEnum.NO_PAY.getCode()) {
        throw new OmcBizException(ErrorCodeEnum.OMC10031004);
    }
    OmcOrder updateOrder = new OmcOrder();
    updateOrder.setId(order.getId());
    updateOrder.setStatus(OmcApiConstant.OrderStatusEnum.CANCELED.getCode());
    return omcOrderMapper.updateByPrimaryKeySelective(updateOrder);
}
Also used : OmcBizException(com.paascloud.provider.exceptions.OmcBizException) OmcOrder(com.paascloud.provider.model.domain.OmcOrder)

Example 3 with OmcOrder

use of com.paascloud.provider.model.domain.OmcOrder in project paascloud-master by paascloud.

the class OmcOrderServiceImpl method queryOrderDtoByOrderNo.

@Override
public OrderDto queryOrderDtoByOrderNo(String orderNo) {
    OmcOrder omcOrder = this.queryByOrderNo(orderNo);
    if (omcOrder == null) {
        throw new OmcBizException(ErrorCodeEnum.OMC10031005, orderNo);
    }
    ModelMapper modelMapper = new ModelMapper();
    return modelMapper.map(omcOrder, OrderDto.class);
}
Also used : OmcBizException(com.paascloud.provider.exceptions.OmcBizException) OmcOrder(com.paascloud.provider.model.domain.OmcOrder) ModelMapper(org.modelmapper.ModelMapper)

Example 4 with OmcOrder

use of com.paascloud.provider.model.domain.OmcOrder 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 OmcOrder

use of com.paascloud.provider.model.domain.OmcOrder in project paascloud-master by paascloud.

the class OmcOrderServiceImpl method assembleOrder.

private OmcOrder assembleOrder(Long userId, Long shippingId, BigDecimal payment) {
    OmcOrder order = new OmcOrder();
    long orderNo = this.generateOrderNo();
    order.setOrderNo(String.valueOf(orderNo));
    order.setStatus(OmcApiConstant.OrderStatusEnum.NO_PAY.getCode());
    order.setPostage(0);
    order.setPaymentType(GlobalConstant.PaymentTypeEnum.ONLINE_PAY.getCode());
    order.setPayment(payment);
    order.setUserId(userId);
    order.setShippingId(shippingId);
    order.setId(super.generateId());
    // 发货时间等等
    // 付款时间等等
    int rowCount = omcOrderMapper.insertSelective(order);
    if (rowCount > 0) {
        return order;
    }
    return null;
}
Also used : OmcOrder(com.paascloud.provider.model.domain.OmcOrder)

Aggregations

OmcOrder (com.paascloud.provider.model.domain.OmcOrder)10 OmcBizException (com.paascloud.provider.exceptions.OmcBizException)7 OmcOrderDetail (com.paascloud.provider.model.domain.OmcOrderDetail)4 ModelMapper (org.modelmapper.ModelMapper)4 OmcCart (com.paascloud.provider.model.domain.OmcCart)1 PtcPayInfo (com.paascloud.provider.model.domain.PtcPayInfo)1 OrderDto (com.paascloud.provider.model.dto.OrderDto)1 OrderVo (com.paascloud.provider.model.vo.OrderVo)1 ApiOperation (io.swagger.annotations.ApiOperation)1 BigDecimal (java.math.BigDecimal)1 Date (java.util.Date)1 Transactional (org.springframework.transaction.annotation.Transactional)1