修改日志
This commit is contained in:
parent
c3e4130548
commit
e295e8d91a
|
|
@ -54,8 +54,16 @@ namespace HuanMeng.MiaoYu.WebPayApi.Controllers
|
||||||
[HttpPost("{tenant?}/{pay?}/{orderId?}/{sign?}")]
|
[HttpPost("{tenant?}/{pay?}/{orderId?}/{sign?}")]
|
||||||
public async Task<string> Post(string? tenant, string? pay, string? orderId, string? sign)
|
public async Task<string> Post(string? tenant, string? pay, string? orderId, string? sign)
|
||||||
{
|
{
|
||||||
#region 验证签名
|
|
||||||
var context = httpContextAccessor.HttpContext;
|
var context = httpContextAccessor.HttpContext;
|
||||||
|
context.Request.EnableBuffering(); // Enable buffering to allow the body to be read multiple times
|
||||||
|
using (var reader = new StreamReader(context.Request.Body, Encoding.UTF8, true, 1024, leaveOpen: true))
|
||||||
|
{
|
||||||
|
var bodyContent = await reader.ReadToEndAsync();
|
||||||
|
logger.LogInformation($"请求支付回调接口,请求路径: {context.Request.Path}, 请求Body: {bodyContent}");
|
||||||
|
context.Request.Body.Position = 0;
|
||||||
|
}
|
||||||
|
#region 验证签名
|
||||||
|
|
||||||
var orderInfo = PaymentExtend.ParseCustomString(orderId);
|
var orderInfo = PaymentExtend.ParseCustomString(orderId);
|
||||||
string newSign = $"{tenant}{orderId}{orderInfo.UserId}";
|
string newSign = $"{tenant}{orderId}{orderInfo.UserId}";
|
||||||
newSign = MD5Encryption.ComputeMD5Hash(newSign);
|
newSign = MD5Encryption.ComputeMD5Hash(newSign);
|
||||||
|
|
@ -109,7 +117,7 @@ namespace HuanMeng.MiaoYu.WebPayApi.Controllers
|
||||||
await dao.daoDbMiaoYu.context.SaveChangesAsync();
|
await dao.daoDbMiaoYu.context.SaveChangesAsync();
|
||||||
return $"error;用户不存在";
|
return $"error;用户不存在";
|
||||||
}
|
}
|
||||||
using (IDbContextTransaction transaction = dao.daoDbMiaoYu.context.Database.BeginTransaction(System.Data.IsolationLevel.RepeatableRead))
|
using (IDbContextTransaction transaction = dao.daoDbMiaoYu.context.Database.BeginTransaction(System.Data.IsolationLevel.ReadUncommitted))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -133,13 +141,7 @@ namespace HuanMeng.MiaoYu.WebPayApi.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
redis.KeyDelete(baseKey);
|
redis.KeyDelete(baseKey);
|
||||||
context.Request.EnableBuffering(); // Enable buffering to allow the body to be read multiple times
|
|
||||||
using (var reader = new StreamReader(context.Request.Body, Encoding.UTF8, true, 1024, leaveOpen: true))
|
|
||||||
{
|
|
||||||
var bodyContent = await reader.ReadToEndAsync();
|
|
||||||
logger.LogInformation($"请求支付回调接口,请求路径: {context.Request.Path}, 请求Body: {bodyContent}");
|
|
||||||
context.Request.Body.Position = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $"success";
|
return $"success";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
|
||||||
<PackageReference Include="Serilog" Version="4.0.0" />
|
<PackageReference Include="Serilog" Version="4.0.0" />
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
|
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
|
||||||
|
<PackageReference Include="Serilog.Expressions" Version="5.0.0" />
|
||||||
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
|
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
"Serilog": {
|
"Serilog": {
|
||||||
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
|
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
|
||||||
"MinimumLevel": {
|
"MinimumLevel": {
|
||||||
"Default": "Information",
|
"Default": "Debug",
|
||||||
"Override": {
|
"Override": {
|
||||||
"Microsoft": "Warning",
|
"Microsoft": "Warning",
|
||||||
"System": "Warning"
|
"System": "Warning"
|
||||||
|
|
@ -35,7 +35,12 @@
|
||||||
"restrictedToMinimumLevel": "Error", //写入日志的级别 //包括 Verbose、Debug、Information、Warning、Error 和 Fatal
|
"restrictedToMinimumLevel": "Error", //写入日志的级别 //包括 Verbose、Debug、Information、Warning、Error 和 Fatal
|
||||||
"shared": true //不占用文件
|
"shared": true //不占用文件
|
||||||
// "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}"
|
// "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}"
|
||||||
}
|
},
|
||||||
|
"Filter": [
|
||||||
|
{
|
||||||
|
"Expression": "Level == 'Error'"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "File",
|
"Name": "File",
|
||||||
|
|
@ -45,7 +50,12 @@
|
||||||
"restrictedToMinimumLevel": "Debug", //写入日志的级别 //包括 Verbose、Debug、Information、Warning、Error 和 Fatal
|
"restrictedToMinimumLevel": "Debug", //写入日志的级别 //包括 Verbose、Debug、Information、Warning、Error 和 Fatal
|
||||||
"shared": true //不占用文件
|
"shared": true //不占用文件
|
||||||
// "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}"
|
// "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}"
|
||||||
}
|
},
|
||||||
|
"Filter": [
|
||||||
|
{
|
||||||
|
"Expression": "Level == 'Debug'"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ]
|
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user