wechat-vendor-sdk 0.4.0

wechat miniprogram and wechat corp sdk (微信小程序、公众号和企业微信部分 sdk 封装)
Documentation
///! 小程序发货信息管理服务 API
use serde::{Deserialize, Serialize};

use crate::wxmini_api_post;

#[derive(Debug, Serialize, Deserialize)]
pub struct OrderKey {
    /// 订单单号类型,用于确认需要上传详情的订单。枚举值1,使用下单商户号和商户侧单号;枚举值2,使用微信支付单号。
    pub order_number_type: u8,
    /// 原支付交易对应的微信订单号
    pub transaction_id: Option<String>,
    /// 支付下单商户的商户号,由微信支付生成并下发。
    pub mchid: Option<String>,
    /// 商户系统内部订单号,只能是数字、大小写字母`_-*`且在同一个商户号下唯一
    pub out_trade_no: Option<String>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct Contact {
    /// 寄件人联系方式,采用掩码传输,最后4位数字不能打掩码
    pub consignor_contact: Option<String>,
    /// 收件人联系方式,采用掩码传输,最后4位数字不能打掩码
    pub receiver_contact: Option<String>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct ShippingListItem {
    /// 物流单号,物流快递发货时必填
    pub tracking_no: Option<String>,
    /// 物流公司编码,快递公司ID,物流快递发货时必填
    pub express_company: Option<String>,
    /// 商品信息,例如:微信红包抱枕*1个,限120个字以内
    pub item_desc: String,
    /// 联系方式,当发货的物流公司为顺丰时,联系方式为必填,收件人或寄件人联系方式二选一
    pub contact: Option<Contact>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct Payer {
    /// 用户标识,用户在小程序appid下的唯一标识
    pub openid: String,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct UploadShippingInfoRequestBody {
    /// 订单,需要上传物流信息的订单
    pub order_key: OrderKey,
    /// 物流模式,发货方式枚举值:1、实体物流配送采用快递公司进行实体物流配送形式 2、同城配送 3、虚拟商品,虚拟商品,例如话费充值,点卡等,无实体配送形式 4、用户自提
    pub logistics_type: u8,
    /// 发货模式,发货模式枚举值:1、UNIFIED_DELIVERY(统一发货)2、SPLIT_DELIVERY(分拆发货)
    pub delivery_mode: u8,
    /// 分拆发货模式时必填,用于标识分拆发货模式下是否已全部发货完成,只有全部发货完成的情况下才会向用户推送发货完成通知。
    pub is_all_delivered: Option<bool>,
    /// 物流信息列表,发货物流单列表,支持统一发货(单个物流单)和分拆发货(多个物流单)两种模式,多重性: [1, 15]
    pub shipping_list: Vec<ShippingListItem>,
    /// 上传时间,用于标识请求的先后顺序
    pub upload_time: String,
    /// 支付者,支付者信息
    pub payer: Payer,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct UploadShippingInfoResponseData {}

wxmini_api_post!(
    /// [发货信息录入接口](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)
    request_upload_shipping_info,
    "api.weixin.qq.com/wxa/sec/order/upload_shipping_info",
    (access_token: Option<&str>),
    &UploadShippingInfoRequestBody,
    UploadShippingInfoResponseData
);

#[derive(Debug, Serialize, Deserialize)]
pub struct SubOrder {
    /// 需要上传物流详情的子单订单,订单类型与合单订单保持一致
    pub order_key: OrderKey,
    /// 物流模式,发货方式枚举值:1、实体物流配送采用快递公司进行实体物流配送形式 2、同城配送 3、虚拟商品,虚拟商品,例如话费充值,点卡等,无实体配送形式 4、用户自提
    pub logistics_type: u8,
    /// 发货模式,发货模式枚举值:1、UNIFIED_DELIVERY(统一发货)2、SPLIT_DELIVERY(分拆发货)
    pub delivery_mode: u8,
    /// 分拆发货模式时必填,用于标识分拆发货模式下是否已全部发货完成,只有全部发货完成的情况下才会向用户推送发货完成通知。
    pub is_all_delivered: Option<bool>,
    /// 子单物流信息列表
    pub shipping_list: Option<Vec<ShippingListItem>>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct UploadCombinedShippingInfoRequestBody {
    /// 合单订单,需要上传物流详情的合单订单,根据订单类型二选一
    pub order_key: OrderKey,
    /// 子单物流详情
    pub sub_orders: Option<Vec<SubOrder>>,
    /// 上传时间,用于标识请求的先后顺序
    pub upload_time: String,
    /// 支付者,支付者信息
    pub payer: Payer,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct UploadCombinedShippingInfoResponseData {}

wxmini_api_post!(
    /// [发货信息合单录入接口](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)
    request_upload_combined_shipping_info,
    "api.weixin.qq.com/wxa/sec/order/upload_combined_shipping_info",
    (access_token: Option<&str>),
    &UploadCombinedShippingInfoRequestBody,
    UploadCombinedShippingInfoResponseData
);

#[derive(Debug, Serialize, Deserialize)]
pub struct GetOrderRequestBody {
    /// 原支付交易对应的微信订单号
    pub transaction_id: Option<String>,
    /// 支付下单商户的商户号,由微信支付生成并下发
    pub merchant_id: Option<String>,
    /// 二级商户号
    pub sub_merchant_id: Option<String>,
    /// 商户系统内部订单号,只能是数字、大小写字母`_-*`且在同一个商户号下唯一
    pub merchant_trade_no: Option<String>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct ShippingListResponseItem {
    /// 物流单号
    pub tracking_no: Option<String>,
    /// 同城配送公司名或物流公司编码,快递公司ID
    pub express_company: Option<String>,
    /// 使用上传物流信息 API 录入的该物流信息的商品描述
    pub goods_desc: Option<String>,
    /// 该物流信息的上传时间,时间戳形式
    pub upload_time: Option<i64>,
    /// 联系方式
    pub contact: Option<Contact>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct Shipping {
    /// 发货模式,发货模式枚举值:1、UNIFIED_DELIVERY(统一发货)2、SPLIT_DELIVERY(分拆发货)
    pub delivery_mode: u8,
    /// 物流模式,发货方式枚举值:1、实体物流配送采用快递公司进行实体物流配送形式 2、同城配送 3、虚拟商品,虚拟商品,例如话费充值,点卡等,无实体配送形式 4、用户自提
    pub logistics_type: u8,
    /// 是否已完成全部发货
    pub finish_shipping: bool,
    /// 在小程序后台发货信息录入页录入的商品描述
    pub goods_desc: String,
    /// 已完成全部发货的次数,未完成时为 0,完成时为 1,重新发货并完成后为 2
    pub finish_shipping_count: u8,
    /// 物流信息列表,发货物流单列表,支持统一发货(单个物流单)和分拆发货(多个物流单)两种模式
    pub shipping_list: Vec<ShippingListResponseItem>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct Order {
    /// 原支付交易对应的微信订单号
    pub transaction_id: String,
    /// 支付下单商户的商户号,由微信支付生成并下发
    pub merchant_id: String,
    /// 二级商户号
    pub sub_merchant_id: String,
    /// 商户系统内部订单号,只能是数字、大小写字母`_-*`且在同一个商户号下唯一
    pub merchant_trade_no: String,
    /// 以分号连接的该支付单的所有商品描述,当超过120字时自动截断并以 "..." 结尾
    pub description: String,
    /// 支付单实际支付金额,整型,单位:分钱
    pub paid_amount: i64,
    /// 支付者openid
    pub openid: String,
    /// 交易创建时间,时间戳形式
    pub trade_create_time: i64,
    /// 支付时间,时间戳形式
    pub pay_time: i64,
    /// 订单状态枚举:(1) 待发货;(2) 已发货;(3) 确认收货;(4) 交易完成;(5) 已退款;(6) 资金待结算
    pub order_state: u8,
    /// 是否处在交易纠纷中
    pub in_complaint: bool,
    /// 发货信息
    pub shipping: Option<Shipping>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct GetOrderResponseData {
    /// 支付单信息
    pub order: Order,
}

wxmini_api_post!(
    /// [查询订单发货状态](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)
    request_get_order_shipping_status,
    "api.weixin.qq.com/wxa/sec/order/get_order",
    (access_token: Option<&str>),
    &GetOrderRequestBody,
    GetOrderResponseData
);

#[derive(Debug, Serialize, Deserialize)]
pub struct PayTimeRange {
    /// 起始时间,时间戳形式,不填则视为从0开始
    pub begin_time: Option<i64>,
    /// 结束时间(含),时间戳形式,不填则视为32位无符号整型的最大值
    pub end_time: Option<i64>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct GetOrderListRequestBody {
    /// 支付时间所属范围
    pub pay_time_range: Option<PayTimeRange>,
    /// 订单状态枚举:(1) 待发货;(2) 已发货;(3) 确认收货;(4) 交易完成;(5) 已退款;(6) 资金待结算
    pub order_state: Option<u8>,
    /// 支付者openid
    pub openid: Option<String>,
    /// 翻页时使用,获取第一页时不用传入,如果查询结果中 has_more 字段为 true,则传入该次查询结果中返回的 last_index 字段可获取下一页
    pub last_index: Option<String>,
    /// 翻页时使用,返回列表的长度,默认为100
    pub page_size: Option<u32>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct GetOrderListResponseData {
    /// 翻页时使用
    pub last_index: String,
    /// 是否还有更多支付单
    pub has_more: bool,
    /// 支付单信息列表
    pub order_list: Vec<Order>,
}

wxmini_api_post!(
    /// [查询订单列表](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)
    request_get_order_list,
    "api.weixin.qq.com/wxa/sec/order/get_order_list",
    (access_token: Option<&str>),
    &GetOrderListRequestBody,
    GetOrderListResponseData
);

#[derive(Debug, Serialize, Deserialize)]
pub struct NotifyConfirmReceiveRequestBody {
    /// 原支付交易对应的微信订单号
    pub transaction_id: Option<String>,
    /// 支付下单商户的商户号,由微信支付生成并下发
    pub merchant_id: Option<String>,
    /// 二级商户号
    pub sub_merchant_id: Option<String>,
    /// 商户系统内部订单号,只能是数字、大小写字母`_-*`且在同一个商户号下唯一
    pub merchant_trade_no: Option<String>,
    /// 快递签收时间,时间戳形式
    pub received_time: i64,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct NotifyConfirmReceiveResponseData {}

wxmini_api_post!(
    /// [确认收货提醒接口](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)
    request_notify_confirm_receive,
    "api.weixin.qq.com/wxa/sec/order/notify_confirm_receive",
    (access_token: Option<&str>),
    &NotifyConfirmReceiveRequestBody,
    NotifyConfirmReceiveResponseData
);

#[derive(Debug, Serialize, Deserialize)]
pub struct SetMsgJumpPathRequestBody {
    /// 商户自定义跳转路径
    pub path: String,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct SetMsgJumpPathResponseData {}

wxmini_api_post!(
    /// [消息跳转路径设置接口](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)
    request_set_msg_jump_path,
    "api.weixin.qq.com/wxa/sec/order/set_msg_jump_path",
    (access_token: Option<&str>),
    &SetMsgJumpPathRequestBody,
    SetMsgJumpPathResponseData
);

#[derive(Debug, Serialize, Deserialize)]
pub struct IsTradeManagedRequestBody {
    /// 待查询小程序的 appid,非服务商调用时仅能查询本账号
    pub appid: String,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct IsTradeManagedResponseData {
    /// 是否已开通小程序发货信息管理服务
    pub is_trade_managed: Option<bool>,
}

wxmini_api_post!(
    /// [查询小程序是否已开通发货信息管理服务](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)
    request_is_trade_managed,
    "api.weixin.qq.com/wxa/sec/order/is_trade_managed",
    (access_token: Option<&str>),
    &IsTradeManagedRequestBody,
    IsTradeManagedResponseData
);

#[derive(Debug, Serialize, Deserialize)]
pub struct IsTradeManagementConfirmationCompletedRequestBody {
    /// 待查询小程序的 appid,非服务商调用时仅能查询本账号
    pub appid: String,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct IsTradeManagementConfirmationCompletedResponseData {
    pub errcode: i32,
    pub errmsg: String,
    /// 是否已完成交易结算管理确认
    pub completed: Option<bool>,
}

wxmini_api_post!(
    /// [查询小程序是否已完成交易结算管理确认](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)
    request_is_trade_management_confirmation_completed,
    "api.weixin.qq.com/wxa/sec/order/is_trade_management_confirmation_completed",
    (access_token: Option<&str>),
    &IsTradeManagementConfirmationCompletedRequestBody,
    IsTradeManagementConfirmationCompletedResponseData
);

#[derive(Debug, Serialize, Deserialize)]
pub struct OpSpecialOrderRequestBody {
    /// 需要特殊发货报备的订单号,可传入微信支付单号或商户单号
    pub order_id: String,
    /// 特殊发货报备类型,1为预售商品订单,2为测试订单
    pub r#type: u8,
    /// 预计发货时间的unix时间戳,type为1时必填,type为2可省略
    pub delay_to: Option<i64>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct OpSpecialOrderResponseData {}

wxmini_api_post!(
    /// [特殊发货报备](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)
    request_op_special_order,
    "api.weixin.qq.com/wxa/sec/order/opspecialorder",
    (access_token: Option<&str>),
    &OpSpecialOrderRequestBody,
    OpSpecialOrderResponseData
);