Update GetProductList.cs

This commit is contained in:
Mikhail
2024-12-20 15:58:58 -05:00
parent 1e7de0ef8b
commit 5391a2da3a

View File

@@ -8,36 +8,36 @@ namespace EpinelPS.LobbyServer.Msgs.Shop
{ {
protected override async Task HandleAsync() protected override async Task HandleAsync()
{ {
try var x = await ReadData<ReqGetJupiterProductList>();
var response = new ResGetJupiterProductList();
foreach (var item in x.ProductIdList)
{ {
var x = await ReadData<ReqGetJupiterProductList>(); // TODO: Optimize this!
var product = GameData.Instance.mediasProductTable.Where(x => x.Key == item);
var response = new ResGetJupiterProductList(); if (product.Any())
foreach (var item in x.ProductIdList)
{ {
// TODO: Optimize this! // Example:
var product = GameData.Instance.mediasProductTable.Where(x => x.Key == item); // Midas RequestGetLocalPriceAsync res ProductId = com.proximabeta.nikke.costumegacha11_02, Price = 3.99, MicroPrice = 3990000, CurrencyCode = USD, CurrencySymbol = $
MidasProductRecord? record = product.FirstOrDefault().Value;
if (product.Any()) if (record != null)
{ {
// Example: if(!double.TryParse(record.cost, out double price))
// Midas RequestGetLocalPriceAsync res ProductId = com.proximabeta.nikke.costumegacha11_02, Price = 3.99, MicroPrice = 3990000, CurrencyCode = USD, CurrencySymbol = $ {
MidasProductRecord? record = product.FirstOrDefault().Value; Console.WriteLine("Failed to parse " + record.cost+" Cash shop will not work probably");
}
long microPrice = (long)(double.Parse(record.cost) * 1000000);
long microPrice = (long)(price * 1000000);
response.ProductInfoList.Add(new NetJupiterProductInfo() { CurrencyCode = "USD", CurrencySymbol = "$", MicroPrice = microPrice, Price = record.cost, ProductId = item }); response.ProductInfoList.Add(new NetJupiterProductInfo() { CurrencyCode = "USD", CurrencySymbol = "$", MicroPrice = microPrice, Price = record.cost, ProductId = item });
} }
else
{
Console.WriteLine("Missing!!!! " + item);
}
} }
await WriteDataAsync(response); else
} {
catch (Exception ex) Console.WriteLine("Missing!!!! " + item);
{ }
Console.WriteLine("Error while handling GetProductList request. Have you replaced sodium library?" + ex);
} }
await WriteDataAsync(response);
} }
} }
} }