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:
36
SVSim.Database/Models/LeaderSkinShopProductEntry.cs
Normal file
36
SVSim.Database/Models/LeaderSkinShopProductEntry.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using SVSim.Database.Common;
|
||||
|
||||
namespace SVSim.Database.Models;
|
||||
|
||||
/// <summary>
|
||||
/// One purchasable leader-skin product. PK = wire product_id (small ints in captures — e.g. 31,
|
||||
/// 165, 166). FK <see cref="SeriesId"/>. <see cref="LeaderSkinId"/> points at the
|
||||
/// <see cref="LeaderSkinEntry"/> the buyer ends up owning.
|
||||
/// </summary>
|
||||
public class LeaderSkinShopProductEntry : BaseEntity<int>
|
||||
{
|
||||
public int SeriesId { get; set; }
|
||||
public int LeaderSkinId { get; set; }
|
||||
|
||||
/// <summary>SystemText keys — resolved client-side via Data.Master.GetLeaderSkinProductText.</summary>
|
||||
public string ProductNameKey { get; set; } = string.Empty;
|
||||
public string IntroductionKey { get; set; } = string.Empty;
|
||||
public string CvNameKey { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Per-product price for solo buy. Captures consistently show crystal/rupy parity for
|
||||
/// regular skins (500c / 500r single, 400 unit-price when bought as set). Nullable so
|
||||
/// promotions can offer one currency without the other.
|
||||
/// </summary>
|
||||
public int? SinglePriceCrystal { get; set; }
|
||||
public int? SinglePriceRupy { get; set; }
|
||||
public int? SinglePriceTicket { get; set; }
|
||||
public int? TicketNumber { get; set; }
|
||||
public long? TicketItemId { get; set; }
|
||||
|
||||
public bool IsEnabled { get; set; }
|
||||
|
||||
public List<LeaderSkinShopProductRewardEntry> Rewards { get; set; } = new();
|
||||
|
||||
public LeaderSkinShopSeriesEntry? Series { get; set; }
|
||||
}
|
||||
17
SVSim.Database/Models/LeaderSkinShopProductRewardEntry.cs
Normal file
17
SVSim.Database/Models/LeaderSkinShopProductRewardEntry.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace SVSim.Database.Models;
|
||||
|
||||
/// <summary>
|
||||
/// One per-buy reward attached to a leader-skin product. Owned by
|
||||
/// <see cref="LeaderSkinShopProductEntry"/>. Captures show each skin product bundles 3 rewards:
|
||||
/// the skin itself (type=10), the matching emblem (type=7), and the matching sleeve (type=6).
|
||||
/// </summary>
|
||||
[Owned]
|
||||
public class LeaderSkinShopProductRewardEntry
|
||||
{
|
||||
public int OrderIndex { get; set; }
|
||||
public int RewardType { get; set; } // Wizard.UserGoods.Type
|
||||
public long RewardDetailId { get; set; }
|
||||
public int RewardNumber { get; set; }
|
||||
}
|
||||
33
SVSim.Database/Models/LeaderSkinShopSeriesEntry.cs
Normal file
33
SVSim.Database/Models/LeaderSkinShopSeriesEntry.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using SVSim.Database.Common;
|
||||
|
||||
namespace SVSim.Database.Models;
|
||||
|
||||
/// <summary>
|
||||
/// One leader-skin-shop series (a themed collection — e.g. "7th Anniversary Skins").
|
||||
/// PK = wire series_id. <see cref="SetSalesStatus"/> controls whether the per-series
|
||||
/// "buy whole set" UI is offered: 0=none (single-skin purchases only), non-zero=set sale active.
|
||||
/// When set-active, the set-price + set-completion-reward fields are populated.
|
||||
/// </summary>
|
||||
public class LeaderSkinShopSeriesEntry : BaseEntity<int>
|
||||
{
|
||||
public bool IsNew { get; set; }
|
||||
public bool IsEnabled { get; set; }
|
||||
|
||||
/// <summary>SkinSeriesPurchaseInfo.eSetSalesStatus — 0=None.</summary>
|
||||
public int SetSalesStatus { get; set; }
|
||||
|
||||
public int? SetPriceCrystal { get; set; }
|
||||
public int? SetPriceRupy { get; set; }
|
||||
public int? SetPriceTicket { get; set; }
|
||||
public long? SetPriceTicketId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// SkinSeriesPurchaseInfo.RewardStatus — 0=none. The per-VIEWER claim state is computed
|
||||
/// at request time from <see cref="ViewerLeaderSkinSetClaim"/>; this column is the catalog
|
||||
/// default surfaced when no viewer is in context (or when set_sales_status==0).
|
||||
/// </summary>
|
||||
public int SetCompletionRewardStatus { get; set; }
|
||||
|
||||
public List<LeaderSkinShopProductEntry> Products { get; set; } = new();
|
||||
public List<LeaderSkinShopSeriesRewardEntry> SetCompletionRewards { get; set; } = new();
|
||||
}
|
||||
18
SVSim.Database/Models/LeaderSkinShopSeriesRewardEntry.cs
Normal file
18
SVSim.Database/Models/LeaderSkinShopSeriesRewardEntry.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace SVSim.Database.Models;
|
||||
|
||||
/// <summary>
|
||||
/// One set-completion bonus item attached to a leader-skin series. Owned by
|
||||
/// <see cref="LeaderSkinShopSeriesEntry"/>. Granted by /leader_skin/buy_set_item once the
|
||||
/// viewer owns every skin in the series. Wire shape: entries inside
|
||||
/// <c>rewards.items[]</c> on the per-series block of /leader_skin/products.
|
||||
/// </summary>
|
||||
[Owned]
|
||||
public class LeaderSkinShopSeriesRewardEntry
|
||||
{
|
||||
public int OrderIndex { get; set; }
|
||||
public int RewardType { get; set; }
|
||||
public long RewardDetailId { get; set; }
|
||||
public int RewardNumber { get; set; }
|
||||
}
|
||||
14
SVSim.Database/Models/ViewerLeaderSkinSetClaim.cs
Normal file
14
SVSim.Database/Models/ViewerLeaderSkinSetClaim.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace SVSim.Database.Models;
|
||||
|
||||
/// <summary>
|
||||
/// One row per (viewer, leader-skin series) marking that the viewer has claimed the
|
||||
/// series-completion bonus via /leader_skin/buy_set_item. Composite PK (ViewerId, SeriesId).
|
||||
/// Standalone table (not a Viewer owned collection) to avoid the cartesian-explode pitfall
|
||||
/// when loading the viewer graph — claim state is checked per-series, not per-viewer-load.
|
||||
/// </summary>
|
||||
public class ViewerLeaderSkinSetClaim
|
||||
{
|
||||
public long ViewerId { get; set; }
|
||||
public int SeriesId { get; set; }
|
||||
public DateTime ClaimedAt { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user