|
| 1 | +import type { CheckResult } from '../lithium/shared/types' |
| 2 | + |
| 3 | +function matchContactInfo(info: string) { |
| 4 | + // 电话/Tel:000-1646464 |
| 5 | + // 邮箱/Mail:abc@gmail.com |
| 6 | + const telRegex = /电话\s?\/\s?Tel\s?[::]?\s*([^\s]+)/ |
| 7 | + const mailRegex = /邮箱\s?\/\s?Mail\s?[::]?\s*([^\s]+)/ |
| 8 | + const websiteRegex = /网址\s?\/\s?Website\s?[::]?\s*([^\s]+)/ |
| 9 | + |
| 10 | + const telMatch = info.match(telRegex) |
| 11 | + const mailMatch = info.match(mailRegex) |
| 12 | + const websiteMatch = info.match(websiteRegex) |
| 13 | + const tel = telMatch ? telMatch[1].trim() : null |
| 14 | + const mail = mailMatch ? mailMatch[1].trim() : null |
| 15 | + const website = websiteMatch ? websiteMatch[1].trim() : null |
| 16 | + |
| 17 | + console.log('匹配结果:', {info, tel, mail, website }) |
| 18 | + return { tel, mail, website } |
| 19 | +} |
| 20 | + |
| 21 | +export function checkContactInfo( |
| 22 | + systemConsignor: string | undefined, |
| 23 | + systemManufacturer: string | undefined, |
| 24 | + summaryConsignorInfo: string, |
| 25 | + summaryManufacturerInfo: string, |
| 26 | +): CheckResult[] { |
| 27 | + if (systemConsignor === systemManufacturer) { |
| 28 | + return [] |
| 29 | + } |
| 30 | + const results: CheckResult[] = [] |
| 31 | + const { tel: consignorTel, mail: consignorMail, website: consignorWebsite } = matchContactInfo(summaryConsignorInfo) |
| 32 | + const { tel: manufacturerTel, mail: manufacturerMail, website: manufacturerWebsite } = matchContactInfo(summaryManufacturerInfo) |
| 33 | + |
| 34 | + if (consignorTel && manufacturerTel && consignorTel === manufacturerTel) { |
| 35 | + results.push({ |
| 36 | + ok: false, |
| 37 | + result: '委托方和制造商联系电话一致, 可能存在信息错误', |
| 38 | + }) |
| 39 | + } |
| 40 | + if (consignorMail && manufacturerMail && consignorMail === manufacturerMail) { |
| 41 | + results.push({ |
| 42 | + ok: false, |
| 43 | + result: '委托方和制造商邮箱一致, 可能存在信息错误', |
| 44 | + }) |
| 45 | + } |
| 46 | + if (consignorWebsite && manufacturerWebsite && consignorWebsite === manufacturerWebsite) { |
| 47 | + results.push({ |
| 48 | + ok: false, |
| 49 | + result: '委托方和制造商网址一致, 可能存在信息错误', |
| 50 | + }) |
| 51 | + } |
| 52 | + return results |
| 53 | +} |
0 commit comments