plan-templates.js 7.9 KB
/**
 * 计划书模版配置
 *
 * @description 定义产品 form_sn 到模版组件和配置的映射关系
 * @module config/plan-templates
 * @author Claude Code
 * @created 2026-02-06
 */

/**
 * 计划书模版配置映射
 * @description form_sn 为产品 API 返回的字段,用于标识该产品使用的计划书模版
 *
 * @example
 * // 产品 API 返回
 * {
 *   id: 1,
 *   product_name: "WIOP3E 盈传创富保障计划 3 - 优选版",
 *   form_sn: "life-insurance-wiop3e"  // 对应下面的配置 key
 * }
 */
export const PLAN_TEMPLATES = {
  // 人寿保险产品 - WIOP3E
  'life-insurance-wiop3e': {
    name: 'WIOP3E 盈传创富保障计划 3 - 优选版',
    component: 'LifeInsuranceTemplate',
    config: {
      currency: 'USD', // 币种:USD/CNY/HKD/EUR
      payment_periods: [
        // 缴费年期选项
        '整付(0-75 岁)',
        '5 年(0-70 岁)',
        '10 年(0-70 岁)'
      ],
      age_range: { min: 0, max: 75 }, // 年龄范围
      insurance_period: '终身' // 保险期间
    }
  },

  // 人寿保险产品 - WIOP3
  'life-insurance-wiop3': {
    name: 'WIOP3 - 盈传创富保障计划 3',
    component: 'LifeInsuranceTemplate',
    config: {
      currency: 'USD',
      payment_periods: [
        '整付(0-75 岁)',
        '5 年(0-70 岁)',
        '10 年(0-70 岁)'
      ],
      age_range: { min: 0, max: 75 },
      insurance_period: '终身'
    }
  },

  // 重疾保险产品 - MPC
  'critical-illness-mpc': {
    name: 'MPC 守护无间重疾',
    component: 'CriticalIllnessTemplate',
    config: {
      currency: 'CNY',
      payment_periods: [
        '10 年(15 日 - 65 岁)',
        '20 年(15 日 - 65 岁)',
        '25 年(15 日 - 60 岁)'
      ],
      age_range: { min: 0, max: 65 },
      insurance_period: '终身'
    }
  },

  // 重疾保险产品 - MBC PRO
  'critical-illness-mbc-pro': {
    name: 'MBC PRO 活跃人生重疾保 PRO',
    component: 'CriticalIllnessTemplate',
    config: {
      currency: 'CNY',
      payment_periods: [
        '10 年(15 日 - 65 岁)',
        '20 年(15 日 - 65 岁)',
        '25 年(15 日 - 60 岁)'
      ],
      age_range: { min: 0, max: 65 },
      insurance_period: '终身'
    }
  },

  // 重疾保险产品 - MBC2
  'critical-illness-mbc2': {
    name: 'MBC2 活跃人生重疾保 2',
    component: 'CriticalIllnessTemplate',
    config: {
      currency: 'CNY',
      payment_periods: [
        '10 年(15 日 - 65 岁)',
        '20 年(15 日 - 65 岁)',
        '25 年(15 日 - 60 岁)'
      ],
      age_range: { min: 0, max: 65 },
      insurance_period: '终身'
    }
  },

  // ====== 储蓄型产品(统一逻辑) ======

  // GS - 宏摯傳承保障計劃
  'savings-gs': {
    name: '宏摯傳承保障計劃',
    component: 'SavingsTemplate',
    category: 'savings', // 储蓄型产品
    config: {
      currency: 'USD', // 默认美元
      payment_periods: [
        '整付(0-100 岁)',
        '5 年(0-80 岁)',
        '10 年(0-75 岁)'
      ],
      age_range: { min: 0, max: 100 },
      insurance_period: '终身',
      // 提取计划配置
      withdrawal_plan: {
        enabled: true,
        currencies: ['HKD', 'USD', 'CNY'], // 支持的币种
        default_currency: 'HKD',
        withdrawal_modes: [
          '年龄指定金额', // 方式1
          '最高固定金额'  // 方式2
        ],
        withdrawal_periods: [
          '1年',
          '2年',
          '3年',
          '5年',
          '10年',
          '15年',
          '20年',
          '终身'
        ]
      }
    }
  },

  // GC - 宏摯家傳承保險計劃
  'savings-gc': {
    name: '宏摯家傳承保險計劃',
    component: 'SavingsTemplate',
    category: 'savings',
    config: {
      currency: 'USD',
      payment_periods: [
        '整付(0-100 岁)',
        '5 年(0-80 岁)',
        '10 年(0-75 岁)'
      ],
      age_range: { min: 0, max: 100 },
      insurance_period: '终身',
      withdrawal_plan: {
        enabled: true,
        currencies: ['HKD', 'USD', 'CNY'],
        default_currency: 'HKD',
        withdrawal_modes: ['年龄指定金额', '最高固定金额'],
        withdrawal_periods: [
          '1年',
          '2年',
          '3年',
          '5年',
          '10年',
          '15年',
          '20年',
          '终身'
        ]
      }
    }
  },

  // FA - 宏浚傳承保障計劃
  'savings-fa': {
    name: '宏浚傳承保障計劃',
    component: 'SavingsTemplate',
    category: 'savings',
    config: {
      currency: 'USD',
      payment_periods: [
        '整付(0-100 岁)',
        '5 年(0-80 岁)',
        '10 年(0-75 岁)'
      ],
      age_range: { min: 0, max: 100 },
      insurance_period: '终身',
      withdrawal_plan: {
        enabled: true,
        currencies: ['HKD', 'USD', 'CNY'],
        default_currency: 'HKD',
        withdrawal_modes: ['年龄指定金额', '最高固定金额'],
        withdrawal_periods: [
          '1年',
          '2年',
          '3年',
          '5年',
          '10年',
          '15年',
          '20年',
          '终身'
        ]
      }
    }
  },

  // LV2 - 赤霞珠終身壽險計劃2(储蓄型终身寿险)
  'savings-lv2': {
    name: '赤霞珠終身壽險計劃2',
    component: 'SavingsTemplate',
    category: 'savings',
    config: {
      currency: 'USD',
      payment_periods: [
        '整付(0-100 岁)',
        '5 年(0-80 岁)',
        '10 年(0-75 岁)'
      ],
      age_range: { min: 0, max: 100 },
      insurance_period: '终身',
      withdrawal_plan: {
        enabled: true,
        currencies: ['HKD', 'USD', 'CNY'],
        default_currency: 'HKD',
        withdrawal_modes: ['年龄指定金额', '最高固定金额'],
        withdrawal_periods: [
          '1年',
          '2年',
          '3年',
          '5年',
          '10年',
          '15年',
          '20年',
          '终身'
        ]
      }
    }
  }
}

