Search in sources :

Example 6 with OmcOrder

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

the class OmcOrderServiceImpl method createOrderDoc.

@Override
@Transactional(rollbackFor = Exception.class)
public OrderVo createOrderDoc(LoginAuthDto loginAuthDto, Long shippingId) {
    Long userId = loginAuthDto.getUserId();
    // 从购物车中获取数据
    List<OmcCart> cartList = omcCartMapper.selectCheckedCartByUserId(userId);
    if (CollectionUtils.isEmpty(cartList)) {
        throw new OmcBizException(ErrorCodeEnum.OMC10031001, userId);
    }
    // 计算这个订单的总价
    List<OmcOrderDetail> omcOrderDetailList = omcCartService.getCartOrderItem(userId, cartList);
    if (CollectionUtils.isEmpty(omcOrderDetailList)) {
        throw new OmcBizException(ErrorCodeEnum.OMC10031001, userId);
    }
    BigDecimal payment = this.getOrderTotalPrice(omcOrderDetailList);
    // 生成订单
    OmcOrder order = this.assembleOrder(userId, shippingId, payment);
    if (order == null) {
        logger.error("生成订单失败, userId={}, shippingId={}, payment={}", userId, shippingId, payment);
        throw new OmcBizException(ErrorCodeEnum.OMC10031002);
    }
    order.setUpdateInfo(loginAuthDto);
    for (OmcOrderDetail orderDetail : omcOrderDetailList) {
        orderDetail.setUpdateInfo(loginAuthDto);
        orderDetail.setOrderNo(order.getOrderNo());
        orderDetail.setId(super.generateId());
        orderDetail.setUpdateInfo(loginAuthDto);
    }
    // mybatis 批量插入
    omcOrderDetailService.batchInsertOrderDetail(omcOrderDetailList);
    // 生成成功,我们要减少我们产品的库存
    this.reduceProductStock(omcOrderDetailList);
    // 清空一下购物车
    this.cleanCart(cartList);
    return assembleOrderVo(order, omcOrderDetailList);
}
Also used : OmcOrderDetail(com.paascloud.provider.model.domain.OmcOrderDetail) OmcCart(com.paascloud.provider.model.domain.OmcCart) OmcBizException(com.paascloud.provider.exceptions.OmcBizException) OmcOrder(com.paascloud.provider.model.domain.OmcOrder) BigDecimal(java.math.BigDecimal) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with OmcOrder

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

the class OmcOrderServiceImpl method queryOrderDtoByUserIdAndOrderNo.

@Override
public OrderDto queryOrderDtoByUserIdAndOrderNo(Long userId, String orderNo) {
    OmcOrder omcOrder = this.queryByUserIdAndOrderNo(userId, 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 8 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(final String orderNo) {
    logger.info("获取订单明细, orderNo={}", orderNo);
    OmcOrder order = omcOrderMapper.selectByOrderNo(orderNo);
    if (null == order) {
        throw new OmcBizException(ErrorCodeEnum.OMC10031005, orderNo);
    }
    List<OmcOrderDetail> orderItemList = omcOrderDetailService.getListByOrderNo(orderNo);
    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 9 with OmcOrder

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

the class PtcAlipayServiceImpl method aliPayCallback.

@Override
public Wrapper aliPayCallback(Map<String, String> params) {
    log.info("支付宝回调. - aliPayCallback. params={}", params);
    String orderNo = params.get("out_trade_no");
    String tradeNo = params.get("trade_no");
    String tradeStatus = params.get("trade_status");
    OrderDto order = omcOrderService.queryOrderDtoByOrderNo(orderNo);
    if (order == null) {
        throw new OmcBizException(ErrorCodeEnum.OMC10031010);
    }
    if (order.getStatus() >= OmcApiConstant.OrderStatusEnum.PAID.getCode()) {
        throw new OmcBizException(ErrorCodeEnum.OMC10031011);
    }
    if (PtcApiConstant.AlipayCallback.TRADE_STATUS_TRADE_SUCCESS.equals(tradeStatus)) {
        order.setPaymentTime(DateUtil.parseDate(params.get("gmt_payment")));
        order.setStatus(OmcApiConstant.OrderStatusEnum.PAID.getCode());
        ModelMapper modelMapper = new ModelMapper();
        OmcOrder omcOrder = modelMapper.map(order, OmcOrder.class);
        omcOrderService.update(omcOrder);
    }
    PtcPayInfo payInfo = new PtcPayInfo();
    payInfo.setUserId(order.getUserId());
    payInfo.setOrderNo(order.getOrderNo());
    payInfo.setPayPlatform(PtcApiConstant.PayPlatformEnum.ALIPAY.getCode());
    payInfo.setPlatformNumber(tradeNo);
    payInfo.setPlatformStatus(tradeStatus);
    payInfo.setUpdateTime(new Date());
    payInfo.setCreatedTime(new Date());
    payInfo.setCreator(order.getCreator());
    payInfo.setCreatorId(order.getUserId());
    payInfo.setLastOperator(order.getLastOperator());
    payInfo.setLastOperatorId(order.getLastOperatorId());
    payInfo.setId(UniqueIdGenerator.generateId());
    ptcPayInfoMapper.insertSelective(payInfo);
    return WrapMapper.ok();
}
Also used : PtcPayInfo(com.paascloud.provider.model.domain.PtcPayInfo) OrderDto(com.paascloud.provider.model.dto.OrderDto) OmcBizException(com.paascloud.provider.exceptions.OmcBizException) OmcOrder(com.paascloud.provider.model.domain.OmcOrder) Date(java.util.Date) ModelMapper(org.modelmapper.ModelMapper)

Example 10 with OmcOrder

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

the class OmcOrderFeignClient method updateOrderById.

@Override
@ApiOperation(httpMethod = "POST", value = "更新订单信息")
public Wrapper updateOrderById(@RequestBody OrderDto orderDto) {
    logger.info("updateOrderById - 更新订单信息. orderDto={}", orderDto);
    ModelMapper modelMapper = new ModelMapper();
    OmcOrder omcOrder = modelMapper.map(orderDto, OmcOrder.class);
    int updateResult = omcOrderService.update(omcOrder);
    return handleResult(updateResult);
}
Also used : OmcOrder(com.paascloud.provider.model.domain.OmcOrder) ModelMapper(org.modelmapper.ModelMapper) ApiOperation(io.swagger.annotations.ApiOperation)

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