Skip to main content

wechat_vendor_sdk/wxmini/api/
order.rs

1///! 小程序发货信息管理服务 API
2use serde::{Deserialize, Serialize};
3
4use crate::wxmini_api_post;
5
6#[derive(Debug, Serialize, Deserialize)]
7pub struct OrderKey {
8    /// 订单单号类型,用于确认需要上传详情的订单。枚举值1,使用下单商户号和商户侧单号;枚举值2,使用微信支付单号。
9    pub order_number_type: u8,
10    /// 原支付交易对应的微信订单号
11    pub transaction_id: Option<String>,
12    /// 支付下单商户的商户号,由微信支付生成并下发。
13    pub mchid: Option<String>,
14    /// 商户系统内部订单号,只能是数字、大小写字母`_-*`且在同一个商户号下唯一
15    pub out_trade_no: Option<String>,
16}
17
18#[derive(Debug, Serialize, Deserialize)]
19pub struct Contact {
20    /// 寄件人联系方式,采用掩码传输,最后4位数字不能打掩码
21    pub consignor_contact: Option<String>,
22    /// 收件人联系方式,采用掩码传输,最后4位数字不能打掩码
23    pub receiver_contact: Option<String>,
24}
25
26#[derive(Debug, Serialize, Deserialize)]
27pub struct ShippingListItem {
28    /// 物流单号,物流快递发货时必填
29    pub tracking_no: Option<String>,
30    /// 物流公司编码,快递公司ID,物流快递发货时必填
31    pub express_company: Option<String>,
32    /// 商品信息,例如:微信红包抱枕*1个,限120个字以内
33    pub item_desc: String,
34    /// 联系方式,当发货的物流公司为顺丰时,联系方式为必填,收件人或寄件人联系方式二选一
35    pub contact: Option<Contact>,
36}
37
38#[derive(Debug, Serialize, Deserialize)]
39pub struct Payer {
40    /// 用户标识,用户在小程序appid下的唯一标识
41    pub openid: String,
42}
43
44#[derive(Debug, Serialize, Deserialize)]
45pub struct UploadShippingInfoRequestBody {
46    /// 订单,需要上传物流信息的订单
47    pub order_key: OrderKey,
48    /// 物流模式,发货方式枚举值:1、实体物流配送采用快递公司进行实体物流配送形式 2、同城配送 3、虚拟商品,虚拟商品,例如话费充值,点卡等,无实体配送形式 4、用户自提
49    pub logistics_type: u8,
50    /// 发货模式,发货模式枚举值:1、UNIFIED_DELIVERY(统一发货)2、SPLIT_DELIVERY(分拆发货)
51    pub delivery_mode: u8,
52    /// 分拆发货模式时必填,用于标识分拆发货模式下是否已全部发货完成,只有全部发货完成的情况下才会向用户推送发货完成通知。
53    pub is_all_delivered: Option<bool>,
54    /// 物流信息列表,发货物流单列表,支持统一发货(单个物流单)和分拆发货(多个物流单)两种模式,多重性: [1, 15]
55    pub shipping_list: Vec<ShippingListItem>,
56    /// 上传时间,用于标识请求的先后顺序
57    pub upload_time: String,
58    /// 支付者,支付者信息
59    pub payer: Payer,
60}
61#[derive(Debug, Serialize, Deserialize)]
62pub struct UploadShippingInfoResponseData {}
63
64wxmini_api_post!(
65    /// [发货信息录入接口](https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E4%B8%80%E3%80%81%E5%8F%91%E8%B4%A7%E4%BF%A1%E6%81%AF%E5%BD%95%E5%85%A5%E6%8E%A5%E5%8F%A3)
66    request_upload_shipping_info,
67    "api.weixin.qq.com/wxa/sec/order/upload_shipping_info",
68    (access_token: Option<&str>),
69    &UploadShippingInfoRequestBody,
70    UploadShippingInfoResponseData
71);
72
73#[derive(Debug, Serialize, Deserialize)]
74pub struct SubOrder {
75    /// 需要上传物流详情的子单订单,订单类型与合单订单保持一致
76    pub order_key: OrderKey,
77    /// 物流模式,发货方式枚举值:1、实体物流配送采用快递公司进行实体物流配送形式 2、同城配送 3、虚拟商品,虚拟商品,例如话费充值,点卡等,无实体配送形式 4、用户自提
78    pub logistics_type: u8,
79    /// 发货模式,发货模式枚举值:1、UNIFIED_DELIVERY(统一发货)2、SPLIT_DELIVERY(分拆发货)
80    pub delivery_mode: u8,
81    /// 分拆发货模式时必填,用于标识分拆发货模式下是否已全部发货完成,只有全部发货完成的情况下才会向用户推送发货完成通知。
82    pub is_all_delivered: Option<bool>,
83    /// 子单物流信息列表
84    pub shipping_list: Option<Vec<ShippingListItem>>,
85}
86
87#[derive(Debug, Serialize, Deserialize)]
88pub struct UploadCombinedShippingInfoRequestBody {
89    /// 合单订单,需要上传物流详情的合单订单,根据订单类型二选一
90    pub order_key: OrderKey,
91    /// 子单物流详情
92    pub sub_orders: Option<Vec<SubOrder>>,
93    /// 上传时间,用于标识请求的先后顺序
94    pub upload_time: String,
95    /// 支付者,支付者信息
96    pub payer: Payer,
97}
98#[derive(Debug, Serialize, Deserialize)]
99pub struct UploadCombinedShippingInfoResponseData {}
100
101wxmini_api_post!(
102    /// [发货信息合单录入接口](https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E4%BA%8C%E3%80%81%E5%8F%91%E8%B4%A7%E4%BF%A1%E6%81%AF%E5%90%88%E5%8D%95%E5%BD%95%E5%85%A5%E6%8E%A5%E5%8F%A3)
103    request_upload_combined_shipping_info,
104    "api.weixin.qq.com/wxa/sec/order/upload_combined_shipping_info",
105    (access_token: Option<&str>),
106    &UploadCombinedShippingInfoRequestBody,
107    UploadCombinedShippingInfoResponseData
108);
109
110#[derive(Debug, Serialize, Deserialize)]
111pub struct GetOrderRequestBody {
112    /// 原支付交易对应的微信订单号
113    pub transaction_id: Option<String>,
114    /// 支付下单商户的商户号,由微信支付生成并下发
115    pub merchant_id: Option<String>,
116    /// 二级商户号
117    pub sub_merchant_id: Option<String>,
118    /// 商户系统内部订单号,只能是数字、大小写字母`_-*`且在同一个商户号下唯一
119    pub merchant_trade_no: Option<String>,
120}
121
122#[derive(Debug, Serialize, Deserialize)]
123pub struct ShippingListResponseItem {
124    /// 物流单号
125    pub tracking_no: Option<String>,
126    /// 同城配送公司名或物流公司编码,快递公司ID
127    pub express_company: Option<String>,
128    /// 使用上传物流信息 API 录入的该物流信息的商品描述
129    pub goods_desc: Option<String>,
130    /// 该物流信息的上传时间,时间戳形式
131    pub upload_time: Option<i64>,
132    /// 联系方式
133    pub contact: Option<Contact>,
134}
135
136#[derive(Debug, Serialize, Deserialize)]
137pub struct Shipping {
138    /// 发货模式,发货模式枚举值:1、UNIFIED_DELIVERY(统一发货)2、SPLIT_DELIVERY(分拆发货)
139    pub delivery_mode: u8,
140    /// 物流模式,发货方式枚举值:1、实体物流配送采用快递公司进行实体物流配送形式 2、同城配送 3、虚拟商品,虚拟商品,例如话费充值,点卡等,无实体配送形式 4、用户自提
141    pub logistics_type: u8,
142    /// 是否已完成全部发货
143    pub finish_shipping: bool,
144    /// 在小程序后台发货信息录入页录入的商品描述
145    pub goods_desc: String,
146    /// 已完成全部发货的次数,未完成时为 0,完成时为 1,重新发货并完成后为 2
147    pub finish_shipping_count: u8,
148    /// 物流信息列表,发货物流单列表,支持统一发货(单个物流单)和分拆发货(多个物流单)两种模式
149    pub shipping_list: Vec<ShippingListResponseItem>,
150}
151
152#[derive(Debug, Serialize, Deserialize)]
153pub struct Order {
154    /// 原支付交易对应的微信订单号
155    pub transaction_id: String,
156    /// 支付下单商户的商户号,由微信支付生成并下发
157    pub merchant_id: String,
158    /// 二级商户号
159    pub sub_merchant_id: String,
160    /// 商户系统内部订单号,只能是数字、大小写字母`_-*`且在同一个商户号下唯一
161    pub merchant_trade_no: String,
162    /// 以分号连接的该支付单的所有商品描述,当超过120字时自动截断并以 "..." 结尾
163    pub description: String,
164    /// 支付单实际支付金额,整型,单位:分钱
165    pub paid_amount: i64,
166    /// 支付者openid
167    pub openid: String,
168    /// 交易创建时间,时间戳形式
169    pub trade_create_time: i64,
170    /// 支付时间,时间戳形式
171    pub pay_time: i64,
172    /// 订单状态枚举:(1) 待发货;(2) 已发货;(3) 确认收货;(4) 交易完成;(5) 已退款;(6) 资金待结算
173    pub order_state: u8,
174    /// 是否处在交易纠纷中
175    pub in_complaint: bool,
176    /// 发货信息
177    pub shipping: Option<Shipping>,
178}
179
180#[derive(Debug, Serialize, Deserialize)]
181pub struct GetOrderResponseData {
182    /// 支付单信息
183    pub order: Order,
184}
185
186wxmini_api_post!(
187    /// [查询订单发货状态](https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E4%B8%89%E3%80%81%E6%9F%A5%E8%AF%A2%E8%AE%A2%E5%8D%95%E5%8F%91%E8%B4%A7%E7%8A%B6%E6%80%81)
188    request_get_order_shipping_status,
189    "api.weixin.qq.com/wxa/sec/order/get_order",
190    (access_token: Option<&str>),
191    &GetOrderRequestBody,
192    GetOrderResponseData
193);
194
195#[derive(Debug, Serialize, Deserialize)]
196pub struct PayTimeRange {
197    /// 起始时间,时间戳形式,不填则视为从0开始
198    pub begin_time: Option<i64>,
199    /// 结束时间(含),时间戳形式,不填则视为32位无符号整型的最大值
200    pub end_time: Option<i64>,
201}
202
203#[derive(Debug, Serialize, Deserialize)]
204pub struct GetOrderListRequestBody {
205    /// 支付时间所属范围
206    pub pay_time_range: Option<PayTimeRange>,
207    /// 订单状态枚举:(1) 待发货;(2) 已发货;(3) 确认收货;(4) 交易完成;(5) 已退款;(6) 资金待结算
208    pub order_state: Option<u8>,
209    /// 支付者openid
210    pub openid: Option<String>,
211    /// 翻页时使用,获取第一页时不用传入,如果查询结果中 has_more 字段为 true,则传入该次查询结果中返回的 last_index 字段可获取下一页
212    pub last_index: Option<String>,
213    /// 翻页时使用,返回列表的长度,默认为100
214    pub page_size: Option<u32>,
215}
216
217#[derive(Debug, Serialize, Deserialize)]
218pub struct GetOrderListResponseData {
219    /// 翻页时使用
220    pub last_index: String,
221    /// 是否还有更多支付单
222    pub has_more: bool,
223    /// 支付单信息列表
224    pub order_list: Vec<Order>,
225}
226
227wxmini_api_post!(
228    /// [查询订单列表](https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E5%9B%9B%E3%80%81%E6%9F%A5%E8%AF%A2%E8%AE%A2%E5%8D%95%E5%88%97%E8%A1%A8)
229    request_get_order_list,
230    "api.weixin.qq.com/wxa/sec/order/get_order_list",
231    (access_token: Option<&str>),
232    &GetOrderListRequestBody,
233    GetOrderListResponseData
234);
235
236#[derive(Debug, Serialize, Deserialize)]
237pub struct NotifyConfirmReceiveRequestBody {
238    /// 原支付交易对应的微信订单号
239    pub transaction_id: Option<String>,
240    /// 支付下单商户的商户号,由微信支付生成并下发
241    pub merchant_id: Option<String>,
242    /// 二级商户号
243    pub sub_merchant_id: Option<String>,
244    /// 商户系统内部订单号,只能是数字、大小写字母`_-*`且在同一个商户号下唯一
245    pub merchant_trade_no: Option<String>,
246    /// 快递签收时间,时间戳形式
247    pub received_time: i64,
248}
249
250#[derive(Debug, Serialize, Deserialize)]
251pub struct NotifyConfirmReceiveResponseData {}
252
253wxmini_api_post!(
254    /// [确认收货提醒接口](https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E4%BA%94%E3%80%81%E7%A1%AE%E8%AE%A4%E6%94%B6%E8%B4%A7%E6%8F%90%E9%86%92%E6%8E%A5%E5%8F%A3)
255    request_notify_confirm_receive,
256    "api.weixin.qq.com/wxa/sec/order/notify_confirm_receive",
257    (access_token: Option<&str>),
258    &NotifyConfirmReceiveRequestBody,
259    NotifyConfirmReceiveResponseData
260);
261
262#[derive(Debug, Serialize, Deserialize)]
263pub struct SetMsgJumpPathRequestBody {
264    /// 商户自定义跳转路径
265    pub path: String,
266}
267
268#[derive(Debug, Serialize, Deserialize)]
269pub struct SetMsgJumpPathResponseData {}
270
271wxmini_api_post!(
272    /// [消息跳转路径设置接口](https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E5%85%AD%E3%80%81%E6%B6%88%E6%81%AF%E8%B7%B3%E8%BD%AC%E8%B7%AF%E5%BE%84%E8%AE%BE%E7%BD%AE%E6%8E%A5%E5%8F%A3)
273    request_set_msg_jump_path,
274    "api.weixin.qq.com/wxa/sec/order/set_msg_jump_path",
275    (access_token: Option<&str>),
276    &SetMsgJumpPathRequestBody,
277    SetMsgJumpPathResponseData
278);
279
280#[derive(Debug, Serialize, Deserialize)]
281pub struct IsTradeManagedRequestBody {
282    /// 待查询小程序的 appid,非服务商调用时仅能查询本账号
283    pub appid: String,
284}
285
286#[derive(Debug, Serialize, Deserialize)]
287pub struct IsTradeManagedResponseData {
288    /// 是否已开通小程序发货信息管理服务
289    pub is_trade_managed: Option<bool>,
290}
291
292wxmini_api_post!(
293    /// [查询小程序是否已开通发货信息管理服务](https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E4%B8%83%E3%80%81%E6%9F%A5%E8%AF%A2%E5%B0%8F%E7%A8%8B%E5%BA%8F%E6%98%AF%E5%90%A6%E5%B7%B2%E5%BC%80%E9%80%9A%E5%8F%91%E8%B4%A7%E4%BF%A1%E6%81%AF%E7%AE%A1%E7%90%86%E6%9C%8D%E5%8A%A1)
294    request_is_trade_managed,
295    "api.weixin.qq.com/wxa/sec/order/is_trade_managed",
296    (access_token: Option<&str>),
297    &IsTradeManagedRequestBody,
298    IsTradeManagedResponseData
299);
300
301#[derive(Debug, Serialize, Deserialize)]
302pub struct IsTradeManagementConfirmationCompletedRequestBody {
303    /// 待查询小程序的 appid,非服务商调用时仅能查询本账号
304    pub appid: String,
305}
306
307#[derive(Debug, Serialize, Deserialize)]
308pub struct IsTradeManagementConfirmationCompletedResponseData {
309    pub errcode: i32,
310    pub errmsg: String,
311    /// 是否已完成交易结算管理确认
312    pub completed: Option<bool>,
313}
314
315wxmini_api_post!(
316    /// [查询小程序是否已完成交易结算管理确认](https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E5%85%AB%E3%80%81%E6%9F%A5%E8%AF%A2%E5%B0%8F%E7%A8%8B%E5%BA%8F%E6%98%AF%E5%90%A6%E5%B7%B2%E5%AE%8C%E6%88%90%E4%BA%A4%E6%98%93%E7%BB%93%E7%AE%97%E7%AE%A1%E7%90%86%E7%A1%AE%E8%AE%A4)
317    request_is_trade_management_confirmation_completed,
318    "api.weixin.qq.com/wxa/sec/order/is_trade_management_confirmation_completed",
319    (access_token: Option<&str>),
320    &IsTradeManagementConfirmationCompletedRequestBody,
321    IsTradeManagementConfirmationCompletedResponseData
322);
323
324#[derive(Debug, Serialize, Deserialize)]
325pub struct OpSpecialOrderRequestBody {
326    /// 需要特殊发货报备的订单号,可传入微信支付单号或商户单号
327    pub order_id: String,
328    /// 特殊发货报备类型,1为预售商品订单,2为测试订单
329    pub r#type: u8,
330    /// 预计发货时间的unix时间戳,type为1时必填,type为2可省略
331    pub delay_to: Option<i64>,
332}
333
334#[derive(Debug, Serialize, Deserialize)]
335pub struct OpSpecialOrderResponseData {}
336
337wxmini_api_post!(
338    /// [特殊发货报备](https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E5%8D%81%E3%80%81%E7%89%B9%E6%AE%8A%E5%8F%91%E8%B4%A7%E6%8A%A5%E5%A4%87)
339    request_op_special_order,
340    "api.weixin.qq.com/wxa/sec/order/opspecialorder",
341    (access_token: Option<&str>),
342    &OpSpecialOrderRequestBody,
343    OpSpecialOrderResponseData
344);