Model层:新增金额分字段定义

- 所有 Model 添加对应的 *Cent int64 字段
- 旧的 float64 字段保留但不输出到 JSON (json:"-")
- 涉及文件:user.go, listing.go, order.go, order_checkout.go, wallet.go, withdrawal.go
- 目标:为后续业务逻辑切换到分存储做准备

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
yml
2026-06-09 13:31:29 +08:00
co-authored by Claude Opus 4.8
parent eaa10d839c
commit b80719d538
6 changed files with 119 additions and 94 deletions
+4 -2
View File
@@ -33,8 +33,10 @@ type RentalListing struct {
ListingNo string `gorm:"column:listing_no;size:20;not null;uniqueIndex" json:"listing_no"` ListingNo string `gorm:"column:listing_no;size:20;not null;uniqueIndex" json:"listing_no"`
AccountID uint64 `gorm:"not null;index" json:"account_id"` AccountID uint64 `gorm:"not null;index" json:"account_id"`
OwnerID uint64 `gorm:"not null;index" json:"owner_id"` OwnerID uint64 `gorm:"not null;index" json:"owner_id"`
Price float64 `gorm:"type:decimal(12,2);not null;default:0" json:"price"` Price float64 `gorm:"type:decimal(12,2);not null;default:0" json:"-"`
DepositAmount float64 `gorm:"type:decimal(12,2);not null;default:0" json:"deposit_amount"` PriceCent int64 `gorm:"not null;default:0" json:"-"`
DepositAmount float64 `gorm:"type:decimal(12,2);not null;default:0" json:"-"`
DepositAmountCent int64 `gorm:"not null;default:0" json:"-"`
InTransaction bool `gorm:"not null;default:false" json:"in_transaction"` InTransaction bool `gorm:"not null;default:false" json:"in_transaction"`
Status string `gorm:"size:32;not null;default:'draft'" json:"status"` Status string `gorm:"size:32;not null;default:'draft'" json:"status"`
ReviewStatus string `gorm:"size:32;not null;default:'none'" json:"review_status"` ReviewStatus string `gorm:"size:32;not null;default:'none'" json:"review_status"`
+12 -6
View File
@@ -15,12 +15,18 @@ type RentalOrder struct {
RenterID uint64 `gorm:"not null;index" json:"renter_id"` RenterID uint64 `gorm:"not null;index" json:"renter_id"`
RentedAt *time.Time `json:"rented_at"` RentedAt *time.Time `json:"rented_at"`
EstimatedDurationHours int `gorm:"not null;default:24" json:"estimated_duration_hours"` EstimatedDurationHours int `gorm:"not null;default:24" json:"estimated_duration_hours"`
RentAmount float64 `gorm:"type:decimal(12,2);not null;default:0" json:"rent_amount"` RentAmount float64 `gorm:"type:decimal(12,2);not null;default:0" json:"-"`
OwnerRentAmount float64 `gorm:"type:decimal(12,2);not null;default:0" json:"owner_rent_amount"` RentAmountCent int64 `gorm:"not null;default:0" json:"-"`
DepositAmount float64 `gorm:"type:decimal(12,2);not null;default:0" json:"deposit_amount"` OwnerRentAmount float64 `gorm:"type:decimal(12,2);not null;default:0" json:"-"`
DepositOriginalAmount float64 `gorm:"type:decimal(12,2);not null;default:0" json:"deposit_original_amount"` OwnerRentAmountCent int64 `gorm:"not null;default:0" json:"-"`
DepositWaivedAmount float64 `gorm:"type:decimal(12,2);not null;default:0" json:"deposit_waived_amount"` DepositAmount float64 `gorm:"type:decimal(12,2);not null;default:0" json:"-"`
PlatformFee float64 `gorm:"type:decimal(12,2);not null;default:0" json:"platform_fee"` DepositAmountCent int64 `gorm:"not null;default:0" json:"-"`
DepositOriginalAmount float64 `gorm:"type:decimal(12,2);not null;default:0" json:"-"`
DepositOriginalAmountCent int64 `gorm:"not null;default:0" json:"-"`
DepositWaivedAmount float64 `gorm:"type:decimal(12,2);not null;default:0" json:"-"`
DepositWaivedAmountCent int64 `gorm:"not null;default:0" json:"-"`
PlatformFee float64 `gorm:"type:decimal(12,2);not null;default:0" json:"-"`
PlatformFeeCent int64 `gorm:"not null;default:0" json:"-"`
AccountSnapshot datatypes.JSON `json:"account_snapshot"` AccountSnapshot datatypes.JSON `json:"account_snapshot"`
Status string `gorm:"size:32;not null;default:'pending_payment'" json:"status"` Status string `gorm:"size:32;not null;default:'pending_payment'" json:"status"`
HandoffStatus string `gorm:"size:32;not null;default:'none'" json:"handoff_status"` HandoffStatus string `gorm:"size:32;not null;default:'none'" json:"handoff_status"`
+18 -9
View File
@@ -11,16 +11,25 @@ type OrderCheckout struct {
OrderID uint64 `gorm:"not null;index" json:"order_id"` OrderID uint64 `gorm:"not null;index" json:"order_id"`
InitiatedBy uint64 `gorm:"not null" json:"initiated_by"` InitiatedBy uint64 `gorm:"not null" json:"initiated_by"`
Status string `gorm:"size:32;not null;default:'submitted'" json:"status"` Status string `gorm:"size:32;not null;default:'submitted'" json:"status"`
RentAmount float64 `gorm:"type:decimal(12,2);not null;default:0" json:"rent_amount"` RentAmount float64 `gorm:"type:decimal(12,2);not null;default:0" json:"-"`
OwnerRentAmount float64 `gorm:"type:decimal(12,2);not null;default:0" json:"owner_rent_amount"` RentAmountCent int64 `gorm:"not null;default:0" json:"-"`
PlatformFee float64 `gorm:"type:decimal(12,2);not null;default:0" json:"platform_fee"` OwnerRentAmount float64 `gorm:"type:decimal(12,2);not null;default:0" json:"-"`
DepositAmount float64 `gorm:"type:decimal(12,2);not null;default:0" json:"deposit_amount"` OwnerRentAmountCent int64 `gorm:"not null;default:0" json:"-"`
ConsumableAmount float64 `gorm:"type:decimal(12,2);not null;default:0" json:"consumable_amount"` PlatformFee float64 `gorm:"type:decimal(12,2);not null;default:0" json:"-"`
PlatformFeeCent int64 `gorm:"not null;default:0" json:"-"`
DepositAmount float64 `gorm:"type:decimal(12,2);not null;default:0" json:"-"`
DepositAmountCent int64 `gorm:"not null;default:0" json:"-"`
ConsumableAmount float64 `gorm:"type:decimal(12,2);not null;default:0" json:"-"`
ConsumableAmountCent int64 `gorm:"not null;default:0" json:"-"`
CoinConsumedM float64 `gorm:"type:decimal(12,2);not null;default:0" json:"coin_consumed_m"` CoinConsumedM float64 `gorm:"type:decimal(12,2);not null;default:0" json:"coin_consumed_m"`
OtherAmount float64 `gorm:"type:decimal(12,2);not null;default:0" json:"other_amount"` OtherAmount float64 `gorm:"type:decimal(12,2);not null;default:0" json:"-"`
DepositDeductAmount float64 `gorm:"type:decimal(12,2);not null;default:0" json:"deposit_deduct_amount"` OtherAmountCent int64 `gorm:"not null;default:0" json:"-"`
RenterRefundAmount float64 `gorm:"type:decimal(12,2);not null;default:0" json:"renter_refund_amount"` DepositDeductAmount float64 `gorm:"type:decimal(12,2);not null;default:0" json:"-"`
OwnerIncomeAmount float64 `gorm:"type:decimal(12,2);not null;default:0" json:"owner_income_amount"` DepositDeductAmountCent int64 `gorm:"not null;default:0" json:"-"`
RenterRefundAmount float64 `gorm:"type:decimal(12,2);not null;default:0" json:"-"`
RenterRefundAmountCent int64 `gorm:"not null;default:0" json:"-"`
OwnerIncomeAmount float64 `gorm:"type:decimal(12,2);not null;default:0" json:"-"`
OwnerIncomeAmountCent int64 `gorm:"not null;default:0" json:"-"`
Content string `json:"content"` Content string `json:"content"`
EvidenceURLS datatypes.JSON `gorm:"column:evidence_urls" json:"evidence_urls"` EvidenceURLS datatypes.JSON `gorm:"column:evidence_urls" json:"evidence_urls"`
OwnerAdjustmentReason string `json:"owner_adjustment_reason"` OwnerAdjustmentReason string `json:"owner_adjustment_reason"`
+2 -1
View File
@@ -10,7 +10,8 @@ type User struct {
RealnameStatus string `gorm:"size:32;not null;default:'unverified'" json:"realname_status"` RealnameStatus string `gorm:"size:32;not null;default:'unverified'" json:"realname_status"`
RiskStatus string `gorm:"size:32;not null;default:'normal'" json:"risk_status"` RiskStatus string `gorm:"size:32;not null;default:'normal'" json:"risk_status"`
CreditScore int `gorm:"not null;default:100" json:"credit_score"` CreditScore int `gorm:"not null;default:100" json:"credit_score"`
DepositFreeQuota float64 `gorm:"type:decimal(12,2);not null;default:0" json:"deposit_free_quota"` DepositFreeQuota float64 `gorm:"type:decimal(12,2);not null;default:0" json:"-"`
DepositFreeQuotaCent int64 `gorm:"not null;default:0" json:"-"`
Status string `gorm:"size:32;not null;default:'active'" json:"status"` Status string `gorm:"size:32;not null;default:'active'" json:"status"`
LastLoginAt *time.Time `json:"last_login_at"` LastLoginAt *time.Time `json:"last_login_at"`
CreatedAt time.Time `json:"created_at"` CreatedAt time.Time `json:"created_at"`
+8 -4
View File
@@ -5,8 +5,10 @@ import "time"
type WalletAccount struct { type WalletAccount struct {
ID uint64 `gorm:"primaryKey" json:"id"` ID uint64 `gorm:"primaryKey" json:"id"`
UserID uint64 `gorm:"not null;uniqueIndex" json:"user_id"` UserID uint64 `gorm:"not null;uniqueIndex" json:"user_id"`
AvailableBalance float64 `gorm:"type:decimal(12,2);not null;default:0" json:"available_balance"` AvailableBalance float64 `gorm:"type:decimal(12,2);not null;default:0" json:"-"`
FrozenBalance float64 `gorm:"type:decimal(12,2);not null;default:0" json:"frozen_balance"` AvailableBalanceCent int64 `gorm:"not null;default:0" json:"-"`
FrozenBalance float64 `gorm:"type:decimal(12,2);not null;default:0" json:"-"`
FrozenBalanceCent int64 `gorm:"not null;default:0" json:"-"`
Status string `gorm:"size:32;not null;default:'active'" json:"status"` Status string `gorm:"size:32;not null;default:'active'" json:"status"`
CreatedAt time.Time `json:"created_at"` CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"` UpdatedAt time.Time `json:"updated_at"`
@@ -22,8 +24,10 @@ type WalletLedger struct {
UserID uint64 `gorm:"not null;index" json:"user_id"` UserID uint64 `gorm:"not null;index" json:"user_id"`
OrderID *uint64 `json:"order_id"` OrderID *uint64 `json:"order_id"`
Direction string `gorm:"size:16;not null" json:"direction"` Direction string `gorm:"size:16;not null" json:"direction"`
Amount float64 `gorm:"type:decimal(12,2);not null" json:"amount"` Amount float64 `gorm:"type:decimal(12,2);not null" json:"-"`
BalanceAfter float64 `gorm:"type:decimal(12,2);not null" json:"balance_after"` AmountCent int64 `gorm:"not null;default:0" json:"-"`
BalanceAfter float64 `gorm:"type:decimal(12,2);not null" json:"-"`
BalanceAfterCent int64 `gorm:"not null;default:0" json:"-"`
BalanceType string `gorm:"size:32;not null" json:"balance_type"` BalanceType string `gorm:"size:32;not null" json:"balance_type"`
BizType string `gorm:"size:32;not null" json:"biz_type"` BizType string `gorm:"size:32;not null" json:"biz_type"`
BizNo string `gorm:"size:64;not null" json:"biz_no"` BizNo string `gorm:"size:64;not null" json:"biz_no"`
+6 -3
View File
@@ -6,9 +6,12 @@ type WithdrawalRequest struct {
ID uint64 `gorm:"primaryKey" json:"id"` ID uint64 `gorm:"primaryKey" json:"id"`
WithdrawNo string `gorm:"size:64;not null;uniqueIndex" json:"withdraw_no"` WithdrawNo string `gorm:"size:64;not null;uniqueIndex" json:"withdraw_no"`
UserID uint64 `gorm:"not null;index" json:"user_id"` UserID uint64 `gorm:"not null;index" json:"user_id"`
Amount float64 `gorm:"type:decimal(12,2);not null" json:"amount"` Amount float64 `gorm:"type:decimal(12,2);not null" json:"-"`
Fee float64 `gorm:"type:decimal(12,2);not null;default:0.00" json:"fee"` AmountCent int64 `gorm:"not null;default:0" json:"-"`
ActualAmount float64 `gorm:"type:decimal(12,2);not null" json:"actual_amount"` Fee float64 `gorm:"type:decimal(12,2);not null;default:0.00" json:"-"`
FeeCent int64 `gorm:"not null;default:0" json:"-"`
ActualAmount float64 `gorm:"type:decimal(12,2);not null" json:"-"`
ActualAmountCent int64 `gorm:"not null;default:0" json:"-"`
PaymentAccountID *uint64 `json:"payment_account_id"` PaymentAccountID *uint64 `json:"payment_account_id"`
AccountType string `gorm:"size:32;not null" json:"account_type"` AccountType string `gorm:"size:32;not null" json:"account_type"`
AccountName string `gorm:"size:128;not null" json:"account_name"` AccountName string `gorm:"size:128;not null" json:"account_name"`