소스 검색

[WeChatPay.V3] 修正部分API 误报 QueryModel is null!,WeChatPayBillDownloadRequest 新增 SetDownloadUrl

Roc 4 년 전
부모
커밋
5e273bdd29
15개의 변경된 파일60개의 추가작업 그리고 53개의 파일을 삭제
  1. 1 6
      samples/WebApplicationSample/Controllers/WeChatPayV3Controller.cs
  2. 1 1
      samples/WebApplicationSample/Views/WeChatPayV3/BillDownload.cshtml
  3. 1 1
      samples/WebApplicationSample/Views/WeChatPayV3/FundflowBill.cshtml
  4. 1 1
      samples/WebApplicationSample/Views/WeChatPayV3/Refund.cshtml
  5. 1 1
      samples/WebApplicationSample/Views/WeChatPayV3/TradeBill.cshtml
  6. 0 18
      src/Essensoft.AspNetCore.Payment.WeChatPay/V3/Domain/WeChatPayBillDownloadQueryModel.cs
  7. 3 15
      src/Essensoft.AspNetCore.Payment.WeChatPay/V3/Extensions/HttpClientExtensions.cs
  8. 8 0
      src/Essensoft.AspNetCore.Payment.WeChatPay/V3/IWeChatPayGetRequest.cs
  9. 5 0
      src/Essensoft.AspNetCore.Payment.WeChatPay/V3/Request/WeChatPayApply4SubSubMerchantsSubMchIdSettlementRequest.cs
  10. 5 0
      src/Essensoft.AspNetCore.Payment.WeChatPay/V3/Request/WeChatPayApplyment4SubApplymentApplymentIdRequest.cs
  11. 5 0
      src/Essensoft.AspNetCore.Payment.WeChatPay/V3/Request/WeChatPayApplyment4SubApplymentBusinessCodeRequest.cs
  12. 10 5
      src/Essensoft.AspNetCore.Payment.WeChatPay/V3/Request/WeChatPayBillDownloadRequest.cs
  13. 5 0
      src/Essensoft.AspNetCore.Payment.WeChatPay/V3/Request/WeChatPayCertificatesRequest.cs
  14. 5 0
      src/Essensoft.AspNetCore.Payment.WeChatPay/V3/Request/WeChatPayCombineTransactionsOutTradeNoRequest.cs
  15. 9 5
      src/Essensoft.AspNetCore.Payment.WeChatPay/V3/Request/WeChatPayRefundDomesticRefundsOutRefundNoRequest.cs

+ 1 - 6
samples/WebApplicationSample/Controllers/WeChatPayV3Controller.cs

@@ -404,13 +404,8 @@ namespace WebApplicationSample.Controllers
         [HttpPost]
         public async Task<IActionResult> BillDownload(WeChatPayBillDownloadViewModel viewModel)
         {
-            var model = new WeChatPayBillDownloadQueryModel()
-            {
-                DownloadUrl = viewModel.DownloadUrl
-            };
-
             var request = new WeChatPayBillDownloadRequest();
-            request.SetQueryModel(model);
+            request.SetDownloadUrl(viewModel.DownloadUrl);
 
             var response = await _client.ExecuteAsync(request, _optionsAccessor.Value);
 

+ 1 - 1
samples/WebApplicationSample/Views/WeChatPayV3/BillDownload.cshtml

@@ -4,7 +4,7 @@
 }
 <nav aria-label="breadcrumb">
     <ol class="breadcrumb">
-        <li class="breadcrumb-item"><a asp-controller="WeChatPayV3" asp-action="Index">微信支付</a></li>
+        <li class="breadcrumb-item"><a asp-controller="WeChatPayV3" asp-action="Index">微信支付V3</a></li>
         <li class="breadcrumb-item active" aria-current="page">@ViewData["Title"]</li>
     </ol>
 </nav>

+ 1 - 1
samples/WebApplicationSample/Views/WeChatPayV3/FundflowBill.cshtml

@@ -4,7 +4,7 @@
 }
 <nav aria-label="breadcrumb">
     <ol class="breadcrumb">
-        <li class="breadcrumb-item"><a asp-controller="WeChatPayV3" asp-action="Index">微信支付</a></li>
+        <li class="breadcrumb-item"><a asp-controller="WeChatPayV3" asp-action="Index">微信支付V3</a></li>
         <li class="breadcrumb-item active" aria-current="page">@ViewData["Title"]</li>
     </ol>
 </nav>

+ 1 - 1
samples/WebApplicationSample/Views/WeChatPayV3/Refund.cshtml

@@ -4,7 +4,7 @@
 }
 <nav aria-label="breadcrumb">
     <ol class="breadcrumb">
