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

This commit is contained in:
zhongjun 2024-03-14 12:24:00 +08:00 committed by GitHub
parent ccf23a8668
commit 5977567689
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 194 additions and 19 deletions

View File

@ -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 @@ public interface WxMaImmediateDeliveryService {
QueryFollowTraceResponse queryFollowTrace(QueryFollowTraceRequest request)
throws WxErrorException ;
/**
* 获取运力id列表get_delivery_list
*
* <pre>
* 商户使用此接口获取所有运力id的列表
* 文档地址https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/express_search.html
* </pre>
*
* @return 响应
* @throws WxErrorException 异常
*/
GetDeliveryListResponse getDeliveryList() throws WxErrorException;
/**
* 更新物流物品信息接口 update_waybill_goods
*
* <pre>
* 更新物品信息
* 文档地址https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/express_search.html
* </pre>
*
* @return 响应
* @throws WxErrorException 异常
*/
WxMaBaseResponse updateWaybillGoods(UpdateWaybillGoodsRequest request) throws WxErrorException;
}

View File

@ -2,10 +2,12 @@ package cn.binarywang.wx.miniapp.api.impl;
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 class WxMaImmediateDeliveryServiceImpl implements WxMaImmediateDeliverySe
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;
}
/**
* 解析响应.
*

View File

@ -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;
/**
* <pre>
* 获取运力id列表get_delivery_list 响应参数
* </pre>
*
* @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> 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);
}
}

View File

@ -58,6 +58,16 @@ public class TraceWaybillRequest implements Serializable {
@SerializedName("receiver_phone")
private String receiverPhone;
/**
* 运力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> 获取
* <pre>
* 是否必填
* 描述该参数用于提高运单号识别的准确度特别是对非主流快递公司建议传入该参数确保查询正确率
* </pre>
*/
@SerializedName("delivery_id")
private String deliveryId;
/**
* 运单ID
* <pre>

View File

@ -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;
/**
* <pre>
* 更新物流信息接口 update_waybill_goods
* </pre>
*
* @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
* <pre>
* 是否必填
* </pre>
*/
@SerializedName("waybill_token")
private String waybillToken;
/**
* 商品信息
* <pre>
* 是否必填
* </pre>
*/
@SerializedName("goods_info")
private WaybillGoodsInfo goodsInfo;
public String toJson() {
return WxMaGsonBuilder.create().toJson(this);
}
}

View File

@ -54,6 +54,14 @@ public class WaybillGoodsInfo implements Serializable {
@SerializedName("goods_img_url")
private String goodsImgUrl;
/**
* 商品详情描述不传默认取商品名称最多40汉字
* <pre>
* 是否必填
* </pre>
*/
@SerializedName("goods_desc")
private String goodsDesc;
}
}

View File

@ -681,6 +681,18 @@ public class WxMaApiUrlConstants {
*/
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";
/**
* 下单接口.