Skip to content

Commit 5977567

Browse files
authored
🆕 #3247 【小程序】即时配送服务增加获取运力id列表和更新物流信息的接口
1 parent ccf23a8 commit 5977567

File tree

7 files changed

+194
-19
lines changed

7 files changed

+194
-19
lines changed

weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaImmediateDeliveryService.java

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,7 @@
11
package cn.binarywang.wx.miniapp.api;
22

3-
import cn.binarywang.wx.miniapp.bean.delivery.AbnormalConfirmRequest;
4-
import cn.binarywang.wx.miniapp.bean.delivery.AbnormalConfirmResponse;
5-
import cn.binarywang.wx.miniapp.bean.delivery.AddOrderRequest;
6-
import cn.binarywang.wx.miniapp.bean.delivery.AddOrderResponse;
7-
import cn.binarywang.wx.miniapp.bean.delivery.BindAccountResponse;
8-
import cn.binarywang.wx.miniapp.bean.delivery.CancelOrderRequest;
9-
import cn.binarywang.wx.miniapp.bean.delivery.CancelOrderResponse;
10-
import cn.binarywang.wx.miniapp.bean.delivery.FollowWaybillRequest;
11-
import cn.binarywang.wx.miniapp.bean.delivery.FollowWaybillResponse;
12-
import cn.binarywang.wx.miniapp.bean.delivery.GetOrderRequest;
13-
import cn.binarywang.wx.miniapp.bean.delivery.GetOrderResponse;
14-
import cn.binarywang.wx.miniapp.bean.delivery.MockUpdateOrderRequest;
15-
import cn.binarywang.wx.miniapp.bean.delivery.MockUpdateOrderResponse;
16-
import cn.binarywang.wx.miniapp.bean.delivery.QueryFollowTraceRequest;
17-
import cn.binarywang.wx.miniapp.bean.delivery.QueryFollowTraceResponse;
18-
import cn.binarywang.wx.miniapp.bean.delivery.QueryWaybillTraceRequest;
19-
import cn.binarywang.wx.miniapp.bean.delivery.QueryWaybillTraceResponse;
20-
import cn.binarywang.wx.miniapp.bean.delivery.TraceWaybillRequest;
21-
import cn.binarywang.wx.miniapp.bean.delivery.TraceWaybillResponse;
3+
import cn.binarywang.wx.miniapp.bean.WxMaBaseResponse;
4+
import cn.binarywang.wx.miniapp.bean.delivery.*;
225
import me.chanjar.weixin.common.error.WxErrorException;
236

247
/**
@@ -162,5 +145,30 @@ FollowWaybillResponse followWaybill(FollowWaybillRequest request)
162145
QueryFollowTraceResponse queryFollowTrace(QueryFollowTraceRequest request)
163146
throws WxErrorException ;
164147

148+
/**
149+
* 获取运力id列表get_delivery_list
150+
*
151+
* <pre>
152+
* 商户使用此接口获取所有运力id的列表
153+
* 文档地址:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/express_search.html
154+
* </pre>
155+
*
156+
* @return 响应
157+
* @throws WxErrorException 异常
158+
*/
159+
GetDeliveryListResponse getDeliveryList() throws WxErrorException;
160+
161+
/**
162+
* 更新物流物品信息接口 update_waybill_goods
163+
*
164+
* <pre>
165+
* 更新物品信息
166+
* 文档地址:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/express_search.html
167+
* </pre>
168+
*
169+
* @return 响应
170+
* @throws WxErrorException 异常
171+
*/
172+
WxMaBaseResponse updateWaybillGoods(UpdateWaybillGoodsRequest request) throws WxErrorException;
165173

166174
}

weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaImmediateDeliveryServiceImpl.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
import cn.binarywang.wx.miniapp.api.WxMaImmediateDeliveryService;
44
import cn.binarywang.wx.miniapp.api.WxMaService;
5+
import cn.binarywang.wx.miniapp.bean.WxMaBaseResponse;
56
import cn.binarywang.wx.miniapp.bean.delivery.*;
67
import cn.binarywang.wx.miniapp.bean.delivery.base.WxMaDeliveryBaseResponse;
78
import cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants;
89
import cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.InstantDelivery;
10+
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
911
import com.google.gson.JsonElement;
1012
import com.google.gson.JsonObject;
1113
import lombok.RequiredArgsConstructor;
@@ -193,6 +195,26 @@ public QueryFollowTraceResponse queryFollowTrace(
193195
return response;
194196
}
195197

