Search in sources :

Example 1 with OmcBizException

use of com.paascloud.provider.exceptions.OmcBizException in project paascloud-master by paascloud.

the class OmcShippingServiceImpl method setDefault.

private void setDefault(LoginAuthDto loginAuthDto, Long addressId, int isDefault) {
    int result;
    OmcShipping updateNotDefault = new OmcShipping();
    updateNotDefault.setDefaultAddress(isDefault);
    updateNotDefault.setUpdateInfo(loginAuthDto);
    updateNotDefault.setId(addressId);
    result = omcShippingMapper.updateByPrimaryKeySelective(updateNotDefault);
    if (result < 1) {
        throw new OmcBizException(ErrorCodeEnum.OMC10031008, addressId);
    }
}
Also used : OmcShipping(com.paascloud.provider.model.domain.OmcShipping) OmcBizException(com.paascloud.provider.exceptions.OmcBizException)

Example 2 with OmcBizException

use of com.paascloud.provider.exceptions.OmcBizException in project paascloud-master by paascloud.

the class OmcShippingServiceImpl method setDefaultAddress.

@Transactional(rollbackFor = Exception.class)
@Override
public int setDefaultAddress(LoginAuthDto loginAuthDto, Long addressId) {
    Long userId = loginAuthDto.getUserId();
    Preconditions.checkArgument(addressId != null, "地址ID不能为空");
    // 1. 查找当前默认地址
    OmcShipping omcShipping = omcShippingMapper.selectDefaultAddressByUserId(userId);
    if (PublicUtil.isEmpty(omcShipping)) {
        throw new OmcBizException(ErrorCodeEnum.OMC10031007);
    }
    // 2. 判断默认地址和当前传入地址是否相同
    if (addressId.equals(omcShipping.getId())) {
        logger.info("所选地址和当前用户默认地址相同 userId={}, addressId={}", userId, addressId);
        return 1;
    }
    // 3. 相同不处理不相同把当前改为非默认, 把当前地址改为默认地址
    setDefault(loginAuthDto, addressId, OmcApiConstant.Shipping.DEFAULT);
    setDefault(loginAuthDto, omcShipping.getId(), OmcApiConstant.Shipping.NOT_DEFAULT);
    return 1;
}
Also used : OmcShipping(com.paascloud.provider.model.domain.OmcShipping) OmcBizException(com.paascloud.provider.exceptions.OmcBizException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with OmcBizException

use of com.paascloud.provider.exceptions.OmcBizException 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 4 with OmcBizException

use of com.paascloud.provider.exceptions.OmcBizException 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 5 with OmcBizException

use of com.paascloud.provider.exceptions.OmcBizException 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)

Aggregations

OmcBizException (com.paascloud.provider.exceptions.OmcBizException)13 OmcOrder (com.paascloud.provider.model.domain.OmcOrder)7 OmcOrderDetail (com.paascloud.provider.model.domain.OmcOrderDetail)5 OmcCart (com.paascloud.provider.model.domain.OmcCart)4 ModelMapper (org.modelmapper.ModelMapper)3 OmcShipping (com.paascloud.provider.model.domain.OmcShipping)2 OrderDto (com.paascloud.provider.model.dto.OrderDto)2 Transactional (org.springframework.transaction.annotation.Transactional)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 MdcBizException (com.paascloud.provider.exceptions.MdcBizException)1 PtcPayInfo (com.paascloud.provider.model.domain.PtcPayInfo)1 ProductDto (com.paascloud.provider.model.dto.ProductDto)1 OptUploadFileByteInfoReqDto (com.paascloud.provider.model.dto.attachment.OptUploadFileByteInfoReqDto)1 OptGetUrlRequest (com.paascloud.provider.model.dto.oss.OptGetUrlRequest)1 OptUploadFileReqDto (com.paascloud.provider.model.dto.oss.OptUploadFileReqDto)1 OptUploadFileRespDto (com.paascloud.provider.model.dto.oss.OptUploadFileRespDto)1