-- 测试数据
-- 先删除已有数据
DELETE FROM stock_flow;
DELETE FROM order_items;
DELETE FROM orders;
DELETE FROM stock;
DELETE FROM products;
DELETE FROM categories;
DELETE FROM customers;
DELETE FROM users;
DELETE FROM system_config;

-- 用户表 - 管理员和销售
INSERT INTO users (user_id, username, phone, password, role, status) VALUES 
('u-admin-001', 'admin', '13800000001', '$2a$10$N.zmdr9k7uOCQb376NoUnuTJ8iAt6Z5EHsM8lE9lBOsl7iAt6Z5EH', 'admin', 1),
('u-sales-001', '张三', '13800000002', '$2a$10$N.zmdr9k7uOCQb376NoUnuTJ8iAt6Z5EHsM8lE9lBOsl7iAt6Z5EH', 'sales', 1),
('u-sales-002', '李四', '13800000003', '$2a$10$N.zmdr9k7uOCQb376NoUnuTJ8iAt6Z5EHsM8lE9lBOsl7iAt6Z5EH', 'sales', 1);

-- 客户表
INSERT INTO customers (customer_id, name, phone, address, remark, total_amount, created_by) VALUES 
('c-001', '王五', '13900000001', '北京市朝阳区XX街道', 'VIP客户', 50000.00, 'u-admin-001'),
('c-002', '赵六', '13900000002', '上海市浦东新区XX路', '普通客户', 15000.00, 'u-sales-001'),
('c-003', '钱七', '13900000003', '广州市天河区XX大道', '新客户', 5000.00, 'u-sales-001'),
('c-004', '孙八', '13900000004', '深圳市南山区XX园', '潜在客户', 0.00, 'u-sales-002');

-- 商品分类表
INSERT INTO categories (category_id, name, parent_id, sort_order, status) VALUES 
('cat-001', '钢材', NULL, 1, 1),
('cat-002', '水泥', NULL, 2, 1),
('cat-003', '木材', NULL, 3, 1),
('cat-004', '管材', NULL, 4, 1),
('cat-005', '螺纹钢', 'cat-001', 1, 1),
('cat-006', '型材', 'cat-001', 2, 1),
('cat-007', 'PC32.5', 'cat-002', 1, 1),
('cat-008', 'PC42.5', 'cat-002', 2, 1);

-- 商品表
INSERT INTO products (product_id, category_id, name, spec, unit, price, cost_price, stock_alert, status) VALUES 
('p-001', 'cat-005', '螺纹钢 Φ12', '12mm', '吨', 4200.00, 3800.00, 10, 1),
('p-002', 'cat-005', '螺纹钢 Φ16', '16mm', '吨', 4100.00, 3700.00, 10, 1),
('p-003', 'cat-005', '螺纹钢 Φ20', '20mm', '吨', 4050.00, 3650.00, 10, 1),
('p-004', 'cat-006', 'H型钢 H200*200*8*12', '200*200', '吨', 3800.00, 3400.00, 5, 1),
('p-005', 'cat-007', '水泥 PC32.5', '32.5级', '吨', 450.00, 380.00, 50, 1),
('p-006', 'cat-008', '水泥 PC42.5', '42.5级', '吨', 520.00, 450.00, 50, 1),
('p-007', 'cat-003', '木材 杉木方', '4*9cm', '立方米', 1200.00, 900.00, 20, 1),
('p-008', 'cat-003', '木材 松木板', '18mm', '平方米', 85.00, 60.00, 100, 1),
('p-009', 'cat-004', 'PVC管 Φ50', '50mm', '米', 12.00, 8.00, 200, 1),
('p-010', 'cat-004', 'PVC管 Φ100', '100mm', '米', 28.00, 20.00, 100, 1),
('p-011', 'cat-004', 'PPR管 Φ25', '25mm', '米', 8.00, 5.50, 300, 1),
('p-012', 'cat-004', '镀锌管 Φ32', '32mm', '米', 22.00, 16.00, 150, 1);

-- 库存表
INSERT INTO stock (stock_id, product_id, quantity, locked_quantity) VALUES 
('s-001', 'p-001', 100, 0),
('s-002', 'p-002', 80, 0),
('s-003', 'p-003', 60, 0),
('s-004', 'p-004', 25, 0),
('s-005', 'p-005', 200, 0),
('s-006', 'p-006', 150, 0),
('s-007', 'p-007', 30, 0),
('s-008', 'p-008', 500, 0),
('s-009', 'p-009', 1000, 0),
('s-010', 'p-010', 500, 0),
('s-011', 'p-011', 2000, 0),
('s-012', 'p-012', 800, 0);

-- 系统配置表
INSERT INTO system_config (config_id, config_key, config_value, remark) VALUES 
('cfg-001', 'order_view_days', '180', '顾客可查看订单天数'),
('cfg-002', 'default_discount_rate', '100', '默认折扣率'),
('cfg-003', 'stock_alert_enabled', 'true', '是否启用库存预警'),
('cfg-004', 'wechat_enabled', 'true', '是否启用微信登录');
