| 
					
				 | 
			
			
				@@ -4,12 +4,18 @@ import cn.hutool.core.collection.CollUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.hutool.core.util.HexUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.hutool.crypto.digest.DigestUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.framework.common.util.json.JsonUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import cn.newfeifan.mall.module.trade.dal.dataobject.delivery.DeliveryExpressDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import cn.newfeifan.mall.module.trade.dal.dataobject.order.TradeOrderDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import cn.newfeifan.mall.module.trade.dal.mysql.delivery.DeliveryExpressMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import cn.newfeifan.mall.module.trade.dal.mysql.order.TradeOrderMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import cn.newfeifan.mall.module.trade.enums.order.TradeOrderStateEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.module.trade.framework.delivery.config.TradeExpressProperties; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.module.trade.framework.delivery.core.client.ExpressClient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.module.trade.framework.delivery.core.client.dto.kd100.Kd100ExpressQueryReqDTO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.module.trade.framework.delivery.core.client.dto.kd100.Kd100ExpressQueryRespDTO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import lombok.AllArgsConstructor; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import lombok.extern.slf4j.Slf4j; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.http.*; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -17,6 +23,8 @@ import org.springframework.util.LinkedMultiValueMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.util.MultiValueMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.web.client.RestTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import javax.annotation.Resource; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.time.LocalDateTime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.Collections; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.Objects; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -35,11 +43,22 @@ import static cn.newfeifan.mall.module.trade.framework.delivery.core.client.conv 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @AllArgsConstructor 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class Kd100ExpressClient implements ExpressClient { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public Kd100ExpressClient(RestTemplate restTemplate,TradeExpressProperties.Kd100Config config){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.restTemplate = restTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.config = config; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private static final String REAL_TIME_QUERY_URL = "https://poll.kuaidi100.com/poll/query.do"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private final RestTemplate restTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private final TradeExpressProperties.Kd100Config config; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private TradeOrderMapper tradeOrderMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private DeliveryExpressMapper deliveryExpressMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 查询快递轨迹 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -63,7 +82,33 @@ public class Kd100ExpressClient implements ExpressClient { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (CollUtil.isEmpty(respDTO.getTracks())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return Collections.emptyList(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return INSTANCE.convertList2(respDTO.getTracks()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<ExpressTrackRespDTO> expressTrackRespDTOS = INSTANCE.convertList2(respDTO.getTracks()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //如果状态为已签收("3"),则保存到订单信息中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(respDTO.getState().equals(TradeOrderStateEnum.RECEIVED.getState())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            updateOrder(respDTO.getExpressCompanyCode(),respDTO.getLogisticsNo(),expressTrackRespDTOS.get(0).getTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return expressTrackRespDTOS; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 保存订单的签收时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param com 快递公司编码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param nu 单号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void updateOrder(String com, String nu, LocalDateTime time){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        DeliveryExpressDO deliveryExpressDO = deliveryExpressMapper.selectByCode(com); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        TradeOrderDO tradeOrderDO = tradeOrderMapper.selectOne(new LambdaQueryWrapper<TradeOrderDO>() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .eq(TradeOrderDO::getLogisticsNo, nu) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .eq(TradeOrderDO::getLogisticsId, deliveryExpressDO.getId()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .isNull(TradeOrderDO::getReceivingTime) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(tradeOrderDO == null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        tradeOrderDO.setReceivingTime(time); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        tradeOrderMapper.updateById(tradeOrderDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 |