Migrate giveProfileMoney() to use addItemToStash()

This commit is contained in:
Dev 2024-01-20 20:06:15 +00:00
parent 399bbb2e3b
commit 4bca0b7747

View File

@ -7,6 +7,7 @@ import { PaymentHelper } from "@spt-aki/helpers/PaymentHelper";
import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; import { TraderHelper } from "@spt-aki/helpers/TraderHelper";
import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData";
import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { Item } from "@spt-aki/models/eft/common/tables/IItem";
import { IAddItemDirectRequest } from "@spt-aki/models/eft/inventory/IAddItemDirectRequest";
import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEventRouterResponse"; import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEventRouterResponse";
import { IProcessBuyTradeRequestData } from "@spt-aki/models/eft/trade/IProcessBuyTradeRequestData"; import { IProcessBuyTradeRequestData } from "@spt-aki/models/eft/trade/IProcessBuyTradeRequestData";
import { IProcessSellTradeRequestData } from "@spt-aki/models/eft/trade/IProcessSellTradeRequestData"; import { IProcessSellTradeRequestData } from "@spt-aki/models/eft/trade/IProcessSellTradeRequestData";
@ -14,6 +15,7 @@ import { BackendErrorCodes } from "@spt-aki/models/enums/BackendErrorCodes";
import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer"; import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
import { LocalisationService } from "@spt-aki/services/LocalisationService"; import { LocalisationService } from "@spt-aki/services/LocalisationService";
import { HashUtil } from "@spt-aki/utils/HashUtil";
import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil"; import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil";
@injectable() @injectable()
@ -21,6 +23,7 @@ export class PaymentService
{ {
constructor( constructor(
@inject("WinstonLogger") protected logger: ILogger, @inject("WinstonLogger") protected logger: ILogger,
@inject("HashUtil") protected hashUtil: HashUtil,
@inject("HttpResponseUtil") protected httpResponse: HttpResponseUtil, @inject("HttpResponseUtil") protected httpResponse: HttpResponseUtil,
@inject("DatabaseServer") protected databaseServer: DatabaseServer, @inject("DatabaseServer") protected databaseServer: DatabaseServer,
@inject("HandbookHelper") protected handbookHelper: HandbookHelper, @inject("HandbookHelper") protected handbookHelper: HandbookHelper,
@ -217,16 +220,21 @@ export class PaymentService
if (!skip) if (!skip)
{ {
const request = { const addItemToStashRequest: IAddItemDirectRequest = {
items: [{ itemWithModsToAdd: [
// eslint-disable-next-line @typescript-eslint/naming-convention {
item_id: currency, _id: this.hashUtil.generate(),
count: calcAmount, _tpl: currency,
}], upd: {
tid: body.tid, StackObjectsCount: calcAmount
}
}
],
foundInRaid: false,
callback: null,
useSortingTable: true
}; };
this.inventoryHelper.addItemToStash(sessionID, addItemToStashRequest, pmcData, output);
output = this.inventoryHelper.addItem(pmcData, request, output, sessionID, null, false, null, true);
} }
// set current sale sum // set current sale sum