Ver Fonte

fix(payroll): restrict fee repair to reviewed lesson IDs

彭峰 há 15 horas atrás
pai
commit
4034a9230f
1 ficheiros alterados com 7 adições e 1 exclusões
  1. 7 1
      scripts/reconcile-legacy-lesson-pay.mjs

+ 7 - 1
scripts/reconcile-legacy-lesson-pay.mjs

@@ -104,7 +104,12 @@ async function main() {
     source({ modelId: 59, myfield2: 'jsmz=' + coachId }),
     source({ uid: coachId, nid: 29, myfield2: 'pl=' + coachId, orders: 'B.yysj=DESC', dszt: 30, xiaokejilu: 1 }),
   ]);
-  const evidence = legacyLessonPayEvidence(lessons, appointments, coachId);
+  const allEvidence = legacyLessonPayEvidence(lessons, appointments, coachId);
+  const requested = opt('--lesson-ids');
+  const ids = new Set(requested?.split(',') ?? []);
+  if ([...ids].some(id => !/^[1-9]\d*$/.test(id))) throw Error('课次编号格式无效');
+  const evidence = requested ? allEvidence.filter(row => ids.has(row.generalId)) : allEvidence;
+  if (requested && evidence.length !== ids.size) throw Error('有指定课次缺少唯一可核验的旧课酬');
   const plan = { company, coachId, evidence };
   const sha256 = createHash('sha256').update(JSON.stringify(plan)).digest('hex');
   await mkdir(out, { recursive: true, mode: 0o700 });
@@ -152,6 +157,7 @@ async function main() {
   try {
     id = (await parse('/classes/Function', 'POST', { name, path: name, code, type: 'standalone', enabled: true, params: [], paramList: [], respType: 'json' }, true)).objectId;
     const expected = await invoke({ mode: 'preview' });
+    if (requested && expected.length !== evidence.length) throw Error('指定课次的线上状态已变化,请重新核对');
     await save('before-' + sha256 + '.json', expected);
     const changed = await invoke({ mode: 'apply', expected });
     await save('receipt-' + sha256 + '.json', changed);