统一金额分制重构

This commit is contained in:
yml
2026-06-09 19:04:11 +08:00
parent 87673288ef
commit 5cd3ead4bd
69 changed files with 886 additions and 1277 deletions
+17 -17
View File
@@ -11,14 +11,14 @@ type DashboardDTO struct {
}
type MetricsDTO struct {
TotalUsers int64 `json:"total_users"`
VerifiedUsers int64 `json:"verified_users"`
TotalListings int64 `json:"total_listings"`
PublishedListings int64 `json:"published_listings"`
TotalOrders int64 `json:"total_orders"`
RentingOrders int64 `json:"renting_orders"`
TodayOrders int64 `json:"today_orders"`
TodayLedgerAmount float64 `json:"today_ledger_amount"`
TotalUsers int64 `json:"total_users"`
VerifiedUsers int64 `json:"verified_users"`
TotalListings int64 `json:"total_listings"`
PublishedListings int64 `json:"published_listings"`
TotalOrders int64 `json:"total_orders"`
RentingOrders int64 `json:"renting_orders"`
TodayOrders int64 `json:"today_orders"`
TodayLedgerAmountCent int64 `json:"today_ledger_amount_cent"`
}
type PendingDTO struct {
@@ -29,15 +29,15 @@ type PendingDTO struct {
}
type RecentOrderDTO struct {
ID uint64 `json:"id"`
OrderNo string `json:"order_no"`
Title string `json:"title"`
RenterID uint64 `json:"renter_id"`
OwnerID uint64 `json:"owner_id"`
Status string `json:"status"`
RentAmount float64 `json:"rent_amount"`
DepositAmount float64 `json:"deposit_amount"`
CreatedAt time.Time `json:"created_at"`
ID uint64 `json:"id"`
OrderNo string `json:"order_no"`
Title string `json:"title"`
RenterID uint64 `json:"renter_id"`
OwnerID uint64 `json:"owner_id"`
Status string `json:"status"`
RentAmountCent int64 `json:"rent_amount_cent"`
DepositAmountCent int64 `json:"deposit_amount_cent"`
CreatedAt time.Time `json:"created_at"`
}
type RecentDisputeDTO struct {
@@ -44,9 +44,9 @@ func (r *Repository) Summary() (*DashboardDTO, error) {
return nil, err
}
if err := r.db.Model(&model.WalletLedger{}).
Select("COALESCE(SUM(amount), 0)").
Select("COALESCE(SUM(amount_cent), 0)").
Where("created_at >= ?", today).
Scan(&metrics.TodayLedgerAmount).Error; err != nil {
Scan(&metrics.TodayLedgerAmountCent).Error; err != nil {
return nil, err
}
if err := r.db.Model(&model.RentalListing{}).Where("review_status = ?", "pending").Count(&pending.ListingReviews).Error; err != nil {
@@ -81,7 +81,7 @@ func (r *Repository) Summary() (*DashboardDTO, error) {
func (r *Repository) recentOrders() ([]RecentOrderDTO, error) {
rows := make([]RecentOrderDTO, 0)
err := r.db.Table("rental_orders AS o").
Select("o.id, o.order_no, a.title, o.renter_id, o.owner_id, o.status, o.rent_amount, o.deposit_amount, o.created_at").
Select("o.id, o.order_no, a.title, o.renter_id, o.owner_id, o.status, o.rent_amount_cent, o.deposit_amount_cent, o.created_at").
Joins("JOIN game_accounts AS a ON a.id = o.account_id").
Order("o.id DESC").
Limit(8).