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

---
 LifePayment/LifePayment.Application/LifePay/LifePayService.cs |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 51 insertions(+), 0 deletions(-)

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 鎿嶄綔

--
Gitblit v1.9.1