| package com.doumee.core.utils.kuaidi100; | 
|   | 
| import cn.hutool.http.HttpUtil; | 
| import com.alibaba.fastjson.JSON; | 
| import com.alibaba.fastjson.JSONObject; | 
| import com.doumee.core.constants.ResponseStatus; | 
| import com.doumee.core.exception.BusinessException; | 
| import io.swagger.util.Json; | 
| import org.apache.commons.codec.digest.DigestUtils; | 
| import org.springframework.beans.factory.annotation.Value; | 
|   | 
| import java.util.HashMap; | 
| import java.util.Map; | 
|   | 
| /** | 
|  * Created by IntelliJ IDEA. | 
|  * | 
|  * @Author : Rk | 
|  * @create 2023/4/24 14:01 | 
|  */ | 
| public class ExpressUtils { | 
|   | 
|   | 
|     private static String key = "jyAJUdnw9566"; | 
|   | 
|     private static String customer = "B0C9AC739B017E6D6AE9C6869FF56DFB"; | 
|   | 
|     private static final String POLL_QUERY_URL = "https://poll.kuaidi100.com/poll/query.do"; | 
|   | 
|     /** | 
|      * 物流信息查询  快递100 | 
|      * @param expressCode | 
|      * @param company | 
|      * @return | 
|      */ | 
|     public static DeliveryDTO queryExpress(String expressCode,String company,String phone){ | 
|         Map<String, String> param = new HashMap<>(); | 
|         //快递单号 | 
|         param.put("num", expressCode); | 
|         //是否显示路由状态信息 | 
|         param.put("resultv2","1"); | 
|         //手机号 | 
|         param.put("phone",phone); | 
|         String mgsData = JSON.toJSONString(param); | 
|         String sign= DigestUtils.md5Hex(mgsData + key + customer).toUpperCase(); | 
|         String url =POLL_QUERY_URL+"?customer="+customer+ "&sign=" +sign+ "¶m="+mgsData; | 
|         String deliveryJson = HttpUtil.get(url); | 
|         DeliveryDTO deliveryDTO = JSON.parseObject(deliveryJson, DeliveryDTO.class); | 
|         if(!deliveryDTO.getMessage().equals("ok")){ | 
|             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),deliveryDTO.getMessage()); | 
|         } | 
|         deliveryDTO.setDvyCompany(company); | 
|         deliveryDTO.setDvyFlowId(expressCode); | 
|         return deliveryDTO; | 
|     } | 
|   | 
|   | 
| } |