重构后端服务架构并优化前端错误处理
This commit is contained in:
44
go-backend/models/payment.go
Normal file
44
go-backend/models/payment.go
Normal file
@@ -0,0 +1,44 @@
|
||||
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"
|
||||
}
|
||||
Reference in New Issue
Block a user