-- S003 种子数据（仅账号，不清空其他门店数据）
-- 用法: sh scripts/dev.sh seed S003

-- 插入门店（若已存在则忽略）
INSERT IGNORE INTO shops (name, code, address, phone, manager_name, created_at, updated_at)
VALUES ('御品轩名酒坊', 'S003', '广州市天河区天河路385号太古汇ML-21', '020-38688866', '王志远', NOW(), NOW());

-- 获取 S003 的 shop_id
SET @shop_id = (SELECT id FROM shops WHERE code = 'S003' LIMIT 1);

-- 密码均为 password123
SET @pwd = '$2a$10$BNHhJoKHryCCEyKqM.11TeLOnSCV8rNtOqvKHUqaczETXLtH/YE1m';

-- 插入用户（若已存在则更新密码）
INSERT INTO users (shop_id, username, password_hash, real_name, phone, role, is_active, created_at, updated_at)
VALUES
  (@shop_id, 'admin',    @pwd, '管理员', '', 'admin',    1, NOW(), NOW()),
  (@shop_id, 'operator', @pwd, '操作员', '', 'operator', 1, NOW(), NOW()),
  (@shop_id, 'test',     @pwd, '只读',   '', 'readonly', 1, NOW(), NOW())
ON DUPLICATE KEY UPDATE password_hash = @pwd, is_active = 1, updated_at = NOW();
