# DB schema table ```sql ALTER TABLE user_wallets ADD COLUMN buyer_avaible_balance decimal(8,2) DEFAULT 0 COMMENT 'Số dư ví buyer' AFTER `available_balance`; ``` ```sql CREATE TABLE `recharge_transactions` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `user_id` bigint(10) unsigned NOT NULL comment 'id của users', `transaction_id` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL comment 'wallet_code + id của transaction', `recharge_api_id` bigint(20) unsigned NOT NULL comment 'API id (nguồn nạp tiền)', `amount` decimal(8, 2) NOT NULL DEFAULT '0' comment 'giá trị transaction', `actual_amount` decimal(8, 2) NOT NULL DEFAULT '0' comment 'giá trị nhận', `status` tinyint(1) NOT NULL DEFAULT '0' comment 'trạng thái giao dịch, 0 thất bại, 1 thành công', `message` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL comment 'message giao dịch', `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) USING BTREE, KEY `UID_IDX` (`user_id`) USING BTREE, unique `TRANSACTION_ID` (`transaction_id`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; ``` ```sql CREATE TABLE `history_transactions` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `handle_id` bigint(10) unsigned NOT NULL comment 'id của users, admins nạp', `handle_model` int NOT NULL DEFAULT '0' comment '0: user, 1 : admin', `user_id` bigint(10) unsigned NOT NULL comment 'id của users nhận', `amount` decimal(8, 2) NOT NULL comment 'giá trị nạp', `actual_amount` decimal(8, 2) NOT NULL DEFAULT '0' comment 'Số tiền thực nhận', `current_balance` decimal(8, 2) NOT NULL comment 'số dư hiện tại', `type` tinyint(1) NOT NULL comment 'loại giao dịch 1: cộng tiền, 0: trừ tiền', `reason` tinyint(1) NOT NULL comment 'lý do', `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci comment 'ghi chú', `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) USING BTREE, KEY `UID_IDX` (`user_id`) USING BTREE, KEY `UID_HANDLE` (`handle_id`) USING BTREE ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; ``` ```sql CREATE TABLE recharge_apis ( `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, `wallet_code` VARCHAR(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'mã ví', `wallet_number` VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'số tài khoản ví', `wallet_holder` VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Chủ sở hữu tài khoàn', `api_token` VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'token api', `api_username` VARCHAR(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'username api', `api_password` VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'password api', `schedule_time` int(10) default null COMMENT 'Thời gian chạy job', `type` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Loại ví - 0: digital wallet, 1: bank wallet', `status` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Trạng thái api - 0: không kích hoạt, 1: kích hoạt', `notify` VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Thông báo của api', `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) USING BTREE ) ENGINE = INNODB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; ```