fix 合并餐饮首页接口
This commit is contained in:
@@ -143,25 +143,9 @@ public class BalancesController : ControllerBase
|
||||
return await _balanceService.GetConsumeNumberAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 消费走势
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("consumptiontrends")]
|
||||
public async Task<List<ConsumptionTrendResponse>> GetConsumptionTrendsAsync([FromQuery] ConsumptionTrendRequest request)
|
||||
{
|
||||
return await _balanceService.GetConsumptionTrendsAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 餐补走势
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("supplementtrend")]
|
||||
public async Task<List<ConsumptionTrendResponse>> GetSupplementTrendsAsync([FromQuery] ConsumptionTrendRequest request)
|
||||
{
|
||||
return await _balanceService.GetSupplementTrendsAsync(request);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 电子餐券申请记录查询
|
||||
|
||||
@@ -26,5 +26,15 @@
|
||||
/// 人均日消费额
|
||||
/// </summary>
|
||||
public int DailyNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 日消费额走势图
|
||||
/// </summary>
|
||||
public List<ConsumptionTrendResponse> Days { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 月消费额走势图
|
||||
/// </summary>
|
||||
public List<ConsumptionTrendResponse> Months { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,9 +27,8 @@ public interface IBalanceService : IScopeDependency
|
||||
|
||||
Task<ConsumeNumberResponse> GetConsumeNumberAsync();
|
||||
|
||||
Task<List<ConsumptionTrendResponse>> GetConsumptionTrendsAsync(ConsumptionTrendRequest request);
|
||||
|
||||
Task<List<ConsumptionTrendResponse>> GetSupplementTrendsAsync(ConsumptionTrendRequest request);
|
||||
|
||||
|
||||
Task<Pagination<OaEMealVoucherResponse>> GetOaEMealVoucherAsync([FromQuery] OaEMealVoucherRequest request);
|
||||
|
||||
|
||||
@@ -575,18 +575,25 @@ public class BalanceService : IBalanceService
|
||||
var monthlySpending = monthbs.Sum(x => x.Amount);
|
||||
//当日消费人数
|
||||
var monthlyCount = monthbs.Select(x => x.UserCode).Distinct().Count();
|
||||
|
||||
//消费走势
|
||||
var months = await GetConsumptionTrendsAsync(ConsumptionTrendEnumType.Month);
|
||||
var days = await GetConsumptionTrendsAsync(ConsumptionTrendEnumType.Day);
|
||||
|
||||
var res = new ConsumeNumberResponse
|
||||
{
|
||||
Total = devices.Count(),
|
||||
OffNumber = offCount,
|
||||
PlaceNumber = places.Count(),
|
||||
ConsumerableNumber = consumerable,
|
||||
DailyNumber = monthlyCount != 0 ? (int)Math.Ceiling(monthlySpending / monthlyCount) : 0
|
||||
DailyNumber = monthlyCount != 0 ? Math.Abs((int)Math.Ceiling(monthlySpending / monthlyCount)) : 0,
|
||||
Days = days,
|
||||
Months = months
|
||||
};
|
||||
return res;
|
||||
|
||||
}
|
||||
public async Task<List<ConsumptionTrendResponse>> GetConsumptionTrendsAsync(ConsumptionTrendRequest request)
|
||||
private async Task<List<ConsumptionTrendResponse>> GetConsumptionTrendsAsync(ConsumptionTrendEnumType type)
|
||||
{
|
||||
var bs = await _dbContext.Queryable<BalanceRecordEntity>()
|
||||
.Where(x => x.Type == BalanceRecordTypeEnumType.Out)
|
||||
@@ -595,7 +602,7 @@ public class BalanceService : IBalanceService
|
||||
var totalAmount = Math.Round(Math.Abs(bs.Sum(x => x.Amount)), 2);
|
||||
|
||||
var list = new List<ConsumptionTrendResponse>();
|
||||
if (request.Type == ConsumptionTrendEnumType.Month)
|
||||
if (type == ConsumptionTrendEnumType.Month)
|
||||
{
|
||||
//月与总额对比
|
||||
var months = GetMonthsOfYear();
|
||||
@@ -636,11 +643,6 @@ public class BalanceService : IBalanceService
|
||||
return list;
|
||||
}
|
||||
|
||||
public async Task<List<ConsumptionTrendResponse>> GetSupplementTrendsAsync(ConsumptionTrendRequest request)
|
||||
{
|
||||
//todo
|
||||
return new List<ConsumptionTrendResponse>();
|
||||
}
|
||||
|
||||
public async Task<Pagination<OaEMealVoucherResponse>> GetOaEMealVoucherAsync(OaEMealVoucherRequest request)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user