From e71dcccec6a1cf51c928a5143264cbbec105ff2f Mon Sep 17 00:00:00 2001 From: 移动系统liao <liaoxujun@qq.com> Date: 星期四, 22 八月 2024 08:35:21 +0800 Subject: [PATCH] 对接财富通 --- cylsg/EzUpFile/EzFileUploadService.cs | 39 +++++++++ cylsg/EzWechat/WechatConfig.json | 9 ++ .gitignore | 2 cylsg/EzWechat/WechatService.cs | 12 +++ cylsg/EzUpFile/UpFileController.cs | 69 +++++++++++++++-- cylsg/EzWechat/WecharPayServicecs.cs | 43 ++++++++++ cylsg/EzWechat/EzWechat.csproj | 1 cylsg/EzTencentCloud/TencentCloudService.cs | 6 cylsg/EzWechat/IWecharPayServicecs.cs | 19 ++++ cylsg/EzUpFile/IEzFileUploadService.cs | 12 ++ 10 files changed, 197 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index c6f6863..324afb0 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,5 @@ cylsg/EzUpFile/obj/ cylsg/cylsg.services/bin/ cylsg/EzUpFile/bin/ +cylsg/cylsg.Web.Entry/wwwroot/wechartKey/ +cylsg/cylsg.Web.Entry/wwwroot/1669018589_20240820_cert.zip diff --git a/cylsg/EzTencentCloud/TencentCloudService.cs b/cylsg/EzTencentCloud/TencentCloudService.cs index 1f80d16..ceafd97 100644 --- a/cylsg/EzTencentCloud/TencentCloudService.cs +++ b/cylsg/EzTencentCloud/TencentCloudService.cs @@ -63,7 +63,7 @@ httpProfile.Endpoint = ("ocr.tencentcloudapi.com"); clientProfile.HttpProfile = httpProfile; - var _ocrClient = new OcrClient(cred, "ap-chengdu", clientProfile); + var _ocrClient = new OcrClient(cred, "ap-shanghai", clientProfile); IDCardOCRRequest req = new IDCardOCRRequest(); if (isFRONT) @@ -175,7 +175,7 @@ httpProfile.Endpoint = ("iai.tencentcloudapi.com"); clientProfile.HttpProfile = httpProfile; - var iaiClient = new IaiClient(cred, "ap-chengdu", clientProfile); + var iaiClient = new IaiClient(cred, "ap-shanghai", clientProfile); try { var retinfo = iaiClient.GetGroupInfoSync(new GetGroupInfoRequest @@ -220,7 +220,7 @@ httpProfile.Endpoint = ("iai.tencentcloudapi.com"); clientProfile.HttpProfile = httpProfile; - var iaiClient = new IaiClient(cred, "ap-chengdu", clientProfile); + var iaiClient = new IaiClient(cred, "ap-shanghai", clientProfile); var ret= iaiClient.CreatePerson(new TencentCloud.Iai.V20200303.Models.CreatePersonRequest { GroupId = App.Configuration["IAIGroupSet:ID"], diff --git a/cylsg/EzUpFile/EzFileUploadService.cs b/cylsg/EzUpFile/EzFileUploadService.cs index e877b52..da61bfd 100644 --- a/cylsg/EzUpFile/EzFileUploadService.cs +++ b/cylsg/EzUpFile/EzFileUploadService.cs @@ -10,6 +10,8 @@ using Microsoft.AspNetCore.Http; using SqlSugar; +using System; +using System.Buffers.Text; using System.Drawing; using System.Globalization; using System.Security.Policy; @@ -339,6 +341,7 @@ idcordinfo = _tcs.IdCord(img64, PageName == "FRONT"); url = await UploadFilesFByBase64(_tcs.GetIdCordImg()); + idcordinfo.AdvancedInfo = null; return (idcordinfo, url); @@ -487,8 +490,42 @@ throw Oops.Oh(e.Message); } } +/// <inheritdoc/> - + public async Task<(bool, string)> IaiAddPerso(string imgBase64, string CoredID, string Name, int PersonGender) + { + if (string.IsNullOrEmpty(imgBase64)) + { + throw Oops.Oh("娌℃湁鍐呭"); + } + + //妫�鏌ヤ笂浼犲ぇ灏� + if (!CommonHelper.CheckBase64Size(imgBase64, 5)) + { + throw Oops.Oh("涓婁紶鏂囦欢澶у皬瓒呰繃闄愬埗锛屾渶澶у厑璁镐笂浼�" + "5" + "M"); + } + + imgBase64 = imgBase64.Replace("data:image/png;base64,", "").Replace("data:image/jgp;base64,", "").Replace("data:image/jpg;base64,", "").Replace("data:image/jpeg;base64,", "");//灏哹ase64澶撮儴淇℃伅鏇挎崲 + bool info = false; + string url = ""; + + try + { + info = _tcs.IaiAddPerso(imgBase64, CoredID, Name, PersonGender); + + url = await UploadFilesFByBase64(imgBase64); + + return (info, url); + + } + catch (Exception e) + { + + throw Oops.Oh(e.Message); + } + } + + #endregion } } diff --git a/cylsg/EzUpFile/IEzFileUploadService.cs b/cylsg/EzUpFile/IEzFileUploadService.cs index 28cd115..dbf822d 100644 --- a/cylsg/EzUpFile/IEzFileUploadService.cs +++ b/cylsg/EzUpFile/IEzFileUploadService.cs @@ -42,14 +42,22 @@ Task<(BizLicenseOCRResponse, string)> UpBizLicense(); /// <summary> - /// 鍒涘缓浜鸿劯鐗瑰緛 + /// 鍒涘缓浜鸿劯鐗瑰緛 鏂囦欢浼犻�� /// </summary> /// <param name="CoredID"> 韬唤璇佸彿</param> /// <param name="Name">濮撳悕</param> /// <param name="PersonGender"> 鎬у埆 0浠h〃鏈~鍐欙紝1浠h〃鐢锋�э紝2浠h〃濂虫�с��</param> /// <returns></returns> Task<(bool, string)> IaiAddPerso(string CoredID, string Name, int PersonGender); - + /// <summary> + /// 鍒涘缓浜鸿劯鐗瑰緛 + /// </summary> + /// <param name="imgBase64">img base64</param> + /// <param name="CoredID"> 韬唤璇佸彿</param> + /// <param name="Name">濮撳悕</param> + /// <param name="PersonGender"> 鎬у埆 0浠h〃鏈~鍐欙紝1浠h〃鐢锋�э紝2浠h〃濂虫�с��</param> + /// <returns></returns> + Task<(bool, string)> IaiAddPerso(string imgBase64, string CoredID, string Name, int PersonGender); } diff --git a/cylsg/EzUpFile/UpFileController.cs b/cylsg/EzUpFile/UpFileController.cs index fb6614d..a3ee514 100644 --- a/cylsg/EzUpFile/UpFileController.cs +++ b/cylsg/EzUpFile/UpFileController.cs @@ -1,4 +1,5 @@ 锘縰sing EzTencentCloud; +using Furion.FriendlyException; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.HttpResults; using Microsoft.AspNetCore.Mvc; @@ -28,12 +29,12 @@ /// <param name="PageName"> 韬唤璇佹鍙嶉潰 FRONT 姝i潰 Back 鍥藉窘鍙嶉潰 </param> /// <returns></returns> [HttpPost] - public async Task<(IDCardOCRResponse, string)> UploadIdCord([FromServices] IEzFileUploadService fileUploadService,IFormFile file, [FromQuery] string PageName = "FRONT") + public async Task<Object> UploadIdCord([FromServices] IEzFileUploadService fileUploadService,IFormFile file, [FromQuery] string PageName = "FRONT") { - return await fileUploadService.UpIdCord(PageName); - + var ret= await fileUploadService.UpIdCord(PageName); + return new { Info = ret.Item1, url = ret.Item2 }; } /// <summary> @@ -42,11 +43,12 @@ /// <param name="PageName"> 韬唤璇佹鍙嶉潰 FRONT 姝i潰 Back 鍥藉窘鍙嶉潰 </param> /// <returns></returns> [HttpPost] - public async Task<(BizLicenseOCRResponse, string)> UpBizLicense([FromServices] IEzFileUploadService fileUploadService, IFormFile file) + public async Task<Object> UpBizLicense([FromServices] IEzFileUploadService fileUploadService, IFormFile file) { - return await fileUploadService.UpBizLicense(); + var ret= await fileUploadService.UpBizLicense(); + return new { Info = ret.Item1, url = ret.Item2 }; } /// <summary> @@ -57,11 +59,32 @@ /// <param name="Gender">0浠h〃鏈~鍐欙紝1浠h〃鐢锋�э紝2浠h〃濂虫�с��</param> /// <returns></returns> [HttpPost] - public async Task<(bool , string)> IaiAddPerso([FromServices] IEzFileUploadService fileUploadService, IFormFile file,[FromQuery] string CordId, [FromQuery] string Name, [FromQuery] int Gender) + public async Task<object> IaiAddPerso([FromServices] IEzFileUploadService fileUploadService, IFormFile file,[FromQuery] string CordId, [FromQuery] string Name, [FromQuery] int Gender) { - return await fileUploadService.IaiAddPerso(CordId, Name,Gender); + var ret= await fileUploadService.IaiAddPerso(CordId, Name,Gender); + return new { IsOK = ret.Item1, url = ret.Item2 }; + + + } + + /// <summary> + /// 澧炲姞浜鸿劯搴� base64 + /// </summary> + /// <param name="param"></param> + /// <returns></returns> + [HttpPost] + public async Task<object> IaiAddPersoBase64([FromServices] IEzFileUploadService fileUploadService, UpDataFileData param) + { + if (string.IsNullOrEmpty(param.imgBase64)) + throw Oops.Oh("娌℃湁鏂囦欢绫诲"); + if (string.IsNullOrEmpty(param.Name)) + throw Oops.Oh("娌℃湁濮撳悕"); + if (string.IsNullOrEmpty(param.CordId)) + throw Oops.Oh("娌℃湁韬唤璇佷俊鎭�"); + var ret = await fileUploadService.IaiAddPerso(param.imgBase64, param.CordId, param. Name, param.Gender??0); + return new { IsOK = ret.Item1, url = ret.Item2 }; } @@ -103,7 +126,7 @@ [HttpPost] public async Task<string> UpdateFileBase64([FromServices] IEzFileUploadService fileUploadService, UpDataFileData Param) { - return await fileUploadService.UploadFilesFByBase64(Param.FileBase64); + return await fileUploadService.UploadFilesFByBase64(Param.imgBase64); } [HttpPost] public async Task<bool> DelFile([FromServices] IEzFileUploadService fileUploadService, DelFileData Param) @@ -120,7 +143,19 @@ /// <summary> /// 鏁版嵁base64 /// </summary> - public string FileBase64 { get; set; } + public string imgBase64 { get; set; } + /// <summary> + /// 韬唤璇佸彿鐮� + /// </summary> + public string? CordId { get; set; } + /// <summary> + /// 濮撳悕 + /// </summary> + public string? Name { get; set; } + /// <summary> + /// 鎬у埆 + /// </summary> + public int? Gender { get; set; } } /// <summary> /// 涓婁紶鏁版嵁 @@ -133,4 +168,20 @@ /// </summary> public string FilePath { get; set; } } + /// <summary> + /// 韬唤璇佽繑鍥炶緭鍑� + /// </summary> + public class IdCordOuput + { + /// <summary> + /// 韬唤璇佺浉鍏充俊鎭� + /// </summary> + public IDCardOCRResponse IdCordInfo { get; set; } + + /// <summary> + /// url + /// </summary> + public string Url { get; set; } + + } } diff --git a/cylsg/EzWechat/EzWechat.csproj b/cylsg/EzWechat/EzWechat.csproj index 1e28ec0..ed480b7 100644 --- a/cylsg/EzWechat/EzWechat.csproj +++ b/cylsg/EzWechat/EzWechat.csproj @@ -8,6 +8,7 @@ <ItemGroup> <PackageReference Include="SKIT.FlurlHttpClient.Wechat.Api" Version="3.4.0" /> + <PackageReference Include="SKIT.FlurlHttpClient.Wechat.TenpayV3" Version="3.7.0" /> </ItemGroup> <ItemGroup> diff --git a/cylsg/EzWechat/IWecharPayServicecs.cs b/cylsg/EzWechat/IWecharPayServicecs.cs new file mode 100644 index 0000000..21173bd --- /dev/null +++ b/cylsg/EzWechat/IWecharPayServicecs.cs @@ -0,0 +1,19 @@ +锘縰sing SKIT.FlurlHttpClient.Wechat.TenpayV3.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EzWechat +{ + public interface IWecharPayServicecs + { + /// <summary> + /// 鏀粯涓�鍗� + /// </summary> + /// <param name="request"></param> + /// <returns></returns> + Task<CreateTransferBatchResponse> PayOderAsync(CreateTransferBatchRequest request); + } +} diff --git a/cylsg/EzWechat/WecharPayServicecs.cs b/cylsg/EzWechat/WecharPayServicecs.cs new file mode 100644 index 0000000..e4a37ab --- /dev/null +++ b/cylsg/EzWechat/WecharPayServicecs.cs @@ -0,0 +1,43 @@ +锘縰sing Furion; +using Furion.DependencyInjection; +using SKIT.FlurlHttpClient.Wechat.TenpayV3; +using SKIT.FlurlHttpClient.Wechat.TenpayV3.Models; +using SKIT.FlurlHttpClient.Wechat.TenpayV3.Settings; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static SKIT.FlurlHttpClient.Wechat.Api.Models.CgibinOpenApiRequestIdGetResponse.Types; + +namespace EzWechat +{ + /// <summary> + /// 寰俊鏀粯鏈嶅姟 + /// </summary> + public class WecharPayServicecs:IWecharPayServicecs, IScoped + { + private readonly WechatTenpayClient _V3Client; + + public WecharPayServicecs() { + var manager = new InMemoryCertificateManager(); + var options = new WechatTenpayClientOptions() + { + MerchantId = App.Configuration["WechartPay:MerchantId"], + MerchantV3Secret = App.Configuration["WechartPay:lojdhuqyt5648dikunm623ddsl2543a5"], + MerchantCertificateSerialNumber = App.Configuration["WechartPay:MerchantCertificateSerialNumber"], + MerchantCertificatePrivateKey = System.IO.File.ReadAllText(App.Configuration["WechartPay:apiclient_keyFile"]), + PlatformCertificateManager = manager // 骞冲彴璇佷功绠$悊鍣ㄧ殑鍏蜂綋鐢ㄦ硶璇峰弬闃呬笅鏂囩殑鍩虹鐢ㄦ硶涓庡姞瀵嗐�侀獙绛炬湁鍏崇殑绔犺妭 + }; + _V3Client = WechatTenpayClientBuilder.Create(options).Build(); + } + + public async Task<CreateTransferBatchResponse> PayOderAsync(CreateTransferBatchRequest request) + { + + var response = await _V3Client.ExecuteCreateTransferBatchAsync(request); + return response; + + } + } +} diff --git a/cylsg/EzWechat/WechatConfig.json b/cylsg/EzWechat/WechatConfig.json index f238b57..a7d7366 100644 --- a/cylsg/EzWechat/WechatConfig.json +++ b/cylsg/EzWechat/WechatConfig.json @@ -3,5 +3,14 @@ "AppId": "wx983556688354dd14", "AppSecret": "2ab1aefaac926855dc9d5f7bf7f04477" + }, + + "WechartPay": { + + "MerchantV3Secret": "lojdhuqyt5648dikunm623ddsl2543a5", + "MerchantId": "1669018589", + "MerchantCertificateSerialNumber": "49FFE8CB27B5EDD026BFF23C41F0DAA83405EB10", + "apiclient_keyFile": "wwwroot\\wechartKey\\apiclient_key.pem" + } } \ No newline at end of file diff --git a/cylsg/EzWechat/WechatService.cs b/cylsg/EzWechat/WechatService.cs index 1d07cce..5070c70 100644 --- a/cylsg/EzWechat/WechatService.cs +++ b/cylsg/EzWechat/WechatService.cs @@ -13,6 +13,7 @@ using System.Text; using System.Threading.Tasks; + namespace EzWechat { @@ -106,5 +107,16 @@ return key; } + + + + + + + + + } + + } -- Gitblit v1.9.1