web-next: /restore-items cobra por SumUp (1€/ítem) en vez de PD
- Nuevo servicio de pago `restore-item` (getRestoreItemPrice default 1€, fulfill SOAP `.item restore <recover_id> <char>`). Al pulsar "Recuperar" se crea un checkout de SumUp y al pagar se ejecuta el restore. - Se quita el descuento de 100 PD y el gate "No tienes PD suficientes". - La búsqueda sigue igual (gratis, cooldown 8h, Turnstile). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -7,11 +7,10 @@ import { getGameCharacters } from './characters'
|
||||
* Recuperar ítems (/restore-items): usa el sistema de recuperación de AzerothCore
|
||||
* por SOAP. `.item restore list <char>` lista los ítems borrados recuperables (el
|
||||
* core aplica las condiciones: calidad Raro+, equipable, se liga al recoger,
|
||||
* borrado < 7 días). `.item restore <recoverId> <char>` restaura uno. Cada
|
||||
* restauración cuesta **100 PD**. La consulta tiene cooldown de 8 h por personaje.
|
||||
* borrado < 7 días). La consulta tiene cooldown de 8 h por personaje. La restauración
|
||||
* de cada ítem se paga por **SumUp** (servicio `restore-item`, ejecuta `.item restore`).
|
||||
*/
|
||||
|
||||
export const RESTORE_ITEM_PD = 100
|
||||
const SEARCH_COOLDOWN_MS = 8 * 60 * 60 * 1000
|
||||
const SAFE_NAME = /^[A-Za-z]{1,12}$/
|
||||
|
||||
@@ -74,39 +73,3 @@ export async function listDeletedItems(accountId: number, character: string): Pr
|
||||
.catch(() => {})
|
||||
return { success: true, items: parseRecoverList(soap) }
|
||||
}
|
||||
|
||||
export interface RestoreResult {
|
||||
success: boolean
|
||||
error?: string
|
||||
name?: string
|
||||
}
|
||||
|
||||
/** Restaura un ítem borrado (cuesta 100 PD; reembolsa si el SOAP falla). */
|
||||
export async function restoreItem(accountId: number, character: string, recoverId: number): Promise<RestoreResult> {
|
||||
if (!(await ownsCharacter(accountId, character))) return { success: false, error: 'characterNotOwned' }
|
||||
if (!Number.isInteger(recoverId) || recoverId <= 0) return { success: false, error: 'invalidRequest' }
|
||||
|
||||
// Cobra 100 PD de forma atómica.
|
||||
let charged = false
|
||||
try {
|
||||
const [res] = await db(DB.default).query(
|
||||
'UPDATE home_api_points SET dp = dp - ? WHERE accountID = ? AND dp >= ?',
|
||||
[RESTORE_ITEM_PD, accountId, RESTORE_ITEM_PD],
|
||||
)
|
||||
// @ts-expect-error affectedRows
|
||||
charged = res.affectedRows === 1
|
||||
} catch {
|
||||
return { success: false, error: 'genericError' }
|
||||
}
|
||||
if (!charged) return { success: false, error: 'insufficientPoints' }
|
||||
|
||||
const soap = await executeSoapCommand(`.item restore ${recoverId} ${character}`)
|
||||
if (soap === null) {
|
||||
await db(DB.default)
|
||||
.query('UPDATE home_api_points SET dp = dp + ? WHERE accountID = ?', [RESTORE_ITEM_PD, accountId])
|
||||
.catch(() => {})
|
||||
return { success: false, error: 'soapError' }
|
||||
}
|
||||
|
||||
return { success: true }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user