/** * 批量更新公积金账户的 housingBaseMin/housingBaseMax * 数据来源:各城市2025年度公积金缴存基数上下限 */ import { PrismaClient } from '@prisma/client' const prisma = new PrismaClient() // 2025年度各城市公积金基数上下限 const CITY_LIMITS: Record = { '北京': { min: 2540, max: 35811 }, '上海': { min: 2690, max: 37302 }, '深圳': { min: 2360, max: 44265 }, '杭州': { min: 2490, max: 40694 }, '石家庄': { min: 2200, max: 26420 }, '天津': { min: 2320, max: 27861 }, '唐山': { min: 2200, max: 26420 }, // 河北省标准 } async function main() { const accounts = await prisma.socialAccount.findMany({ where: { type: 'HOUSING' } }) let updated = 0 let skipped = 0 for (const account of accounts) { const limits = CITY_LIMITS[account.city] if (!limits) { console.log(`[跳过] ${account.name} (${account.city}) — 无该城市的公积金上下限数据`) skipped++ continue } // 更新该账户下所有年度标准的 housingBaseMin/housingBaseMax const result = await prisma.socialYearStandard.updateMany({ where: { accountId: account.id }, data: { housingBaseMin: limits.min, housingBaseMax: limits.max, }, }) console.log(`[更新] ${account.name} (${account.city}) → 下限 ${limits.min} / 上限 ${limits.max},影响 ${result.count} 条标准`) updated++ } console.log(`\n完成:更新 ${updated} 个账户,跳过 ${skipped} 个`) } main().then(() => process.exit(0)).catch(e => { console.error(e); process.exit(1) })