diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteChannelsExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteChannelsExtensions.cs index ded5c0e9..1f02863d 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteChannelsExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteChannelsExtensions.cs @@ -117,6 +117,48 @@ namespace SKIT.FlurlHttpClient.Wechat.Api } #endregion + #region OrderDelivery + /// + /// 异步调用 [POST] /channels/ec/order/deliverycompanylist/get 接口。 + /// REF: https://developers.weixin.qq.com/doc/channels/API/order/deliverycompanylist_get.html + /// + /// + /// + /// + /// + public static async Task ExecuteChannelsECOrderDeliveryCompanyListGetAsync(this WechatApiClient client, Models.ChannelsECOrderDeliveryCompanyListGetRequest request, CancellationToken cancellationToken = default) + { + if (client is null) throw new ArgumentNullException(nameof(client)); + if (request is null) throw new ArgumentNullException(nameof(request)); + + IFlurlRequest flurlReq = client + .CreateRequest(request, HttpMethod.Post, "channels", "ec", "order", "deliverycompanylist", "get") + .SetQueryParam("access_token", request.AccessToken); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } + + /// + /// 异步调用 [POST] /channels/ec/order/delivery/send 接口。 + /// REF: https://developers.weixin.qq.com/doc/channels/API/order/delivery_send.html + /// + /// + /// + /// + /// + public static async Task ExecuteChannelsECOrderDeliverySendAsync(this WechatApiClient client, Models.ChannelsECOrderDeliverySendRequest request, CancellationToken cancellationToken = default) + { + if (client is null) throw new ArgumentNullException(nameof(client)); + if (request is null) throw new ArgumentNullException(nameof(request)); + + IFlurlRequest flurlReq = client + .CreateRequest(request, HttpMethod.Post, "channels", "ec", "order", "delivery", "send") + .SetQueryParam("access_token", request.AccessToken); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } + #endregion + #region ECWindow /// /// 异步调用 [POST] /channels/ec/window/product/add 接口。 diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECOrderDelivery/ChannelsECOrderDeliveryCompanyListGetRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECOrderDelivery/ChannelsECOrderDeliveryCompanyListGetRequest.cs new file mode 100644 index 00000000..69078b0f --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECOrderDelivery/ChannelsECOrderDeliveryCompanyListGetRequest.cs @@ -0,0 +1,9 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /channels/ec/order/deliverycompanylist/get 接口的请求。 + /// + public class ChannelsECOrderDeliveryCompanyListGetRequest : WechatApiRequest, IInferable + { + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECOrderDelivery/ChannelsECOrderDeliveryCompanyListGetResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECOrderDelivery/ChannelsECOrderDeliveryCompanyListGetResponse.cs new file mode 100644 index 00000000..9e228987 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECOrderDelivery/ChannelsECOrderDeliveryCompanyListGetResponse.cs @@ -0,0 +1,35 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /channels/ec/order/deliverycompanylist/get 接口的响应。 + /// + public class ChannelsECOrderDeliveryCompanyListGetResponse : WechatApiResponse + { + public static class Types + { + public class DeliveryCompany + { + /// + /// 获取或设置快递公司 ID。 + /// + [Newtonsoft.Json.JsonProperty("delivery_id")] + [System.Text.Json.Serialization.JsonPropertyName("delivery_id")] + public string DeliveryId { get; set; } = default!; + + /// + /// 获取或设置快递公司名称。 + /// + [Newtonsoft.Json.JsonProperty("delivery_name")] + [System.Text.Json.Serialization.JsonPropertyName("delivery_name")] + public string DeliveryName { get; set; } = default!; + } + } + + /// + /// 获取或设置快递公司列表。 + /// + [Newtonsoft.Json.JsonProperty("company_list")] + [System.Text.Json.Serialization.JsonPropertyName("company_list")] + public Types.DeliveryCompany[] DeliveryCompanyList { get; set; } = default!; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECOrderDelivery/ChannelsECOrderDeliverySendRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECOrderDelivery/ChannelsECOrderDeliverySendRequest.cs new file mode 100644 index 00000000..40854653 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECOrderDelivery/ChannelsECOrderDeliverySendRequest.cs @@ -0,0 +1,85 @@ +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /channels/ec/order/delivery/send 接口的请求。 + /// + public class ChannelsECOrderDeliverySendRequest : WechatApiRequest, IInferable + { + public static class Types + { + public class Delivery + { + public static class Types + { + public class Product + { + /// + /// 获取或设置商品 ID。 + /// + [Newtonsoft.Json.JsonProperty("product_id")] + [System.Text.Json.Serialization.JsonPropertyName("product_id")] + public long ProductId { get; set; } + + /// + /// 获取或设置 SKU ID。 + /// + [Newtonsoft.Json.JsonProperty("sku_id")] + [System.Text.Json.Serialization.JsonPropertyName("sku_id")] + public long SKUId { get; set; } + + /// + /// 获取或设置商品数量。 + /// + [Newtonsoft.Json.JsonProperty("product_cnt")] + [System.Text.Json.Serialization.JsonPropertyName("product_cnt")] + public int Count { get; set; } + } + } + + /// + /// 获取或设置快递公司 ID。 + /// + [Newtonsoft.Json.JsonProperty("delivery_id")] + [System.Text.Json.Serialization.JsonPropertyName("delivery_id")] + public string DeliveryId { get; set; } = string.Empty; + + /// + /// 获取或设置快递单号。 + /// + [Newtonsoft.Json.JsonProperty("waybill_id")] + [System.Text.Json.Serialization.JsonPropertyName("waybill_id")] + public string? WaybillId { get; set; } + + /// + /// 获取或设置发货方式。 + /// + [Newtonsoft.Json.JsonProperty("deliver_type")] + [System.Text.Json.Serialization.JsonPropertyName("deliver_type")] + public int DeliverType { get; set; } + + /// + /// 获取或设置商品列表。 + /// + [Newtonsoft.Json.JsonProperty("product_infos")] + [System.Text.Json.Serialization.JsonPropertyName("product_infos")] + public IList ProductList { get; set; } = new List(); + } + } + + /// + /// 获取或设置订单 ID。 + /// + [Newtonsoft.Json.JsonProperty("order_id")] + [System.Text.Json.Serialization.JsonPropertyName("order_id")] + public long OrderId { get; set; } + + /// + /// 获取或设置快递列表。 + /// + [Newtonsoft.Json.JsonProperty("delivery_list")] + [System.Text.Json.Serialization.JsonPropertyName("delivery_list")] + public IList DeliveryList { get; set; } = new List(); + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECOrderDelivery/ChannelsECOrderDeliverySendResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECOrderDelivery/ChannelsECOrderDeliverySendResponse.cs new file mode 100644 index 00000000..0f45c24e --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECOrderDelivery/ChannelsECOrderDeliverySendResponse.cs @@ -0,0 +1,9 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /channels/ec/order/delivery/send 接口的响应。 + /// + public class ChannelsECOrderDeliverySendResponse : WechatApiResponse + { + } +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Channels/ECOrderDelivery/ChannelsECOrderDeliveryCompanyListGetResponse.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Channels/ECOrderDelivery/ChannelsECOrderDeliveryCompanyListGetResponse.json new file mode 100644 index 00000000..6dcc80a8 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Channels/ECOrderDelivery/ChannelsECOrderDeliveryCompanyListGetResponse.json @@ -0,0 +1,18 @@ +{ + "errcode": 0, + "errmsg": "ok", + "company_list": [ + { + "delivery_id": "SF", + "delivery_name": "顺丰速运" + }, + { + "delivery_id": "YTO", + "delivery_name": "圆通快速" + }, + { + "delivery_id": "ZTO", + "delivery_name": "中通快速" + } + ] +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Channels/ECOrderDelivery/ChannelsECOrderDeliverySendRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Channels/ECOrderDelivery/ChannelsECOrderDeliverySendRequest.json new file mode 100644 index 00000000..9f64ba61 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Channels/ECOrderDelivery/ChannelsECOrderDeliverySendRequest.json @@ -0,0 +1,17 @@ +{ + "order_id": "123456", + "delivery_list": [ + { + "delivery_id": "YD", + "waybill_id": "23424324253", + "deliver_type": 1, + "product_infos": [ + { + "product_cnt": 1, + "product_id": "12345", + "sku_id": "678910" + } + ] + } + ] +}