правки для магазина

This commit is contained in:
2026-07-19 19:13:50 +04:00
parent 58dcb622f3
commit 737d7c756d
3 changed files with 109 additions and 57 deletions
+49 -2
View File
@@ -73,8 +73,15 @@ CREATE TABLE IF NOT EXISTS `store_currencies` (
-- Dumping data for table store.store_currencies: ~2 rows (approximately)
INSERT INTO `store_currencies` (`id`, `type`, `name`, `icon`, `data`, `tooltip`) VALUES
(1, 1, 'Gold', 'Gold', 0, 'This is normal gold.'),
(2, 2, 'Item Token', 'Token', 4540, 'This is an item currency.');
(1, 3, 'Баланс', 'Gold', 0, 'Баланс учётной записи на сайте.');
-- The website account balance is the only in-game store currency. These
-- statements also migrate databases bootstrapped by an older Store.sql.
UPDATE `store_currencies`
SET `type` = 3, `name` = 'Баланс', `icon` = 'Gold', `data` = 0,
`tooltip` = 'Баланс учётной записи на сайте.'
WHERE `id` = 1;
DELETE FROM `store_currencies` WHERE `id` <> 1;
-- Dumping structure for table store.store_logs
CREATE TABLE IF NOT EXISTS `store_logs` (
@@ -173,6 +180,46 @@ INSERT INTO `store_services` (`id`, `type`, `name`, `tooltipName`, `tooltipType`
(17, 8, 'Level 60 Boost', 'Level Boost', '', 'Boosts your characters level to level 60!', 'achievement_level_60', 40, 1, 0, 0, 0, 1, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1),
(18, 1, 'Tuxedo Set', 'Tuxedo Set', '', 'Express your great fashion sense with this full Tuxedo set!\r\n\r\nContains the following:\r\n\r\n1x Tuxedo Jacket\r\n1x Tuxedo Shirt\r\n1x Tuxedo Pants', 'inv_shirt_black_01', 50, 1, 0, 0, 0, 1, 10036, 10035, 10034, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1);
UPDATE `store_services` SET `currency` = 1;
-- Atomic bridge between the website balance and Eluna. It both reserves the
-- funds and writes the website-compatible ledger entry before a reward is sent.
DROP FUNCTION IF EXISTS `acore_auth`.`store_deduct_balance`;
DELIMITER //
CREATE FUNCTION `acore_auth`.`store_deduct_balance`(
p_account_id INT UNSIGNED,
p_amount DECIMAL(14,2),
p_reference VARCHAR(191),
p_character_guid INT UNSIGNED,
p_service_id INT UNSIGNED
) RETURNS DECIMAL(14,2)
DETERMINISTIC
MODIFIES SQL DATA
BEGIN
DECLARE v_balance_after DECIMAL(14,2) DEFAULT -1;
UPDATE `acore_auth`.`account_balances`
SET `balance` = `balance` - p_amount, `updated_at` = CURRENT_TIMESTAMP
WHERE `account_id` = p_account_id
AND p_amount >= 0
AND `balance` >= p_amount;
IF ROW_COUNT() = 1 THEN
SELECT `balance` INTO v_balance_after
FROM `acore_auth`.`account_balances`
WHERE `account_id` = p_account_id;
INSERT INTO `acore_auth`.`balance_transactions`
(`account_id`, `type`, `amount`, `balance_after`, `reference`, `metadata`, `created_at`)
VALUES
(p_account_id, 'store_purchase', -p_amount, v_balance_after, p_reference,
JSON_OBJECT('character_guid', p_character_guid, 'service_id', p_service_id), CURRENT_TIMESTAMP);
END IF;
RETURN v_balance_after;
END//
DELIMITER ;
/*!40103 SET TIME_ZONE=IFNULL(@OLD_TIME_ZONE, 'system') */;
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;