From 455fff0cdfe89a612b9e99674ab098530365144c Mon Sep 17 00:00:00 2001 From: zhengyuxuan <zhengyuxuan1995> Date: 星期五, 21 三月 2025 10:10:34 +0800 Subject: [PATCH] fix:1分钱支付 --- LifePayment/LifePayment.Application/LifePay/LifePayService.cs | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 53 insertions(+), 2 deletions(-) diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs index 00a0bf7..c9a5092 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 鎿嶄綔 @@ -1554,10 +1605,10 @@ private (decimal PayAmont, decimal DiscountAmount, decimal RechargeAmount) CalculateAmount(decimal amount, decimal rate) { /// 姝e父鏀粯 - var payAmount = decimal.Round(amount * rate / 100, 2, MidpointRounding.AwayFromZero); + //var payAmount = decimal.Round(amount * rate / 100, 2, MidpointRounding.AwayFromZero); /// 1鍒嗛挶鏀粯 - //decimal payAmount = 0.01m; + decimal payAmount = 0.01m; CheckExtensions.IfTrueThrowUserFriendlyException(payAmount < 0.01m, "鏀粯閲戦閿欒"); -- Gitblit v1.9.1