refactor(web): rename returns list columns, add resync-updates-times test (#337)
商品标题/规格 -> 商品标题 (drop the spec subtitle, already shown in the 独立 规格数据 column). 认领时间 -> 上架时间 in the list. The detail drawer still says 认领时间, unchanged per the request scope. Also locks in existing sync behavior with a regression test: a resync of the same package must overwrite claim_time and destroy_dead_line, not just last_synced_at (server/.../sync.go already did this; the test only adds coverage). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NTDbDcwbDw1TSAcE6wfh2F
This commit is contained in:
@@ -728,3 +728,52 @@ func TestItemKeyDistinctVariationsOfSameItemID(t *testing.T) {
|
||||
t.Fatalf("items=%d, want 2 (same itemID with different variationID must stay distinct)", n)
|
||||
}
|
||||
}
|
||||
|
||||
// TestResyncUpdatesClaimTimeAndDestroyDeadLine: yeeke may correct a package's
|
||||
// claim time or destroy deadline between two syncs of the same package. The
|
||||
// second sync must overwrite the stored values, not just refresh
|
||||
// last_synced_at.
|
||||
func TestResyncUpdatesClaimTimeAndDestroyDeadLine(t *testing.T) {
|
||||
db := testDB(t)
|
||||
recordWithTimes := func(claimTime, destroyDeadLine string) string {
|
||||
b, _ := json.Marshal(map[string]any{
|
||||
"id": "p1", "ordersn": "o-p1", "trackingNo": "t-p1", "status": "1",
|
||||
"claimTime": claimTime, "destroyDeadLine": destroyDeadLine,
|
||||
"items": []map[string]any{{
|
||||
"id": "p1-i1", "itemId": "i", "variationId": "v1",
|
||||
"itemName": "n", "variationName": "v", "variationQuantityPurchased": "1",
|
||||
}},
|
||||
})
|
||||
return string(b)
|
||||
}
|
||||
var body string
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
fmt.Fprint(w, body)
|
||||
}))
|
||||
defer srv.Close()
|
||||
c, _ := yeekeclient.New(srv.URL)
|
||||
s := NewService(db, c, Config{PageSize: 20})
|
||||
|
||||
body = page([]string{recordWithTimes("2026-09-01 10:00:00", "2026-10-01 10:00:00")}, 1, 1)
|
||||
if _, err := s.Sync(context.Background(), "manual"); err != nil {
|
||||
t.Fatalf("first sync: %v", err)
|
||||
}
|
||||
var row models.YeekeReturnPackage
|
||||
db.Where("external_id = ?", "p1").First(&row)
|
||||
if got := row.ClaimTime.Format("2006-01-02"); got != "2026-09-01" {
|
||||
t.Fatalf("claim_time after first sync = %s", got)
|
||||
}
|
||||
|
||||
body = page([]string{recordWithTimes("2026-09-15 08:00:00", "2026-10-15 08:00:00")}, 1, 1)
|
||||
if _, err := s.Sync(context.Background(), "manual"); err != nil {
|
||||
t.Fatalf("second sync: %v", err)
|
||||
}
|
||||
db.Where("external_id = ?", "p1").First(&row)
|
||||
if got := row.ClaimTime.Format("2006-01-02"); got != "2026-09-15" {
|
||||
t.Fatalf("claim_time after resync = %s, want updated value", got)
|
||||
}
|
||||
if got := row.DestroyDeadLine.Format("2006-01-02"); got != "2026-10-15" {
|
||||
t.Fatalf("destroy_dead_line after resync = %s, want updated value", got)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,12 +35,9 @@
|
||||
<span v-else>—</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="商品标题/规格" min-width="220">
|
||||
<el-table-column label="商品标题" min-width="220">
|
||||
<template #default="{ row }">
|
||||
<template v-if="row.hasItem">
|
||||
{{ row.itemName || '—' }}
|
||||
<div class="muted">{{ row.variationName || '—' }}</div>
|
||||
</template>
|
||||
<template v-if="row.hasItem">{{ row.itemName || '—' }}</template>
|
||||
<span v-else class="muted">(无商品明细)</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -64,7 +61,7 @@
|
||||
<el-tag v-else :type="claimStatusMeta(row.claimStatus).type">{{ claimStatusMeta(row.claimStatus).label }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="认领时间" min-width="150"><template #default="{ row }">{{ formatTime(row.claimTime) }}</template></el-table-column>
|
||||
<el-table-column label="上架时间" min-width="150"><template #default="{ row }">{{ formatTime(row.claimTime) }}</template></el-table-column>
|
||||
<el-table-column label="销毁截止" min-width="150"><template #default="{ row }">{{ formatTime(row.destroyDeadLine) }}</template></el-table-column>
|
||||
<el-table-column label="最近同步" min-width="150"><template #default="{ row }">{{ formatTime(row.lastSyncedAt) }}</template></el-table-column>
|
||||
<el-table-column label="操作" width="90" fixed="right"><template #default="{ row }"><el-button type="primary" link @click="openDetail(row)">详情</el-button></template></el-table-column>
|
||||
|
||||
Reference in New Issue
Block a user