You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
3.1 KiB

package model
import (
"database/sql/driver"
"encoding/json"
"github.com/shopspring/decimal"
)
/*
订单模块
*/
const (
REGISTER_STATUS_SUCCESS = "0" // 成功
REGISTER_STATUS_FIAL = "1" // 失败
REGISTER_STATUS_WAITPAY = "2" // 待支付
)
type Order struct {
/*
代收,代扣
充值:
status:
0 - 成功
1 - 失败
2 - 待支付
提现:
status:
0 - 成功
1 - 失败
2 - 待审核
3 - 审核成功
4 - 审核拒绝
转账
type:
0 - 充值
1 - 提现
2 - 转账
3 - 虚拟转账(电子户)
*/
Id int64 `gorm:"primary_key;column:id" json:"id"` //
OrderId string `gorm:"column:order_id" json:"orderId"` // 订单号
MerchantOrderId string `gorm:"column:merchant_order_id" json:"merchantOrderId"` // 商户订单号
ChannelOrderId string `gorm:"column:channel_order_id" json:"channelOrderId"` // 渠道订单号
MerchantId int64 `gorm:"column:merchant_id" json:"merchantId"` // 商户ID
ChannelId int64 `gorm:"column:channel_id" json:"channelId"` // 渠道ID
Amount decimal.Decimal `gorm:"column:amount" json:"amount"` // 金额
ActAmount decimal.Decimal `gorm:"column:act_amount" json:"actAmount"` // 实际到账金额
Fee decimal.Decimal `gorm:"column:fee" json:"fee"` // 手续费
Type string `gorm:"column:type" json:"type"` // 0-代收 1-代扣
SuccessTime int64 `gorm:"column:success_time" json:"successTime"` // 成功时间
CreateTime int64 `gorm:"column:create_time" json:"createTime"` // 创建时间
Status string `gorm:"column:status" json:"status"` // 订单状态
ErrMsg string `gorm:"column:err_msg" json:"errMsg"` // 失败原因
CallbackStatus bool `gorm:"column:callback_status" json:"callbackStatus"` // 回调状态
CallbackErrMsg string `gorm:"column:callback_err_msg" json:"callbackErrMsg"` // 回调失败原因
CallbackTime int64 `gorm:"column:callback_time" json:"callbackTime"` // 回调时间
Uid int64 `gorm:"column:uid" json:"uid"` // 操作人UID
From OrderAccount `gorm:"column:from" json:"from"` // from
To OrderAccount `gorm:"column:to" json:"to"` // to
Customer JSON `gorm:"column:customer" json:"customer"` // 自定义字段 回调时返回
}
func (Order) TableName() string {
return "order"
}
type OrderAccount struct {
/*
账户信息
*/
Account string `json:"account,omitempty"` // 账号
Name string `json:"name,omitempty"` // 名称
}
func (j *OrderAccount) Scan(value interface{}) error {
return json.Unmarshal(value.([]byte), &j)
}
func (j OrderAccount) Value() (driver.Value, error) {
return json.Marshal(j)
}