-        <li class="breadcrumb-item"><a asp-controller="WeChatPayV3" asp-action="Index">微信支付</a></li>
+        <li class="breadcrumb-item"><a asp-controller="WeChatPayV3" asp-action="Index">微信支付V3</a></li>
         <li class="breadcrumb-item active" aria-current="page">@ViewData["Title"]</li>
     </ol>
 </nav>

+ 1 - 1
samples/WebApplicationSample/Views/WeChatPayV3/TradeBill.cshtml

@@ -4,7 +4,7 @@
 }
 <nav aria-label="breadcrumb">
     <ol class="breadcrumb">
-        <li class="breadcrumb-item"><a asp-controller="WeChatPayV3" asp-action="Index">微信支付</a></li>
+        <li class="breadcrumb-item"><a asp-controller="WeChatPayV3" asp-action="Index">微信支付V3</a></li>
         <li class="breadcrumb-item active" aria-current="page">@ViewData["Title"]</li>
     </ol>
 </nav>

+ 0 - 18
src/Essensoft.AspNetCore.Payment.WeChatPay/V3/Domain/WeChatPayBillDownloadQueryModel.cs

@@ -1,18 +0,0 @@
-using System.Text.Json.Serialization;
-
-namespace Essensoft.AspNetCore.Payment.WeChatPay.V3.Domain
-{
-    /// <summary>
-    /// 账单-下载账单API(电商平台、服务商、直连商户)- 请求URL参数
-    /// <para><a href="https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/bill/chapter3_3.shtml">账单-下载账单API</a></para>
-    /// 最新更新时间:2019.09.16
-    /// </summary>
-    public class WeChatPayBillDownloadQueryModel : WeChatPayObject
-    {
-        /// <summary>
-        /// 下载地址
-        /// </summary>
-        [JsonPropertyName("download_url")]
-        public string DownloadUrl { get; set; }
-    }
-}

+ 3 - 15
src/Essensoft.AspNetCore.Payment.WeChatPay/V3/Extensions/HttpClientExtensions.cs

@@ -8,8 +8,6 @@ using System.Text.Encodings.Web;
 using System.Text.Json;
 using System.Threading.Tasks;
 using Essensoft.AspNetCore.Payment.Security;
-using Essensoft.AspNetCore.Payment.WeChatPay.V3.Domain;
-using Essensoft.AspNetCore.Payment.WeChatPay.V3.Request;
 
 namespace Essensoft.AspNetCore.Payment.WeChatPay.V3.Extensions
 {
@@ -19,20 +17,10 @@ namespace Essensoft.AspNetCore.Payment.WeChatPay.V3.Extensions
 
         public static async Task<(WeChatPayHeaders headers, string body, int statusCode)> GetAsync<T>(this HttpClient client, IWeChatPayGetRequest<T> request, WeChatPayOptions options) where T : WeChatPayResponse
         {
-            string url;
+            var url = request.GetRequestUrl();
 
-            if (request is WeChatPayBillDownloadRequest && request.GetQueryModel() is WeChatPayBillDownloadQueryModel queryModel)
-            {
-                url = queryModel.DownloadUrl;
-            }
-            else if (request is WeChatPayCertificatesRequest)
+            if (request.GetNeedQueryModel())
             {
-                url = request.GetRequestUrl();
-            }
-            else
-            {
-                url = request.GetRequestUrl();
-
                 if (url.Contains("?"))
                 {
                     var txtParams = QueryModelConvertToDictionary(request);
@@ -129,7 +117,7 @@ namespace Essensoft.AspNetCore.Payment.WeChatPay.V3.Extensions
                 return JsonSerializer.Deserialize<IDictionary<string, string>>(str, jsonSerializerOptions);
             }
 
-            throw new WeChatPayException("QueryModel is null!");
+            throw new WeChatPayException("request.QueryModel is null!");
         }
 
         private static string BuildToken(string url, string method, string body, WeChatPayOptions options)

+ 8 - 0
src/Essensoft.AspNetCore.Payment.WeChatPay/V3/IWeChatPayGetRequest.cs

@@ -29,5 +29,13 @@
         {
             return true;
         }
+
+        /// <summary>
+        /// 是否需要URL参数
+        /// </summary>
+        bool GetNeedQueryModel()
+        {
+            return true;
+        }
     }
 }

+ 5 - 0
src/Essensoft.AspNetCore.Payment.WeChatPay/V3/Request/WeChatPayApply4SubSubMerchantsSubMchIdSettlementRequest.cs

