use of com.paascloud.provider.model.domain.OmcShipping 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.model.domain.OmcShipping 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.model.domain.OmcShipping in project paascloud-master by paascloud.
the class OmcOrderServiceImpl method assembleOrderVo.
private OrderVo assembleOrderVo(OmcOrder order, List<OmcOrderDetail> orderItemList) {
OrderVo orderVo = new OrderVo();
orderVo.setOrderNo(order.getOrderNo());
orderVo.setPayment(order.getPayment());
orderVo.setPaymentType(order.getPaymentType());
orderVo.setPaymentTypeDesc(Objects.requireNonNull(GlobalConstant.PaymentTypeEnum.codeOf(order.getPaymentType())).getValue());
orderVo.setPostage(order.getPostage());
orderVo.setStatus(order.getStatus());
orderVo.setStatusDesc(OmcApiConstant.OrderStatusEnum.codeOf(order.getStatus()).getValue());
orderVo.setShippingId(order.getShippingId());
OmcShipping shipping = omcShippingMapper.selectByPrimaryKey(order.getShippingId());
if (shipping != null) {
orderVo.setReceiverName(shipping.getReceiverName());
orderVo.setShippingVo(assembleShippingVo(shipping));
}
orderVo.setPaymentTime(order.getPaymentTime());
orderVo.setSendTime(order.getSendTime());
orderVo.setEndTime(order.getEndTime());
orderVo.setCreateTime(order.getCreatedTime());
orderVo.setCloseTime(order.getCloseTime());
orderVo.setCreator(order.getCreator());
orderVo.setImageHost("");
List<OrderItemVo> orderItemVoList = Lists.newArrayList();
for (OmcOrderDetail orderItem : orderItemList) {
OrderItemVo orderItemVo = assembleOrderItemVo(orderItem);
orderItemVoList.add(orderItemVo);
}
orderVo.setOrderItemVoList(orderItemVoList);
return orderVo;
}
use of com.paascloud.provider.model.domain.OmcShipping in project paascloud-master by paascloud.
the class OmcShippingController method selectShippingById.
/**
* 根据Id查询收货人地址.
*
* @param shippingId the shipping id
*
* @return the wrapper
*/
@PostMapping("/selectShippingById/{shippingId}")
@ApiOperation(httpMethod = "POST", value = "根据Id查询收货人地址")
public Wrapper<OmcShipping> selectShippingById(@PathVariable Long shippingId) {
Long userId = getLoginAuthDto().getUserId();
logger.info("selectShippingById - 根据Id查询收货人地址. userId={}, shippingId={}", userId, shippingId);
OmcShipping omcShipping = omcShippingService.selectByShippingIdUserId(userId, shippingId);
return WrapMapper.ok(omcShipping);
}
Aggregations