-- ============================================
-- 创建138开头的测试账号
-- 创建时间: 2026-02-01
-- 说明: 创建5个不同角色的测试账号，手机号为138001380XX
-- ============================================

-- 1. 家长账号 - 13800138000
INSERT INTO `user` (
    `tenant_id`,
    `phone`,
    `password`,
    `real_name`,
    `nickname`,
    `gender`,
    `user_type`,
    `status`,
    `referral_code`,
    `create_time`,
    `update_time`,
    `deleted`
) VALUES (
    1,
    '13800138000',
    '$2a$10$N.zmdr9k7uOCQb376NoUnuTzanmHxPGKx8.0.PvZ8Mq0ibNbGXqDm', -- password: 123456
    '测试家长',
    '测试家长',
    1,
    'PARENT',
    1,
    'TEST_PARENT',
    CURRENT_TIMESTAMP,
    CURRENT_TIMESTAMP,
    0
) ON DUPLICATE KEY UPDATE
    `password` = '$2a$10$N.zmdr9k7uOCQb376NoUnuTzanmHxPGKx8.0.PvZ8Mq0ibNbGXqDm',
    `user_type` = 'PARENT',
    `update_time` = CURRENT_TIMESTAMP;

-- 2. 陪伴员账号 - 13800138001
INSERT INTO `user` (
    `tenant_id`,
    `phone`,
    `password`,
    `real_name`,
    `nickname`,
    `gender`,
    `user_type`,
    `status`,
    `referral_code`,
    `education_level`,
    `teaching_subjects`,
    `self_introduction`,
    `is_full_time`,
    `create_time`,
    `update_time`,
    `deleted`
) VALUES (
    1,
    '13800138001',
    '$2a$10$N.zmdr9k7uOCQb376NoUnuTzanmHxPGKx8.0.PvZ8Mq0ibNbGXqDm', -- password: 123456
    '测试陪伴员',
    '测试陪伴员',
    2,
    'PROVIDER',
    1,
    'TEST_TEACHER',
    '本科',
    '语文,数学,英语',
    '测试陪伴员账号',
    1,
    CURRENT_TIMESTAMP,
    CURRENT_TIMESTAMP,
    0
) ON DUPLICATE KEY UPDATE
    `password` = '$2a$10$N.zmdr9k7uOCQb376NoUnuTzanmHxPGKx8.0.PvZ8Mq0ibNbGXqDm',
    `user_type` = 'PROVIDER',
    `update_time` = CURRENT_TIMESTAMP;

-- 3. 管理师账号 - 13800138002
INSERT INTO `user` (
    `tenant_id`,
    `phone`,
    `password`,
    `real_name`,
    `nickname`,
    `gender`,
    `user_type`,
    `status`,
    `referral_code`,
    `create_time`,
    `update_time`,
    `deleted`
) VALUES (
    1,
    '13800138002',
    '$2a$10$N.zmdr9k7uOCQb376NoUnuTzanmHxPGKx8.0.PvZ8Mq0ibNbGXqDm', -- password: 123456
    '测试管理师',
    '测试管理师',
    1,
    'MANAGER',
    1,
    'TEST_MANAGER',
    CURRENT_TIMESTAMP,
    CURRENT_TIMESTAMP,
    0
) ON DUPLICATE KEY UPDATE
    `password` = '$2a$10$N.zmdr9k7uOCQb376NoUnuTzanmHxPGKx8.0.PvZ8Mq0ibNbGXqDm',
    `user_type` = 'MANAGER',
    `update_time` = CURRENT_TIMESTAMP;

-- 4. 分销员账号 - 13800138003
INSERT INTO `user` (
    `tenant_id`,
    `phone`,
    `password`,
    `real_name`,
    `nickname`,
    `gender`,
    `user_type`,
    `status`,
    `referral_code`,
    `create_time`,
    `update_time`,
    `deleted`
) VALUES (
    1,
    '13800138003',
    '$2a$10$N.zmdr9k7uOCQb376NoUnuTzanmHxPGKx8.0.PvZ8Mq0ibNbGXqDm', -- password: 123456
    '测试分销员',
    '测试分销员',
    1,
    'DISTRIBUTOR',
    1,
    'TEST_DIST',
    CURRENT_TIMESTAMP,
    CURRENT_TIMESTAMP,
    0
) ON DUPLICATE KEY UPDATE
    `password` = '$2a$10$N.zmdr9k7uOCQb376NoUnuTzanmHxPGKx8.0.PvZ8Mq0ibNbGXqDm',
    `user_type` = 'DISTRIBUTOR',
    `update_time` = CURRENT_TIMESTAMP;

-- 5. 服务商账号 - 13800138004
INSERT INTO `user` (
    `tenant_id`,
    `phone`,
    `password`,
    `real_name`,
    `nickname`,
    `gender`,
    `user_type`,
    `status`,
    `referral_code`,
    `create_time`,
    `update_time`,
    `deleted`
) VALUES (
    1,
    '13800138004',
    '$2a$10$N.zmdr9k7uOCQb376NoUnuTzanmHxPGKx8.0.PvZ8Mq0ibNbGXqDm', -- password: 123456
    '测试服务商',
    '测试服务商',
    1,
    'SERVICE_PROVIDER',
    1,
    'TEST_PROVIDER',
    CURRENT_TIMESTAMP,
    CURRENT_TIMESTAMP,
    0
) ON DUPLICATE KEY UPDATE
    `password` = '$2a$10$N.zmdr9k7uOCQb376NoUnuTzanmHxPGKx8.0.PvZ8Mq0ibNbGXqDm',
    `user_type` = 'SERVICE_PROVIDER',
    `update_time` = CURRENT_TIMESTAMP;

-- ============================================
-- 验证创建结果
-- ============================================

SELECT 
    id,
    phone,
    real_name,
    user_type,
    status,
    referral_code,
    create_time
FROM `user`
WHERE phone IN (
    '13800138000',
    '13800138001', 
    '13800138002',
    '13800138003',
    '13800138004'
)
ORDER BY phone;

-- ============================================
-- 使用说明
-- ============================================
-- 
-- 测试账号信息：
-- 1. 家长：13800138000 / 123456
-- 2. 陪伴员：13800138001 / 123456
-- 3. 管理师：13800138002 / 123456
-- 4. 分销员：13800138003 / 123456
-- 5. 服务商：13800138004 / 123456
-- 
-- 注意：
-- - 使用 ON DUPLICATE KEY UPDATE 确保如果账号已存在则更新
-- - 密码统一为 123456（BCrypt加密）
-- - 所有账号状态为正常
-- 
-- ============================================
