147 lines
5.4 KiB
TypeScript
147 lines
5.4 KiB
TypeScript
export const CORP_GOODS_TYPES = ['license_year', 'license_destory', 'credit_repair'] as const
|
||
|
||
export type CorpGoodsType = (typeof CORP_GOODS_TYPES)[number]
|
||
|
||
const RECEIPT_META: Record<CorpGoodsType, { title: string, description: string }> = {
|
||
credit_repair: {
|
||
title: '工商信息修复回执单',
|
||
description:
|
||
'信用网站官网 https://www.creditchina.gov.cn/\n' +
|
||
'搜索企业: 在首页搜索框输入公司全称或统一社会信用代码进行查询\n' +
|
||
'查看信用信息: 进入企业信用信息详情页;\n' +
|
||
'重点关注:\n' +
|
||
'1."行政处罚"栏目: 查看该条被修复的行政处罚信息状态。如果修复成功,通常会显示"已修复"、"已信用修复"、"已撤下"等状态标识,或者该条信息已不再显示在公示列表中;\n' +
|
||
'2."信用修复"栏目(如果有): 有些平台会单独列出企业的信用修复申请记录及状态(如:申请中、审核通过/修复成功、审核不通过);\n' +
|
||
'3.查看"失信信息"或"重点关注名单": 如果该处罚曾导致企业被列入失信名单或重点关注名单,确认这些名单中是否已移除该公司;',
|
||
},
|
||
license_destory: {
|
||
title: '工商信息注销回执单',
|
||
description:
|
||
'访问官网(http://www.gsxt.gov.cn),输入企业名称或统一社会信用代码进行搜索。\n' +
|
||
'在企业详情页面查看“登记状态”栏是否标注为“注销”\n' +
|
||
'注意:注销信息通常需1-3天完成公示更新,建议完成注销流程后次日查询。',
|
||
},
|
||
license_year: {
|
||
title: '信息申报回执单',
|
||
description:
|
||
'年报国家公示官网:https://www.gsxt.gov.cn\n' +
|
||
'1.年报公示日期为7个工作日,到期后可自行登陆国家企业信用信息官网查询;\n' +
|
||
'2.您的个人信息(姓名、电话、身份证),只用于您办理业务时使用;\n' +
|
||
'3.企业一站式服务平台为第三方企业服务公司,办理业务方便快捷,办理不成功退全部费用;',
|
||
},
|
||
}
|
||
|
||
export function isCorpGoodsType (goodsType?: string): goodsType is CorpGoodsType {
|
||
return (CORP_GOODS_TYPES as readonly string[]).includes(goodsType || '')
|
||
}
|
||
|
||
export function shouldShowReceipt (goodsType?: string) {
|
||
return isCorpGoodsType(goodsType)
|
||
}
|
||
|
||
export function pickGoodsType (payload: any): string {
|
||
const data = payload?.data ?? payload ?? {}
|
||
const prev = data.prev_info ?? data.prevInfo ?? payload?.prevInfo ?? {}
|
||
const fromPrev = String(prev.goods_type || prev.type || '').trim()
|
||
if (fromPrev) return fromPrev
|
||
|
||
const goods = Array.isArray(data.goods) ? data.goods : []
|
||
const first = goods[0] || {}
|
||
return String(first.goods_type || first.type || '').trim()
|
||
}
|
||
|
||
export function getReceiptMeta (goodsType?: string, goodsName?: string) {
|
||
if (isCorpGoodsType(goodsType)) {
|
||
return RECEIPT_META[goodsType]
|
||
}
|
||
const name = String(goodsName || '').trim()
|
||
return {
|
||
title: name ? `${name}回执单` : '回执单',
|
||
description: '',
|
||
}
|
||
}
|
||
|
||
export type OrderFile = {
|
||
id?: string
|
||
url?: string
|
||
}
|
||
|
||
function isPdfUrl (url: string) {
|
||
return /\.pdf(?:$|[?#])/i.test(url)
|
||
}
|
||
|
||
export function splitOrderFiles (files?: OrderFile[] | null) {
|
||
const images: OrderFile[] = []
|
||
const pdfs: OrderFile[] = []
|
||
|
||
for (const file of files || []) {
|
||
const url = typeof file?.url === 'string' ? file.url.replace(/^http:\/\//i, 'https://') : ''
|
||
if (!url) continue
|
||
const nextFile = url === file.url ? file : { ...file, url }
|
||
if (isPdfUrl(url)) pdfs.push(nextFile)
|
||
else images.push(nextFile)
|
||
}
|
||
|
||
return { images, pdfs }
|
||
}
|
||
|
||
export function numberToUpperCase (money: unknown): string {
|
||
const cnNums = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖']
|
||
const cnIntRadice = ['', '拾', '佰', '仟']
|
||
const cnIntUnits = ['', '万', '亿', '兆']
|
||
const cnDecUnits = ['角', '分']
|
||
const cnInteger = '整'
|
||
const cnIntLast = '元'
|
||
|
||
if (money === '' || money === undefined || money === null) return ''
|
||
|
||
const text = String(money)
|
||
const cashText = text.charAt(0) === '-' ? text.slice(1) : text
|
||
let cash = parseFloat(cashText)
|
||
if (cash === 0) return `${cnNums[0]}${cnIntLast}${cnInteger}`
|
||
if (!Number.isFinite(cash)) return ''
|
||
|
||
const [integerNum, rawDecimal = ''] = cash.toString().split('.')
|
||
const decimalNum = rawDecimal.substr(0, 2)
|
||
let chineseStr = ''
|
||
|
||
if (integerNum !== '-' && parseInt(integerNum, 10) > 0) {
|
||
const intLen = integerNum.length
|
||
let zero = 0
|
||
for (let i = 0; i < intLen; i++) {
|
||
const intChar = integerNum.substr(i, 1)
|
||
const intSlen = intLen - i - 1
|
||
const divided = intSlen / 4
|
||
const remain = intSlen % 4
|
||
|
||
if (intChar === '0') {
|
||
zero += 1
|
||
} else {
|
||
if (zero > 0) chineseStr += cnNums[0]
|
||
zero = 0
|
||
chineseStr += cnNums[parseInt(intChar, 10)] + cnIntRadice[remain]
|
||
}
|
||
if (remain === 0 && divided > 0) {
|
||
chineseStr += cnIntUnits[divided]
|
||
}
|
||
}
|
||
chineseStr += cnIntLast
|
||
}
|
||
|
||
if (decimalNum) {
|
||
for (let i = 0; i < decimalNum.length; i++) {
|
||
const decChar = decimalNum.substr(i, 1)
|
||
if (decChar !== '0') {
|
||
chineseStr += cnNums[parseInt(decChar, 10)] + cnDecUnits[i]
|
||
}
|
||
if (decChar === '0' && parseInt(integerNum, 10) > 0) {
|
||
chineseStr += cnNums[0] + cnDecUnits[i]
|
||
}
|
||
}
|
||
} else {
|
||
chineseStr += cnInteger
|
||
}
|
||
|
||
return chineseStr
|
||
}
|