From ecc217f694e03e660ef54bbada24fcb4ee59a728 Mon Sep 17 00:00:00 2001
From: zhengyuxuan <zhengyuxuan1995>
Date: 星期五, 21 三月 2025 09:33:12 +0800
Subject: [PATCH] 回单下载

---
 LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml |   74 ++++++++++++++++++
 LifePayment/LifePayment.Domain/WeChat/WxClient.cs                          |    2 
 LifePayment/LifePayment.Domain/WeChat/IWxPayApi.cs                         |    4 +
 LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs               |    9 ++
 LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayService.cs   |    2 
 LifePayment/LifePayment.Domain/Ali/AliPayApi.cs                            |    2 
 LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml                |    6 +
 LifePayment/LifePayment.Domain/WeChat/WxPayApi.cs                          |   14 +++
 LifePayment/LifePayment.Application/LifePay/LifePayService.cs              |   51 ++++++++++++
 LifePayment/LifePayment.Domain.Shared/LifePaymentConstant.cs               |    4 +
 LifePayment/LifePayment.Domain.Shared/WeChat/WxPayPostBaseModel.cs         |   31 +++++++
 11 files changed, 195 insertions(+), 4 deletions(-)

diff --git a/LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayService.cs b/LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayService.cs
index 82c7994..604b07b 100644
--- a/LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayService.cs
+++ b/LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayService.cs
@@ -250,6 +250,8 @@
 
     Task<List<LifePayOrderListTemplate>> GetLifePayOrderPageExport(QueryLifePayOrderListInput input);
 
+    Task<string> GetBillErceiptExport(string orderNo);
+
     /// <summary>
     /// 璁剧疆鐢熸椿缂磋垂鏀粯绫诲瀷
     /// </summary>
diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
index 00a0bf7..a06be30 100644
--- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
+++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
@@ -25,6 +25,7 @@
 using Nest;
 using Volo.Abp.Domain.Entities;
 using Volo.Abp.ObjectMapping;
+using NPOI.SS.Formula.Functions;
 
 namespace LifePayment.Application;
 
@@ -45,6 +46,7 @@
     private readonly IDataFilter dataFilter;
     private readonly IChannelFilter _channelFilter;
     private readonly IAliPayApi _aliPayApi;
+    private readonly IAlipayInterfaceManager _alipayInterfaceManager;
     private readonly IWxPayApi _wxPayApi;
     private readonly WxPayOption _wxPayOptions;
 
@@ -61,6 +63,7 @@
                           IRepository<DallyStatistics, Guid> dallyStatisticsRepository,
                           IRepository<OperateHistory, Guid> operateHistory,
                           IAliPayApi aliPayApi,
+                          IAlipayInterfaceManager aliPayInterfaceManager,
                           IWxPayApi wxPayApi,
                           IOptions<WxPayOption> wxPayOptions,
                           IRepository<LifePayChannles, Guid> lifePayChannlesRep,
@@ -77,6 +80,7 @@
         _lifePayIntroInfoRepository = lifePayIntroInfoRepository;
         _dallyStatisticsRepository = dallyStatisticsRepository;
         _aliPayApi = aliPayApi;
+        _alipayInterfaceManager = aliPayInterfaceManager;
         _wxPayApi = wxPayApi;
         _wxPayOptions = wxPayOptions.Value;
         _distributedEventBus = distributedEventBus;
@@ -663,7 +667,54 @@
         });
         return result;
     }
+    public async Task<string> GetBillErceiptExport(string orderNo)
+    {
+        try
+        {
+            var order = await _lifePayOrderRepository.Where(x => x.OrderNo == orderNo).FirstOrDefaultAsync();
 
+            CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "鏈壘鍒拌鍗曚俊鎭�");
+            if (order.LifePayType == LifePayTypeEnum.AliPay)
+            {
+                var elecInfoInput = new DataBillErceiptApplyInput
+                {
+                    Type = "FUND_DETAIL",
+                    Key = orderNo
+                };
+
+                var elecInfoOutput = await _alipayInterfaceManager.DataBillErceiptApply(elecInfoInput);
+                if (elecInfoOutput != null)
+                {
+                    var elecFileInput = new DataBillEreceiptQueryInput
+                    {
+                        FileId = elecInfoOutput.FileId,
+                    };
+                    var elecFileOutput = await _alipayInterfaceManager.DataBillEreceiptQuery(elecFileInput);
+                    if (!string.IsNullOrEmpty(elecFileOutput.DownloadUrl))
+                    {
+                        return elecFileOutput.DownloadUrl;
+                    }
+                    return "";
+                }
+                return "";
+            }
+            else
+            {
+                WxPayTradeBillApplyRequest req = new WxPayTradeBillApplyRequest
+                {
+                    OutBillNo = order.OutOrderNo,
+                };
+
+                var res = await _wxPayApi.WxPayTradeBillApply(req);
+                return "";
+            }
+        }
+        catch (Exception ex)
+        {
+            _logger.LogError("鑾峰彇璁㈠崟鍙蜂负{0}鐢靛瓙鍥炲崟鍑虹幇閿欒锛歿1}", orderNo, ex.Message);
+            return "";
+        }
+    }
     #endregion
 
     #region 鎿嶄綔