198+
@Override
199+
public GetDeliveryListResponse getDeliveryList() throws WxErrorException {
200+
String responseContent = this.wxMaService.post(InstantDelivery.GET_DELIVERY_LIST_URL,"");
201+
GetDeliveryListResponse response = GetDeliveryListResponse.fromJson(responseContent);
202+
if (response.getErrcode() == -1) {
203+
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
204+
}
205+
return response;
206+
}
207+
208+
@Override
209+
public WxMaBaseResponse updateWaybillGoods(UpdateWaybillGoodsRequest request) throws WxErrorException {
210+
String responseContent = this.wxMaService.post(InstantDelivery.GET_DELIVERY_LIST_URL,request);
211+
WxMaBaseResponse response = WxMaGsonBuilder.create().fromJson(responseContent, WxMaBaseResponse.class);
212+
if (response.getErrcode() == -1) {
213+
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
214+
}
215+
return response;
216+
}
217+
196218
/**
197219
* 解析响应.
198220
*
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package cn.binarywang.wx.miniapp.bean.delivery;
2+
3+
import cn.binarywang.wx.miniapp.bean.WxMaBaseResponse;
4+
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
5+
import com.google.gson.annotations.SerializedName;
6+
import lombok.Data;
7+
import lombok.experimental.Accessors;
8+
9+
import java.io.Serializable;
10+
import java.util.List;
11+
12+
/**
13+
* <pre>
14+
* 获取运力id列表get_delivery_list 响应参数
15+
* </pre>
16+
*
17+
* @author zhongjun
18+
* @since 2024-03-14
19+
*/
20+
@Data
21+
@Accessors(chain = true)
22+
public class GetDeliveryListResponse extends WxMaBaseResponse implements Serializable {
23+
24+
private static final long serialVersionUID = 7113254030347413645L;
25+
26+
/**
27+
* 运力公司个数
28+
*/
29+
@SerializedName("count")
30+
private Integer count;
31+
32+
/**
33+
* 运力公司列表
34+
*/
35+
@SerializedName("delivery_list")
36+
private List<DeliveryList> deliveryList;
37+
38+
@Data
39+
@Accessors(chain = true)
40+
public static class DeliveryList implements Serializable {
41+
42+
private static final long serialVersionUID = 2543667583406735085L;
43+
44+
/**
45+
* 运力公司 id
46+
*/
47+
@SerializedName("delivery_id")
48+
private String deliveryId;
49+
/**
50+
* 运力公司名称
51+
*/
52+
@SerializedName("delivery_name")
53+
private String deliveryName;
54+
55+
}
56+
57+
58+
public static GetDeliveryListResponse fromJson(String json) {
59+
return WxMaGsonBuilder.create().fromJson(json, GetDeliveryListResponse.class);
60+
}
61+
}

weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/TraceWaybillRequest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ public class TraceWaybillRequest implements Serializable {
5858
@SerializedName("receiver_phone")
5959
private String receiverPhone;
6060

61+
/**
62+
* 运力id(运单号所属运力公司id),该字段从 <a href='https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/express_search.html#%E8%8E%B7%E5%8F%96%E8%BF%90%E5%8A%9Bid%E5%88%97%E8%A1%A8get-delivery-list'>get_delivery_list</a> 获取。
63+
* <pre>
64+
* 是否必填: 否
65+
* 描述:该参数用于提高运单号识别的准确度;特别是对非主流快递公司,建议传入该参数,确保查询正确率。
66+
* </pre>
67+
*/
68+
@SerializedName("delivery_id")
69+
private String deliveryId;
70+
6171
/**
6272
* 运单ID
6373
* <pre>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package cn.binarywang.wx.miniapp.bean.delivery;
2+
3+
4+
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
5+
import com.google.gson.annotations.SerializedName;
6+
import lombok.AllArgsConstructor;
7+
import lombok.Builder;
8+
import lombok.Data;
9+
import lombok.NoArgsConstructor;
10+
import lombok.experimental.Accessors;
11+
12+
import java.io.Serializable;
13+
14+
/**
15+
* <pre>
16+
* 更新物流信息接口 update_waybill_goods
17+
* </pre>
18+
*
19+
* @author zhongjun
20+
* @since 2024-03-14
21+
*/
22+
@Data
23+
@Builder
24+
@NoArgsConstructor
25+
@AllArgsConstructor
26+
@Accessors(chain = true)
27+
public class UpdateWaybillGoodsRequest implements Serializable {
28+
29+
private static final long serialVersionUID = -8817584588925001295L;
30+
31+
32+
33+
/**
34+
* 查询id
35+
* <pre>
36+
* 是否必填: 是
37+
* </pre>
38+
*/
39+
@SerializedName("waybill_token")
40+
private String waybillToken;
41+
42+
/**
43+
* 商品信息
44+
* <pre>
45+
* 是否必填: 是
46+
* </pre>
47+
*/
48+
@SerializedName("goods_info")
49+
private WaybillGoodsInfo goodsInfo;
50+
51+
public String toJson() {
52+
return WxMaGsonBuilder.create().toJson(this);
53+
}
54+
}

weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/WaybillGoodsInfo.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ public static class GoodsItem {
5454
@SerializedName("goods_img_url")
5555
private String goodsImgUrl;
5656

57+
/**
58+
* 商品详情描述,不传默认取“商品名称”值,最多40汉字
59+
* <pre>
60+
* 是否必填: 否
61+
* </pre>
62+
*/
63+
@SerializedName("goods_desc")
64+
private String goodsDesc;
5765

5866
}
5967
}

weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaApiUrlConstants.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,18 @@ public interface InstantDelivery {
681681
*/
682682
String QUERY_FOLLOW_TRACE_URL = "https://api.weixin.qq.com/cgi-bin/express/delivery/open_msg/query_follow_trace";
683683

684+
/**
685+
* 获取运力id列表get_delivery_list
686+
* 商户使用此接口获取所有运力id的列表
687+
*/
688+
String GET_DELIVERY_LIST_URL = "https://api.weixin.qq.com/cgi-bin/express/delivery/open_msg/get_delivery_list";
689+
690+
/**
691+
* 获取运力id列表get_delivery_list
692+
* 商户使用此接口获取所有运力id的列表
693+
*/
694+
String UPDATE_WAYBILL_GOODS_URL = "https://api.weixin.qq.com/cgi-bin/express/delivery/open_msg/update_waybill_goods";
695+
684696

685697
/**
686698
* 下单接口.

0 commit comments

Comments
 (0)