You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.5 KiB
Go
61 lines
1.5 KiB
Go
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
"time"
|
|
)
|
|
|
|
type Order struct {
|
|
ID int
|
|
RequestID string
|
|
OrderNo string
|
|
OrderSn string
|
|
Token string
|
|
Status string
|
|
PayUrl string
|
|
User *User `gorm:"foreignKey:OrderNo;references:OrderNo"`
|
|
Project *Project `gorm:"foreignKey:OrderNo;references:OrderNo"`
|
|
Applicant *Applicant `gorm:"foreignKey:OrderNo;references:OrderNo"`
|
|
Assured *Assured `gorm:"foreignKey:OrderNo;references:OrderNo"`
|
|
OrderResult *OrderResult `gorm:"foreignKey:OrderNo;references:OrderNo"`
|
|
Invoice *Invoice `gorm:"foreignKey:OrderNo;references:OrderNo"`
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time `json:"-"`
|
|
}
|
|
|
|
func (Order) TableName() string {
|
|
return "order"
|
|
}
|
|
|
|
func (a Order) MarshalJSON() ([]byte, error) {
|
|
type Alias Order
|
|
return json.Marshal(&struct {
|
|
CreatedAt string
|
|
UpdatedAt string
|
|
*Alias
|
|
}{
|
|
CreatedAt: a.CreatedAt.Format("2006-01-02 15:04:05"),
|
|
UpdatedAt: a.UpdatedAt.Format("2006-01-02 15:04:05"),
|
|
Alias: (*Alias)(&a),
|
|
})
|
|
}
|
|
|
|
func (a Order) GetStatusText() string {
|
|
if a.Status == "submitted" {
|
|
return "待支付"
|
|
} else if a.Status == "initial" {
|
|
return "待提交"
|
|
} else if a.Status == "payed" {
|
|
return "已出函"
|
|
} else if a.Status == "generated" {
|
|
return "待提交"
|
|
} else if a.Status == "signed" {
|
|
return "待提交"
|
|
} else if a.Status == "revoked" {
|
|
return "已退保"
|
|
} else if a.Status == "claimed" {
|
|
return "已理赔"
|
|
}
|
|
return "待提交"
|
|
}
|