增加线下提号店铺管理

This commit is contained in:
yml2213
2026-07-26 18:19:12 +08:00
parent c594b543d1
commit 6b44ab599d
12 changed files with 176 additions and 2 deletions
@@ -125,6 +125,62 @@ func TestRepositoryUpdateProfitRejectsCompleted(t *testing.T) {
}
}
func TestRepositoryListAdminFiltersShopName(t *testing.T) {
repo, db := newPickupTestRepo(t)
first := seedPickup(t, db, StatusPickingUp)
if err := db.Model(&first).Updates(map[string]any{
"platform": "淘宝",
"shop_name": "大锤一店",
}).Error; err != nil {
t.Fatalf("设置第一条提号店铺失败: %v", err)
}
second := first
second.ID = 0
second.PickupNo = "PK-PROFIT-002"
second.ShopName = "大锤二店"
if err := db.Create(&second).Error; err != nil {
t.Fatalf("创建第二条提号记录失败: %v", err)
}
result, err := repo.ListAdmin(t.Context(), AdminPickupQuery{ShopName: " 大锤一店 "})
if err != nil {
t.Fatalf("ListAdmin() error = %v", err)
}
if result.Total != 1 || len(result.Items) != 1 {
t.Fatalf("店铺筛选结果 = total %d, items %d, want 1", result.Total, len(result.Items))
}
if result.Items[0].ShopName != "大锤一店" {
t.Fatalf("店铺名称 = %q, want 大锤一店", result.Items[0].ShopName)
}
}
func TestRepositoryListShopNamesReturnsDistinctPlatformOptions(t *testing.T) {
repo, db := newPickupTestRepo(t)
first := seedPickup(t, db, StatusPickingUp)
if err := db.Model(&first).Updates(map[string]any{
"platform": "淘宝",
"shop_name": "大锤一店",
}).Error; err != nil {
t.Fatalf("设置第一条提号店铺失败: %v", err)
}
for index, row := range []model.AdminPickup{
{PickupNo: "PK-SHOP-002", ListingID: first.ListingID, AccountID: first.AccountID, OwnerID: first.OwnerID, AdminID: 1, Platform: "淘宝", ShopName: "大锤一店", Status: StatusPickingUp},
{PickupNo: "PK-SHOP-003", ListingID: first.ListingID, AccountID: first.AccountID, OwnerID: first.OwnerID, AdminID: 1, Platform: "拼多多", ShopName: "大锤二店", Status: StatusPickingUp},
} {
if err := db.Create(&row).Error; err != nil {
t.Fatalf("创建第 %d 条店铺选项失败: %v", index+2, err)
}
}
names, err := repo.ListShopNames(t.Context(), "淘宝")
if err != nil {
t.Fatalf("ListShopNames() error = %v", err)
}
if len(names) != 1 || names[0] != "大锤一店" {
t.Fatalf("淘宝店铺选项 = %v, want [大锤一店]", names)
}
}
func assertInt64(t *testing.T, name string, got, want int64) {
t.Helper()
if got != want {