Authored by mali

Merge branch 'test6.8.4' of http://git.yoho.cn/ufo/ufo-platform into test6.8.4

@@ -12,4 +12,6 @@ import com.yoho.order.model.ExpressInfo; @@ -12,4 +12,6 @@ import com.yoho.order.model.ExpressInfo;
12 public interface ExpressInfoMapper { 12 public interface ExpressInfoMapper {
13 13
14 List<ExpressInfo> selectByOrderCodeAndType(@Param("orderCode") String orderCode, @Param("expressTypeList") List<Integer> expressTypeList); 14 List<ExpressInfo> selectByOrderCodeAndType(@Param("orderCode") String orderCode, @Param("expressTypeList") List<Integer> expressTypeList);
  15 +
  16 + List<ExpressInfo> selectExpressInfoListByWaybillCodeAndLogisticsType(@Param("waybillCode") String waybillCode, @Param("logisticsType") Integer logisticsType);
15 } 17 }
@@ -32,5 +32,12 @@ @@ -32,5 +32,12 @@
32 </foreach> 32 </foreach>
33 </if> 33 </if>
34 </select> 34 </select>
  35 +
  36 + <select id="selectExpressInfoListByWaybillCodeAndLogisticsType" resultMap="BaseResultMap">
  37 + SELECT <include refid="Base_Column_List" />
  38 + FROM express_info
  39 + where waybill_code = #{waybillCode} and logistics_type = #{logisticsType}
  40 + ORDER BY create_time
  41 + </select>
35 42
36 </mapper> 43 </mapper>
@@ -10,6 +10,7 @@ import java.util.Set; @@ -10,6 +10,7 @@ import java.util.Set;
10 import java.util.concurrent.TimeUnit; 10 import java.util.concurrent.TimeUnit;
11 import java.util.stream.Collectors; 11 import java.util.stream.Collectors;
12 12
  13 +import com.alibaba.fastjson.JSON;
13 import org.apache.commons.collections.CollectionUtils; 14 import org.apache.commons.collections.CollectionUtils;
14 import org.apache.commons.lang3.StringUtils; 15 import org.apache.commons.lang3.StringUtils;
15 import org.elasticsearch.common.collect.Lists; 16 import org.elasticsearch.common.collect.Lists;
@@ -600,7 +601,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { @@ -600,7 +601,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
600 601
601 public List<ExpressInfoResp> queryExpressList(String orderCode, String expressType) { 602 public List<ExpressInfoResp> queryExpressList(String orderCode, String expressType) {
602 LOGGER.info("queryExpressList orderCode is {}, expressTypeStr is {}", orderCode, expressType); 603 LOGGER.info("queryExpressList orderCode is {}, expressTypeStr is {}", orderCode, expressType);
603 - List<ExpressInfo> list = expressInfoMapper.selectByOrderCodeAndType(orderCode, convertExpressType(expressType)); 604 + List<ExpressInfo> list = getExpressInfoListByStage(orderCode, expressType);
604 if(CollectionUtils.isEmpty(list)) { 605 if(CollectionUtils.isEmpty(list)) {
605 return Lists.newArrayList(); 606 return Lists.newArrayList();
606 } 607 }
@@ -621,6 +622,40 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { @@ -621,6 +622,40 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
621 622
622 return respList; 623 return respList;
623 } 624 }
  625 +
  626 + private List<ExpressInfo> getExpressInfoListByStage(String orderCode, String expressType){
  627 + LOGGER.info("getExpressInfoListByStage orderCode is {}, expressTypeStr is {}", orderCode, expressType);
  628 + List<String> orderCodeList = Lists.newArrayList();
  629 + orderCodeList.add(orderCode);
  630 + List<ExpressRecord> records = expressRecordMapper.selectByOrderCodeListAndType(orderCodeList,convertExpressType(expressType));
  631 + if(CollectionUtils.isEmpty(records)) {
  632 + LOGGER.info("getExpressInfoListByStage records is empty , orderCode is {}, expressTypeStr is {}", orderCode, expressType);
  633 + return Lists.newArrayList();
  634 + }
  635 +
  636 + ExpressRecord record = records.get(0);
  637 + LOGGER.info("getExpressInfoListByStage begin , orderCode = {} ,expressType = {}, expressRecord = {} ",orderCode,expressType,record);
  638 + String waybillCode = record.getWaybillCode();
  639 + Integer logisticsType = record.getLogisticsType();
  640 +
  641 + //原来的情况,根据订单号直接查询物流,如果存在物流信息,则直接返回,否则有可能是多单一号
  642 + List<ExpressInfo> list = expressInfoMapper.selectByOrderCodeAndType(orderCode, convertExpressType(expressType));
  643 +
  644 + //有可能存在一个订单号,多个物流的情况,比如原来的物流填错了,修改了新的物流,只保留新的物流号的信息
  645 + if(CollectionUtils.isNotEmpty(list)){
  646 + list = list.stream().filter(info -> StringUtils.equals(waybillCode,info.getWaybillCode())).collect(Collectors.toList());
  647 + }
  648 +
  649 + if(CollectionUtils.isNotEmpty(list)) {
  650 + LOGGER.info("getExpressInfoListByStage success have data in express info orderCode = {} ,expressType = {} ",orderCode,expressType);
  651 + return list;
  652 + }
  653 +
  654 + LOGGER.info("getExpressInfoListByStage orderCode is {}, expressTypeStr is {},records size is {} ,records is {}", orderCode, expressType , records.size(),JSON.toJSONString(records));
  655 +
  656 + List<ExpressInfo> expressInfoList = expressInfoMapper.selectExpressInfoListByWaybillCodeAndLogisticsType(waybillCode,logisticsType);
  657 + return expressInfoList;
  658 + }
624 659
625 public List<OrderOperateRecordResp> queryOperateRecordList(BuyerOrderReq req){ 660 public List<OrderOperateRecordResp> queryOperateRecordList(BuyerOrderReq req){
626 if(null == req.getOrderCode()) { 661 if(null == req.getOrderCode()) {