db

package
v0.0.0-...-19e6259 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoleTypeAdmin = 1 //管理员账号
	RoleTypeThird = 2 //三方平台账号
)

Users表中role字段的取值

View Source
const (
	OpActionRegister  = 1 //注册
	OpActionFreezen   = 2 //冻结账号
	OpActionUnFreezen = 3 //账号解冻
	OpActionDelete    = 4 //账号删除
)
View Source
const (
	UserOffline = 1 //离线
	UserOnline  = 2 //在线
)
View Source
const (
	StatusNormal  = 1 //正常
	StatusDeleted = 2 //删除
	StatusFreezed = 3 //冻结
	StatusBound   = 4 //绑定
)
View Source
const (
	OrderStatusCreated  = 1 //创建
	OrderStatusPayed    = 2 //完成
	OrderStatusNotified = 3 //已确认订单
)

订单状态

View Source
const (
	OrderTypeUnknown      = iota
	OrderTypeBuyToken     //购买令牌
	OrderTypeConsumeToken //消费代币(eg:使用令牌购买游戏中的道具,比如房卡)
	OrderTypeConsume3rd   //第三方支付平台消费(eg:直接使用alipay, wechat等购买游戏中的道具)
	OrderTypeTest         //支付测试
)
View Source
const (
	NotifyResultSuccess = 1 //通知成功
	NotifyResultFailed  = 2 //通知失败
)
View Source
const (
	RankingNormal = 1
	RankingDesc   = 2
)
View Source
const (
	DefaultTopN = 10
)
View Source
const (
	KWX = "broker"
)

Variables

This section is empty.

Functions

func ApplyClub

func ApplyClub(uid, clubId int64) error

func BalanceList

func BalanceList(uids []string) (map[string]string, error)

func BuildDSN

func BuildDSN(host string, port int, username, password, dbname, args string) string

Build data source name

func ChannelCondition

func ChannelCondition(c []string) string

func ClubList

func ClubList(uid int64) ([]model.Club, error)

func ClubLoseBalance

func ClubLoseBalance(clubId, balance int64, consume *model.CardConsume) error

func Combined

func Combined(cond ...string) string

func ConsumeStats

func ConsumeStats(from, to int64) ([]*protocol.CardConsume, error)

消耗统计

func DeleteDesk

func DeleteDesk(id int64) error

func DeleteHistoriesByDeskID

func DeleteHistoriesByDeskID(deskId int64) error

func DeleteHistory

func DeleteHistory(id int64) error

func DeleteUser

func DeleteUser(uid int64) error

DeleteUser delete the user

func DeskList

func DeskList(player int64) ([]model.Desk, int, error)

func DeskNumberExists

func DeskNumberExists(no string) bool

指定的桌子是否存在

func EqInt64Condition

func EqInt64Condition(col string, v int64) string

func EqIntCondition

func EqIntCondition(col string, v int) string

func Insert

func Insert(bean interface{}) error

func InsertConsume

func InsertConsume(entity *model.CardConsume) error

func InsertDesk

func InsertDesk(h *model.Desk) error

func InsertHistory

func InsertHistory(h *model.History) error

func InsertLoginLog

func InsertLoginLog(uid int64, d protocol.Device, appid string, channelID string)

func InsertOnline

func InsertOnline(count int, deskCount int)

func InsertOrder

func InsertOrder(order *model.Order) error

func InsertRegister

func InsertRegister(reg *model.Register)

func InsertThirdAccount

func InsertThirdAccount(account *model.ThirdAccount, u *model.User) error

func InsertTrade

func InsertTrade(t *model.Trade) error

func InsertUser

func InsertUser(u *model.User) error

InsertUser insert a new user

func IsBalanceEnough

func IsBalanceEnough(clubId int64) bool

func IsClubMember

func IsClubMember(clubId, uid int64) bool

func IsUserExists

func IsUserExists(uid int64) bool

IsUserExists is the user with uid is existed

func LtInt64Condition

func LtInt64Condition(col string, v int64) string

func MustStartup

func MustStartup(dsn string, opts ...ModelOption) func()

New create the database's connection

func OnlineStats

func OnlineStats(begin, end int64) ([]model.Online, error)

func OnlineStatsLite

func OnlineStatsLite() (*model.Online, error)

实时在线人/桌数

func OrderList

func OrderList(uid int64, appid, channelID, orderID, payBy string, start, end int64, status, offset, count int) ([]model.Order, int, error)

func QueryActivationUser

func QueryActivationUser(from, to int64) ([]*protocol.ActivationUser, error)

活跃人数

func QueryDesk

func QueryDesk(id int64) (*model.Desk, error)

func QueryGuestUser

