async function enrollmentOrderTransition(input,current,order,orderId,status){ const row=await Psql.oneOrNone('SELECT "objectId","sourceKey" FROM "CommonModel" WHERE "company"=$1 AND "modelId"=54 AND "generalId"::text=$2',[DEFAULT_COMPANY_ID,String(orderId)]);if(!row)fail(404,'预约不存在'); if(status!==10)fail(409,'请使用老师一次结课入口'); if(number(order.dszt)===0&&/^legacy[:\-]/.test(row.sourceKey||'')){const prepared=await prepareLegacyAppointment(row,current);if(prepared.blockedReason)fail(409,prepared.blockedReason);} let learning; if(input.learningBindingId)learning=await startLessonWithContent(current,row.objectId,input.learningBindingId,input.expectedUpdatedAt); else try{await Psql.one('SELECT xs_start_appointment_for_actor($1,$2,$3,$4) AS result',[DEFAULT_COMPANY_ID,row.objectId,current.id,ownLegacyId(current)]);}catch(error){fail(409,String(error.message));} return{GeneralID:orderId,status,previousStatus:number(order.dszt),learning}; }