package model import ( "time" "github.com/shopspring/decimal" "github.com/uptrace/bun" ) type UserCharge struct { bun.BaseModel `bun:"table:user_charge,alias:c"` Created `bun:"extend"` Seq int64 `bun:"type:bigint,pk,notnull,autoincrement" json:"seq"` UserId string `bun:",notnull" json:"userId"` Fee decimal.NullDecimal `json:"fee"` Discount decimal.NullDecimal `json:"discount"` Amount decimal.NullDecimal `json:"amount"` ChargeTo time.Time `bun:"type:date,notnull" json:"chargeTo" time_format:"simple_date" time_location:"shanghai"` Settled bool `bun:",notnull,default:false" json:"settled"` SettledAt *time.Time `bun:"type:timestamptz" json:"settledAt" time_format:"simple_datetime" time_location:"shanghai"` Cancelled bool `bun:",notnull,default:false" json:"cancelled"` CancelledAt *time.Time `bun:"type:timestamptz" json:"cancelledAt" time_format:"simple_datetime" time_location:"shanghai"` Refunded bool `bun:",notnull,default:false" json:"refunded"` RefundedAt *time.Time `bun:"type:timestamptz" json:"refundedAt" time_format:"simple_datetime" time_location:"shanghai"` Detail *UserDetail `bun:"rel:belongs-to,join:user_id=id" json:"-"` } type ChargeWithName struct { UserDetail `bun:"extend"` UserCharge `bun:"extend"` }