移除随机延时

This commit is contained in:
cheney
2026-10-21 20:10:19 +08:00
parent 3b79054995
commit 18941236af
2 changed files with 9 additions and 55 deletions
+4 -25
View File
@@ -193,11 +193,7 @@ async function processHotelBill(bill, billIndex, totalBills) {
} }
const initResp = await initReceiveOrderPrice(settlementSeq, receiveBillId); 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); const confirmResp = await confirmInvoiceOrder(settlementSeq, receiveBillId);
console.log(' -> confirmInvoiceOrder:', JSON.stringify(confirmResp)); console.log(' -> confirmInvoiceOrder:', JSON.stringify(confirmResp));
@@ -238,11 +234,7 @@ async function processFlightBill(bill, billIndex, totalBills) {
} }
const initResp = await initReceiveOrderPrice(settlementSeq, receiveBillId); 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); const confirmResp = await confirmInvoiceOrder(settlementSeq, receiveBillId);
console.log(' -> confirmInvoiceOrder:', JSON.stringify(confirmResp)); console.log(' -> confirmInvoiceOrder:', JSON.stringify(confirmResp));
@@ -269,11 +261,7 @@ async function processInternationalFlightBill(bill, billIndex, totalBills) {
console.log(' --- 国际机票 [' + billIndex + '/' + totalBills + '] ' + bill.statementName + ' ---'); console.log(' --- 国际机票 [' + billIndex + '/' + totalBills + '] ' + bill.statementName + ' ---');
const initResp = await initReceiveOrderPrice(settlementSeq, receiveBillId); 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); const confirmResp = await confirmInvoiceOrder(settlementSeq, receiveBillId);
console.log(' -> confirmInvoiceOrder:', JSON.stringify(confirmResp)); console.log(' -> confirmInvoiceOrder:', JSON.stringify(confirmResp));
@@ -292,16 +280,7 @@ async function processInternationalFlightBill(bill, billIndex, totalBills) {
console.log(''); console.log('');
} }
// ========== 13. 随机延时 ========== // ========== 接口错误检查 ==========
function sleep(ms) {
return new Promise(function (resolve) { setTimeout(resolve, ms); });
}
function randomDelaySeconds() {
return Math.floor(15 + Math.random() * 31);
}
// ========== 接口错误检查 ==========
function ensureOk(resp, what) { function ensureOk(resp, what) {
if (resp && resp.code && resp.code !== 'Z000') { if (resp && resp.code && resp.code !== 'Z000') {
if (resp.code === 'E003') { if (resp.code === 'E003') {
+5 -30
View File
@@ -204,11 +204,7 @@ async function processTrainBill(bill, billIndex, totalBills) {
console.log(' --- 火车票 [' + billIndex + '/' + totalBills + '] ' + bill.statementName + ' ---'); console.log(' --- 火车票 [' + billIndex + '/' + totalBills + '] ' + bill.statementName + ' ---');
const initResp = await initReceiveOrderPrice(settlementSeq, receiveBillId); 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); const confirmResp = await confirmInvoiceOrder(settlementSeq, receiveBillId);
console.log(' -> confirmInvoiceOrder:', JSON.stringify(confirmResp)); console.log(' -> confirmInvoiceOrder:', JSON.stringify(confirmResp));
@@ -242,11 +238,7 @@ async function processHotelBill(bill, billIndex, totalBills) {
} }
const initResp = await initReceiveOrderPrice(settlementSeq, receiveBillId); 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); const confirmResp = await confirmInvoiceOrder(settlementSeq, receiveBillId);
console.log(' -> confirmInvoiceOrder:', JSON.stringify(confirmResp)); console.log(' -> confirmInvoiceOrder:', JSON.stringify(confirmResp));
@@ -287,11 +279,7 @@ async function processFlightBill(bill, billIndex, totalBills) {
} }
const initResp = await initReceiveOrderPrice(settlementSeq, receiveBillId); 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); const confirmResp = await confirmInvoiceOrder(settlementSeq, receiveBillId);
console.log(' -> confirmInvoiceOrder:', JSON.stringify(confirmResp)); console.log(' -> confirmInvoiceOrder:', JSON.stringify(confirmResp));
@@ -318,11 +306,7 @@ async function processInternationalFlightBill(bill, billIndex, totalBills) {
console.log(' --- 国际机票 [' + billIndex + '/' + totalBills + '] ' + bill.statementName + ' ---'); console.log(' --- 国际机票 [' + billIndex + '/' + totalBills + '] ' + bill.statementName + ' ---');
const initResp = await initReceiveOrderPrice(settlementSeq, receiveBillId); 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); const confirmResp = await confirmInvoiceOrder(settlementSeq, receiveBillId);
console.log(' -> confirmInvoiceOrder:', JSON.stringify(confirmResp)); console.log(' -> confirmInvoiceOrder:', JSON.stringify(confirmResp));
@@ -341,16 +325,7 @@ async function processInternationalFlightBill(bill, billIndex, totalBills) {
console.log(''); console.log('');
} }
// ========== 15. 随机延时 ========== // ========== 接口错误检查 ==========
function sleep(ms) {
return new Promise(function (resolve) { setTimeout(resolve, ms); });
}
function randomDelaySeconds() {
return Math.floor(15 + Math.random() * 31);
}
// ========== 接口错误检查 ==========
function ensureOk(resp, what) { function ensureOk(resp, what) {
if (resp && resp.code && resp.code !== 'Z000') { if (resp && resp.code && resp.code !== 'Z000') {
if (resp.code === 'E003') { if (resp.code === 'E003') {