@@ -31,5 +31,10 @@ namespace Essensoft.AspNetCore.Payment.WeChatPay.V3.Request
         {
             throw new NotImplementedException();
         }
+
+        public bool GetNeedQueryModel()
+        {
+            return false;
+        }
     }
 }

+ 5 - 0
src/Essensoft.AspNetCore.Payment.WeChatPay/V3/Request/WeChatPayApplyment4SubApplymentApplymentIdRequest.cs

@@ -31,5 +31,10 @@ namespace Essensoft.AspNetCore.Payment.WeChatPay.V3.Request
         {
             throw new NotImplementedException();
         }
+
+        public bool GetNeedQueryModel()
+        {
+            return false;
+        }
     }
 }

+ 5 - 0
src/Essensoft.AspNetCore.Payment.WeChatPay/V3/Request/WeChatPayApplyment4SubApplymentBusinessCodeRequest.cs

@@ -34,5 +34,10 @@ namespace Essensoft.AspNetCore.Payment.WeChatPay.V3.Request
         {
             throw new NotImplementedException();
         }
+
+        public bool GetNeedQueryModel()
+        {
+            return false;
+        }
     }
 }

+ 10 - 5
src/Essensoft.AspNetCore.Payment.WeChatPay/V3/Request/WeChatPayBillDownloadRequest.cs

@@ -14,24 +14,29 @@ namespace Essensoft.AspNetCore.Payment.WeChatPay.V3.Request
     /// </summary>
     public class WeChatPayBillDownloadRequest : IWeChatPayGetRequest<WeChatPayBillDownloadResponse>
     {
-        private WeChatPayObject queryModel;
+        private string requestUrl;
 
         public string GetRequestUrl()
         {
-            throw new NotImplementedException();
+            return requestUrl;
+        }
+
+        public void SetDownloadUrl(string url)
+        {
+            requestUrl = url;
         }
 
         public WeChatPayObject GetQueryModel()
         {
-            return queryModel;
+            throw new NotImplementedException();
         }
 
         public void SetQueryModel(WeChatPayObject queryModel)
         {
-            this.queryModel = queryModel;
+            throw new NotImplementedException();
         }
 
-        public bool GetNeedCheckSign()
+        public bool GetNeedQueryModel()
         {
             return false;
         }

+ 5 - 0
src/Essensoft.AspNetCore.Payment.WeChatPay/V3/Request/WeChatPayCertificatesRequest.cs

@@ -28,5 +28,10 @@ namespace Essensoft.AspNetCore.Payment.WeChatPay.V3.Request
         {
             return false;
         }
+
+        public bool GetNeedQueryModel()
+        {
+            return false;
+        }
     }
 }

+ 5 - 0
src/Essensoft.AspNetCore.Payment.WeChatPay/V3/Request/WeChatPayCombineTransactionsOutTradeNoRequest.cs

@@ -31,5 +31,10 @@ namespace Essensoft.AspNetCore.Payment.WeChatPay.V3.Request
         {
             throw new NotImplementedException();
         }
+
+        public bool GetNeedQueryModel()
+        {
+            return false;
+        }
     }
 }

+ 9 - 5
src/Essensoft.AspNetCore.Payment.WeChatPay/V3/Request/WeChatPayRefundDomesticRefundsOutRefundNoRequest.cs

@@ -1,4 +1,5 @@
-using Essensoft.AspNetCore.Payment.WeChatPay.V3.Response;
+using System;
+using Essensoft.AspNetCore.Payment.WeChatPay.V3.Response;
 
 namespace Essensoft.AspNetCore.Payment.WeChatPay.V3.Request
 {
@@ -13,8 +14,6 @@ namespace Essensoft.AspNetCore.Payment.WeChatPay.V3.Request
     /// </summary>
     public class WeChatPayRefundDomesticRefundsOutRefundNoRequest : IWeChatPayGetRequest<WeChatPayRefundDomesticRefundsOutRefundNoResponse>
     {
-        private WeChatPayObject queryModel;
-
         /// <summary>
         /// 商户退款单号
         /// 商户系统内部的退款单号,商户系统内部唯一,只能是数字、大小写字母_-|*@ ,同一退款单号多次请求只退一笔。
@@ -29,12 +28,17 @@ namespace Essensoft.AspNetCore.Payment.WeChatPay.V3.Request
 
         public WeChatPayObject GetQueryModel()
         {
-            return queryModel;
+            throw new NotImplementedException();
         }
 
         public void SetQueryModel(WeChatPayObject queryModel)
         {
-            this.queryModel = queryModel;
+            throw new NotImplementedException();
+        }
+
+        public bool GetNeedQueryModel()
+        {
+            return false;
         }
     }
 }