using System.Security.Claims; using System.Text.Json.Serialization; using Web.Api.Common; using Web.Api.Extensions; using Application.Abstractions.Messaging; namespace Web.Api.Endpoints.Store; public sealed class PlaceOrderRequest { [JsonPropertyName("channelID")] public int? ChannelID { get; set; } [JsonPropertyName("giftToMemberID")] public int? GiftToMemberID { get; set; } [JsonPropertyName("giftMessage")] public string? GiftMessage { get; set; } [JsonPropertyName("items")] public List Items { get; set; } = []; public sealed class PlaceOrderItem { [JsonPropertyName("productID")] public int ProductID { get; set; } [JsonPropertyName("quantity")] public int Quantity { get; set; } } } /// 상점 — 주문 결제 (PgCharged 차감 + 채널 보상 + 게임사 정산 큐). internal sealed class OrdersPlace : IEndpoint { public void MapEndpoint(IEndpointRouteBuilder app) { app.MapPost("api/store/orders", async ( PlaceOrderRequest body, ClaimsPrincipal user, ISender sender, CancellationToken ct ) => { var memberID = user.GetRequiredMemberID(); var items = body.Items.Select(i => new Application.Features.Api.Store.Orders.Place.Command.Item(i.ProductID, i.Quantity) ).ToList(); var result = await sender.Send(new Application.Features.Api.Store.Orders.Place.Command( memberID, body.ChannelID, items, body.GiftToMemberID, body.GiftMessage ), ct); if (result.IsFailure) { return CustomResults.Problem(result); } return ApiResponse.Ok(result.Value); }) .WithTags("Store") .RequireAuthorization(); } }