test 处理第一个数据异常问题

This commit is contained in:
2024-06-04 14:23:51 +08:00
parent a2d97f25af
commit 0a7fc847f0

View File

@@ -1,4 +1,5 @@
using Dlhis.Basic.Api.Request;
using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Canteen.Entities;
using Dlhis.Entity.Canteen.Enums;
using Dlhis.ScheduledTask.Common.Request;
@@ -81,6 +82,24 @@ public class HangfireController : ControllerBase
var data = await _dbContext.Queryable<BalanceRecordEntity>().Where(x => x.UserCode == code).Where(x => x.Remark == row.Remark).ToListAsync();
if (data.Count > 1)
{
var f = data.First();
var others = data.Where(x => x.Id != f.Id).ToList();
others.ForEach(x => x.Status = BalanceRecordStatusEnumType.Obsolute);
await _dbContext.UpdateAsync(others);
var sum = await _dbContext.Queryable<BalanceRecordEntity>().Where(x => x.Status == BalanceRecordStatusEnumType.Valid).SumAsync(x => x.Amount);
var mealInfo = await _dbContext.Queryable<GainfoMealEntity>().Where(x => x.UserCode == f.UserCode).SingleAsync();
await _dbContext.Updateable<GainfoMealEntity>()
.SetColumns(x => x.Balance == sum)
.SetColumns(x => x.Version == x.Version + 1)
.SetColumns(x => x.ModifiedTime == DateTime.Now)
.Where(x => x.UserCode == f.UserCode && x.Version == mealInfo.Version)
.ExecuteCommandAsync();
}
return data;
}
}