fix 查询我的餐补接口迁移
This commit is contained in:
@@ -32,4 +32,15 @@ public class MealSupplementsRecordController
|
||||
{
|
||||
return await _mealSupplementRecordService.GetPageAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取我的餐补数据
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("my")]
|
||||
public async Task<List<MealSupplementRecordMyResponse>> GetMyMealSupplementRecords(MealSupplementRecordMyRequest request)
|
||||
{
|
||||
return await _mealSupplementRecordService.GetMyMealSupplementRecords(request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Kurisu.Core.CustomClass;
|
||||
|
||||
namespace Dlhis.Canteen.MealSupplementRecord.Request;
|
||||
|
||||
public class MealSupplementRecordMyRequest : IValidatableObject
|
||||
{
|
||||
public DateTimePeriod SearchDateTimePeriod { get; set; }
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
SearchDateTimePeriod.End = SearchDateTimePeriod.End.Value.AddDays(1).AddSeconds(-1);
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,20 @@
|
||||
using Kurisu.Core.CustomClass;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Kurisu.Core.CustomClass;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Canteen.MealSupplementRecord.Request;
|
||||
|
||||
public class MealSupplementRecordRequest : PageDto
|
||||
public class MealSupplementRecordRequest : PageDto, IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 餐补日期范围
|
||||
/// </summary>
|
||||
public DateTimePeriod DateTimePeriod { get; set; }
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
DateTimePeriod.End = DateTimePeriod.End.Value.AddDays(1).AddSeconds(-1);
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Dlhis.Canteen.MealSupplementRecord.Response;
|
||||
|
||||
public class MealSupplementRecordMyResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 餐补日期
|
||||
/// </summary>
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public decimal CurrentAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 餐补金额
|
||||
/// </summary>
|
||||
public string Amount => CurrentAmount.ToString("f2");
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
@@ -7,4 +7,6 @@ namespace Dlhis.Canteen.MealSupplementRecord.Services;
|
||||
public interface IMealSupplementRecordService : IScopeDependency
|
||||
{
|
||||
Task<Pagination<MealSupplementRecordResponse>> GetPageAsync(MealSupplementRecordRequest request);
|
||||
|
||||
Task<List<MealSupplementRecordMyResponse>> GetMyMealSupplementRecords(MealSupplementRecordMyRequest request);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
using Dlhis.Canteen.MealSupplementRecord.Request;
|
||||
using Dlhis.Canteen.MealSupplementRecord.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Basic.Enums;
|
||||
using Dlhis.Entity.Canteen.Entities;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Kurisu.Core.User.Abstractions;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Canteen.MealSupplementRecord.Services.Implements;
|
||||
|
||||
@@ -13,10 +16,12 @@ public class MealSupplementRecordService : IMealSupplementRecordService
|
||||
{
|
||||
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly ICurrentUser _currentUser;
|
||||
|
||||
public MealSupplementRecordService(IDbContext dbContext)
|
||||
public MealSupplementRecordService(IDbContext dbContext, ICurrentUser currentUser)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_currentUser = currentUser;
|
||||
}
|
||||
|
||||
public async Task<Pagination<MealSupplementRecordResponse>> GetPageAsync(MealSupplementRecordRequest request)
|
||||
@@ -44,4 +49,22 @@ public class MealSupplementRecordService : IMealSupplementRecordService
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
public async Task<List<MealSupplementRecordMyResponse>> GetMyMealSupplementRecords(MealSupplementRecordMyRequest request)
|
||||
{
|
||||
var code = _currentUser.GetUserClaim("jinko-code") ?? string.Empty;
|
||||
|
||||
return await _dbContext.Queryable<MealSupplementRecordEntity>()
|
||||
.Where(x => x.Date >= request.SearchDateTimePeriod.Start && x.Date <= request.SearchDateTimePeriod.End)
|
||||
.Where(x => x.Status == MealSupplementStatusEnumtype.Success)
|
||||
.Where(x => x.Code == code)
|
||||
.OrderBy(x => x.Date, OrderByType.Desc)
|
||||
.Select(x => new MealSupplementRecordMyResponse
|
||||
{
|
||||
CurrentAmount = x.Amount,
|
||||
Date = x.Date,
|
||||
Remark = x.Remark
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,15 +182,4 @@ public class BalancesController : ControllerBase
|
||||
{
|
||||
return await _balanceService.GetConsumeDeviceAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询餐补入账记录
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("balanceOfMealSupplementRecordByUser")]
|
||||
public async Task<Pagination<BalanceRecordByUserResponse>> BalanceRecordByUserAsync([FromQuery] BalanceRecordByUserRequest request)
|
||||
{
|
||||
return await _balanceService.GetBalanceOfMealSupplementRecordByUser(request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Request;
|
||||
|
||||
public class BalanceRecordByUserRequest : PageDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户档案号
|
||||
/// </summary>
|
||||
public string UserNo { get; set; }
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
using Dlhis.Canteen.Order.Request;
|
||||
using Dlhis.Canteen.Order.Response;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Services;
|
||||
|
||||
@@ -33,7 +32,4 @@ public interface IBalanceService : IScopeDependency
|
||||
Task<Pagination<AverageDailyResponse>> AverageDailyAsync(AverageDailyRequest request);
|
||||
|
||||
Task<Pagination<DevicePageResponse>> GetConsumeDeviceAsync(GetConsumeDeviceRequest request);
|
||||
|
||||
|
||||
Task<Pagination<BalanceRecordByUserResponse>> GetBalanceOfMealSupplementRecordByUser(BalanceRecordByUserRequest request);
|
||||
}
|
||||
|
||||
@@ -747,17 +747,6 @@ public class BalanceService : IBalanceService
|
||||
return page;
|
||||
}
|
||||
|
||||
public async Task<Pagination<BalanceRecordByUserResponse>> GetBalanceOfMealSupplementRecordByUser(BalanceRecordByUserRequest request)
|
||||
{
|
||||
var page = await _dbContext.Queryable<BalanceRecordEntity>()
|
||||
.Where(x => x.Source == BalanceRecordSourceEnumType.LocalTenantSubsidies || x.Source == BalanceRecordSourceEnumType.OtherTenantSubsidies)
|
||||
.Where(x => x.UserNo == request.UserNo)
|
||||
.Select<BalanceRecordByUserResponse>()
|
||||
.ToPageListAsync(request);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取离线设备
|
||||
|
||||
Reference in New Issue
Block a user