fix 补充日志输出
This commit is contained in:
@@ -1,20 +1,19 @@
|
||||
using Dlhis.Canteen.Order.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Canteen.Entities;
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||
using Kurisu.AspNetCore.Utils;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Services.Implements;
|
||||
|
||||
public class MiddleService : IMiddleService
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly IBalanceService _balanceService;
|
||||
|
||||
public MiddleService(IDbContext dbContext)
|
||||
public MiddleService(IDbContext dbContext, IBalanceService balanceService)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_balanceService = balanceService;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -26,38 +25,7 @@ public class MiddleService : IMiddleService
|
||||
if (!await _dbContext.Queryable<BalanceRecordEntity>().AnyAsync(x => x.No == entity.No))
|
||||
{
|
||||
await _dbContext.InsertAsync(entity);
|
||||
|
||||
await CommonHelper.RetryAsync(async () =>
|
||||
{
|
||||
var mealUser = await _dbContext.Queryable<GainfoMealEntity>().Where(x => x.UserCode == entity.UserCode).FirstAsync();
|
||||
if (mealUser == null)
|
||||
{
|
||||
mealUser = new GainfoMealEntity
|
||||
{
|
||||
UserNo = entity.No,
|
||||
UserCode = entity.UserCode,
|
||||
Balance = 0,
|
||||
BalanceOfRecharge = 0,
|
||||
BalanceOfSubsidies = 0,
|
||||
Version = 0
|
||||
};
|
||||
|
||||
await _dbContext.InsertAsync(mealUser);
|
||||
}
|
||||
|
||||
//重新核算
|
||||
var balance = await _dbContext.Queryable<BalanceRecordEntity>()
|
||||
.Where(x => x.UserCode == entity.UserCode)
|
||||
.Where(x => x.Status == BalanceRecordStatusEnumType.Valid)
|
||||
.SumAsync(x => x.Amount);
|
||||
|
||||
await _dbContext.Updateable<GainfoMealEntity>()
|
||||
.SetColumns(x => x.Version == x.Version + 1)
|
||||
.SetColumns(x => x.Balance == balance)
|
||||
.SetColumns(x => x.ModifiedTime == DateTime.Now)
|
||||
.Where(x => x.UserCode == mealUser.UserCode && x.Version == mealUser.Version)
|
||||
.ExecuteCommandThrowVersionAsync();
|
||||
}, 5);
|
||||
await _balanceService.ReCalcAsync(entity.UserCode);
|
||||
}
|
||||
|
||||
//获取人员余额
|
||||
|
||||
Reference in New Issue
Block a user