fix 超市限额问题
This commit is contained in:
@@ -370,16 +370,23 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
var dayMarketCostMax = await GetSettingAsync<decimal>(CanteenSettingItemEnumType.DayMarketCostMax);
|
||||
if (dayMarketCostMax != default)
|
||||
{
|
||||
var businessPlaceCodes = await DbContext.Queryable<BusinessPlaceEntity>()
|
||||
if (order.BusinessPlaceCode.HasValue && await DbContext.Queryable<BusinessPlaceEntity>()
|
||||
.Where(x => x.Catalog == CanteenBusinessPlaceCatalogEnumType.Supermarket)
|
||||
.Select(x => x.Code).ToListAsync();
|
||||
|
||||
var cost = balanceRecords.Where(x => x.BusinessPlaceCode.HasValue)
|
||||
.Where(x => businessPlaceCodes.Contains(x.BusinessPlaceCode.Value))
|
||||
.Sum(x => x.Amount);
|
||||
if (cost + Math.Abs(order.Amount) > dayMarketCostMax)
|
||||
.Where(x => x.Code == order.BusinessPlaceCode.Value)
|
||||
.AnyAsync())
|
||||
{
|
||||
throw new UserFriendlyException($"超出当天超市消费限制({dayMarketCostMax}),无法消费");
|
||||
var businessPlaceCodes = await DbContext.Queryable<BusinessPlaceEntity>()
|
||||
.Where(x => x.Catalog == CanteenBusinessPlaceCatalogEnumType.Supermarket)
|
||||
.Select(x => x.Code).ToListAsync();
|
||||
|
||||
var cost = balanceRecords.Where(x => x.BusinessPlaceCode.HasValue)
|
||||
.Where(x => businessPlaceCodes.Contains(x.BusinessPlaceCode.Value))
|
||||
.Sum(x => x.Amount);
|
||||
|
||||
if (cost + Math.Abs(order.Amount) > dayMarketCostMax)
|
||||
{
|
||||
throw new UserFriendlyException($"超出当天超市消费限制({dayMarketCostMax}),无法消费");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user