assets

package
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2023 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FreezeStatusNew  FreezeStatus = 0
	FreezeStatusDone FreezeStatus = 1

	Behavior_Trade    OpBehavior = "trade"
	Behavior_Recharge OpBehavior = "deposit"
	Behavior_Withdraw OpBehavior = "withdraw"
	Behavior_Transfer OpBehavior = "transfer"
)
View Source
const (
	//根账户,所有的进出账都从这个账户开始,所有列的资产求和应该为0
	UserRoot string = "root"
	//系统收取手续费用放在该用户ID下
	UserSystemFee string = "fee"
)

Variables

This section is empty.

Functions

func BalanceOfAvailable

func BalanceOfAvailable(user_id, symbol string) decimal.Decimal

func BalanceOfFreeze

func BalanceOfFreeze(user_id, symbol string) decimal.Decimal

func BalanceOfTotal

func BalanceOfTotal(user_id, symbol string) decimal.Decimal

func DemoData

func DemoData()

func FreezeAssets

func FreezeAssets(db *xorm.Session, user_id string, symbol string, freeze_amount, business_id string, behavior OpBehavior) (success bool, err error)

func FreezeTotalAssets

func FreezeTotalAssets(db *xorm.Session, user_id string, symbol string, business_id string, behavior OpBehavior) (success bool, err error)

func QueryAssetsLogBusIdIsExist

func QueryAssetsLogBusIdIsExist(symbol string, user_id string, business_id string) bool

func SysDeposit

func SysDeposit(to string, symbol string, amount string, business_id string) (success bool, err error)

充值

func SysWithdraw

func SysWithdraw(user_id string, symbol string, amount string, business_id string) (success bool, err error)

提现

func Transfer

func Transfer(db *xorm.Session, from, to string, symbol string, amount string, business_id string, behavior OpBehavior, note string) (success bool, err error)

func UnfreezeAllAssets

func UnfreezeAllAssets(db *xorm.Session, symbol string, user_id string, business_id string) (success bool, err error)

func UnfreezeAssets

func UnfreezeAssets(db *xorm.Session, symbol string, user_id string, business_id, unfreeze_amount string) (success bool, err error)

Types

type Assets

type Assets struct {
	Id         int64      `xorm:"pk autoincr bigint" json:"id"`
	UserId     string     `xorm:"varchar(30) notnull unique(userid_symbol)" json:"user_id"`
	Symbol     string     `xorm:"varchar(30) notnull unique(userid_symbol)" json:"symbol"`
	Total      string     `xorm:"decimal(40,20) default(0) notnull" json:"total"`
	Freeze     string     `xorm:"decimal(40,20) default(0) notnull" json:"freeze"`
	Available  string     `xorm:"decimal(40,20) default(0) notnull" json:"avail"`
	CreateTime utils.Time `xorm:"timestamp created" json:"create_time"`
	UpdateTime utils.Time `xorm:"timestamp updated" json:"update_time"`
}

用户资产余额表

func FindSymbol

func FindSymbol(user_id string, symbol string) *Assets

func UserAssets

func UserAssets(user_id string, symbol []string) []Assets

type AssetsFreeze

type AssetsFreeze struct {
	Id           int64        `xorm:"pk autoincr bigint" json:"id"`
	UserId       string       `xorm:"varchar(30) index notnull" json:"user_id"`
	Symbol       string       `xorm:"varchar(30) index notnull" json:"symbol"`
	Amount       string       `xorm:"decimal(40,20) default(0) notnull" json:"amount"`             // 冻结总量
	FreezeAmount string       `xorm:"decimal(40,20) default(0) notnull" json:"freeze_amount"`      // 冻结着的量
	Status       FreezeStatus `xorm:"tinyint(1)" json:"status"`                                    // 状态 冻结中, 已解冻
	BusinessId   string       `xorm:"varchar(100) unique(business_id) notnull" json:"business_id"` //业务相关的id
	OpType       OpBehavior   `xorm:"varchar(15)" json:"op_type"`
	Info         string       `xorm:"varchar(64)" json:"info"`
	CreateTime   utils.Time   `xorm:"timestamp created" json:"create_time"`
	UpdateTime   utils.Time   `xorm:"timestamp updated" json:"update_time"`
}

func QueryFreeze

func QueryFreeze(db *xorm.Session, symbol string, business_id string) (*AssetsFreeze, error)

func (*AssetsFreeze) TableName added in v0.1.7

func (a *AssetsFreeze) TableName() string

type AssetsHealthStatus

type AssetsHealthStatus struct {
	GlobalTotal string `json:"global_total"`
	UserTotal   string `json:"user_total"`
	Health      bool   `json:"health"`
}

func AssetsCheck

func AssetsCheck() AssetsHealthStatus

type AssetsLog

type AssetsLog struct {
	Id         int64      `xorm:"pk autoincr bigint" json:"id"`
	UserId     string     `xorm:"varchar(30) index notnull" json:"user_id"`
	Symbol     string     `xorm:"varchar(30) index notnull" json:"symbol"`
	Before     string     `xorm:"decimal(40,20) default(0)" json:"before"`                    // 变动前
	Amount     string     `xorm:"decimal(40,20) default(0)" json:"amount"`                    // 变动数
	After      string     `xorm:"decimal(40,20) default(0)" json:"after"`                     // 变动后
	BusinessId string     `xorm:"varchar(100) index(business_id) notnull" json:"business_id"` //业务相关的id
	OpType     OpBehavior `xorm:"varchar(15)" json:"op_type"`
	Info       string     `xorm:"varchar(150)" json:"info"`
	CreateTime utils.Time `xorm:"timestamp created" json:"create_time"`
	UpdateTime utils.Time `xorm:"timestamp updated" json:"update_time"`
}

用户资产变动记录

func (*AssetsLog) TableName added in v0.1.7

func (a *AssetsLog) TableName() string

type FreezeStatus

type FreezeStatus int

用户资产冻结记录

type OpBehavior

type OpBehavior string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL