legacy-writing-sync-ownership.js 1.0 KB

12345678910111213141516171819202122
  1. const syncWritingEvidencePrefix = '同步自动核对:';
  2. function hasSyncWritingPlan(appointment) {
  3. return appointment?.kcid === '398' &&
  4. ['primary_writing', 'middle_writing', 'high_writing'].includes(appointment.courseCategoryKey) &&
  5. String(appointment.categoryEvidence || '').startsWith(syncWritingEvidencePrefix);
  6. }
  7. async function syncWritingHasTeachingEvidence(db, companyId, common, appointment) {
  8. return Boolean(await db.oneOrNone(`
  9. SELECT 1 WHERE EXISTS (
  10. SELECT 1 FROM "CourseCreditReservation" WHERE company=$1 AND "appointmentId"=$2
  11. ) OR EXISTS (
  12. SELECT 1 FROM "LessonRecord" WHERE company=$1 AND yyds::text=ANY($3::text[])
  13. ) OR EXISTS (
  14. SELECT 1 FROM "LessonRecordFact" WHERE company=$1 AND yyds::text=ANY($3::text[])
  15. ) OR EXISTS (
  16. SELECT 1 FROM "LessonCompletionReport" WHERE company=$1
  17. AND ("appointmentId"=$2 OR "appointmentGeneralId"::text=ANY($3::text[]))
  18. )
  19. `, [companyId, common.objectId, [String(common.generalId), String(appointment.id)]]));
  20. }