diff --git a/Src/Dlhis.Canteen/Order/Controllers/BalancesController.cs b/Src/Dlhis.Canteen/Order/Controllers/BalancesController.cs index 1f26795a..af7ade7a 100644 --- a/Src/Dlhis.Canteen/Order/Controllers/BalancesController.cs +++ b/Src/Dlhis.Canteen/Order/Controllers/BalancesController.cs @@ -1,11 +1,12 @@ using System.ComponentModel.DataAnnotations; using System.Data; -using Dlhis.Canteen.EMealVoucher.Services; using Dlhis.Canteen.Order.Request; using Dlhis.Canteen.Order.Response; using Dlhis.Canteen.Order.Services; +using Dlhis.Entity.Canteen.Entities; using Kurisu.AspNetCore.DataAccess.Dto; using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop; +using Kurisu.AspNetCore.DataAccess.SqlSugar.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -21,11 +22,13 @@ public class BalancesController : ControllerBase { private readonly IBalanceService _balanceService; private readonly IHainingBalanceService _hainingBalanceService; + private readonly IServiceProvider _serviceProvider; - public BalancesController(IBalanceService balanceService, IHainingBalanceService hainingBalanceService) + public BalancesController(IBalanceService balanceService, IHainingBalanceService hainingBalanceService, IServiceProvider serviceProvider) { _balanceService = balanceService; _hainingBalanceService = hainingBalanceService; + _serviceProvider = serviceProvider; } /// @@ -204,4 +207,20 @@ public class BalancesController : ControllerBase { 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(); + var codes = await db.Queryable().Where(x => x.Amount < 0 && x.Workplace == "5").Select(x => x.Code).Distinct().ToListAsync(); + foreach (var code in codes) + { + await _balanceService.ReCalcAsync(code); + } + } + } } \ No newline at end of file