Documentation ¶
Index ¶
- Constants
- Variables
- func AutoMigrate() error
- func GetK(k string) string
- func GetOtherNotify(address string) bool
- func Init() error
- func IsNeedNotifyByTxid(txid string) bool
- func SetK(k, v string)
- type Config
- type NotifyRecord
- type TradeOrders
- func (o *TradeOrders) GetStatusLabel() string
- func (o *TradeOrders) OrderSetExpired() error
- func (o *TradeOrders) OrderSetNotifyState(state int) error
- func (o *TradeOrders) OrderSetSucc() error
- func (o *TradeOrders) OrderUpdateTxInfo(refBlockNum int64, fromAddress, tradeHash string, confirmedAt time.Time) error
- type WalletAddress
Constants ¶
View Source
const OrderNotifyStateFail = 0 // 回调失败
View Source
const OrderNotifyStateSucc = 1 // 回调成功
View Source
const OrderStatusExpired = 3 // 订单过期
View Source
const OrderStatusSuccess = 2 // 订单成功
View Source
const OrderStatusWaiting = 1 // 等待支付
View Source
const OrderTradeTypeTronTrx = "tron.trx"
View Source
const OrderTradeTypeUsdtTrc20 = "usdt.trc20"
View Source
const OtherNotifyDisable = 0
View Source
const OtherNotifyEnable = 1
View Source
const StatusDisable = 0
View Source
const StatusEnable = 1
Variables ¶
View Source
var DB *gorm.DB
Functions ¶
func AutoMigrate ¶ added in v1.9.26
func AutoMigrate() error
func GetOtherNotify ¶
func IsNeedNotifyByTxid ¶
Types ¶
type Config ¶ added in v1.13.29
type NotifyRecord ¶
type NotifyRecord struct { Txid string `gorm:"primary_key;type:varchar(64);not null;comment:交易哈希"` CreatedAt time.Time `gorm:"autoCreateTime;type:timestamp;not null;comment:创建时间"` UpdatedAt time.Time `gorm:"autoUpdateTime;type:timestamp;not null;comment:更新时间"` }
func (*NotifyRecord) TableName ¶
func (nr *NotifyRecord) TableName() string
type TradeOrders ¶
type TradeOrders struct { Id int64 `gorm:"primary_key;AUTO_INCREMENT;comment:id"` OrderId string `gorm:"type:varchar(255);not null;unique;color:blue;comment:客户订单ID"` TradeId string `gorm:"type:varchar(255);not null;unique;color:blue;comment:本地订单ID"` TradeType string `gorm:"type:varchar(20);not null;comment:交易类型"` TradeHash string `gorm:"type:varchar(64);default:'';unique;comment:交易哈希"` TradeRate string `gorm:"type:varchar(10);not null;comment:交易汇率"` Amount string `gorm:"type:decimal(10,2);not null;default:0;comment:USDT交易数额"` Money float64 `gorm:"type:decimal(10,2);not null;default:0;comment:订单交易金额"` Address string `gorm:"type:varchar(34);not null;comment:收款地址"` FromAddress string `gorm:"type:varchar(34);not null;default:'';comment:支付地址"` Status int `gorm:"type:tinyint(1);not null;default:0;comment:交易状态 1:等待支付 2:支付成功 3:订单过期"` ReturnUrl string `gorm:"type:varchar(255);not null;default:'';comment:同步地址"` NotifyUrl string `gorm:"type:varchar(255);not null;default:'';comment:异步地址"` NotifyNum int `gorm:"type:int(11);not null;default:0;comment:回调次数"` NotifyState int `gorm:"type:tinyint(1);not null;default:0;comment:回调状态 1:成功 0:失败"` RefBlockNum int64 `gorm:"type:bigint(20);not null;default:0;comment:交易所在区块"` ExpiredAt time.Time `gorm:"type:timestamp;not null;comment:订单失效时间"` CreatedAt time.Time `gorm:"autoCreateTime;type:timestamp;not null;comment:创建时间"` UpdatedAt time.Time `gorm:"autoUpdateTime;type:timestamp;not null;comment:更新时间"` ConfirmedAt time.Time `gorm:"type:timestamp;null;comment:交易确认时间"` }
func GetNotifyFailedTradeOrders ¶
func GetNotifyFailedTradeOrders() ([]TradeOrders, error)
func GetTradeOrder ¶
func GetTradeOrder(tradeId string) (TradeOrders, bool)
func GetTradeOrderByStatus ¶
func GetTradeOrderByStatus(Status int) ([]TradeOrders, error)
func (*TradeOrders) GetStatusLabel ¶ added in v1.8.20
func (o *TradeOrders) GetStatusLabel() string
func (*TradeOrders) OrderSetExpired ¶
func (o *TradeOrders) OrderSetExpired() error
func (*TradeOrders) OrderSetNotifyState ¶
func (o *TradeOrders) OrderSetNotifyState(state int) error
func (*TradeOrders) OrderSetSucc ¶
func (o *TradeOrders) OrderSetSucc() error
func (*TradeOrders) OrderUpdateTxInfo ¶ added in v1.13.29
type WalletAddress ¶
type WalletAddress struct { Id int64 `gorm:"integer;primaryKey;not null;comment:id"` Address string `gorm:"type:varchar(255);not null;unique;comment:钱包地址"` Status int `gorm:"type:tinyint(1);not null;default:1;comment:地址状态 1启动 0禁止"` OtherNotify int `gorm:"type:tinyint(1);not null;default:1;comment:其它转账通知 1启动 0禁止"` CreatedAt time.Time `gorm:"autoCreateTime;type:timestamp;not null;comment:创建时间"` UpdatedAt time.Time `gorm:"autoUpdateTime;type:timestamp;not null;comment:更新时间"` }
func CalcTradeAmount ¶
func CalcTradeAmount(wa []WalletAddress, rate, money float64, tradeType string) (WalletAddress, string)
CalcTradeAmount 计算当前实际可用的交易金额
func GetAvailableAddress ¶
func GetAvailableAddress() []WalletAddress
func (*WalletAddress) Delete ¶
func (wa *WalletAddress) Delete()
func (*WalletAddress) SetOtherNotify ¶
func (wa *WalletAddress) SetOtherNotify(notify int)
func (*WalletAddress) SetStatus ¶
func (wa *WalletAddress) SetStatus(status int)
func (*WalletAddress) TableName ¶
func (wa *WalletAddress) TableName() string
Click to show internal directories.
Click to hide internal directories.