开票初始化与随机间隔,新增无火车票版本

This commit is contained in:
cheney
2026-10-20 20:58:48 +08:00
parent 19680aaf90
commit ef22374db7
2 changed files with 418 additions and 0 deletions
+41
View File
@@ -82,6 +82,19 @@ async function batchAdjustInvoiceOrderPrice(settlementSeq, receiveBillId, origin
return resp.json();
}
// ========== 4.5 初始化开票价格信息 ==========
async function initReceiveOrderPrice(settlementSeq, receiveBillId) {
const url = BASE_URL + '/api/tmc/tmc/settlement/receiveInvoice/initReceiveOrderPrice';
const headers = {
...COMMON_HEADERS,
'content-type': 'application/json;charset=UTF-8',
'Referer': BASE_URL + '/new-tmc/finance/settlement/pay/invoice/billing/' + receiveBillId,
};
const body = JSON.stringify({ settlementSeq: settlementSeq });
const resp = await fetch(url, { headers: headers, method: 'POST', body: body });
return resp.json();
}
// ========== 5. 确认开票 ==========
async function confirmInvoiceOrder(settlementSeq, receiveBillId) {
const url = BASE_URL + '/api/tmc/tmc/settlement/receiveInvoice/confirmInvoiceOrder';
@@ -190,6 +203,9 @@ async function processTrainBill(bill, billIndex, totalBills) {
console.log(' --- 火车票 [' + billIndex + '/' + totalBills + '] ' + bill.statementName + ' ---');
const initResp = await initReceiveOrderPrice(settlementSeq, receiveBillId);
console.log(' -> initReceiveOrderPrice:', JSON.stringify(initResp));
const confirmResp = await confirmInvoiceOrder(settlementSeq, receiveBillId);
console.log(' -> confirmInvoiceOrder:', JSON.stringify(confirmResp));
@@ -221,6 +237,9 @@ async function processHotelBill(bill, billIndex, totalBills) {
return;
}
const initResp = await initReceiveOrderPrice(settlementSeq, receiveBillId);
console.log(' -> initReceiveOrderPrice:', JSON.stringify(initResp));
const confirmResp = await confirmInvoiceOrder(settlementSeq, receiveBillId);
console.log(' -> confirmInvoiceOrder:', JSON.stringify(confirmResp));
@@ -259,6 +278,9 @@ async function processFlightBill(bill, billIndex, totalBills) {
return;
}
const initResp = await initReceiveOrderPrice(settlementSeq, receiveBillId);
console.log(' -> initReceiveOrderPrice:', JSON.stringify(initResp));
const confirmResp = await confirmInvoiceOrder(settlementSeq, receiveBillId);
console.log(' -> confirmInvoiceOrder:', JSON.stringify(confirmResp));
@@ -283,6 +305,9 @@ async function processInternationalFlightBill(bill, billIndex, totalBills) {
console.log(' --- 国际机票 [' + billIndex + '/' + totalBills + '] ' + bill.statementName + ' ---');
const initResp = await initReceiveOrderPrice(settlementSeq, receiveBillId);
console.log(' -> initReceiveOrderPrice:', JSON.stringify(initResp));
const confirmResp = await confirmInvoiceOrder(settlementSeq, receiveBillId);
console.log(' -> confirmInvoiceOrder:', JSON.stringify(confirmResp));
@@ -300,6 +325,15 @@ async function processInternationalFlightBill(bill, billIndex, totalBills) {
console.log('');
}
// ========== 15. 随机延时 ==========
function sleep(ms) {
return new Promise(function (resolve) { setTimeout(resolve, ms); });
}
function randomDelaySeconds() {
return Math.floor(15 + Math.random() * 31);
}
// ========== 主流程 ==========
async function main() {
const teamIds = readTeamIds();
@@ -310,6 +344,13 @@ async function main() {
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);
}
console.log('[' + (i + 1) + '/' + teamIds.length + '] 处理 ' + teamId + ' ...');
try {