优化
This commit is contained in:
@@ -227,14 +227,9 @@ async function execute(context, { scope, writeMeasured = false, idempotencyNames
|
||||
}
|
||||
if (scope === 'QUOTES_ONLY') {
|
||||
const customer = requireQuoteCustomer(context)
|
||||
const supplier = context.options?.fixedCustomerId
|
||||
? await (await import('./finance-full-fixtures.mjs')).loadSupplier(context, 'TRUCKING', { truckingScope: 'OVERSEAS' })
|
||||
: await command('POST', '/api/platform/v1/suppliers?tenantId=0', {
|
||||
name: `车辆报价验收-${context.marker}`, category: 'TRUCKING', truckingScope: 'OVERSEAS', carrierCodes: [], status: 'ACTIVE', remark: context.marker,
|
||||
region: 'TEST', legalRepresentative: '测试法人', contactName: '测试联系人', phone: '19900000000', email: 'fleet-acceptance@example.com', settlementPeriod: 'MONTHLY_30',
|
||||
}, '新建本轮海外车队供应商')
|
||||
const supplier = await (await import('./finance-full-fixtures.mjs')).loadSupplier(context, 'TRUCKING', { truckingScope: 'OVERSEAS' })
|
||||
if (!supplier) throw new Error('缺少现有海外拖车供应商,不自动创建')
|
||||
proof.supplierReused = Boolean(context.options?.fixedCustomerId)
|
||||
proof.supplierReused = true
|
||||
proof.supplierId = id(supplier.id ?? supplier)
|
||||
check('供应商返回明确标识', null, /^\d+$/.test(proof.supplierId))
|
||||
const day = new Date().toISOString().slice(0, 10)
|
||||
@@ -315,17 +310,6 @@ async function execute(context, { scope, writeMeasured = false, idempotencyNames
|
||||
if (row.status === 'ACTIVE') await command('PATCH', `${QUOTES}/${encode(no)}/status`, { recordVersion: row.recordVersion, status: 'INACTIVE' }, '停用本轮专用报价并保留历史')
|
||||
} catch (error) { cleanupErrors.push(error.message) }
|
||||
}
|
||||
if (proof.supplierId && !proof.supplierReused && !context.quoteRequestOutcomeUnknown) {
|
||||
try {
|
||||
const path = `/api/platform/v1/suppliers/${encode(proof.supplierId)}`
|
||||
const response = await request('PATCH', `${path}/status?tenantId=0`, { status: 'INACTIVE' })
|
||||
context.apiSuccess(MODULE, '停用本轮车队供应商并保留证据', response, '', OPTIONS)
|
||||
check('供应商停用命令成功', response, successful(response))
|
||||
const supplier = await command('GET', `${path}?tenantId=0`, undefined, '回查本轮车队供应商已停用')
|
||||
check('本轮车队供应商最终停用', null, supplier.status === 'INACTIVE' && id(supplier.id) === proof.supplierId)
|
||||
} catch (error) { cleanupErrors.push(error.message) }
|
||||
}
|
||||
proof.cleanup = context.quoteRequestOutcomeUnknown ? 'NOT_ATTEMPTED_UNKNOWN_OUTCOME' : cleanupErrors.length ? 'FAILED' : proof.quotes.length || proof.supplierId ? 'RETAINED_AND_DEACTIVATED' : 'NOTHING_CREATED'
|
||||
if (cleanupErrors.length) { proof.cleanupErrors = cleanupErrors; proof.status = 'FAILED'; failure ||= new Error('本轮报价资源停用失败') }
|
||||
}
|
||||
if (failure) throw failure
|
||||
|
||||
Reference in New Issue
Block a user