订舱数据回推

optimize
wanghaomei 1 year ago
parent b5c5781c33
commit 2689aaa89c

@ -1,5 +1,7 @@
using Furion;
using Furion.EventBus;
using Furion.FriendlyException;
using Furion.RemoteRequest.Extensions;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
@ -8,6 +10,8 @@ using Myshipping.Application.Entity;
using Myshipping.Application.Service.BookingOrder.Dto;
using Myshipping.Core;
using Myshipping.Core.Entity;
using Myshipping.Core.Service;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
@ -48,6 +52,8 @@ namespace Myshipping.Application.Event
var repoGoodsSta = scope.ServiceProvider.GetRequiredService<SqlSugarRepository<BookingGoodsStatus>>();
var repoGoodsStaCfg = scope.ServiceProvider.GetRequiredService<SqlSugarRepository<BookingGoodsStatusConfig>>();
var cacheService = scope.ServiceProvider.GetRequiredService<ISysCacheService>();
var custOrder = await repoCutomerOrder.AsQueryable().Filter(null, true).FirstAsync(x => x.BookingId == bookId);
if (custOrder == null) //非客户订舱系统过来的数据
{
@ -105,7 +111,50 @@ namespace Myshipping.Application.Event
}
}
_logger.LogInformation($"准备发送客户订舱数据同步:{sendObj.ToJsonString()}");
//回推回执
var recFeedbackConfig = cacheService.GetAllSysConfig().Result.FirstOrDefault(x => x.Code == "DjyBookingCustomerRecFeedbackURL");
if (recFeedbackConfig == null || string.IsNullOrEmpty(recFeedbackConfig.Value))
{
throw Oops.Bah("回推订舱数据的URL地址未配置请联系管理员");
}
var recFeedbackUserKey = cacheService.GetAllSysConfig().Result.FirstOrDefault(x => x.Code == "DjyBookingCustomerRecFeedbackUserKey");
if (recFeedbackUserKey == null || string.IsNullOrEmpty(recFeedbackUserKey.Value))
{
throw Oops.Bah("回推订舱数据的用户KEY未配置请联系管理员");
}
var recFeedbackUserSecret = cacheService.GetAllSysConfig().Result.FirstOrDefault(x => x.Code == "DjyBookingCustomerRecFeedbackUserSecret");
if (recFeedbackUserSecret == null || string.IsNullOrEmpty(recFeedbackUserSecret.Value))
{
throw Oops.Bah("回推订舱数据的用户秘钥未配置,请联系管理员");
}
var feedbackUrl = recFeedbackConfig.Value;
if (!feedbackUrl.EndsWith("/"))
{
feedbackUrl += "/";
}
feedbackUrl += "BookingCustomerOrder/RecBookingDataFeedback";
_logger.LogInformation($"准备发送客户订舱数据同步:{sendObj.ToJsonString()}URL{feedbackUrl}");
var rtn = await feedbackUrl
.SetHeaders(new Dictionary<string, object> {
{ CommonConst.API_USER_HEADER_KEY, recFeedbackUserKey.Value},
{ CommonConst.API_USER_HEADER_SECRET, recFeedbackUserSecret.Value}
})
.SetBody(sendObj)
.PostAsStringAsync();
_logger.LogInformation($"回推审核返回:{rtn}");
var jobjRtn = JObject.Parse(rtn);
if (jobjRtn.GetIntValue("code") != 200)
{
throw Oops.Bah(jobjRtn.GetStringValue("message"));
}
}
}
}

@ -863,19 +863,19 @@ namespace Myshipping.Application
}
//回推回执
var recFeedbackConfig = _cache.GetAllSysConfig().Result.FirstOrDefault(x => x.Code == "DjyBookingCustomerRecAuditFeedbackURL");
var recFeedbackConfig = _cache.GetAllSysConfig().Result.FirstOrDefault(x => x.Code == "DjyBookingCustomerRecFeedbackURL");
if (recFeedbackConfig == null || string.IsNullOrEmpty(recFeedbackConfig.Value))
{
throw Oops.Bah("回推订舱审核结果的URL地址未配置请联系管理员");
}
var recFeedbackUserKey = _cache.GetAllSysConfig().Result.FirstOrDefault(x => x.Code == "DjyBookingCustomerRecAuditFeedbackUserKey");
var recFeedbackUserKey = _cache.GetAllSysConfig().Result.FirstOrDefault(x => x.Code == "DjyBookingCustomerRecFeedbackUserKey");
if (recFeedbackUserKey == null || string.IsNullOrEmpty(recFeedbackUserKey.Value))
{
throw Oops.Bah("回推订舱审核结果的用户KEY未配置请联系管理员");
}
var recFeedbackUserSecret = _cache.GetAllSysConfig().Result.FirstOrDefault(x => x.Code == "DjyBookingCustomerRecAuditFeedbackUserSecret");
var recFeedbackUserSecret = _cache.GetAllSysConfig().Result.FirstOrDefault(x => x.Code == "DjyBookingCustomerRecFeedbackUserSecret");
if (recFeedbackUserSecret == null || string.IsNullOrEmpty(recFeedbackUserSecret.Value))
{
throw Oops.Bah("回推订舱审核结果的用户秘钥未配置,请联系管理员");
@ -888,9 +888,17 @@ namespace Myshipping.Application
Comment = comment
};
_logger.LogInformation($"回推审核数据:{JsonConvert.SerializeObject(sendObj)}");
var feedbackUrl = recFeedbackConfig.Value;
if (!feedbackUrl.EndsWith("/"))
{
feedbackUrl += "/";
}
feedbackUrl += "BookingCustomerOrder/RecBookingAuditFeedback";
_logger.LogInformation($"回推审核数据:{JsonConvert.SerializeObject(sendObj)}URL{feedbackUrl}");
var rtn = await recFeedbackConfig.Value
var rtn = await feedbackUrl
.SetHeaders(new Dictionary<string, object> {
{ CommonConst.API_USER_HEADER_KEY, recFeedbackUserKey.Value},
{ CommonConst.API_USER_HEADER_SECRET, recFeedbackUserSecret.Value}

Loading…
Cancel
Save