You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1627 lines
38 KiB
1627 lines
38 KiB
package call |
|
|
|
import ( |
|
"encoding/json" |
|
"errors" |
|
"net" |
|
"server/common" |
|
"server/config" |
|
"server/db" |
|
"server/util" |
|
"sort" |
|
"strings" |
|
"time" |
|
|
|
"github.com/liangdas/mqant/log" |
|
"github.com/oschwald/geoip2-golang" |
|
) |
|
|
|
var ( |
|
channels []*common.Channel |
|
region *geoip2.Reader |
|
configPlatform *common.ConfigPlatform |
|
configRWPer []*common.ConfigRWPer |
|
configActivity []*common.ConfigActivity |
|
configPayProduct []*common.ConfigPayProduct |
|
ConfigPayChannels []*common.ConfigPayChannels |
|
configWithdrawChannels []*common.ConfigWithdrawChannels |
|
configVIP []*common.ConfigVIP |
|
configH5 *common.ConfigH5 |
|
ConfigTron *common.ConfigTron |
|
configWithdrawProduct []*common.ConfigWithdrawProduct |
|
configGameList []*common.ConfigGameList |
|
configGameProvider []*common.ConfigGameProvider |
|
configGameTypes []*common.ConfigGameType |
|
configGameMarks []*common.ConfigGameMark |
|
configFirstPageGames []*common.ConfigFirstPageGames |
|
configBroadcast []*common.ConfigBroadcast |
|
configNotice []*common.ConfigNotice |
|
configCurrencyRateUSD []*common.ConfigCurrencyRateUSD |
|
configServerVersions []*common.ServerVersion |
|
configGameRooms []*common.ConfigGameRoom |
|
configRobots []*common.ConfigRobot |
|
configAppSpin []*common.ConfigAppSpin |
|
configShare []*common.ConfigShare |
|
configShareSys *common.ConfigShareSys |
|
configActivityPddSpin []*common.ConfigActivityPddSpin |
|
configActivityPdd *common.ConfigActivityPdd |
|
configTask []*common.ConfigTask |
|
configCurrencyResource []*common.ConfigCurrencyResource |
|
configFirstPay []*common.ConfigFirstPay |
|
configActivityFreeSpin []*common.ConfigActivityFreeSpin |
|
configActivityFirstRechargeBack *common.ConfigActivityFirstRechargeBack |
|
configActivityLuckyCode []*common.ConfigActivityLuckyCode |
|
configBanner []*common.ConfigBanner |
|
configActivitySign []*common.ConfigActivitySign |
|
configActivityBreakGift []*common.ConfigActivityBreakGift |
|
configShareRobot []*common.ConfigShareRobot |
|
configActivityWeekCard *common.ConfigActivityWeekCard |
|
configActivitySlots []*common.ConfigActivitySlots |
|
configActivityLuckyShop []*common.ConfigActivityLuckyShop |
|
configServerFlag []*common.ConfigServerFlag |
|
configActivitySevenDayBox []*common.ConfigActivitySevenDayBox |
|
configActivitySuper []*common.ConfigActivitySuper |
|
configTgRobot []*common.ConfigTgRobot |
|
configBetDraw []*common.ConfigActivityBetDraw |
|
configActivityPopup []*common.ConfigActivityPopup |
|
configDiscountTicket []common.ConfigDiscountTicket |
|
configRtp []common.ConfigRtp |
|
// 客服 |
|
configCustomerRobot []*common.ConfigCustomerRobot |
|
customerOrderLabel []*common.CustomerOrderLabel |
|
configCustomer *common.ConfigCustomer |
|
) |
|
|
|
var ( |
|
gameListTimer *time.Timer |
|
gameListReloadTime = 1 * time.Minute |
|
) |
|
|
|
// 加载渠道信息 |
|
func LoadChannels() (err error) { |
|
one := []*common.Channel{} |
|
if err := db.Mysql().C().Find(&one).Error; err != nil { |
|
log.Error("GetChannels err:%v", err) |
|
return err |
|
} |
|
channels = one |
|
return nil |
|
} |
|
|
|
func GetChannelListReal() []*common.Channel { |
|
one := []*common.Channel{} |
|
if err := db.Mysql().C().Find(&one).Error; err != nil { |
|
log.Error("GetChannels err:%v", err) |
|
return nil |
|
} |
|
return one |
|
} |
|
|
|
func GetChannelList() []*common.Channel { |
|
if channels == nil { |
|
if err := LoadChannels(); err != nil { |
|
log.Error("err:%v", err) |
|
return nil |
|
} |
|
} |
|
return channels |
|
} |
|
|
|
func GetChannelByID(id int) *common.Channel { |
|
if channels == nil { |
|
if err := LoadChannels(); err != nil { |
|
log.Error("err:%v", err) |
|
return nil |
|
} |
|
} |
|
for i, v := range channels { |
|
if int(v.ChannelID) == id { |
|
return channels[i] |
|
} |
|
} |
|
return nil |
|
} |
|
|
|
func GetChannelByURL(url string) *common.Channel { |
|
for i, v := range channels { |
|
if v.URL == url { |
|
return channels[i] |
|
} |
|
} |
|
return nil |
|
} |
|
|
|
// LoadIpDB 初始化ip数据库 |
|
func LoadIpDB() (err error) { |
|
if region != nil { |
|
region.Close() |
|
} |
|
region, err = geoip2.Open("../city.mmdb") |
|
if err != nil { |
|
log.Error("err:%v", err) |
|
return |
|
} |
|
return |
|
} |
|
|
|
// SearchIP 查询ip |
|
func SearchIP(ip string) (ipInfo *geoip2.City, err error) { |
|
if region == nil { |
|
if err = LoadIpDB(); err != nil { |
|
return |
|
} |
|
} |
|
pip := net.ParseIP(ip) |
|
return region.City(pip) |
|
} |
|
|
|
func GetCountry(ip string) string { |
|
pip := net.ParseIP(ip) |
|
data, err := region.City(pip) |
|
if err != nil { |
|
log.Error("err:%v", err) |
|
return "" |
|
} |
|
return data.Country.IsoCode |
|
} |
|
|
|
// LoadConfigPlatform 加载平台配置 |
|
func LoadConfigPlatform() (err error) { |
|
one := new(common.ConfigPlatform) |
|
if err := db.Mysql().Get(one); err != nil { |
|
return err |
|
} |
|
configPlatform = one |
|
return nil |
|
} |
|
|
|
// GetConfigPlatform 获取平台配置 |
|
func GetConfigPlatform() *common.ConfigPlatform { |
|
if configPlatform == nil { |
|
if err := LoadConfigPlatform(); err != nil { |
|
return nil |
|
} |
|
} |
|
return configPlatform |
|
} |
|
|
|
// LoadConfigRWPer 加载充提比配置 |
|
func LoadConfigRWPer() (err error) { |
|
one := []*common.ConfigRWPer{} |
|
if _, err := db.Mysql().QueryAll("", "down", &common.ConfigRWPer{}, &one); err != nil { |
|
return err |
|
} |
|
configRWPer = one |
|
return nil |
|
} |
|
|
|
// LoadConfigRWPer 获取充提比配置 |
|
func GetConfigRWPerByRecharge(recharge int64, t int) int64 { |
|
for _, v := range configRWPer { |
|
if v.Type != t { |
|
continue |
|
} |
|
if recharge >= v.Down && (recharge <= v.Up || v.Up < 0) { |
|
return v.Per |
|
} |
|
} |
|
return 0 |
|
} |
|
|
|
// CanAutoWithdraw 是否可自动退出 |
|
func CanAutoWithdraw(uid int, recharge, withdraw int64) bool { |
|
if !config.GetBase().Release { |
|
return false |
|
} |
|
t := common.RWPerTypeMulti |
|
if withdraw == 0 { |
|
t = common.RWPerTypeFirst |
|
} |
|
per := GetConfigRWPerByRecharge(recharge, t) |
|
log.Debug("uid:%d,per:%d,recharge:%d,withdraw:%d", uid, per, recharge, withdraw) |
|
if per == 0 { |
|
return false |
|
} |
|
return recharge*per >= withdraw*100 |
|
} |
|
|
|
// LoadConfigActivity 加载活动总配置表 |
|
func LoadConfigActivity() (err error) { |
|
one := []*common.ConfigActivity{} |
|
if _, err := db.Mysql().QueryAll("", "sort", &common.ConfigActivity{}, &one); err != nil { |
|
return err |
|
} |
|
configActivity = one |
|
for _, v := range configActivity { |
|
log.Debug("finish load activity:%+v", *v) |
|
} |
|
return nil |
|
} |
|
|
|
// GetConfigActivity 获取活动配置 |
|
func GetConfigActivityAll() []*common.ConfigActivity { |
|
return configActivity |
|
} |
|
|
|
// GetConfigActivityActiveAll 获取所有开放中的活动配置 |
|
func GetConfigActivityActiveAll(uid int) []*common.ConfigActivity { |
|
ret := []*common.ConfigActivity{} |
|
for _, v := range configActivity { |
|
if !v.IsValid() { |
|
continue |
|
} |
|
if v.ActivityID == common.ActivityIDFirstRechargeBack && !ShouldShowActivityFirstRechargeBack(uid) { |
|
continue |
|
} |
|
if v.Push != 1 { |
|
continue |
|
} |
|
ret = append(ret, v) |
|
} |
|
return ret |
|
} |
|
|
|
// GetConfigActivity 获取活动配置 |
|
func GetConfigActivityByID(actID int) *common.ConfigActivity { |
|
for _, v := range configActivity { |
|
if v.ActivityID == actID { |
|
return v |
|
} |
|
} |
|
return nil |
|
} |
|
|
|
// LoadConfigPayProduct 加载商品配置表 |
|
func LoadConfigPayProduct() (err error) { |
|
one := []*common.ConfigPayProduct{} |
|
if _, err := db.Mysql().QueryAll("", "type", &common.ConfigPayProduct{}, &one); err != nil { |
|
return err |
|
} |
|
sort.Slice(one, func(i, j int) bool { |
|
a := one[i] |
|
b := one[j] |
|
if a.Type > b.Type { |
|
return false |
|
} else if a.Type < b.Type { |
|
return true |
|
} |
|
return a.Sort < b.Sort |
|
}) |
|
configPayProduct = one |
|
return nil |
|
} |
|
|
|
// GetConfigPayProduct 获取商品配置 |
|
func GetConfigPayProduct() []*common.ConfigPayProduct { |
|
if len(configPayProduct) == 0 { |
|
if err := LoadConfigPayProduct(); err != nil { |
|
return nil |
|
} |
|
} |
|
return configPayProduct |
|
} |
|
|
|
// GetConfigPayProductByKind 获取商品配置 |
|
func GetConfigPayProductByKind(kind int) []*common.ConfigPayProduct { |
|
if len(configPayProduct) == 0 { |
|
if err := LoadConfigPayProduct(); err != nil { |
|
return nil |
|
} |
|
} |
|
ret := []*common.ConfigPayProduct{} |
|
for _, v := range configPayProduct { |
|
if v.Kind == kind { |
|
ret = append(ret, v) |
|
} |
|
} |
|
return ret |
|
} |
|
|
|
func GetConfigPayProductByID(id int) *common.ConfigPayProduct { |
|
if len(configPayProduct) == 0 { |
|
if err := LoadConfigPayProduct(); err != nil { |
|
return nil |
|
} |
|
} |
|
for _, v := range configPayProduct { |
|
if v.ProductID == id { |
|
return v |
|
} |
|
} |
|
return nil |
|
} |
|
|
|
func GetConfigPayProductByActivityID(actID int) []*common.ConfigPayProduct { |
|
ret := []*common.ConfigPayProduct{} |
|
for _, v := range configPayProduct { |
|
if v.ActivityID == actID { |
|
ret = append(ret, v) |
|
} |
|
} |
|
return ret |
|
} |
|
|
|
// LoadConfigPayChannels 加载代收渠道配置 |
|
func LoadConfigPayChannels() (err error) { |
|
var one []*common.ConfigPayChannels |
|
if _, err = db.Mysql().QueryAll("", "pay_per desc", &common.ConfigPayChannels{}, &one); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
ret := []*common.ConfigPayChannels{} |
|
for _, v := range one { |
|
if v.PayPer <= 0 { |
|
continue |
|
} |
|
ret = append(ret, v) |
|
log.Debug("finish load channel:%+v", *v) |
|
} |
|
ConfigPayChannels = ret |
|
return nil |
|
} |
|
|
|
// GetConfigPayChannelsByID 获取支付渠道配置 |
|
func GetConfigPayChannelsByID(currencyType common.CurrencyType) []*common.ConfigPayChannels { |
|
ret := []*common.ConfigPayChannels{} |
|
for i, v := range ConfigPayChannels { |
|
if v.PayPer <= 0 || v.CurrencyType != currencyType { |
|
continue |
|
} |
|
ret = append(ret, ConfigPayChannels[i]) |
|
} |
|
return ret |
|
} |
|
|
|
// GetConfigPayChannels 获取代收渠道配置 |
|
func GetConfigPayChannels() []*common.ConfigPayChannels { |
|
ret := []*common.ConfigPayChannels{} |
|
for i, v := range ConfigPayChannels { |
|
if v.PayPer <= 0 { |
|
continue |
|
} |
|
ret = append(ret, ConfigPayChannels[i]) |
|
} |
|
return ret |
|
} |
|
|
|
// LoadConfigWithdrawChannels 加载代付渠道配置 |
|
func LoadConfigWithdrawChannels() (err error) { |
|
var one []*common.ConfigWithdrawChannels |
|
if _, err = db.Mysql().QueryAll("", "withdraw_per desc", &common.ConfigWithdrawChannels{}, &one); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configWithdrawChannels = one |
|
return nil |
|
} |
|
|
|
// GetConfigWithdrawChannels 获取代付渠道配置 |
|
func GetConfigWithdrawChannels() []*common.ConfigWithdrawChannels { |
|
ret := []*common.ConfigWithdrawChannels{} |
|
for i, v := range configWithdrawChannels { |
|
if v.WithdrawPer <= 0 { |
|
continue |
|
} |
|
ret = append(ret, configWithdrawChannels[i]) |
|
} |
|
return ret |
|
} |
|
|
|
// GetConfigWithdrawLimits 获取赠送上下限配置 |
|
func GetConfigWithdrawLimits() (down, up int64) { |
|
for _, v := range configWithdrawChannels { |
|
if v.PayDown < down || down == 0 { |
|
down = v.PayDown |
|
} |
|
if up < v.PayUp { |
|
up = v.PayUp |
|
} |
|
} |
|
return |
|
} |
|
|
|
// GetConfigWithdrawChannelsByID 获取代付渠道配置 |
|
func GetConfigWithdrawChannelsByID(id int, currencyType common.CurrencyType) *common.ConfigWithdrawChannels { |
|
for i, v := range configWithdrawChannels { |
|
if v.ChannelID == id && v.CurrencyType == currencyType { |
|
return configWithdrawChannels[i] |
|
} |
|
} |
|
return nil |
|
} |
|
|
|
// GetConfigWithdrawChannelsBest 选择推荐的代付渠道 |
|
func GetConfigWithdrawChannelsBest(currencyType common.CurrencyType) *common.ConfigWithdrawChannels { |
|
for i, v := range configWithdrawChannels { |
|
if v.CurrencyType == currencyType && v.WithdrawPer > 0 { |
|
return configWithdrawChannels[i] |
|
} |
|
} |
|
return nil |
|
} |
|
|
|
// LoadConfigVIP 加载vip配置 |
|
func LoadConfigVIP() (err error) { |
|
var one []*common.ConfigVIP |
|
if _, err = db.Mysql().QueryAll("", "level", &common.ConfigVIP{}, &one); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configVIP = one |
|
return nil |
|
} |
|
|
|
// GetConfigVIP 获取vip配置 |
|
func GetConfigVIP() []*common.ConfigVIP { |
|
return configVIP |
|
} |
|
|
|
// GetConfigVIPByLevel 获取vip配置 |
|
func GetConfigVIPByLevel(level int) *common.ConfigVIP { |
|
for _, v := range configVIP { |
|
if v.Level == level { |
|
return v |
|
} |
|
} |
|
return nil |
|
} |
|
|
|
// LoadConfigH5 h5配置 |
|
func LoadConfigH5() (err error) { |
|
one := new(common.ConfigH5) |
|
err = db.Mysql().Get(one) |
|
if err != nil { |
|
return |
|
} |
|
configH5 = one |
|
return |
|
} |
|
|
|
// GetConfigH5 h5配置 |
|
func GetConfigH5() *common.ConfigH5 { |
|
return configH5 |
|
} |
|
|
|
// LoadConfigTron tron配置 |
|
func LoadConfigTron() (err error) { |
|
one := new(common.ConfigTron) |
|
err = db.Mysql().Get(one) |
|
if err != nil { |
|
return |
|
} |
|
ConfigTron = one |
|
return nil |
|
} |
|
|
|
// GetConfigTron tron配置 |
|
func GetConfigTron() *common.ConfigTron { |
|
return ConfigTron |
|
} |
|
|
|
// LoadConfigWithdrawProduct 退出商品 |
|
func LoadConfigWithdrawProduct() (err error) { |
|
one := []*common.ConfigWithdrawProduct{} |
|
if _, err := db.Mysql().QueryAll("", "", &common.ConfigWithdrawProduct{}, &one); err != nil { |
|
return err |
|
} |
|
configWithdrawProduct = one |
|
return nil |
|
} |
|
|
|
// GetConfigWithdrawProduct 退出商品 |
|
func GetConfigWithdrawProduct(t ...common.CurrencyType) []*common.ConfigWithdrawProduct { |
|
if len(t) > 0 { |
|
ret := []*common.ConfigWithdrawProduct{} |
|
for _, v := range configWithdrawProduct { |
|
if v.Type == t[0] { |
|
ret = append(ret, v) |
|
} |
|
} |
|
return ret |
|
} |
|
return configWithdrawProduct |
|
} |
|
|
|
func GetConfigWithdrawProductByID(id int) *common.ConfigWithdrawProduct { |
|
for _, v := range configWithdrawProduct { |
|
if v.ProductID == id { |
|
return v |
|
} |
|
} |
|
return nil |
|
} |
|
|
|
// LoadGames 无论修改供应商还是单个游戏,都会触发所有重新加载 |
|
func LoadGames() (err error) { |
|
if gameListTimer != nil { |
|
gameListTimer.Reset(gameListReloadTime) |
|
} else { |
|
// 每分钟刷新一次 |
|
gameListTimer = time.AfterFunc(gameListReloadTime, func() { |
|
LoadGames() |
|
}) |
|
} |
|
providers := []*common.ConfigGameProvider{} |
|
if _, err = db.Mysql().QueryAll("", "sort", &common.ConfigGameProvider{}, &providers); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
for _, v := range providers { |
|
if v.WhiteIPs != "" { |
|
err := json.Unmarshal([]byte(v.WhiteIPs), &v.SubIp) |
|
if err != nil { |
|
log.Error("err:%v", err) |
|
} |
|
} |
|
} |
|
tmplist := []*common.ConfigGameList{} |
|
if _, err = db.Mysql().QueryAll("open = 1", "sort desc", &common.ConfigGameList{}, &tmplist); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
list := []*common.ConfigGameList{} |
|
for _, v := range tmplist { |
|
for _, k := range providers { |
|
if v.GameProvider == k.ProviderID { |
|
if k.Open == 1 { // 特殊过滤 |
|
list = append(list, v) |
|
} |
|
break |
|
} |
|
} |
|
} |
|
for _, v := range providers { |
|
count := 0 |
|
for _, j := range list { |
|
if j.GameProvider == v.ProviderID { |
|
count++ |
|
} |
|
} |
|
v.GamesNum = count |
|
} |
|
configGameProvider = providers |
|
// sort.SliceStable(list, func(i int, j int) bool { |
|
// sortI := GetConfigGameProvider(list[i].GameProvider).Sort |
|
// sortJ := GetConfigGameProvider(list[j].GameProvider).Sort |
|
// if sortI < sortJ { |
|
// return true |
|
// } else if sortI > sortJ { |
|
// return false |
|
// } |
|
// return list[i].Sort < list[j].Sort |
|
// }) |
|
configGameList = list |
|
return nil |
|
} |
|
|
|
// 游戏提供商 |
|
// func LoadConfigGameProvider() (err error) { |
|
// one := []*common.ConfigGameProvider{} |
|
// if _, err = db.Mysql().QueryAll("", "sort", &common.ConfigGameProvider{}, &one); err != nil { |
|
// log.Error("err:%v", err) |
|
// return err |
|
// } |
|
// if len(configGameList) == 0 { |
|
// LoadConfigGameList() |
|
// } |
|
// for _, v := range configGameProvider { |
|
// count := 0 |
|
// for _, j := range configGameList { |
|
// if j.GameProvider == v.ProviderID { |
|
// count++ |
|
// } |
|
// } |
|
// v.GamesNum = count |
|
// } |
|
// configGameProvider = one |
|
// return nil |
|
// } |
|
|
|
// 游戏提供商 |
|
func GetConfigGameProviderAll() []*common.ConfigGameProvider { |
|
return configGameProvider |
|
} |
|
|
|
// 游戏提供商 |
|
func GetConfigGameProviderAllOpen() []*common.ConfigGameProvider { |
|
ret := []*common.ConfigGameProvider{} |
|
for _, v := range configGameProvider { |
|
if v.ProviderID == common.ProviderPG2 || v.ProviderID == common.ProviderJiLi2 { |
|
continue |
|
} |
|
if v.Show == 2 { |
|
continue |
|
} |
|
if v.Open == 2 { |
|
continue |
|
} |
|
ret = append(ret, v) |
|
} |
|
return ret |
|
} |
|
|
|
// 游戏提供商 |
|
func GetConfigGameProviderByName(name string) *common.ConfigGameProvider { |
|
for _, v := range configGameProvider { |
|
if v.ProviderName == name { |
|
return v |
|
} |
|
} |
|
return nil |
|
} |
|
|
|
// 游戏提供商 |
|
func GetConfigGameProviderByPath(path string) *common.ConfigGameProvider { |
|
for _, v := range configGameProvider { |
|
if v.Callback == path { |
|
return v |
|
} |
|
} |
|
return nil |
|
} |
|
|
|
// 游戏提供商 |
|
func GetConfigGameProvider(provider int) *common.ConfigGameProvider { |
|
// if len(configGameProvider) == 0 { |
|
// LoadConfigGameProvider() |
|
// } |
|
for _, v := range configGameProvider { |
|
if v.ProviderID == provider { |
|
return v |
|
} |
|
} |
|
return nil |
|
} |
|
|
|
func GetConfigGameListByGameID(provider, gameID int) *common.ConfigGameList { |
|
for _, v := range configGameList { |
|
if v.GameProvider == provider && v.GameID == gameID { |
|
return v |
|
} |
|
} |
|
return nil |
|
} |
|
|
|
// 游戏列表配置 |
|
// func LoadConfigGameList() (err error) { |
|
// one := []*common.ConfigGameList{} |
|
// if _, err = db.Mysql().QueryAll("", "sort", &common.ConfigGameList{}, &one); err != nil { |
|
// log.Error("err:%v", err) |
|
// return err |
|
// } |
|
// sort.SliceStable(one, func(i int, j int) bool { |
|
// sortI := GetConfigGameProvider(one[i].GameProvider).Sort |
|
// sortJ := GetConfigGameProvider(one[j].GameProvider).Sort |
|
// if sortI < sortJ { |
|
// return true |
|
// } else if sortI > sortJ { |
|
// return false |
|
// } |
|
// return one[i].Sort < one[j].Sort |
|
// }) |
|
// configGameList = one |
|
// return nil |
|
// } |
|
|
|
// 获取游戏列表配置 num拉取的个数,cond 约定第一个为provider,第二个为mark,第三个为type |
|
func GetConfigGameList(num int, cond ...int) []*common.ConfigGameList { |
|
if len(cond) == 0 { |
|
if num <= 0 || num > len(configGameList) { |
|
return configGameList |
|
} |
|
return configGameList[:num] |
|
} |
|
ret := []*common.ConfigGameList{} |
|
for _, v := range configGameList { |
|
if v.GameType == common.GameTypeSportBook || v.GameType == common.GameTypeESport { // 屏蔽sport |
|
continue |
|
} |
|
if cond[0] != 0 && v.GameProvider != cond[0] { |
|
continue |
|
} |
|
if len(cond) > 1 { |
|
if cond[1] != 0 && v.Mark != cond[1] { |
|
continue |
|
} |
|
} |
|
if len(cond) > 2 { |
|
if cond[2] != 0 && v.GameType != cond[2] { |
|
continue |
|
} |
|
} |
|
if v.GameProvider == common.ProviderPG2 || v.GameProvider == common.ProviderJiLi2 { |
|
continue |
|
} |
|
provider := -1 |
|
if v.GameProvider == common.ProviderJili { |
|
provider = common.ProviderJiLi2 |
|
} else if v.GameProvider == common.ProviderPGSoft { |
|
provider = common.ProviderPG2 |
|
} |
|
if provider != -1 { |
|
game := GetConfigGameListByGameID(provider, v.GameID) |
|
if game != nil { |
|
ret = append(ret, v) |
|
continue |
|
} |
|
} else { |
|
ret = append(ret, v) |
|
} |
|
} |
|
sort.Slice(ret, func(i, j int) bool { |
|
return ret[i].Sort > ret[j].Sort |
|
}) |
|
if num > 0 && len(ret) >= num { |
|
return ret[:num] |
|
} else { |
|
return ret |
|
} |
|
} |
|
|
|
func GetConfigGameListByID(provider, gameID int) *common.ConfigGameList { |
|
for _, v := range configGameList { |
|
if v.GameProvider == provider && v.GameID == gameID { |
|
return v |
|
} |
|
} |
|
return nil |
|
} |
|
|
|
func GetConfigGameListByName(name string) (ret []*common.ConfigGameList) { |
|
for _, v := range configGameList { |
|
if strings.Index(v.Name, name) != -1 { |
|
ret = append(ret, v) |
|
} |
|
} |
|
return |
|
} |
|
func GetConfigGameListByType(t int) []*common.ConfigGameList { |
|
ret := []*common.ConfigGameList{} |
|
for _, v := range configGameList { |
|
if v.GameType == t { |
|
ret = append(ret, v) |
|
} |
|
} |
|
return ret |
|
} |
|
|
|
func GetConfigGameListByCode(provider int, gameCode string) *common.ConfigGameList { |
|
for _, v := range configGameList { |
|
if v.GameProvider == provider && v.GameCode == gameCode { |
|
return v |
|
} |
|
} |
|
return nil |
|
} |
|
|
|
// 游戏类别配置 |
|
func LoadConfigGameTypes() (err error) { |
|
one := []*common.ConfigGameType{} |
|
if _, err = db.Mysql().QueryAll("open = 1", "sort", &common.ConfigGameType{}, &one); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configGameTypes = one |
|
return nil |
|
} |
|
|
|
// 游戏类别配置 |
|
func GetConfigGameTypes() []*common.ConfigGameType { |
|
return configGameTypes |
|
} |
|
|
|
// 游戏角标 |
|
func LoadConfigGameMarks() (err error) { |
|
one := []*common.ConfigGameMark{} |
|
if _, err = db.Mysql().QueryAll("", "sort", &common.ConfigGameMark{}, &one); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configGameMarks = one |
|
return nil |
|
} |
|
|
|
// 游戏角标 |
|
func GetConfigGameMarks() []*common.ConfigGameMark { |
|
return configGameMarks |
|
} |
|
|
|
// 游戏角标 |
|
func GetConfigGameMarkByName(name string) *common.ConfigGameMark { |
|
for _, v := range configGameMarks { |
|
if v.MarkName == name { |
|
return v |
|
} |
|
} |
|
return nil |
|
} |
|
|
|
// 首页游戏 |
|
func LoadConfigFirstPageGames() (err error) { |
|
one := []*common.ConfigFirstPageGames{} |
|
if _, err = db.Mysql().QueryAll("open = 1", "sort", &common.ConfigFirstPageGames{}, &one); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configFirstPageGames = one |
|
return nil |
|
} |
|
|
|
// 首页游戏 |
|
func GetConfigFirstPageGames() []*common.ConfigFirstPageGames { |
|
return configFirstPageGames |
|
} |
|
|
|
// 首页游戏 |
|
func LoadConfigBroadcast() (err error) { |
|
one := []*common.ConfigBroadcast{} |
|
if _, err = db.Mysql().QueryAll("", "", &common.ConfigBroadcast{}, &one); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configBroadcast = one |
|
return nil |
|
} |
|
|
|
// 首页游戏 |
|
func GetConfigBroadcast() []*common.ConfigBroadcast { |
|
return configBroadcast |
|
} |
|
|
|
func GetBroadcastConfigWithID(id int) *common.ConfigBroadcast { |
|
for _, v := range configBroadcast { |
|
if v.BroadcastID == id { |
|
return v |
|
} |
|
} |
|
return nil |
|
} |
|
|
|
// notice |
|
func LoadConfigNotice() (err error) { |
|
one := []*common.ConfigNotice{} |
|
if _, err = db.Mysql().QueryAll("", "", &common.ConfigNotice{}, &one); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configNotice = one |
|
return nil |
|
} |
|
|
|
func GetConfigNotice() []*common.ConfigNotice { |
|
return configNotice |
|
} |
|
|
|
func LoadConfigCurrencyRateUSD() (err error) { |
|
one := []*common.ConfigCurrencyRateUSD{} |
|
if _, err = db.Mysql().QueryAll("", "", &common.ConfigCurrencyRateUSD{}, &one); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configCurrencyRateUSD = one |
|
return nil |
|
} |
|
|
|
func GetConfigCurrencyRateUSD(t common.CurrencyType) int64 { |
|
for _, v := range configCurrencyRateUSD { |
|
if v.CurrencyType == t { |
|
return v.Rate |
|
} |
|
} |
|
return 0 |
|
} |
|
|
|
func LoadServerVersions() error { |
|
one := []*common.ServerVersion{} |
|
if err := db.Mysql().C().Find(&one).Error; err != nil { |
|
log.Error("LoadServerVersions err:%v", err) |
|
return err |
|
} |
|
configServerVersions = one |
|
return nil |
|
} |
|
|
|
func GetServerVersion(serverID int) int { |
|
for _, v := range configServerVersions { |
|
if serverID == v.ServerID { |
|
return v.Version |
|
} |
|
} |
|
return 0 |
|
} |
|
|
|
func IsMainServer(serverID int) bool { |
|
for _, v := range configServerVersions { |
|
if serverID == v.ServerID { |
|
return config.GetConfig().Version == v.Version |
|
} |
|
} |
|
return true |
|
} |
|
|
|
func LoadConfigGameRooms() (err error) { |
|
one := []*common.ConfigGameRoom{} |
|
if _, err = db.Mysql().QueryAll("", "", &common.ConfigGameRoom{}, &one); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
for _, v := range one { |
|
if v.BetLimitStr != "" { |
|
err := json.Unmarshal([]byte(v.BetLimitStr), &v.BetLimit) |
|
if err != nil { |
|
log.Error("err:%v", err) |
|
} |
|
} |
|
} |
|
configGameRooms = one |
|
return nil |
|
} |
|
|
|
func GetConfigGameRoom(gid int) []*common.ConfigGameRoom { |
|
list := []*common.ConfigGameRoom{} |
|
for _, v := range configGameRooms { |
|
if v.GameID == gid { |
|
list = append(list, v) |
|
} |
|
} |
|
return list |
|
} |
|
|
|
func GetConfigWaterReal(gid, rid int) *common.ConfigWater { |
|
con := &common.ConfigWater{GameID: gid, RoomID: rid} |
|
db.Mysql().Get(con) |
|
if con.ID == 0 { |
|
return nil |
|
} |
|
return con |
|
} |
|
|
|
func LoadConfigRobots() (err error) { |
|
one := []*common.ConfigRobot{} |
|
if _, err = db.Mysql().QueryAll("", "", &common.ConfigRobot{}, &one); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configRobots = one |
|
return nil |
|
} |
|
|
|
func GetConfigRobots() []*common.ConfigRobot { |
|
return configRobots |
|
} |
|
|
|
func LoadConfigAppSpin() (err error) { |
|
one := []*common.ConfigAppSpin{} |
|
if _, err = db.Mysql().QueryAll("", "sort desc", &common.ConfigAppSpin{}, &one); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configAppSpin = one |
|
return nil |
|
} |
|
|
|
func GetConfigAppSpin() []*common.ConfigAppSpin { |
|
return configAppSpin |
|
} |
|
|
|
func LoadConfigShare() (err error) { |
|
one := []*common.ConfigShare{} |
|
if _, err = db.Mysql().QueryAll("", "level", &common.ConfigShare{}, &one); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configShare = one |
|
return nil |
|
} |
|
|
|
func GetConfigShare() []*common.ConfigShare { |
|
return configShare |
|
} |
|
|
|
func GetConfigShareLevelByBet(bet int64) *common.ConfigShare { |
|
for i := len(configShare) - 1; i >= 0; i-- { |
|
if bet >= configShare[i].Bet { |
|
return configShare[i] |
|
} |
|
} |
|
return nil |
|
} |
|
|
|
func GetConfigShareByLevel(level int) *common.ConfigShare { |
|
for _, v := range configShare { |
|
if level == v.Level { |
|
return v |
|
} |
|
} |
|
return nil |
|
} |
|
|
|
// LoadConfigShareSys 分享系统配置 |
|
func LoadConfigShareSys() (err error) { |
|
one := new(common.ConfigShareSys) |
|
err = db.Mysql().Get(one) |
|
if err != nil { |
|
return |
|
} |
|
configShareSys = one |
|
return |
|
} |
|
|
|
func GetConfigShareSys() *common.ConfigShareSys { |
|
return configShareSys |
|
} |
|
|
|
// LoadConfigActivityPdd 拼多多配置 |
|
func LoadConfigActivityPdd() (err error) { |
|
one := new(common.ConfigActivityPdd) |
|
err = db.Mysql().Get(one) |
|
if err != nil { |
|
return |
|
} |
|
configActivityPdd = one |
|
return |
|
} |
|
|
|
func GetConfigActivityPdd() *common.ConfigActivityPdd { |
|
return configActivityPdd |
|
} |
|
|
|
// LoadConfigActivityPddSpin 拼多多转盘配置 |
|
func LoadConfigActivityPddSpin() (err error) { |
|
one := []*common.ConfigActivityPddSpin{} |
|
if _, err = db.Mysql().QueryAll("", "amount_down,sort", &common.ConfigActivityPddSpin{}, &one); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configActivityPddSpin = one |
|
return |
|
} |
|
|
|
func GetConfigActivityPddSpinByAmount(amount int64) []*common.ConfigActivityPddSpin { |
|
ret := []*common.ConfigActivityPddSpin{} |
|
for _, v := range configActivityPddSpin { |
|
if v.AmountDown <= amount && v.AmountUp >= amount { |
|
ret = append(ret, v) |
|
} |
|
} |
|
return ret |
|
} |
|
|
|
func GetConfigActivityPddSpin() []*common.ConfigActivityPddSpin { |
|
return configActivityPddSpin |
|
} |
|
|
|
// LoadConfigTask 任务配置 |
|
func LoadConfigTask() (err error) { |
|
one := []*common.ConfigTask{} |
|
if _, err = db.Mysql().QueryAll("open = 1", "sort asc", &common.ConfigTask{}, &one); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configTask = one |
|
return |
|
} |
|
|
|
func GetConfigTask() []*common.ConfigTask { |
|
return configTask |
|
} |
|
|
|
func GetConfigTaskByTaskID(taskID int) *common.ConfigTask { |
|
for _, v := range configTask { |
|
if v.TaskID == taskID { |
|
return v |
|
} |
|
} |
|
return nil |
|
} |
|
|
|
func GetConfigTaskByTaskType(t int) (ret []*common.ConfigTask) { |
|
for _, v := range configTask { |
|
if int(v.Type) == t { |
|
ret = append(ret, v) |
|
} |
|
} |
|
return |
|
} |
|
|
|
// LoadConfigCurrencyResource 货币来源配置 |
|
func LoadConfigCurrencyResource() (err error) { |
|
one := []*common.ConfigCurrencyResource{} |
|
if _, err = db.Mysql().QueryAll("", "", &common.ConfigCurrencyResource{}, &one); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configCurrencyResource = one |
|
return |
|
} |
|
|
|
func GetConfigCurrencyResource() []*common.ConfigCurrencyResource { |
|
return configCurrencyResource |
|
} |
|
|
|
func GetConfigCurrencyResourceMultiple(t common.CurrencyRes) int64 { |
|
for _, v := range configCurrencyResource { |
|
if v.Type == t { |
|
return v.Multiple |
|
} |
|
} |
|
return 0 |
|
} |
|
|
|
func GetConfigCurrencyResourceNeedBet(t common.CurrencyRes, amount int64) (needBet int64) { |
|
if amount <= 0 { |
|
return |
|
} |
|
needBet = GetConfigCurrencyResourceMultiple(t) * amount / 100 |
|
if needBet < 0 { |
|
needBet = 0 |
|
} |
|
return |
|
} |
|
|
|
// LoadConfigFirstPay 首充 |
|
func LoadConfigFirstPay() (err error) { |
|
one := []*common.ConfigFirstPay{} |
|
if _, err = db.Mysql().QueryAll("", "amount", &common.ConfigFirstPay{}, &one); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configFirstPay = one |
|
return |
|
} |
|
|
|
func GetConfigFirstPay() []*common.ConfigFirstPay { |
|
return configFirstPay |
|
} |
|
|
|
func GetConfigFirstPayLevelByAmount(amount int64) int { |
|
for _, v := range configFirstPay { |
|
if amount >= v.Amount { |
|
return v.Level |
|
} |
|
} |
|
return 0 |
|
} |
|
|
|
func GetConfigFirstPayPerByAmount(first bool, amount int64) int64 { |
|
for i := len(configFirstPay) - 1; i >= 0; i-- { |
|
v := configFirstPay[i] |
|
if amount >= v.Amount { |
|
if first { |
|
return v.FirstPer |
|
} |
|
return v.Per |
|
} |
|
} |
|
return 0 |
|
} |
|
|
|
// LoadConfigActivityFreeSpin 每日免费转盘配置 |
|
func LoadConfigActivityFreeSpin() (err error) { |
|
one := []*common.ConfigActivityFreeSpin{} |
|
if _, err = db.Mysql().QueryAll("", "sort", &common.ConfigActivityFreeSpin{}, &one); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
for _, v := range one { |
|
if v.Type == common.ActivityFreeSpinItemRandomCash && v.CashUp < v.CashDown { |
|
log.Error("invalid cashup cashdown:%+v", v) |
|
return errors.New("invalid cashup cashdown") |
|
} |
|
} |
|
configActivityFreeSpin = one |
|
return |
|
} |
|
|
|
func GetConfigActivityFreeSpin() []*common.ConfigActivityFreeSpin { |
|
return configActivityFreeSpin |
|
} |
|
|
|
// 获取指定类型的物品 |
|
func GetConfigActivityFreeSpinByType(t int) (ret []*common.ConfigActivityFreeSpin) { |
|
for _, v := range configActivityFreeSpin { |
|
if v.Type == t { |
|
ret = append(ret, v) |
|
} |
|
} |
|
return |
|
} |
|
|
|
// LoadConfigActivityFirstRechargeBack 加载首日充值返还配置 |
|
func LoadConfigActivityFirstRechargeBack() (err error) { |
|
one := new(common.ConfigActivityFirstRechargeBack) |
|
if err := db.Mysql().Get(one); err != nil { |
|
return err |
|
} |
|
configActivityFirstRechargeBack = one |
|
return nil |
|
} |
|
|
|
func GetConfigActivityFirstRechargeBack() *common.ConfigActivityFirstRechargeBack { |
|
return configActivityFirstRechargeBack |
|
} |
|
|
|
func LoadConfigActivityLuckCode() (err error) { |
|
list := []*common.ConfigActivityLuckyCode{} |
|
if _, err = db.Mysql().QueryAll("", "", &common.ConfigActivityLuckyCode{}, &list); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configActivityLuckyCode = list |
|
return nil |
|
} |
|
|
|
func GetConfigAcitivityLuckyCode(t int) []*common.ConfigActivityLuckyCode { |
|
var ret []*common.ConfigActivityLuckyCode |
|
for _, conf := range configActivityLuckyCode { |
|
if conf.Type == t { |
|
ret = append(ret, conf) |
|
} |
|
} |
|
return ret |
|
} |
|
|
|
func GetConfigAcitivityLuckyCodeTotalWeight(t int) (total int64) { |
|
for _, v := range configActivityLuckyCode { |
|
if v.Type == t { |
|
total += v.Per |
|
} |
|
} |
|
return |
|
} |
|
|
|
func LoadConfigBanner() (err error) { |
|
list := []*common.ConfigBanner{} |
|
if _, err = db.Mysql().QueryAll("", "sort", &common.ConfigBanner{}, &list); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configBanner = list |
|
return nil |
|
} |
|
|
|
func GetConfigBanner(uid int) []*common.ConfigBanner { |
|
list := []*common.ConfigBanner{} |
|
for _, v := range configBanner { |
|
if !v.IsValid() { |
|
continue |
|
} |
|
if v.ActivityID == common.ActivityIDFirstRechargeBack && !ShouldShowActivityFirstRechargeBack(uid) { |
|
continue |
|
} |
|
list = append(list, v) |
|
} |
|
return list |
|
} |
|
|
|
func LoadConfigActivitySign() (err error) { |
|
list := []*common.ConfigActivitySign{} |
|
if _, err = db.Mysql().QueryAll("", "day", &common.ConfigActivitySign{}, &list); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configActivitySign = list |
|
return nil |
|
} |
|
|
|
func GetConfigActivitySign() []*common.ConfigActivitySign { |
|
return configActivitySign |
|
} |
|
|
|
func GetConfigActivitySignByWheel(wheel int) (ret []*common.ConfigActivitySign) { |
|
for _, conf := range configActivitySign { |
|
if wheel >= conf.WheelStart && wheel <= conf.WheelEnd { |
|
ret = append(ret, conf) |
|
} |
|
} |
|
return |
|
} |
|
|
|
func LoadConfigActivityBreakGift() (err error) { |
|
list := []*common.ConfigActivityBreakGift{} |
|
if _, err = db.Mysql().QueryAll("", "recharge_down", &common.ConfigActivityBreakGift{}, &list); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configActivityBreakGift = list |
|
return nil |
|
} |
|
|
|
func GetConfigActivityBreakGiftByRecharge(recharge int64, data *common.PlayerPayData) *common.ConfigActivityBreakGift { |
|
for _, v := range configActivityBreakGift { |
|
if util.SliceContain(data.SubBreakGift, v.Level) { |
|
continue |
|
} |
|
if v.RechargeDown <= recharge && (recharge < v.RechargeUp || v.RechargeUp <= 0) { |
|
return v |
|
} |
|
} |
|
return nil |
|
} |
|
|
|
func GetConfigActivityBreakGiftByProductID(productID int) *common.ConfigActivityBreakGift { |
|
for _, v := range configActivityBreakGift { |
|
if v.ProductID == productID { |
|
return v |
|
} |
|
} |
|
return nil |
|
} |
|
|
|
func LoadConfigShareRobot() (err error) { |
|
list := []*common.ConfigShareRobot{} |
|
if _, err = db.Mysql().QueryAll("", "", &common.ConfigShareRobot{}, &list); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configShareRobot = list |
|
return nil |
|
} |
|
|
|
func GetConfigShareRobot() []*common.ConfigShareRobot { |
|
return configShareRobot |
|
} |
|
|
|
func GetConfigShareRobotByID(robotID int) *common.ConfigShareRobot { |
|
for _, v := range configShareRobot { |
|
if v.RobotID == robotID { |
|
return v |
|
} |
|
} |
|
return nil |
|
} |
|
|
|
func LoadConfigActivityWeekCard() (err error) { |
|
one := new(common.ConfigActivityWeekCard) |
|
if err := db.Mysql().Get(one); err != nil { |
|
return err |
|
} |
|
configActivityWeekCard = one |
|
return nil |
|
} |
|
|
|
func GetConfigActivityWeekCard() *common.ConfigActivityWeekCard { |
|
return configActivityWeekCard |
|
} |
|
|
|
func LoadConfigActivitySlots() (err error) { |
|
list := []*common.ConfigActivitySlots{} |
|
if _, err = db.Mysql().QueryAll("", "rank_down", &common.ConfigActivitySlots{}, &list); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configActivitySlots = list |
|
return nil |
|
} |
|
|
|
func GetConfigActivitySlots() []*common.ConfigActivitySlots { |
|
return configActivitySlots |
|
} |
|
|
|
func GetConfigActivitySlotsRewardByRank(rank int) int64 { |
|
for _, v := range configActivitySlots { |
|
if rank >= v.RankDown && rank <= v.RankUp { |
|
return v.Reward |
|
} |
|
} |
|
return 0 |
|
} |
|
|
|
func LoadConfigActivityLuckyShop() (err error) { |
|
list := []*common.ConfigActivityLuckyShop{} |
|
if _, err = db.Mysql().QueryAll("", "type asc", &common.ConfigActivityLuckyShop{}, &list); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configActivityLuckyShop = list |
|
return nil |
|
} |
|
|
|
func GetConfigActivityLuckShop(t int) *common.ConfigActivityLuckyShop { |
|
for _, v := range configActivityLuckyShop { |
|
if v.Type == t { |
|
return v |
|
} |
|
} |
|
return nil |
|
} |
|
|
|
func LoadConfigServerFlag() (err error) { |
|
list := []*common.ConfigServerFlag{} |
|
if _, err = db.Mysql().QueryAll("", "", &common.ConfigServerFlag{}, &list); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configServerFlag = list |
|
return nil |
|
} |
|
|
|
func GetConfigServerFlag(flag string) *common.ConfigServerFlag { |
|
for _, v := range configServerFlag { |
|
if v.Flag == flag { |
|
return v |
|
} |
|
} |
|
return nil |
|
} |
|
|
|
func LoadConfigActivitySevenDayBox() (err error) { |
|
list := []*common.ConfigActivitySevenDayBox{} |
|
if _, err = db.Mysql().QueryAll("", "type asc,recharge desc", &common.ConfigActivitySevenDayBox{}, &list); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
for _, v := range list { |
|
if v.CashRange != "" { |
|
err := json.Unmarshal([]byte(v.CashRange), &v.SubCashRange) |
|
if err != nil { |
|
log.Error("err:%v", err) |
|
} |
|
} |
|
} |
|
configActivitySevenDayBox = list |
|
return nil |
|
} |
|
|
|
func GetConfigActivitySevenDayBoxByRechargeAndType(recharge int64, t int) (ret []*common.ConfigActivitySevenDayBox) { |
|
var rechargeLevel int64 |
|
for _, v := range configActivitySevenDayBox { |
|
if v.Type != t { |
|
continue |
|
} |
|
if rechargeLevel != 0 && rechargeLevel != v.Recharge { |
|
continue |
|
} |
|
if recharge >= v.Recharge { |
|
rechargeLevel = v.Recharge |
|
ret = append(ret, v) |
|
} |
|
} |
|
return |
|
} |
|
|
|
func LoadConfigActivitySuper() (err error) { |
|
list := []*common.ConfigActivitySuper{} |
|
if _, err = db.Mysql().QueryAll("", "type asc,index asc,sort asc", &common.ConfigActivitySuper{}, &list); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configActivitySuper = list |
|
return nil |
|
} |
|
|
|
func GetConfigActivitySuperByType(t int) (ret []*common.ConfigActivitySuper) { |
|
for _, v := range configActivitySuper { |
|
if v.Type != t { |
|
continue |
|
} |
|
ret = append(ret, v) |
|
} |
|
return |
|
} |
|
|
|
func GetConfigActivitySuperByTypeAndIndex(t, index int) (ret []*common.ConfigActivitySuper) { |
|
for _, v := range configActivitySuper { |
|
if v.Type != t { |
|
continue |
|
} |
|
if v.Index != index { |
|
continue |
|
} |
|
ret = append(ret, v) |
|
} |
|
return |
|
} |
|
|
|
func LoadConfigTgRobot() (err error) { |
|
var list []*common.ConfigTgRobot |
|
if _, err = db.Mysql().QueryAll("", "", &common.ConfigTgRobot{}, &list); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configTgRobot = list |
|
return nil |
|
} |
|
|
|
func GetConfigTgRobot() []*common.ConfigTgRobot { |
|
return configTgRobot |
|
} |
|
|
|
// LoadBetDraw 加载 BetDraw 的配置 |
|
func LoadBetDraw() (err error) { |
|
var list []*common.ConfigActivityBetDraw |
|
if _, err = db.Mysql().QueryAll("", "", &common.ConfigActivityBetDraw{}, &list); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configBetDraw = list |
|
return nil |
|
} |
|
|
|
func GetConfigBetDraw() []*common.ConfigActivityBetDraw { |
|
return configBetDraw |
|
} |
|
|
|
func GetConfigBetDrawByType(t int) ([]*common.ConfigActivityBetDraw, []int64) { |
|
var ret []*common.ConfigActivityBetDraw |
|
var weight []int64 |
|
for _, conf := range configBetDraw { |
|
if conf.Type == t { |
|
weight = append(weight, conf.Weight) |
|
ret = append(ret, conf) |
|
} |
|
} |
|
return ret, weight |
|
} |
|
|
|
func LoadConfigActivityPopup() (err error) { |
|
var list []*common.ConfigActivityPopup |
|
if _, err = db.Mysql().QueryAll("", "", &common.ConfigActivityPopup{}, &list); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configActivityPopup = list |
|
return nil |
|
} |
|
|
|
func GetConfigActivityPopup() []*common.ConfigActivityPopup { |
|
return configActivityPopup |
|
} |
|
|
|
func GetConfigActivityPopupByType(jumpType int) []*common.ConfigActivityPopup { |
|
var ret []*common.ConfigActivityPopup |
|
for _, item := range configActivityPopup { |
|
if item.JumpType == jumpType { |
|
ret = append(ret, item) |
|
} |
|
} |
|
return ret |
|
} |
|
|
|
func LoadConfigDiscountTicket() (err error) { |
|
var list []common.ConfigDiscountTicket |
|
if _, err = db.Mysql().QueryAll("", "", &common.ConfigDiscountTicket{}, &list); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configDiscountTicket = list |
|
return nil |
|
} |
|
|
|
func GetConfigDiscountTicket() []common.ConfigDiscountTicket { |
|
return configDiscountTicket |
|
} |
|
|
|
// GetConfigDiscountTicketByAmount 不存在就获取小一档的 |
|
func GetConfigDiscountTicketByAmount(amount int64) (ret common.ConfigDiscountTicket) { |
|
for _, item := range configDiscountTicket { |
|
if item.RechargeAmount <= amount { |
|
ret = item |
|
} |
|
} |
|
return |
|
} |
|
|
|
func LoadConfigRTP() (err error) { |
|
var list []common.ConfigRtp |
|
if _, err = db.Mysql().QueryAll("", "", &common.ConfigRtp{}, &list); err != nil { |
|
log.Error("err:%v", err) |
|
return err |
|
} |
|
configRtp = list |
|
return nil |
|
} |
|
|
|
func GetConfigRTP() []common.ConfigRtp { |
|
return configRtp |
|
} |
|
|
|
// GetConfigRTPByAmount |
|
func GetConfigRTPByAmount(amount int64) (ret common.ConfigRtp) { |
|
for _, item := range configRtp { |
|
if amount >= item.MinRecharge && amount <= item.MinRecharge { |
|
return item |
|
} |
|
} |
|
return |
|
}
|
|
|