diff --git a/backend/internal/modules/listing/dto.go b/backend/internal/modules/listing/dto.go index d7a254c..1aa0367 100644 --- a/backend/internal/modules/listing/dto.go +++ b/backend/internal/modules/listing/dto.go @@ -25,8 +25,8 @@ type ListingDTO struct { AssetSummary map[string]any `json:"asset_summary,omitempty"` ScreenshotURLS []string `json:"screenshot_urls"` CoverURL string `json:"cover_url"` - Price float64 `json:"price"` - DepositAmount float64 `json:"deposit_amount"` + PriceCent int64 `json:"price_cent"` + DepositAmountCent int64 `json:"deposit_amount_cent"` IsAccelerated bool `json:"is_accelerated_sale"` InTransaction bool `json:"in_transaction"` Status string `json:"status"` diff --git a/backend/internal/modules/listing/repository.go b/backend/internal/modules/listing/repository.go index 1f0201d..08a795d 100644 --- a/backend/internal/modules/listing/repository.go +++ b/backend/internal/modules/listing/repository.go @@ -908,8 +908,8 @@ func matchesPublicQuery(item ListingDTO, query PublicListQuery) bool { return false } - price := item.Price - deposit := item.DepositAmount + price := float64(item.PriceCent) / 100 + deposit := float64(item.DepositAmountCent) / 100 total := price + deposit coinM := coinMFromListing(item) if !numberInRange(coinM, NumberRange{Min: query.MinCoin, Max: query.MaxCoin}) { @@ -944,9 +944,9 @@ func sortPublicListings(items []ListingDTO, sortKey string) { b := items[j] switch sortKey { case "priceAsc": - return a.Price < b.Price + return a.PriceCent < b.PriceCent case "priceDesc": - return a.Price > b.Price + return a.PriceCent > b.PriceCent case "coinDesc": return a.HafCoinAmount > b.HafCoinAmount case "awmDesc": @@ -1421,7 +1421,7 @@ func applySellerListingPrice(item *ListingDTO) { } sellerPrice := readSummaryNumber(breakdown["seller_total_price"]) if sellerPrice > 0 { - item.Price = sellerPrice + item.PriceCent = int64(math.Round(sellerPrice * 100)) } sellerRatio := readSummaryNumber(breakdown["seller_ratio"]) if sellerRatio > 0 { @@ -1447,24 +1447,24 @@ func (row listingRow) toDTO() ListingDTO { OwnerNickname: row.OwnerNickname, Title: row.Title, Description: row.Description, - GameName: row.GameName, - ServerRegion: row.ServerRegion, - LoginPlatform: row.LoginPlatform, - RankLevel: row.RankLevel, - HafCoinAmount: row.HafCoinAmount, - AssetSummary: assetSummary, - ScreenshotURLS: screenshotURLS, - CoverURL: publicCoverURL(row.ID, screenshotURLS, row.Status, row.ReviewStatus), - Price: row.Price, - DepositAmount: row.DepositAmount, - IsAccelerated: isAcceleratedSale(assetSummary), - InTransaction: row.InTransaction, - Status: row.Status, - ReviewStatus: reviewStatus, - ReviewReason: reviewReason, - PublishedAt: row.PublishedAt, - CreatedAt: row.CreatedAt, - UpdatedAt: row.UpdatedAt, + GameName: row.GameName, + ServerRegion: row.ServerRegion, + LoginPlatform: row.LoginPlatform, + RankLevel: row.RankLevel, + HafCoinAmount: row.HafCoinAmount, + AssetSummary: assetSummary, + ScreenshotURLS: screenshotURLS, + CoverURL: publicCoverURL(row.ID, screenshotURLS, row.Status, row.ReviewStatus), + PriceCent: row.PriceCent, + DepositAmountCent: row.DepositAmountCent, + IsAccelerated: isAcceleratedSale(assetSummary), + InTransaction: row.InTransaction, + Status: row.Status, + ReviewStatus: reviewStatus, + ReviewReason: reviewReason, + PublishedAt: row.PublishedAt, + CreatedAt: row.CreatedAt, + UpdatedAt: row.UpdatedAt, } } @@ -1473,30 +1473,30 @@ func toDTO(account model.GameAccount, listing model.RentalListing) *ListingDTO { screenshotURLS := cleanScreenshotURLs(decodeScreenshots(account.ScreenshotURLS)) reviewStatus, reviewReason := normalizedReviewState(listing.Status, listing.ReviewStatus, listing.ReviewReason) return &ListingDTO{ - ID: listing.ID, - ListingNo: listing.ListingNo, - AccountID: account.ID, - OwnerID: listing.OwnerID, - Title: account.Title, - Description: account.Description, - GameName: account.GameName, - ServerRegion: account.ServerRegion, - LoginPlatform: account.LoginPlatform, - RankLevel: account.RankLevel, - HafCoinAmount: account.HafCoinAmount, - AssetSummary: assetSummary, - ScreenshotURLS: screenshotURLS, - CoverURL: publicCoverURL(listing.ID, screenshotURLS, listing.Status, listing.ReviewStatus), - Price: listing.Price, - DepositAmount: listing.DepositAmount, - IsAccelerated: isAcceleratedSale(assetSummary), - InTransaction: listing.InTransaction, - Status: listing.Status, - ReviewStatus: reviewStatus, - ReviewReason: reviewReason, - PublishedAt: listing.PublishedAt, - CreatedAt: listing.CreatedAt, - UpdatedAt: listing.UpdatedAt, + ID: listing.ID, + ListingNo: listing.ListingNo, + AccountID: account.ID, + OwnerID: listing.OwnerID, + Title: account.Title, + Description: account.Description, + GameName: account.GameName, + ServerRegion: account.ServerRegion, + LoginPlatform: account.LoginPlatform, + RankLevel: account.RankLevel, + HafCoinAmount: account.HafCoinAmount, + AssetSummary: assetSummary, + ScreenshotURLS: screenshotURLS, + CoverURL: publicCoverURL(listing.ID, screenshotURLS, listing.Status, listing.ReviewStatus), + PriceCent: listing.PriceCent, + DepositAmountCent: listing.DepositAmountCent, + IsAccelerated: isAcceleratedSale(assetSummary), + InTransaction: listing.InTransaction, + Status: listing.Status, + ReviewStatus: reviewStatus, + ReviewReason: reviewReason, + PublishedAt: listing.PublishedAt, + CreatedAt: listing.CreatedAt, + UpdatedAt: listing.UpdatedAt, } }