feat(M08-D): 补后台订单运营

This commit is contained in:
Codex
2026-08-10 11:52:25 +08:00
parent 3502f5b5f7
commit 20a292e4ce
10 changed files with 619 additions and 37 deletions
+14 -1
View File
@@ -8,6 +8,7 @@ const token = signAccessToken({
tid: '7', aid: '9', rv: 1
}, secret, 900);
let transitionInput;
let historyInput;
const options = {
jwtSecret: secret,
authRepository: {
@@ -33,7 +34,10 @@ const options = {
transitionInput = { actor, orderId, action, reason };
return { orderId, status: action === 'CANCEL' ? 'CANCELLED' : 'PAID' };
},
async history() { return []; }
async history(tenantId, userId, orderId, access) {
historyInput = { tenantId, userId, orderId, access };
return [{ id: '1', fromStatus: null, toStatus: 'DRAFT', action: 'CREATED' }];
}
}
};
const app = await buildApp({ orderState: options });
@@ -76,6 +80,15 @@ assert.equal(transitionInput.action, 'START');
assert.equal(transitionInput.actor.source, 'ADMIN');
assert.equal(transitionInput.actor.traceId, 'm08c-route-transition');
const adminHistory = await app.inject({
method: 'GET', url: '/admin-api/orders/31/history',
headers: { authorization: `Bearer ${token}` }
});
assert.equal(adminHistory.statusCode, 200);
assert.equal(adminHistory.json().data[0].action, 'CREATED');
assert.equal(historyInput.orderId, '31');
assert.equal(historyInput.access.roles[0], 'TENANT_ADMIN');
const cancelled = await app.inject({
method: 'POST',
url: '/app-api/orders/31/cancel',