From efef23b91cfcdf3e242258876b2b4ae8abb8fb7e Mon Sep 17 00:00:00 2001 From: zhengyuxuan <zhengyuxuan1995> Date: 星期四, 27 三月 2025 13:39:15 +0800 Subject: [PATCH] fix:支持在配置文件中配置是否开启1分钱支付 --- LifePayment/LifePayment.Host/appsettings.json | 4 ++-- LifePayment/LifePayment.Application/LifePay/LifePayService.cs | 23 ++++++++++++++++------- LifePayment/LifePayment.Domain.Shared/InitSetting.cs | 5 +++++ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs index 715815b..f932280 100644 --- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs +++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs @@ -51,6 +51,7 @@ private readonly IAlipayInterfaceManager _alipayInterfaceManager; private readonly IWxPayApi _wxPayApi; private readonly WxPayOption _wxPayOptions; + private readonly InitSetting _initSettingOptions; private readonly IACOOLYManager _aCOOLYManager; @@ -67,6 +68,7 @@ IAlipayInterfaceManager aliPayInterfaceManager, IWxPayApi wxPayApi, IOptions<WxPayOption> wxPayOptions, + IOptions<InitSetting> initSettingOptions, IRepository<LifePayChannles, Guid> lifePayChannlesRep, IRepository<LifePayAccount, Guid> lifePayAccount, IDataFilter dataFilter, @@ -83,6 +85,7 @@ _alipayInterfaceManager = aliPayInterfaceManager; _wxPayApi = wxPayApi; _wxPayOptions = wxPayOptions.Value; + _initSettingOptions = initSettingOptions.Value; _distributedEventBus = distributedEventBus; _lifePayChannlesRep = lifePayChannlesRep; _lifePayAccount = lifePayAccount; @@ -1810,15 +1813,21 @@ private (decimal PayAmont, decimal DiscountAmount, decimal RechargeAmount) CalculateAmount(decimal amount, decimal rate) { - /// 姝e父鏀粯 - //var payAmount = decimal.Round(amount * rate / 100, 2, MidpointRounding.AwayFromZero); + if (_initSettingOptions.OpenTheOnePennyTest) + { + /// 1鍒嗛挶鏀粯 + decimal payAmount = 0.01m; - /// 1鍒嗛挶鏀粯 - decimal payAmount = 0.01m; + CheckExtensions.IfTrueThrowUserFriendlyException(payAmount < 0.01m, "鏀粯閲戦閿欒"); - CheckExtensions.IfTrueThrowUserFriendlyException(payAmount < 0.01m, "鏀粯閲戦閿欒"); - - return (payAmount, amount - payAmount, amount); + return (payAmount, amount - payAmount, amount); + } + else + { + /// 姝e父鏀粯 + var payAmount = decimal.Round(amount * rate / 100, 2, MidpointRounding.AwayFromZero); + return (payAmount, amount - payAmount, amount); + } } private void SetOrderStatus(LifePayOrder order, string code) diff --git a/LifePayment/LifePayment.Domain.Shared/InitSetting.cs b/LifePayment/LifePayment.Domain.Shared/InitSetting.cs index 7f31665..078f435 100644 --- a/LifePayment/LifePayment.Domain.Shared/InitSetting.cs +++ b/LifePayment/LifePayment.Domain.Shared/InitSetting.cs @@ -155,5 +155,10 @@ /// 褰撳墠鐢靛瓙绛� /// </summary> public string CurrentSign { get; set; } + + /// <summary> + /// 寮�鍚�1鍒嗛挶娴嬭瘯妯″紡 + /// </summary> + public bool OpenTheOnePennyTest { get; set; } } } \ No newline at end of file diff --git a/LifePayment/LifePayment.Host/appsettings.json b/LifePayment/LifePayment.Host/appsettings.json index f1862cd..215c844 100644 --- a/LifePayment/LifePayment.Host/appsettings.json +++ b/LifePayment/LifePayment.Host/appsettings.json @@ -113,7 +113,8 @@ "OfflinePayEndDays": 3, //绾夸笅鏀粯姹囨鏃堕棿鏈�鏅氬ぉ鏁�(鍗曚綅锛氬ぉ) "BankWalletAccountOpenCodeProviderName": "BankWalletAccountOpen", //閾惰閽卞寘寮�鎴烽獙璇佺爜妯℃澘鍚嶇О "BankWalletAccountOpenCodeValidTime": 5, //閾惰閽卞寘寮�鎴烽獙璇佺爜鏈夋晥鏃堕棿(鍗曚綅鍒�) - "FaceAuthReturnUrl": "https://www.81812333.com/" + "FaceAuthReturnUrl": "https://www.81812333.com/", + "OpenTheOnePennyTest": true //寮�鍚�1鍒嗛挶娴嬭瘯妯″紡 }, "ACOOLY": { "PartnerId": "250220171531F0572977", @@ -155,6 +156,5 @@ "EncryptKey": "jjy8A7hB/1Bkhg+8FtXyyg==", "AlipayPublicKey": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoDrOheetqHkE1RYaNhogP/iHVXEtGZW4A/JJnwpJs+6eLXfpXf/ecuywplDpgc/BXSUEnDaktUwceLXO8vdIf8h0y8yqWwYdgzC0xELYpTroK3dlNiShgVkUEeMXi+n3Mhjp9OVrqieggDI3YGzDBLY4UAWsXCcXnD+r/xIpT8keVMtb/LrUmL5XLvBVcn5MkJTAoeFt18EQXOLFN1+ldpaf9k+iyM2fbgXCc6InNSgHGSHZwhzm9t+cGqNd1ju/nQN9lHwKCDQPMn6cor2lsP1nsEfpHp2vdfNEdccVSRZB/kdtFzXEUpTFznz8+zK2D0Ra+B0G1nSxus9xsD3HmwIDAQAB" }, - "AllowedHosts": "*" } \ No newline at end of file -- Gitblit v1.9.1