fix test recalc

This commit is contained in:
2024-08-22 15:28:11 +08:00
parent 5f245c82ec
commit e70abaa48c

View File

@@ -1,11 +1,12 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Data; using System.Data;
using Dlhis.Canteen.EMealVoucher.Services;
using Dlhis.Canteen.Order.Request; using Dlhis.Canteen.Order.Request;
using Dlhis.Canteen.Order.Response; using Dlhis.Canteen.Order.Response;
using Dlhis.Canteen.Order.Services; using Dlhis.Canteen.Order.Services;
using Dlhis.Entity.Canteen.Entities;
using Kurisu.AspNetCore.DataAccess.Dto; using Kurisu.AspNetCore.DataAccess.Dto;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop; using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@@ -21,11 +22,13 @@ public class BalancesController : ControllerBase
{ {
private readonly IBalanceService _balanceService; private readonly IBalanceService _balanceService;
private readonly IHainingBalanceService _hainingBalanceService; private readonly IHainingBalanceService _hainingBalanceService;
private readonly IServiceProvider _serviceProvider;
public BalancesController(IBalanceService balanceService, IHainingBalanceService hainingBalanceService) public BalancesController(IBalanceService balanceService, IHainingBalanceService hainingBalanceService, IServiceProvider serviceProvider)
{ {
_balanceService = balanceService; _balanceService = balanceService;
_hainingBalanceService = hainingBalanceService; _hainingBalanceService = hainingBalanceService;
_serviceProvider = serviceProvider;
} }
/// <summary> /// <summary>
@@ -204,4 +207,20 @@ public class BalancesController : ControllerBase
{ {
await _balanceService.ReCalcAsync(request.UserCode); await _balanceService.ReCalcAsync(request.UserCode);
} }
[HttpPost("recalc1")]
[IgnoreTenant]
[Transactional(IsolationLevel.ReadCommitted)]
public async Task ReC5()
{
using (var scope = _serviceProvider.CreateScope())
{
var db = scope.ServiceProvider.GetService<IDbContext>();
var codes = await db.Queryable<MealSupplementRecordEntity>().Where(x => x.Amount < 0 && x.Workplace == "5").Select(x => x.Code).Distinct().ToListAsync();
foreach (var code in codes)
{
await _balanceService.ReCalcAsync(code);
}
}
}
} }