add 消费处理完成

This commit is contained in:
2024-10-25 17:10:18 +08:00
parent 8cf195eb77
commit 0e0c5db6b8
38 changed files with 1280 additions and 1192 deletions

View File

@@ -187,37 +187,6 @@ public class MealSupplementRecordService : IMealSupplementRecordService
DepartmentNo = gainfo.DepartmentNo,
DeviceUniqueNo = null
});
await CommonHelper.RetryAsync(async () =>
{
var mealUser = await _dbContext.Queryable<GainfoMealEntity>().Where(x => x.UserCode == request.Code).FirstAsync();
if (mealUser == null)
{
mealUser = new GainfoMealEntity
{
UserCode = gainfo.Code,
Balance = 0,
BalanceOfRecharge = 0,
BalanceOfSubsidies = 0,
Version = 0
};
await _dbContext.InsertAsync(mealUser);
}
//重新核算
var balance = await _dbContext.Queryable<BalanceRecordEntity>()
.Where(x => x.UserCode == request.Code)
.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);
}
}
}