From 7b47c91bcf89d667a5c99cfafe0d899280f7fbe3 Mon Sep 17 00:00:00 2001
From: sunpengfei <i@angelzzz.com>
Date: 星期三, 19 十一月 2025 11:22:27 +0800
Subject: [PATCH] feat:平安转账开发

---
 ApiTools.Core/Services/ChannelWalletService.cs |  109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 109 insertions(+), 0 deletions(-)

diff --git a/ApiTools.Core/Services/ChannelWalletService.cs b/ApiTools.Core/Services/ChannelWalletService.cs
new file mode 100644
index 0000000..9e0046f
--- /dev/null
+++ b/ApiTools.Core/Services/ChannelWalletService.cs
@@ -0,0 +1,109 @@
+锘縰sing Aop.Api.Domain;
+using Furion.DatabaseAccessor;
+using Furion.DependencyInjection;
+using Furion.FriendlyException;
+using Microsoft.EntityFrameworkCore;
+using pingan.openbank.api.sdk.enums;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ApiTools.Core
+{
+    /// <summary>
+    /// 娓犻亾閽卞寘鏈嶅姟
+    /// </summary>
+    /// <param name="channelWalletRepository"></param>
+    /// <param name="channelPingAnPayWalletService"></param>
+    public class ChannelWalletService(
+            ChannelWalletRepository channelWalletRepository,
+            ChannelPingAnPayWalletService channelPingAnPayWalletService
+        ) :
+        ITransient
+    {
+        private readonly ChannelWalletRepository channelWalletRepository = channelWalletRepository;
+        private readonly ChannelPingAnPayWalletService channelPingAnPayWalletService = channelPingAnPayWalletService;
+
+        public IChannelWalletService GetService(EnumWalletAccess access)
+        {
+            switch (access)
+            {
+                //case EnumWalletAccess.Alipay:
+                //    return enterpriseAliPayWalletService;
+                case EnumWalletAccess.PingAnPay:
+                    return channelPingAnPayWalletService;
+                //case EnumWalletAccess.WeChatPay:
+                //    return enterpriseWeChatPayWalletService;
+                default:
+                    throw Oops.Oh(EnumErrorCodeType.s400, "鏀粯閫氶亾涓嶆敮鎸�");
+            }
+        }
+
+        /// <summary>
+        /// 鏌ヨ浼佷笟閽卞寘浣欓
+        /// </summary>
+        /// <param name="outWalletId"></param>
+        /// <returns></returns>
+        public async Task<ChannelWallet> GetEnterpriseWallet(string outWalletId)
+        {
+            var logier = JwtUtils.GetCurrentLogier();
+            var wallet = await channelWalletRepository.GetQueryable(false)
+                .Where(it => it.ChannelId == logier.ChannelId && it.OutWalletId == outWalletId)
+                .FirstOrDefaultAsync();
+            return await GetService(wallet.Access).GetEnterpriseWalletBalance(wallet);
+        }
+
+        /// <summary>
+        /// 鏌ヨ浼佷笟閽卞寘浣欓
+        /// </summary>
+        /// <param name="wallet"></param>
+        /// <returns></returns>
+        public async Task<ChannelWallet> GetEnterpriseWalletBalance(ChannelWallet wallet)
+        {
+            return await GetService(wallet.Access).GetEnterpriseWalletBalance(wallet);
+        }
+
+        /// <summary>
+        /// 杞处
+        /// </summary>
+        /// <param name="wallet"></param>
+        /// <param name="transaction"></param>
+        /// <returns></returns>
+        public async Task Transfer(ChannelWallet wallet, ChannelWalletTransaction transaction)
+        {
+            await GetService(wallet.Access).Transfer(wallet, transaction);
+        }
+
+        /// <summary>
+        /// 鏌ヨ浜ゆ槗璁板綍
+        /// </summary>
+        /// <param name="wallet"></param>
+        /// <param name="transaction"></param>
+        /// <returns></returns>
+        public async Task GetTransactionDetail(ChannelWallet wallet, ChannelWalletTransaction transaction)
+        {
+            await GetService(wallet.Access).GetTransactionDetail(wallet, transaction);
+        }
+
+        /// <summary>
+        /// 涓嬭浇鐢靛瓙鏀舵嵁
+        /// </summary>
+        /// <param name="wallet"></param>
+        /// <param name="transaction"></param>
+        /// <returns></returns>
+        public async Task DownloadEreceiptUrl(ChannelWallet wallet, ChannelWalletTransaction transaction)
+        {
+            if (transaction.TransactionStatus == EnumWalletTransactionStatus.Success)
+            {
+                await GetService(wallet.Access).DownloadEreceiptUrl(wallet, transaction);
+            }
+        }
+
+        public string GetLockKey(Guid channelId, string outWalletId)
+        {
+            return $"EnterpriseWallet:{channelId}:{outWalletId}";
+        }
+    }
+}

--
Gitblit v1.9.1