diff --git a/LifePayment/LifePayment.Domain.Shared/LifePaymentConstant.cs b/LifePayment/LifePayment.Domain.Shared/LifePaymentConstant.cs
index b093ed8..f626839 100644
--- a/LifePayment/LifePayment.Domain.Shared/LifePaymentConstant.cs
+++ b/LifePayment/LifePayment.Domain.Shared/LifePaymentConstant.cs
@@ -55,6 +55,10 @@
 
         public const string WxPayDomesticRefunds = "/v3/refund/domestic/refunds";
 
+        public const string WxPayTradeBillApply = "/v3/fund-app/mch-transfer/elecsign/out-bill-no";
+
+        public const string WxPayTradeBillQuery = "/v3/fund-app/mch-transfer/elecsign/out-bill-no/{out_bill_no}";
+
         public const string WxRechargeNotifySectionUrl = "/api/WxPayNotify/WxRechargeNotify";
 
         public const string WxPayDomesticRefundsNotifySectionUrl = "/api/WxPayNotify/WxPayDomesticRefundsNotify";
diff --git a/LifePayment/LifePayment.Domain.Shared/WeChat/WxPayPostBaseModel.cs b/LifePayment/LifePayment.Domain.Shared/WeChat/WxPayPostBaseModel.cs
index d9e2d8b..4c235b5 100644
--- a/LifePayment/LifePayment.Domain.Shared/WeChat/WxPayPostBaseModel.cs
+++ b/LifePayment/LifePayment.Domain.Shared/WeChat/WxPayPostBaseModel.cs
@@ -763,5 +763,36 @@
 
     }
 
+    public class WxPayTradeBillApplyRequest
+    {
+        /// <summary>
+        /// 寰俊鏀粯璁㈠崟鍙�
+        /// </summary>
+        [JsonProperty("out_bill_no")]
+        public string OutBillNo { get; set; }
+    }
 
+    public class WxPayTradeBillApplyReponse
+    {
+       /// <summary>
+        /// 寰俊鏀粯璁㈠崟鍙�
+        /// </summary>
+        [JsonProperty("transfer_bill_no")]
+        public string TransferBillNo { get; set; }
+    }
+
+    public class WxPayTradeBillQueryRequest
+    {
+        /// <summary>
+        /// 寰俊鏀粯璁㈠崟鍙�
+        /// </summary>
+        [JsonProperty("transfer_bill_no")]
+        public string TransferBillNo { get; set; }
+    }
+
+    public class WxPayTradeBillQueryReponse
+    {
+        [JsonProperty("download_url")]
+        public string DownloadUrl { get; set; }
+    }
 }
\ No newline at end of file
diff --git a/LifePayment/LifePayment.Domain/Ali/AliPayApi.cs b/LifePayment/LifePayment.Domain/Ali/AliPayApi.cs
index a64cc72..daf94ef 100644
--- a/LifePayment/LifePayment.Domain/Ali/AliPayApi.cs
+++ b/LifePayment/LifePayment.Domain/Ali/AliPayApi.cs
@@ -4,6 +4,7 @@
 using Alipay.EasySDK.Payment.FaceToFace.Models;
 using LifePayment.Domain.Shared;
 using Microsoft.Extensions.Options;
+using Nest;
 using System.Threading.Tasks;
 
 namespace LifePayment.Domain
@@ -39,5 +40,6 @@
             AlipayTradeRefundResponse response = Factory.Payment.Common().Refund(input.OutTradeNo,input.RefundAmount);
             return response;
         }
+
     }
 }
\ No newline at end of file
diff --git a/LifePayment/LifePayment.Domain/WeChat/IWxPayApi.cs b/LifePayment/LifePayment.Domain/WeChat/IWxPayApi.cs
index 3b34e5d..805ecfc 100644
--- a/LifePayment/LifePayment.Domain/WeChat/IWxPayApi.cs
+++ b/LifePayment/LifePayment.Domain/WeChat/IWxPayApi.cs
@@ -23,5 +23,9 @@
         string GeneratePaySignByKey(string message);
 
         Task<WxPayDomesticRefundsReponse> WxPayDomesticRefunds(WxPayDomesticRefundsRequest input);
