using CommonDomain.BaseModel; namespace CommonDomain; public static class LotteryPrizeProductHelper { public static void Enrich(LotteryActivityConfig? lottery, GameConfig? gameConfig) { if (lottery?.Pools == null || gameConfig == null) return; foreach (var prize in lottery.Pools.SelectMany(pool => pool.PrizeList ?? new List())) { if (string.IsNullOrWhiteSpace(prize.OtherId)) continue; var number = prize.OtherId.Trim(); var fragment = gameConfig.PropFragments?.FirstOrDefault(item => item.Number == number); BaseProduct? product; if (fragment != null) { prize.Type = 4; product = fragment; } else { product = gameConfig.PropConfig?.FirstOrDefault(item => item.Number == number); if (product == null) continue; prize.Type = 3; } var imageUrl = product.ImageUrl; if (string.IsNullOrWhiteSpace(imageUrl) && fragment != null) imageUrl = gameConfig.PropConfig?.FirstOrDefault(item => item.Number == fragment.ProductNumber)?.ImageUrl ?? ""; if (string.IsNullOrWhiteSpace(prize.Name)) prize.Name = product.Name; if (!string.IsNullOrWhiteSpace(imageUrl)) prize.Icon = imageUrl; prize.Product ??= new BaseProduct(); prize.Product.Number = product.Number; prize.Product.Name = product.Name; prize.Product.Desc = product.Desc; prize.Product.ImageUrl = imageUrl; prize.Product.Type = product.Type; prize.Product.Level = product.Level; } } }