Corrected ProcessBuyTradeRequestData transactionId to be Mongoid, updated associated code
Also moved TransactionId in `InsuranceRequestData` to be MongoId, updated associated code
This commit is contained in:
@@ -864,7 +864,7 @@ public class RagfairController(
|
||||
// Cleanup of cache now we've used the tax value from it
|
||||
ragfairTaxService.ClearStoredOfferTaxById(requestRootItemId);
|
||||
|
||||
var buyTradeRequest = CreateBuyTradeRequestObject(CurrencyType.RUB, tax.Value);
|
||||
var buyTradeRequest = CreateBuyTradeRequestObject(CurrencyType.RUB, tax.Value, pmcData.Id.Value);
|
||||
paymentService.PayMoney(pmcData, buyTradeRequest, sessionId, output);
|
||||
if (output.Warnings.Count > 0)
|
||||
{
|
||||
@@ -1069,7 +1069,7 @@ public class RagfairController(
|
||||
sellInOncePiece
|
||||
);
|
||||
|
||||
var request = CreateBuyTradeRequestObject(CurrencyType.RUB, tax);
|
||||
var request = CreateBuyTradeRequestObject(CurrencyType.RUB, tax, pmcData.Id.Value);
|
||||
paymentService.PayMoney(pmcData, request, sessionId, output);
|
||||
if (output.Warnings.Count > 0)
|
||||
{
|
||||
@@ -1088,12 +1088,13 @@ public class RagfairController(
|
||||
/// </summary>
|
||||
/// <param name="currency">What currency: RUB, EURO, USD</param>
|
||||
/// <param name="value">Amount of currency</param>
|
||||
/// <param name="pmcId">Players id</param>
|
||||
/// <returns>ProcessBuyTradeRequestData</returns>
|
||||
protected ProcessBuyTradeRequestData CreateBuyTradeRequestObject(CurrencyType currency, double value)
|
||||
protected ProcessBuyTradeRequestData CreateBuyTradeRequestObject(CurrencyType currency, double value, MongoId pmcId)
|
||||
{
|
||||
return new ProcessBuyTradeRequestData
|
||||
{
|
||||
TransactionId = "ragfair",
|
||||
TransactionId = pmcId,
|
||||
Action = "TradingConfirm",
|
||||
SchemeItems = [new IdWithCount { Id = currency.GetCurrencyTpl(), Count = Math.Round(value) }],
|
||||
Type = string.Empty,
|
||||
|
||||
@@ -87,10 +87,14 @@ public class TradeController(
|
||||
|
||||
foreach (var offer in request.Offers)
|
||||
{
|
||||
var fleaOffer = ragfairServer.GetOffer(offer.Id);
|
||||
var fleaOffer = ragfairServer.GetOffer(new MongoId(offer.Id));
|
||||
if (fleaOffer is null)
|
||||
{
|
||||
return httpResponseUtil.AppendErrorToOutput(output, $"Offer with ID {offer.Id} not found", BackendErrorCodes.OfferNotFound);
|
||||
return httpResponseUtil.AppendErrorToOutput(
|
||||
output,
|
||||
$"Offer with ID: {offer.Id} not found",
|
||||
BackendErrorCodes.OfferNotFound
|
||||
);
|
||||
}
|
||||
|
||||
if (offer.Count == 0)
|
||||
@@ -156,7 +160,7 @@ public class TradeController(
|
||||
var buyData = new ProcessBuyTradeRequestData
|
||||
{
|
||||
Action = "TradingConfirm",
|
||||
Type = "buy_from_ragfair",
|
||||
Type = "buy_from_ragfair_trader",
|
||||
TransactionId = fleaOffer.User.Id,
|
||||
ItemId = fleaOffer.Root,
|
||||
Count = requestOffer.Count,
|
||||
@@ -188,8 +192,8 @@ public class TradeController(
|
||||
var buyData = new ProcessBuyTradeRequestData
|
||||
{
|
||||
Action = "TradingConfirm",
|
||||
Type = "buy_from_ragfair",
|
||||
TransactionId = "ragfair",
|
||||
Type = "buy_from_ragfair_pmc",
|
||||
TransactionId = fleaOffer.User.Id,
|
||||
ItemId = fleaOffer.Id, // Store ragfair offerId in buyRequestData.item_id
|
||||
Count = requestOffer.Count,
|
||||
SchemeId = 0,
|
||||
|
||||
@@ -57,7 +57,7 @@ public class TradeHelper(
|
||||
List<Item> offerItems = [];
|
||||
Action<int>? buyCallback;
|
||||
|
||||
if (string.Equals(buyRequestData.TransactionId, "ragfair", StringComparison.OrdinalIgnoreCase))
|
||||
if (string.Equals(buyRequestData.Type, "buy_from_ragfair_pmc", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// Called when player purchases PMC offer from ragfair
|
||||
buyCallback = buyCount =>
|
||||
@@ -129,6 +129,7 @@ public class TradeHelper(
|
||||
}
|
||||
else
|
||||
{
|
||||
// Can only be trader purchase
|
||||
buyCallback = buyCount =>
|
||||
{
|
||||
// Update assort/flea item values
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace SPTarkov.Server.Core.Models.Eft.Insurance;
|
||||
public record InsureRequestData : InventoryBaseActionRequestData
|
||||
{
|
||||
[JsonPropertyName("tid")]
|
||||
public string? TransactionId { get; set; }
|
||||
public MongoId TransactionId { get; set; }
|
||||
|
||||
[JsonPropertyName("items")]
|
||||
public List<MongoId>? Items { get; set; }
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using SPTarkov.Server.Core.Models.Common;
|
||||
using SPTarkov.Server.Core.Models.Eft.Inventory;
|
||||
|
||||
namespace SPTarkov.Server.Core.Models.Eft.Trade;
|
||||
@@ -9,5 +10,5 @@ public record ProcessBaseTradeRequestData : InventoryBaseActionRequestData
|
||||
public string? Type { get; set; }
|
||||
|
||||
[JsonPropertyName("tid")]
|
||||
public string? TransactionId { get; set; }
|
||||
public MongoId TransactionId { get; set; }
|
||||
}
|
||||
|
||||
@@ -76,17 +76,13 @@ public class PaymentService(
|
||||
// Track the total amount of all currencies.
|
||||
var totalCurrencyAmount = 0d;
|
||||
|
||||
// TODO: PMC flea offers use a transaction id of "ragfair", hacky
|
||||
var isPmcFleaPurchase = request.TransactionId == "ragfair";
|
||||
var requestTransactionId = isPmcFleaPurchase ? MongoId.Empty() : new MongoId(request.TransactionId);
|
||||
var requestTransactionId = new MongoId(request.TransactionId);
|
||||
|
||||
// Who is recipient of money player is sending
|
||||
var payToTrader = !isPmcFleaPurchase && traderHelper.TraderExists(requestTransactionId);
|
||||
var payToTrader = request.Type == "buy_from_ragfair_trader" && traderHelper.TraderExists(requestTransactionId);
|
||||
|
||||
// May need to convert to trader currency
|
||||
var trader = isPmcFleaPurchase
|
||||
? new TraderBase { Currency = CurrencyType.RUB }
|
||||
: traderHelper.GetTrader(requestTransactionId, sessionID);
|
||||
var trader = payToTrader ? traderHelper.GetTrader(requestTransactionId, sessionID) : new TraderBase { Currency = CurrencyType.RUB }; // TODO: cleanup
|
||||
|
||||
// Loop through each type of currency involved in the trade
|
||||
foreach (var (currencyTpl, currencyAmount) in currencyAmounts)
|
||||
|
||||
Reference in New Issue
Block a user