44 lines
1.4 KiB
Go
44 lines
1.4 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type PaymentType string
|
|
type PaymentMethod string
|
|
type PaymentStatus string
|
|
|
|
const (
|
|
PaymentTypeAdvance PaymentType = "advance"
|
|
PaymentTypeFinal PaymentType = "final"
|
|
|
|
PaymentMethodWechat PaymentMethod = "wechat"
|
|
PaymentMethodAlipay PaymentMethod = "alipay"
|
|
PaymentMethodBank PaymentMethod = "bank"
|
|
|
|
PaymentStatusPending PaymentStatus = "pending"
|
|
PaymentStatusSuccess PaymentStatus = "success"
|
|
PaymentStatusFailed PaymentStatus = "failed"
|
|
PaymentStatusRefunded PaymentStatus = "refunded"
|
|
)
|
|
|
|
type Payment struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
PaymentNo string `gorm:"uniqueIndex;not null" json:"payment_no"`
|
|
OrderID uint `gorm:"not null" json:"order_id"`
|
|
UserID uint `gorm:"not null" json:"user_id"`
|
|
Amount float64 `gorm:"not null" json:"amount"`
|
|
PaymentType PaymentType `gorm:"not null" json:"payment_type"`
|
|
PaymentMethod PaymentMethod `gorm:"not null" json:"payment_method"`
|
|
Status PaymentStatus `gorm:"default:pending" json:"status"`
|
|
TransactionID string `json:"transaction_id"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
|
}
|
|
|
|
func (Payment) TableName() string {
|
|
return "payments"
|
|
} |