java对接顺丰(丰桥)官⽅接⼝查询物流附⼩程序物流模板
java对接顺丰接⼝查询物流
前提
丰桥是没有客服的,旁边的客服和都是摆设,“同性交友会”罢了
值得⼀提的是,必须按照他的类型写 不然会有问题,后续补充问题
我写的如下,还需要官⽅提供的jar
final String CLIENT_CODE ="o";//此处替换为您在丰桥平台获取的顾客编码
final String CHECK_WORD ="o";//此处替换为您在丰桥平台获取的校验码
EspServiceCode testService = EspServiceCode.EXP_RECE_SEARCH_ROUTES;//查路由
final String CALL_URL_PROD ="sfapi.sf-express/std/service";
CallExpressServiceTools Instance();
Map<String, String> params =new HashMap<String, String>();
String timeStamp = String.valueOf(System.currentTimeMillis());
String msgData ="{\"trackingNumber\":[\"SF"+id+"\"],\"checkPhoneNo\":\""+phone+"\"}";//⽆⽉结卡号通过运单和⼿机后4位即可
params.put("partnerID", CLIENT_CODE);// 顾客编码,对应丰桥上获取的clientCode
params.put("requestID", UUID.randomUUID().toString().replace("-",""));
params.put("serviceCode",Code());// 接⼝服务码
params.put("timestamp", timeStamp);
params.put("msgData", msgData);
params.put("msgDigest", MsgDigest(msgData,timeStamp,CHECK_WORD));
long startTime = System.currentTimeMillis();
System.out.println("====调⽤请求:"+ ("msgData"));
String result = HttpClientUtil.post(CALL_URL_PROD, params);
System.out.println("====调⽤丰桥的接⼝服务代码:"+ String.Code())+" 接⼝耗时:"+ String.valueOf(System.currentTimeMillis()-s tartTime)+"====");
System.out.println("===调⽤地址 ==="+CALL_URL_PROD);
System.out.println("===顾客编码 ==="+CLIENT_CODE);
System.out.println("===返回结果:"+result);
问题
这个接⼝服务码必须这么写,如果直接写成 String 类型 会提⽰你没有服务权限 属实拉胯
最后,他返回的Json 是个套中套格式,我也细⼼的帮各位贴出
System.out.println("===返回结果:"+result);
String apiResultData = String("apiResultData");
System.out.println("========="+apiResultData+"============");
String msg = String("msgData");
System.out.println("msgdata"+msg);
String routeResps = String("routeResps");
System.out.println("routeResps"+String());
最后⼤致是这么个内容
routeResps[{"mailNo":"SF1334711867349","routes":[
{"acceptAddress":"上海市","acceptTime":"2021-01-30 11:20:22","remark":"顺丰速运已收取快件","opCode":"50"},
{"acceptAddress":"上海市","acceptTime":"2021-01-30 16:29:16","remark":"快件在【上海青浦⾹花桥营业部】完成分拣,准备发往【苏州千灯中转场】","opCo de":"30"},
{"acceptAddress":"⼴州市","acceptTime":"2021-02-01 12:18:34","remark":"在官⽹\"运单资料&签收图\",可查看签收⼈信息","opCode":"8000"}]}]
最后的最后,还帮⼤家贴出⼩程序的物流模板
效果如图
代码
<template>
<view class="shipping">
<view v-if="list.length==0">未发货或⼿机号单号错误</view>
<view class="linehh" v-if="list.length>0":></view>
<view class="ul" v-for="(item,index) in list":key="index">
<view class="li">
<view class="time">
<text class="timeday">{{item.day}}</text>
<text class="timeh">{{item.time}}</text>
</view>
<view class="mmmm">
<view class="yuan ":class="{act:index==0||index == list.length-1,first:index==0,end:index==list.length-1}">
</view>
</view>
<view class="desc":class="{black:index==0||index == list.length-1}"> <text>{{item.desc}}</text>
</view>
</view>
</view>
<!--<view class="btn" @click="">分享</view>-->
</view>
</view>
</template>
<script>
import{ wuliu }from'../../api/index'
export default{
data(){
return{
id:0,
phone:0,
xiantiaoHeight:0,
xiantiaoLeft:0,
xiantiaoTop:0,
list:[],
wuliuList:{
time:'',
day:'',
desc:''
},
onLoad(options){
var that =this;
setTimeout(function(){
},2000)
this.id = options.id
this.phone = options.phone
console.log(this.id+"3333333333")
this.chaxun()
},
onShareAppMessage(){},//⼩程序分享
methods:{
getHeight(){
const query = ateSelectorQuery();
query.select('.first').boundingClientRect()
query.select('.end').boundingClientRect()
var that =this;
<(function(res){
console.log(res);
var xiantiaoHeight =0;
if(res[1]!==null){
xiantiaoHeight =(res[1].top - res[0].top);
}
console.log(res[0].left);
console.log(res[0].top);
console.log(xiantiaoHeight);
that.xiantiaoHeight=xiantiaoHeight;
that.xiantiaoLeft= res[0].left +4;
that.xiantiaoTop= res[0].top;
})
},
async chaxun(){
var that =this
let json =await wuliu({
id : that.id,
phone :that.phone
})
this.list = json
this.list =this.list[0].routes
console.log(this.list)
for(var i =0; i <this.list.length; i++){
var day =this.list[i].acceptTime
var date = day.substring(5,10)
var time = day.substring(11,16)
var desc =this.list[i].remark
this.list[i].day = date
this.list[i].time = time
this.list[i].desc = desc
}
console.log(this.list)
</script>
<style lang="scss">
page {
background:rgba(246,246,246,1);
padding-bottom:120upx;
font-family: PingFang SC;
letter-spacing:0.30000001192092896px;
}
/
/ 物流列表
.shipping {
width:94%;
margin:0 auto;
background-color: #ffffff;
padding:30upx;
margin-top:20upx;
border-radius:10upx;
.linehh {
position: absolute;
width:2upx;
border-left:2upx dotted rgba(176,177,183,1);
}
.ul {
.li {
width:100%;
display: flex;
height: auto;
margin-top:2upx;
// .time:before {
//  /* 流程点的样式 */
//  content: '';
/
/  border: 3upx solid $base-color;
//  background-color: $base-color;
//  display: inline-block;
制作查询类小程序//  width: 16upx;
//  height: 16upx;
//  border-radius: 10upx;
//  margin-left: 120upx;
//  margin-right: 0upx
// }
.time {
width:16%;
padding:20upx 0upx;
display: flex;
flex-direction: column;
align-items: center;
font-family: PingFang SC;
font-weight: bold;
color:rgba(176,177,183,1);
.timeday {
font-size:28upx;
}
.timeh {
font-size:24upx;
}
}
.mmmm {
position: relative;
width:10%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
.yuan {
position: absolute;
left:20upx;
width:20rpx;
height:20rpx;
background: #dedede;
border-radius:50%;
border:3rpx solid #f2f2f2;
&.act{
background-color: #FD2E6F;
}
}
}
.desc {
width:74%;
padding:20upx 0upx;
margin-left:20upx;
font-size:28upx;
font-weight:500;
color:rgba(176,177,183,1);
&.black{
color:rgba(34,36,49,1);;
}
text {}
}
}
}
}
</style>

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。