增加线下提号店铺管理

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
@@ -84,6 +84,7 @@ func (r *Repository) Create(ctx context.Context, req CreateRequest, adminID uint
OwnerID: listing.OwnerID,
AdminID: adminID,
Platform: strings.TrimSpace(req.Platform),
ShopName: strings.TrimSpace(req.ShopName),
ListingPriceCent: priceSnapshot.ListingPriceCent,
OwnerPriceCent: priceSnapshot.OwnerPriceCent,
WebsiteProfitCent: priceSnapshot.WebsiteProfitCent,
@@ -145,6 +146,7 @@ func (r *Repository) Create(ctx context.Context, req CreateRequest, adminID uint
"pickup_no": pickupNo,
"listing_id": listing.ID,
"platform": pickup.Platform,
"shop_name": pickup.ShopName,
"profit_cent": pickup.ProfitAmountCent,
},
}); err != nil {
@@ -417,6 +419,9 @@ func (r *Repository) ListAdmin(ctx context.Context, query AdminPickupQuery) (*Pa
if status := strings.TrimSpace(query.Status); status != "" {
db = db.Where("p.status = ?", status)
}
if shopName := strings.TrimSpace(query.ShopName); shopName != "" {
db = db.Where("p.shop_name = ?", shopName)
}
if kw := strings.TrimSpace(query.Keyword); kw != "" {
like := "%" + kw + "%"
db = db.Where("p.pickup_no LIKE ? OR l.listing_no LIKE ? OR a.title LIKE ?", like, like, like)
@@ -424,6 +429,23 @@ func (r *Repository) ListAdmin(ctx context.Context, query AdminPickupQuery) (*Pa
return r.paginatePickups(db, query.Page, query.PageSize, false)
}
// ListShopNames 返回历史提号中已使用的店铺名称,供后台选择和筛选。
func (r *Repository) ListShopNames(ctx context.Context, platform string) ([]string, error) {
if r == nil || r.db == nil {
return nil, ErrDependencyUnavailable
}
db := r.db.WithContext(ctx).Model(&model.AdminPickup{}).
Where("shop_name <> ''")
if value := strings.TrimSpace(platform); value != "" {
db = db.Where("platform = ?", value)
}
names := make([]string, 0)
if err := db.Distinct("shop_name").Order("shop_name ASC").Limit(200).Pluck("shop_name", &names).Error; err != nil {
return nil, err
}
return names, nil
}
func (r *Repository) ListForSeller(ctx context.Context, ownerID uint64, query SellerPickupQuery) (*PaginatedResult, error) {
if r == nil || r.db == nil {
return nil, ErrDependencyUnavailable
@@ -453,6 +475,7 @@ func (r *Repository) paginatePickups(db *gorm.DB, page, pageSize int, sellerView
item.WebsiteProfitCent = 0
item.ProfitAmountCent = 0
item.BuyerRatio = 0
item.ShopName = ""
}
items = append(items, item)
}
@@ -521,6 +544,7 @@ func (row pickupRow) toDTO() PickupDTO {
OwnerPhone: row.OwnerPhone,
AdminID: row.AdminID,
Platform: row.Platform,
ShopName: row.ShopName,
ListingPriceCent: row.ListingPriceCent,
OwnerPriceCent: row.OwnerPriceCent,
WebsiteProfitCent: row.WebsiteProfitCent,