fix(admin): align coload groups with inbound fragments
This commit is contained in:
@@ -4,8 +4,7 @@ import { batchQueryPlatformCoLoadGroups, cancelPlatformCoLoadGroup, createPlatfo
|
||||
|
||||
const group = {
|
||||
groupId: 2093000000000000001n, groupNo: 'CLG-2093000000000000001', status: 'ACTIVE',
|
||||
warehouseId: 2093000000000000002n, channelCode: 'NY-EXX', destinationType: 'WAREHOUSE',
|
||||
destinationWarehouseId: 2093000000000000003n, destinationCode: 'ONT8', lockedPlanId: null,
|
||||
warehouseId: 2093000000000000002n, channelCode: 'NY-EXX', lockedPlanId: null,
|
||||
version: 0, fullPackageCount: 18, createdAt: '2026-08-29T10:00:00', updatedAt: '2026-08-29T10:00:00',
|
||||
members: [
|
||||
{ tenantId: 2093000000000000004n, orderId: 2093000000000000005n, inboundId: 2093000000000000006n, fullPackageCount: 8 },
|
||||
@@ -39,11 +38,28 @@ describe('co-load group API', () => {
|
||||
it('batch-enriches three list rows and normalizes every long id without numeric coercion', async () => {
|
||||
const third = { ...group.members[0], orderId: 2093000000000000010n, inboundId: 2093000000000000011n }
|
||||
const threeMemberGroup = { ...group, fullPackageCount: 23, members: [...group.members, third] }
|
||||
const post = vi.spyOn(http, 'post').mockResolvedValue({ code: '200', message: 'ok', data: threeMemberGroup.members.map((member) => ({ orderId: member.orderId, inboundId: member.inboundId, group: threeMemberGroup })) })
|
||||
const post = vi.spyOn(http, 'post').mockResolvedValue({ code: '200', message: 'ok', data: threeMemberGroup.members.map((member) => ({ orderId: member.orderId, group: threeMemberGroup })) })
|
||||
const orderIds = ['2093000000000000005', '2093000000000000008', '2093000000000000010']
|
||||
const result = await batchQueryPlatformCoLoadGroups(orderIds)
|
||||
expect(post).toHaveBeenCalledWith('/platform/v1/first-leg/coload-groups/batch-query', { orderIds })
|
||||
expect(result).toHaveLength(3)
|
||||
expect(result[2]).toMatchObject({ orderId: '2093000000000000010', inboundId: '2093000000000000011', group: { groupId: '2093000000000000001', fullPackageCount: 23 } })
|
||||
expect(result[2]).toMatchObject({ orderId: '2093000000000000010', group: { groupId: '2093000000000000001', fullPackageCount: 23 } })
|
||||
expect(result[2]).not.toHaveProperty('inboundId')
|
||||
})
|
||||
|
||||
it('keeps every inbound fragment when one order has multiple current inbounds', async () => {
|
||||
const fragment = { ...group.members[0], inboundId: 2093000000000000012n, fullPackageCount: 3 }
|
||||
const multiInboundGroup = { ...group, fullPackageCount: 21, members: [group.members[0], fragment, group.members[1]] }
|
||||
const post = vi.spyOn(http, 'post').mockResolvedValue({ code: '200', message: 'ok', data: [
|
||||
{ orderId: group.members[0].orderId, group: multiInboundGroup },
|
||||
{ orderId: group.members[1].orderId, group: multiInboundGroup },
|
||||
] })
|
||||
const result = await batchQueryPlatformCoLoadGroups(['2093000000000000005', '2093000000000000008'])
|
||||
expect(post).toHaveBeenCalledTimes(1)
|
||||
expect(result[0].group.members).toEqual([
|
||||
expect.objectContaining({ orderId: '2093000000000000005', inboundId: '2093000000000000006', fullPackageCount: 8 }),
|
||||
expect.objectContaining({ orderId: '2093000000000000005', inboundId: '2093000000000000012', fullPackageCount: 3 }),
|
||||
expect.objectContaining({ orderId: '2093000000000000008', inboundId: '2093000000000000009', fullPackageCount: 10 }),
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -15,9 +15,6 @@ export interface CoLoadGroup {
|
||||
status: CoLoadGroupStatus
|
||||
warehouseId: string
|
||||
channelCode: string
|
||||
destinationType: string
|
||||
destinationWarehouseId: string | null
|
||||
destinationCode: string | null
|
||||
lockedPlanId: string | null
|
||||
version: number
|
||||
members: CoLoadGroupMember[]
|
||||
@@ -28,21 +25,18 @@ export interface CoLoadGroup {
|
||||
|
||||
export interface OrderCoLoadGroupInfo {
|
||||
orderId: string
|
||||
inboundId: string
|
||||
group: CoLoadGroup
|
||||
}
|
||||
|
||||
type RawId = string | number
|
||||
type RawCoLoadGroup = Omit<CoLoadGroup, 'groupId' | 'warehouseId' | 'destinationWarehouseId' | 'lockedPlanId' | 'members'> & {
|
||||
type RawCoLoadGroup = Omit<CoLoadGroup, 'groupId' | 'warehouseId' | 'lockedPlanId' | 'members'> & {
|
||||
groupId: RawId
|
||||
warehouseId: RawId
|
||||
destinationWarehouseId: RawId | null
|
||||
lockedPlanId: RawId | null
|
||||
members: Array<Omit<CoLoadGroupMember, 'tenantId' | 'orderId' | 'inboundId'> & { tenantId: RawId; orderId: RawId; inboundId: RawId }>
|
||||
}
|
||||
type RawOrderCoLoadGroupInfo = Omit<OrderCoLoadGroupInfo, 'orderId' | 'inboundId' | 'group'> & {
|
||||
type RawOrderCoLoadGroupInfo = Omit<OrderCoLoadGroupInfo, 'orderId' | 'group'> & {
|
||||
orderId: RawId
|
||||
inboundId: RawId
|
||||
group: RawCoLoadGroup
|
||||
}
|
||||
|
||||
@@ -55,7 +49,6 @@ function normalizeGroup(raw: RawCoLoadGroup): CoLoadGroup {
|
||||
...raw,
|
||||
groupId: String(raw.groupId),
|
||||
warehouseId: String(raw.warehouseId),
|
||||
destinationWarehouseId: optionalId(raw.destinationWarehouseId),
|
||||
lockedPlanId: optionalId(raw.lockedPlanId),
|
||||
version: Number(raw.version),
|
||||
fullPackageCount: Number(raw.fullPackageCount),
|
||||
@@ -94,7 +87,6 @@ export async function batchQueryPlatformCoLoadGroups(orderIds: string[]) {
|
||||
)
|
||||
return unwrapApiResponse(response).map((item) => ({
|
||||
orderId: String(item.orderId),
|
||||
inboundId: String(item.inboundId),
|
||||
group: normalizeGroup(item.group),
|
||||
}))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user