fix gainfomeal处理
This commit is contained in:
@@ -24,35 +24,42 @@ public class SysDataService : ISysDataService
|
|||||||
var type = App.ActiveTypes
|
var type = App.ActiveTypes
|
||||||
.Where(x => x.IsDefined(typeof(SugarTable), false))
|
.Where(x => x.IsDefined(typeof(SugarTable), false))
|
||||||
.Where(x => !x.IsDefined(typeof(SkipScanAttribute), false))
|
.Where(x => !x.IsDefined(typeof(SkipScanAttribute), false))
|
||||||
.First(x => x.GetCustomAttribute<SugarTable>()!.TableName == tableName);
|
.FirstOrDefault(x => x.GetCustomAttribute<SugarTable>()!.TableName == tableName);
|
||||||
|
|
||||||
var table = type.GetCustomAttribute<SugarTable>()!.TableName;
|
var table = type?.GetCustomAttribute<SugarTable>()!.TableName;
|
||||||
var sql = $"select * from {table}";
|
var sql = $"select * from {table}";
|
||||||
|
|
||||||
|
if (type == null)
|
||||||
|
{
|
||||||
|
table = tableName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (type.IsAssignableTo(typeof(ITenantId)))
|
if (type.IsAssignableTo(typeof(ITenantId)))
|
||||||
{
|
{
|
||||||
sql += $" where tenantId = '{factory}'";
|
sql += $" where tenantId = '{factory}'";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (tableName)
|
switch (table)
|
||||||
{
|
{
|
||||||
case "Gainfo":
|
case "Gainfo":
|
||||||
return await _dbContext.Queryable<GainfoEntity>().Where(x => x.Factory == factory).Select(x => (object)x).ToListAsync();
|
return await _dbContext.Queryable<GainfoEntity>().Where(x => x.Factory == factory).Select(x => (object)x).ToListAsync();
|
||||||
case "GainfoMeal":
|
case "GainfoMeal":
|
||||||
{
|
{
|
||||||
var factories = await GetWalletFactoriesAsync(factory);
|
var r = await _dbContext.Queryable<GainfoEntity>()
|
||||||
|
.LeftJoin<BalanceRecordEntity>((x, b) => x.Code == b.UserCode)
|
||||||
|
.Where(x => x.Factory == factory)
|
||||||
|
.Where((x, b) => b.Source != BalanceRecordSourceEnumType.EMealVoucher && b.Status == BalanceRecordStatusEnumType.Valid && b.IsDeleted == false)
|
||||||
|
.GroupBy(x => x.Code)
|
||||||
|
.Select((x, b) => new
|
||||||
|
{
|
||||||
|
UserCode = x.Code,
|
||||||
|
Balance = SqlFunc.AggregateSum(b.Amount)
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
var codes = await _dbContext.Queryable<GainfoEntity>().Where(x => x.Factory == factory).Select(x => x.Code).ToListAsync();
|
return r.Select(x => (object)x).ToList();
|
||||||
// return await _dbContext.Queryable<BalanceRecordEntity>()
|
|
||||||
// .Where(x => codes.Contains(x.UserCode) && factories.Contains(x.TenantId))
|
|
||||||
// .Where(x => x.Source != BalanceRecordSourceEnumType.EMealVoucher)
|
|
||||||
// .GroupBy(x => x.UserCode)
|
|
||||||
// .Select(x => new
|
|
||||||
// {
|
|
||||||
// x.UserCode,
|
|
||||||
// Balance = SqlFunc.AggregateSum(x.Amount)
|
|
||||||
// })
|
|
||||||
// .ToListAsync();
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return await _dbContext.Client.SqlQueryable<object>(sql).ToListAsync();
|
return await _dbContext.Client.SqlQueryable<object>(sql).ToListAsync();
|
||||||
|
|||||||
Reference in New Issue
Block a user