|
|
|
@ -66,6 +66,7 @@ namespace Myshipping.Application.Event
|
|
|
|
|
var repoUser = scope.ServiceProvider.GetRequiredService<SqlSugarRepository<SysUser>>();
|
|
|
|
|
var repoBooking = scope.ServiceProvider.GetRequiredService<SqlSugarRepository<BookingOrder>>();
|
|
|
|
|
var repoFeeRecord = scope.ServiceProvider.GetRequiredService<SqlSugarRepository<BookingFeeRecord>>();
|
|
|
|
|
var repoTenantParamValue = scope.ServiceProvider.GetRequiredService<SqlSugarRepository<DjyTenantParamValue>>();
|
|
|
|
|
var cache = scope.ServiceProvider.GetRequiredService<ISysCacheService>();
|
|
|
|
|
|
|
|
|
|
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}",
|
|
|
|
|