diff --git a/src/controllers/api/purchaseController.ts b/src/controllers/api/purchaseController.ts index 4658da51..ce8c873b 100644 --- a/src/controllers/api/purchaseController.ts +++ b/src/controllers/api/purchaseController.ts @@ -13,7 +13,6 @@ export const purchaseController: RequestHandler = async (req, res) => { try { const inventory = await getInventory(accountId); - // 记录购买前的货币状态 const beforePurchase = { RegularCredits: inventory.RegularCredits, PremiumCredits: inventory.PremiumCredits, @@ -26,7 +25,6 @@ export const purchaseController: RequestHandler = async (req, res) => { const response = await handlePurchase(purchaseRequest, inventory); await inventory.save(); - // 记录购买后的货币状态 const afterPurchase = { RegularCredits: inventory.RegularCredits, PremiumCredits: inventory.PremiumCredits, @@ -37,7 +35,6 @@ export const purchaseController: RequestHandler = async (req, res) => { res.json(response); - // 立即发送货币更新广播,确保客户端实时同步 sendWsBroadcastTo(accountId, { update_inventory: true, currency_update: { @@ -50,7 +47,6 @@ export const purchaseController: RequestHandler = async (req, res) => { } catch (error) { logger.error(`Purchase failed for account ${accountId}:`, error); - // 返回详细的错误信息给客户端 if (error instanceof Error && error.message.includes('Insufficient')) { res.status(400).json({ error: 'INSUFFICIENT_CURRENCY', diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index 143d7010..642a9885 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -1259,7 +1259,6 @@ export const updateCurrency = ( ): IInventoryChanges => { if (price != 0 && isCurrencyTracked(inventory, usePremium)) { if (usePremium) { - // 验证白金余额是否足够 if (validateBalance) { const totalPlatinum = inventory.PremiumCredits + inventory.PremiumCreditsFree; if (totalPlatinum < price) { @@ -1278,7 +1277,6 @@ export const updateCurrency = ( inventory.PremiumCredits -= price; logger.debug(`currency changes `, { PremiumCredits: -price }); } else { - // 验证现金余额是否足够 if (validateBalance && inventory.RegularCredits < price) { throw new Error(`Insufficient credits balance. Required: ${price}, Available: ${inventory.RegularCredits}`); }