Fix: taking the wrong amount
This commit is contained in:
@@ -69,7 +69,12 @@ public class PaymentService(
|
||||
else
|
||||
{
|
||||
// If the item is money, add its count to the currencyAmounts object.
|
||||
currencyAmounts.TryAdd(item.Template, currencyAmounts.GetValueOrDefault(item.Template, 0) + itemRequest.Count);
|
||||
// sometimes the currency can be in two parts, so it fails to tryadd the second part
|
||||
if (!currencyAmounts.TryAdd(item.Template, currencyAmounts.GetValueOrDefault(item.Template, 0) + itemRequest.Count))
|
||||
{
|
||||
// if it fails, add the amount to the existing amount
|
||||
currencyAmounts[item.Template] += itemRequest.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -77,7 +82,12 @@ public class PaymentService(
|
||||
// Used by `SptInsure`
|
||||
// Handle differently, `id` is the money type tpl
|
||||
var currencyTpl = itemRequest.Id;
|
||||
currencyAmounts.TryAdd(currencyTpl, currencyAmounts.GetValueOrDefault(currencyTpl, 0) + itemRequest.Count);
|
||||
// sometimes the currency can be in two parts, so it fails to tryadd the second part
|
||||
if (!currencyAmounts.TryAdd(currencyTpl, currencyAmounts.GetValueOrDefault(currencyTpl, 0) + itemRequest.Count))
|
||||
{
|
||||
// if it fails, add the amount to the existing amount
|
||||
currencyAmounts[currencyTpl] += itemRequest.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user