diff --git a/Libraries/Core/Controllers/CustomizationController.cs b/Libraries/Core/Controllers/CustomizationController.cs
index 473937af..e6825c6a 100644
--- a/Libraries/Core/Controllers/CustomizationController.cs
+++ b/Libraries/Core/Controllers/CustomizationController.cs
@@ -1,15 +1,21 @@
+using System.Text.Json;
using Core.Helpers;
+using Core.Models.Common;
using Core.Models.Eft.Common;
using Core.Models.Eft.Common.Tables;
using Core.Models.Eft.Customization;
using Core.Models.Eft.Hideout;
using Core.Models.Eft.ItemEvent;
+using Core.Models.Eft.Trade;
+using Core.Models.Enums;
using Core.Models.Utils;
using Core.Routers;
using Core.Servers;
using Core.Services;
using Core.Utils.Cloners;
using SptCommon.Annotations;
+using SptCommon.Extensions;
+using Location = Core.Models.Eft.Inventory.Location;
namespace Core.Controllers;
@@ -21,7 +27,8 @@ public class CustomizationController(
SaveServer _saveServer,
LocalisationService _localisationService,
ProfileHelper _profileHelper,
- ICloner _cloner
+ ICloner _cloner,
+ PaymentService _paymentService
)
{
protected string _lowerParentClothingId = "5cd944d01388ce000a659df9";
@@ -97,7 +104,7 @@ public class CustomizationController(
return output;
}
-
+
// Charge player for buying item
PayForClothingItems(sessionId, pmcData, buyClothingRequest.Items, output);
@@ -156,97 +163,19 @@ public class CustomizationController(
foreach (var inventoryItemToProcess in itemsToPayForClothingWith)
{
- PayForClothingItem(sessionId, pmcData, inventoryItemToProcess, output);
- }
- }
-
- ///
- /// Update output object and player profile with purchase details for single piece of clothing
- ///
- /// Session id
- /// Player profile
- /// Payment details
- /// Client response
- private void PayForClothingItem(string sessionId, PmcData pmcData, PaymentItemForClothing? paymentItemDetails,
- ItemEventRouterResponse output)
- {
- var inventoryItem = pmcData.Inventory?.Items?.FirstOrDefault(x => x.Id == paymentItemDetails?.Id);
- if (inventoryItem == null)
- {
- _logger.Error(
- _localisationService.GetText(
- "customisation-unable_to_find_clothing_item_in_inventory",
- paymentItemDetails?.Id
- )
- );
- return;
- }
-
- if (paymentItemDetails?.Del != null)
- {
- output.ProfileChanges[sessionId]
- .Items?.DeletedItems.Add(
- new Item
- {
- Id = inventoryItem.Id,
- Template = inventoryItem.Template,
- ParentId = inventoryItem.ParentId,
- SlotId = inventoryItem.SlotId,
- Location = (ItemLocation?)inventoryItem.Location,
- Upd = inventoryItem.Upd
- }
- );
- }
-
- pmcData.Inventory?.Items?.Remove(inventoryItem);
-
- inventoryItem.Upd ??= new Upd { StackObjectsCount = 1 };
-
- if (inventoryItem.Upd?.StackObjectsCount == null)
- {
- if (inventoryItem.Upd != null)
+ var options = new ProcessBuyTradeRequestData
{
- inventoryItem.Upd.StackObjectsCount = 1;
- }
+ SchemeItems = [new IdWithCount { Count = inventoryItemToProcess.Count.Value, Id = inventoryItemToProcess.Id }],
+ TransactionId = Traders.RAGMAN,
+ Action = "BuyCustomization",
+ Type = "",
+ ItemId = "",
+ Count = 0,
+ SchemeId = 0
+ };
+
+ _paymentService.PayMoney(pmcData, options, sessionId, output);
}
-
- if (inventoryItem.Upd?.StackObjectsCount == paymentItemDetails?.Count)
- {
- output.ProfileChanges[sessionId]
- .Items?.DeletedItems.Add(
- new Item
- {
- Id = inventoryItem.Id,
- Template = inventoryItem.Template,
- ParentId = inventoryItem.ParentId,
- SlotId = inventoryItem.SlotId,
- Location = (ItemLocation?)inventoryItem.Location,
- Upd = inventoryItem.Upd
- }
- );
-
- pmcData.Inventory?.Items?.Remove(inventoryItem);
- return;
- }
-
- if (!(inventoryItem.Upd?.StackObjectsCount > paymentItemDetails?.Count))
- {
- return;
- }
-
- inventoryItem.Upd.StackObjectsCount -= paymentItemDetails.Count;
- output.ProfileChanges[sessionId]
- .Items?.ChangedItems?.Add(
- new Item
- {
- Id = inventoryItem.Id,
- Template = inventoryItem.Template,
- ParentId = inventoryItem.ParentId,
- SlotId = inventoryItem.SlotId,
- Location = (ItemLocation?)inventoryItem.Location,
- Upd = inventoryItem.Upd
- }
- );
}
///
diff --git a/Libraries/Core/Services/PaymentService.cs b/Libraries/Core/Services/PaymentService.cs
index 4eb6d280..7622dbbd 100644
--- a/Libraries/Core/Services/PaymentService.cs
+++ b/Libraries/Core/Services/PaymentService.cs
@@ -10,6 +10,7 @@ using Core.Models.Spt.Config;
using Core.Models.Utils;
using Core.Servers;
using Core.Utils;
+using LogLevel = Core.Models.Spt.Logging.LogLevel;
namespace Core.Services;
@@ -135,7 +136,10 @@ public class PaymentService(
_traderHelper.LevelUp(request.TransactionId, pmcData);
}
- _logger.Debug("Item(s) taken. Status OK.");
+ if (_logger.IsLogEnabled(LogLevel.Debug))
+ {
+ _logger.Debug("Item(s) taken. Status OK.");
+ }
}
private double? GetTraderItemHandbookPriceRouble(string? traderAssortId, string traderId)