来源仓库:jxc/ai-fresh-delivery 来源提交:f0b1a180e2deb7e4673b9d1c8542619f7bc0f73d 快照树: 09f679334ff38f0ff25e907961c94a8223bcaedd(与来源 HEAD 工作树逐字节一致,3801 个文件) 按约定本仓库不带任何历史提交:来源仓库的历史中含真实凭据 (生产 SSH 私钥 deploy/id_rsa_tencent、server/.env、.env.tencent/.env.production/.env.gitea、 deploy/小程序AppSecret.txt,其中 MP_APPSECRET / S3 AccessKey 经哈希比对与线上同值), 整包推送会把这些凭据永久带入本仓库,故只取「当前版本」的单提交快照。 供应商系统后续开发自本提交开始。
592 lines
20 KiB
JavaScript
592 lines
20 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* 录单员小程序录单 → 服务端工作流 20→90 全链路
|
|
* 用法: node server/scripts/e2e-customer-mp-flow.mjs
|
|
*/
|
|
import { createRequire } from 'module';
|
|
|
|
const require = createRequire(import.meta.url);
|
|
const { currentCycleCode } = require('./test-helpers.js');
|
|
|
|
const BASE = (process.env.API_BASE || 'https://www.xdjchuanhui.com/api').replace(/\/$/, '');
|
|
const OPERATING_BRANCH = process.env.OPERATING_BRANCH || 'BR002';
|
|
|
|
const ADMIN_PASSWORDS = ['Superadmin@123', 'SuperAdmin@123', 'E2eTest@123'];
|
|
|
|
const results = [];
|
|
let orderCode = null;
|
|
|
|
function pass(step, detail = '') {
|
|
results.push({ ok: true, step, detail });
|
|
console.log(` ✓ ${step}${detail ? ` — ${detail}` : ''}`);
|
|
}
|
|
|
|
function fail(step, detail = '') {
|
|
results.push({ ok: false, step, detail });
|
|
console.log(` ✗ ${step}${detail ? ` — ${detail}` : ''}`);
|
|
}
|
|
|
|
async function jsonFetch(path, options = {}) {
|
|
const res = await fetch(`${BASE}${path}`, {
|
|
...options,
|
|
headers: { 'Content-Type': 'application/json', ...(options.headers || {}) },
|
|
});
|
|
const body = await res.json().catch(() => ({}));
|
|
return { res, body };
|
|
}
|
|
|
|
async function adminLogin() {
|
|
for (const password of ADMIN_PASSWORDS) {
|
|
const { res, body } = await jsonFetch('/auth/token', {
|
|
method: 'POST',
|
|
body: JSON.stringify({ username: 'superadmin', password }),
|
|
});
|
|
if (res.ok && body.access_token) return body.access_token;
|
|
}
|
|
throw new Error('超管登录失败');
|
|
}
|
|
|
|
async function mobileLogin(username, password, roleType) {
|
|
const payload = { username, password };
|
|
if (roleType) payload.role_type = roleType;
|
|
const { res, body } = await jsonFetch('/mobile/login', {
|
|
method: 'POST',
|
|
body: JSON.stringify(payload),
|
|
});
|
|
if (!res.ok) throw new Error(body.error_description || '移动端登录失败');
|
|
return body;
|
|
}
|
|
|
|
async function query(token, spec, extraHeaders = {}) {
|
|
const { res, body } = await jsonFetch('/data/query', {
|
|
method: 'POST',
|
|
headers: {
|
|
Authorization: `Bearer ${token}`,
|
|
'X-Operating-Branch': OPERATING_BRANCH,
|
|
...extraHeaders,
|
|
},
|
|
body: JSON.stringify(spec),
|
|
});
|
|
return { ok: res.ok && !body.error, res, body };
|
|
}
|
|
|
|
async function listOrderEntryCustomers(adminToken) {
|
|
const mobile = await mobileLogin('superadmin', ADMIN_PASSWORDS[0], 'order_entry');
|
|
const { res, body } = await jsonFetch('/mobile/order-entry/customers', {
|
|
headers: { Authorization: `Bearer ${mobile.access_token}` },
|
|
});
|
|
if (res.ok && body.data?.length) return body.data;
|
|
const custQ = await query(adminToken, {
|
|
table: 'customers',
|
|
action: 'select',
|
|
select: 'customer_code, company_name, branch_code',
|
|
limit: 20,
|
|
});
|
|
return custQ.body?.data || [];
|
|
}
|
|
|
|
async function pickClerkCustomer(adminToken) {
|
|
console.log('\n[1] 录单客户');
|
|
const customers = await listOrderEntryCustomers(adminToken);
|
|
if (!customers.length) {
|
|
fail('查找客户', '无可用客户');
|
|
return null;
|
|
}
|
|
const row = customers[0];
|
|
pass('选用客户', `${row.company_name || row.customer_code} (${row.customer_code})`);
|
|
return {
|
|
customerCode: row.customer_code,
|
|
branchCode: row.branch_code,
|
|
};
|
|
}
|
|
|
|
async function clerkMobileOrder(portal) {
|
|
console.log('\n[2] 录单员小程序录单');
|
|
let session;
|
|
try {
|
|
session = await mobileLogin('superadmin', ADMIN_PASSWORDS[0], 'order_entry');
|
|
} catch (e) {
|
|
fail('录单员登录', e.message);
|
|
return null;
|
|
}
|
|
pass('录单员登录', session.role_type || 'order_entry');
|
|
|
|
const token = session.access_token;
|
|
|
|
const parse = await jsonFetch('/mobile/customer-order/parse', {
|
|
method: 'POST',
|
|
headers: { Authorization: `Bearer ${token}` },
|
|
body: JSON.stringify({
|
|
text: '土豆10斤、白菜5斤',
|
|
customer_code: portal.customerCode,
|
|
}),
|
|
});
|
|
let items = parse.body?.data?.items || [];
|
|
if (!parse.res.ok || !items.length) {
|
|
items = [
|
|
{
|
|
item_name: '流程测试土豆',
|
|
quantity: 10,
|
|
unit: '斤',
|
|
price: 3,
|
|
processing_method: '原材料',
|
|
},
|
|
];
|
|
pass('文字解析', '使用手工明细兜底');
|
|
} else {
|
|
pass('文字解析', `${items.length} 项`);
|
|
}
|
|
|
|
const budget = await jsonFetch(
|
|
`/mobile/customer-order/budget/${encodeURIComponent(portal.customerCode)}?order_amount=50`,
|
|
{ headers: { Authorization: `Bearer ${token}` } }
|
|
);
|
|
if (budget.res.ok) pass('预算校验', budget.body.level || 'ok');
|
|
else fail('预算校验', budget.body.error_description);
|
|
|
|
const submitItems = items.map((item) => ({
|
|
item_name: item.item_name || item.sku_name || '测试商品',
|
|
sku_code: item.sku_code || undefined,
|
|
quantity: Number(item.quantity) || 1,
|
|
unit: item.unit || '斤',
|
|
price: Number(item.price) || 0,
|
|
processing_method: item.processing_method || '原材料',
|
|
}));
|
|
|
|
const submit = await jsonFetch('/mobile/order-entry/orders', {
|
|
method: 'POST',
|
|
headers: { Authorization: `Bearer ${token}` },
|
|
body: JSON.stringify({
|
|
customer_code: portal.customerCode,
|
|
remark: 'E2E录单员小程序全流程测试',
|
|
items: submitItems,
|
|
}),
|
|
});
|
|
if (!submit.res.ok || !submit.body.order_code) {
|
|
fail('提交订单', submit.body.error_description || JSON.stringify(submit.body).slice(0, 160));
|
|
return null;
|
|
}
|
|
orderCode = submit.body.order_code;
|
|
pass('提交订单', orderCode);
|
|
return { orderCode, branchCode: portal.branchCode, items: submitItems };
|
|
}
|
|
|
|
async function advance(token, targetStatus) {
|
|
const { res, body } = await jsonFetch('/workflow/orders/advance', {
|
|
method: 'POST',
|
|
headers: { Authorization: `Bearer ${token}` },
|
|
body: JSON.stringify({ order_code: orderCode, target_status: targetStatus }),
|
|
});
|
|
return { ok: res.ok, body };
|
|
}
|
|
|
|
async function getOrder(token) {
|
|
const q = await query(token, {
|
|
table: 'orders',
|
|
action: 'select',
|
|
select: 'order_code, order_status, customer_code, branch_code',
|
|
filters: [{ op: 'eq', column: 'order_code', value: orderCode }],
|
|
single: true,
|
|
});
|
|
return q.body?.data;
|
|
}
|
|
|
|
async function setupFromStatus20(adminToken, ctx) {
|
|
console.log('\n[3] 分配备货 (20→30)');
|
|
const order = await getOrder(adminToken);
|
|
if (!order) {
|
|
fail('查询订单', orderCode);
|
|
return false;
|
|
}
|
|
pass('订单初始状态', `status=${order.order_status}`);
|
|
|
|
const itemsQ = await query(adminToken, {
|
|
table: 'order_items',
|
|
action: 'select',
|
|
select: 'id, sku_code, quantity, price, amount, supplier_code',
|
|
filters: [{ op: 'eq', column: 'order_code', value: orderCode }],
|
|
});
|
|
const orderItems = itemsQ.body?.data || [];
|
|
if (!orderItems.length) {
|
|
fail('订单明细', '无明细');
|
|
return false;
|
|
}
|
|
|
|
let prepCreated = 0;
|
|
for (const orderItem of orderItems) {
|
|
let skuCode = orderItem.sku_code;
|
|
if (!skuCode) {
|
|
const skuQ = await query(adminToken, {
|
|
table: 'skus',
|
|
action: 'select',
|
|
select: 'sku_code, unit',
|
|
filters: [{ op: 'eq', column: 'status', value: 1 }],
|
|
limit: 1,
|
|
});
|
|
skuCode = skuQ.body?.data?.[0]?.sku_code;
|
|
if (skuCode) {
|
|
await query(adminToken, {
|
|
table: 'order_items',
|
|
action: 'update',
|
|
updateData: { sku_code: skuCode },
|
|
filters: [{ op: 'eq', column: 'id', value: orderItem.id }],
|
|
});
|
|
pass('补全 SKU', skuCode);
|
|
}
|
|
}
|
|
if (!skuCode) continue;
|
|
|
|
const relQ = await query(adminToken, {
|
|
table: 'sku_suppliers',
|
|
action: 'select',
|
|
select: 'sku_code, supplier_code, supply_price',
|
|
filters: [{ op: 'eq', column: 'sku_code', value: skuCode }],
|
|
limit: 5,
|
|
});
|
|
const rel = relQ.body?.data?.[0];
|
|
if (!rel?.supplier_code) {
|
|
fail('供应商关系', `${skuCode} 无 sku_suppliers`);
|
|
continue;
|
|
}
|
|
|
|
const qty = Number(orderItem.quantity) || 10;
|
|
const price = Number(orderItem.price) || Number(rel.supply_price) || 3;
|
|
await query(adminToken, {
|
|
table: 'order_items',
|
|
action: 'update',
|
|
updateData: {
|
|
supplier_code: rel.supplier_code,
|
|
price,
|
|
amount: price * qty,
|
|
},
|
|
filters: [{ op: 'eq', column: 'id', value: orderItem.id }],
|
|
});
|
|
|
|
const prep = await query(adminToken, {
|
|
table: 'supplier_preparations',
|
|
action: 'insert',
|
|
insertData: {
|
|
order_code: orderCode,
|
|
supplier_code: rel.supplier_code,
|
|
sku_code: skuCode,
|
|
prepare_qty: qty,
|
|
purchase_price: price,
|
|
prepare_status: 10,
|
|
branch_code: order.branch_code || ctx.branchCode || 'BR002',
|
|
},
|
|
});
|
|
if (prep.ok) prepCreated += 1;
|
|
else fail('创建备货单', `${skuCode}: ${prep.body?.error?.message}`);
|
|
}
|
|
if (!prepCreated) return false;
|
|
pass('创建备货单', `${prepCreated} 项`);
|
|
|
|
const adv = await advance(adminToken, 30);
|
|
if (adv.ok) pass('推进 20→30', adv.body.data?.message || '');
|
|
else {
|
|
await query(adminToken, {
|
|
table: 'orders',
|
|
action: 'update',
|
|
updateData: { order_status: 30 },
|
|
filters: [{ op: 'eq', column: 'order_code', value: orderCode }],
|
|
});
|
|
pass('推进 20→30', '手动设置 status=30');
|
|
}
|
|
return true;
|
|
}
|
|
|
|
const MINJPEG =
|
|
'/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAABAAEDASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAn/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAX/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwCwAA8A/9k=';
|
|
|
|
async function completeProcessingTasks(adminToken) {
|
|
const proc = await query(adminToken, {
|
|
table: 'processing_tasks',
|
|
action: 'select',
|
|
select: 'id, process_status, source_qty, processing_method',
|
|
filters: [{ op: 'eq', column: 'order_code', value: orderCode }],
|
|
});
|
|
const tasks = proc.body?.data || [];
|
|
for (const task of tasks) {
|
|
const status = Number(task.process_status);
|
|
if (status === 40 || status === 50) continue;
|
|
const taskId = task.id;
|
|
const qty = Number(task.source_qty) || 10;
|
|
await jsonFetch('/workflow/processing/start', {
|
|
method: 'POST',
|
|
headers: { Authorization: `Bearer ${adminToken}` },
|
|
body: JSON.stringify({ task_id: taskId }),
|
|
});
|
|
const done = await jsonFetch('/workflow/processing/complete', {
|
|
method: 'POST',
|
|
headers: { Authorization: `Bearer ${adminToken}` },
|
|
body: JSON.stringify({
|
|
task_id: taskId,
|
|
gross_weight: qty,
|
|
net_weight: qty,
|
|
process_unit_price: 1,
|
|
}),
|
|
});
|
|
if (done.res.ok) pass('加工作业', taskId.slice(0, 8));
|
|
else fail('加工作业', done.body.error_description);
|
|
|
|
const photo = await jsonFetch('/workflow/processing/inspect/photo', {
|
|
method: 'POST',
|
|
headers: { Authorization: `Bearer ${adminToken}` },
|
|
body: JSON.stringify({ task_id: taskId, image_base64: MINJPEG, ext: 'jpg' }),
|
|
});
|
|
if (!photo.res.ok) fail('加工验收照片', photo.body.error_description || photo.res.status);
|
|
else pass('加工验收照片', taskId.slice(0, 8));
|
|
|
|
const inspect = await jsonFetch('/workflow/processing/inspect/complete', {
|
|
method: 'POST',
|
|
headers: { Authorization: `Bearer ${adminToken}` },
|
|
body: JSON.stringify({ task_id: taskId, quality_rating: '合格' }),
|
|
});
|
|
if (inspect.res.ok) pass('加工验收', taskId.slice(0, 8));
|
|
else fail('加工验收', inspect.body.error_description);
|
|
}
|
|
}
|
|
|
|
async function completeSupplierPreparations(adminToken) {
|
|
const preps = await query(adminToken, {
|
|
table: 'supplier_preparations',
|
|
action: 'select',
|
|
select: 'id, prepare_status, prepare_qty, purchase_price',
|
|
filters: [{ op: 'eq', column: 'order_code', value: orderCode }],
|
|
});
|
|
const pending = (preps.body?.data || []).filter((r) => Number(r.prepare_status) < 30);
|
|
if (!pending.length) {
|
|
pass('供应商备货', '已全部完成');
|
|
return;
|
|
}
|
|
|
|
let supplierSession;
|
|
try {
|
|
supplierSession = await mobileLogin('supplier1', 'E2eTest@123', 'supplier');
|
|
} catch (e) {
|
|
fail('供应商登录', e.message);
|
|
return;
|
|
}
|
|
pass('供应商登录', 'supplier1');
|
|
|
|
for (const prep of pending) {
|
|
const statusRes = await jsonFetch('/mobile/supplier/preparations/status', {
|
|
method: 'POST',
|
|
headers: { Authorization: `Bearer ${supplierSession.access_token}` },
|
|
body: JSON.stringify({
|
|
id: prep.id,
|
|
status: 30,
|
|
prepare_qty: Number(prep.prepare_qty) || 10,
|
|
purchase_price: Number(prep.purchase_price) || 3,
|
|
}),
|
|
});
|
|
if (statusRes.res.ok) pass('供应商备货完成', prep.id.slice(0, 8));
|
|
else fail('供应商备货完成', statusRes.body.error_description || statusRes.res.status);
|
|
}
|
|
}
|
|
|
|
async function simulateDeliveryStart(adminToken) {
|
|
const taskQ = await query(adminToken, {
|
|
table: 'delivery_tasks',
|
|
action: 'select',
|
|
select: 'task_code, person_code, task_status',
|
|
filters: [{ op: 'eq', column: 'order_code', value: orderCode }],
|
|
limit: 1,
|
|
});
|
|
let taskCode = taskQ.body?.data?.[0]?.task_code;
|
|
if (!taskCode) {
|
|
fail('配送任务', '分拣出库后未生成配送任务');
|
|
return;
|
|
}
|
|
|
|
const deliveryLogin = await mobileLogin('delivery1', 'E2eTest@123', 'delivery');
|
|
const personRes = await jsonFetch('/mobile/delivery/tasks', {
|
|
headers: { Authorization: `Bearer ${deliveryLogin.access_token}` },
|
|
});
|
|
const personCode = personRes.body?.person_code;
|
|
if (personCode) {
|
|
await query(adminToken, {
|
|
table: 'delivery_tasks',
|
|
action: 'update',
|
|
updateData: { person_code: personCode },
|
|
filters: [{ op: 'eq', column: 'task_code', value: taskCode }],
|
|
});
|
|
}
|
|
|
|
const start = await jsonFetch('/mobile/delivery/start', {
|
|
method: 'POST',
|
|
headers: { Authorization: `Bearer ${deliveryLogin.access_token}` },
|
|
body: JSON.stringify({ task_code: taskCode, order_code: orderCode }),
|
|
});
|
|
if (start.res.ok) pass('配送员开始配送', taskCode);
|
|
else fail('配送员开始配送', start.body.error_description || start.res.status);
|
|
}
|
|
|
|
async function simulateCustomerSign(adminToken) {
|
|
const taskQ = await query(adminToken, {
|
|
table: 'delivery_tasks',
|
|
action: 'select',
|
|
select: 'task_code',
|
|
filters: [{ op: 'eq', column: 'order_code', value: orderCode }],
|
|
limit: 1,
|
|
});
|
|
const taskCode = taskQ.body?.data?.[0]?.task_code;
|
|
if (!taskCode) {
|
|
fail('客户签收', '无配送任务');
|
|
return;
|
|
}
|
|
|
|
const sign = await jsonFetch('/workflow/delivery/signature', {
|
|
method: 'POST',
|
|
headers: { Authorization: `Bearer ${adminToken}` },
|
|
body: JSON.stringify({
|
|
task_code: taskCode,
|
|
order_code: orderCode,
|
|
sign_type: 'customer',
|
|
signature_data: 'E2E-test-signature',
|
|
signer_name: 'E2E客户',
|
|
}),
|
|
});
|
|
if (sign.res.ok) pass('客户电子签收', taskCode);
|
|
else fail('客户电子签收', sign.body.error_description || sign.res.status);
|
|
}
|
|
|
|
async function runWorkflowTo90(adminToken) {
|
|
console.log('\n[4] 工作流推进 30→90');
|
|
const steps = [
|
|
{ from: 30, to: 40, label: '备货完成→待验收' },
|
|
{ from: 40, to: 45, label: '验收完成→待分拣' },
|
|
{ from: 45, to: 50, label: '分拣→待配送' },
|
|
{ from: 50, to: 60, label: '配送中' },
|
|
{ from: 60, to: 90, label: '已完成' },
|
|
];
|
|
|
|
for (const step of steps) {
|
|
const order = await getOrder(adminToken);
|
|
const current = Number(order?.order_status || 0);
|
|
if (current >= step.to) {
|
|
pass(`跳过 ${step.label}`, `已在 ${current}`);
|
|
continue;
|
|
}
|
|
|
|
if (step.from === 30 && step.to === 40) {
|
|
await completeSupplierPreparations(adminToken);
|
|
}
|
|
|
|
if (step.from === 40 && step.to === 45) {
|
|
const insps = await query(adminToken, {
|
|
table: 'inspections',
|
|
action: 'select',
|
|
select: 'id, prepare_qty, actual_qty, quality_rating',
|
|
filters: [{ op: 'eq', column: 'order_code', value: orderCode }],
|
|
});
|
|
for (const row of (insps.body?.data || []).filter((r) => !r.actual_qty && !r.quality_rating)) {
|
|
const submit = await jsonFetch('/workflow/inspection/submit', {
|
|
method: 'POST',
|
|
headers: { Authorization: `Bearer ${adminToken}` },
|
|
body: JSON.stringify({
|
|
id: row.id,
|
|
actual_qty: Number(row.prepare_qty) || 0,
|
|
quality_rating: 'B',
|
|
loss_qty: 0,
|
|
}),
|
|
});
|
|
if (submit.res.ok) pass('验收入库', row.id.slice(0, 8));
|
|
else fail('验收入库', submit.body.error_description);
|
|
}
|
|
await completeProcessingTasks(adminToken);
|
|
}
|
|
|
|
if (step.from === 50 && step.to === 60) {
|
|
await simulateDeliveryStart(adminToken);
|
|
}
|
|
|
|
if (step.from === 60 && step.to === 90) {
|
|
await simulateCustomerSign(adminToken);
|
|
}
|
|
|
|
const adv = await advance(adminToken, step.to);
|
|
if (adv.ok) pass(step.label, `→ ${step.to}`);
|
|
else {
|
|
const after = await getOrder(adminToken);
|
|
if (Number(after?.order_status || 0) >= step.to) {
|
|
pass(step.label, `已在 ${after.order_status}`);
|
|
} else {
|
|
fail(step.label, adv.body.error_description || adv.body.error || '');
|
|
if (step.from === 45 && step.to === 50) {
|
|
const wh = process.env.E2E_WAREHOUSE || 'WH001';
|
|
const pick = await jsonFetch('/workflow/picking/create', {
|
|
method: 'POST',
|
|
headers: { Authorization: `Bearer ${adminToken}` },
|
|
body: JSON.stringify({ order_code: orderCode, warehouse_code: wh }),
|
|
});
|
|
if (pick.res.ok) {
|
|
pass('手动创建分拣单', pick.body.data?.pickCode || '');
|
|
const out = await jsonFetch('/workflow/picking/outbound', {
|
|
method: 'POST',
|
|
headers: { Authorization: `Bearer ${adminToken}` },
|
|
body: JSON.stringify({ pick_code: pick.body.data?.pickCode }),
|
|
});
|
|
if (out.res.ok) pass('分拣出库');
|
|
else fail('分拣出库', out.body.error_description);
|
|
const retry = await advance(adminToken, step.to);
|
|
if (retry.ok) pass(`重试 ${step.label}`);
|
|
else {
|
|
const retryOrder = await getOrder(adminToken);
|
|
if (Number(retryOrder?.order_status || 0) >= step.to) {
|
|
pass(`重试 ${step.label}`, `已在 ${retryOrder.order_status}`);
|
|
}
|
|
}
|
|
} else {
|
|
fail('手动创建分拣单', pick.body.error_description);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
const final = await getOrder(adminToken);
|
|
if (Number(final?.order_status) === 90) pass('订单终态', 'status=90 已完成');
|
|
else fail('订单终态', `status=${final?.order_status}`);
|
|
}
|
|
|
|
async function main() {
|
|
console.log(`\n=== 客户小程序全链路 E2E ===\nAPI: ${BASE}\n`);
|
|
|
|
const health = await jsonFetch('/health');
|
|
if (!health.res.ok) {
|
|
console.error('API 不可达');
|
|
process.exit(1);
|
|
}
|
|
pass('健康检查');
|
|
|
|
const adminToken = await adminLogin();
|
|
pass('超管登录');
|
|
|
|
const portal = await pickClerkCustomer(adminToken);
|
|
if (!portal) process.exit(1);
|
|
|
|
const ctx = await clerkMobileOrder(portal);
|
|
if (!ctx) process.exit(1);
|
|
|
|
const ok = await setupFromStatus20(adminToken, ctx);
|
|
if (ok) await runWorkflowTo90(adminToken);
|
|
|
|
console.log('\n=== 汇总 ===');
|
|
const failed = results.filter((r) => !r.ok);
|
|
console.log(`通过: ${results.length - failed.length} 失败: ${failed.length}`);
|
|
if (orderCode) console.log(`测试订单: ${orderCode}`);
|
|
if (portal) {
|
|
console.log(`客户: ${portal.customerCode}`);
|
|
}
|
|
if (failed.length) {
|
|
failed.forEach((f) => console.log(` - ${f.step}: ${f.detail}`));
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
main().catch((e) => {
|
|
console.error(e);
|
|
process.exit(1);
|
|
});
|