diff --git a/kaipiao-no-train.js b/kaipiao-no-train.js index 678957e..a5dd48c 100644 --- a/kaipiao-no-train.js +++ b/kaipiao-no-train.js @@ -193,7 +193,11 @@ async function processHotelBill(bill, billIndex, totalBills) { } const initResp = await initReceiveOrderPrice(settlementSeq, receiveBillId); - console.log(' -> initReceiveOrderPrice:', JSON.stringify(initResp)); + console.log(' -> initReceiveOrderPrice:', JSON.stringify(initResp)); + + const waitSeconds = randomDelaySeconds(); + console.log(' [延时] 随机等待 ' + waitSeconds + 's 后继续开票...'); + await sleep(waitSeconds * 1000); const confirmResp = await confirmInvoiceOrder(settlementSeq, receiveBillId); console.log(' -> confirmInvoiceOrder:', JSON.stringify(confirmResp)); @@ -234,7 +238,11 @@ async function processFlightBill(bill, billIndex, totalBills) { } const initResp = await initReceiveOrderPrice(settlementSeq, receiveBillId); - console.log(' -> initReceiveOrderPrice:', JSON.stringify(initResp)); + console.log(' -> initReceiveOrderPrice:', JSON.stringify(initResp)); + + const waitSeconds = randomDelaySeconds(); + console.log(' [延时] 随机等待 ' + waitSeconds + 's 后继续开票...'); + await sleep(waitSeconds * 1000); const confirmResp = await confirmInvoiceOrder(settlementSeq, receiveBillId); console.log(' -> confirmInvoiceOrder:', JSON.stringify(confirmResp)); @@ -261,7 +269,11 @@ async function processInternationalFlightBill(bill, billIndex, totalBills) { console.log(' --- 国际机票 [' + billIndex + '/' + totalBills + '] ' + bill.statementName + ' ---'); const initResp = await initReceiveOrderPrice(settlementSeq, receiveBillId); - console.log(' -> initReceiveOrderPrice:', JSON.stringify(initResp)); + console.log(' -> initReceiveOrderPrice:', JSON.stringify(initResp)); + + const waitSeconds = randomDelaySeconds(); + console.log(' [延时] 随机等待 ' + waitSeconds + 's 后继续开票...'); + await sleep(waitSeconds * 1000); const confirmResp = await confirmInvoiceOrder(settlementSeq, receiveBillId); console.log(' -> confirmInvoiceOrder:', JSON.stringify(confirmResp)); @@ -297,15 +309,8 @@ async function main() { return; } - for (let i = 0; i < teamIds.length; i++) { - const teamId = teamIds[i]; - - if (i > 0) { - const waitSeconds = randomDelaySeconds(); - console.log(' [延时] 随机等待 ' + waitSeconds + 's 后处理下一个 TEAM...\n'); - await sleep(waitSeconds * 1000); - } - + for (let i = 0; i < teamIds.length; i++) { + const teamId = teamIds[i]; console.log('[' + (i + 1) + '/' + teamIds.length + '] 处理 ' + teamId + ' ...'); try { diff --git a/kaipiao.js b/kaipiao.js index 4cb182d..167fe99 100644 --- a/kaipiao.js +++ b/kaipiao.js @@ -204,7 +204,11 @@ async function processTrainBill(bill, billIndex, totalBills) { console.log(' --- 火车票 [' + billIndex + '/' + totalBills + '] ' + bill.statementName + ' ---'); const initResp = await initReceiveOrderPrice(settlementSeq, receiveBillId); - console.log(' -> initReceiveOrderPrice:', JSON.stringify(initResp)); + console.log(' -> initReceiveOrderPrice:', JSON.stringify(initResp)); + + const waitSeconds = randomDelaySeconds(); + console.log(' [延时] 随机等待 ' + waitSeconds + 's 后继续开票...'); + await sleep(waitSeconds * 1000); const confirmResp = await confirmInvoiceOrder(settlementSeq, receiveBillId); console.log(' -> confirmInvoiceOrder:', JSON.stringify(confirmResp)); @@ -238,7 +242,11 @@ async function processHotelBill(bill, billIndex, totalBills) { } const initResp = await initReceiveOrderPrice(settlementSeq, receiveBillId); - console.log(' -> initReceiveOrderPrice:', JSON.stringify(initResp)); + console.log(' -> initReceiveOrderPrice:', JSON.stringify(initResp)); + + const waitSeconds = randomDelaySeconds(); + console.log(' [延时] 随机等待 ' + waitSeconds + 's 后继续开票...'); + await sleep(waitSeconds * 1000); const confirmResp = await confirmInvoiceOrder(settlementSeq, receiveBillId); console.log(' -> confirmInvoiceOrder:', JSON.stringify(confirmResp)); @@ -279,7 +287,11 @@ async function processFlightBill(bill, billIndex, totalBills) { } const initResp = await initReceiveOrderPrice(settlementSeq, receiveBillId); - console.log(' -> initReceiveOrderPrice:', JSON.stringify(initResp)); + console.log(' -> initReceiveOrderPrice:', JSON.stringify(initResp)); + + const waitSeconds = randomDelaySeconds(); + console.log(' [延时] 随机等待 ' + waitSeconds + 's 后继续开票...'); + await sleep(waitSeconds * 1000); const confirmResp = await confirmInvoiceOrder(settlementSeq, receiveBillId); console.log(' -> confirmInvoiceOrder:', JSON.stringify(confirmResp)); @@ -306,7 +318,11 @@ async function processInternationalFlightBill(bill, billIndex, totalBills) { console.log(' --- 国际机票 [' + billIndex + '/' + totalBills + '] ' + bill.statementName + ' ---'); const initResp = await initReceiveOrderPrice(settlementSeq, receiveBillId); - console.log(' -> initReceiveOrderPrice:', JSON.stringify(initResp)); + console.log(' -> initReceiveOrderPrice:', JSON.stringify(initResp)); + + const waitSeconds = randomDelaySeconds(); + console.log(' [延时] 随机等待 ' + waitSeconds + 's 后继续开票...'); + await sleep(waitSeconds * 1000); const confirmResp = await confirmInvoiceOrder(settlementSeq, receiveBillId); console.log(' -> confirmInvoiceOrder:', JSON.stringify(confirmResp)); @@ -342,15 +358,8 @@ async function main() { return; } - for (let i = 0; i < teamIds.length; i++) { - const teamId = teamIds[i]; - - if (i > 0) { - const waitSeconds = randomDelaySeconds(); - console.log(' [延时] 随机等待 ' + waitSeconds + 's 后处理下一个 TEAM...\n'); - await sleep(waitSeconds * 1000); - } - + for (let i = 0; i < teamIds.length; i++) { + const teamId = teamIds[i]; console.log('[' + (i + 1) + '/' + teamIds.length + '] 处理 ' + teamId + ' ...'); try {