// 将数字转换成大写中文
export const dealFigureToChinese = (figure: string) => {
  figure = `${figure}`
  const len = figure.length - 1
  const idxs = ['', '十', '百', '千', '万', '十', '百', '千', '亿', '十', '百', '千', '万', '十', '百', '千', '亿']
  const num = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九']
  return figure.replace(/([1-9]|0+)/g, (data, data1, idx, full) => {
    let pos = 0
    if (data1[0] != '0') {
      pos = len - idx
      if (idx == 0 && data1[0] == 1 && idxs[len - idx] == '十')
        return idxs[len - idx]

      return num[data1[0]] + idxs[len - idx]
    }
    else {
      const left = len - idx
      const right = len - idx + data1.length
      if (Math.floor(right / 4) - Math.floor(left / 4) > 0)
        pos = left - left % 4

      if (pos)
        return idxs[pos] + num[data1[0]]
      else if (idx + data1.length >= len)
        return ''
      else
        return num[data1[0]]
    }
  })
}