/**
 * 全局功能开关
 * @description 用于控制实验性功能或未来扩展功能的开关
 *
 * @example 开启多币种功能:设置 MULTI_CURRENCY_ENABLED = true
 */
export const FEATURE_FLAGS = {
  /**
   * 多币种切换功能
   * @description false: 方案 1 - 固定币种(当前实现)
   *              true: 方案 2 - 支持多币种切换(未来扩展)
   * @type {boolean}
   */
  MULTI_CURRENCY_ENABLED: false
}

/**
 * 币种符号映射
 * @description 币种代码到符号的映射关系
 */
export const CURRENCY_SYMBOLS = {
  CNY: '¥', // 人民币
  USD: '$', // 美元
  HKD: 'HK$', // 港币
  EUR: '€' // 欧元
}

/**
 * 币种完整信息映射
 * @description 币种代码到完整信息的映射(用于多币种模式)
 */
export const CURRENCY_MAP = {
  CNY: { label: '人民币', symbol: '¥', value: 'CNY' },
  USD: { label: '美元', symbol: '$', value: 'USD' },
  HKD: { label: '港币', symbol: 'HK$', value: 'HKD' },
  EUR: { label: '欧元', symbol: '€', value: 'EUR' }
}

/**
 * 根据 form_sn 获取模版配置
 * @param {string} formSn - 产品 API 返回的 form_sn 字段
 * @returns {Object|null} 模版配置对象,未找到返回 null
 *
 * @example
 * const config = getTemplateConfig('life-insurance-wiop3e')
 * // 返回: { name: 'WIOP3E...', component: 'LifeInsuranceTemplate', config: {...} }
 */
export function getTemplateConfig(formSn) {
  if (!formSn) {
    console.warn('[plan-templates] form_sn 为空')
    return null
  }

  const config = PLAN_TEMPLATES[formSn]
  if (!config) {
    console.error(`[plan-templates] 未找到模版配置: ${formSn}`)
    return null
  }

  return config
}

/**
 * 获取币种符号
 * @param {string} currencyCode - 币种代码(CNY/USD/HKD/EUR)
 * @returns {string} 币种符号
 *
 * @example
 * const symbol = getCurrencySymbol('USD') // 返回: '$'
 */
export function getCurrencySymbol(currencyCode) {
  return CURRENCY_SYMBOLS[currencyCode] || '¥'
}