-- Database Backup
-- Date: 2025-11-30 04:11:19
-- Database: petrolim_bot_ban_hang

DROP TABLE IF EXISTS `activity_logs`;

CREATE TABLE `activity_logs` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` bigint(20) DEFAULT NULL,
  `action` varchar(255) DEFAULT NULL,
  `details` text DEFAULT NULL,
  `ip_address` varchar(50) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_created_at` (`created_at`),
  KEY `idx_user_id` (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

INSERT INTO `activity_logs` (`id`, `user_id`, `action`, `details`, `ip_address`, `created_at`) VALUES ('1', '0', 'OPTIMIZE_DB', 'Tối ưu hóa database', '3.81.200.231', '2025-11-30 11:11:18');

DROP TABLE IF EXISTS `order_accounts`;

CREATE TABLE `order_accounts` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `order_id` int(11) NOT NULL,
  `account_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `order_id` (`order_id`),
  KEY `account_id` (`account_id`)
) ENGINE=InnoDB AUTO_INCREMENT=96 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('52', '1', '1');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('53', '1', '2');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('54', '1', '3');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('55', '1', '4');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('56', '1', '5');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('57', '2', '6');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('58', '2', '8');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('59', '2', '9');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('60', '2', '10');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('61', '2', '11');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('62', '2', '12');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('63', '2', '13');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('64', '4', '14');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('65', '4', '15');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('66', '5', '16');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('67', '5', '17');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('68', '1', '1');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('69', '2', '2');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('70', '2', '3');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('71', '3', '4');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('72', '4', '5');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('73', '5', '6');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('74', '6', '7');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('75', '7', '8');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('76', '7', '9');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('77', '8', '10');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('78', '8', '11');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('79', '8', '12');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('80', '8', '13');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('81', '8', '14');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('82', '9', '15');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('83', '10', '16');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('84', '6', '1');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('85', '6', '2');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('86', '5', '3');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('87', '5', '4');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('88', '7', '5');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('89', '7', '6');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('90', '7', '7');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('91', '9', '8');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('92', '2', '1');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('93', '1', '1');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('94', '1', '1');
INSERT INTO `order_accounts` (`id`, `order_id`, `account_id`) VALUES ('95', '2', '1');

DROP TABLE IF EXISTS `orders`;

CREATE TABLE `orders` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` bigint(20) NOT NULL,
  `product_id` int(11) NOT NULL,
  `account_id` int(11) DEFAULT NULL,
  `total_price` decimal(10,2) NOT NULL,
  `status` varchar(50) DEFAULT 'pending',
  `order_code` varchar(50) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `processing_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `orders_ibfk_1` (`product_id`),
  KEY `orders_ibfk_2` (`account_id`),
  CONSTRAINT `orders_ibfk_1` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `orders_ibfk_2` FOREIGN KEY (`account_id`) REFERENCES `product_accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

INSERT INTO `orders` (`id`, `user_id`, `product_id`, `account_id`, `total_price`, `status`, `order_code`, `created_at`, `processing_at`) VALUES ('1', '5991592025', '1', NULL, '26000.00', 'pending', 'DH0001', '2025-11-28 21:34:45', NULL);
INSERT INTO `orders` (`id`, `user_id`, `product_id`, `account_id`, `total_price`, `status`, `order_code`, `created_at`, `processing_at`) VALUES ('2', '5991592025', '1', '1', '13000.00', 'completed', 'DH0002', '2025-11-28 21:49:45', NULL);
INSERT INTO `orders` (`id`, `user_id`, `product_id`, `account_id`, `total_price`, `status`, `order_code`, `created_at`, `processing_at`) VALUES ('3', '558200751', '1', NULL, '13000.00', 'pending', 'DH0003', '2025-11-28 21:50:02', NULL);
INSERT INTO `orders` (`id`, `user_id`, `product_id`, `account_id`, `total_price`, `status`, `order_code`, `created_at`, `processing_at`) VALUES ('4', '5991592025', '1', NULL, '195000.00', 'pending', 'DH0004', '2025-11-28 23:30:57', NULL);
INSERT INTO `orders` (`id`, `user_id`, `product_id`, `account_id`, `total_price`, `status`, `order_code`, `created_at`, `processing_at`) VALUES ('5', '2032631208', '1', NULL, '13000.00', 'pending', 'DH0005', '2025-11-29 21:16:03', NULL);

DROP TABLE IF EXISTS `product_accounts`;

CREATE TABLE `product_accounts` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `product_id` int(11) NOT NULL,
  `account_data` text NOT NULL,
  `is_sold` tinyint(1) DEFAULT 0,
  `sold_to_user_id` bigint(20) DEFAULT NULL,
  `sold_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `product_accounts_ibfk_1` (`product_id`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

INSERT INTO `product_accounts` (`id`, `product_id`, `account_data`, `is_sold`, `sold_to_user_id`, `sold_at`) VALUES ('1', '1', '956mpv3kf7@hathitrannhien.edu.vn|ChatGPT@4672|2S2QD5BS3QIFJ3GSEY7V4LGVPCRZ3S2U', '1', '5991592025', '2025-11-28 21:50:27');
INSERT INTO `product_accounts` (`id`, `product_id`, `account_data`, `is_sold`, `sold_to_user_id`, `sold_at`) VALUES ('2', '1', 'guiooqm83e@tempmail.ckvn.edu.vn|ChatGPT@1269|BUGIEHKUKLSPORWSIB2WOQDPGABXVAVQ', '0', NULL, NULL);
INSERT INTO `product_accounts` (`id`, `product_id`, `account_data`, `is_sold`, `sold_to_user_id`, `sold_at`) VALUES ('3', '1', 'vid2df3rt7@1trick.net|ChatGPT@7428|S2UFJ45AEZGI7HHFDQ3FLZZB2PDBOLSD', '0', NULL, NULL);
INSERT INTO `product_accounts` (`id`, `product_id`, `account_data`, `is_sold`, `sold_to_user_id`, `sold_at`) VALUES ('4', '1', 's75a8ls3n0@1trick.net|ChatGPT@6474|V2CHGX5FT6YJKAQL6YSPVN3XK2RKGM6D', '0', NULL, NULL);
INSERT INTO `product_accounts` (`id`, `product_id`, `account_data`, `is_sold`, `sold_to_user_id`, `sold_at`) VALUES ('5', '1', 'soh9gsv49s@tempmail.ckvn.edu.vn|ChatGPT@3328|IGWI6CFK2TPHHEPL5EGAX2F2PZRBWLBX', '0', NULL, NULL);
INSERT INTO `product_accounts` (`id`, `product_id`, `account_data`, `is_sold`, `sold_to_user_id`, `sold_at`) VALUES ('6', '1', 'rgg1romihs@tempmail.id.vn|ChatGPT@1968|M4GBFMHB7CEUWJSPT7XMLGUOAY7IDL5S', '0', NULL, NULL);
INSERT INTO `product_accounts` (`id`, `product_id`, `account_data`, `is_sold`, `sold_to_user_id`, `sold_at`) VALUES ('7', '1', 'g24b7jshs7@1trick.net|ChatGPT@8802|TE754MDAHOLBIZK6QHFXTJK6EI7QE5LO', '0', NULL, NULL);
INSERT INTO `product_accounts` (`id`, `product_id`, `account_data`, `is_sold`, `sold_to_user_id`, `sold_at`) VALUES ('8', '1', 'hft29alu5b@tempmail.id.vn|ChatGPT@5214|QWXDYQSQYE6VCNHXSPOXAJST7AWCIKKF', '0', NULL, NULL);
INSERT INTO `product_accounts` (`id`, `product_id`, `account_data`, `is_sold`, `sold_to_user_id`, `sold_at`) VALUES ('9', '1', 'bpflxqciuy@tempmail.id.vn|ChatGPT@2755|KGHVYJYYNNJIEW2COPRGPUE7EDRNCMLW', '0', NULL, NULL);
INSERT INTO `product_accounts` (`id`, `product_id`, `account_data`, `is_sold`, `sold_to_user_id`, `sold_at`) VALUES ('10', '1', 'ou199rfhlz@tempmail.ckvn.edu.vn|ChatGPT@1870|A23RE2WSA3RVSE2Q6LQKQSYEEJTF2LNZ', '0', NULL, NULL);
INSERT INTO `product_accounts` (`id`, `product_id`, `account_data`, `is_sold`, `sold_to_user_id`, `sold_at`) VALUES ('11', '1', '7vc9520z4o@tempmail.id.vn|ChatGPT@7913|3W65JLL5ULFBRSE3FQXRI4B46NK7W5P7', '0', NULL, NULL);
INSERT INTO `product_accounts` (`id`, `product_id`, `account_data`, `is_sold`, `sold_to_user_id`, `sold_at`) VALUES ('12', '1', 'scucxbe1s6@tempmail.ckvn.edu.vn|ChatGPT@8315|MGXS26XCXLUIBGBNNIUQM2ZGYS2HQGNS', '0', NULL, NULL);
INSERT INTO `product_accounts` (`id`, `product_id`, `account_data`, `is_sold`, `sold_to_user_id`, `sold_at`) VALUES ('13', '1', 'f6zj2xt793@hathitrannhien.edu.vn|ChatGPT@5320|CZORUWIDSR34PLFIGPEV3DLQWUITB2NJ', '0', NULL, NULL);
INSERT INTO `product_accounts` (`id`, `product_id`, `account_data`, `is_sold`, `sold_to_user_id`, `sold_at`) VALUES ('14', '1', 'rx2oa7f6g9@tempmail.ckvn.edu.vn|ChatGPT@4445|XRG2SQNEYEG3Q6JCOUMREXSSGJW6L2MS', '0', NULL, NULL);
INSERT INTO `product_accounts` (`id`, `product_id`, `account_data`, `is_sold`, `sold_to_user_id`, `sold_at`) VALUES ('15', '1', 'tftp05k4ql@tempmail.ckvn.edu.vn|ChatGPT@5176|UHAOZ5ERHHB32REI2H5ZIN6SLHU7B6QI', '0', NULL, NULL);
INSERT INTO `product_accounts` (`id`, `product_id`, `account_data`, `is_sold`, `sold_to_user_id`, `sold_at`) VALUES ('16', '1', '4u1lfe60wk@hathitrannhien.edu.vn|ChatGPT@2145|S7QGONW2YXI2JFRNQGQQKD3KCW4AM7WY', '0', NULL, NULL);

DROP TABLE IF EXISTS `products`;

CREATE TABLE `products` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `description` text DEFAULT NULL,
  `price` decimal(10,2) NOT NULL,
  `category` varchar(100) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

INSERT INTO `products` (`id`, `name`, `description`, `price`, `category`, `created_at`) VALUES ('1', 'ChatGPT Go [User|Pass|2FA]', 'GPT Go', '13000.00', 'AI', '2025-11-28 20:29:41');

DROP TABLE IF EXISTS `users`;

CREATE TABLE `users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `telegram_id` bigint(20) NOT NULL,
  `username` varchar(255) DEFAULT NULL,
  `first_name` varchar(255) DEFAULT NULL,
  `registered_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `telegram_id` (`telegram_id`)
) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

INSERT INTO `users` (`id`, `telegram_id`, `username`, `first_name`, `registered_at`) VALUES ('1', '5991592025', 'giacatluon99', 'Gia Cát Lượng', '2025-11-28 20:48:13');
INSERT INTO `users` (`id`, `telegram_id`, `username`, `first_name`, `registered_at`) VALUES ('9', '558200751', 'buidinh1803', 'Mr.0🔥', '2025-11-28 21:49:39');
INSERT INTO `users` (`id`, `telegram_id`, `username`, `first_name`, `registered_at`) VALUES ('23', '5307991443', 'Huy30042001', 'Huy', '2025-11-29 10:10:59');
INSERT INTO `users` (`id`, `telegram_id`, `username`, `first_name`, `registered_at`) VALUES ('26', '2032631208', 'Tien21t', 'Tien', '2025-11-29 21:15:32');

