怎么用SpringBoot实现快递物流查询
发表于:2024-10-01 作者:千家信息网编辑
千家信息网最后更新 2024年10月01日,本篇内容介绍了"怎么用SpringBoot实现快递物流查询"的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所
千家信息网最后更新 2024年10月01日怎么用SpringBoot实现快递物流查询
本篇内容介绍了"怎么用SpringBoot实现快递物流查询"的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
快递物流查询
注:需要购买快递物流查询接口服务获取AppCode
工具类
其中http请求工具类自行查看demo源码
@Slf4jpublic class LogisticUtil { /** * 查询物流信息 * * @param params 提交参数 * @return 物流信息 * @author zhengqingya * @date 2021/10/23 10:48 下午 */ public static LogisticVO getLogisticInfo(LogisticDTO params) { String no = params.getNo(); String type = params.getType(); String appCode = params.getAppCode(); // 请求地址 String requestUrl = String.format("https://kdwlcxf.market.alicloudapi.com/kdwlcx?no=%s&type=%s", no, StringUtils.isBlank(type) ? "" : type); // 发起请求 MapheaderMap = Maps.newHashMap(); headerMap.put("Authorization", String.format("APPCODE %s", appCode)); String resultJson = HttpUtil.getUrl(requestUrl, headerMap); LogisticApiResult logisticApiResult = JSON.parseObject(resultJson, LogisticApiResult.class); Assert.notNull(logisticApiResult, "参数异常"); Assert.isTrue(logisticApiResult.getStatus() == 0, logisticApiResult.getMsg()); return logisticApiResult.getResult(); }}
请求实体类
@Data@SuperBuilder@NoArgsConstructor@AllArgsConstructor@ApiModel("物流-查询参数")public class LogisticDTO { @ApiModelProperty(value = "快递单号 【顺丰请输入运单号 : 收件人或寄件人手机号后四位。例如:123456789:1234】", required = true, example = "780098068058") private String no; @ApiModelProperty(value = "快递公司代码: 可不填自动识别,填了查询更快【代码见附表】", required = true, example = "zto") private String type; @ApiModelProperty(value = "appCode", required = true, example = "xxx") private String appCode;}
响应实体类
@Data@Builder@NoArgsConstructor@AllArgsConstructor@ApiModel("物流-api响应结果")public class LogisticApiResult { @ApiModelProperty("状态码") private Integer status; @ApiModelProperty("提示信息") private String msg; @ApiModelProperty("结果集") private LogisticVO result;}
@Data@Builder@NoArgsConstructor@AllArgsConstructor@ApiModel("物流-响应参数")public class LogisticVO { @ApiModelProperty("运单编号") private String number; @ApiModelProperty("快递公司编码[见附表]") private String type; @ApiModelProperty("投递状态 0快递收件(揽件)1在途中 2正在派件 3已签收 4派送失败 5.疑难件 6.退件签收") private String deliverystatus; @ApiModelProperty("是否本人签收") private String issign; @ApiModelProperty("快递公司名字") private String expName; @ApiModelProperty("快递公司官网") private String expSite; @ApiModelProperty("快递公司电话") private String expPhone; @ApiModelProperty("快递员") private String courier; @ApiModelProperty("快递员电话") private String courierPhone; @ApiModelProperty("最新轨迹的时间") private String updateTime; @ApiModelProperty("发货到收货耗时(截止最新轨迹)") private String takeTime; @ApiModelProperty("快递公司logo") private String logo; @ApiModelProperty("事件轨迹集") private Listlist; @Data @Builder @NoArgsConstructor @AllArgsConstructor @ApiModel("事件轨迹集") public static class LogisticItem { @ApiModelProperty("时间点") private String time; @ApiModelProperty("事件详情") private String status; }}
测试api
@Slf4j@RestController@RequestMapping("/test")@Api(tags = "测试api")public class TestController { @ApiOperation("查询物流信息") @GetMapping("getLogistic") public LogisticVO getLogistic(@ModelAttribute LogisticDTO params) { return LogisticUtil.getLogisticInfo(params); }}
接口文档 http://127.0.0.1/doc.html
"怎么用SpringBoot实现快递物流查询"的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注网站,小编将为大家输出更多高质量的实用文章!
快递
物流
查询
公司
信息
参数
轨迹
事件
代码
内容
单号
实体
工具
接口
时间
更多
状态
电话
知识
结果
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
服务器如何设置vps管理
国家网络安全宣传周成立背景
奉贤区企业软件开发哪家好
ASP代码软件开发
数据库id应该设置多长
asp从数据库读取数据
平顶山软件开发招聘
数据库属性值的约束
服务器内存对网速的影响
大专的计算机网络技术学什么
长沙计算机网络技术学费多少
佛山app软件开发订制
成都erp软件开发公司排名
网络安全教案幼儿园中班
后台管理服务器系统
预激综合征软件开发
一般人软件开发专票税点多少
服务器维修专员
脉动测速软件开发
怎么筛选两组不同数据库
网络安全手抄报上面该写什么字
软件开发失败了怎么做账
软件开发生意好吗
学校网络安全预案及流程
非关系型数据库适合处理
我的世界帝王服务器
软件开发第三方银行接口
软件开发win7
数据库设计入门经典 下载
两会网络安全成关注焦点