func QueryGuestUser(appId string, imei string) (*model.User, error)

func QueryHistoriesByDeskID

func QueryHistoriesByDeskID(deskID int64) ([]model.History, int, error)

func QueryHistory

func QueryHistory(id int64) (*model.History, error)

func QueryOrder

func QueryOrder(orderID string) (*model.Order, error)

func QueryRegisterUsers

func QueryRegisterUsers(begin, end int64) (int, error)

注册用户数

func QueryThirdAccount

func QueryThirdAccount(account, platform string) (*model.ThirdAccount, error)

func QueryUser

func QueryUser(id int64) (*model.User, error)

QueryUser get the user by id

func QueryUserInfo

func QueryUserInfo(id int64) (*protocol.UserStatsInfo, error)

QueryUserInfo get the user by id

func QueryUserList

func QueryUserList(offset, count int) ([]model.User, int64, error)

func RangeCondition

func RangeCondition(column string, begin, end int64) string

给定列, 返回起始时间条件SQL语句, [begin, end)

func RegisterUserLog

func RegisterUserLog(u *model.User, d protocol.Device, appid string, channelID string, regType int)

func RetentionList

func RetentionList(current int) (*protocol.Retention, error)

某注册天的 n日留存

func UpdateDesk

func UpdateDesk(d *model.Desk) error

func UpdateThirdAccount

func UpdateThirdAccount(account *model.ThirdAccount) error

func UpdateUser

func UpdateUser(u *model.User) error

UpdateUser update user's info

func UserAddCoin

func UserAddCoin(uid int64, coin int64) error

func UserLoseCoin

func UserLoseCoin(id int64, coin int64) error

func UserLoseCoinByUID

func UserLoseCoinByUID(uid int64, coin int64) error

func YXPayOrderList

func YXPayOrderList(uid int64, appid, channelID, orderID string, start, end int64, typ, offset, count int) ([]model.Order, int, error)

Types

type Closer

type Closer func()

type KeyPair

type KeyPair struct {
	PrivateKey string
	PublicKey  string
}

KeyPair rsa's public & private key pair

type Logger

type Logger struct {
	*log.Entry
	// contains filtered or unexported fields
}

func (*Logger) IsShowSQL

func (l *Logger) IsShowSQL() bool

func (*Logger) Level

func (l *Logger) Level() core.LogLevel

func (*Logger) SetLevel

func (l *Logger) SetLevel(level core.LogLevel)

func (*Logger) ShowSQL

func (l *Logger) ShowSQL(show ...bool)

type ModelOption

type ModelOption func(*options)

ModelOption specifies an option for dialing a xordefaultModel.

func MaxIdleConns

func MaxIdleConns(i int) ModelOption

MaxIdleConns specifies the max idle connect numbers.

func MaxOpenConns

func MaxOpenConns(i int) ModelOption

MaxOpenConns specifies the max open connect numbers.

func ShowSQL

func ShowSQL(show bool) ModelOption

ShowSQL specifies the buffer size.

type Option

type Option func(setting *Setting)

func MaxIdleConnOption

func MaxIdleConnOption(i int) Option

func MaxOpenConnOption

func MaxOpenConnOption(i int) Option

func ShowSQLOption

func ShowSQLOption(show bool) Option

type Setting

type Setting struct {
	ShowSQL      bool
	MaxOpenConns int
	MaxIdleConns int
}

type ViewChannelApp

type ViewChannelApp struct {
	Id     int64
	Type   byte
	Status byte

	Uid             int64
	CreatedAt       int64
	RegisterAt      int64
	FirstRechargeAt int64

	RealMoney    int
	RegisterType int

	Os                string
	Imei              string
	OrderId           string
	AppId             string
	Model             string
	ServerId          string
	ProductId         string
	OrderPlatform     string
	PayPlatform       string
	PassportChannelId string
	PaymentChannelId  string
}

trade & register & user => views

func (*ViewChannelApp) TableName

func (v *ViewChannelApp) TableName() string

type ViewTrade

type ViewTrade struct {
	PayAt int64
	Uid   int64
	Id    int64

	Type         int
	Money        int
	RealMoney    int
	ProductCount int
	Status       int

	OrderId        string
	ComsumerId     string
	AppId          string
	ChannelId      string
	OrderPlatform  string
	ChannelOrderId string
	Currency       string
	RoleId         string
	ServerName     string
	ProductId      string
	ProductName    string
	RoleName       string
	PayPlatform    string
}

trade & order => views

func TradeList

func TradeList(appid, channelID, orderID string, start, end int64, offset, count int) ([]ViewTrade, int, error)

func (*ViewTrade) TableName

func (v *ViewTrade) TableName() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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