SET NAMES utf8mb4;
-- 为每家供应商创建登录账号，关联到 biz_supplier.user_id

-- 4.1 华顺达
INSERT INTO sys_user (dept_id, user_name, nick_name, user_type, phonenumber, password, status, del_flag, create_by, create_time, remark, tenant_id)
VALUES (100, 'hsd', '华顺达', '00', '13800138001', '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '0', '0', 'admin', NOW(), '供应商-华顺达', 1);
SELECT @uid1:=LAST_INSERT_ID();
UPDATE biz_supplier SET user_id = @uid1 WHERE supplier_id = 1;

-- 4.2 博远精密
INSERT INTO sys_user (dept_id, user_name, nick_name, user_type, phonenumber, password, status, del_flag, create_by, create_time, remark, tenant_id)
VALUES (100, 'boyuan', '博远精密', '00', '13900139002', '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '0', '0', 'admin', NOW(), '供应商-博远精密', 1);
SELECT @uid2:=LAST_INSERT_ID();
UPDATE biz_supplier SET user_id = @uid2 WHERE supplier_id = 2;

-- 4.3 瑞达工控
INSERT INTO sys_user (dept_id, user_name, nick_name, user_type, phonenumber, password, status, del_flag, create_by, create_time, remark, tenant_id)
VALUES (100, 'ruida', '瑞达工控', '00', '13700137003', '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '0', '0', 'admin', NOW(), '供应商-瑞达工控', 1);
SELECT @uid3:=LAST_INSERT_ID();
UPDATE biz_supplier SET user_id = @uid3 WHERE supplier_id = 3;

-- 4.4 联盟电气
INSERT INTO sys_user (dept_id, user_name, nick_name, user_type, phonenumber, password, status, del_flag, create_by, create_time, remark, tenant_id)
VALUES (100, 'lianmeng', '联盟电气', '00', '15900159004', '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '0', '0', 'admin', NOW(), '供应商-联盟电气', 1);
SELECT @uid4:=LAST_INSERT_ID();
UPDATE biz_supplier SET user_id = @uid4 WHERE supplier_id = 4;

-- 4.5 华中精工
INSERT INTO sys_user (dept_id, user_name, nick_name, user_type, phonenumber, password, status, del_flag, create_by, create_time, remark, tenant_id)
VALUES (100, 'hzjg', '华中精工', '00', '13600136005', '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '0', '0', 'admin', NOW(), '供应商-华中精工', 1);
SELECT @uid5:=LAST_INSERT_ID();
UPDATE biz_supplier SET user_id = @uid5 WHERE supplier_id = 5;

-- 分配 supplier 角色
INSERT INTO sys_user_role (user_id, role_id) VALUES
(@uid1, 3), (@uid2, 3), (@uid3, 3), (@uid4, 3), (@uid5, 3);

-- 验证
SELECT s.supplier_name, s.user_id, u.user_name, u.nick_name
FROM biz_supplier s JOIN sys_user u ON s.user_id = u.user_id
ORDER BY s.supplier_id;
