feat: 我的订单调整

This commit is contained in:
zoujing committed 2026-07-31 09:50:31 +08:00
1 parent 6a9135770b
commit a36183d4d8
4 files changed
+390 -52

No files matched your search

+39 -9
View File
@@ -16,7 +16,7 @@ import {
test('provides coherent default visitor ticket data', async () => {
const data = await import('./data.js')
const { AVAILABLE_DATES, GROUPS, INITIAL_TRAVELERS, INSURANCE, PLACEHOLDER_IMAGE, PRODUCTS, REFUND_REASONS, SCENIC_SPOT } = data
const { AVAILABLE_DATES, GROUPS, INITIAL_TRAVELERS, INSURANCE, ORDER_STATUS_META, PLACEHOLDER_IMAGE, PRODUCTS, REFUND_REASONS, SCENIC_SPOT } = data
const { INITIAL_ORDERS } = data
assert.equal(PLACEHOLDER_IMAGE, 'https://one-feel-bucket.oss-cn-guangzhou.aliyuncs.com/oneFeel/2082673896938569729.jpg')
@@ -71,15 +71,45 @@ test('provides coherent default visitor ticket data', async () => {
assert.deepEqual(productsById.get('classic').reservation, { requiresDate: true, advanceDays: 30, requiresTimeSlot: true, timeSlots: standardSlots, realNameRequired: true, idTypes: ['身份证', '护照'], maxQuantity: 5, contactPhoneRequired: true })
assert.deepEqual(productsById.get('classic').highlights, ['官方', '实名预约', '整包退', '双凭证'])
assert.deepEqual(INITIAL_TRAVELERS[0], { id: 'traveler-lin-xiao', name: '林晓', idType: '身份证', idNumber: '110101199001020010', phone: '13800138000' })
assert.equal(INITIAL_ORDERS.length, 2)
assert.deepEqual(INITIAL_ORDERS.map(({ productId, visitDate, timeSlot, quantity, travelers, insurance, gateCredential, selfCredential, entitlements }) => ({ productId, visitDate, timeSlot, quantity, travelers, insurance, hasGateCredential: Boolean(gateCredential), hasSelfCredential: Boolean(selfCredential), fulfillment: entitlements.map(({ fulfillment }) => fulfillment) })), [
{ productId: 'adult', visitDate: '2026-08-01', timeSlot: '08:00—09:30', quantity: 1, travelers: [{ id: 'traveler-lin-xiao', name: '林晓', idType: '身份证', idNumber: '110101199001020010', phone: '13800138000' }], insurance: { name: '出行意外险', price: 5, quantity: 1, status: 'active' }, hasGateCredential: true, hasSelfCredential: false, fulfillment: ['third_party', 'third_party'] },
{ productId: 'classic', visitDate: '2026-08-02', timeSlot: '09:30—11:30', quantity: 1, travelers: [{ id: 'traveler-lin-xiao', name: '林晓', idType: '身份证', idNumber: '110101199001020010', phone: '13800138000' }], insurance: null, hasGateCredential: true, hasSelfCredential: true, fulfillment: ['third_party', 'third_party', 'self'] },
])
assert.deepEqual(
Object.fromEntries(Object.entries(ORDER_STATUS_META).map(([status, meta]) => [status, meta.label])),
{
pending_payment: '待支付',
closed: '已关闭',
paid: '待使用',
fulfilling: '出票中',
partial_used: '部分使用',
completed: '已完成',
refunding: '退款中',
partial_refunded: '部分退款',
refunded: '已退款',
exception: '异常',
},
)
assert.equal(INITIAL_ORDERS.length, 11)
assert.deepEqual(
INITIAL_ORDERS.map(({ orderNo, productName, status, amount }) => [orderNo, productName, status, amount]),
[
['LB202607260001', '小七孔经典畅游套餐', 'partial_used', 188],
['LB202607260002', '小七孔经典畅游套餐', 'paid', 376],
['LB202607260003', '荔波小七孔景区成人票', 'exception', 120],
['LB202607260004', '鸳鸯湖游船票', 'paid', 100],
['LB202607260005', '荔波小七孔景区成人票', 'fulfilling', 120],
['LB202607260006', '鸳鸯湖游船票', 'completed', 50],
['LB202607260007', '小七孔观光车票', 'refunding', 80],
['LB202607260008', '精品讲解服务', 'refunded', 68],
['LB202607260009', '小七孔经典畅游套餐', 'pending_payment', 188],
['LB202607260010', '荔波小七孔景区成人票', 'closed', 120],
['LB202607260011', '鸳鸯湖游船票', 'partial_refunded', 100],
],
)
assert.deepEqual(new Set(INITIAL_ORDERS.map(({ status }) => status)), new Set(Object.keys(ORDER_STATUS_META)))
for (const order of INITIAL_ORDERS) {
assert.notEqual(order.travelers[0], INITIAL_TRAVELERS[0])
const sourceProduct = productsById.get(order.productId)
for (const entitlement of order.entitlements) assert.notEqual(entitlement, sourceProduct.entitlements.find((source) => source.id === entitlement.sourceId))
assert.equal(order.paidAmount, order.amount)
assert.equal(order.productAmount, order.amount)
assert.equal(order.insuranceAmount, 0)
assert.equal(order.travelers[0].name, order.customerName)
assert.ok(order.entitlements.every((entitlement) => ['pending', 'used', 'refunding', 'refunded'].includes(entitlement.status)))
}
})