feat(M08-A): 接入顾客端续费换房分享

This commit is contained in:
Codex
2026-06-25 11:34:23 +08:00
parent a4e13d911e
commit 874b9b8e29
7 changed files with 337 additions and 5 deletions
+40
View File
@@ -8,6 +8,7 @@ const token = signAccessToken({
tid: '7', aid: '9', rv: 1
}, secret, 900);
let called;
let customerCalled;
const authRepository = {
async validateSession() {
return {
@@ -33,7 +34,15 @@ const app = await buildApp({
called = { actor, orderId, body };
return { orderId, adjustmentType: 'RENEW', amountDeltaCents: 1200 };
},
async customerRenew(actor, orderId, body) {
customerCalled = { action: 'renew', actor, orderId, body };
return { orderId, adjustmentType: 'RENEW', amountDeltaCents: 1800 };
},
async changeRoom() { throw new Error('not called'); },
async customerChangeRoom(actor, orderId, body) {
customerCalled = { action: 'changeRoom', actor, orderId, body };
return { orderId, adjustmentType: 'CHANGE_ROOM', amountDeltaCents: -500 };
},
async adjustTime() { throw new Error('not called'); },
async note() { throw new Error('not called'); },
async cancellationQuote() {
@@ -71,6 +80,37 @@ assert.equal(called.orderId, '31');
assert.equal(called.actor.traceId, 'm04c-renew-route');
assert.equal(called.body.pricingPolicy, 'LOCKED');
const customerRenewed = await app.inject({
method: 'POST',
url: '/app-api/orders/31/renew',
headers: { authorization: `Bearer ${token}`, 'x-trace-id': 'm08a-customer-renew' },
payload: {
endAt: new Date(Date.now() + 10800000).toISOString(),
pricingPolicy: 'CURRENT',
reason: 'miniapp renew'
}
});
assert.equal(customerRenewed.statusCode, 200);
assert.equal(customerCalled.action, 'renew');
assert.equal(customerCalled.actor.source, 'APP');
assert.equal(customerCalled.actor.traceId, 'm08a-customer-renew');
assert.equal(customerCalled.body.pricingPolicy, 'CURRENT');
const customerChanged = await app.inject({
method: 'POST',
url: '/app-api/orders/31/change-room',
headers: { authorization: `Bearer ${token}`, 'x-trace-id': 'm08a-customer-change-room' },
payload: {
roomId: '32',
reason: 'miniapp change room'
}
});
assert.equal(customerChanged.statusCode, 200);
assert.equal(customerCalled.action, 'changeRoom');
assert.equal(customerCalled.actor.source, 'APP');
assert.equal(customerCalled.orderId, '31');
assert.equal(customerCalled.body.roomId, '32');
const quote = await app.inject({
method: 'GET',
url: '/app-api/orders/31/cancellation-quote',