Authored by qinchao

物流

... ... @@ -2,12 +2,13 @@ package com.yohoufo.order.controller;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohobuy.ufo.model.order.resp.ExpressInfoRespBo;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.cache.Cachable;
import com.yohoufo.order.model.response.AppraiseAddressResp;
import com.yohoufo.order.service.IExpressInfoService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -48,8 +49,12 @@ public class ExpressInfoController {
* @return
*/
@RequestMapping(params = "method=ufo.order.expressDetailInfo")
public ApiResponse queryExpressDetailInfo(@RequestParam("uid") Integer uid, @RequestParam("orderCode") Long orderCode) {
ExpressInfoRespBo expressInfoRespBo = expressInfoService.queryExpressDetailInfo(uid,orderCode);
public ApiResponse queryExpressDetailInfo(@RequestParam("uid") Integer uid, @RequestParam("orderCode") Long orderCode,@RequestParam(value = "tabType",required = false) String tabType) {
TabType actor = null;
if(StringUtils.isNotBlank(tabType)){
actor = TabType.getTabType(tabType);
}
ExpressInfoRespBo expressInfoRespBo = expressInfoService.queryExpressDetailInfo(uid,orderCode,actor);
return new ApiResponse.ApiResponseBuilder().code(200).data(expressInfoRespBo).build();
}
... ...
package com.yohoufo.order.service;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohobuy.ufo.model.order.resp.ExpressInfoRespBo;
import com.yohoufo.order.model.response.AppraiseAddressResp;
... ... @@ -53,7 +54,7 @@ public interface IExpressInfoService {
* @param orderCode
* @return
*/
ExpressInfoRespBo queryExpressDetailInfo(Integer uid,Long orderCode);
ExpressInfoRespBo queryExpressDetailInfo(Integer uid, Long orderCode, TabType actor);
/**
* 根据用户默认地址的省份定位到鉴定中心的地址返回
... ...
... ... @@ -6,6 +6,7 @@ import com.google.common.collect.Lists;
import com.yoho.core.rabbitmq.YhProducer;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohobuy.ufo.model.order.resp.ExpressInfoDetail;
import com.yohobuy.ufo.model.order.resp.ExpressInfoRespBo;
... ... @@ -15,7 +16,6 @@ import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.*;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.order.common.ExpressForMqSend;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.model.AddressInfo;
import com.yohoufo.order.model.response.AppraiseAddressResp;
... ... @@ -35,6 +35,7 @@ import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
/**
* @author kun.wang
... ... @@ -243,19 +244,38 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
* @return
*/
@Override
public ExpressInfoRespBo queryExpressDetailInfo(Integer uid,Long orderCode) {
LOGGER.info("queryExpressDetailInfo uid={}, orderCode = {}",uid, orderCode);
public ExpressInfoRespBo queryExpressDetailInfo(Integer uid,Long orderCode,TabType actor) {
LOGGER.info("queryExpressDetailInfo uid={}, orderCode = {},actor = {} ",uid, orderCode,actor);
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if (buyerOrder == null){
LOGGER.warn("getOrderInfo order not exist, orderCode is {}", orderCode);
LOGGER.warn("queryExpressDetailInfo getOrderInfo order not exist, orderCode is {}", orderCode);
throw new ServiceException(ServiceError.ORDER_NULL);
}
//验证订单和tabType匹配
if(actor!=null){
switch (actor){
case BUY:
if(uid!=buyerOrder.getUid()){
//验证是买家
LOGGER.warn("queryExpressDetailInfo check order not match buyer , uid = {} ,order is {} ", orderCode ,JSON.toJSONString(buyerOrder) );
throw new ServiceException(ServiceError.ORDER_NULL);
}
case SELL:
if(uid!=buyerOrder.getSellerUid()){
//验证是卖家
LOGGER.warn("queryExpressDetailInfo check order not match seller , uid = {} ,order is {} ", orderCode ,JSON.toJSONString(buyerOrder) );
throw new ServiceException(ServiceError.ORDER_NULL);
}
}
}
ExpressInfoRespBo expressInfoRespBo = new ExpressInfoRespBo();
Integer expressType = getExpressType(buyerOrder);
Integer expressType = getExpressType(buyerOrder,actor);
LOGGER.info("getExpressType result = {}", expressType);
List<ExpressInfo> expressInfoList = expressInfoMapper.selectAllExpressInfo(uid, orderCode, expressType);
processExpressInfo(expressInfoList, expressInfoRespBo);
//获取上一阶段的辅助物流信息
List<ExpressInfoDetail> supplementExpressInfoDetailList = Lists.newArrayList();
expressInfoRespBo.setSupplementExpressInfoDetailList(supplementExpressInfoDetailList);
... ... @@ -324,9 +344,8 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
private void constructExpressInfo(List<ExpressInfo> expressInfoList, List<ExpressInfoDetail> supplementExpressInfoDetailList) {
if (CollectionUtils.isNotEmpty(expressInfoList)) {
ExpressInfoDetail expressInfoDetail;
for (ExpressInfo expressInfo : expressInfoList) {
expressInfoDetail = new ExpressInfoDetail();
ExpressInfoDetail expressInfoDetail = new ExpressInfoDetail();
// 运单接收地
expressInfoDetail.setAcceptAddress(expressInfo.getAcceptAddress());
// 运单信息
... ... @@ -341,20 +360,50 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
* orderCode 一定是买家订单号
* @return
*/
private Integer getExpressType(BuyerOrder buyerOrder) {
private Integer getExpressType(BuyerOrder buyerOrder,TabType actor) {
if(null==actor){
if(OrderStatus.SELLER_SEND_OUT.getCode()==buyerOrder.getStatus()||OrderStatus.PLATFORM_CHECKING.getCode()==buyerOrder.getStatus()){
return ExpressInfoConstant.EXPRESS_TYPE_1;
}else if(OrderStatus.CHECKING_FAKE.getCode()==buyerOrder.getStatus()){
return ExpressInfoConstant.EXPRESS_TYPE_3;
}else if(OrderStatus.WAITING_RECEIVE.getCode()==buyerOrder.getStatus()||OrderStatus.DONE.getCode()==buyerOrder.getStatus()){
//4 和 5 状态有问题 ,买家查看物流是没问题的,卖家查看物流有问题啊.
return ExpressInfoConstant.EXPRESS_TYPE_2;
}else if(OrderStatus.CHECKING_FAKE.getCode()==buyerOrder.getStatus()){
return ExpressInfoConstant.EXPRESS_TYPE_3;
}else if(OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE.getCode()==buyerOrder.getStatus()){
return ExpressInfoConstant.EXPRESS_TYPE_REBACK;
}
}else {
switch (actor){
case BUY:
return getExpressTypeBuyer(buyerOrder);
case SELL:
return getExpressTypeSeller(buyerOrder);
default:
return 0;
}
}
return 0;
}
private Integer getExpressTypeSeller(BuyerOrder buyerOrder){
Integer status = buyerOrder.getStatus();
Integer type ;
if (Objects.equals(OrderStatus.CHECKING_FAKE.getCode(), status)){
type = ExpressInfoConstant.EXPRESS_TYPE_3;
}else if(Objects.equals(OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE.getCode(), status)){
type = ExpressInfoConstant.EXPRESS_TYPE_REBACK;
}else{
type = ExpressInfoConstant.EXPRESS_TYPE_1;
}
return type;
}
private Integer getExpressTypeBuyer(BuyerOrder buyerOrder){
return ExpressInfoConstant.EXPRESS_TYPE_2;
}
/**
* 根据用户默认地址的省份定位到鉴定中心的地址返回
*
... ...