+
+        Task<WxPayTradeBillApplyReponse> WxPayTradeBillApply(WxPayTradeBillApplyRequest input);
+
+        Task<WxPayTradeBillQueryReponse> WxPayTradeBillQuery(WxPayTradeBillQueryRequest input);
     }
 }
\ No newline at end of file
diff --git a/LifePayment/LifePayment.Domain/WeChat/WxClient.cs b/LifePayment/LifePayment.Domain/WeChat/WxClient.cs
index 4d30661..61f6131 100644
--- a/LifePayment/LifePayment.Domain/WeChat/WxClient.cs
+++ b/LifePayment/LifePayment.Domain/WeChat/WxClient.cs
@@ -40,7 +40,7 @@
             return result;
         }
 
-        public async Task<TResult> RefundsPostAsync<TInput, TResult>(TInput input, string function)
+        public async Task<TResult> NomalPostAsync<TInput, TResult>(TInput input, string function)
         {
             var client = HttpClientFactory.CreateClient(LifePaymentConstant.WxPayHttpClientName);
             var body = JsonConvert.SerializeObject(input);
diff --git a/LifePayment/LifePayment.Domain/WeChat/WxPayApi.cs b/LifePayment/LifePayment.Domain/WeChat/WxPayApi.cs
index c26f1e6..090020c 100644
--- a/LifePayment/LifePayment.Domain/WeChat/WxPayApi.cs
+++ b/LifePayment/LifePayment.Domain/WeChat/WxPayApi.cs
@@ -31,7 +31,19 @@
 
         public async Task<WxPayDomesticRefundsReponse> WxPayDomesticRefunds(WxPayDomesticRefundsRequest input)
         {
-            var result = await RefundsPostAsync<WxPayDomesticRefundsRequest, WxPayDomesticRefundsReponse>(input, LifePaymentConstant.WxPayDomesticRefunds);
+            var result = await NomalPostAsync<WxPayDomesticRefundsRequest, WxPayDomesticRefundsReponse>(input, LifePaymentConstant.WxPayDomesticRefunds);
+            return result;
+        }
+
+        public async Task<WxPayTradeBillApplyReponse> WxPayTradeBillApply(WxPayTradeBillApplyRequest input)
+        {
+            var result = await NomalPostAsync<WxPayTradeBillApplyRequest, WxPayTradeBillApplyReponse>(input, LifePaymentConstant.WxPayTradeBillApply);
+            return result;
+        }
+
+        public async Task<WxPayTradeBillQueryReponse> WxPayTradeBillQuery(WxPayTradeBillQueryRequest input)
+        {
+            var result = await NomalPostAsync<WxPayTradeBillQueryRequest, WxPayTradeBillQueryReponse>(input, LifePaymentConstant.WxPayTradeBillQuery);
             return result;
         }
     }
diff --git a/LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml b/LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml
index ba6111d..1a8cd0d 100644
--- a/LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml
+++ b/LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml
@@ -56,6 +56,12 @@
             </summary>
             <returns></returns>
         </member>
+        <member name="M:LifePayment.HttpApi.LifePayController.GetTopStatistics">
+            <summary>
+            鑾峰彇椤堕儴缁熻鏁版嵁
+            </summary>
+            <returns></returns>
+        </member>
         <member name="M:LifePayment.HttpApi.LifePayController.GetElectricParValue(LifePayment.Domain.Shared.ChannelsBaseInput)">
             <summary>
             鑾峰彇鐢佃垂闈㈠��
diff --git a/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml b/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
index fa1a781..60c75bb 100644
--- a/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
+++ b/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
@@ -845,6 +845,11 @@
             璁㈠崟绫诲瀷
             </summary>
         </member>
+        <member name="P:LifePayment.Application.Contracts.LifePayOrderOutput.RefundOrderNo">
+            <summary>
+            閫�娆捐鍗曞彿
+            </summary>
+        </member>
         <member name="P:LifePayment.Application.Contracts.LifePayOrderOutput.OrderNo">
             <summary>
             璁㈠崟鍙�
@@ -875,7 +880,7 @@
             鏀粯鐘舵��
             </summary>
         </member>
-        <member name="P:LifePayment.Application.Contracts.LifePayOrderOutput.LifePayOrderStatus">
+        <member name="P:LifePayment.Application.Contracts.LifePayOrderOutput.Status">
             <summary>
             璁㈠崟鐘舵��
             </summary>
