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.

57 lines
1.4 KiB
Go

5 months ago
package model
import (
"encoding/json"
"time"
)
type Order struct {
5 months ago
ID int
RequestID string
4 months ago
OrderNo string
5 months ago
OrderSn string
Token string
5 months ago
Status string
PayUrl string
4 months ago
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"`
4 months ago
Invoice *Invoice `gorm:"foreignKey:OrderNo;references:OrderNo"`
5 months ago
CreatedAt time.Time
UpdatedAt time.Time `json:"-"`
5 months ago
}
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),
})
}
3 months ago
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 "待提交"
}
return "待提交"
}