-- ============================================================
-- 零食商城 测试数据
-- 执行前请先执行 schema.sql
-- ============================================================

USE `snack_mall`;


-- ============================================================
-- 管理员账号（密码：[REDACTED]，BCrypt 加密，强度 10）
-- BCrypt hash for "123456":
-- ============================================================
INSERT INTO `admin` (`username`, `password`, `nickname`, `role`, `status`) VALUES
('admin',    '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '超级管理员', 'super_admin', 1),
('manager',  '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '运营经理',   'admin',       1),
('operator', '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '运营专员',   'operator',    1);


-- ============================================================
-- 普通用户（密码：[REDACTED]）
-- ============================================================
INSERT INTO `user` (`username`, `password`, `phone`, `nickname`, `avatar`, `status`) VALUES
('user001', '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '13800138001', '小张同学',  'https://api.dicebear.com/7.x/avataaars/svg?seed=user001', 1),
('user002', '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '13800138002', '爱吃零食',  'https://api.dicebear.com/7.x/avataaars/svg?seed=user002', 1),
('user003', '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '13800138003', '零食达人',  'https://api.dicebear.com/7.x/avataaars/svg?seed=user003', 1),
('user004', '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '13800138004', '吃货联盟',  'https://api.dicebear.com/7.x/avataaars/svg?seed=user004', 1),
('user005', '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '13800138005', '甜品控',    'https://api.dicebear.com/7.x/avataaars/svg?seed=user005', 1);


-- ============================================================
-- 商品分类（一级 + 二级）
-- ============================================================
INSERT INTO `category` (`id`, `name`, `parent_id`, `level`, `sort`, `icon`, `status`) VALUES
(1,  '休闲零食',    0, 1, 1, NULL, 1),
(2,  '坚果炒货',    1, 2, 1, NULL, 1),
(3,  '糖果巧克力',  1, 2, 2, NULL, 1),
(4,  '肉脯卤味',    1, 2, 3, NULL, 1),
(5,  '膨化食品',    1, 2, 4, NULL, 1),
(6,  '蜜饯果干',    1, 2, 5, NULL, 1),
(7,  '饮料饮品',    0, 1, 2, NULL, 1),
(8,  '碳酸饮料',    7, 2, 1, NULL, 1),
(9,  '果汁',        7, 2, 2, NULL, 1),
(10, '茶饮',        7, 2, 3, NULL, 1),
(11, '饼干糕点',    0, 1, 3, NULL, 1),
(12, '饼干',        11, 2, 1, NULL, 1),
(13, '蛋糕',        11, 2, 2, NULL, 1);


-- ============================================================
-- 商品 SPU
-- ============================================================
INSERT INTO `product` (`id`, `name`, `category_id`, `brand`, `main_image`, `origin_price`, `sales`, `status`, `is_hot`, `is_new`) VALUES
(1,  '原味夏威夷果 500g',          2, '良品铺子', 'https://img.zcool.cn/community/01a87e5e7b8e7a0000001.png@1280w_1l_2o_100sh.png', 89.00, 320, 1, 1, 0),
(2,  '奶油味腰果 200g',            2, '三只松鼠', 'https://img.zcool.cn/community/01a87e5e7b8e7a0000001.png@1280w_1l_2o_100sh.png', 49.00, 280, 1, 1, 1),
(3,  '原味开心果 300g',            2, '来伊份',   'https://img.zcool.cn/community/01a87e5e7b8e7a0000001.png@1280w_1l_2o_100sh.png', 69.00, 150, 1, 0, 1),
(4,  '蜂蜜核桃仁 250g',            2, '洽洽',     'https://img.zcool.cn/community/01a87e5e7b8e7a0000001.png@1280w_1l_2o_100sh.png', 39.90, 220, 1, 1, 0),
(5,  '原味瓜子 500g',              2, '洽洽',     'https://img.zcool.cn/community/01a87e5e7b8e7a0000001.png@1280w_1l_2o_100sh.png', 19.90, 480, 1, 1, 0),
(6,  '草莓味软糖 200g',            3, '阿尔卑斯', 'https://img.zcool.cn/community/01a87e5e7b8e7a0000001.png@1280w_1l_2o_100sh.png', 12.90, 600, 1, 0, 0),
(7,  '牛奶巧克力 100g',            3, '德芙',     'https://img.zcool.cn/community/01a87e5e7b8e7a0000001.png@1280w_1l_2o_100sh.png', 28.90, 720, 1, 1, 0),
(8,  '黑巧克力 85% 100g',          3, 'Lindt',    'https://img.zcool.cn/community/01a87e5e7b8e7a0000001.png@1280w_1l_2o_100sh.png', 49.90, 320, 1, 1, 0),
(9,  '蜜汁猪肉脯 250g',            4, '无穷',     'https://img.zcool.cn/community/01a87e5e7b8e7a0000001.png@1280w_1l_2o_100sh.png', 35.90, 380, 1, 1, 0),
(10, '麻辣牛肉干 200g',            4, '老四川',   'https://img.zcool.cn/community/01a87e5e7b8e7a0000001.png@1280w_1l_2o_100sh.png', 42.90, 260, 1, 0, 0),
(11, '原味薯片 大包装 135g',       5, '乐事',     'https://img.zcool.cn/community/01a87e5e7b8e7a0000001.png@1280w_1l_2o_100sh.png', 9.90, 1200, 1, 1, 0),
(12, '虾条 80g',                    5, '上好佳',   'https://img.zcool.cn/community/01a87e5e7b8e7a0000001.png@1280w_1l_2o_100sh.png', 6.90, 860, 1, 0, 0),
(13, '芒果干 100g',                6, '溜溜梅',   'https://img.zcool.cn/community/01a87e5e7b8e7a0000001.png@1280w_1l_2o_100sh.png', 15.90, 540, 1, 1, 0),
(14, '葡萄干 200g',                6, '楼兰蜜语', 'https://img.zcool.cn/community/01a87e5e7b8e7a0000001.png@1280w_1l_2o_100sh.png', 18.90, 380, 1, 0, 0),
(15, '可乐 330ml*6 罐装',          8, '可口可乐', 'https://img.zcool.cn/community/01a87e5e7b8e7a0000001.png@1280w_1l_2o_100sh.png', 25.90, 920, 1, 1, 0),
(16, '雪碧 330ml*6 罐装',          8, '雪碧',     'https://img.zcool.cn/community/01a87e5e7b8e7a0000001.png@1280w_1l_2o_100sh.png', 25.90, 580, 1, 1, 0),
(17, '100% 橙汁 1L',               9, '汇源',     'https://img.zcool.cn/community/01a87e5e7b8e7a0000001.png@1280w_1l_2o_100sh.png', 19.90, 360, 1, 0, 1),
(18, '蜜桃乌龙茶 500ml',           10, '三得利',   'https://img.zcool.cn/community/01a87e5e7b8e7a0000001.png@1280w_1l_2o_100sh.png', 12.90, 420, 1, 0, 1),
(19, '奥利奥饼干 388g',            12, '奥利奥',   'https://img.zcool.cn/community/01a87e5e7b8e7a0000001.png@1280w_1l_2o_100sh.png', 22.90, 1100, 1, 1, 0),
(20, '熔岩蛋糕 6 个装',            13, '好利来',   'https://img.zcool.cn/community/01a87e5e7b8e7a0000001.png@1280w_1l_2o_100sh.png', 39.90, 290, 1, 0, 1);


-- ============================================================
-- 商品 SKU
-- ============================================================
INSERT INTO `product_sku` (`product_id`, `sku_name`, `price`, `stock`, `sales`, `sort`) VALUES
-- 夏威夷果
(1, '原味/500g', 79.00, 500, 320, 1),
(1, '盐焗/500g', 79.00, 300, 120, 2),
(1, '奶油/500g', 84.00, 200,  80, 3),
-- 腰果
(2, '原味/200g', 39.90, 400, 280, 1),
(2, '盐焗/200g', 39.90, 250, 100, 2),
-- 开心果
(3, '原味/300g', 59.00, 300, 150, 1),
(3, '盐焗/300g', 59.00, 200,  60, 2),
-- 核桃
(4, '蜂蜜/250g', 35.90, 400, 220, 1),
(4, '原味/250g', 32.90, 300,  80, 2),
-- 瓜子
(5, '原味/500g', 16.90, 1000, 480, 1),
(5, '五香/500g', 16.90, 600,  200, 2),
-- 软糖
(6, '草莓味/200g', 9.90, 600, 600, 1),
(6, '混合味/200g', 12.90, 400, 220, 2),
-- 巧克力
(7, '牛奶/100g', 24.90, 500, 720, 1),
(7, '榛仁/100g', 28.90, 300, 280, 2),
-- 黑巧
(8, '85%/100g', 39.90, 400, 320, 1),
(8, '70%/100g', 35.90, 300, 180, 2),
-- 猪肉脯
(9, '蜜汁/250g', 32.90, 500, 380, 1),
(9, '麻辣/250g', 32.90, 300, 120, 2),
-- 牛肉干
(10, '麻辣/200g', 39.90, 400, 260, 1),
(10, '五香/200g', 39.90, 300, 100, 2),
-- 薯片
(11, '原味/135g', 8.90, 1000, 1200, 1),
(11, '番茄/135g', 8.90, 800,  680, 2),
(11, '黄瓜/135g', 8.90, 600,  420, 3),
-- 虾条
(12, '原味/80g',  5.90, 800, 860, 1),
-- 芒果干
(13, '原味/100g', 12.90, 500, 540, 1),
(13, '蜜饯/100g', 14.90, 300, 180, 2),
-- 葡萄干
(14, '红提/200g', 16.90, 400, 380, 1),
(14, '黑加仑/200g', 16.90, 300, 120, 2),
-- 可乐
(15, '原味/330ml*6', 22.90, 800, 920, 1),
(15, '零度/330ml*6', 22.90, 500, 320, 2),
-- 雪碧
(16, '原味/330ml*6', 22.90, 700, 580, 1),
-- 橙汁
(17, '原味/1L', 17.90, 400, 360, 1),
-- 蜜桃乌龙
(18, '原味/500ml', 10.90, 500, 420, 1),
-- 奥利奥
(19, '原味/388g', 19.90, 800, 1100, 1),
(19, '巧克力/388g', 19.90, 500, 480, 2),
-- 蛋糕
(20, '原味/6 个装', 36.90, 200, 290, 1);


-- ============================================================
-- 收货地址
-- ============================================================
INSERT INTO `address` (`user_id`, `receiver`, `phone`, `province`, `city`, `district`, `detail`, `is_default`) VALUES
(1, '张三', '13800138001', '广东省', '深圳市', '南山区', '科技园南路 88 号腾讯大厦', 1),
(1, '张三', '13800138001', '广东省', '深圳市', '福田区', '华强北路 1002 号', 0),
(2, '李四', '13800138002', '北京市', '海淀区', '中关村', '中关村大街 27 号', 1),
(3, '王五', '13800138003', '上海市', '浦东新区', '陆家嘴', '世纪大道 100 号', 1),
(4, '赵六', '13800138004', '浙江省', '杭州市', '西湖区', '文三路 478 号', 1);


-- ============================================================
-- 轮播图
-- ============================================================
INSERT INTO `banner` (`title`, `image`, `link_type`, `link_value`, `sort`, `status`) VALUES
('618 大促全场满 199 减 50',         'https://placehold.co/750x320/1E40AF/FFFFFF?text=618+Big+Sale',       0, NULL, 1, 1),
('新品上市 · 进口零食专区',          'https://placehold.co/750x320/3B82F6/FFFFFF?text=New+Arrival',     1, '7',  2, 1),
('新人专享 · 注册即领 50 元大礼包',  'https://placehold.co/750x320/F59E0B/FFFFFF?text=New+User+Gift',    0, NULL, 3, 1),
('每日签到领积分换好礼',             'https://placehold.co/750x320/10B981/FFFFFF?text=Check+In',         0, NULL, 4, 1);


-- ============================================================
-- 系统公告
-- ============================================================
INSERT INTO `notice` (`title`, `content`, `type`, `is_top`, `status`, `start_time`, `end_time`) VALUES
('【重要】关于 618 大促活动规则说明',
  '<p>亲爱的用户：</p><p>618 大促活动即将开始，全场满 199 减 50，满 399 减 120，上不封顶！活动期间更有每日 10 点/20 点限时秒杀，等你来抢！</p><p>活动期间如有任何问题，请联系在线客服。</p>',
  1, 1, 1, '2026-06-01 00:00:00', '2026-06-25 23:59:59'),
('系统升级维护通知',
  '<p>为了提供更好的服务，系统将于 2026-06-15 02:00 - 04:00 进行例行维护升级。维护期间可能短暂无法访问，请合理安排购物时间。</p>',
  1, 0, 1, '2026-06-10 00:00:00', '2026-06-16 23:59:59'),
('新人福利：注册即送 50 元大礼包',
  '<p>新用户注册后可在「领券中心」领取 50 元新人礼包，包含：满 99 减 20、满 199 减 30 优惠券各一张。</p>',
  2, 0, 1, '2026-05-01 00:00:00', '2026-12-31 23:59:59'),
('关于规范使用账户的公告',
  '<p>为保障您的账户安全，请勿将账户借给他人使用。如发现异常登录行为，系统将自动冻结账户。</p>',
  0, 0, 1, '2026-05-15 00:00:00', '2026-12-31 23:59:59'),
('物流更新提醒',
  '<p>近期受天气影响，部分地区物流时效可能延长 1-2 天，请耐心等待。如长时间未收到，可联系客服查询。</p>',
  0, 0, 1, '2026-06-01 00:00:00', '2026-06-30 23:59:59');


-- ============================================================
-- 优惠券模板
-- ============================================================
INSERT INTO `coupon` (`name`, `type`, `amount`, `min_amount`, `max_discount`, `total`, `remain`, `per_limit`, `status`, `start_time`, `end_time`, `valid_days`) VALUES
-- 满减券
('满 99 减 10',      0, 10.00,  99.00,  0.00, 1000, 856, 1, 1, '2026-06-01 00:00:00', '2026-06-30 23:59:59', 30),
('满 199 减 30',     0, 30.00, 199.00,  0.00,  500, 320, 1, 1, '2026-06-01 00:00:00', '2026-06-30 23:59:59', 30),
('满 399 减 80',     0, 80.00, 399.00,  0.00,  200, 168, 1, 1, '2026-06-01 00:00:00', '2026-06-25 23:59:59', 15),
-- 折扣券
('9 折优惠券',       1,  0.90,   0.00, 50.00,  800, 580, 1, 1, '2026-06-01 00:00:00', '2026-06-30 23:59:59', 30),
('8.5 折优惠券',     1,  0.85, 100.00, 80.00,  300, 180, 1, 1, '2026-06-01 00:00:00', '2026-06-25 23:59:59', 15),
-- 无门槛
('新人 5 元无门槛',  2,  5.00,   0.00,  0.00, 5000, 3200, 1, 1, '2026-05-01 00:00:00', '2026-12-31 23:59:59', 30),
('新人 10 元无门槛', 2, 10.00,   0.00,  0.00, 3000, 2100, 1, 1, '2026-05-01 00:00:00', '2026-12-31 23:59:59', 30);


-- ============================================================
-- 限时抢购活动
-- ============================================================
INSERT INTO `seckill_activity` (`name`, `start_time`, `end_time`, `status`) VALUES
('618 限时秒杀 · 第一场',  '2026-06-02 10:00:00', '2026-06-02 12:00:00', 1),
('618 限时秒杀 · 第二场',  '2026-06-02 14:00:00', '2026-06-02 16:00:00', 0),
('618 限时秒杀 · 第三场',  '2026-06-02 20:00:00', '2026-06-02 22:00:00', 0),
('618 限时秒杀 · 第四场',  '2026-06-03 10:00:00', '2026-06-03 12:00:00', 0),
('618 限时秒杀 · 第五场',  '2026-06-03 20:00:00', '2026-06-03 22:00:00', 0),
('已结束场次回顾',          '2026-06-01 10:00:00', '2026-06-01 12:00:00', 2);


-- ============================================================
-- 抢购活动商品
-- ============================================================
INSERT INTO `seckill_product` (`activity_id`, `product_id`, `sku_id`, `seckill_price`, `seckill_stock`, `remain_stock`, `per_limit`, `sales`) VALUES
-- 第一场
(1, 1,  1,  49.90, 100,  68, 2, 32),
(1, 7, 14,  14.90, 200, 145, 3, 55),
(1, 11, 22,  4.90, 500, 320, 5, 180),
(1, 15, 30, 12.90, 300, 198, 2, 102),
-- 第二场
(2, 2,  4,  19.90, 150, 150, 2, 0),
(2, 9, 18,  19.90, 200, 200, 2, 0),
(2, 19, 39,  9.90, 500, 500, 3, 0),
-- 第三场
(3, 8, 16,  24.90, 200, 200, 2, 0),
(3, 13, 27,  6.90, 300, 300, 3, 0),
(3, 20, 41, 19.90, 100, 100, 1, 0);


-- ============================================================
-- 客服快捷回复模板
-- ============================================================
INSERT INTO `quick_reply` (`title`, `content`, `sort`, `status`) VALUES
('问候',     '您好，欢迎光临零食商城~ 请问有什么可以帮您？', 1, 1),
('已发货',   '您的订单已经发货啦，物流单号：xx，预计 2-3 天到达，请耐心等待哦~', 2, 1),
('催发货',   '亲，您的订单正在紧急处理中，我们会尽快为您发货，感谢您的耐心等待！', 3, 1),
('退换货',   '亲，如需退换货请提供订单号和具体问题，我们会在 24 小时内为您处理~', 4, 1),
('感谢',     '感谢您的咨询，祝您购物愉快！如有问题随时联系在线客服~', 5, 1),
('库存咨询', '亲，这款商品目前库存充足，可以直接下单哦~', 6, 1);


-- ============================================================
-- 收藏
-- ============================================================
INSERT INTO `favorite` (`user_id`, `product_id`) VALUES
(1,  1), (1,  7), (1,  9),
(2,  2), (2, 11),
(3,  1), (3,  8), (3, 19),
(4, 11), (4, 15),
(5,  6), (5, 13);


-- ============================================================
-- 客服示例会话
-- ============================================================
INSERT INTO `chat_session` (`id`, `session_no`, `user_id`, `admin_id`, `status`, `user_unread`, `admin_unread`, `last_message`, `last_time`, `user_seq`, `admin_seq`) VALUES
(1, 'CS20260601001', 1, 1, 1, 1, 0, '好的，下一单', '2026-06-01 14:02:00', 3, 3),
(2, 'CS20260601002', 2, NULL, 0, 1, 1, '请问发货时间是什么时候？', '2026-06-01 15:23:00', 1, 0),
(3, 'CS20260601003', 3, 1, 2, 0, 0, '感谢您的耐心解答！', '2026-06-01 16:45:00', 2, 2),
(4, 'CS20260601004', 4, NULL, 0, 1, 1, '我下单了怎么还没发货？', '2026-06-02 09:12:00', 1, 0),
(5, 'CS20260601005', 5, 1, 1, 1, 0, '请问优惠券怎么用？', '2026-06-02 10:30:00', 1, 0);


-- ============================================================
-- 客服示例消息（含 seq 序号）
-- ============================================================
INSERT INTO `chat_message` (`session_id`, `seq`, `sender_id`, `sender_type`, `type`, `content`, `is_recalled`, `create_time`) VALUES
(1, 1, 1, 0, 'text', '你好，请问夏威夷果还有货吗？', 0, '2026-06-01 14:00:00'),
(1, 2, 1, 1, 'text', '亲，在的哦，目前库存充足~',     0, '2026-06-01 14:01:00'),
(1, 3, 1, 0, 'text', '好的，下一单',                 0, '2026-06-01 14:02:00'),
(2, 1, 2, 0, 'text', '请问发货时间是什么时候？',     0, '2026-06-01 15:23:00'),
(3, 1, 3, 0, 'text', '订单已收到，谢谢',             0, '2026-06-01 16:40:00'),
(3, 2, 1, 1, 'text', '感谢您的耐心解答！',           0, '2026-06-01 16:45:00'),
(4, 1, 4, 0, 'text', '我下单了怎么还没发货？',       0, '2026-06-02 09:12:00'),
(5, 1, 5, 0, 'text', '请问优惠券怎么用？',           0, '2026-06-02 10:30:00');


-- ============================================================
-- 抢购成功记录示例（模拟已经异步落库后的状态）
-- ============================================================
INSERT INTO `seckill_order` (`user_id`, `activity_id`, `product_id`, `sku_id`, `quantity`, `seckill_price`, `order_id`, `status`) VALUES
(1, 1,  1,  1, 1, 49.90, NULL, 0),
(1, 1,  7, 14, 2, 14.90, NULL, 0),
(2, 1, 11, 22, 3,  4.90, NULL, 0),
(3, 1, 15, 30, 1, 12.90, NULL, 1);


-- ============================================================
-- 完成
-- ============================================================
SELECT '✅ 测试数据导入完成' AS message;
SELECT '默认管理员账号: admin / 123456' AS info;
SELECT '默认用户账号:   user001 / 123456' AS info;