@@ -908,6 +913,16 @@
         <member name="P:LifePayment.Application.Contracts.LifePayOrderOutput.RefundCredentialsImgUrl">
             <summary>
             閫�娆惧嚟璇�
+            </summary>
+        </member>
+        <member name="P:LifePayment.Application.Contracts.LifePayOrderOutput.RefundApplyRemark">
+            <summary>
+            閫�娆惧師鍥�
+            </summary>
+        </member>
+        <member name="P:LifePayment.Application.Contracts.LifePayOrderOutput.RefundCheckRemark">
+            <summary>
+            椹冲洖鍘熷洜
             </summary>
         </member>
         <member name="P:LifePayment.Application.Contracts.LifePayOrderOutput.ACOOLYOrderNo">
@@ -1015,7 +1030,7 @@
             鏀粯鐘舵��
             </summary>
         </member>
-        <member name="P:LifePayment.Application.Contracts.LifePayRefundOrderOutput.LifePayOrderStatus">
+        <member name="P:LifePayment.Application.Contracts.LifePayRefundOrderOutput.Status">
             <summary>
             璁㈠崟鐘舵��
             </summary>
@@ -1043,6 +1058,26 @@
         <member name="P:LifePayment.Application.Contracts.LifePayRefundOrderOutput.RefundCredentialsImgUrl">
             <summary>
             閫�娆惧嚟璇�
+            </summary>
+        </member>
+        <member name="P:LifePayment.Application.Contracts.LifePayRefundOrderOutput.RefundApplyRemark">
+            <summary>
+            閫�娆剧敵璇峰師鍥�
+            </summary>
+        </member>
+        <member name="P:LifePayment.Application.Contracts.LifePayRefundOrderOutput.RefundApplyTime">
+            <summary>
+            閫�娆剧敵璇锋椂闂�
+            </summary>
+        </member>
+        <member name="P:LifePayment.Application.Contracts.LifePayRefundOrderOutput.RefundCheckRemark">
+            <summary>
+            閫�娆鹃┏鍥炲師鍥�
+            </summary>
+        </member>
+        <member name="P:LifePayment.Application.Contracts.LifePayRefundOrderOutput.RefundOrderNo">
+            <summary>
+            閫�娆捐鍗曞彿
             </summary>
         </member>
         <member name="P:LifePayment.Application.Contracts.LifePayRefundOrderOutput.ACOOLYOrderNo">
@@ -1140,6 +1175,41 @@
             绱鏀舵
             </summary>
         </member>
+        <member name="P:LifePayment.Application.Contracts.TopStatisticsOutput.ReceiptsYesterda">
+            <summary>
+            鏄ㄦ棩鏀舵
+            </summary>
+        </member>
+        <member name="P:LifePayment.Application.Contracts.TopStatisticsOutput.AccumulatedOrders">
+            <summary>
+            绱涓嬪崟
+            </summary>
+        </member>
+        <member name="P:LifePayment.Application.Contracts.TopStatisticsOutput.OrdersNumYesterda">
+            <summary>
+            鏄ㄦ棩涓嬪崟
+            </summary>
+        </member>
+        <member name="P:LifePayment.Application.Contracts.TopStatisticsOutput.YesterdaSuccess">
+            <summary>
+            鏄ㄦ棩鎴愬姛
+            </summary>
+        </member>
+        <member name="P:LifePayment.Application.Contracts.TopStatisticsOutput.YesterdaFail">
+            <summary>
+            鏄ㄦ棩澶辫触
+            </summary>
+        </member>
+        <member name="P:LifePayment.Application.Contracts.TopStatisticsOutput.AccumulatedUsers">
+            <summary>
+            绱鐢ㄦ埛
+            </summary>
+        </member>
+        <member name="P:LifePayment.Application.Contracts.TopStatisticsOutput.YesterdayActiveUsers">
+            <summary>
+            鏄ㄦ棩娲昏穬鐢ㄦ埛
+            </summary>
+        </member>
         <member name="P:LifePayment.Application.Contracts.RecordOperateHistoryEto.RelationId">
             <summary>
             鍏宠仈鍏崇郴ID
diff --git a/LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs b/LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs
index 893a7e7..856ba52 100644
--- a/LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs
+++ b/LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs
@@ -363,6 +363,15 @@
             return Json(default);
         }
 
+        [HttpGet]
+        public async Task<ActionResult> GetBillErceiptExport(string orderNo)
+        {
+            var data = await _lifePayService.GetBillErceiptExport(orderNo);
+           
+
+            return Json(default);
+        }
+
         #endregion
 
         #region 鎿嶄綔

--
Gitblit v1.9.1