| | |
| | | package com.ruoyi.order.service.impl; |
| | | |
| | | import com.alibaba.nacos.shaded.com.google.gson.Gson; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.kuaidi100.sdk.request.QueryTrackParam; |
| | | import com.kuaidi100.sdk.request.QueryTrackReq; |
| | | import com.kuaidi100.sdk.utils.SignUtils; |
| | | import com.ruoyi.order.mapper.LogisticsMapper; |
| | | import com.ruoyi.order.service.ILogisticsService; |
| | | import com.ruoyi.system.api.domain.Logistics; |
| | | import com.ruoyi.system.api.domain.dto.LogisticsDTO; |
| | | import com.ruoyi.system.api.domain.vo.Express100VO; |
| | | import com.kuaidi100.sdk.core.IBaseClient; |
| | | import com.kuaidi100.sdk.pojo.HttpResult; |
| | | import com.kuaidi100.sdk.api.QueryTrack; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | |
| | | public class LogisticsServiceImpl extends ServiceImpl<LogisticsMapper, Logistics> implements |
| | | ILogisticsService { |
| | | |
| | | private String key="BltjQodT7186"; |
| | | private String customer="56DE8E9E3D58CE73C60755C8B7483043"; |
| | | |
| | | |
| | | |
| | | @Override |
| | | public Express100VO getLogisticsList(LogisticsDTO logisticsDTO) { |
| | | QueryTrackReq queryTrackReq = new QueryTrackReq(); |
| | | QueryTrackParam queryTrackParam = new QueryTrackParam(); |
| | | queryTrackParam.setCom(logisticsDTO.getCompany()); |
| | | queryTrackParam.setNum(logisticsDTO.getPostid()); |
| | | String param = new Gson().toJson(queryTrackParam); |
| | | |
| | | queryTrackReq.setParam(param); |
| | | queryTrackReq.setCustomer(customer); |
| | | queryTrackReq.setSign(SignUtils.querySign(param ,key,customer)); |
| | | |
| | | IBaseClient baseClient = new QueryTrack(); |
| | | HttpResult execute = null; |
| | | try { |
| | | execute = baseClient.execute(queryTrackReq); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | // 对返回的数据进行反序列化处理 |
| | | Gson gson = new Gson(); |
| | | String responseBody = execute.getBody(); |
| | | Express100VO response = gson.fromJson(responseBody, Express100VO.class); |
| | | return response; |
| | | } |
| | | } |