diff --git a/backend/internal/modules/listing/presenter.go b/backend/internal/modules/listing/presenter.go index 38fb5a4..015de05 100644 --- a/backend/internal/modules/listing/presenter.go +++ b/backend/internal/modules/listing/presenter.go @@ -57,6 +57,7 @@ func normalizedListingPriceCent(req CreateRequest) int64 { func publicListings(items []ListingDTO) []ListingDTO { for index := range items { applyPublicListingURLs(&items[index]) + applyPublicListingPrice(&items[index]) } return items } @@ -156,12 +157,47 @@ func applySellerListingPrice(item *ListingDTO) { item.AssetSummary["publish_ratio"] = sellerRatio } delete(breakdown, "buyer_coin_base_price") + delete(breakdown, "buyer_coin_base_price_cent") delete(breakdown, "buyer_total_price") + delete(breakdown, "buyer_total_price_cent") delete(breakdown, "buyer_ratio") + delete(breakdown, "buyer_ratio_bps") delete(breakdown, "platform_markup_amount") + delete(breakdown, "platform_markup_amount_cent") delete(breakdown, "platform_rule_type") } +// applyPublicListingPrice 只保留买家侧价格字段,隐藏卖家成本与平台加价。 +func applyPublicListingPrice(item *ListingDTO) { + if item == nil || item.AssetSummary == nil { + return + } + breakdown, ok := item.AssetSummary["price_breakdown"].(map[string]any) + if !ok { + return + } + for _, key := range []string{ + "seller_reference_ratio", + "seller_reference_ratio_bps", + "seller_ratio", + "seller_ratio_bps", + "seller_coin_base_price", + "seller_coin_base_price_cent", + "seller_total_price", + "seller_total_price_cent", + "platform_markup_amount", + "platform_markup_amount_cent", + "platform_rule_type", + "admin_adjust_reason", + "admin_adjusted_at", + "admin_adjusted_by", + "site_receive_ratio_delta", + "site_receive_cost_delta", + } { + delete(breakdown, key) + } +} + func (row listingRow) toDTO() ListingDTO { assetSummary := decodeAssetSummary(row.AssetSummary) screenshotURLS := cleanScreenshotURLs(decodeScreenshots(row.ScreenshotURLS)) diff --git a/backend/internal/modules/listing/public_query.go b/backend/internal/modules/listing/public_query.go index 2e2dac7..43dca0d 100644 --- a/backend/internal/modules/listing/public_query.go +++ b/backend/internal/modules/listing/public_query.go @@ -239,6 +239,7 @@ func (r *Repository) FindPublic(ctx context.Context, id uint64, siteCode string) return nil, err } applyPublicListingURLs(dto) + applyPublicListingPrice(dto) items := []ListingDTO{*dto} if err := r.applyShelfMarkup(ctx, siteCode, items); err != nil { return nil, err diff --git a/backend/internal/modules/listing/query.go b/backend/internal/modules/listing/query.go index 4b351eb..797062d 100644 --- a/backend/internal/modules/listing/query.go +++ b/backend/internal/modules/listing/query.go @@ -258,11 +258,21 @@ func (r *Repository) findForReviewUpdate(tx *gorm.DB, listingID uint64) (*model. func (r *Repository) nextListingNo(tx *gorm.DB, now time.Time) (string, error) { bizDate := now.Format("20060102") if tx.Dialector.Name() == "mysql" { + // 以当天已有编号的最大值为兜底,避免种子数据或外部写入后序列落后导致编号冲突。 + var maxSeq int + if err := tx.Raw( + `SELECT COALESCE(MAX(CAST(SUBSTRING(listing_no, 9) AS UNSIGNED)), 0) + FROM rental_listings WHERE listing_no LIKE ?`, + bizDate+"%", + ).Scan(&maxSeq).Error; err != nil { + return "", err + } + nextSeq := maxSeq + 1 if err := tx.Exec(` INSERT INTO listing_no_sequences (biz_date, next_seq) - VALUES (?, LAST_INSERT_ID(1)) - ON DUPLICATE KEY UPDATE next_seq = LAST_INSERT_ID(next_seq + 1) - `, bizDate).Error; err != nil { + VALUES (?, LAST_INSERT_ID(?)) + ON DUPLICATE KEY UPDATE next_seq = LAST_INSERT_ID(GREATEST(next_seq + 1, ?)) + `, bizDate, nextSeq, nextSeq).Error; err != nil { return "", err } var seq int