|
@@ -35,11 +35,16 @@ async function directReviewFeeProof(co,rows,includePending=false) {
|
|
|
LEFT JOIN "LegacyReviewSyncState" s ON s.company=m.company AND s."taskId"=m."objectId"
|
|
LEFT JOIN "LegacyReviewSyncState" s ON s.company=m.company AND s."taskId"=m."objectId"
|
|
|
WHERE c.company=$1 AND c."modelId"=60 AND c."generalId"=ANY($2::numeric[]) AND m.fxzt='1'
|
|
WHERE c.company=$1 AND c."modelId"=60 AND c."generalId"=ANY($2::numeric[]) AND m.fxzt='1'
|
|
|
AND ($3 OR NOT COALESCE(s."pendingIncome",false)) AND v.status IN ('historical','exception')
|
|
AND ($3 OR NOT COALESCE(s."pendingIncome",false)) AND v.status IN ('historical','exception')
|
|
|
- AND (v."incomeMonth">='2026-09' OR xs_legacy_review_needs_fee(m.company,m."objectId"))
|
|
|
|
|
|
|
+ AND (v."incomeMonth">='2026-09' OR EXISTS(
|
|
|
|
|
+ SELECT 1 FROM "CommonModel" o JOIN "CourseAppointment" a ON a.company=o.company AND a.id=o."itemId"
|
|
|
|
|
+ WHERE o.company=m.company AND o."modelId"=54 AND a.szyh::text=m.yhid::text AND a.dslx::text='3'
|
|
|
|
|
+ AND o."generalId"=CASE WHEN m."orderId"::text ~ '^[1-9][0-9]*$' THEN m."orderId"::numeric END
|
|
|
|
|
+ ))
|
|
|
AND r."completionRole"='historical_unknown'`,[co,ids,includePending]);
|
|
AND r."completionRole"='historical_unknown'`,[co,ids,includePending]);
|
|
|
const verified=new Set(),zeros=new Map(),trials=new Map(),fields=['yhid','plid','xxjlid','orderId','kcid','fxzt','wcsj','kywrq','kywsj'];
|
|
const verified=new Set(),zeros=new Map(),trials=new Map(),fields=['yhid','plid','xxjlid','orderId','kcid','fxzt','wcsj','kywrq','kywsj'];
|
|
|
- const deadline=Date.now()+15000;
|
|
|
|
|
- for(const coach of new Set(candidates.map(row=>Number(row.coachId)))){
|
|
|
|
|
|
|
+ const deadline=Date.now()+24000;
|
|
|
|
|
+ const coaches=[...new Set(candidates.map(row=>Number(row.coachId)))];
|
|
|
|
|
+ async function readCoachFees(coach){
|
|
|
const coachIds=new Set(candidates.filter(row=>Number(row.coachId)===coach).map(row=>Number(row.generalId)));
|
|
const coachIds=new Set(candidates.filter(row=>Number(row.coachId)===coach).map(row=>Number(row.generalId)));
|
|
|
const income=new Map();
|
|
const income=new Map();
|
|
|
let total, count, read=0;
|
|
let total, count, read=0;
|
|
@@ -70,6 +75,10 @@ async function directReviewFeeProof(co,rows,includePending=false) {
|
|
|
console.warn(JSON.stringify({event:'legacy_review_income_proof_unavailable',coach}));
|
|
console.warn(JSON.stringify({event:'legacy_review_income_proof_unavailable',coach}));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ // A slow coach account must not consume the whole source page's proof budget.
|
|
|
|
|
+ for(let i=0;i<coaches.length&&Date.now()<deadline;i+=3){
|
|
|
|
|
+ await Promise.all(coaches.slice(i,i+3).map(readCoachFees));
|
|
|
|
|
+ }
|
|
|
if(zeros.size){
|
|
if(zeros.size){
|
|
|
const zeroRows=rows.filter(row=>zeros.has(Number(row.GeneralID??row.generalId)));
|
|
const zeroRows=rows.filter(row=>zeros.has(Number(row.GeneralID??row.generalId)));
|
|
|
try{
|
|
try{
|