mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-08-20 09:28:58 +08:00
🆕 #3247 【小程序】即时配送服务增加获取运力id列表和更新物流信息的接口
This commit is contained in:
parent
ccf23a8668
commit
5977567689
@ -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;
|
||||
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析响应.
|
||||
*
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
@ -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>
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -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";
|
||||
|
||||
|
||||
/**
|
||||
* 下单接口.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user