|
|
package com.yohoufo.order.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yoho.error.ServiceError;
|
|
|
import com.yoho.error.exception.ServiceException;
|
|
|
import com.yohobuy.ufo.model.order.common.OrderListType;
|
...
|
...
|
@@ -10,17 +11,23 @@ import com.yohobuy.ufo.model.order.resp.OrderCntResp; |
|
|
import com.yohobuy.ufo.model.order.resp.OrderListInfo;
|
|
|
import com.yohobuy.ufo.model.order.resp.PageResp;
|
|
|
import com.yohobuy.ufo.model.order.vo.OrderListVo;
|
|
|
import com.yohoufo.common.exception.UfoServiceException;
|
|
|
import com.yohoufo.common.utils.AddressUtil;
|
|
|
import com.yohoufo.common.utils.DateUtil;
|
|
|
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
|
|
|
import com.yohoufo.dal.order.BuyerOrderMapper;
|
|
|
import com.yohoufo.dal.order.BuyerOrderMetaMapper;
|
|
|
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
|
|
|
import com.yohoufo.dal.order.model.BuyerOrder;
|
|
|
import com.yohoufo.dal.order.model.BuyerOrderGoods;
|
|
|
import com.yohoufo.dal.order.model.BuyerOrderMeta;
|
|
|
import com.yohoufo.dal.order.model.SellerOrderGoods;
|
|
|
import com.yohoufo.order.common.ActionStatusHold;
|
|
|
import com.yohoufo.order.common.DelStatus;
|
|
|
import com.yohoufo.order.constants.MetaKey;
|
|
|
import com.yohoufo.order.event.BeforeDepotReceiveEvent;
|
|
|
import com.yohoufo.order.event.BeforeSellerDeliverEvent;
|
|
|
import com.yohoufo.order.model.AddressInfo;
|
|
|
import com.yohoufo.order.model.request.OrderListRequest;
|
|
|
import com.yohoufo.order.model.request.OrderRequest;
|
|
|
import com.yohoufo.order.model.response.OrderDetailInfo;
|
...
|
...
|
@@ -31,6 +38,9 @@ import com.yohoufo.order.service.cache.CacheKeyBuilder; |
|
|
import com.yohoufo.order.service.cache.OrderCacheService;
|
|
|
import com.yohoufo.order.service.proxy.InBoxFacade;
|
|
|
import com.yohoufo.order.service.proxy.ProductProxyService;
|
|
|
import com.yohoufo.order.service.proxy.UserProxyService;
|
|
|
import com.yohoufo.order.utils.AddressHelper;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
...
|
...
|
@@ -76,6 +86,12 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
@Autowired
|
|
|
private BuyerOrderCancelService buyerOrderCancelService;
|
|
|
|
|
|
@Autowired
|
|
|
private UserProxyService userProxyService;
|
|
|
|
|
|
@Autowired
|
|
|
private BuyerOrderMetaMapper buyerOrderMetaMapper;
|
|
|
|
|
|
/**
|
|
|
* 提交订单
|
|
|
* @param orderRequest
|
...
|
...
|
@@ -107,6 +123,92 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 买家修改收货地址:
|
|
|
* 鉴定中心确定收货之前,都可以修改地址
|
|
|
* @ addressId 加密过的地址Id
|
|
|
*/
|
|
|
@Override
|
|
|
public void buyerModifyAddress(int uid,Long orderCode,String addressIdStr){
|
|
|
//入参
|
|
|
if(uid < 0){
|
|
|
throw new UfoServiceException(400,"参数错误:uid错误");
|
|
|
}
|
|
|
if(orderCode==null||orderCode < 0){
|
|
|
throw new UfoServiceException(400,"参数错误:订单号错误");
|
|
|
}
|
|
|
if(StringUtils.isBlank(addressIdStr)){
|
|
|
throw new UfoServiceException(400,"参数错误:收货地址错误");
|
|
|
}
|
|
|
|
|
|
// 检查地址是否合法
|
|
|
int addressId = AddressUtil.getDecryptStr(addressIdStr);
|
|
|
if (addressId < 0){
|
|
|
logger.warn("buyerModifyAddress addressId invalidate, uid is {}, order code is {}, addressIdStr is {}", uid,
|
|
|
orderCode,addressIdStr);
|
|
|
throw new ServiceException(ServiceError.ORDER_ADDRESSID_INVALIDATE);
|
|
|
}
|
|
|
|
|
|
//获取地址
|
|
|
AddressInfo addressInfo = userProxyService.getAddressInfoNotHidden(uid, addressId);
|
|
|
if(AddressHelper.isNeedUpdate(addressInfo)){
|
|
|
logger.warn("buyerModifyAddress addressId need update, uid is {}, order code is {}, addressIdStr is {}", uid,
|
|
|
orderCode,addressIdStr);
|
|
|
throw new ServiceException(ServiceError.ORDER_ADDRESS_NEED_UPDATE);
|
|
|
}
|
|
|
|
|
|
AddressInfo hiddenAddress = userProxyService.getHiddenAddressInfo(uid, addressId);
|
|
|
|
|
|
//检查订单
|
|
|
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCodeUid(orderCode,uid);
|
|
|
if(buyerOrder==null){
|
|
|
logger.warn("buyerModifyAddress check orderCode exist, uid is {}, orderCode is {}",
|
|
|
uid, orderCode );
|
|
|
throw new ServiceException(ServiceError.ORDER_NULL);
|
|
|
}
|
|
|
|
|
|
if(buyerOrder.getStatus()==null){
|
|
|
logger.warn("buyerModifyAddress check orderCode status is null, uid is {}, orderCode is {} ,status is {}",
|
|
|
uid, orderCode,buyerOrder.getStatus() );
|
|
|
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
|
|
|
}
|
|
|
|
|
|
//平台确认收货之前,允许修改,否则不允许
|
|
|
if(buyerOrder.getStatus() >= OrderStatus.PLATFORM_CHECKING.getCode()){
|
|
|
logger.warn("buyerModifyAddress check orderCode status not invalid, uid is {}, orderCode is {} ,status is {}",
|
|
|
uid, orderCode,buyerOrder.getStatus() );
|
|
|
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
|
|
|
}
|
|
|
|
|
|
//更新收货地址:明文地址
|
|
|
BuyerOrderMeta meta=new BuyerOrderMeta();
|
|
|
meta.setUid(uid);
|
|
|
meta.setOrderCode(orderCode);
|
|
|
meta.setMetaKey(MetaKey.BUYER_DELIVERY_ADDRESS);
|
|
|
meta.setMetaValue(JSONObject.toJSONString(addressInfo));
|
|
|
logger.info("buyerModifyAddress updateDeliveryAddress meta param {} begin ",meta);
|
|
|
int updateRowNum = buyerOrderMetaMapper.updateMetaValueByUidAndOrderCodeAndMetaKey(meta);
|
|
|
logger.info("buyerModifyAddress updateDeliveryAddress meta param {} end, updateRowNum {} ",meta,updateRowNum);
|
|
|
|
|
|
// 隐藏地址
|
|
|
BuyerOrderMeta meta_hiddenAddress=new BuyerOrderMeta();
|
|
|
meta_hiddenAddress.setUid(uid);
|
|
|
meta_hiddenAddress.setOrderCode(orderCode);
|
|
|
meta_hiddenAddress.setMetaKey(MetaKey.BUYER_DELIVERY_HIDDEN_ADDRESS);
|
|
|
meta_hiddenAddress.setMetaValue(JSONObject.toJSONString(hiddenAddress));
|
|
|
logger.info("buyerModifyAddress updateDeliveryAddress_hidden meta param {} begin ",meta_hiddenAddress);
|
|
|
updateRowNum = buyerOrderMetaMapper.updateMetaValueByUidAndOrderCodeAndMetaKey(meta_hiddenAddress);
|
|
|
logger.info("buyerModifyAddress updateDeliveryAddress_hidden meta param {} end, updateRowNum {} ",meta_hiddenAddress,updateRowNum);
|
|
|
|
|
|
//清地址缓存
|
|
|
cacheCleaner.delete(Arrays.asList(
|
|
|
CacheKeyBuilder.orderDetailKey(uid, TabType.BUY.getValue(), orderCode)));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 取消订单
|
|
|
* @param orderRequest
|
...
|
...
|
|