...
|
...
|
@@ -54,6 +54,8 @@ import javax.annotation.Resource; |
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.yohoufo.order.utils.ServiceExceptions.throwServiceExceptionIf;
|
|
|
|
|
|
/**
|
|
|
* @author kun.wang
|
|
|
* @date 2018/9/25
|
...
|
...
|
@@ -398,33 +400,91 @@ public class ExpressInfoServiceImpl implements IExpressInfoService { |
|
|
*/
|
|
|
@Override
|
|
|
public ExpressInfoRespBo queryExpressDetailInfo(Integer uid, Long orderCode, TabType actor, Integer scene) {
|
|
|
LOGGER.info("queryExpressDetailInfo uid={}, orderCode = {},actor = {} ", uid, orderCode, actor);
|
|
|
String logTag = String.format("query express detail %s", orderCode);
|
|
|
LOGGER.info("{}, uid is {} actor is {} and scene is {}", logTag, uid, actor, scene);
|
|
|
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
|
|
|
if (buyerOrder == null) {
|
|
|
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.equals(buyerOrder.getUid())) {
|
|
|
//验证是买家
|
|
|
LOGGER.warn("queryExpressDetailInfo check order not match buyer , uid = {} ,order is {} ", orderCode, JSON.toJSONString(buyerOrder));
|
|
|
throw new UfoServiceException(400, "订单物流不允许买家用户查询");
|
|
|
throwServiceExceptionIf(Objects.isNull(buyerOrder), "订单不存在");
|
|
|
boolean isBuyer = actor == TabType.BUY;
|
|
|
boolean isSeller = actor == TabType.SELL;
|
|
|
throwServiceExceptionIf(isBuyer && !uid.equals(buyerOrder.getUid()), "订单物流不允许买家用户查询");
|
|
|
throwServiceExceptionIf(isSeller && !uid.equals(buyerOrder.getSellerUid()), "订单物流不允许卖家用户查询");
|
|
|
|
|
|
ExpressInfoRespBo result = new ExpressInfoResponseDateBuilder(actor, scene, buyerOrder)
|
|
|
.init()
|
|
|
.handler(expressInfoRespBo -> {
|
|
|
List<Integer> expressTypeList = getCurrentExpressType4ExpressRecord(buyerOrder.getStatus(), actor);
|
|
|
if (CollectionUtils.isEmpty(expressTypeList)) {
|
|
|
LOGGER.info("{}, expressTypeList is empty", logTag);
|
|
|
return;
|
|
|
}
|
|
|
break;
|
|
|
case SELL:
|
|
|
if (!uid.equals(buyerOrder.getSellerUid())) {
|
|
|
//验证是卖家
|
|
|
LOGGER.warn("queryExpressDetailInfo check order not match seller , uid = {} ,order is {} ", orderCode, JSON.toJSONString(buyerOrder));
|
|
|
throw new UfoServiceException(400, "订单物流不允许卖家用户查询");
|
|
|
|
|
|
//1.物流单号信息
|
|
|
constructWayBillInfo(orderCode, expressTypeList, expressInfoRespBo);
|
|
|
|
|
|
// 构造物流信息
|
|
|
if (expressTypeList.size() == 1) {
|
|
|
//设定最近一个阶段的物流
|
|
|
List<ExpressInfo> expressInfoList = getExpressInfoListByStage(actor, orderCode, expressTypeList.get(0));
|
|
|
constructExpressInfo(actor, expressInfoList, expressInfoRespBo.getExpressInfoDetailList());
|
|
|
expressInfoRespBo.setExpressInfoDetailTitle("卖家发往平台");
|
|
|
} else if (expressTypeList.size() == 2) {
|
|
|
if (EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER.getCode().intValue() == expressTypeList.get(0)) {
|
|
|
//设定鉴定的物流调拨信息
|
|
|
List<ExpressInfo> judgeExpressInfoList = getExpressInfoListByStage(actor, orderCode, EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER.getCode());
|
|
|
constructExpressInfo(actor, judgeExpressInfoList, expressInfoRespBo.getJudgeExpressInfoDetailList());
|
|
|
|
|
|
//获取上一阶段的辅助物流信息
|
|
|
constructSupplementExpress(actor, orderCode, expressTypeList.get(0), expressInfoRespBo);
|
|
|
} else {
|
|
|
//设定最近一个阶段的物流
|
|
|
List<ExpressInfo> expressInfoList = getExpressInfoListByStage(actor, orderCode, expressTypeList.get(0));
|
|
|
constructExpressInfo(actor, expressInfoList, expressInfoRespBo.getExpressInfoDetailList());
|
|
|
if (EnumExpressType.EXPRESS_TYPE_2.getCode().equals(expressTypeList.get(0))) {
|
|
|
expressInfoRespBo.setExpressInfoDetailTitle("平台发往买家");
|
|
|
} else {
|
|
|
expressInfoRespBo.setExpressInfoDetailTitle("平台发往卖家");
|
|
|
}
|
|
|
|
|
|
|
|
|
//获取上一阶段的辅助物流信息
|
|
|
constructSupplementExpress(actor, orderCode, expressTypeList.get(0), expressInfoRespBo);
|
|
|
}
|
|
|
} else if (expressTypeList.size() == 3) {
|
|
|
//设定最近一个阶段的物流
|
|
|
List<ExpressInfo> expressInfoList = getExpressInfoListByStage(actor, orderCode, expressTypeList.get(0));
|
|
|
constructExpressInfo(actor, expressInfoList, expressInfoRespBo.getExpressInfoDetailList());
|
|
|
if (EnumExpressType.EXPRESS_TYPE_2.getCode().equals(expressTypeList.get(0))) {
|
|
|
expressInfoRespBo.setExpressInfoDetailTitle("平台发往买家");
|
|
|
} else {
|
|
|
expressInfoRespBo.setExpressInfoDetailTitle("平台发往卖家");
|
|
|
}
|
|
|
|
|
|
//设定鉴定的物流调拨信息
|
|
|
List<ExpressInfo> judgeExpressInfoList = getExpressInfoListByStage(actor, orderCode, EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER.getCode());
|
|
|
constructExpressInfo(actor, judgeExpressInfoList, expressInfoRespBo.getJudgeExpressInfoDetailList());
|
|
|
|
|
|
//获取上一阶段的辅助物流信息
|
|
|
constructSupplementExpress(actor, orderCode, expressTypeList.get(0), expressInfoRespBo);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
.handler(expressInfoRespBo -> {
|
|
|
//5.设定阶段的信息
|
|
|
expressInfoRespBo.setStage(new ExpressStageBuilder(actor, buyerOrder)
|
|
|
.scene(scene)
|
|
|
.isQuickShipDone(() -> Optional.ofNullable(storageDepositMapper.selectByOrderCode(orderCode))
|
|
|
.filter(e -> Objects.equals(e.getStatus(), StorageDepositStatusEnum.HAS_END.getCode()))
|
|
|
.isPresent())
|
|
|
.build());
|
|
|
})
|
|
|
.wash()
|
|
|
.build();
|
|
|
|
|
|
LOGGER.info("{}, result is {}",logTag, JSON.toJSONString(result));
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
private ExpressInfoRespBo createExpressInfoResponseDate() {
|
|
|
ExpressInfoRespBo expressInfoRespBo = new ExpressInfoRespBo();
|
|
|
expressInfoRespBo.setExpressInfoDetailTitle("");
|
|
|
expressInfoRespBo.setJudgeExpressInfoDetailTitle("平台鉴定");
|
...
|
...
|
@@ -432,91 +492,30 @@ public class ExpressInfoServiceImpl implements IExpressInfoService { |
|
|
expressInfoRespBo.setExpressInfoDetailList(Lists.newArrayList());
|
|
|
expressInfoRespBo.setJudgeExpressInfoDetailList(Lists.newArrayList());
|
|
|
expressInfoRespBo.setSupplementExpressInfoDetailList(Lists.newArrayList());
|
|
|
return expressInfoRespBo;
|
|
|
}
|
|
|
|
|
|
List<Integer> expressTypeList = getCurrentExpressType4ExpressRecord(buyerOrder.getStatus(), actor);
|
|
|
LOGGER.info("queryExpressDetailInfo getExpressType expressTypeList result = {}, uid={}, orderCode = {},actor = {} ", expressTypeList, uid, orderCode, actor);
|
|
|
if (CollectionUtils.isEmpty(expressTypeList)) {
|
|
|
LOGGER.info("queryExpressDetailInfo getExpressType expressTypeList return empty result = {}, uid={}, orderCode = {},actor = {} ", expressTypeList, uid, orderCode, actor);
|
|
|
return expressInfoRespBo;
|
|
|
}
|
|
|
|
|
|
//1.物流单号信息
|
|
|
constructWayBillInfo(orderCode, expressTypeList, expressInfoRespBo);
|
|
|
if (TabType.BUY == actor && expressInfoRespBo.getExpressType() != null
|
|
|
&& expressInfoRespBo.getExpressType().intValue() == EnumExpressType.EXPRESS_TYPE_1.getCode().intValue()) {
|
|
|
//买家不能看到卖家的物流单号
|
|
|
expressInfoRespBo.setWayBillCode("");
|
|
|
}
|
|
|
|
|
|
|
|
|
// 构造物流信息
|
|
|
if (expressTypeList.size() == 1) {
|
|
|
//设定最近一个阶段的物流
|
|
|
List<ExpressInfo> expressInfoList = getExpressInfoListByStage(actor, orderCode, expressTypeList.get(0));
|
|
|
constructExpressInfo(actor, expressInfoList, expressInfoRespBo.getExpressInfoDetailList());
|
|
|
expressInfoRespBo.setExpressInfoDetailTitle("卖家发往平台");
|
|
|
} else if (expressTypeList.size() == 2) {
|
|
|
if (EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER.getCode().intValue() == expressTypeList.get(0)) {
|
|
|
//设定鉴定的物流调拨信息
|
|
|
List<ExpressInfo> judgeExpressInfoList = getExpressInfoListByStage(actor, orderCode, EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER.getCode());
|
|
|
constructExpressInfo(actor, judgeExpressInfoList, expressInfoRespBo.getJudgeExpressInfoDetailList());
|
|
|
|
|
|
//获取上一阶段的辅助物流信息
|
|
|
constructSupplementExpress(actor, orderCode, expressTypeList.get(0), expressInfoRespBo);
|
|
|
} else {
|
|
|
//设定最近一个阶段的物流
|
|
|
List<ExpressInfo> expressInfoList = getExpressInfoListByStage(actor, orderCode, expressTypeList.get(0));
|
|
|
constructExpressInfo(actor, expressInfoList, expressInfoRespBo.getExpressInfoDetailList());
|
|
|
if (EnumExpressType.EXPRESS_TYPE_2.getCode().equals(expressTypeList.get(0))) {
|
|
|
expressInfoRespBo.setExpressInfoDetailTitle("平台发往买家");
|
|
|
} else {
|
|
|
expressInfoRespBo.setExpressInfoDetailTitle("平台发往卖家");
|
|
|
}
|
|
|
|
|
|
|
|
|
//获取上一阶段的辅助物流信息
|
|
|
constructSupplementExpress(actor, orderCode, expressTypeList.get(0), expressInfoRespBo);
|
|
|
}
|
|
|
} else if (expressTypeList.size() == 3) {
|
|
|
//设定最近一个阶段的物流
|
|
|
List<ExpressInfo> expressInfoList = getExpressInfoListByStage(actor, orderCode, expressTypeList.get(0));
|
|
|
constructExpressInfo(actor, expressInfoList, expressInfoRespBo.getExpressInfoDetailList());
|
|
|
if (EnumExpressType.EXPRESS_TYPE_2.getCode().equals(expressTypeList.get(0))) {
|
|
|
expressInfoRespBo.setExpressInfoDetailTitle("平台发往买家");
|
|
|
} else {
|
|
|
expressInfoRespBo.setExpressInfoDetailTitle("平台发往卖家");
|
|
|
}
|
|
|
|
|
|
//设定鉴定的物流调拨信息
|
|
|
List<ExpressInfo> judgeExpressInfoList = getExpressInfoListByStage(actor, orderCode, EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER.getCode());
|
|
|
constructExpressInfo(actor, judgeExpressInfoList, expressInfoRespBo.getJudgeExpressInfoDetailList());
|
|
|
private void washExpressInfoResponseDate(Integer scene, TabType actor, BuyerOrder buyerOrder, ExpressInfoRespBo expressInfoRespBo) {
|
|
|
|
|
|
//获取上一阶段的辅助物流信息
|
|
|
constructSupplementExpress(actor, orderCode, expressTypeList.get(0), expressInfoRespBo);
|
|
|
// 快速发货
|
|
|
if (ExpressScene.QUICK_SHIP.equals(scene) && actor == TabType.BUY) {
|
|
|
expressInfoRespBo.setSupplementExpressInfoDetailTitle(StringUtils.EMPTY);
|
|
|
expressInfoRespBo.setSupplementExpressInfoDetailList(Lists.newArrayList());
|
|
|
expressInfoRespBo.setJudgeExpressInfoDetailTitle(StringUtils.EMPTY);
|
|
|
expressInfoRespBo.setJudgeExpressInfoDetailList(Lists.newArrayList());
|
|
|
}
|
|
|
|
|
|
//5.设定阶段的信息
|
|
|
expressInfoRespBo.setStage(new ExpressStageBuilder(actor, buyerOrder)
|
|
|
.scene(scene)
|
|
|
.expressInfoRespBo(expressInfoRespBo)
|
|
|
.isQuickShipDone(() -> Optional.ofNullable(storageDepositMapper.selectByOrderCode(orderCode))
|
|
|
.filter(e -> Objects.equals(e.getStatus(), StorageDepositStatusEnum.HAS_END.getCode()))
|
|
|
.isPresent())
|
|
|
.build());
|
|
|
|
|
|
//鉴定阶段的物流仍然属于卖家
|
|
|
if (expressInfoRespBo.getExpressType() != null && EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER.getCode() == expressInfoRespBo.getExpressType().intValue()) {
|
|
|
if (expressInfoRespBo.getExpressType() != null
|
|
|
&& EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER.getCode() == expressInfoRespBo.getExpressType().intValue()) {
|
|
|
expressInfoRespBo.setExpressType(EnumExpressType.EXPRESS_TYPE_1.getCode().byteValue());
|
|
|
}
|
|
|
|
|
|
// 隐藏闪购订单中卖家发往平台的物流
|
|
|
if (BuyerOrderUtils.isQuickDeliver(buyerOrder)) {
|
|
|
expressInfoRespBo.setSupplementExpressInfoDetailTitle("");
|
|
|
expressInfoRespBo.setSupplementExpressInfoDetailTitle(StringUtils.EMPTY);
|
|
|
expressInfoRespBo.setSupplementExpressInfoDetailList(Collections.emptyList());
|
|
|
}
|
|
|
|
|
|
LOGGER.info("queryExpressDetailInfo result = {}", JSON.toJSONString(expressInfoRespBo));
|
|
|
return expressInfoRespBo;
|
|
|
}
|
|
|
|
|
|
private void constructSupplementExpress(TabType actor, Long orderCode, Integer expressType, ExpressInfoRespBo expressInfoRespBo) {
|
...
|
...
|
|