| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- using Domain.Entities.Store.ValueObject;
- using SharedKernel.Extensions;
- using SharedKernel.Helpers;
- using Application.Abstractions.Messaging;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.AspNetCore.Mvc.RazorPages;
- using Microsoft.AspNetCore.Mvc.Rendering;
- using System.ComponentModel;
- using System.ComponentModel.DataAnnotations;
- namespace Admin.Pages.Store.Settlement;
- public class IndexModel(IMediator mediator) : PageModel
- {
- [BindProperty(SupportsGet = true)]
- public QueryParams Query { get; set; } = new();
- public sealed class QueryParams
- {
- [Range(1, int.MaxValue)]
- public int PageNum { get; set; } = 1;
- [Range(1, 100)]
- public ushort PerPage { get; set; } = 20;
- [DisplayName("게임")]
- public int? GameID { get; set; }
- [DisplayName("연도")]
- [Range(2000, 9999)]
- public int? Year { get; set; }
- [DisplayName("월")]
- [Range(1, 12)]
- public int? Month { get; set; }
- [DisplayName("정산 상태")]
- public GameSettlementStatus? Status { get; set; }
- }
- public int Total { get; set; }
- public SearchGameSettlements.Response.StatusCounts? Counts { get; set; }
- public SearchGameSettlements.Response.Summary? Totals { get; set; }
- public List<SelectListItem> Games { get; set; } = [];
- public List<(
- int Num,
- int ID,
- int GameID,
- string GameName,
- string GamePublisher,
- int Year,
- int Month,
- int TotalRevenueAmount,
- int OrderCount,
- GameSettlementStatus Status,
- string StatusText,
- string CreatedAt,
- string? SettledAt,
- string? SettledByAdminEmail,
- string DetailURL
- )> List { get; set; } = [];
- public Pagination? Pagination { get; set; }
- public async Task OnGetAsync(CancellationToken ct)
- {
- if (!ModelState.IsValid)
- {
- return;
- }
- await LoadGamesAsync(ct);
- var result = await mediator.Send(new SearchGameSettlements.Query(
- Query.GameID,
- Query.Year,
- Query.Month,
- Query.Status,
- Query.PageNum,
- Query.PerPage
- ), ct);
- Total = result.Total;
- Counts = result.Counts;
- Totals = result.Totals;
- var qs = Request.QueryString.ToString();
- List = [.. result.List.Select(c => (
- c.Num,
- c.ID,
- c.GameID,
- c.GameName,
- c.GamePublisher,
- c.Year,
- c.Month,
- c.TotalRevenueAmount,
- c.OrderCount,
- c.Status,
- StatusText: StatusToText(c.Status),
- c.CreatedAt.GetDateAt(),
- c.SettledAt?.ToString("yyyy-MM-dd HH:mm"),
- c.SettledByAdminEmail,
- DetailURL: $"/Store/Settlement/Detail/{c.ID}{qs}"
- ))];
- Pagination = new Pagination(result.Total, Query.PageNum, Query.PerPage);
- }
- private async Task LoadGamesAsync(CancellationToken ct)
- {
- var result = await mediator.Send(new GetGames.Query(false), ct);
- Games = [.. result.List.Select(g => new SelectListItem
- {
- Value = g.ID.ToString(),
- Text = $"{g.KorName} ({g.Publisher})"
- })];
- }
- public static string StatusToText(GameSettlementStatus s) => s switch
- {
- GameSettlementStatus.Pending => "정산 대기",
- GameSettlementStatus.Settled => "정산 완료",
- _ => "?"
- };
- }
|