feat(leader-skin): shop catalog + 5 endpoints (/products, /buy, /buy_set, /buy_set_item, /ids)
Schema: LeaderSkinShopSeries -> Products (owned rewards) + owned SetCompletionRewards on the series; ViewerLeaderSkinSetClaim composite PK (ViewerId, SeriesId) backs the /buy_set_item idempotent-claim check. Importer mirrors SleeveShopImporter: idempotent find-or-create, owned collections rewritten wholesale on rerun. 16 series, 104 products. Controller (extends existing /set with 5 new endpoints): - /products: dict-keyed-by-series_id-string wire shape. is_completed per-viewer, rewards.status from ViewerLeaderSkinSetClaim (0=no set sale, 1=available, 2=claimed) matching client RewardStatus enum. - /buy: single skin, sales_type 1/2 dispatch, 3=>501. - /buy_set: whole series at SetPrice; requires set_sales_status != 0; grants every product's rewards (RewardGrantService idempotent on already-owned cosmetics, so partial-set buys don't double-add). - /buy_set_item: requires viewer owns every skin in series; idempotent on re-claim (returns 200 + empty reward_list, not 400) so client retries don't error. - /ids: flat owned-skin-id list for badge refresh. 496 tests pass (was 486; +10 leader-skin-shop tests). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using MessagePack;
|
||||
using SVSim.EmulatedEntrypoint.Models.Dtos.Requests;
|
||||
|
||||
namespace SVSim.EmulatedEntrypoint.Models.Dtos.Requests.LeaderSkin;
|
||||
|
||||
/// <summary>
|
||||
/// /leader_skin/buy request body. sales_type is ShopCommonUtility.SalesType:
|
||||
/// 0=free, 1=crystal, 2=rupy, 3=ticket (v1: 3 returns 501 — no ticket-priced skin captured).
|
||||
/// <see cref="ItemId"/> is the ticket item id when paying with a ticket, null otherwise.
|
||||
/// </summary>
|
||||
[MessagePackObject]
|
||||
public class LeaderSkinBuyRequest : BaseRequest
|
||||
{
|
||||
[JsonPropertyName("product_id")]
|
||||
[Key("product_id")]
|
||||
public int ProductId { get; set; }
|
||||
|
||||
[JsonPropertyName("sales_type")]
|
||||
[Key("sales_type")]
|
||||
public int SalesType { get; set; }
|
||||
|
||||
[JsonPropertyName("item_id")]
|
||||
[Key("item_id")]
|
||||
public long? ItemId { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using MessagePack;
|
||||
using SVSim.EmulatedEntrypoint.Models.Dtos.Requests;
|
||||
|
||||
namespace SVSim.EmulatedEntrypoint.Models.Dtos.Requests.LeaderSkin;
|
||||
|
||||
/// <summary>
|
||||
/// /leader_skin/buy_set_item — claim the series-completion bonus once every skin in the series
|
||||
/// is owned. <c>sales_type</c> field exists on the client's param class but is never set; server
|
||||
/// ignores it.
|
||||
/// </summary>
|
||||
[MessagePackObject]
|
||||
public class LeaderSkinBuySetItemRequest : BaseRequest
|
||||
{
|
||||
[JsonPropertyName("series_id")]
|
||||
[Key("series_id")]
|
||||
public int SeriesId { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using MessagePack;
|
||||
using SVSim.EmulatedEntrypoint.Models.Dtos.Requests;
|
||||
|
||||
namespace SVSim.EmulatedEntrypoint.Models.Dtos.Requests.LeaderSkin;
|
||||
|
||||
/// <summary>
|
||||
/// /leader_skin/buy_set — purchase every skin in a series in one call (cheaper per-skin).
|
||||
/// </summary>
|
||||
[MessagePackObject]
|
||||
public class LeaderSkinBuySetRequest : BaseRequest
|
||||
{
|
||||
[JsonPropertyName("series_id")]
|
||||
[Key("series_id")]
|
||||
public int SeriesId { get; set; }
|
||||
|
||||
[JsonPropertyName("sales_type")]
|
||||
[Key("sales_type")]
|
||||
public int SalesType { get; set; }
|
||||
|
||||
[JsonPropertyName("item_id")]
|
||||
[Key("item_id")]
|
||||
public long? ItemId { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using MessagePack;
|
||||
using SVSim.EmulatedEntrypoint.Models.Dtos;
|
||||
|
||||
namespace SVSim.EmulatedEntrypoint.Models.Dtos.Responses.LeaderSkin;
|
||||
|
||||
/// <summary>
|
||||
/// /leader_skin/buy, /leader_skin/buy_set, /leader_skin/buy_set_item all return the same shape:
|
||||
/// a <c>reward_list</c> of standard <see cref="RewardListEntry"/> entries (post-state totals
|
||||
/// for currencies, grant counts for cosmetics).
|
||||
/// </summary>
|
||||
[MessagePackObject]
|
||||
public class LeaderSkinBuyResponse
|
||||
{
|
||||
[JsonPropertyName("reward_list")]
|
||||
[Key("reward_list")]
|
||||
public List<RewardListEntry> RewardList { get; set; } = new();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using MessagePack;
|
||||
|
||||
namespace SVSim.EmulatedEntrypoint.Models.Dtos.Responses.LeaderSkin;
|
||||
|
||||
/// <summary>
|
||||
/// /leader_skin/ids — flat list of leader_skin_ids the viewer owns. Used by the client to
|
||||
/// refresh badges across the skin-selection UI without re-fetching the full shop catalog.
|
||||
/// </summary>
|
||||
[MessagePackObject]
|
||||
public class LeaderSkinIdsResponse
|
||||
{
|
||||
[JsonPropertyName("user_leader_skin_ids")]
|
||||
[Key("user_leader_skin_ids")]
|
||||
public List<int> UserLeaderSkinIds { get; set; } = new();
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using MessagePack;
|
||||
|
||||
namespace SVSim.EmulatedEntrypoint.Models.Dtos.Responses.LeaderSkin;
|
||||
|
||||
// /leader_skin/products wire shape: `data` IS the per-series dict (no wrapping field).
|
||||
// Per SkinPurchaseInfoTask.Parse line 31: `JsonData jsonData = base.ResponseData["data"];`
|
||||
// then iterates positionally. Dict-keyed-by-series_id_string mirrors the prod capture exactly.
|
||||
// The controller returns Dictionary<string, SkinSeriesDto> directly so `data` becomes that dict.
|
||||
|
||||
[MessagePackObject]
|
||||
public class SkinSeriesDto
|
||||
{
|
||||
[JsonPropertyName("series_id")]
|
||||
[Key("series_id")]
|
||||
public int SeriesId { get; set; }
|
||||
|
||||
/// <summary>True when the viewer owns every product's skin in this series.</summary>
|
||||
[JsonPropertyName("is_completed")]
|
||||
[Key("is_completed")]
|
||||
public bool IsCompleted { get; set; }
|
||||
|
||||
[JsonPropertyName("is_new")]
|
||||
[Key("is_new")]
|
||||
public bool IsNew { get; set; }
|
||||
|
||||
/// <summary>Always emit — client unconditionally calls .ToInt() on this field.</summary>
|
||||
[JsonPropertyName("set_sales_status")]
|
||||
[Key("set_sales_status")]
|
||||
public int SetSalesStatus { get; set; }
|
||||
|
||||
[JsonPropertyName("rewards")]
|
||||
[Key("rewards")]
|
||||
public SkinSeriesRewardsDto Rewards { get; set; } = new();
|
||||
|
||||
/// <summary>Always emit — client reads this dict when set_sales_status != 0.</summary>
|
||||
[JsonPropertyName("set_prices")]
|
||||
[Key("set_prices")]
|
||||
public SkinSeriesSetPricesDto SetPrices { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("sales_period_info")]
|
||||
[Key("sales_period_info")]
|
||||
public List<object> SalesPeriodInfo { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("products")]
|
||||
[Key("products")]
|
||||
public List<SkinProductDto> Products { get; set; } = new();
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public class SkinSeriesRewardsDto
|
||||
{
|
||||
/// <summary>SkinSeriesPurchaseInfo.RewardStatus — 0=none, 1=not_got, 2=got.</summary>
|
||||
[JsonPropertyName("status")]
|
||||
[Key("status")]
|
||||
public int Status { get; set; }
|
||||
|
||||
[JsonPropertyName("items")]
|
||||
[Key("items")]
|
||||
public List<SkinSeriesRewardItemDto> Items { get; set; } = new();
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public class SkinSeriesRewardItemDto
|
||||
{
|
||||
[JsonPropertyName("reward_type")]
|
||||
[Key("reward_type")]
|
||||
public int RewardType { get; set; }
|
||||
|
||||
[JsonPropertyName("reward_detail_id")]
|
||||
[Key("reward_detail_id")]
|
||||
public long RewardDetailId { get; set; }
|
||||
|
||||
[JsonPropertyName("reward_number")]
|
||||
[Key("reward_number")]
|
||||
public int RewardNumber { get; set; }
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public class SkinSeriesSetPricesDto
|
||||
{
|
||||
[JsonPropertyName("set_price_crystal")]
|
||||
[Key("set_price_crystal")]
|
||||
public int? SetPriceCrystal { get; set; }
|
||||
|
||||
[JsonPropertyName("set_price_rupy")]
|
||||
[Key("set_price_rupy")]
|
||||
public int? SetPriceRupy { get; set; }
|
||||
|
||||
[JsonPropertyName("set_price_ticket")]
|
||||
[Key("set_price_ticket")]
|
||||
public int? SetPriceTicket { get; set; }
|
||||
|
||||
[JsonPropertyName("ticket_id")]
|
||||
[Key("ticket_id")]
|
||||
public long? TicketId { get; set; }
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public class SkinProductDto
|
||||
{
|
||||
[JsonPropertyName("product_id")]
|
||||
[Key("product_id")]
|
||||
public int ProductId { get; set; }
|
||||
|
||||
[JsonPropertyName("leader_skin_id")]
|
||||
[Key("leader_skin_id")]
|
||||
public int LeaderSkinId { get; set; }
|
||||
|
||||
[JsonPropertyName("product_name")]
|
||||
[Key("product_name")]
|
||||
public string ProductName { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("introduction")]
|
||||
[Key("introduction")]
|
||||
public string Introduction { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("cv_name")]
|
||||
[Key("cv_name")]
|
||||
public string CvName { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("is_purchased")]
|
||||
[Key("is_purchased")]
|
||||
public bool IsPurchased { get; set; }
|
||||
|
||||
[JsonPropertyName("sale")]
|
||||
[Key("sale")]
|
||||
public SkinProductSaleDto Sale { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("sales_period_info")]
|
||||
[Key("sales_period_info")]
|
||||
public List<object> SalesPeriodInfo { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("rewards")]
|
||||
[Key("rewards")]
|
||||
public List<SkinProductRewardDto> Rewards { get; set; } = new();
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public class SkinProductSaleDto
|
||||
{
|
||||
[JsonPropertyName("single_price_crystal")]
|
||||
[Key("single_price_crystal")]
|
||||
public int? SinglePriceCrystal { get; set; }
|
||||
|
||||
[JsonPropertyName("single_price_rupy")]
|
||||
[Key("single_price_rupy")]
|
||||
public int? SinglePriceRupy { get; set; }
|
||||
|
||||
[JsonPropertyName("single_price_ticket")]
|
||||
[Key("single_price_ticket")]
|
||||
public int? SinglePriceTicket { get; set; }
|
||||
|
||||
[JsonPropertyName("ticket_number")]
|
||||
[Key("ticket_number")]
|
||||
public int? TicketNumber { get; set; }
|
||||
|
||||
[JsonPropertyName("item_id")]
|
||||
[Key("item_id")]
|
||||
public long? ItemId { get; set; }
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public class SkinProductRewardDto
|
||||
{
|
||||
[JsonPropertyName("reward_type")]
|
||||
[Key("reward_type")]
|
||||
public int RewardType { get; set; }
|
||||
|
||||
[JsonPropertyName("reward_detail_id")]
|
||||
[Key("reward_detail_id")]
|
||||
public long RewardDetailId { get; set; }
|
||||
|
||||
[JsonPropertyName("reward_number")]
|
||||
[Key("reward_number")]
|
||||
public int RewardNumber { get; set; }
|
||||
|
||||
[JsonPropertyName("is_owned")]
|
||||
[Key("is_owned")]
|
||||
public bool IsOwned { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user