fix 调试问题
This commit is contained in:
@@ -11,8 +11,5 @@ public interface ICanteenSettingService : IScopeDependency
|
||||
/// <param name="tenantId"></param>
|
||||
/// <returns></returns>
|
||||
Task<Dictionary<CanteenSettingItemEnumType, string>> GetUserSettingAsync(string userNo, string tenantId);
|
||||
|
||||
|
||||
Task<TimeOnly?> GetBusinessSwitchTimeAsync(string tenantId);
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ public class BalanceRecordCheckBackgroundService : BackgroundService
|
||||
var balanceRecords = await db.Queryable<LocalBalanceRecordEntity>().Where(x => x.TenantId == factory).Where(x => !x.IsSync).ToListAsync(stoppingToken);
|
||||
if (balanceRecords.Any())
|
||||
{
|
||||
_logger.LogInformation("上传离线订单");
|
||||
foreach (var balanceRecord in balanceRecords)
|
||||
{
|
||||
await db.Client.Ado.BeginTranAsync();
|
||||
@@ -70,9 +71,8 @@ public class BalanceRecordCheckBackgroundService : BackgroundService
|
||||
if (r.Code == ApiStateCode.Success)
|
||||
{
|
||||
var d = r.Data;
|
||||
var balance = decimal.Parse(d.Balance);
|
||||
await db.Updateable<LocalGainfoMealEntity>()
|
||||
.SetColumns(x => x.Balance == balance)
|
||||
.SetColumns(x => x.Balance == d.Balance)
|
||||
.Where(x => x.UserCode == d.UserCode)
|
||||
.ExecuteCommandAsync(stoppingToken);
|
||||
|
||||
@@ -144,7 +144,7 @@ public class BalanceRecordCheckBackgroundService : BackgroundService
|
||||
|
||||
var tokenResponse = await httpClient.PostAsync($"https://{_hostName}/api/User/OAuth2/clientgrant", new StringContent(JsonConvert.SerializeObject(new
|
||||
{
|
||||
ClientId = "e569c2aaa98e300c",
|
||||
ClientId = "e509c2aaa98e300c",
|
||||
ClientSecret = "6184d8979fc48105"
|
||||
}), Encoding.UTF8, "application/json"));
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using Dlhis.Middle.Entities;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||
using Mapster;
|
||||
|
||||
@@ -19,7 +20,7 @@ public class CanteenSettingService : ICanteenSettingService
|
||||
|
||||
public async Task<Dictionary<CanteenSettingItemEnumType, string>> GetUserSettingAsync(string userNo, string tenantId)
|
||||
{
|
||||
var settings = await _context.Queryable<CanteenSettingEntity>()
|
||||
var settings = await _context.Queryable<LocalCanteenSettingEntity>()
|
||||
.Where(x => x.Enable)
|
||||
.Where(x => x.TenantId == tenantId)
|
||||
.Where(x => x.UniqueType == CanteenSettingUnqiueEnumType.Person && x.UniqueValue == userNo || x.UniqueType == CanteenSettingUnqiueEnumType.Tenant)
|
||||
@@ -33,72 +34,4 @@ public class CanteenSettingService : ICanteenSettingService
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public async Task<TimeOnly?> GetBusinessSwitchTimeAsync(string tenantId)
|
||||
{
|
||||
var setting = await _context.Queryable<CanteenSettingEntity>()
|
||||
.Where(x => x.Enable)
|
||||
.Where(x => x.TenantId == tenantId)
|
||||
.Where(x => x.Item == CanteenSettingItemEnumType.BusinessSwitchTime)
|
||||
.FirstAsync();
|
||||
|
||||
try
|
||||
{
|
||||
return TimeOnly.Parse(setting.Value);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//*********************************************** help methods ***************************************************//
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 检验参数
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
private static bool IsValidFormat<T>(string value, CanteenSettingItemEnumType? type = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
//判断0/1
|
||||
if (type == CanteenSettingItemEnumType.AllowSendAtMeal ||
|
||||
type == CanteenSettingItemEnumType.AllowRepeatInOneShift ||
|
||||
type == CanteenSettingItemEnumType.AllowNoBalance ||
|
||||
type == CanteenSettingItemEnumType.AllowCrossTenant)
|
||||
{
|
||||
var intvaule = int.Parse(value);
|
||||
if (intvaule == 0 || intvaule == 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (type == CanteenSettingItemEnumType.BusinessSwitchTime)
|
||||
{
|
||||
var timeOnly = value.Adapt<TimeOnly>();
|
||||
return timeOnly.Minute == 0 && timeOnly.Second == 0;
|
||||
}
|
||||
|
||||
//mapster
|
||||
value.Adapt<T>();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace Dlhis.Middle.Services.Implements;
|
||||
|
||||
public class HealthCheckService : IHealthCheckService
|
||||
{
|
||||
private bool _isOffline = true;
|
||||
private bool _isOffline = false;
|
||||
private readonly string _hostName;
|
||||
private readonly ILogger<HealthCheckService> _logger;
|
||||
private int _successRetry;
|
||||
@@ -26,14 +26,14 @@ public class HealthCheckService : IHealthCheckService
|
||||
var tcpClient = new TcpClient();
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("tcp connecting {host} {port}", _hostName, 443);
|
||||
_logger.LogDebug("tcp connecting {host} {port}", _hostName, 443);
|
||||
await tcpClient.ConnectAsync(_hostName, 443);
|
||||
_retry++;
|
||||
_logger.LogInformation("retry {retry}", _retry);
|
||||
_logger.LogDebug("retry {retry}", _retry);
|
||||
if (tcpClient.Connected)
|
||||
{
|
||||
_successRetry++;
|
||||
_logger.LogInformation("success connected {count}", _successRetry);
|
||||
_logger.LogDebug("success connected {count}", _successRetry);
|
||||
if (_successRetry == 4)
|
||||
{
|
||||
_isOffline = false;
|
||||
@@ -43,7 +43,7 @@ public class HealthCheckService : IHealthCheckService
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogInformation("wait next check in {waitTime}", _successRetry * 1000);
|
||||
_logger.LogDebug("wait next check in {waitTime}", _successRetry * 1000);
|
||||
await Task.Delay(_successRetry * 1000);
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class HealthCheckService : IHealthCheckService
|
||||
{
|
||||
_successRetry = 0;
|
||||
_isOffline = true;
|
||||
_logger.LogInformation("current is {status}", "unavailable");
|
||||
_logger.LogDebug("current is {status}", "unavailable");
|
||||
await Task.Delay(2000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,9 +42,8 @@ public class OrderService : IOrderService
|
||||
if (remoteResult.Code == ApiStateCode.Success)
|
||||
{
|
||||
var d = remoteResult.Data;
|
||||
var balance = decimal.Parse(d.Balance);
|
||||
await _dbContext.Updateable<LocalGainfoMealEntity>()
|
||||
.SetColumns(x => x.Balance == balance)
|
||||
.SetColumns(x => x.Balance == d.Balance)
|
||||
.Where(x => x.UserCode == d.UserCode)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
@@ -52,15 +51,12 @@ public class OrderService : IOrderService
|
||||
return remoteResult;
|
||||
}
|
||||
|
||||
//尝试匹配userId
|
||||
_ = long.TryParse(request.UserUniqueNo, out var userId);
|
||||
|
||||
//根据档案号
|
||||
var gainfo = await _dbContext.Queryable<LocalGainfoEntity>()
|
||||
.Where(x => x.Code == request.UserUniqueNo || x.Id == userId || x.CardNo == request.UserUniqueNo)
|
||||
.Where(x => x.Code == request.UserUniqueNo || x.CardNo == request.UserUniqueNo)
|
||||
.FirstAsync();
|
||||
|
||||
var message = string.Empty;
|
||||
var message = "消费成功";
|
||||
|
||||
gainfo.ThrowIfNull("无消费权限");
|
||||
|
||||
@@ -78,9 +74,9 @@ public class OrderService : IOrderService
|
||||
|
||||
|
||||
//获取人员余额
|
||||
var data = await _dbContext.Queryable<GainfoEntity>()
|
||||
.LeftJoin<DepartmentEntity>((ga, department) => ga.DepartmentNo == department.No)
|
||||
.LeftJoin<GainfoMealEntity>((ga, department, mealUser) => ga.No == mealUser.UserNo)
|
||||
var data = await _dbContext.Queryable<LocalGainfoEntity>()
|
||||
.LeftJoin<LocalDepartmentEntity>((ga, department) => ga.DepartmentNo == department.No)
|
||||
.LeftJoin<LocalGainfoMealEntity>((ga, department, mealUser) => ga.No == mealUser.UserNo)
|
||||
.Where(ga => ga.Id == gainfo.Id)
|
||||
.Select((ga, department, mealUser) => new OrderResultResponse
|
||||
{
|
||||
@@ -88,7 +84,7 @@ public class OrderService : IOrderService
|
||||
UserName = ga.Name,
|
||||
DepartmentNo = ga.DepartmentNo,
|
||||
DepartmentName = department.Name,
|
||||
CurrentBalance = mealUser.Balance
|
||||
Balance = mealUser.Balance
|
||||
})
|
||||
.SingleAsync();
|
||||
|
||||
@@ -134,8 +130,8 @@ public class OrderService : IOrderService
|
||||
|
||||
var shift = shifts.FirstOrDefault(x => new TimePeriod
|
||||
{
|
||||
Start = x.Start,
|
||||
End = x.End
|
||||
Start = TimeOnly.FromDateTime(x.Start),
|
||||
End = TimeOnly.FromDateTime(x.End)
|
||||
}.IsPresent1(request.CostDateTime));
|
||||
shift.ThrowIfNull("非就餐时间,无法消费");
|
||||
|
||||
@@ -192,7 +188,7 @@ public class OrderService : IOrderService
|
||||
{
|
||||
var gainfoMeal = await _dbContext.Queryable<LocalGainfoMealEntity>().Where(x => x.UserNo == balanceRecord.UserNo).SingleAsync();
|
||||
//金额+-
|
||||
gainfoMeal.Balance += balanceRecord.Amount;
|
||||
gainfoMeal.Balance -= Math.Abs(balanceRecord.Amount);
|
||||
|
||||
(gainfoMeal.Balance < 0).ThrowIfTrue("余额不足,无法消费");
|
||||
|
||||
@@ -217,7 +213,7 @@ public class OrderService : IOrderService
|
||||
/// <param name="shift"></param>
|
||||
/// <param name="costDateTime"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<DateTime> GetCostDateAsync(BusinessShiftMealRelationshipEntity shift, DateTime costDateTime)
|
||||
private async Task<DateTime> GetCostDateAsync(LocalBusinessShiftMealRelationshipEntity shift, DateTime costDateTime)
|
||||
{
|
||||
var switchTime = await GetSettingAsync<TimeOnly?>(shift.TenantId, CanteenSettingItemEnumType.BusinessSwitchTime);
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public class RemoteOrderService : IRemoteOrderService
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> AbleRemoteCallAsync()
|
||||
{
|
||||
if (await _dbContext.Queryable<LocalOrderEntity>().AnyAsync(x => !x.IsSync))
|
||||
if (await _dbContext.Queryable<LocalBalanceRecordEntity>().AnyAsync(x => !x.IsSync))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user