-- =============================================================================
-- 入职资料：银行开户实名、身份证地址与身份证正反面照片
-- 说明：为 lq_employee_profile / lq_employee_profile_submission 补齐字段；可重复执行
-- =============================================================================

SET NAMES utf8mb4;
SET @db_name = DATABASE();

-- lq_employee_profile.F_BankAccountName
SET @col_exists = (
  SELECT COUNT(1) FROM information_schema.COLUMNS
  WHERE TABLE_SCHEMA = @db_name AND TABLE_NAME = 'lq_employee_profile' AND COLUMN_NAME = 'F_BankAccountName'
);
SET @sql = IF(@col_exists = 0,
  'ALTER TABLE `lq_employee_profile` ADD COLUMN `F_BankAccountName` varchar(128) DEFAULT NULL COMMENT ''开户实名（开户人真实姓名）'' AFTER `F_BankCardCipher`;',
  'SELECT ''lq_employee_profile.F_BankAccountName 已存在'';'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

-- lq_employee_profile.F_IdCardAddress
SET @col_exists = (
  SELECT COUNT(1) FROM information_schema.COLUMNS
  WHERE TABLE_SCHEMA = @db_name AND TABLE_NAME = 'lq_employee_profile' AND COLUMN_NAME = 'F_IdCardAddress'
);
SET @sql = IF(@col_exists = 0,
  'ALTER TABLE `lq_employee_profile` ADD COLUMN `F_IdCardAddress` varchar(500) DEFAULT NULL COMMENT ''身份证地址（完整地址，独立于籍贯）'' AFTER `F_BankAccountName`;',
  'SELECT ''lq_employee_profile.F_IdCardAddress 已存在'';'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

-- lq_employee_profile.F_IdCardFrontUrl
SET @col_exists = (
  SELECT COUNT(1) FROM information_schema.COLUMNS
  WHERE TABLE_SCHEMA = @db_name AND TABLE_NAME = 'lq_employee_profile' AND COLUMN_NAME = 'F_IdCardFrontUrl'
);
SET @sql = IF(@col_exists = 0,
  'ALTER TABLE `lq_employee_profile` ADD COLUMN `F_IdCardFrontUrl` varchar(500) DEFAULT NULL COMMENT ''身份证正面照片 URL'' AFTER `F_IdCardAddress`;',
  'SELECT ''lq_employee_profile.F_IdCardFrontUrl 已存在'';'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

-- lq_employee_profile.F_IdCardBackUrl
SET @col_exists = (
  SELECT COUNT(1) FROM information_schema.COLUMNS
  WHERE TABLE_SCHEMA = @db_name AND TABLE_NAME = 'lq_employee_profile' AND COLUMN_NAME = 'F_IdCardBackUrl'
);
SET @sql = IF(@col_exists = 0,
  'ALTER TABLE `lq_employee_profile` ADD COLUMN `F_IdCardBackUrl` varchar(500) DEFAULT NULL COMMENT ''身份证反面照片 URL'' AFTER `F_IdCardFrontUrl`;',
  'SELECT ''lq_employee_profile.F_IdCardBackUrl 已存在'';'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

-- lq_employee_profile_submission.F_BankAccountName
SET @col_exists = (
  SELECT COUNT(1) FROM information_schema.COLUMNS
  WHERE TABLE_SCHEMA = @db_name AND TABLE_NAME = 'lq_employee_profile_submission' AND COLUMN_NAME = 'F_BankAccountName'
);
SET @sql = IF(@col_exists = 0,
  'ALTER TABLE `lq_employee_profile_submission` ADD COLUMN `F_BankAccountName` varchar(128) DEFAULT NULL COMMENT ''开户实名（开户人真实姓名）'' AFTER `F_BankCardCipher`;',
  'SELECT ''lq_employee_profile_submission.F_BankAccountName 已存在'';'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

-- lq_employee_profile_submission.F_IdCardAddress
SET @col_exists = (
  SELECT COUNT(1) FROM information_schema.COLUMNS
  WHERE TABLE_SCHEMA = @db_name AND TABLE_NAME = 'lq_employee_profile_submission' AND COLUMN_NAME = 'F_IdCardAddress'
);
SET @sql = IF(@col_exists = 0,
  'ALTER TABLE `lq_employee_profile_submission` ADD COLUMN `F_IdCardAddress` varchar(500) DEFAULT NULL COMMENT ''身份证地址（完整地址，独立于籍贯）'' AFTER `F_BankAccountName`;',
  'SELECT ''lq_employee_profile_submission.F_IdCardAddress 已存在'';'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

-- lq_employee_profile_submission.F_IdCardFrontUrl
SET @col_exists = (
  SELECT COUNT(1) FROM information_schema.COLUMNS
  WHERE TABLE_SCHEMA = @db_name AND TABLE_NAME = 'lq_employee_profile_submission' AND COLUMN_NAME = 'F_IdCardFrontUrl'
);
SET @sql = IF(@col_exists = 0,
  'ALTER TABLE `lq_employee_profile_submission` ADD COLUMN `F_IdCardFrontUrl` varchar(500) DEFAULT NULL COMMENT ''身份证正面照片 URL'' AFTER `F_IdCardAddress`;',
  'SELECT ''lq_employee_profile_submission.F_IdCardFrontUrl 已存在'';'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

-- lq_employee_profile_submission.F_IdCardBackUrl
SET @col_exists = (
  SELECT COUNT(1) FROM information_schema.COLUMNS
  WHERE TABLE_SCHEMA = @db_name AND TABLE_NAME = 'lq_employee_profile_submission' AND COLUMN_NAME = 'F_IdCardBackUrl'
);
SET @sql = IF(@col_exists = 0,
  'ALTER TABLE `lq_employee_profile_submission` ADD COLUMN `F_IdCardBackUrl` varchar(500) DEFAULT NULL COMMENT ''身份证反面照片 URL'' AFTER `F_IdCardFrontUrl`;',
  'SELECT ''lq_employee_profile_submission.F_IdCardBackUrl 已存在'';'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
