feat 生日券功能,自动上传消费数据,提醒访客到期
This commit is contained in:
107
Src/Dlhis.Canteen/Voucher/Controllers/VouchersController.cs
Normal file
107
Src/Dlhis.Canteen/Voucher/Controllers/VouchersController.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
using Dlhis.Basic.Vouchers.Request;
|
||||
using Dlhis.Canteen.Order.Request;
|
||||
using Dlhis.Canteen.Order.Response;
|
||||
using Dlhis.Canteen.Tickets.Request;
|
||||
using Dlhis.Canteen.Tickets.Services;
|
||||
using Dlhis.Canteen.Voucher.Requests;
|
||||
using Dlhis.Canteen.Voucher.Response;
|
||||
using Dlhis.Constants;
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using Kurisu.AspNetCore.Authentication.Abstractions;
|
||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Dlhis.Canteen.Voucher.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// 券
|
||||
/// </summary>
|
||||
[Authorize]
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class VouchersController : ControllerBase
|
||||
{
|
||||
private readonly INamedResolver _namedResolver;
|
||||
private readonly ICurrentUser _currentUser;
|
||||
|
||||
public VouchersController(INamedResolver namedResolver, ICurrentUser currentUser)
|
||||
{
|
||||
_namedResolver = namedResolver;
|
||||
_currentUser = currentUser;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取分页数据(按券类型)
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("page")]
|
||||
public async Task<Pagination<VoucherPageResponse>> GetPageAsync([FromQuery] VoucherPageRequest request)
|
||||
{
|
||||
return await _namedResolver.GetService<IVoucherService>(request.Type.ToString() + "VoucherService").GetPageAsync(request);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取我的分页数据(按券类型)(H5)
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("my")]
|
||||
public async Task<Pagination<VoucherPageResponse>> GetMyPageAsync([FromQuery] VoucherPageRequest request)
|
||||
{
|
||||
var userCode = _currentUser.GetUserClaim(UserClaimConstants.JinkoCode);
|
||||
request.UserCode = userCode;
|
||||
return await _namedResolver.GetService<IVoucherService>(request.Type.ToString()).GetPageAsync(request);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 创建生日券
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpPost("birthday/create")]
|
||||
public async Task CreateBirthdayVoucherAsync(VoucherByBirthdayRequest request)
|
||||
{
|
||||
var srv = _namedResolver.GetService<IVoucherService>(VoucherEnumType.Birthday.ToString() + "VoucherService");
|
||||
srv.ThrowIfNull("不支持的券类型");
|
||||
await srv.CreateAsync(new Dictionary<string, object>
|
||||
{
|
||||
["userCodes"] = request.UserCodes,
|
||||
["begin"] = request.Begin,
|
||||
["end"] = request.End,
|
||||
["remark"] = request.Remark
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 餐券消费分页
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("balance/page")]
|
||||
[IgnoreTenant]
|
||||
public async Task<Pagination<VoucherBalancePageResponse>> GetVoucherBalancePageAsync([FromQuery] VoucherBalancePageRequest request)
|
||||
{
|
||||
var srv = _namedResolver.GetService<IVoucherService>(request.Type.ToString() + "VoucherService");
|
||||
|
||||
return await srv.GetVoucherBalancePageAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 我的餐券消费分页(H5)
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("balance/my/page")]
|
||||
[IgnoreTenant]
|
||||
public async Task<Pagination<VoucherBalancePageResponse>> GetMyVoucherBalancePageAsync([FromQuery] VoucherBalancePageRequest request)
|
||||
{
|
||||
var srv = _namedResolver.GetService<IVoucherService>(request.Type.ToString());
|
||||
return await srv.GetVoucherBalancePageAsync(request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user