Browse Source

[WebApplicationSample][Alipay] 新增 统一转账、查询统一转账订单、余额查询,删除 单笔转账到支付宝账户、查询转账订单、查询对账单下载地址

Roc 5 years ago
parent
commit
110da49eaf

+ 21 - 20
samples/WebApplicationSample/Controllers/AlipayController.cs

@@ -286,7 +286,7 @@ namespace WebApplicationSample.Controllers
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// 单笔转账到支付宝账户
+        /// 统一转账
         /// </summary>
         /// </summary>
         [HttpGet]
         [HttpGet]
         public IActionResult Transfer()
         public IActionResult Transfer()
@@ -295,28 +295,29 @@ namespace WebApplicationSample.Controllers
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// 单笔转账到支付宝账户
+        /// 统一转账
         /// </summary>
         /// </summary>
         [HttpPost]
         [HttpPost]
         public async Task<IActionResult> Transfer(AlipayTransferViewModel viewMode)
         public async Task<IActionResult> Transfer(AlipayTransferViewModel viewMode)
         {
         {
-            var model = new AlipayFundTransToaccountTransferModel
+            var model = new AlipayFundTransUniTransferModel
             {
             {
                 OutBizNo = viewMode.OutBizNo,
                 OutBizNo = viewMode.OutBizNo,
-                PayeeType = viewMode.PayeeType,
-                PayeeAccount = viewMode.PayeeAccount,
-                Amount = viewMode.Amount,
+                TransAmount = viewMode.TransAmount,
+                ProductCode = viewMode.ProductCode,
+                BizScene = viewMode.BizScene,
+                PayeeInfo = new Participant { Identity = viewMode.PayeeIdentity, IdentityType = viewMode.PayeeIdentityType, Name = viewMode.PayeeName },
                 Remark = viewMode.Remark
                 Remark = viewMode.Remark
             };
             };
-            var req = new AlipayFundTransToaccountTransferRequest();
+            var req = new AlipayFundTransUniTransferRequest();
             req.SetBizModel(model);
             req.SetBizModel(model);
-            var response = await _client.ExecuteAsync(req, _optionsAccessor.Value);
+            var response = await _client.CertificateExecuteAsync(req, _optionsAccessor.Value);
             ViewData["response"] = response.ResponseBody;
             ViewData["response"] = response.ResponseBody;
             return View();
             return View();
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// 查询转账订单
+        /// 查询统一转账订单
         /// </summary>
         /// </summary>
         [HttpGet]
         [HttpGet]
         public IActionResult TransQuery()
         public IActionResult TransQuery()
@@ -325,18 +326,18 @@ namespace WebApplicationSample.Controllers
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// 查询转账订单
+        /// 查询统一转账订单
         /// </summary>
         /// </summary>
         [HttpPost]
         [HttpPost]
         public async Task<IActionResult> TransQuery(AlipayTransQueryViewModel viewMode)
         public async Task<IActionResult> TransQuery(AlipayTransQueryViewModel viewMode)
         {
         {
-            var model = new AlipayFundTransOrderQueryModel
+            var model = new AlipayFundTransCommonQueryModel
             {
             {
                 OutBizNo = viewMode.OutBizNo,
                 OutBizNo = viewMode.OutBizNo,
                 OrderId = viewMode.OrderId
                 OrderId = viewMode.OrderId
             };
             };
 
 
-            var req = new AlipayFundTransOrderQueryRequest();
+            var req = new AlipayFundTransCommonQueryRequest();
             req.SetBizModel(model);
             req.SetBizModel(model);
             var response = await _client.ExecuteAsync(req, _optionsAccessor.Value);
             var response = await _client.ExecuteAsync(req, _optionsAccessor.Value);
             ViewData["response"] = response.ResponseBody;
             ViewData["response"] = response.ResponseBody;
@@ -344,27 +345,27 @@ namespace WebApplicationSample.Controllers
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// 查询对账单下载地址
+        /// 余额查询
         /// </summary>
         /// </summary>
         [HttpGet]
         [HttpGet]
-        public IActionResult BillDownloadurlQuery()
+        public IActionResult AccountQuery()
         {
         {
             return View();
             return View();
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// 查询对账单下载地址
+        /// 余额查询
         /// </summary>
         /// </summary>
         [HttpPost]
         [HttpPost]
-        public async Task<IActionResult> BillDownloadurlQuery(AlipayBillDownloadurlQueryViewModel viewModel)
+        public async Task<IActionResult> AccountQuery(AlipayAccountQueryViewModel viewModel)
         {
         {
-            var model = new AlipayDataDataserviceBillDownloadurlQueryModel
+            var model = new AlipayFundAccountQueryModel
             {
             {
-                BillDate = viewModel.BillDate,
-                BillType = viewModel.BillType
+                AlipayUserId = viewModel.AlipayUserId,
+                AccountType = viewModel.AccountType
             };
             };
 
 
-            var req = new AlipayDataDataserviceBillDownloadurlQueryRequest();
+            var req = new AlipayFundAccountQueryRequest();
             req.SetBizModel(model);
             req.SetBizModel(model);
             var response = await _client.ExecuteAsync(req, _optionsAccessor.Value);
             var response = await _client.ExecuteAsync(req, _optionsAccessor.Value);
             ViewData["response"] = response.ResponseBody;
             ViewData["response"] = response.ResponseBody;

+ 32 - 11
samples/WebApplicationSample/Models/AlipayViewModel.cs

@@ -175,16 +175,28 @@ namespace WebApplicationSample.Models
         public string OutBizNo { get; set; }
         public string OutBizNo { get; set; }
 
 
         [Required]
         [Required]
-        [Display(Name = "payee_account")]
-        public string PayeeAccount { get; set; }
+        [Display(Name = "trans_amount")]
+        public string TransAmount { get; set; }
 
 
         [Required]
         [Required]
-        [Display(Name = "payee_type")]
-        public string PayeeType { get; set; }
+        [Display(Name = "product_code")]
+        public string ProductCode { get; set; }
+
+        [Required]
+        [Display(Name = "biz_scene")]
+        public string BizScene { get; set; }
 
 
         [Required]
         [Required]
-        [Display(Name = "amount")]
-        public string Amount { get; set; }
+        [Display(Name = "payee_info_identity")]
+        public string PayeeIdentity { get; set; }
+
+        [Required]
+        [Display(Name = "payee_info_identity_type")]
+        public string PayeeIdentityType { get; set; }
+
+        [Required]
+        [Display(Name = "payee_info_name")]
+        public string PayeeName { get; set; }
 
 
         [Display(Name = "remark")]
         [Display(Name = "remark")]
         public string Remark { get; set; }
         public string Remark { get; set; }
@@ -192,21 +204,30 @@ namespace WebApplicationSample.Models
 
 
     public class AlipayTransQueryViewModel
     public class AlipayTransQueryViewModel
     {
     {
+        [Display(Name = "product_code")]
+        public string ProductCode { get; set; }
+
+        [Display(Name = "biz_scene")]
+        public string BizScene { get; set; }
+
         [Display(Name = "out_biz_no")]
         [Display(Name = "out_biz_no")]
         public string OutBizNo { get; set; }
         public string OutBizNo { get; set; }
 
 
         [Display(Name = "order_id")]
         [Display(Name = "order_id")]
         public string OrderId { get; set; }
         public string OrderId { get; set; }
+
+        [Display(Name = "pay_fund_order_id")]
+        public string PayFundOrderId { get; set; }
     }
     }
 
 
-    public class AlipayBillDownloadurlQueryViewModel
+    public class AlipayAccountQueryViewModel
     {
     {
         [Required]
         [Required]
-        [Display(Name = "bill_type")]
-        public string BillType { get; set; }
+        [Display(Name = "alipay_user_id")]
+        public string AlipayUserId { get; set; }
 
 
         [Required]
         [Required]
-        [Display(Name = "bill_date")]
-        public string BillDate { get; set; }
+        [Display(Name = "account_type")]
+        public string AccountType { get; set; }
     }
     }
 }
 }

+ 7 - 7
samples/WebApplicationSample/Views/Alipay/BillDownloadurlQuery.cshtml → samples/WebApplicationSample/Views/Alipay/AccountQuery.cshtml

@@ -1,6 +1,6 @@
-@model AlipayBillDownloadurlQueryViewModel
+@model AlipayAccountQueryViewModel
 @{
 @{
-    ViewData["Title"] = "查询对账单下载地址";
+    ViewData["Title"] = "余额查询";
 }
 }
 <nav aria-label="breadcrumb">
 <nav aria-label="breadcrumb">
     <ol class="breadcrumb">
     <ol class="breadcrumb">
@@ -11,15 +11,15 @@
 <br />
 <br />
 <div class="card">
 <div class="card">
     <div class="card-body">
     <div class="card-body">
-        <form asp-controller="Alipay" asp-action="BillDownloadurlQuery">
+        <form asp-controller="Alipay" asp-action="AccountQuery">
             <div asp-validation-summary="All" class="text-danger"></div>
             <div asp-validation-summary="All" class="text-danger"></div>
             <div class="form-group">
             <div class="form-group">
-                <label asp-for="BillDate"></label>
-                <input type="text" class="form-control" asp-for="BillDate" />
+                <label asp-for="AlipayUserId"></label>
+                <input type="text" class="form-control" asp-for="AlipayUserId" />
             </div>
             </div>
             <div class="form-group">
             <div class="form-group">
-                <label asp-for="BillType"></label>
-                <input type="text" class="form-control" asp-for="BillType" />
+                <label asp-for="AccountType"></label>
+                <input type="text" class="form-control" asp-for="AccountType" value="ACCTRANS_ACCOUNT" />
             </div>
             </div>
             <button type="submit" class="btn btn-primary">提交请求</button>
             <button type="submit" class="btn btn-primary">提交请求</button>
         </form>
         </form>

+ 7 - 7
samples/WebApplicationSample/Views/Alipay/Index.cshtml

@@ -68,20 +68,20 @@
         </tr>
         </tr>
         <tr>
         <tr>
             <th scope="row">9</th>
             <th scope="row">9</th>
-            <td>单笔转账到支付宝账户</td>
-            <td><a href="https://docs.open.alipay.com/api_28/alipay.fund.trans.toaccount.transfer" target="_blank">alipay.fund.trans.toaccount.transfer</a></td>
+            <td>统一转账</td>
+            <td><a href="https://docs.open.alipay.com/api_28/alipay.fund.trans.uni.transfer" target="_blank">alipay.fund.trans.uni.transfer</a></td>
             <td><a asp-controller="Alipay" asp-action="Transfer">立即测试</a></td>
             <td><a asp-controller="Alipay" asp-action="Transfer">立即测试</a></td>
         </tr>
         </tr>
         <tr>
         <tr>
             <th scope="row">10</th>
             <th scope="row">10</th>
-            <td>查询转账订单</td>
-            <td><a href="https://docs.open.alipay.com/api_28/alipay.fund.trans.order.query" target="_blank">alipay.fund.trans.order.query</a></td>
+            <td>查询统一转账订单</td>
+            <td><a href="https://docs.open.alipay.com/api_28/alipay.fund.trans.common.query" target="_blank">alipay.fund.trans.common.query</a></td>
             <td><a asp-controller="Alipay" asp-action="TransQuery">立即测试</a></td>
             <td><a asp-controller="Alipay" asp-action="TransQuery">立即测试</a></td>
         </tr>
         </tr>
         <tr>
         <tr>
             <th scope="row">11</th>
             <th scope="row">11</th>
-            <td>查询对账单下载地址</td>
-            <td><a href="https://docs.open.alipay.com/api_15/alipay.data.dataservice.bill.downloadurl.query" target="_blank">alipay.data.dataservice.bill.downloadurl.query</a></td>
-            <td><a asp-controller="Alipay" asp-action="BillDownloadurlQuery">立即测试</a></td>
+            <td>余额查询</td>
+            <td><a href="https://docs.open.alipay.com/api_28/alipay.fund.account.query" target="_blank">alipay.fund.account.query</a></td>
+            <td><a asp-controller="Alipay" asp-action="AccountQuery">立即测试</a></td>
         </tr>
         </tr>
 </table>
 </table>

+ 13 - 1
samples/WebApplicationSample/Views/Alipay/TransQuery.cshtml

@@ -1,6 +1,6 @@
 @model AlipayTransQueryViewModel
 @model AlipayTransQueryViewModel
 @{
 @{
-    ViewData["Title"] = "查询转账订单";
+    ViewData["Title"] = "查询统一转账订单";
 }
 }
 <nav aria-label="breadcrumb">
 <nav aria-label="breadcrumb">
     <ol class="breadcrumb">
     <ol class="breadcrumb">
@@ -13,14 +13,26 @@
     <div class="card-body">
     <div class="card-body">
         <form asp-controller="Alipay" asp-action="TransQuery">
         <form asp-controller="Alipay" asp-action="TransQuery">
             <div asp-validation-summary="All" class="text-danger"></div>
             <div asp-validation-summary="All" class="text-danger"></div>
+            <div class="form-group">
+                <label asp-for="ProductCode"></label>
+                <input type="text" class="form-control" asp-for="ProductCode" />
+            </div>
             <div class="form-group">
             <div class="form-group">
                 <label asp-for="OutBizNo"></label>
                 <label asp-for="OutBizNo"></label>
                 <input type="text" class="form-control" asp-for="OutBizNo" />
                 <input type="text" class="form-control" asp-for="OutBizNo" />
             </div>
             </div>
+            <div class="form-group">
+                <label asp-for="BizScene"></label>
+                <input type="text" class="form-control" asp-for="BizScene" />
+            </div>
             <div class="form-group">
             <div class="form-group">
                 <label asp-for="OrderId"></label>
                 <label asp-for="OrderId"></label>
                 <input type="text" class="form-control" asp-for="OrderId" />
                 <input type="text" class="form-control" asp-for="OrderId" />
             </div>
             </div>
+            <div class="form-group">
+                <label asp-for="PayFundOrderId"></label>
+                <input type="text" class="form-control" asp-for="PayFundOrderId" />
+            </div>
             <button type="submit" class="btn btn-primary">提交请求</button>
             <button type="submit" class="btn btn-primary">提交请求</button>
         </form>
         </form>
         <hr />
         <hr />

+ 20 - 8
samples/WebApplicationSample/Views/Alipay/Transfer.cshtml

@@ -1,6 +1,6 @@
 @model AlipayTransferViewModel
 @model AlipayTransferViewModel
 @{
 @{
-    ViewData["Title"] = "单笔转账到支付宝账户";
+    ViewData["Title"] = "统一转账";
 }
 }
 <nav aria-label="breadcrumb">
 <nav aria-label="breadcrumb">
     <ol class="breadcrumb">
     <ol class="breadcrumb">
@@ -18,20 +18,32 @@
                 <input type="text" class="form-control" asp-for="OutBizNo" value="@DateTime.Now.ToString("yyyyMMddHHmmssfff")" />
                 <input type="text" class="form-control" asp-for="OutBizNo" value="@DateTime.Now.ToString("yyyyMMddHHmmssfff")" />
             </div>
             </div>
             <div class="form-group">
             <div class="form-group">
-                <label asp-for="PayeeType"></label>
-                <input type="text" class="form-control" asp-for="PayeeType" value="ALIPAY_LOGONID" />
+                <label asp-for="TransAmount"></label>
+                <input type="text" class="form-control" asp-for="TransAmount" value="0.1" />
             </div>
             </div>
             <div class="form-group">
             <div class="form-group">
-                <label asp-for="PayeeAccount"></label>
-                <input type="text" class="form-control" asp-for="PayeeAccount" />
+                <label asp-for="ProductCode"></label>
+                <input type="text" class="form-control" asp-for="ProductCode" value="TRANS_ACCOUNT_NO_PWD" />
             </div>
             </div>
             <div class="form-group">
             <div class="form-group">
-                <label asp-for="Amount"></label>
-                <input type="text" class="form-control" asp-for="Amount" value="0.01" />
+                <label asp-for="BizScene"></label>
+                <input type="text" class="form-control" asp-for="BizScene" value="DIRECT_TRANSFER" />
+            </div>
+            <div class="form-group">
+                <label asp-for="PayeeIdentity"></label>
+                <input type="text" class="form-control" asp-for="PayeeIdentity" />
+            </div>
+            <div class="form-group">
+                <label asp-for="PayeeIdentityType"></label>
+                <input type="text" class="form-control" asp-for="PayeeIdentityType" value="ALIPAY_LOGON_ID" />
+            </div>
+            <div class="form-group">
+                <label asp-for="PayeeName"></label>
+                <input type="text" class="form-control" asp-for="PayeeName" />
             </div>
             </div>
             <div class="form-group">
             <div class="form-group">
                 <label asp-for="Remark"></label>
                 <label asp-for="Remark"></label>
-                <input type="text" class="form-control" asp-for="Remark" value="单笔转账到支付宝账户转账备注" />
+                <input type="text" class="form-control" asp-for="Remark" value="统一转账-单笔无密转账到支付宝账户" />
             </div>
             </div>
             <button type="submit" class="btn btn-primary">提交请求</button>
             <button type="submit" class="btn btn-primary">提交请求</button>
         </form>
         </form>