From 5977567689c8fed902361e1689353c59721213f2 Mon Sep 17 00:00:00 2001 From: zhongjun Date: Thu, 14 Mar 2024 12:24:00 +0800 Subject: [PATCH] =?UTF-8?q?:new:=20#3247=20=E3=80=90=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E3=80=91=E5=8D=B3=E6=97=B6=E9=85=8D=E9=80=81=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96=E8=BF=90=E5=8A=9B?= =?UTF-8?q?id=E5=88=97=E8=A1=A8=E5=92=8C=E6=9B=B4=E6=96=B0=E7=89=A9?= =?UTF-8?q?=E6=B5=81=E4=BF=A1=E6=81=AF=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/WxMaImmediateDeliveryService.java | 46 ++++++++------ .../WxMaImmediateDeliveryServiceImpl.java | 22 +++++++ .../delivery/GetDeliveryListResponse.java | 61 +++++++++++++++++++ .../bean/delivery/TraceWaybillRequest.java | 10 +++ .../delivery/UpdateWaybillGoodsRequest.java | 54 ++++++++++++++++ .../bean/delivery/WaybillGoodsInfo.java | 8 +++ .../miniapp/constant/WxMaApiUrlConstants.java | 12 ++++ 7 files changed, 194 insertions(+), 19 deletions(-) create mode 100644 weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/GetDeliveryListResponse.java create mode 100644 weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/UpdateWaybillGoodsRequest.java diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaImmediateDeliveryService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaImmediateDeliveryService.java index 29df4afcd6..4d1db50726 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaImmediateDeliveryService.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaImmediateDeliveryService.java @@ -1,24 +1,7 @@ package cn.binarywang.wx.miniapp.api; -import cn.binarywang.wx.miniapp.bean.delivery.AbnormalConfirmRequest; -import cn.binarywang.wx.miniapp.bean.delivery.AbnormalConfirmResponse; -import cn.binarywang.wx.miniapp.bean.delivery.AddOrderRequest; -import cn.binarywang.wx.miniapp.bean.delivery.AddOrderResponse; -import cn.binarywang.wx.miniapp.bean.delivery.BindAccountResponse; -import cn.binarywang.wx.miniapp.bean.delivery.CancelOrderRequest; -import cn.binarywang.wx.miniapp.bean.delivery.CancelOrderResponse; -import cn.binarywang.wx.miniapp.bean.delivery.FollowWaybillRequest; -import cn.binarywang.wx.miniapp.bean.delivery.FollowWaybillResponse; -import cn.binarywang.wx.miniapp.bean.delivery.GetOrderRequest; -import cn.binarywang.wx.miniapp.bean.delivery.GetOrderResponse; -import cn.binarywang.wx.miniapp.bean.delivery.MockUpdateOrderRequest; -import cn.binarywang.wx.miniapp.bean.delivery.MockUpdateOrderResponse; -import cn.binarywang.wx.miniapp.bean.delivery.QueryFollowTraceRequest; -import cn.binarywang.wx.miniapp.bean.delivery.QueryFollowTraceResponse; -import cn.binarywang.wx.miniapp.bean.delivery.QueryWaybillTraceRequest; -import cn.binarywang.wx.miniapp.bean.delivery.QueryWaybillTraceResponse; -import cn.binarywang.wx.miniapp.bean.delivery.TraceWaybillRequest; -import cn.binarywang.wx.miniapp.bean.delivery.TraceWaybillResponse; +import cn.binarywang.wx.miniapp.bean.WxMaBaseResponse; +import cn.binarywang.wx.miniapp.bean.delivery.*; import me.chanjar.weixin.common.error.WxErrorException; /** @@ -162,5 +145,30 @@ FollowWaybillResponse followWaybill(FollowWaybillRequest request) QueryFollowTraceResponse queryFollowTrace(QueryFollowTraceRequest request) throws WxErrorException ; + /** + * 获取运力id列表get_delivery_list + * + *
+   * 商户使用此接口获取所有运力id的列表
+   * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/express_search.html
+   * 
+ * + * @return 响应 + * @throws WxErrorException 异常 + */ + GetDeliveryListResponse getDeliveryList() throws WxErrorException; + + /** + * 更新物流物品信息接口 update_waybill_goods + * + *
+   * 更新物品信息
+   * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/express_search.html
+   * 
+ * + * @return 响应 + * @throws WxErrorException 异常 + */ + WxMaBaseResponse updateWaybillGoods(UpdateWaybillGoodsRequest request) throws WxErrorException; } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaImmediateDeliveryServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaImmediateDeliveryServiceImpl.java index b6c3814f62..fa1927ffd1 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaImmediateDeliveryServiceImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaImmediateDeliveryServiceImpl.java @@ -2,10 +2,12 @@ import cn.binarywang.wx.miniapp.api.WxMaImmediateDeliveryService; import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.bean.WxMaBaseResponse; import cn.binarywang.wx.miniapp.bean.delivery.*; import cn.binarywang.wx.miniapp.bean.delivery.base.WxMaDeliveryBaseResponse; import cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants; import cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.InstantDelivery; +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import lombok.RequiredArgsConstructor; @@ -193,6 +195,26 @@ public QueryFollowTraceResponse queryFollowTrace( return response; } + @Override + public GetDeliveryListResponse getDeliveryList() throws WxErrorException { + String responseContent = this.wxMaService.post(InstantDelivery.GET_DELIVERY_LIST_URL,""); + GetDeliveryListResponse response = GetDeliveryListResponse.fromJson(responseContent); + if (response.getErrcode() == -1) { + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); + } + return response; + } + + @Override + public WxMaBaseResponse updateWaybillGoods(UpdateWaybillGoodsRequest request) throws WxErrorException { + String responseContent = this.wxMaService.post(InstantDelivery.GET_DELIVERY_LIST_URL,request); + WxMaBaseResponse response = WxMaGsonBuilder.create().fromJson(responseContent, WxMaBaseResponse.class); + if (response.getErrcode() == -1) { + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); + } + return response; + } + /** * 解析响应. * diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/GetDeliveryListResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/GetDeliveryListResponse.java new file mode 100644 index 0000000000..f760df79d0 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/GetDeliveryListResponse.java @@ -0,0 +1,61 @@ +package cn.binarywang.wx.miniapp.bean.delivery; + +import cn.binarywang.wx.miniapp.bean.WxMaBaseResponse; +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + +/** + *
+ * 获取运力id列表get_delivery_list 响应参数
+ * 
+ * + * @author zhongjun + * @since 2024-03-14 + */ +@Data +@Accessors(chain = true) +public class GetDeliveryListResponse extends WxMaBaseResponse implements Serializable { + + private static final long serialVersionUID = 7113254030347413645L; + + /** + * 运力公司个数 + */ + @SerializedName("count") + private Integer count; + + /** + * 运力公司列表 + */ + @SerializedName("delivery_list") + private List deliveryList; + + @Data + @Accessors(chain = true) + public static class DeliveryList implements Serializable { + + private static final long serialVersionUID = 2543667583406735085L; + + /** + * 运力公司 id + */ + @SerializedName("delivery_id") + private String deliveryId; + /** + * 运力公司名称 + */ + @SerializedName("delivery_name") + private String deliveryName; + + } + + + public static GetDeliveryListResponse fromJson(String json) { + return WxMaGsonBuilder.create().fromJson(json, GetDeliveryListResponse.class); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/TraceWaybillRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/TraceWaybillRequest.java index 0f929956a2..7a582ad83e 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/TraceWaybillRequest.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/TraceWaybillRequest.java @@ -58,6 +58,16 @@ public class TraceWaybillRequest implements Serializable { @SerializedName("receiver_phone") private String receiverPhone; + /** + * 运力id(运单号所属运力公司id),该字段从 get_delivery_list 获取。 + *
+   * 是否必填: 否
+   * 描述:该参数用于提高运单号识别的准确度;特别是对非主流快递公司,建议传入该参数,确保查询正确率。
+   * 
+ */ + @SerializedName("delivery_id") + private String deliveryId; + /** * 运单ID *
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/UpdateWaybillGoodsRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/UpdateWaybillGoodsRequest.java
new file mode 100644
index 0000000000..146a5ee9a6
--- /dev/null
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/UpdateWaybillGoodsRequest.java
@@ -0,0 +1,54 @@
+package cn.binarywang.wx.miniapp.bean.delivery;
+
+
+import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
+import com.google.gson.annotations.SerializedName;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 
+ * 更新物流信息接口 update_waybill_goods
+ * 
+ * + * @author zhongjun + * @since 2024-03-14 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class UpdateWaybillGoodsRequest implements Serializable { + + private static final long serialVersionUID = -8817584588925001295L; + + + + /** + * 查询id + *
+   * 是否必填: 是
+   * 
+ */ + @SerializedName("waybill_token") + private String waybillToken; + + /** + * 商品信息 + *
+   * 是否必填: 是
+   * 
+ */ + @SerializedName("goods_info") + private WaybillGoodsInfo goodsInfo; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/WaybillGoodsInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/WaybillGoodsInfo.java index 8695efec1a..a3605435a5 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/WaybillGoodsInfo.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/delivery/WaybillGoodsInfo.java @@ -54,6 +54,14 @@ public static class GoodsItem { @SerializedName("goods_img_url") private String goodsImgUrl; + /** + * 商品详情描述,不传默认取“商品名称”值,最多40汉字 + *
+     * 是否必填: 否
+     * 
+ */ + @SerializedName("goods_desc") + private String goodsDesc; } } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaApiUrlConstants.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaApiUrlConstants.java index 30fb8c2661..6c11a07373 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaApiUrlConstants.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaApiUrlConstants.java @@ -681,6 +681,18 @@ public interface InstantDelivery { */ String QUERY_FOLLOW_TRACE_URL = "https://api.weixin.qq.com/cgi-bin/express/delivery/open_msg/query_follow_trace"; + /** + * 获取运力id列表get_delivery_list + * 商户使用此接口获取所有运力id的列表 + */ + String GET_DELIVERY_LIST_URL = "https://api.weixin.qq.com/cgi-bin/express/delivery/open_msg/get_delivery_list"; + + /** + * 获取运力id列表get_delivery_list + * 商户使用此接口获取所有运力id的列表 + */ + String UPDATE_WAYBILL_GOODS_URL = "https://api.weixin.qq.com/cgi-bin/express/delivery/open_msg/update_waybill_goods"; + /** * 下单接口.