From 986bf3b61986403fee41972e31a21ae45262991b Mon Sep 17 00:00:00 2001 From: wanghaomei <86whm@163.com> Date: Thu, 7 Mar 2024 10:09:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=A3=E8=B4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Event/BookingFeeSubscriber.cs | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/Myshipping.Application/Event/BookingFeeSubscriber.cs b/Myshipping.Application/Event/BookingFeeSubscriber.cs index 0f732623..c5d70b10 100644 --- a/Myshipping.Application/Event/BookingFeeSubscriber.cs +++ b/Myshipping.Application/Event/BookingFeeSubscriber.cs @@ -66,6 +66,7 @@ namespace Myshipping.Application.Event var repoUser = scope.ServiceProvider.GetRequiredService>(); var repoBooking = scope.ServiceProvider.GetRequiredService>(); var repoFeeRecord = scope.ServiceProvider.GetRequiredService>(); + var repoTenantParamValue = scope.ServiceProvider.GetRequiredService>(); var cache = scope.ServiceProvider.GetRequiredService(); var typeStr = $"{bsType}_{sendType}"; @@ -73,13 +74,13 @@ namespace Myshipping.Application.Event var idToDo = idList.Except(dbFeeRecord).ToList(); var sysCfg = await cache.GetAllSysConfig(); var feeUrl = sysCfg.FirstOrDefault(x => x.Code == "djyFeeApiUrl"); - var feeUserId = sysCfg.FirstOrDefault(x => x.Code == "djyFeeApiUserId"); - var feeKey = sysCfg.FirstOrDefault(x => x.Code == "djyFeeApiKey"); - if (feeKey == null || string.IsNullOrEmpty(feeUrl.Value) - || feeUserId == null || string.IsNullOrEmpty(feeUserId.Value) - || feeKey == null || string.IsNullOrEmpty(feeKey.Value)) + //var feeUserId = sysCfg.FirstOrDefault(x => x.Code == "djyFeeApiUserId"); + //var feeKey = sysCfg.FirstOrDefault(x => x.Code == "djyFeeApiKey"); + if (feeUrl == null || string.IsNullOrEmpty(feeUrl.Value)) + //|| feeUserId == null || string.IsNullOrEmpty(feeUserId.Value) + //|| feeKey == null || string.IsNullOrEmpty(feeKey.Value)) { - var errMsg = "大简云扣费URL和KEY未配置"; + var errMsg = "大简云扣费URL未配置"; _logger.LogError(errMsg); DingTalkGroupHelper.SendDingTalkGroupMessage("bookingFeeNotify", "扣费失败提醒", errMsg); return; @@ -90,6 +91,21 @@ namespace Myshipping.Application.Event var order = await repoBooking.AsQueryable().Filter(null, true).FirstAsync(x => x.Id == id); var iptId = string.IsNullOrEmpty(order.OPID) ? order.CreatedUserId.Value : Convert.ToInt64(order.OPID); var user = await repoUser.AsQueryable().Filter(null, true).FirstAsync(x => x.Id == iptId); + var keyList = await repoTenantParamValue.AsQueryable() + .Filter(null, true) + .Where(x => x.TenantId == order.TenantId && (x.ParaCode == "BOOKING_FEE_USERID" || x.ParaCode == "BOOKING_FEE_USERKEY")) + .ToListAsync(); + if (keyList.Count < 2) + { + var errMsg = $"未找到{order.MBLNO}({id})所在租户的授权userid和key,无法调用扣费"; + _logger.LogError(errMsg); + DingTalkGroupHelper.SendDingTalkGroupMessage("bookingFeeNotify", "扣费失败提醒", errMsg); + continue; + } + var feeUserId = keyList.First(x => x.ParaCode == "BOOKING_FEE_USERID").ItemCode; + var feeUserKey = keyList.First(x => x.ParaCode == "BOOKING_FEE_USERKEY").ItemCode; + + if (user == null || string.IsNullOrEmpty(user.DjyUserId)) { var errMsg = $"未找到{order.MBLNO}({id})的用户信息,无法调用扣费"; @@ -100,11 +116,11 @@ namespace Myshipping.Application.Event var seconds = DateTime.Now.ToTimeStamp(); var runId = Guid.NewGuid().ToString(); - var srcBeforMD5 = $"{runId}{feeUserId.Value}expend{bsType}{sendType}{id}{order.MBLNO}{seconds}{feeKey.Value}"; + var srcBeforMD5 = $"{runId}{feeUserId}expend{bsType}{sendType}{id}{order.MBLNO}{seconds}{feeUserKey}"; var postObj = new { runId, - userId = feeUserId.Value, + userId = feeUserId, module = "expend",//固定 bsType = $"{bsType}", sendType = $"{sendType}",