90 lines
2.9 KiB
C#
90 lines
2.9 KiB
C#
using Dlhis.Middle.Api;
|
|
using Dlhis.Middle.Request;
|
|
using Dlhis.Middle.Response;
|
|
using Dlhis.Middle.Services;
|
|
using Kurisu.AspNetCore.DataAccess.Dto;
|
|
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
|
using Kurisu.AspNetCore.UnifyResultAndValidation;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Dlhis.Middle.Controllers;
|
|
|
|
[Route("api/canteen/[controller]")]
|
|
[ApiController]
|
|
public class BalancesController : ControllerBase
|
|
{
|
|
private readonly IBalanceService _balanceService;
|
|
private readonly IHealthCheckService _healthCheckService;
|
|
private readonly ICanteenApi _canteenApi;
|
|
|
|
public BalancesController(IBalanceService balanceService, IHealthCheckService healthCheckService, ICanteenApi canteenApi)
|
|
{
|
|
_balanceService = balanceService;
|
|
_healthCheckService = healthCheckService;
|
|
_canteenApi = canteenApi;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设备消费记录
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("device/page")]
|
|
[IgnoreTenant]
|
|
public async Task<DefaultApiResult<Pagination<BalanceRecordDeviceResponse>>> GetPageByDeviceUniqueNoGetAsync([FromQuery] BalanceRecordPageByDeviceUniqueNoRequest request)
|
|
{
|
|
if (_healthCheckService.GetIsOffline())
|
|
{
|
|
return new DefaultApiResult<Pagination<BalanceRecordDeviceResponse>>()
|
|
{
|
|
Data = await _balanceService.GetPageByDeviceUniqueNoAsync(request),
|
|
Code = ApiStateCode.Success
|
|
};
|
|
}
|
|
|
|
return await _canteenApi.GetPageByDeviceUniqueNoAsync(request);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设备消费记录
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("device/page")]
|
|
[IgnoreTenant]
|
|
public async Task<DefaultApiResult<Pagination<BalanceRecordDeviceResponse>>> GetPageByDeviceUniqueNoPostAsync(BalanceRecordPageByDeviceUniqueNoRequest request)
|
|
{
|
|
if (_healthCheckService.GetIsOffline())
|
|
{
|
|
return new DefaultApiResult<Pagination<BalanceRecordDeviceResponse>>()
|
|
{
|
|
Data = await _balanceService.GetPageByDeviceUniqueNoAsync(request),
|
|
Msg = "离线查询",
|
|
Code = ApiStateCode.Success
|
|
};
|
|
}
|
|
|
|
return await _canteenApi.GetPageByDeviceUniqueNoAsync(request);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 退款
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
[HttpPost("refund")]
|
|
[IgnoreTenant]
|
|
public async Task<DefaultApiResult<OrderResultResponse>> RefundAsync(BalanceRecordRefundRequest request)
|
|
{
|
|
if (_healthCheckService.GetIsOffline())
|
|
{
|
|
return new DefaultApiResult<OrderResultResponse>()
|
|
{
|
|
Data = null,
|
|
Code = ApiStateCode.Error,
|
|
Msg = "不支持离线退款"
|
|
};
|
|
}
|
|
|
|
return await _canteenApi.RefundAsync(request);
|
|
}
|
|
} |