81 lines
2.8 KiB
C#
81 lines
2.8 KiB
C#
using Dlhis.Entity.Basic.Entity;
|
|
using Dlhis.Entity.Canteen.Entities;
|
|
using Dlhis.Entity.Canteen.Enums;
|
|
using Dlhis.External.OpenApi.Response;
|
|
using Kurisu.AspNetCore.CustomClass;
|
|
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
|
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using SqlSugar;
|
|
|
|
namespace Dlhis.External.OpenApi.Controllers;
|
|
|
|
[Authorize]
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class CanteenController : ControllerBase
|
|
{
|
|
private readonly IDbContext _dbContext;
|
|
|
|
public CanteenController(IDbContext dbContext)
|
|
{
|
|
_dbContext = dbContext;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 电子餐券记录
|
|
/// </summary>
|
|
/// <param name="factory"></param>
|
|
/// <param name="dateTimePeriods"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("eMealVoucher/records")]
|
|
[IgnoreTenant]
|
|
public async Task<List<EMealVoucherRecordResponse>> GetEMealVoucherRecordsAsync(string factory, [FromQuery] DateTimePeriod dateTimePeriods)
|
|
{
|
|
return await _dbContext.Queryable<EMealVoucherEntity>()
|
|
.Where(x => x.Factory == factory)
|
|
.WhereIF(dateTimePeriods.HasValue(), x => x.Date >= dateTimePeriods.Start && x.Date <= dateTimePeriods.End)
|
|
.Select(x => new EMealVoucherRecordResponse
|
|
{
|
|
No = x.No,
|
|
Title = x.Title,
|
|
Code = x.Code,
|
|
CostId = x.CostId,
|
|
Source = x.Source,
|
|
Phone = x.Phone,
|
|
Number = x.Number,
|
|
Reason = x.Reason,
|
|
Shifts = x.Shifts,
|
|
Factories = x.Factories,
|
|
Date = default,
|
|
Factory = x.Factory,
|
|
Details = SqlFunc.Subqueryable<EMealVoucherDetailEntity>().Where(p => p.No == x.No).ToList<EMealVoucherRecordDetailResponse>()
|
|
})
|
|
.ToListAsync();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 余额明细
|
|
/// </summary>
|
|
/// <param name="factory"></param>
|
|
/// <param name="time"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("balance/records")]
|
|
[IgnoreTenant]
|
|
public async Task<List<BalanceRecordResponse>> GetBalanceRecordsAsync(string factory, DateTime time)
|
|
{
|
|
return await _dbContext.Queryable<BalanceRecordEntity>()
|
|
.Where(x => x.CostDate == time && x.TenantId == factory && x.Status == BalanceRecordStatusEnumType.Valid)
|
|
.Select(x => new BalanceRecordResponse
|
|
{
|
|
UserCode = x.UserCode,
|
|
CostDateTime = x.CostDateTime,
|
|
Amount = x.Amount,
|
|
Type = x.Type,
|
|
BusinessPlace = SqlFunc.Subqueryable<BusinessPlaceEntity>().Where(p => p.Code == x.BusinessPlaceCode).Select(p => p.CustomCode),
|
|
Remark = x.Remark
|
|
})
|
|
.ToListAsync();
|
|
}
|
|
} |