goProject/trunk/center/paycenter/internal/pay/order.go
2025-01-23 16:12:49 +08:00

68 lines
2.3 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package pay
import (
"common/connection"
"strconv"
"time"
)
func init() {
//注册数据库
connection.RegisterDBModel(&Order{})
}
type Order struct {
//订单id
OrderID int64 `gorm:"column:order_id;primary_key;comment:订单id" json:"order_id"`
//订单号
PrepayId string `gorm:"column:prepay_id;comment:预支付交易会话标识" json:"prepay_id"`
//订单金额
OrderMoney int64 `gorm:"column:order_money;comment:订单金额" json:"order_money"`
//订单状态 0:未支付 1:已支付 2:已关闭
OrderStatus int32 `gorm:"column:order_status;comment:订单状态" json:"order_status"`
//用户id
UserID string `gorm:"column:user_id;comment:用户id" json:"user_id"`
//区服id
ServerID int64 `gorm:"column:server_id;comment:区服id" json:"server_id"`
//玩家标识
PlayerID string `gorm:"column:player_id;comment:玩家标识" json:"player_id"`
//是否通知游戏服 0未通知 1已通知
IsNotifyGameServer int32 `gorm:"column:is_notify_game_server;comment:是否通知游戏服" json:"is_notify_game_server"`
//订单日期
OrderDate time.Time `gorm:"column:order_date;comment:订单日期" json:"order_date"`
//订单时间
OrderTime time.Time `gorm:"column:order_time;type:date;comment:订单时间" json:"order_time"`
//订单类型 1:微信支付 2:支付宝支付
OrderType int32 `gorm:"column:order_type;comment:订单类型" json:"order_type"`
//表的名字 这里是表的后缀
TableNameData int32 `gorm:"column:table_name;comment:表的名字 这里是表的后缀" json:"table_name"`
}
// TableName 表名
func (order *Order) TableName() string {
return "order_" + strconv.Itoa(int(order.TableNameData))
}
// NewOrder 创建订单
// @param orderId 订单id
// @param prepayId 预支付id
// @param playerID 玩家id
// @param serverID 服务器id
// @param orderType 订单类型
func NewOrder(orderId int64, prepayId string, playerID string, serverID int64, orderType int32) *Order {
return &Order{
OrderID: orderId,
PrepayId: prepayId,
OrderMoney: 100,
OrderStatus: 1,
PlayerID: playerID,
ServerID: serverID,
UserID: playerID,
OrderDate: time.Now(),
OrderTime: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC),
OrderType: orderType,
TableNameData: connection.GetMonth(),
}
}