865 lines
53 KiB
PL/PgSQL
865 lines
53 KiB
PL/PgSQL
/*
|
||
Navicat Premium Dump SQL
|
||
|
||
Source Server : localhost_3306
|
||
Source Server Type : MySQL
|
||
Source Server Version : 80036 (8.0.36)
|
||
Source Host : localhost:3306
|
||
Source Schema : flash_sale_db
|
||
|
||
Target Server Type : MySQL
|
||
Target Server Version : 80036 (8.0.36)
|
||
File Encoding : 65001
|
||
|
||
Date: 25/03/2026 23:57:40
|
||
*/
|
||
|
||
SET NAMES utf8mb4;
|
||
SET FOREIGN_KEY_CHECKS = 0;
|
||
|
||
-- ----------------------------
|
||
-- Table structure for flash_sales
|
||
-- ----------------------------
|
||
DROP TABLE IF EXISTS `flash_sales`;
|
||
CREATE TABLE `flash_sales`
|
||
(
|
||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '秒杀活动ID',
|
||
`product_id` bigint NOT NULL COMMENT '商品ID',
|
||
`flash_price` decimal(10, 2) NOT NULL COMMENT '秒杀价格',
|
||
`flash_stock` int NOT NULL COMMENT '秒杀库存',
|
||
`start_time` timestamp NOT NULL COMMENT '开始时间',
|
||
`end_time` timestamp NOT NULL COMMENT '结束时间',
|
||
`status` tinyint DEFAULT '1' COMMENT '状态:1-未开始,2-进行中,3-已结束',
|
||
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||
`updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||
PRIMARY KEY (`id`),
|
||
KEY `idx_product_id` (`product_id`),
|
||
KEY `idx_start_time` (`start_time`),
|
||
KEY `idx_end_time` (`end_time`),
|
||
KEY `idx_status` (`status`),
|
||
KEY `idx_created_at` (`created_at`),
|
||
CONSTRAINT `flash_sales_ibfk_1` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE
|
||
) ENGINE = InnoDB
|
||
AUTO_INCREMENT = 13
|
||
DEFAULT CHARSET = utf8mb4
|
||
COLLATE = utf8mb4_unicode_ci COMMENT ='秒杀活动表';
|
||
|
||
-- ----------------------------
|
||
-- Records of flash_sales
|
||
-- ----------------------------
|
||
BEGIN;
|
||
INSERT INTO `flash_sales` (`id`, `product_id`, `flash_price`, `flash_stock`, `start_time`, `end_time`, `status`,
|
||
`created_at`, `updated_at`)
|
||
VALUES (10, 4, 0.01, 10, '2026-03-14 15:55:00', '2026-08-02 15:55:00', 2, '2026-03-14 15:50:34', '2026-03-14 09:55:25');
|
||
INSERT INTO `flash_sales` (`id`, `product_id`, `flash_price`, `flash_stock`, `start_time`, `end_time`, `status`,
|
||
`created_at`, `updated_at`)
|
||
VALUES (11, 1, 0.01, 9, '2026-03-14 17:12:00', '2027-03-19 17:12:00', 2, '2026-03-14 17:07:14', '2026-03-14 09:47:30');
|
||
INSERT INTO `flash_sales` (`id`, `product_id`, `flash_price`, `flash_stock`, `start_time`, `end_time`, `status`,
|
||
`created_at`, `updated_at`)
|
||
VALUES (12, 2, 0.01, 1, '2026-03-14 20:48:00', '2027-03-13 20:48:00', 1, '2026-03-14 20:43:59', '2026-03-14 12:43:59');
|
||
COMMIT;
|
||
|
||
-- ----------------------------
|
||
-- Table structure for group_buying
|
||
-- ----------------------------
|
||
DROP TABLE IF EXISTS `group_buying`;
|
||
CREATE TABLE `group_buying`
|
||
(
|
||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||
`created_at` datetime(6) NOT NULL,
|
||
`duration_minutes` int NOT NULL,
|
||
`end_time` datetime(6) NOT NULL,
|
||
`group_price` decimal(10, 2) NOT NULL,
|
||
`max_per_user` int NOT NULL,
|
||
`product_id` bigint NOT NULL,
|
||
`remaining_stock` int NOT NULL,
|
||
`required_members` int NOT NULL,
|
||
`start_time` datetime(6) NOT NULL,
|
||
`status` int NOT NULL,
|
||
`total_stock` int NOT NULL,
|
||
`updated_at` datetime(6) DEFAULT NULL,
|
||
PRIMARY KEY (`id`),
|
||
KEY `FK59r61d7iyp2vxxkoyjudk343o` (`product_id`),
|
||
CONSTRAINT `FK59r61d7iyp2vxxkoyjudk343o` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`)
|
||
) ENGINE = InnoDB
|
||
AUTO_INCREMENT = 4
|
||
DEFAULT CHARSET = utf8mb4
|
||
COLLATE = utf8mb4_0900_ai_ci;
|
||
|
||
-- ----------------------------
|
||
-- Records of group_buying
|
||
-- ----------------------------
|
||
BEGIN;
|
||
INSERT INTO `group_buying` (`id`, `created_at`, `duration_minutes`, `end_time`, `group_price`, `max_per_user`,
|
||
`product_id`, `remaining_stock`, `required_members`, `start_time`, `status`, `total_stock`,
|
||
`updated_at`)
|
||
VALUES (1, '2026-03-13 23:32:29.162000', 1440, '2026-07-05 00:00:00.000000', 0.01, 1, 1, 98, 2,
|
||
'2026-03-13 23:32:21.000000', 2, 100, '2026-03-13 23:32:32.081000');
|
||
INSERT INTO `group_buying` (`id`, `created_at`, `duration_minutes`, `end_time`, `group_price`, `max_per_user`,
|
||
`product_id`, `remaining_stock`, `required_members`, `start_time`, `status`, `total_stock`,
|
||
`updated_at`)
|
||
VALUES (2, '2026-03-14 15:49:21.162000', 1440, '2026-03-29 15:54:00.000000', 0.01, 1, 5, 95, 2,
|
||
'2026-03-14 15:54:00.000000', 2, 100, '2026-03-14 15:49:25.451000');
|
||
INSERT INTO `group_buying` (`id`, `created_at`, `duration_minutes`, `end_time`, `group_price`, `max_per_user`,
|
||
`product_id`, `remaining_stock`, `required_members`, `start_time`, `status`, `total_stock`,
|
||
`updated_at`)
|
||
VALUES (3, '2026-03-16 23:57:24.818000', 1440, '2026-03-18 00:02:00.000000', 0.01, 3, 11, 96, 2,
|
||
'2026-03-16 00:02:00.000000', 2, 100, '2026-03-17 00:17:44.859000');
|
||
COMMIT;
|
||
|
||
-- ----------------------------
|
||
-- Table structure for group_buying_group
|
||
-- ----------------------------
|
||
DROP TABLE IF EXISTS `group_buying_group`;
|
||
CREATE TABLE `group_buying_group`
|
||
(
|
||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||
`completed_at` datetime(6) DEFAULT NULL,
|
||
`created_at` datetime(6) NOT NULL,
|
||
`current_members` int NOT NULL,
|
||
`expire_time` datetime(6) NOT NULL,
|
||
`group_buying_id` bigint NOT NULL,
|
||
`group_no` varchar(64) NOT NULL,
|
||
`leader_user_id` bigint NOT NULL,
|
||
`required_members` int NOT NULL,
|
||
`status` int NOT NULL,
|
||
PRIMARY KEY (`id`),
|
||
UNIQUE KEY `UK_9khnmu1trewcuahx5k2m0am51` (`group_no`),
|
||
KEY `FKqa4p2gmyfgv73i1278fncxyjd` (`group_buying_id`),
|
||
KEY `FKmc231ojxg44fsobry8h71p7ts` (`leader_user_id`),
|
||
CONSTRAINT `FKmc231ojxg44fsobry8h71p7ts` FOREIGN KEY (`leader_user_id`) REFERENCES `users` (`id`),
|
||
CONSTRAINT `FKqa4p2gmyfgv73i1278fncxyjd` FOREIGN KEY (`group_buying_id`) REFERENCES `group_buying` (`id`)
|
||
) ENGINE = InnoDB
|
||
AUTO_INCREMENT = 8
|
||
DEFAULT CHARSET = utf8mb4
|
||
COLLATE = utf8mb4_0900_ai_ci;
|
||
|
||
-- ----------------------------
|
||
-- Records of group_buying_group
|
||
-- ----------------------------
|
||
BEGIN;
|
||
INSERT INTO `group_buying_group` (`id`, `completed_at`, `created_at`, `current_members`, `expire_time`,
|
||
`group_buying_id`, `group_no`, `leader_user_id`, `required_members`, `status`)
|
||
VALUES (1, '2026-03-16 21:06:50.390000', '2026-03-14 15:49:34.380000', 1, '2026-03-15 15:49:34.379000', 1,
|
||
'GB1773474574379662', 3, 2, 3);
|
||
INSERT INTO `group_buying_group` (`id`, `completed_at`, `created_at`, `current_members`, `expire_time`,
|
||
`group_buying_id`, `group_no`, `leader_user_id`, `required_members`, `status`)
|
||
VALUES (2, '2026-03-16 16:01:20.000000', '2026-03-16 21:09:52.417000', 2, '2026-03-17 21:09:52.413000', 1,
|
||
'GB1773666592413340', 3, 2, 2);
|
||
INSERT INTO `group_buying_group` (`id`, `completed_at`, `created_at`, `current_members`, `expire_time`,
|
||
`group_buying_id`, `group_no`, `leader_user_id`, `required_members`, `status`)
|
||
VALUES (3, '2026-03-16 16:01:20.000000', '2026-03-16 23:36:48.080000', 2, '2026-03-17 23:36:48.076000', 2,
|
||
'GB1773675408076559', 3, 2, 2);
|
||
INSERT INTO `group_buying_group` (`id`, `completed_at`, `created_at`, `current_members`, `expire_time`,
|
||
`group_buying_id`, `group_no`, `leader_user_id`, `required_members`, `status`)
|
||
VALUES (4, '2026-03-16 16:01:20.000000', '2026-03-16 23:44:34.651000', 2, '2026-03-17 23:44:34.647000', 2,
|
||
'GB1773675874647308', 3, 2, 2);
|
||
INSERT INTO `group_buying_group` (`id`, `completed_at`, `created_at`, `current_members`, `expire_time`,
|
||
`group_buying_id`, `group_no`, `leader_user_id`, `required_members`, `status`)
|
||
VALUES (5, NULL, '2026-03-16 23:47:02.225000', 1, '2026-03-17 23:47:02.224000', 2, 'GB1773676022224046', 15, 2, 1);
|
||
INSERT INTO `group_buying_group` (`id`, `completed_at`, `created_at`, `current_members`, `expire_time`,
|
||
`group_buying_id`, `group_no`, `leader_user_id`, `required_members`, `status`)
|
||
VALUES (6, NULL, '2026-03-17 00:06:39.985000', 2, '2026-03-18 00:06:39.983000', 3, 'GB1773677199982359', 3, 2, 1);
|
||
INSERT INTO `group_buying_group` (`id`, `completed_at`, `created_at`, `current_members`, `expire_time`,
|
||
`group_buying_id`, `group_no`, `leader_user_id`, `required_members`, `status`)
|
||
VALUES (7, '2026-03-17 00:18:19.615000', '2026-03-17 00:17:54.946000', 2, '2026-03-18 00:17:54.941000', 3,
|
||
'GB1773677874941488', 3, 2, 2);
|
||
COMMIT;
|
||
|
||
-- ----------------------------
|
||
-- Table structure for group_buying_member
|
||
-- ----------------------------
|
||
DROP TABLE IF EXISTS `group_buying_member`;
|
||
CREATE TABLE `group_buying_member`
|
||
(
|
||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||
`group_id` bigint NOT NULL,
|
||
`joined_at` datetime(6) NOT NULL,
|
||
`order_id` bigint DEFAULT NULL,
|
||
`status` int NOT NULL,
|
||
`user_id` bigint NOT NULL,
|
||
PRIMARY KEY (`id`),
|
||
UNIQUE KEY `uk_group_user` (`group_id`, `user_id`),
|
||
KEY `FK2k1d07r2qich4sqquxisdkf7e` (`user_id`),
|
||
CONSTRAINT `FK2k1d07r2qich4sqquxisdkf7e` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`),
|
||
CONSTRAINT `FKplwuuxax228wqw6nr6pnmmllq` FOREIGN KEY (`group_id`) REFERENCES `group_buying_group` (`id`)
|
||
) ENGINE = InnoDB
|
||
AUTO_INCREMENT = 13
|
||
DEFAULT CHARSET = utf8mb4
|
||
COLLATE = utf8mb4_0900_ai_ci;
|
||
|
||
-- ----------------------------
|
||
-- Records of group_buying_member
|
||
-- ----------------------------
|
||
BEGIN;
|
||
INSERT INTO `group_buying_member` (`id`, `group_id`, `joined_at`, `order_id`, `status`, `user_id`)
|
||
VALUES (1, 1, '2026-03-14 15:49:34.432000', 21, 3, 3);
|
||
INSERT INTO `group_buying_member` (`id`, `group_id`, `joined_at`, `order_id`, `status`, `user_id`)
|
||
VALUES (2, 2, '2026-03-16 21:09:52.464000', 23, 2, 3);
|
||
INSERT INTO `group_buying_member` (`id`, `group_id`, `joined_at`, `order_id`, `status`, `user_id`)
|
||
VALUES (3, 2, '2026-03-16 23:09:11.629000', 25, 2, 15);
|
||
INSERT INTO `group_buying_member` (`id`, `group_id`, `joined_at`, `order_id`, `status`, `user_id`)
|
||
VALUES (4, 3, '2026-03-16 23:36:48.130000', 26, 2, 3);
|
||
INSERT INTO `group_buying_member` (`id`, `group_id`, `joined_at`, `order_id`, `status`, `user_id`)
|
||
VALUES (5, 3, '2026-03-16 23:37:04.179000', 27, 2, 15);
|
||
INSERT INTO `group_buying_member` (`id`, `group_id`, `joined_at`, `order_id`, `status`, `user_id`)
|
||
VALUES (6, 4, '2026-03-16 23:44:34.711000', 28, 2, 3);
|
||
INSERT INTO `group_buying_member` (`id`, `group_id`, `joined_at`, `order_id`, `status`, `user_id`)
|
||
VALUES (7, 4, '2026-03-16 23:45:05.179000', 29, 2, 15);
|
||
INSERT INTO `group_buying_member` (`id`, `group_id`, `joined_at`, `order_id`, `status`, `user_id`)
|
||
VALUES (8, 5, '2026-03-16 23:47:02.250000', 30, 1, 15);
|
||
INSERT INTO `group_buying_member` (`id`, `group_id`, `joined_at`, `order_id`, `status`, `user_id`)
|
||
VALUES (9, 6, '2026-03-17 00:06:40.074000', 31, 1, 3);
|
||
INSERT INTO `group_buying_member` (`id`, `group_id`, `joined_at`, `order_id`, `status`, `user_id`)
|
||
VALUES (10, 6, '2026-03-17 00:06:47.015000', 32, 1, 15);
|
||
INSERT INTO `group_buying_member` (`id`, `group_id`, `joined_at`, `order_id`, `status`, `user_id`)
|
||
VALUES (11, 7, '2026-03-17 00:17:55.040000', 33, 2, 3);
|
||
INSERT INTO `group_buying_member` (`id`, `group_id`, `joined_at`, `order_id`, `status`, `user_id`)
|
||
VALUES (12, 7, '2026-03-17 00:18:19.601000', 34, 2, 15);
|
||
COMMIT;
|
||
|
||
-- ----------------------------
|
||
-- Table structure for notifications
|
||
-- ----------------------------
|
||
DROP TABLE IF EXISTS `notifications`;
|
||
CREATE TABLE `notifications`
|
||
(
|
||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||
`created_at` datetime(6) NOT NULL,
|
||
`link` varchar(255) DEFAULT NULL,
|
||
`message` text NOT NULL,
|
||
`is_read` bit(1) NOT NULL,
|
||
`title` varchar(255) NOT NULL,
|
||
`type` varchar(32) NOT NULL,
|
||
`user_id` bigint NOT NULL,
|
||
PRIMARY KEY (`id`),
|
||
KEY `idx_notification_user_read` (`user_id`, `is_read`),
|
||
KEY `idx_notification_user_created` (`user_id`, `created_at`)
|
||
) ENGINE = InnoDB
|
||
AUTO_INCREMENT = 15
|
||
DEFAULT CHARSET = utf8mb4
|
||
COLLATE = utf8mb4_0900_ai_ci;
|
||
|
||
-- ----------------------------
|
||
-- Records of notifications
|
||
-- ----------------------------
|
||
BEGIN;
|
||
INSERT INTO `notifications` (`id`, `created_at`, `link`, `message`, `is_read`, `title`, `type`, `user_id`)
|
||
VALUES (4, '2026-03-16 23:07:03.974000', '/order/24', '您的订单 #24 已创建,请尽快完成支付', b'0', '订单创建成功',
|
||
'order', 3);
|
||
INSERT INTO `notifications` (`id`, `created_at`, `link`, `message`, `is_read`, `title`, `type`, `user_id`)
|
||
VALUES (5, '2026-03-16 23:07:12.309000', '/order/24', '您的订单 #24 已支付成功,等待商家发货', b'0', '订单支付成功',
|
||
'order', 3);
|
||
INSERT INTO `notifications` (`id`, `created_at`, `link`, `message`, `is_read`, `title`, `type`, `user_id`)
|
||
VALUES (6, '2026-03-16 23:09:32.499000', '/order/25', '您的订单 #25 已支付成功,等待商家发货', b'0', '订单支付成功',
|
||
'order', 15);
|
||
INSERT INTO `notifications` (`id`, `created_at`, `link`, `message`, `is_read`, `title`, `type`, `user_id`)
|
||
VALUES (7, '2026-03-16 23:10:35.244000', '/order/23', '您的订单 #23 退货申请已提交,请等待审核', b'0', '退货申请已提交',
|
||
'return', 3);
|
||
INSERT INTO `notifications` (`id`, `created_at`, `link`, `message`, `is_read`, `title`, `type`, `user_id`)
|
||
VALUES (8, '2026-03-16 23:11:26.084000', '/order/23', '您的订单 #23 退货申请已通过,请尽快寄回商品', b'0',
|
||
'退货申请已通过', 'return', 3);
|
||
INSERT INTO `notifications` (`id`, `created_at`, `link`, `message`, `is_read`, `title`, `type`, `user_id`)
|
||
VALUES (9, '2026-03-16 23:37:56.413000', '/order/26', '您的订单 #26 已支付成功,等待商家发货', b'0', '订单支付成功',
|
||
'order', 3);
|
||
INSERT INTO `notifications` (`id`, `created_at`, `link`, `message`, `is_read`, `title`, `type`, `user_id`)
|
||
VALUES (10, '2026-03-16 23:38:20.405000', '/order/27', '您的订单 #27 已支付成功,等待商家发货', b'0', '订单支付成功',
|
||
'order', 15);
|
||
INSERT INTO `notifications` (`id`, `created_at`, `link`, `message`, `is_read`, `title`, `type`, `user_id`)
|
||
VALUES (11, '2026-03-16 23:46:54.529000', '/order/29', '您的订单 #29 已支付成功,等待商家发货', b'0', '订单支付成功',
|
||
'order', 15);
|
||
INSERT INTO `notifications` (`id`, `created_at`, `link`, `message`, `is_read`, `title`, `type`, `user_id`)
|
||
VALUES (12, '2026-03-16 23:47:12.529000', '/order/30', '您的订单 #30 已支付成功,等待商家发货', b'0', '订单支付成功',
|
||
'order', 15);
|
||
INSERT INTO `notifications` (`id`, `created_at`, `link`, `message`, `is_read`, `title`, `type`, `user_id`)
|
||
VALUES (13, '2026-03-17 00:09:01.296000', '/order/32', '您的订单 #32 已支付成功,等待商家发货', b'0', '订单支付成功',
|
||
'order', 15);
|
||
INSERT INTO `notifications` (`id`, `created_at`, `link`, `message`, `is_read`, `title`, `type`, `user_id`)
|
||
VALUES (14, '2026-03-17 00:09:21.874000', '/order/31', '您的订单 #31 已支付成功,等待商家发货', b'0', '订单支付成功',
|
||
'order', 3);
|
||
COMMIT;
|
||
|
||
-- ----------------------------
|
||
-- Table structure for order_items
|
||
-- ----------------------------
|
||
DROP TABLE IF EXISTS `order_items`;
|
||
CREATE TABLE `order_items`
|
||
(
|
||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||
`created_at` datetime(6) NOT NULL,
|
||
`order_id` bigint NOT NULL,
|
||
`price` decimal(10, 2) NOT NULL,
|
||
`product_id` bigint NOT NULL,
|
||
`product_image_url` varchar(500) DEFAULT NULL,
|
||
`product_name` varchar(200) NOT NULL,
|
||
`quantity` int NOT NULL,
|
||
`subtotal` decimal(10, 2) NOT NULL,
|
||
PRIMARY KEY (`id`)
|
||
) ENGINE = InnoDB
|
||
AUTO_INCREMENT = 14
|
||
DEFAULT CHARSET = utf8mb4
|
||
COLLATE = utf8mb4_0900_ai_ci;
|
||
|
||
-- ----------------------------
|
||
-- Records of order_items
|
||
-- ----------------------------
|
||
BEGIN;
|
||
INSERT INTO `order_items` (`id`, `created_at`, `order_id`, `price`, `product_id`, `product_image_url`, `product_name`,
|
||
`quantity`, `subtotal`)
|
||
VALUES (1, '2026-03-16 23:07:03.951000', 24, 168.00, 14,
|
||
'/uploads/products/2026/03/14/2e380b9213824856b7d00e0d2b54b436.png', '五常大米 10kg', 2, 336.00);
|
||
INSERT INTO `order_items` (`id`, `created_at`, `order_id`, `price`, `product_id`, `product_image_url`, `product_name`,
|
||
`quantity`, `subtotal`)
|
||
VALUES (2, '2026-03-16 23:36:48.126000', 26, 0.01, 5,
|
||
'/uploads/products/2025/07/29/019006fd420548d0b306982931329205.jpg', 'Apple Watch Series 9', 1, 0.01);
|
||
INSERT INTO `order_items` (`id`, `created_at`, `order_id`, `price`, `product_id`, `product_image_url`, `product_name`,
|
||
`quantity`, `subtotal`)
|
||
VALUES (3, '2026-03-16 23:37:04.171000', 27, 0.01, 5,
|
||
'/uploads/products/2025/07/29/019006fd420548d0b306982931329205.jpg', 'Apple Watch Series 9', 1, 0.01);
|
||
INSERT INTO `order_items` (`id`, `created_at`, `order_id`, `price`, `product_id`, `product_image_url`, `product_name`,
|
||
`quantity`, `subtotal`)
|
||
VALUES (4, '2026-03-16 23:44:34.708000', 28, 0.01, 5,
|
||
'/uploads/products/2025/07/29/019006fd420548d0b306982931329205.jpg', 'Apple Watch Series 9', 1, 0.01);
|
||
INSERT INTO `order_items` (`id`, `created_at`, `order_id`, `price`, `product_id`, `product_image_url`, `product_name`,
|
||
`quantity`, `subtotal`)
|
||
VALUES (5, '2026-03-16 23:45:05.177000', 29, 0.01, 5,
|
||
'/uploads/products/2025/07/29/019006fd420548d0b306982931329205.jpg', 'Apple Watch Series 9', 1, 0.01);
|
||
INSERT INTO `order_items` (`id`, `created_at`, `order_id`, `price`, `product_id`, `product_image_url`, `product_name`,
|
||
`quantity`, `subtotal`)
|
||
VALUES (6, '2026-03-16 23:47:02.241000', 30, 0.01, 5,
|
||
'/uploads/products/2025/07/29/019006fd420548d0b306982931329205.jpg', 'Apple Watch Series 9', 1, 0.01);
|
||
INSERT INTO `order_items` (`id`, `created_at`, `order_id`, `price`, `product_id`, `product_image_url`, `product_name`,
|
||
`quantity`, `subtotal`)
|
||
VALUES (7, '2026-03-14 15:49:34.000000', 21, 0.01, 1,
|
||
'/uploads/products/2025/07/29/019006fd420548d0b306982931329205.jpg', 'iPhone 15 Pro Max', 1, 0.01);
|
||
INSERT INTO `order_items` (`id`, `created_at`, `order_id`, `price`, `product_id`, `product_image_url`, `product_name`,
|
||
`quantity`, `subtotal`)
|
||
VALUES (8, '2026-03-16 21:09:52.000000', 23, 0.01, 1,
|
||
'/uploads/products/2025/07/29/019006fd420548d0b306982931329205.jpg', 'iPhone 15 Pro Max', 1, 0.01);
|
||
INSERT INTO `order_items` (`id`, `created_at`, `order_id`, `price`, `product_id`, `product_image_url`, `product_name`,
|
||
`quantity`, `subtotal`)
|
||
VALUES (9, '2026-03-16 23:09:12.000000', 25, 0.01, 1,
|
||
'/uploads/products/2025/07/29/019006fd420548d0b306982931329205.jpg', 'iPhone 15 Pro Max', 1, 0.01);
|
||
INSERT INTO `order_items` (`id`, `created_at`, `order_id`, `price`, `product_id`, `product_image_url`, `product_name`,
|
||
`quantity`, `subtotal`)
|
||
VALUES (10, '2026-03-17 00:06:40.069000', 31, 0.01, 11,
|
||
'/uploads/products/2025/07/29/019006fd420548d0b306982931329205.jpg', '深入理解Java虚拟机', 1, 0.01);
|
||
INSERT INTO `order_items` (`id`, `created_at`, `order_id`, `price`, `product_id`, `product_image_url`, `product_name`,
|
||
`quantity`, `subtotal`)
|
||
VALUES (11, '2026-03-17 00:06:47.011000', 32, 0.01, 11,
|
||
'/uploads/products/2025/07/29/019006fd420548d0b306982931329205.jpg', '深入理解Java虚拟机', 1, 0.01);
|
||
INSERT INTO `order_items` (`id`, `created_at`, `order_id`, `price`, `product_id`, `product_image_url`, `product_name`,
|
||
`quantity`, `subtotal`)
|
||
VALUES (12, '2026-03-17 00:17:55.030000', 33, 0.01, 11,
|
||
'/uploads/products/2025/07/29/019006fd420548d0b306982931329205.jpg', '深入理解Java虚拟机', 1, 0.01);
|
||
INSERT INTO `order_items` (`id`, `created_at`, `order_id`, `price`, `product_id`, `product_image_url`, `product_name`,
|
||
`quantity`, `subtotal`)
|
||
VALUES (13, '2026-03-17 00:18:19.597000', 34, 0.01, 11,
|
||
'/uploads/products/2025/07/29/019006fd420548d0b306982931329205.jpg', '深入理解Java虚拟机', 1, 0.01);
|
||
COMMIT;
|
||
|
||
-- ----------------------------
|
||
-- Table structure for order_returns
|
||
-- ----------------------------
|
||
DROP TABLE IF EXISTS `order_returns`;
|
||
CREATE TABLE `order_returns`
|
||
(
|
||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||
`admin_remark` varchar(500) DEFAULT NULL,
|
||
`cancelled_at` datetime(6) DEFAULT NULL,
|
||
`completed_at` datetime(6) DEFAULT NULL,
|
||
`created_at` datetime(6) NOT NULL,
|
||
`description` text,
|
||
`images` varchar(2000) DEFAULT NULL,
|
||
`order_id` bigint NOT NULL,
|
||
`reason` varchar(500) NOT NULL,
|
||
`refund_amount` decimal(10, 2) NOT NULL,
|
||
`reject_reason` varchar(500) DEFAULT NULL,
|
||
`return_no` varchar(64) NOT NULL,
|
||
`return_tracking` varchar(100) DEFAULT NULL,
|
||
`reviewed_at` datetime(6) DEFAULT NULL,
|
||
`shipped_at` datetime(6) DEFAULT NULL,
|
||
`status` int NOT NULL,
|
||
`updated_at` datetime(6) DEFAULT NULL,
|
||
`user_id` bigint NOT NULL,
|
||
PRIMARY KEY (`id`),
|
||
UNIQUE KEY `UK_elu6c1jupuay4bgn9gffdsbcx` (`return_no`)
|
||
) ENGINE = InnoDB
|
||
AUTO_INCREMENT = 2
|
||
DEFAULT CHARSET = utf8mb4
|
||
COLLATE = utf8mb4_0900_ai_ci;
|
||
|
||
-- ----------------------------
|
||
-- Records of order_returns
|
||
-- ----------------------------
|
||
BEGIN;
|
||
INSERT INTO `order_returns` (`id`, `admin_remark`, `cancelled_at`, `completed_at`, `created_at`, `description`,
|
||
`images`, `order_id`, `reason`, `refund_amount`, `reject_reason`, `return_no`,
|
||
`return_tracking`, `reviewed_at`, `shipped_at`, `status`, `updated_at`, `user_id`)
|
||
VALUES (1, NULL, NULL, NULL, '2026-03-16 23:10:35.208000', '1', NULL, 23, '商品与描述不符', 0.01, NULL,
|
||
'RT1773673835208', NULL, '2026-03-16 23:11:26.080000', NULL, 2, '2026-03-16 23:11:26.096000', 3);
|
||
COMMIT;
|
||
|
||
-- ----------------------------
|
||
-- Table structure for orders
|
||
-- ----------------------------
|
||
DROP TABLE IF EXISTS `orders`;
|
||
CREATE TABLE `orders`
|
||
(
|
||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '订单ID',
|
||
`user_id` bigint NOT NULL COMMENT '用户ID',
|
||
`product_id` bigint NOT NULL COMMENT '商品ID',
|
||
`quantity` int NOT NULL DEFAULT '1' COMMENT '购买数量',
|
||
`total_price` decimal(10, 2) NOT NULL COMMENT '总价',
|
||
`status` tinyint DEFAULT '1' COMMENT '状态:1-待支付,2-已支付,3-已发货,4-已完成,5-已取消',
|
||
`order_type` tinyint DEFAULT '1' COMMENT '订单类型:1-普通订单,2-秒杀订单',
|
||
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||
`updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||
`completed_at` datetime(6) DEFAULT NULL,
|
||
`group_no` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||
`order_no` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||
`paid_at` datetime(6) DEFAULT NULL,
|
||
`payment_method` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||
`receiver_address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||
`receiver_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||
`receiver_phone` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||
`remark` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||
`shipped_at` datetime(6) DEFAULT NULL,
|
||
`flash_sale_id` bigint DEFAULT NULL,
|
||
`group_buying_group_id` bigint DEFAULT NULL,
|
||
PRIMARY KEY (`id`),
|
||
KEY `idx_user_id` (`user_id`),
|
||
KEY `idx_product_id` (`product_id`),
|
||
KEY `idx_status` (`status`),
|
||
KEY `idx_order_type` (`order_type`),
|
||
KEY `idx_created_at` (`created_at`),
|
||
KEY `idx_user_product` (`user_id`, `product_id`),
|
||
CONSTRAINT `orders_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
|
||
CONSTRAINT `orders_ibfk_2` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE
|
||
) ENGINE = InnoDB
|
||
AUTO_INCREMENT = 35
|
||
DEFAULT CHARSET = utf8mb4
|
||
COLLATE = utf8mb4_unicode_ci COMMENT ='订单表';
|
||
|
||
-- ----------------------------
|
||
-- Records of orders
|
||
-- ----------------------------
|
||
BEGIN;
|
||
INSERT INTO `orders` (`id`, `user_id`, `product_id`, `quantity`, `total_price`, `status`, `order_type`, `created_at`,
|
||
`updated_at`, `completed_at`, `group_no`, `order_no`, `paid_at`, `payment_method`,
|
||
`receiver_address`, `receiver_name`, `receiver_phone`, `remark`, `shipped_at`, `flash_sale_id`,
|
||
`group_buying_group_id`)
|
||
VALUES (18, 3, 1, 1, 7999.00, 3, 2, '2025-07-04 22:02:40', '2026-03-14 16:24:42', NULL, NULL, '', NULL, NULL, NULL,
|
||
NULL, NULL, '商家发货', '2026-03-14 16:24:42.039000', NULL, NULL);
|
||
INSERT INTO `orders` (`id`, `user_id`, `product_id`, `quantity`, `total_price`, `status`, `order_type`, `created_at`,
|
||
`updated_at`, `completed_at`, `group_no`, `order_no`, `paid_at`, `payment_method`,
|
||
`receiver_address`, `receiver_name`, `receiver_phone`, `remark`, `shipped_at`, `flash_sale_id`,
|
||
`group_buying_group_id`)
|
||
VALUES (19, 3, 14, 1, 168.00, 4, 1, '2025-07-04 22:03:38', '2026-03-16 23:10:49', '2026-03-16 23:10:49.075000', NULL,
|
||
'', NULL, NULL, NULL, NULL, NULL, '用户确认收货', '2026-03-14 16:24:50.513000', NULL, NULL);
|
||
INSERT INTO `orders` (`id`, `user_id`, `product_id`, `quantity`, `total_price`, `status`, `order_type`, `created_at`,
|
||
`updated_at`, `completed_at`, `group_no`, `order_no`, `paid_at`, `payment_method`,
|
||
`receiver_address`, `receiver_name`, `receiver_phone`, `remark`, `shipped_at`, `flash_sale_id`,
|
||
`group_buying_group_id`)
|
||
VALUES (20, 3, 14, 2, 336.00, 4, 1, '2025-07-30 09:07:22', '2026-03-16 23:10:45', '2026-03-16 23:10:45.025000', NULL,
|
||
'', '2026-03-13 23:33:50.367000', 'ONLINE', NULL, NULL, NULL, '用户确认收货', '2026-03-14 16:24:48.353000',
|
||
NULL, NULL);
|
||
INSERT INTO `orders` (`id`, `user_id`, `product_id`, `quantity`, `total_price`, `status`, `order_type`, `created_at`,
|
||
`updated_at`, `completed_at`, `group_no`, `order_no`, `paid_at`, `payment_method`,
|
||
`receiver_address`, `receiver_name`, `receiver_phone`, `remark`, `shipped_at`, `flash_sale_id`,
|
||
`group_buying_group_id`)
|
||
VALUES (21, 3, 1, 1, 0.01, 4, 3, '2026-03-14 15:49:34', '2026-03-14 16:25:00', '2026-03-14 16:25:00.018000', NULL,
|
||
'GB1773474574422850', '2026-03-14 15:54:07.163000', 'ONLINE', NULL, NULL, NULL, '用户确认收货',
|
||
'2026-03-14 16:24:37.672000', NULL, 1);
|
||
INSERT INTO `orders` (`id`, `user_id`, `product_id`, `quantity`, `total_price`, `status`, `order_type`, `created_at`,
|
||
`updated_at`, `completed_at`, `group_no`, `order_no`, `paid_at`, `payment_method`,
|
||
`receiver_address`, `receiver_name`, `receiver_phone`, `remark`, `shipped_at`, `flash_sale_id`,
|
||
`group_buying_group_id`)
|
||
VALUES (22, 3, 1, 1, 0.01, 4, 2, '2026-03-14 17:47:30', '2026-03-16 23:10:40', '2026-03-16 23:10:39.916000', NULL,
|
||
'FS1773481650367298', '2026-03-14 17:47:37.837000', 'ONLINE', NULL, NULL, NULL, '用户确认收货',
|
||
'2026-03-16 23:07:25.085000', 11, NULL);
|
||
INSERT INTO `orders` (`id`, `user_id`, `product_id`, `quantity`, `total_price`, `status`, `order_type`, `created_at`,
|
||
`updated_at`, `completed_at`, `group_no`, `order_no`, `paid_at`, `payment_method`,
|
||
`receiver_address`, `receiver_name`, `receiver_phone`, `remark`, `shipped_at`, `flash_sale_id`,
|
||
`group_buying_group_id`)
|
||
VALUES (23, 3, 1, 1, 0.01, 6, 3, '2026-03-16 21:09:52', '2026-03-16 23:10:35', '2026-03-16 23:06:38.357000', NULL,
|
||
'GB1773666592456790', '2026-03-16 21:12:56.248000', 'ONLINE', NULL, NULL, NULL, '用户申请退货',
|
||
'2026-03-16 21:26:18.999000', NULL, 2);
|
||
INSERT INTO `orders` (`id`, `user_id`, `product_id`, `quantity`, `total_price`, `status`, `order_type`, `created_at`,
|
||
`updated_at`, `completed_at`, `group_no`, `order_no`, `paid_at`, `payment_method`,
|
||
`receiver_address`, `receiver_name`, `receiver_phone`, `remark`, `shipped_at`, `flash_sale_id`,
|
||
`group_buying_group_id`)
|
||
VALUES (24, 3, 14, 2, 336.00, 4, 1, '2026-03-16 23:07:04', '2026-03-16 23:10:17', '2026-03-16 23:10:17.251000', NULL,
|
||
'FS1773673623934239', '2026-03-16 23:07:12.285000', 'ONLINE', NULL, NULL, NULL, '用户确认收货',
|
||
'2026-03-16 23:07:22.791000', NULL, NULL);
|
||
INSERT INTO `orders` (`id`, `user_id`, `product_id`, `quantity`, `total_price`, `status`, `order_type`, `created_at`,
|
||
`updated_at`, `completed_at`, `group_no`, `order_no`, `paid_at`, `payment_method`,
|
||
`receiver_address`, `receiver_name`, `receiver_phone`, `remark`, `shipped_at`, `flash_sale_id`,
|
||
`group_buying_group_id`)
|
||
VALUES (25, 15, 1, 1, 0.01, 4, 3, '2026-03-16 23:09:12', '2026-03-16 23:14:48', '2026-03-16 23:14:48.467000', NULL,
|
||
'GB1773673751625355', '2026-03-16 23:09:32.485000', 'ONLINE', NULL, NULL, NULL, '用户确认收货',
|
||
'2026-03-16 23:11:18.685000', NULL, 2);
|
||
INSERT INTO `orders` (`id`, `user_id`, `product_id`, `quantity`, `total_price`, `status`, `order_type`, `created_at`,
|
||
`updated_at`, `completed_at`, `group_no`, `order_no`, `paid_at`, `payment_method`,
|
||
`receiver_address`, `receiver_name`, `receiver_phone`, `remark`, `shipped_at`, `flash_sale_id`,
|
||
`group_buying_group_id`)
|
||
VALUES (26, 3, 5, 1, 0.01, 2, 3, '2026-03-16 23:36:48', '2026-03-16 23:37:56', NULL, NULL, 'GB1773675408118011',
|
||
'2026-03-16 23:37:56.394000', 'ONLINE', NULL, NULL, NULL, '模拟支付成功 - ONLINE', NULL, NULL, 3);
|
||
INSERT INTO `orders` (`id`, `user_id`, `product_id`, `quantity`, `total_price`, `status`, `order_type`, `created_at`,
|
||
`updated_at`, `completed_at`, `group_no`, `order_no`, `paid_at`, `payment_method`,
|
||
`receiver_address`, `receiver_name`, `receiver_phone`, `remark`, `shipped_at`, `flash_sale_id`,
|
||
`group_buying_group_id`)
|
||
VALUES (27, 15, 5, 1, 0.01, 2, 3, '2026-03-16 23:37:04', '2026-03-16 23:38:20', NULL, NULL, 'GB1773675424159373',
|
||
'2026-03-16 23:38:20.390000', 'ONLINE', NULL, NULL, NULL, '模拟支付成功 - ONLINE', NULL, NULL, 3);
|
||
INSERT INTO `orders` (`id`, `user_id`, `product_id`, `quantity`, `total_price`, `status`, `order_type`, `created_at`,
|
||
`updated_at`, `completed_at`, `group_no`, `order_no`, `paid_at`, `payment_method`,
|
||
`receiver_address`, `receiver_name`, `receiver_phone`, `remark`, `shipped_at`, `flash_sale_id`,
|
||
`group_buying_group_id`)
|
||
VALUES (28, 3, 5, 1, 0.01, 1, 3, '2026-03-16 23:44:35', '2026-03-16 23:44:35', NULL, NULL, 'GB1773675874699140', NULL,
|
||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, 4);
|
||
INSERT INTO `orders` (`id`, `user_id`, `product_id`, `quantity`, `total_price`, `status`, `order_type`, `created_at`,
|
||
`updated_at`, `completed_at`, `group_no`, `order_no`, `paid_at`, `payment_method`,
|
||
`receiver_address`, `receiver_name`, `receiver_phone`, `remark`, `shipped_at`, `flash_sale_id`,
|
||
`group_buying_group_id`)
|
||
VALUES (29, 15, 5, 1, 0.01, 2, 3, '2026-03-16 23:45:05', '2026-03-16 23:46:55', NULL, NULL, 'GB1773675905174079',
|
||
'2026-03-16 23:46:54.506000', 'ONLINE', NULL, NULL, NULL, '模拟支付成功 - ONLINE', NULL, NULL, 4);
|
||
INSERT INTO `orders` (`id`, `user_id`, `product_id`, `quantity`, `total_price`, `status`, `order_type`, `created_at`,
|
||
`updated_at`, `completed_at`, `group_no`, `order_no`, `paid_at`, `payment_method`,
|
||
`receiver_address`, `receiver_name`, `receiver_phone`, `remark`, `shipped_at`, `flash_sale_id`,
|
||
`group_buying_group_id`)
|
||
VALUES (30, 15, 5, 1, 0.01, 2, 3, '2026-03-16 23:47:02', '2026-03-16 23:47:13', NULL, NULL, 'GB1773676022236796',
|
||
'2026-03-16 23:47:12.518000', 'ONLINE', NULL, NULL, NULL, '模拟支付成功 - ONLINE', NULL, NULL, 5);
|
||
INSERT INTO `orders` (`id`, `user_id`, `product_id`, `quantity`, `total_price`, `status`, `order_type`, `created_at`,
|
||
`updated_at`, `completed_at`, `group_no`, `order_no`, `paid_at`, `payment_method`,
|
||
`receiver_address`, `receiver_name`, `receiver_phone`, `remark`, `shipped_at`, `flash_sale_id`,
|
||
`group_buying_group_id`)
|
||
VALUES (31, 3, 11, 1, 0.01, 2, 3, '2026-03-17 00:06:40', '2026-03-17 00:09:22', NULL, NULL, 'GB1773677200059352',
|
||
'2026-03-17 00:09:21.854000', 'ONLINE', NULL, NULL, NULL, '模拟支付成功 - ONLINE', NULL, NULL, 6);
|
||
INSERT INTO `orders` (`id`, `user_id`, `product_id`, `quantity`, `total_price`, `status`, `order_type`, `created_at`,
|
||
`updated_at`, `completed_at`, `group_no`, `order_no`, `paid_at`, `payment_method`,
|
||
`receiver_address`, `receiver_name`, `receiver_phone`, `remark`, `shipped_at`, `flash_sale_id`,
|
||
`group_buying_group_id`)
|
||
VALUES (32, 15, 11, 1, 0.01, 2, 3, '2026-03-17 00:06:47', '2026-03-17 00:09:01', NULL, NULL, 'GB1773677207007351',
|
||
'2026-03-17 00:09:01.270000', 'ONLINE', NULL, NULL, NULL, '模拟支付成功 - ONLINE', NULL, NULL, 6);
|
||
INSERT INTO `orders` (`id`, `user_id`, `product_id`, `quantity`, `total_price`, `status`, `order_type`, `created_at`,
|
||
`updated_at`, `completed_at`, `group_no`, `order_no`, `paid_at`, `payment_method`,
|
||
`receiver_address`, `receiver_name`, `receiver_phone`, `remark`, `shipped_at`, `flash_sale_id`,
|
||
`group_buying_group_id`)
|
||
VALUES (33, 3, 11, 1, 0.01, 1, 3, '2026-03-17 00:17:55', '2026-03-17 00:17:55', NULL, NULL, 'GB1773677875020045', NULL,
|
||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, 7);
|
||
INSERT INTO `orders` (`id`, `user_id`, `product_id`, `quantity`, `total_price`, `status`, `order_type`, `created_at`,
|
||
`updated_at`, `completed_at`, `group_no`, `order_no`, `paid_at`, `payment_method`,
|
||
`receiver_address`, `receiver_name`, `receiver_phone`, `remark`, `shipped_at`, `flash_sale_id`,
|
||
`group_buying_group_id`)
|
||
VALUES (34, 15, 11, 1, 0.01, 1, 3, '2026-03-17 00:18:20', '2026-03-17 00:18:20', NULL, NULL, 'GB1773677899592443', NULL,
|
||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, 7);
|
||
COMMIT;
|
||
|
||
-- ----------------------------
|
||
-- Table structure for product_reviews
|
||
-- ----------------------------
|
||
DROP TABLE IF EXISTS `product_reviews`;
|
||
CREATE TABLE `product_reviews`
|
||
(
|
||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||
`admin_reply` text,
|
||
`content` text NOT NULL,
|
||
`created_at` datetime(6) NOT NULL,
|
||
`order_id` bigint NOT NULL,
|
||
`product_id` bigint NOT NULL,
|
||
`rating` int NOT NULL,
|
||
`replied_at` datetime(6) DEFAULT NULL,
|
||
`status` int NOT NULL,
|
||
`updated_at` datetime(6) DEFAULT NULL,
|
||
`user_id` bigint NOT NULL,
|
||
PRIMARY KEY (`id`),
|
||
UNIQUE KEY `uk_review_order_user_product` (`order_id`, `user_id`, `product_id`)
|
||
) ENGINE = InnoDB
|
||
AUTO_INCREMENT = 2
|
||
DEFAULT CHARSET = utf8mb4
|
||
COLLATE = utf8mb4_0900_ai_ci;
|
||
|
||
-- ----------------------------
|
||
-- Records of product_reviews
|
||
-- ----------------------------
|
||
BEGIN;
|
||
INSERT INTO `product_reviews` (`id`, `admin_reply`, `content`, `created_at`, `order_id`, `product_id`, `rating`,
|
||
`replied_at`, `status`, `updated_at`, `user_id`)
|
||
VALUES (1, NULL, '13245', '2026-03-14 16:25:09.918000', 21, 1, 5, NULL, 1, '2026-03-16 21:26:27.855000', 3);
|
||
COMMIT;
|
||
|
||
-- ----------------------------
|
||
-- Table structure for products
|
||
-- ----------------------------
|
||
DROP TABLE IF EXISTS `products`;
|
||
CREATE TABLE `products`
|
||
(
|
||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '商品ID',
|
||
`name` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商品名称',
|
||
`description` text COLLATE utf8mb4_unicode_ci COMMENT '商品描述',
|
||
`price` decimal(10, 2) NOT NULL COMMENT '商品价格',
|
||
`stock` int NOT NULL DEFAULT '0' COMMENT '库存数量',
|
||
`image_url` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '商品图片URL',
|
||
`status` tinyint DEFAULT '1' COMMENT '状态:1-上架,0-下架',
|
||
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||
`updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||
`category` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||
PRIMARY KEY (`id`),
|
||
KEY `idx_name` (`name`),
|
||
KEY `idx_price` (`price`),
|
||
KEY `idx_stock` (`stock`),
|
||
KEY `idx_status` (`status`),
|
||
KEY `idx_created_at` (`created_at`)
|
||
) ENGINE = InnoDB
|
||
AUTO_INCREMENT = 18
|
||
DEFAULT CHARSET = utf8mb4
|
||
COLLATE = utf8mb4_unicode_ci COMMENT ='商品表';
|
||
|
||
-- ----------------------------
|
||
-- Records of products
|
||
-- ----------------------------
|
||
BEGIN;
|
||
INSERT INTO `products` (`id`, `name`, `description`, `price`, `stock`, `image_url`, `status`, `created_at`,
|
||
`updated_at`, `category`)
|
||
VALUES (1, 'iPhone 15 Pro Max', '苹果最新旗舰手机,A17 Pro芯片,钛金属设计', 9999.00, 100,
|
||
'/uploads/products/2025/07/29/019006fd420548d0b306982931329205.jpg', 1, '2026-03-14 17:51:14',
|
||
'2026-03-14 17:51:14', NULL);
|
||
INSERT INTO `products` (`id`, `name`, `description`, `price`, `stock`, `image_url`, `status`, `created_at`,
|
||
`updated_at`, `category`)
|
||
VALUES (2, 'MacBook Pro 16英寸', 'M3 Max芯片,36GB内存,1TB存储', 25999.00, 50,
|
||
'/uploads/products/2026/03/14/4943b3f7cd1048a6ba008a5f163d9cd7.webp', 1, '2026-03-14 17:51:14',
|
||
'2026-03-14 17:51:14', '默认分类');
|
||
INSERT INTO `products` (`id`, `name`, `description`, `price`, `stock`, `image_url`, `status`, `created_at`,
|
||
`updated_at`, `category`)
|
||
VALUES (3, 'iPad Air', '10.9英寸液晶显示屏,M1芯片', 4399.00, 80,
|
||
'/uploads/products/2025/07/29/019006fd420548d0b306982931329205.jpg', 1, '2026-03-14 17:51:14',
|
||
'2026-03-14 17:51:14', NULL);
|
||
INSERT INTO `products` (`id`, `name`, `description`, `price`, `stock`, `image_url`, `status`, `created_at`,
|
||
`updated_at`, `category`)
|
||
VALUES (4, 'AirPods Pro 2', '主动降噪无线耳机,空间音频', 1899.00, 200,
|
||
'/uploads/products/2025/07/29/019006fd420548d0b306982931329205.jpg', 1, '2026-03-14 17:51:14',
|
||
'2026-03-14 17:51:14', NULL);
|
||
INSERT INTO `products` (`id`, `name`, `description`, `price`, `stock`, `image_url`, `status`, `created_at`,
|
||
`updated_at`, `category`)
|
||
VALUES (5, 'Apple Watch Series 9', '健康监测,GPS+蜂窝网络', 3199.00, 150,
|
||
'/uploads/products/2025/07/29/019006fd420548d0b306982931329205.jpg', 1, '2026-03-14 17:51:14',
|
||
'2026-03-14 17:51:14', NULL);
|
||
INSERT INTO `products` (`id`, `name`, `description`, `price`, `stock`, `image_url`, `status`, `created_at`,
|
||
`updated_at`, `category`)
|
||
VALUES (6, '小米电视 65英寸', '4K超高清,120Hz刷新率', 2999.00, 60,
|
||
'/uploads/products/2025/07/29/019006fd420548d0b306982931329205.jpg', 1, '2026-03-14 17:51:14',
|
||
'2026-03-14 17:51:14', NULL);
|
||
INSERT INTO `products` (`id`, `name`, `description`, `price`, `stock`, `image_url`, `status`, `created_at`,
|
||
`updated_at`, `category`)
|
||
VALUES (7, '戴森吸尘器 V15', '激光显微尘,强劲吸力', 4690.00, 40,
|
||
'/uploads/products/2025/07/29/019006fd420548d0b306982931329205.jpg', 1, '2026-03-14 17:51:14',
|
||
'2026-03-14 17:51:14', NULL);
|
||
INSERT INTO `products` (`id`, `name`, `description`, `price`, `stock`, `image_url`, `status`, `created_at`,
|
||
`updated_at`, `category`)
|
||
VALUES (8, '美的空调 1.5匹', '变频节能,静音运行', 2599.00, 80,
|
||
'/uploads/products/2025/07/29/019006fd420548d0b306982931329205.jpg', 1, '2026-03-14 17:51:14',
|
||
'2026-03-14 17:51:14', NULL);
|
||
INSERT INTO `products` (`id`, `name`, `description`, `price`, `stock`, `image_url`, `status`, `created_at`,
|
||
`updated_at`, `category`)
|
||
VALUES (9, 'Nike Air Jordan 1', '经典篮球鞋,限量版配色1', 1299.00, 119,
|
||
'/uploads/products/2025/07/29/019006fd420548d0b306982931329205.jpg', 1, '2026-03-14 17:51:14',
|
||
'2026-03-14 17:51:14', NULL);
|
||
INSERT INTO `products` (`id`, `name`, `description`, `price`, `stock`, `image_url`, `status`, `created_at`,
|
||
`updated_at`, `category`)
|
||
VALUES (10, 'Adidas Ultra Boost', '缓震跑鞋,Boost中底', 1599.00, 100,
|
||
'/uploads/products/2025/07/29/019006fd420548d0b306982931329205.jpg', 1, '2026-03-14 17:51:14',
|
||
'2026-03-14 17:51:14', NULL);
|
||
INSERT INTO `products` (`id`, `name`, `description`, `price`, `stock`, `image_url`, `status`, `created_at`,
|
||
`updated_at`, `category`)
|
||
VALUES (11, '深入理解Java虚拟机', 'JVM原理与实践,第3版', 89.00, 500,
|
||
'/uploads/products/2025/07/29/019006fd420548d0b306982931329205.jpg', 1, '2026-03-14 17:51:14',
|
||
'2026-03-14 17:51:14', NULL);
|
||
INSERT INTO `products` (`id`, `name`, `description`, `price`, `stock`, `image_url`, `status`, `created_at`,
|
||
`updated_at`, `category`)
|
||
VALUES (14, '五常大米 10kg', '东北优质大米,香甜可口1111', 168.00, 192,
|
||
'/uploads/products/2026/03/14/2e380b9213824856b7d00e0d2b54b436.png', 1, '2026-03-14 17:51:14',
|
||
'2026-03-16 15:07:03', '默认分类');
|
||
INSERT INTO `products` (`id`, `name`, `description`, `price`, `stock`, `image_url`, `status`, `created_at`,
|
||
`updated_at`, `category`)
|
||
VALUES (17, '123', '', 0.01, 10, '', 1, '2026-03-14 17:51:14', '2026-03-14 17:51:14', '123');
|
||
COMMIT;
|
||
|
||
-- ----------------------------
|
||
-- Table structure for user_addresses
|
||
-- ----------------------------
|
||
DROP TABLE IF EXISTS `user_addresses`;
|
||
CREATE TABLE `user_addresses`
|
||
(
|
||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||
`address` varchar(255) NOT NULL,
|
||
`city` varchar(50) DEFAULT NULL,
|
||
`created_at` datetime(6) NOT NULL,
|
||
`district` varchar(50) DEFAULT NULL,
|
||
`is_default` bit(1) NOT NULL,
|
||
`name` varchar(100) NOT NULL,
|
||
`phone` varchar(20) NOT NULL,
|
||
`province` varchar(50) DEFAULT NULL,
|
||
`updated_at` datetime(6) DEFAULT NULL,
|
||
`user_id` bigint NOT NULL,
|
||
PRIMARY KEY (`id`)
|
||
) ENGINE = InnoDB
|
||
DEFAULT CHARSET = utf8mb4
|
||
COLLATE = utf8mb4_0900_ai_ci;
|
||
|
||
-- ----------------------------
|
||
-- Records of user_addresses
|
||
-- ----------------------------
|
||
BEGIN;
|
||
COMMIT;
|
||
|
||
-- ----------------------------
|
||
-- Table structure for user_favorites
|
||
-- ----------------------------
|
||
DROP TABLE IF EXISTS `user_favorites`;
|
||
CREATE TABLE `user_favorites`
|
||
(
|
||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||
`created_at` datetime(6) NOT NULL,
|
||
`product_id` bigint NOT NULL,
|
||
`user_id` bigint NOT NULL,
|
||
PRIMARY KEY (`id`),
|
||
UNIQUE KEY `uk_favorite_user_product` (`user_id`, `product_id`)
|
||
) ENGINE = InnoDB
|
||
AUTO_INCREMENT = 3
|
||
DEFAULT CHARSET = utf8mb4
|
||
COLLATE = utf8mb4_0900_ai_ci;
|
||
|
||
-- ----------------------------
|
||
-- Records of user_favorites
|
||
-- ----------------------------
|
||
BEGIN;
|
||
INSERT INTO `user_favorites` (`id`, `created_at`, `product_id`, `user_id`)
|
||
VALUES (2, '2026-03-16 21:26:46.264000', 14, 3);
|
||
COMMIT;
|
||
|
||
-- ----------------------------
|
||
-- Table structure for users
|
||
-- ----------------------------
|
||
DROP TABLE IF EXISTS `users`;
|
||
CREATE TABLE `users`
|
||
(
|
||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '用户ID',
|
||
`username` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '用户名',
|
||
`password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '密码(加密)',
|
||
`email` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '邮箱',
|
||
`phone` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '手机号',
|
||
`status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '用户状态:1-正常,0-禁用',
|
||
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||
`updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||
`last_login` datetime DEFAULT NULL COMMENT '最后登录时间',
|
||
`avatar` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||
`role` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||
PRIMARY KEY (`id`),
|
||
UNIQUE KEY `username` (`username`),
|
||
KEY `idx_username` (`username`),
|
||
KEY `idx_email` (`email`),
|
||
KEY `idx_phone` (`phone`),
|
||
KEY `idx_status` (`status`),
|
||
KEY `idx_created_at` (`created_at`),
|
||
KEY `idx_users_status` (`status`),
|
||
KEY `idx_users_last_login` (`last_login`),
|
||
KEY `idx_users_created_at` (`created_at`)
|
||
) ENGINE = InnoDB
|
||
AUTO_INCREMENT = 16
|
||
DEFAULT CHARSET = utf8mb4
|
||
COLLATE = utf8mb4_unicode_ci COMMENT ='用户表';
|
||
|
||
-- ----------------------------
|
||
-- Records of users
|
||
-- ----------------------------
|
||
BEGIN;
|
||
INSERT INTO `users` (`id`, `username`, `password`, `email`, `phone`, `status`, `created_at`, `updated_at`, `last_login`,
|
||
`avatar`, `role`)
|
||
VALUES (1, 'demo1', '$2a$10$3V4zVguC/6eJjkuh78JqeufsNnjtHado/xUpGzrdLylF/TjH1ZoQ6', 'admin_updated@example.com',
|
||
'13888888888', 1, '2026-03-14 17:51:14', '2026-03-14 17:51:14', NULL, NULL, '');
|
||
INSERT INTO `users` (`id`, `username`, `password`, `email`, `phone`, `status`, `created_at`, `updated_at`, `last_login`,
|
||
`avatar`, `role`)
|
||
VALUES (2, 'demo2', '$2a$10$3V4zVguC/6eJjkuh78JqeufsNnjtHado/xUpGzrdLylF/TjH1ZoQ6', 'demo2@example.com', '13800138002',
|
||
1, '2026-03-14 17:51:14', '2026-03-14 17:51:14', NULL, NULL, '');
|
||
INSERT INTO `users` (`id`, `username`, `password`, `email`, `phone`, `status`, `created_at`, `updated_at`, `last_login`,
|
||
`avatar`, `role`)
|
||
VALUES (3, 'admin', '$2a$10$3V4zVguC/6eJjkuh78JqeufsNnjtHado/xUpGzrdLylF/TjH1ZoQ6', 'admin@example.com', '13800138000',
|
||
1, '2026-03-14 17:51:14', '2026-03-17 00:17:36', '2026-03-17 00:17:36', NULL, '');
|
||
INSERT INTO `users` (`id`, `username`, `password`, `email`, `phone`, `status`, `created_at`, `updated_at`, `last_login`,
|
||
`avatar`, `role`)
|
||
VALUES (4, 'testuser1', '$2a$10$3V4zVguC/6eJjkuh78JqeufsNnjtHado/xUpGzrdLylF/TjH1ZoQ6', 'test1@example.com',
|
||
'13800138003', 1, '2026-03-14 17:51:14', '2026-03-14 17:51:14', NULL, NULL, '');
|
||
INSERT INTO `users` (`id`, `username`, `password`, `email`, `phone`, `status`, `created_at`, `updated_at`, `last_login`,
|
||
`avatar`, `role`)
|
||
VALUES (5, 'testuser2', '$2a$10$3V4zVguC/6eJjkuh78JqeufsNnjtHado/xUpGzrdLylF/TjH1ZoQ6', 'test2@example.com',
|
||
'13800138004', 1, '2026-03-14 17:51:14', '2026-03-14 17:51:14', NULL, NULL, '');
|
||
INSERT INTO `users` (`id`, `username`, `password`, `email`, `phone`, `status`, `created_at`, `updated_at`, `last_login`,
|
||
`avatar`, `role`)
|
||
VALUES (6, 'testuser3', '$2a$10$3V4zVguC/6eJjkuh78JqeufsNnjtHado/xUpGzrdLylF/TjH1ZoQ6', 'test3@example.com',
|
||
'13800138005', 1, '2026-03-14 17:51:14', '2026-03-14 17:51:14', NULL, NULL, '');
|
||
INSERT INTO `users` (`id`, `username`, `password`, `email`, `phone`, `status`, `created_at`, `updated_at`, `last_login`,
|
||
`avatar`, `role`)
|
||
VALUES (7, 'testuser4', '$2a$10$3V4zVguC/6eJjkuh78JqeufsNnjtHado/xUpGzrdLylF/TjH1ZoQ6', 'test4@example.com',
|
||
'13800138006', 1, '2026-03-14 17:51:14', '2026-03-14 17:51:14', NULL, NULL, '');
|
||
INSERT INTO `users` (`id`, `username`, `password`, `email`, `phone`, `status`, `created_at`, `updated_at`, `last_login`,
|
||
`avatar`, `role`)
|
||
VALUES (8, 'testuser5', '$2a$10$3V4zVguC/6eJjkuh78JqeufsNnjtHado/xUpGzrdLylF/TjH1ZoQ6', 'test5@example.com',
|
||
'13800138007', 1, '2026-03-14 17:51:14', '2026-03-14 17:51:14', NULL, NULL, '');
|
||
INSERT INTO `users` (`id`, `username`, `password`, `email`, `phone`, `status`, `created_at`, `updated_at`, `last_login`,
|
||
`avatar`, `role`)
|
||
VALUES (11, 'student', '$2a$10$3V4zVguC/6eJjkuh78JqeufsNnjtHado/xUpGzrdLylF/TjH1ZoQ6', '1231231@gmail.com',
|
||
'19889899898', 1, '2026-03-14 17:51:14', '2026-03-14 17:51:14', NULL, NULL, '');
|
||
INSERT INTO `users` (`id`, `username`, `password`, `email`, `phone`, `status`, `created_at`, `updated_at`, `last_login`,
|
||
`avatar`, `role`)
|
||
VALUES (12, 'student1', '$2a$10$3V4zVguC/6eJjkuh78JqeufsNnjtHado/xUpGzrdLylF/TjH1ZoQ6', 'gz1@gmail.com', '19566111010',
|
||
1, '2026-03-14 17:51:14', '2026-03-14 17:51:14', NULL, NULL, '');
|
||
INSERT INTO `users` (`id`, `username`, `password`, `email`, `phone`, `status`, `created_at`, `updated_at`, `last_login`,
|
||
`avatar`, `role`)
|
||
VALUES (13, '123123', '$2a$10$3V4zVguC/6eJjkuh78JqeufsNnjtHado/xUpGzrdLylF/TjH1ZoQ6', NULL, NULL, 1,
|
||
'2026-03-14 17:51:14', '2026-03-14 17:51:14', NULL, NULL, '');
|
||
INSERT INTO `users` (`id`, `username`, `password`, `email`, `phone`, `status`, `created_at`, `updated_at`, `last_login`,
|
||
`avatar`, `role`)
|
||
VALUES (14, '123', '$2a$10$3V4zVguC/6eJjkuh78JqeufsNnjtHado/xUpGzrdLylF/TjH1ZoQ6', '123@qq.com', '', 1,
|
||
'2026-03-14 17:51:14', '2026-03-14 17:51:14', NULL, '', 'USER');
|
||
INSERT INTO `users` (`id`, `username`, `password`, `email`, `phone`, `status`, `created_at`, `updated_at`, `last_login`,
|
||
`avatar`, `role`)
|
||
VALUES (15, '123456', '$2a$10$a7YnUMYMmgWt1mdf6WmyEux/4YPT05rutsab2KLajgGYf60aZfbUW', '1232@qq.com', '13223322332', 1,
|
||
'2026-03-16 23:08:57', '2026-03-17 00:18:13', '2026-03-17 00:18:13', '', 'USER');
|
||
COMMIT;
|
||
|
||
-- ----------------------------
|
||
-- View structure for active_flash_sales
|
||
-- ----------------------------
|
||
DROP VIEW IF EXISTS `active_flash_sales`;
|
||
CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `active_flash_sales` AS
|
||
select `fs`.`id` AS `id`,
|
||
`fs`.`product_id` AS `product_id`,
|
||
`p`.`name` AS `product_name`,
|
||
`p`.`price` AS `original_price`,
|
||
`fs`.`flash_price` AS `flash_price`,
|
||
`fs`.`flash_stock` AS `flash_stock`,
|
||
`fs`.`start_time` AS `start_time`,
|
||
`fs`.`end_time` AS `end_time`,
|
||
`fs`.`status` AS `status`,
|
||
`p`.`image_url` AS `image_url`
|
||
from (`flash_sales` `fs` join `products` `p` on ((`fs`.`product_id` = `p`.`id`)))
|
||
where ((`fs`.`status` = 2) and (`fs`.`start_time` <= now()) and (`fs`.`end_time` > now()) and (`p`.`status` = 1));
|
||
|
||
-- ----------------------------
|
||
-- View structure for order_statistics
|
||
-- ----------------------------
|
||
DROP VIEW IF EXISTS `order_statistics`;
|
||
CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `order_statistics` AS
|
||
select cast(`orders`.`created_at` as date) AS `order_date`,
|
||
count(0) AS `total_orders`,
|
||
sum((case when (`orders`.`status` = 1) then 1 else 0 end)) AS `pending_orders`,
|
||
sum((case when (`orders`.`status` = 2) then 1 else 0 end)) AS `paid_orders`,
|
||
sum((case when (`orders`.`status` = 4) then 1 else 0 end)) AS `completed_orders`,
|
||
sum((case when (`orders`.`order_type` = 2) then 1 else 0 end)) AS `flash_sale_orders`,
|
||
sum(`orders`.`total_price`) AS `total_amount`
|
||
from `orders`
|
||
group by cast(`orders`.`created_at` as date)
|
||
order by `order_date` desc;
|
||
|
||
SET FOREIGN_KEY_CHECKS = 1;
|