|
|
|
|
package common
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"reflect"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 账号身份
|
|
|
|
|
const (
|
|
|
|
|
PlayerRoleNormal = iota
|
|
|
|
|
PlayerRoleRobot = 100
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 玩家状态
|
|
|
|
|
const (
|
|
|
|
|
PlayerStatusNormal = iota + 1
|
|
|
|
|
PlayerStatusMatching
|
|
|
|
|
PlayerStatusPlaying
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 玩家是否在线
|
|
|
|
|
const (
|
|
|
|
|
PlayerOnline = iota + 1
|
|
|
|
|
PlayerOffline
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type PlayerDBInfo struct {
|
|
|
|
|
Id int `gorm:"primary_key;AUTO_INCREMENT;column:id" json:"id" redis:"id"`
|
|
|
|
|
ADID string `gorm:"column:adid;type:varchar(256);comment:玩家adjustID" json:"adid" redis:"adid"`
|
|
|
|
|
GPSADID string `gorm:"column:gps_adid;type:varchar(256);comment:玩家google广告ID" json:"gps_adid" redis:"gps_adid"`
|
|
|
|
|
Openid *string `gorm:"column:openid;type:varchar(128);uniqueIndex:channel_openid;comment:唯一识别号" json:"-" redis:"openid"`
|
|
|
|
|
IP string `gorm:"column:ip;type:varchar(256);comment:玩家登录ip" json:"ip" redis:"ip"`
|
|
|
|
|
Pass string `gorm:"column:pass;type:varchar(64)" json:"pass" redis:"pass"`
|
|
|
|
|
Nick string `gorm:"column:nick;type:varchar(64)" json:"nick" redis:"nick"`
|
|
|
|
|
Mobile string `gorm:"column:mobile;default:null;type:varchar(64);uniqueIndex:channel_mobile" json:"mobile" redis:"mobile"`
|
|
|
|
|
Avatar string `gorm:"column:avatar;type:varchar(512);default:''" json:"avatar" redis:"avatar"`
|
|
|
|
|
DeviceId string `gorm:"column:deviceid;type:varchar(256);default:'';comment:设备号" json:"deviceid" redis:"deviceid"`
|
|
|
|
|
SessionID string `gorm:"-" json:"sessionID" redis:"sessionID"`
|
|
|
|
|
AccountName string `gorm:"column:account_name;default:null;uniqueIndex:channel_account_name;commont:账户名" json:"account_name" redis:"account_name"`
|
|
|
|
|
GateID string `gorm:"-" json:"gateID" redis:"gateID"`
|
|
|
|
|
Token string `gorm:"-" json:"token" redis:"token"`
|
|
|
|
|
Birth int64 `gorm:"column:birth;type:bigint(20);default:0;comment:账号创建时间,时间戳" json:"birth" redis:"birth"`
|
|
|
|
|
Role int `gorm:"column:role;type:smallint(8);default:0;comment:玩家角色0普通玩家,100机器人" json:"role" redis:"role"`
|
|
|
|
|
ChannelID int `gorm:"column:channel_id;type:bigint(20);uniqueIndex:channel_openid;uniqueIndex:channel_mobile;uniqueIndex:channel_account_name;default:1;comment:渠道id" json:"channel_id" redis:"channel_id"`
|
|
|
|
|
AccountType int `gorm:"column:account_type;comment:0游客,1fb,2gp" json:"account_type" redis:"account_type"`
|
|
|
|
|
Status int `gorm:"column:status;type:tinyint(4);default:1;comment:账号状态,1正常,2封禁" json:"status" redis:"status"`
|
|
|
|
|
Online int `gorm:"column:online;type:tinyint(4);default:2;comment:是否在线,1在线,2不在线" json:"online" redis:"online"`
|
|
|
|
|
Tag string `gorm:"column:tag; type:varchar(512);default:'';comment:后台管理给账户打的标签,用户不可见" json:"tag" redis:"tag"`
|
|
|
|
|
Platform int `gorm:"column:platform;type:int(11);default:1;comment:最新登录平台" json:"platform" redis:"platform"`
|
|
|
|
|
LastLogin int64 `gorm:"column:last_login;type:bigint(20);default:0;comment:最近登录时间" json:"last_login" redis:"last_login"`
|
|
|
|
|
Country string `gorm:"column:country;type:varchar(64);default:'';comment:国家" json:"country" redis:"country"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (u *PlayerDBInfo) TableName() string {
|
|
|
|
|
return "users"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PlayerSession 玩家会话信息
|
|
|
|
|
type PlayerSession struct {
|
|
|
|
|
SessionID string `json:"sessionID" redis:"sessionID"`
|
|
|
|
|
GateID string `json:"gateID" redis:"gateID"`
|
|
|
|
|
Nick string `json:"nick" redis:"nick"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FacebookUserInfo facebook返回的登录接口
|
|
|
|
|
type FacebookUserInfo struct {
|
|
|
|
|
ID string
|
|
|
|
|
Name string
|
|
|
|
|
Picture struct {
|
|
|
|
|
Data struct {
|
|
|
|
|
URL string `json:"url"`
|
|
|
|
|
Height int
|
|
|
|
|
Width int
|
|
|
|
|
IsSilhouette bool
|
|
|
|
|
} `json:"data"`
|
|
|
|
|
} `json:"picture"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GooglePlayUserInfo googlePlay返回的登录接口
|
|
|
|
|
type GooglePlayUserInfo struct {
|
|
|
|
|
ID string `json:"sub"`
|
|
|
|
|
Email string
|
|
|
|
|
Name string
|
|
|
|
|
Given_name string
|
|
|
|
|
Family_name string
|
|
|
|
|
Picture string
|
|
|
|
|
Locale string
|
|
|
|
|
Verified_email bool
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PlayerStatus 玩家状态
|
|
|
|
|
// type PlayerStatus struct {
|
|
|
|
|
// GameName string `json:"GameName" redis:"GameName"`
|
|
|
|
|
// UUID string `json:"UUID" redis:"UUID"`
|
|
|
|
|
// TableID string `json:"TableID" redis:"TableID"`
|
|
|
|
|
// ActiveTime int64 `json:"ActiveTime" redis:"ActiveTime"`
|
|
|
|
|
// WorkID int `json:"WorkID" redis:"WorkID"`
|
|
|
|
|
// MatchID uint32 `json:"MatchID" redis:"MatchID"`
|
|
|
|
|
// Status uint32 `json:"Status" redis:"Status"`
|
|
|
|
|
// GameID uint32 `json:"GameID" redis:"GameID"`
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// func (s *PlayerStatus) MarshalBinary() ([]byte, error) {
|
|
|
|
|
// return json.Marshal(s)
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// func (s *PlayerStatus) UnmarshalBinary(data []byte) error {
|
|
|
|
|
// return json.Unmarshal(data, s)
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// NormalPlayerSql 返回查询正常用户的sql条件语句
|
|
|
|
|
func NormalPlayerSql(channel ...*int) string {
|
|
|
|
|
sql := ""
|
|
|
|
|
for _, v := range channel {
|
|
|
|
|
if v == nil {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
if sql == "" {
|
|
|
|
|
sql += fmt.Sprintf("(channel_id = %v", *v)
|
|
|
|
|
} else {
|
|
|
|
|
sql += fmt.Sprintf(" or channel_id = %v", *v)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if len(sql) > 0 {
|
|
|
|
|
sql += ")"
|
|
|
|
|
}
|
|
|
|
|
sql += fmt.Sprintf(" and role <> %v and status = %v", PlayerRoleRobot, AccountStatusNormal)
|
|
|
|
|
return sql
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PlayerData 保存一些玩家记录
|
|
|
|
|
type PlayerData struct {
|
|
|
|
|
UID int `gorm:"column:uid;not null;type:int(11);uniqueIndex:uid"`
|
|
|
|
|
LastSysEmailDraw int64 `gorm:"column:last_sys_email_draw;type:bigint(20);default:0;comment:最近一次接收系统邮件的时间"`
|
|
|
|
|
LastAppSpinDraw int64 `gorm:"column:last_app_spin_draw;type:bigint(20);default:0;comment:上次领取app下载转盘的时间"`
|
|
|
|
|
FeedbackTime int64 `gorm:"column:feedback_time;type:bigint(20);default:0;comment:完成问卷调查的时间"`
|
|
|
|
|
DayBet int64 `gorm:"column:day_bet;type:bigint(20);default:0;comment:日打码"`
|
|
|
|
|
DayBetTime int64 `gorm:"column:day_bet_time;type:bigint(20);default:0;comment:修改时间"`
|
|
|
|
|
LastPopUp int64 `gorm:"column:last_pop_up;type:bigint(20);default:0;comment:上次弹窗时间"`
|
|
|
|
|
LuckyWheel string `gorm:"column:lucky_wheel;type:varchar(1024);default:'';comment:转盘抽奖发放信息"`
|
|
|
|
|
LuckyWheelMap map[string]int `gorm:"-"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (u *PlayerData) TableName() string {
|
|
|
|
|
return "player_data"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PlayerRed 玩家红点信息
|
|
|
|
|
type PlayerRed struct {
|
|
|
|
|
ID uint `gorm:"primarykey"`
|
|
|
|
|
UID int `gorm:"column:uid;not null;type:int(11);uniqueIndex:uid"`
|
|
|
|
|
Mail int `gorm:"column:mail;type:int(11);comment:未读取邮件数" json:"Mail"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (u *PlayerRed) TableName() string {
|
|
|
|
|
return "player_red"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
ItemStatusZero = iota
|
|
|
|
|
ItemStatusNormal // 正常
|
|
|
|
|
ItemStatusInvalid // 不可用
|
|
|
|
|
ItemStatusAll
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 物品的枚举
|
|
|
|
|
const (
|
|
|
|
|
ItemZero = iota
|
|
|
|
|
ItemDiscountTicket
|
|
|
|
|
ItemAll
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// PlayerItems 玩家道具
|
|
|
|
|
type PlayerItems struct {
|
|
|
|
|
ID int `gorm:"primarykey"`
|
|
|
|
|
UID int `gorm:"column:uid;type:int(11)"`
|
|
|
|
|
ItemID int `gorm:"column:item_id;default:0;comment:物品id"`
|
|
|
|
|
Time int64 `gorm:"column:time;type:bigint(20);default:0;comment:获得的时间"`
|
|
|
|
|
Status int `gorm:"column:status;type:int(11);default:0;comment:物品状态"`
|
|
|
|
|
Exi1 int64 `gorm:"column:exi1;type:bigint(20);default:0;comment:物品标识字段1"`
|
|
|
|
|
Exi2 int64 `gorm:"column:exi2;type:bigint(20);default:0;comment:物品标识字段2"`
|
|
|
|
|
Exi3 int64 `gorm:"column:exi3;type:bigint(20);default:0;comment:物品标识字段3"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *PlayerItems) TableName() string {
|
|
|
|
|
return "player_items"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PlayerH5Data 玩家H5数据
|
|
|
|
|
type PlayerH5Data struct {
|
|
|
|
|
UID int `gorm:"primary_key;column:uid;type:int(11)"`
|
|
|
|
|
Collect int `gorm:"column:collect;type:int(11);default:1;comment:是否已领取H5收藏奖励,1未领取,2已领取"`
|
|
|
|
|
Download int `gorm:"column:download;type:int(11);default:1;comment:是否已领取H5下载奖励,1未领取,2已领取"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *PlayerH5Data) TableName() string {
|
|
|
|
|
return "player_h5data"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
PlayerRechargeTableName = "player_currency_recharge" // 玩家充值账户
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// PlayerCurrency 玩家货币数据(此结构只能往后新增字段,前面字段不能修改顺序)
|
|
|
|
|
type PlayerCurrency struct {
|
|
|
|
|
UID int `gorm:"primary_key;column:uid;type:int(11)"`
|
|
|
|
|
ChannelID int `gorm:"column:channel_id;type:bigint(20);default:1;comment:渠道id"`
|
|
|
|
|
INR int64 `gorm:"column:inr;type:bigint(20);default:0;comment:卢比"`
|
|
|
|
|
USDT int64 `gorm:"column:usdt;type:bigint(20);default:0;comment:usdt"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *PlayerCurrency) TableName() string {
|
|
|
|
|
return "player_currency"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *PlayerCurrency) GetBalanceByType(ct CurrencyType) int64 {
|
|
|
|
|
ref := reflect.ValueOf(p).Elem()
|
|
|
|
|
val := ref.Field(int(ct) + 1)
|
|
|
|
|
if val.IsValid() {
|
|
|
|
|
return val.Int()
|
|
|
|
|
}
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *PlayerCurrency) SetBalance(ct CurrencyType, value int64) {
|
|
|
|
|
ref := reflect.ValueOf(p).Elem()
|
|
|
|
|
val := ref.Field(int(ct) + 1)
|
|
|
|
|
if val.IsValid() {
|
|
|
|
|
val.SetInt(value)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PlayerProfile 玩家生涯数据
|
|
|
|
|
type PlayerProfile struct {
|
|
|
|
|
UID int `gorm:"primary_key;column:uid;type:int(11)"`
|
|
|
|
|
ChannelID int `gorm:"column:channel_id;type:bigint(20);default:1;comment:渠道id"`
|
|
|
|
|
NeedBet int64 `gorm:"column:need_bet;type:bigint(20);comment:当前所需下注量"`
|
|
|
|
|
TotalBet int64 `gorm:"column:total_bet;type:bigint(20);comment:总下注"`
|
|
|
|
|
TotalCounts int64 `gorm:"column:total_counts;type:bigint(20);comment:总下注次数"`
|
|
|
|
|
TotalSettle int64 `gorm:"column:total_settle;type:bigint(20);comment:总派发"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *PlayerProfile) TableName() string {
|
|
|
|
|
return "player_profile"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Level vip等级
|
|
|
|
|
// Bet 下注额
|
|
|
|
|
// Exp vip经验
|
|
|
|
|
// Draws 已经领取的vip等级奖励,从右至左,等级低到高
|
|
|
|
|
//
|
|
|
|
|
// Cashback 当前可领取的cashback
|
|
|
|
|
type VipData struct {
|
|
|
|
|
ID int `gorm:"primary_key;AUTO_INCREMENT;column:id" json:"ID"`
|
|
|
|
|
UID int `gorm:"column:uid;not null;type:int(11);uniqueIndex:uid" json:"UID"`
|
|
|
|
|
Level int `gorm:"column:level;not null;type:int(11);default:0;comment:vip等级" json:"Level"`
|
|
|
|
|
Bet int64 `gorm:"column:bet;not null;type:bigint(20);default:0;comment:下注额" json:"Bet"`
|
|
|
|
|
Exp int64 `gorm:"column:exp;not null;type:bigint(20);default:0;comment:vip经验" json:"Exp"`
|
|
|
|
|
Draws int64 `gorm:"column:draws;not null;type:bigint(20);default:0;comment:已经领取的vip等级奖励,从右至左,等级低到高" json:"Draws"`
|
|
|
|
|
WeekBonusAt int64 `gorm:"column:week_bonus_at;not null;type:bigint(20);default:0;comment:上一次领取周bonus" json:"WeekBonusAt"`
|
|
|
|
|
Profit int64 `gorm:"column:profit;not null;type:bigint(20);default:0;comment:计算周期内的盈亏" json:"Profit"`
|
|
|
|
|
ProfitTime int64 `gorm:"column:profit_time;not null;type:bigint(20);default:0;comment:开始计算时间节点" json:"ProfitTime"`
|
|
|
|
|
Cashback int64 `gorm:"column:cashback;not null;type:bigint(20);default:0;comment:当前可领取的cashback" json:"Cashback"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *VipData) TableName() string {
|
|
|
|
|
return "vip_data"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type TronData struct {
|
|
|
|
|
ID int `gorm:"primary_key;AUTO_INCREMENT;column:id"`
|
|
|
|
|
UID int `gorm:"column:uid;not null;type:int(11);uniqueIndex:uid"`
|
|
|
|
|
Addr string `gorm:"column:addr; type:varchar(256);default:'';comment:钱包地址"`
|
|
|
|
|
Usdt int64 `gorm:"column:usdt;type:bigint(20);default:0;comment:地址里的u存量,单位1e6"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *TronData) TableName() string {
|
|
|
|
|
return "tron_data"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PlayerStatus 玩家状态
|
|
|
|
|
type PlayerStatus struct {
|
|
|
|
|
ModuleName string `json:"ModuleName" redis:"ModuleName"`
|
|
|
|
|
WorkID int `json:"WorkID" redis:"WorkID"`
|
|
|
|
|
GameID int `json:"GameID" redis:"GameID"`
|
|
|
|
|
SubID int `json:"SubID" redis:"SubID"`
|
|
|
|
|
TableID string `json:"TableID" redis:"TableID"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 玩家广告相关数据
|
|
|
|
|
type PlayerADData struct {
|
|
|
|
|
ID int `gorm:"primarykey"`
|
|
|
|
|
UID int `gorm:"column:uid;type:int(11);index:uid"`
|
|
|
|
|
IP string `gorm:"column:ip;type:varchar(256);comment:玩家ip"`
|
|
|
|
|
FBC string `gorm:"column:fbc;type:varchar(256);comment:玩家点击识别号"`
|
|
|
|
|
FBP string `gorm:"column:fbp;type:varchar(256);comment:玩家浏览器识别号"`
|
|
|
|
|
ChannelID int `gorm:"column:channel_id;type:bigint(20);default:1000;comment:渠道id"`
|
|
|
|
|
UserAgent string `gorm:"column:user_agent;type:varchar(256);comment:玩家浏览器版本"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *PlayerADData) TableName() string {
|
|
|
|
|
return "player_ad_data"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 玩家购买记录
|
|
|
|
|
type PlayerPayData struct {
|
|
|
|
|
ID uint `gorm:"primarykey"`
|
|
|
|
|
UID int `gorm:"column:uid;not null;type:int(11);uniqueIndex:uid"`
|
|
|
|
|
BreakGift string `gorm:"column:break_gift;type:varchar(256);default:'';comment:已购买破产礼包的档位"`
|
|
|
|
|
SubBreakGift []int `gorm:"-"`
|
|
|
|
|
// FirstPay string `gorm:"column:first_pay;default:'';type:varchar(256);comment:首次购买商品记录"`
|
|
|
|
|
// SubFirstPay []int `gorm:"-"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *PlayerPayData) TableName() string {
|
|
|
|
|
return "player_pay_data"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type PlayerRtpData struct {
|
|
|
|
|
Id int `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT" json:"id"`
|
|
|
|
|
Uid int `gorm:"column:uid;type:int(11)" json:"uid"`
|
|
|
|
|
Rtp int `gorm:"column:rtp;type:int(11)" json:"rtp"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *PlayerRtpData) TableName() string {
|
|
|
|
|
return "player_rtp_data"
|
|
|
|
|
}
|