From 42667807e2c546396e52109f9aaee96cbc2364ee Mon Sep 17 00:00:00 2001 From: Fu Diwei Date: Sat, 18 Sep 2021 12:50:34 +0800 Subject: [PATCH] =?UTF-8?q?feat(wxapi):=20=E6=96=B0=E5=A2=9E=E4=BA=A4?= =?UTF-8?q?=E6=98=93=E7=BB=84=E4=BB=B6=E4=BF=AE=E6=94=B9=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...WechatApiClientExecuteProductExtensions.cs | 63 ++++++++++++------ .../ProductOrderChangeOrderPriceRequest.cs | 66 +++++++++++++++++++ .../ProductOrderChangeOrderPriceResponse.cs | 12 ++++ .../ProductOrderChangeOrderPriceRequest.json | 12 ++++ .../ProductOrderChangeOrderPriceResponse.json | 4 ++ 5 files changed, 137 insertions(+), 20 deletions(-) create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/Product/Order/ProductOrderChangeOrderPriceRequest.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/Product/Order/ProductOrderChangeOrderPriceResponse.cs create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Product/Order/ProductOrderChangeOrderPriceRequest.json create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Product/Order/ProductOrderChangeOrderPriceResponse.json diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteProductExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteProductExtensions.cs index 43112247..45d4936d 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteProductExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteProductExtensions.cs @@ -1134,29 +1134,10 @@ namespace SKIT.FlurlHttpClient.Wechat.Api #endregion #region Order - /// - /// 异步调用 [POST] /product/order/get 接口。 - /// REF: https://developers.weixin.qq.com/miniprogram/dev/framework/ministore/minishopopencomponent/API/order/get_order_detail.html - /// - /// - /// - /// - /// - public static async Task ExecuteProductOrderGetAsync(this WechatApiClient client, Models.ProductOrderGetRequest 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, "product", "order", "get") - .SetQueryParam("access_token", request.AccessToken); - - return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); - } - /// /// 异步调用 [POST] /product/order/get_list 接口。 /// REF: https://developers.weixin.qq.com/miniprogram/dev/framework/ministore/minishopopencomponent/API/order/get_order_list.html + /// REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/ministore/minishopopencomponent/API/order/get_order_list.html /// /// /// @@ -1174,9 +1155,31 @@ namespace SKIT.FlurlHttpClient.Wechat.Api return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } + /// + /// 异步调用 [POST] /product/order/get 接口。 + /// REF: https://developers.weixin.qq.com/miniprogram/dev/framework/ministore/minishopopencomponent/API/order/get_order_detail.html + /// REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/ministore/minishopopencomponent/API/order/get_order_detail.html + /// + /// + /// + /// + /// + public static async Task ExecuteProductOrderGetAsync(this WechatApiClient client, Models.ProductOrderGetRequest 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, "product", "order", "get") + .SetQueryParam("access_token", request.AccessToken); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } + /// /// 异步调用 [POST] /product/order/search 接口。 /// REF: https://developers.weixin.qq.com/miniprogram/dev/framework/ministore/minishopopencomponent/API/order/search_order.html + /// REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/ministore/minishopopencomponent/API/order/search_order.html /// /// /// @@ -1193,6 +1196,26 @@ namespace SKIT.FlurlHttpClient.Wechat.Api return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } + + /// + /// 异步调用 [POST] /product/order/change_order_price 接口。 + /// REF: https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/ministore/minishopopencomponent/API/order/change_order_price.html + /// + /// + /// + /// + /// + public static async Task ExecuteProductOrderChangeOrderPriceAsync(this WechatApiClient client, Models.ProductOrderChangeOrderPriceRequest 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, "product", "order", "change_order_price") + .SetQueryParam("access_token", request.AccessToken); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } #endregion #region Coupon diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Product/Order/ProductOrderChangeOrderPriceRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Product/Order/ProductOrderChangeOrderPriceRequest.cs new file mode 100644 index 00000000..c8506461 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Product/Order/ProductOrderChangeOrderPriceRequest.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /product/order/change_order_price 接口的请求。 + /// + public class ProductOrderChangeOrderPriceRequest : WechatApiRequest + { + 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("change_price")] + [System.Text.Json.Serialization.JsonPropertyName("change_price")] + public int Price { get; set; } + } + } + + /// + /// 获取或设置订单 ID。 + /// + [Newtonsoft.Json.JsonProperty("order_id")] + [System.Text.Json.Serialization.JsonPropertyName("order_id")] + public long OrderId { get; set; } + + /// + /// 获取或设置是否修改运费。 + /// + [Newtonsoft.Json.JsonProperty("change_express")] + [System.Text.Json.Serialization.JsonPropertyName("change_express")] + public bool RequireChangeExpress { get; set; } + + /// + /// 获取或设置运费价格(单位:分)。 + /// + [Newtonsoft.Json.JsonProperty("express_fee")] + [System.Text.Json.Serialization.JsonPropertyName("express_fee")] + public int? ExpressFee { get; set; } + + /// + /// 获取或设置修改价格的商品列表。 + /// + [Newtonsoft.Json.JsonProperty("change_order_infos")] + [System.Text.Json.Serialization.JsonPropertyName("change_order_infos")] + public IList ProductList { get; set; } = new List(); + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Product/Order/ProductOrderChangeOrderPriceResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Product/Order/ProductOrderChangeOrderPriceResponse.cs new file mode 100644 index 00000000..56c673fd --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Product/Order/ProductOrderChangeOrderPriceResponse.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /product/order/change_order_price 接口的响应。 + /// + public class ProductOrderChangeOrderPriceResponse : WechatApiResponse + { + } +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Product/Order/ProductOrderChangeOrderPriceRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Product/Order/ProductOrderChangeOrderPriceRequest.json new file mode 100644 index 00000000..7ec590ae --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Product/Order/ProductOrderChangeOrderPriceRequest.json @@ -0,0 +1,12 @@ +{ + "order_id": 123456, + "change_express": true, + "express_fee": 0, + "change_order_infos": [ + { + "product_id": 1234, + "sku_id": 5678, + "change_price": 300 + } + ] +} \ No newline at end of file diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Product/Order/ProductOrderChangeOrderPriceResponse.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Product/Order/ProductOrderChangeOrderPriceResponse.json new file mode 100644 index 00000000..f752befe --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Product/Order/ProductOrderChangeOrderPriceResponse.json @@ -0,0 +1,4 @@ +{ + "errcode": 0, + "errmsg": "ok" +} \ No newline at end of file