金额使用整数, 不再扣押金, 价格每个人看到自己的-1
This commit is contained in:
@@ -61,11 +61,12 @@ func (r *Repository) Create(ownerID uint64, req CreateRequest, reviewRequired bo
|
||||
return err
|
||||
}
|
||||
price := normalizedListingPrice(req)
|
||||
depositAmount := roundMoney(req.DepositAmount)
|
||||
listing := model.RentalListing{
|
||||
AccountID: account.ID,
|
||||
OwnerID: ownerID,
|
||||
Price: price,
|
||||
DepositAmount: req.DepositAmount,
|
||||
DepositAmount: depositAmount,
|
||||
Status: listingStatus,
|
||||
ReviewStatus: reviewStatus,
|
||||
PublishedAt: publishedAt,
|
||||
@@ -109,7 +110,7 @@ func (r *Repository) Update(ownerID uint64, listingID uint64, req UpdateRequest,
|
||||
|
||||
price := normalizedListingPrice(req)
|
||||
listing.Price = price
|
||||
listing.DepositAmount = req.DepositAmount
|
||||
listing.DepositAmount = roundMoney(req.DepositAmount)
|
||||
listingStatus, reviewStatus, publishedAt := initialPublishState(reviewRequired)
|
||||
listing.Status = listingStatus
|
||||
listing.ReviewStatus = reviewStatus
|
||||
@@ -488,7 +489,15 @@ func rowsToDTO(rows []listingRow) []ListingDTO {
|
||||
}
|
||||
|
||||
func normalizedListingPrice(req CreateRequest) float64 {
|
||||
return req.Price
|
||||
if req.AssetSummary != nil {
|
||||
if breakdown, ok := req.AssetSummary["price_breakdown"].(map[string]any); ok {
|
||||
buyerPrice := readSummaryNumber(breakdown["buyer_total_price"])
|
||||
if buyerPrice > 0 {
|
||||
return roundMoney(buyerPrice)
|
||||
}
|
||||
}
|
||||
}
|
||||
return roundMoney(req.Price)
|
||||
}
|
||||
|
||||
func publicListings(items []ListingDTO) []ListingDTO {
|
||||
@@ -524,6 +533,15 @@ func applySellerListingPrice(item *ListingDTO) {
|
||||
if sellerPrice > 0 {
|
||||
item.Price = sellerPrice
|
||||
}
|
||||
sellerRatio := readSummaryNumber(breakdown["seller_ratio"])
|
||||
if sellerRatio > 0 {
|
||||
item.AssetSummary["publish_ratio"] = sellerRatio
|
||||
}
|
||||
delete(breakdown, "buyer_coin_base_price")
|
||||
delete(breakdown, "buyer_total_price")
|
||||
delete(breakdown, "buyer_ratio")
|
||||
delete(breakdown, "platform_markup_amount")
|
||||
delete(breakdown, "platform_rule_type")
|
||||
}
|
||||
|
||||
func (row listingRow) toDTO() ListingDTO {
|
||||
|
||||
Reference in New Issue
Block a user