|
|
package com.yohoufo.order.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yoho.error.ServiceError;
|
|
|
import com.yoho.error.exception.ServiceException;
|
|
|
import com.yohobuy.ufo.model.order.common.OrderListType;
|
|
|
import com.yohobuy.ufo.model.order.common.OrderStatus;
|
|
|
import com.yohobuy.ufo.model.order.common.SkupStatus;
|
|
|
import com.yohobuy.ufo.model.order.common.TabType;
|
|
|
import com.yohobuy.ufo.model.order.req.BuyerOrderMetaUpdateReq;
|
|
|
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.DateUtil;
|
|
|
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
|
|
|
import com.yohoufo.dal.order.BuyerOrderMapper;
|
...
|
...
|
@@ -21,16 +25,19 @@ import com.yohoufo.order.common.ActionStatusHold; |
|
|
import com.yohoufo.order.common.DelStatus;
|
|
|
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;
|
|
|
import com.yohoufo.order.model.response.OrderSummaryResp;
|
|
|
import com.yohoufo.order.service.IBuyerOrderMetaService;
|
|
|
import com.yohoufo.order.service.IBuyerOrderService;
|
|
|
import com.yohoufo.order.service.cache.CacheCleaner;
|
|
|
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 org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
...
|
...
|
@@ -76,6 +83,9 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
@Autowired
|
|
|
private BuyerOrderCancelService buyerOrderCancelService;
|
|
|
|
|
|
@Autowired
|
|
|
private IBuyerOrderMetaService buyerOrderMetaService;
|
|
|
|
|
|
/**
|
|
|
* 提交订单
|
|
|
* @param orderRequest
|
...
|
...
|
@@ -107,6 +117,142 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 买家修改收货地址:
|
|
|
* 鉴定中心确定收货之前,都可以修改地址
|
|
|
*/
|
|
|
@Override
|
|
|
public void buyerModifyAddress(int uid, long orderCode,AddressInfo changedAddress){
|
|
|
//入参
|
|
|
if(uid <= 0){
|
|
|
throw new UfoServiceException(400,"参数错误:uid错误");
|
|
|
}
|
|
|
if(orderCode <= 0){
|
|
|
throw new UfoServiceException(400,"参数错误:订单号错误");
|
|
|
}
|
|
|
|
|
|
///// 检查隐藏的内容是否有变化,带*
|
|
|
if(StringUtils.isBlank(changedAddress.getAddress())||StringUtils.isBlank(changedAddress.getConsignee())
|
|
|
||StringUtils.isBlank(changedAddress.getMobile())
|
|
|
||StringUtils.isBlank(changedAddress.getArea())
|
|
|
||StringUtils.isBlank(changedAddress.getAreaCode())){
|
|
|
throw new UfoServiceException(400,"地址信息填写错误");
|
|
|
}
|
|
|
|
|
|
AddressInfo dbAddressInfo = buyerOrderMetaService.getAddressInfo(uid,orderCode);
|
|
|
if(dbAddressInfo==null){
|
|
|
logger.warn("dbAddressInfo is null ,uid {} ,orderCode {}",uid,orderCode);
|
|
|
throw new UfoServiceException(400,"找不到地址信息");
|
|
|
}
|
|
|
|
|
|
AddressInfo dbAddressInfo_hidden = buyerOrderMetaService.getHiddenAddressInfo(uid,orderCode);
|
|
|
if(dbAddressInfo_hidden==null){
|
|
|
logger.warn("dbAddressInfo_hidden is null ,uid {} ,orderCode {}",uid,orderCode);
|
|
|
throw new UfoServiceException(400,"找不到地址信息");
|
|
|
}
|
|
|
|
|
|
//详细地址没有变化
|
|
|
if(StringUtils.equals(dbAddressInfo_hidden.getAddress(),changedAddress.getAddress())){
|
|
|
changedAddress.setAddress(dbAddressInfo.getAddress());
|
|
|
}
|
|
|
//收货人没有变化
|
|
|
if(StringUtils.equals(dbAddressInfo_hidden.getConsignee(),changedAddress.getConsignee())){
|
|
|
changedAddress.setConsignee(dbAddressInfo.getConsignee());
|
|
|
}
|
|
|
//手机号没有变化
|
|
|
if(StringUtils.equals(dbAddressInfo_hidden.getMobile(),changedAddress.getMobile())){
|
|
|
changedAddress.setMobile(dbAddressInfo.getMobile());
|
|
|
}
|
|
|
|
|
|
boolean changed = convertAddressInfoFrontRequest(dbAddressInfo,changedAddress);
|
|
|
|
|
|
//至少有一个要更新,否则直接返回
|
|
|
if(!changed){
|
|
|
throw new UfoServiceException(400,"地址信息无变化");
|
|
|
//return ;
|
|
|
}
|
|
|
|
|
|
//检查订单
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
//买家已付款,卖家已发货,只有这两种状态的情况下,才允许改地址
|
|
|
boolean allowChange = buyerOrder.getStatus().intValue() == OrderStatus.HAS_PAYED.getCode()
|
|
|
||buyerOrder.getStatus().intValue() == OrderStatus.SELLER_SEND_OUT.getCode() ;
|
|
|
|
|
|
if(!allowChange){
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
//更新收货地址:明文地址 . 隐藏地址
|
|
|
JSONObject jo_address = (JSONObject)JSON.toJSON(dbAddressInfo);
|
|
|
jo_address.remove("uid");
|
|
|
String jo_address_string=jo_address.toJSONString();
|
|
|
BuyerOrderMetaUpdateReq updateInfo = new BuyerOrderMetaUpdateReq();
|
|
|
updateInfo.setUid(uid);
|
|
|
updateInfo.setOrderCode(orderCode);
|
|
|
updateInfo.setAddress(jo_address_string);
|
|
|
logger.info("buyerModifyAddress begin update address , uid is {}, orderCode is {},update address info {}",
|
|
|
uid, orderCode ,jo_address_string);
|
|
|
buyerOrderMetaService.updateDeliveryAddress(updateInfo);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 把变的信息项更新
|
|
|
*/
|
|
|
private boolean convertAddressInfoFrontRequest(AddressInfo dbAddressInfo,AddressInfo req){
|
|
|
boolean changed =false;
|
|
|
if(!StringUtils.equals(req.getConsignee(),dbAddressInfo.getConsignee())){
|
|
|
changed = true;
|
|
|
dbAddressInfo.setConsignee(req.getConsignee());
|
|
|
}
|
|
|
if(!StringUtils.equals(req.getAddress(),dbAddressInfo.getAddress())){
|
|
|
changed = true;
|
|
|
dbAddressInfo.setAddress(req.getAddress());
|
|
|
}
|
|
|
if(!StringUtils.equals(req.getAreaCode(),dbAddressInfo.getAreaCode())){
|
|
|
changed = true;
|
|
|
dbAddressInfo.setAreaCode(req.getAreaCode());
|
|
|
}
|
|
|
if(!StringUtils.equals(req.getArea(),dbAddressInfo.getArea())){
|
|
|
changed = true;
|
|
|
dbAddressInfo.setArea(req.getArea());
|
|
|
}
|
|
|
if(!StringUtils.equals(req.getMobile(),dbAddressInfo.getMobile())){
|
|
|
changed = true;
|
|
|
dbAddressInfo.setMobile(req.getMobile());
|
|
|
}
|
|
|
|
|
|
//address_id 比较特殊,地址id根本不存在,所以如果前台不传,则把原来的置0
|
|
|
if(req.getAddress_id()!=null&&req.getAddress_id()>0){
|
|
|
//changed = true; //此项目不作为信息更改判断根据
|
|
|
dbAddressInfo.setAddress_id(req.getAddress_id());
|
|
|
}else{
|
|
|
dbAddressInfo.setAddress_id(0);
|
|
|
}
|
|
|
|
|
|
if(StringUtils.isNotBlank(req.getIsUpdate())){
|
|
|
//changed = true; //此项目不作为信息更改判断根据
|
|
|
dbAddressInfo.setIsUpdate(req.getIsUpdate());
|
|
|
}
|
|
|
return changed;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 取消订单
|
|
|
* @param orderRequest
|
...
|
...
|
|