fix 参数配置方法修改

This commit is contained in:
2024-10-24 16:51:17 +08:00
parent 7ce43ee45a
commit 8cf195eb77
5 changed files with 60 additions and 48 deletions

View File

@@ -22,6 +22,7 @@ namespace Dlhis.Canteen.Order.Services.Implements;
public class OrderService : BaseOrderService, IOrderService
{
private readonly ICanteenSettingService _canteenSettingService;
private readonly IServiceProvider _serviceProvider;
private readonly IHttpContextAccessor _httpContextAccessor;
@@ -33,6 +34,7 @@ public class OrderService : BaseOrderService, IOrderService
ILogger<OrderService> logger)
: base(canteenSettingService, dbContext, currentUser, logger)
{
_canteenSettingService = canteenSettingService;
_serviceProvider = serviceProvider;
_httpContextAccessor = httpContextAccessor;
}
@@ -198,7 +200,7 @@ public class OrderService : BaseOrderService, IOrderService
/// <returns></returns>
private async Task<DateTime> GetCostDateAsync(BusinessShiftMealRelationshipEntity shift, DateTime costDateTime)
{
var switchTime = await GetSettingAsync<TimeOnly?>(string.Empty, shift.TenantId, CanteenSettingItemEnumType.BusinessSwitchTime);
var switchTime = await _canteenSettingService.GetSettingAsync<TimeOnly?>(CanteenSettingItemEnumType.BusinessSwitchTime, shift.TenantId, string.Empty);
var costDate = costDateTime.Date;
@@ -243,7 +245,7 @@ public class OrderService : BaseOrderService, IOrderService
.ToListAsync();
//一天消费金额
var dayCostMax = await GetSettingAsync<decimal>(order.UserNo, order.TenantId, CanteenSettingItemEnumType.DayCostMax);
var dayCostMax = await _canteenSettingService.GetSettingAsync<decimal>(CanteenSettingItemEnumType.DayCostMax, order.TenantId, order.UserNo);
if (dayCostMax != default)
{
//消费记录一定会有营业点代码!.Value是安全用法
@@ -255,7 +257,7 @@ public class OrderService : BaseOrderService, IOrderService
}
//一次消费金额
var onceCostMax = await GetSettingAsync<decimal>(order.UserNo, order.TenantId, CanteenSettingItemEnumType.OnceCostMax);
var onceCostMax = await _canteenSettingService.GetSettingAsync<decimal>(CanteenSettingItemEnumType.OnceCostMax, order.TenantId, order.UserNo);
if (onceCostMax != default)
{
(Math.Abs(order.Amount) > onceCostMax).ThrowIfTrue($"单次消费金额不能超出{onceCostMax}元");
@@ -264,7 +266,7 @@ public class OrderService : BaseOrderService, IOrderService
//超市消费限额
if (order.BusinessPlaceCode.HasValue && supermarketCodes.Contains(order.BusinessPlaceCode.Value))
{
var dayMarketCostMax = await GetSettingAsync<decimal>(order.UserNo, order.TenantId, CanteenSettingItemEnumType.DayMarketCostMax);
var dayMarketCostMax = await _canteenSettingService.GetSettingAsync<decimal>(CanteenSettingItemEnumType.DayMarketCostMax, order.TenantId, order.UserNo);
if (dayMarketCostMax != default)
{
var cost = todayAllBalanceRecords.Where(x => x.BusinessPlaceCode.HasValue)
@@ -276,7 +278,7 @@ public class OrderService : BaseOrderService, IOrderService
}
//重复餐次消费
var allowRepeatInOneShift = await GetSettingAsync(order.UserNo, order.TenantId, CanteenSettingItemEnumType.AllowRepeatInOneShift, true);
var allowRepeatInOneShift = await _canteenSettingService.GetSettingAsync(CanteenSettingItemEnumType.AllowRepeatInOneShift, order.TenantId, order.UserNo, true);
if (!allowRepeatInOneShift)
{
var costCount = todayAllBalanceRecords.Count(x => x.ShiftType == order.ShiftType);