38 lines
1.8 KiB
Go
38 lines
1.8 KiB
Go
package models
|
||
|
||
import (
|
||
"platform/web/core"
|
||
|
||
"github.com/shopspring/decimal"
|
||
)
|
||
|
||
// Bill 账单表
|
||
type Bill struct {
|
||
core.Model
|
||
UserID int32 `json:"user_id" gorm:"column:user_id"` // 用户ID
|
||
TradeID *int32 `json:"trade_id,omitempty" gorm:"column:trade_id"` // 订单ID
|
||
ResourceID *int32 `json:"resource_id,omitempty" gorm:"column:resource_id"` // 套餐ID
|
||
RefundID *int32 `json:"refund_id,omitempty" gorm:"column:refund_id"` // 退款ID
|
||
CouponUserID *int32 `json:"coupon_user_id,omitempty" gorm:"column:coupon_user_id"` // 优惠券发放ID
|
||
BillNo string `json:"bill_no" gorm:"column:bill_no"` // 易读账单号
|
||
Info *string `json:"info,omitempty" gorm:"column:info"` // 产品可读信息
|
||
Type BillType `json:"type" gorm:"column:type"` // 账单类型:1-消费,2-退款,3-充值
|
||
Amount decimal.Decimal `json:"amount" gorm:"column:amount"` // 应付金额
|
||
Actual decimal.Decimal `json:"actual" gorm:"column:actual"` // 实付金额
|
||
|
||
User *User `json:"user,omitempty" gorm:"foreignKey:UserID"`
|
||
Trade *Trade `json:"trade,omitempty" gorm:"foreignKey:TradeID"`
|
||
Resource *Resource `json:"resource,omitempty" gorm:"foreignKey:ResourceID"`
|
||
Refund *Refund `json:"refund,omitempty" gorm:"foreignKey:RefundID"`
|
||
CouponUser *CouponUser `json:"coupon,omitempty" gorm:"foreignKey:CouponUserID"`
|
||
}
|
||
|
||
// BillType 账单类型枚举
|
||
type BillType int
|
||
|
||
const (
|
||
BillTypeConsume BillType = 1 // 消费
|
||
BillTypeRefund BillType = 2 // 退款
|
||
BillTypeRecharge BillType = 3 // 充值
|
||
)
|