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);
}
}
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;
}
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);
}
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);
}
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);
}
Aggregations