|
|
@@ -290,3 +290,34 @@ test('旧来源未完成任务可跟进老师切换,后续完成不再因老
|
|
|
assert.equal(result.data.updated,1,'可信旧来源的老师切换应同步');
|
|
|
assert.equal((await sql('SELECT plid FROM "MemoryPracticeRecord" WHERE id=302'))[0].plid,'31');
|
|
|
});
|
|
|
+
|
|
|
+test('旧预约换编号或改到新系统时段,原子保留新课与时长;不相同时继续导入',async()=>{
|
|
|
+ await sql("UPDATE \"LegacyDirectRun\" SET status='running',\"leaseUntil\"=now()+interval '5 minutes' WHERE \"runId\"=$1",[runId]);
|
|
|
+ await db.exec(`ALTER TABLE "_User" ADD COLUMN IF NOT EXISTS "legacyGroupId" numeric, ADD COLUMN IF NOT EXISTS "isDisabled" boolean;
|
|
|
+ CREATE TABLE IF NOT EXISTS "CourseCreditReservation"(company text,"appointmentId" text);
|
|
|
+ INSERT INTO "_User" ("objectId",company,username,"legacyUserId","legacyGroupId") VALUES('student-book','co','student-book',7801,1);
|
|
|
+ INSERT INTO "CourseAppointment"("objectId",company,id,"sourceKey",szyh,pl,kcid,yykcid,yysj,bxrq,dszt,dslx)
|
|
|
+ VALUES('native-a','co',8700,'schedule:native','7801','76','170','170','2099-12-01 21:00','2099-12-01','0','1');
|
|
|
+ INSERT INTO "CommonModel"("objectId",company,"modelId","itemId","generalId",status,"sourceKey")
|
|
|
+ VALUES('native-c','co',54,8700,8700,99,'schedule:native')`);
|
|
|
+ const append=(id,fields={})=>({action:'append',modelId:54,batchKey:'book-'+id,rows:[{generalId:id,common:{objectId:'c'+id,status:99},addon:{
|
|
|
+ objectId:'a'+id,id,szyh:'7801',pl:'76',kcid:'170',yykcid:'170',yysj:'2099-12-01 21:00:00',bxrq:'2099-12-01',dszt:'0',dslx:'2',...fields}}]});
|
|
|
+ const run=async req=>{const r=await call(req);assert.equal(r.success,true,r.message);return r.data};
|
|
|
+ const native=()=>sql(`SELECT to_jsonb(c) c,to_jsonb(a) a FROM "CommonModel" c JOIN "CourseAppointment" a ON c."itemId"=a.id WHERE c."objectId"='native-c'`);
|
|
|
+ const before=await native();const added=await run(append(8711));assert.equal(added.postimages[0].common.status,-2);assert.equal(added.duplicates,1);
|
|
|
+ assert.equal((await run(append(8711))).postimages[0].common.status,-2);
|
|
|
+ assert.equal((await run(append(8712))).postimages[0].common.status,-2);
|
|
|
+ for(const [i,change] of [{pl:'77'},{szyh:'7802'},{kcid:'180',yykcid:'180'},{yysj:'2099-12-01 21:30'},{dszt:'10'},{yykcid:'180'}].entries()){
|
|
|
+ assert.equal((await run(append(8720+i,change))).postimages[0].common.status,99);
|
|
|
+ }
|
|
|
+ const moved=(await run(append(8730,{yysj:'2099-12-01 19:00'}))).postimages[0];
|
|
|
+ const patch=(row,yysj,batchKey)=>({action:'patch',modelId:54,batchKey,rows:[{generalId:row.common.generalId,commonId:row.common.objectId,
|
|
|
+ addonId:row.addon.objectId,commonVersion:row.common.updatedAt,addonVersion:row.addon.updatedAt,values:{yysj}}]});
|
|
|
+ const shifted=(await run(patch(moved,'2099-12-01 21:00','book-patch'))).postimages[0];assert.equal(shifted.common.status,-2);
|
|
|
+ assert.equal((await run(patch(shifted,'2099-12-01 20:00','book-cancelled-patch'))).updated,0);
|
|
|
+ await sql('INSERT INTO "CourseCreditReservation"(company,"appointmentId") VALUES($1,$2)',['co','c8740']);
|
|
|
+ assert.equal((await run(append(8740))).postimages[0].common.status,99);
|
|
|
+ await sql('INSERT INTO "LessonRecord"(company,"objectId",id,yyds) VALUES($1,$2,$3,$4)',['co','lesson-8741',9741,'8741']);
|
|
|
+ assert.equal((await run(append(8741))).postimages[0].common.status,99);
|
|
|
+ assert.deepEqual(await native(),before);
|
|
|
+});
|