印度包网
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.

2675 lines
63 KiB

1 year ago
package call
import (
"encoding/json"
"errors"
3 months ago
jsoniter "github.com/json-iterator/go"
1 year ago
"net"
"server/common"
"server/config"
"server/db"
"server/util"
"sort"
"strings"
2 months ago
"sync"
1 year ago
"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
configActivitySlots []*common.ConfigActivitySlots
configActivityLuckyShop []*common.ConfigActivityLuckyShop
configServerFlag []*common.ConfigServerFlag
configActivitySevenDayBox []*common.ConfigActivitySevenDayBox
configActivitySuper []*common.ConfigActivitySuper
1 year ago
configTgRobot []*common.ConfigTgRobot
1 year ago
configBetDraw []*common.ConfigActivityBetDraw
configActivityPopup []*common.ConfigActivityPopup
configDiscountTicket []common.ConfigDiscountTicket
configRtp []common.ConfigRtp
configRankReward []common.ConfigShareRankReward
configRankRule []common.ConfigShareRankRule
// 客服
configCustomerRobot []*common.ConfigCustomerRobot
customerOrderLabel []*common.CustomerOrderLabel
configCustomer *common.ConfigCustomer
3 months ago
configGameClassify []*common.ConfigGameClassify
configRank []*common.ConfigRank
configGameTag []*common.ConfigGameTag
configShowGameTag []*common.ConfigShowGameTag
configGameListAll []*common.ConfigGameList
3 months ago
configPopUp []*common.ConfigPopUp
configPdd *common.ConfigPdd
configLuckyWheel *common.ConfigLuckyWheel
3 months ago
configShareBanner []*common.ConfigShareBanner
configShareTaskNew []*common.ConfigShareTaskNew
configShareLimitTask []*common.ConfigShareLimitTask
configShareWithdrawProducts []*common.ConfigShareWithdrawProducts
ConfigWithdrawChannels []*common.ConfigWithdrawChannels
2 months ago
// 加锁
configShareRankMu sync.Mutex
configShareRankAwardMap map[int]map[int]common.RankAward
configShareRankAward map[int][]common.RankAward
configShareMu sync.Mutex
configShareMap map[int]*common.ConfigShare
configWeekCard *common.ConfigWeekCard
2 months ago
configRtpControl []*common.ConfigRtpControl
1 month ago
configEliminateBet common.ConfigEliminateBet
1 year ago
)
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, withdrawNow int64) bool {
1 year ago
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,withdrawNow:%d", uid, per, recharge, withdraw, withdrawNow)
1 year ago
if per == 0 {
return false
}
return recharge*per >= (withdraw+withdrawNow)*100
1 year ago
}
// 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 {
v.IsOpen = true
1 year ago
if !v.IsValid() {
v.IsOpen = false
1 year ago
}
if v.ActivityID == common.ActivityIDFirstRechargeBack && !ShouldShowActivityFirstRechargeBack(uid) {
continue
}
if v.Push != 1 {
v.IsOpen = false
1 year ago
}
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
}
2 months ago
func GetConfigPayProductByAmount(amount int64) *common.ConfigPayProduct {
if len(configPayProduct) == 0 {
if err := LoadConfigPayProduct(); err != nil {
return nil
}
}
for _, v := range configPayProduct {
if v.Amount == amount {
return v
}
}
return nil
}
1 year ago
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)
}
ConfigPayChannels = ret
return nil
}
1 year ago
// 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
}
1 year ago
// 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
}
2 months ago
func GetWithdrawChannelName(channelId int) string {
var name string
switch channelId {
case 0:
name = "FunzonePay"
case 1:
name = "WellPay"
case 2:
name = "OctroPay"
case 3:
name = "IGeekPay"
case 4:
name = "CloudPay"
case 5:
name = "VSPay"
case 6:
name = "JoyPay"
case 7:
name = "FFPay"
case 8:
name = "BestPay"
case 9:
name = "HXPay"
case 10:
name = "MGPay"
case 11:
name = "OOPay"
case 12:
name = "ZWPay"
case 13:
name = "FastPay"
case 14:
name = "HaoPay"
case 15:
name = "QPPay"
case 16:
name = "OwlPay"
case 17:
name = "SkyPay"
case 18:
name = "GrePay"
case 19:
name = "MoonPay"
case 20:
name = "Acepay"
case 21:
name = "MccPay"
case 22:
name = "YoduPay"
case 23:
name = "WordPay"
case 24:
name = "HWPay"
case 25:
name = "JJPay"
case 26:
name = "AntPay"
case 27:
name = "MlPay"
case 28:
name = "RojPay"
case 29:
name = "QuantaPay"
case 30:
name = "InnoPay"
case 31:
name = "PePay"
case 32:
name = "FF8Pay"
case 33:
name = "flapay"
case 34:
name = "DidaPay"
case 35:
name = "CYGGPay"
case 36:
name = "ZPay"
case 37:
name = "HappyPay"
case 38:
name = "FastPlusPay"
case 39:
name = "GoPay"
case 40:
name = "LemonPay"
case 41:
name = "CamelPay"
case 42:
name = "MoonPay2"
case 43:
name = "Spay"
case 44:
name = "VendooPay"
case 45:
name = "EaniPay"
case 46:
name = "AgroPay"
case 47:
name = "H4pay"
case 48:
name = "NativePay"
case 49:
name = "FeiPay"
case 50:
name = "VTPay"
case 51:
name = "NewbePay"
case 52:
name = "RoosPay"
case 53:
name = "ProPay"
case 54:
name = "FoxPay"
case 55:
name = "SuperPay"
case 56:
name = "STGoPay"
case 57:
name = "QeelinPay"
case 58:
name = "airpay"
case 59:
name = "NSpay"
case 60:
name = "RupeePay"
case 61:
name = "Fpay"
case 62:
name = "kingpay"
case 63:
name = "tkpay"
case 64:
name = "GalloPay"
case 65:
name = "MLPay2"
case 66:
name = "GlobalPay"
case 67:
name = "DDayPay"
case 68:
name = "HongxinPay"
case 69:
name = "Richpay"
case 70:
name = "MoneydealerPay"
case 71:
name = "MtxxPay"
case 72:
name = "robus"
case 73:
name = "MoneydealerNatviePay"
case 74:
name = "Virgopay"
default:
name = "unknown name"
}
return name
}
1 year ago
// 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 {
3 months ago
result := make([]*common.ConfigVIP, 0, len(configVIP))
for _, v := range configVIP {
tmpV := *v
result = append(result, &tmpV)
}
return result
1 year ago
}
2 months ago
func GetConfigVIPWithout0() []*common.ConfigVIP {
result := make([]*common.ConfigVIP, 0, len(configVIP)-1)
for _, v := range configVIP {
if v.Level == 0 {
continue
}
tmpV := *v
result = append(result, &tmpV)
}
return result
}
1 year ago
// 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 {
3 months ago
if v.TagIdMap == nil {
v.TagIdMap = make(map[int]struct{})
}
if v.TagIds != "" {
var tagIds []int
err = jsoniter.UnmarshalFromString(v.TagIds, &tagIds)
if err != nil {
log.Error("unmarshal tagIds err, %s", err.Error())
} else {
for _, tagId := range tagIds {
v.TagIdMap[tagId] = struct{}{}
}
}
}
1 year ago
for _, k := range providers {
if v.GameProvider == k.ProviderID {
1 year ago
if k.Open == 1 { // 特殊过滤
1 year ago
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
3 months ago
configGameListAll = tmplist
1 year ago
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
}
1 year ago
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
}
1 year ago
// 游戏列表配置
// 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 {
1 year ago
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)
}
1 year ago
}
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
}
1 year ago
}
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
}
1 year ago
func GetConfigGameListByType(t int) []*common.ConfigGameList {
ret := []*common.ConfigGameList{}
for _, v := range configGameList {
if v.GameType == t {
ret = append(ret, v)
}
}
return ret
}
// 游戏类别配置
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) {
2 months ago
configShareMu.Lock()
defer configShareMu.Unlock()
3 months ago
list := []*common.ConfigShare{}
2 months ago
if _, err = db.Mysql().QueryAll("", "level", &common.ConfigShare{}, &list); err != nil {
1 year ago
log.Error("err:%v", err)
return err
}
2 months ago
if configShareMap == nil {
configShareMap = make(map[int]*common.ConfigShare)
}
3 months ago
for _, v := range list {
if v.RewardTiers != "" {
err := json.Unmarshal([]byte(v.RewardTiers), &v.SubRewardTiers)
if err != nil {
log.Error("err:%v", err)
return err
}
2 months ago
v.SubRewardTiersMap = make(map[int]common.ConfigShareTiers)
for _, tier := range v.SubRewardTiers {
v.SubRewardTiersMap[tier.Tier] = tier
}
3 months ago
}
2 months ago
configShareMap[v.Level] = v
3 months ago
}
configShare = list
1 year ago
return nil
}
3 months ago
func GetConfigShare(level, channel int) *common.ConfigShare {
for _, v := range configShare {
2 months ago
if v.Level == level {
3 months ago
return v
}
}
return nil
1 year ago
}
2 months ago
func GetConfigShareAll() []common.ConfigShare {
result := make([]common.ConfigShare, 0, len(configShare))
1 year ago
for _, v := range configShare {
2 months ago
result = append(result, *v)
1 year ago
}
3 months ago
return result
1 year ago
}
2 months ago
func GetConfigShareMap() map[int]*common.ConfigShare {
configShareMu.Lock()
defer configShareMu.Unlock()
return configShareMap
}
//func GetConfigShareByExp(channel int, exp int64) (ret *common.ConfigShare) {
// cons := GetConfigShares(channel)
// if len(cons) == 0 {
// return
// }
// for i, v := range cons {
// if v.Exp < 0 {
// continue
// }
// if exp == v.Exp {
// return v
// }
// if exp < v.Exp && i > 0 {
// return cons[i-1]
// }
// }
// ret = cons[len(cons)-1]
// return
//}
//func GetConfigShares(channel int) []*common.ConfigShare {
// var result []*common.ConfigShare
// for _, v := range configShare {
// if v.Channel == channel || v.Channel == channel-10000 {
// result = append(result, v)
// continue
// }
// }
// return result
//}
1 year ago
// 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 {
1 year ago
if int(v.Type) == t {
1 year ago
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
}
1 year ago
func GetConfigCurrencyResourceMultiple(t common.CurrencyRes) int64 {
for _, v := range configCurrencyResource {
if v.Type == t {
return v.Multiple
}
}
return 0
}
3 months ago
func GetConfigCurrencyResourceNeedBet(t common.CurrencyRes, amount int64, speMultiples ...int) (needBet int64) {
1 year ago
if amount <= 0 {
return
}
3 months ago
if len(speMultiples) != 0 {
return amount * int64(speMultiples[0])
}
1 year ago
needBet = GetConfigCurrencyResourceMultiple(t) * amount / 100
if needBet < 0 {
needBet = 0
}
return
}
func GetConfigCurrencyResourceNeedBetByActId(activityId int, amount int64) (needBet int64) {
if amount <= 0 {
return
}
switch activityId {
case common.ActivityIDWeekCard:
config := GetConfigWeekCard()
needBet = int64(config.BetMultiples) * amount
return
}
return
}
1 year ago
// 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 GetConfigFirstPayByCount(uid int, amount int64, buyCountMap map[string]int) (times int, per int64, topThree bool) {
1 month ago
var buyCount int
if buyCountMap != nil {
//// todo 一个额度一个首充计算
//buyCount = buyCountMap[fmt.Sprintf("%d", amount)]
// todo 全部额度公用一个首充计算
for _, count := range buyCountMap {
buyCount += count
}
1 month ago
times = buyCount
}
3 months ago
for _, v := range configFirstPay {
if v.Amount == amount {
switch buyCount {
case 0:
per = v.FirstPer
topThree = true
case 1:
per = v.SecondPer
topThree = true
case 2:
per = v.ThirdPer
topThree = true
default:
per = v.Per
}
break
}
}
if buyCount < 20 {
topThree = true
}
//log.Debug("uid:%d rechargeCount:%d per:%d", uid, buyCount, per)
3 months ago
return
}
1 year ago
// 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
}
1 year ago
func GetConfigAcitivityLuckyCode(t int) []*common.ConfigActivityLuckyCode {
var ret []*common.ConfigActivityLuckyCode
for _, conf := range configActivityLuckyCode {
if conf.Type == t {
ret = append(ret, conf)
}
}
return ret
1 year ago
}
1 year ago
func GetConfigAcitivityLuckyCodeTotalWeight(t int) (total int64) {
1 year ago
for _, v := range configActivityLuckyCode {
1 year ago
if v.Type == t {
total += v.Per
}
1 year ago
}
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
3 months ago
sort.Slice(configBanner, func(i, j int) bool {
return configBanner[i].Sort > configBanner[j].Sort
})
1 year ago
return nil
}
3 months ago
func GetConfigBanner(uid, tagId int) []*common.ConfigBanner {
1 year ago
list := []*common.ConfigBanner{}
for _, v := range configBanner {
if !v.IsValid() {
continue
}
if v.ActivityID == common.ActivityIDFirstRechargeBack && !ShouldShowActivityFirstRechargeBack(uid) {
continue
}
3 months ago
if v.TagId != tagId {
continue
}
1 year ago
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
}
1 year ago
func GetConfigActivitySignByWheel(wheel int) (ret []*common.ConfigActivitySign) {
for _, conf := range configActivitySign {
if wheel >= conf.WheelStart && wheel <= conf.WheelEnd {
ret = append(ret, conf)
}
}
return
}
1 year ago
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 LoadConfigWeekCard() (err error) {
one := new(common.ConfigWeekCard)
if _, err = db.Mysql().QueryAll("switch = 1", "", &common.ConfigWeekCard{}, &one); err != nil {
log.Error("err:%v", err)
1 year ago
return err
}
if one.AwardData != "" {
var awardData []common.WeekCardDay
err = json.Unmarshal([]byte(one.AwardData), &awardData)
if err != nil {
log.Error("unmarshal err, %s", err.Error())
return
}
one.AwardDetails = make(map[int]common.WeekCardDay)
for _, v := range awardData {
one.AwardDetails[v.Day] = v
}
}
configWeekCard = one
1 year ago
return nil
}
func GetConfigWeekCard() *common.ConfigWeekCard {
return configWeekCard
1 year ago
}
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
}
1 year ago
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
}
1 year ago
// 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
}
1 year ago
// GetConfigDiscountTicketByAmount 不存在就获取小一档的
func GetConfigDiscountTicketByAmount(amount int64) (ret common.ConfigDiscountTicket) {
for _, item := range configDiscountTicket {
1 year ago
if item.RechargeAmount <= amount {
ret = item
}
}
1 year ago
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.MaxRecharge {
return item
}
}
return
}
func LoadConfigRobotRankReward() (err error) {
var list []common.ConfigShareRankReward
if _, err = db.Mysql().QueryAll("", "", &common.ConfigShareRankReward{}, &list); err != nil {
log.Error("err:%v", err)
return err
}
configRankReward = list
return nil
}
func GetConfigRobotRankReward() []common.ConfigShareRankReward {
return configRankReward
}
func GetConfigRobotRankRewardByRank(rank int) (ret common.ConfigShareRankReward) {
for _, conf := range configRankReward {
if conf.StartLevel <= rank && conf.EndLevel >= rank {
return conf
}
}
return
}
func LoadConfigRobotRankRule() (err error) {
var list []common.ConfigShareRankRule
if _, err = db.Mysql().QueryAll("", "", &common.ConfigShareRankRule{}, &list); err != nil {
log.Error("err:%v", err)
return err
}
configRankRule = list
return nil
}
func GetConfigRobotRankRule() []common.ConfigShareRankRule {
return configRankRule
}
func GetConfigRobotRankRuleByDay(day int) (ret common.ConfigShareRankRule) {
for _, rule := range configRankRule {
if rule.Day == day {
return rule
}
}
return
}
3 months ago
func LoadConfigRank() (err error) {
var list []*common.ConfigRank
if _, err = db.Mysql().QueryAll("open = 1", "", &common.ConfigRank{}, &list); err != nil {
log.Error("err:%v", err)
return err
}
for _, rank := range list {
if rank.RankCycle != "" {
err = jsoniter.UnmarshalFromString(rank.RankCycle, &rank.RankCycleMap)
if err != nil {
log.Error("unmarshal RankCycle err, %+v, %s", *rank, err.Error())
return
}
}
if rank.FreeRates != "" {
err = jsoniter.UnmarshalFromString(rank.FreeRates, &rank.FreeRatesMap)
if err != nil {
log.Error("unmarshal FreeRates err, %+v, %s", *rank, err.Error())
return
}
}
if rank.RankAwards != "" {
var tmpRankAwards map[string]string
rank.RankAwardsMap = make(map[string][]common.RankAward)
rank.RankAwardsOneMap = make(map[string]map[int]common.RankAward)
3 months ago
err = jsoniter.UnmarshalFromString(rank.RankAwards, &tmpRankAwards)
if err != nil {
log.Error("unmarshal RankAwards err, %+v, %s", *rank, err.Error())
return
}
if len(tmpRankAwards) == 0 {
log.Error("rankAwards is nil, %+v", *rank)
return
}
for rankCycle, awards := range tmpRankAwards {
var tmpAwards []common.RankAward
err = jsoniter.UnmarshalFromString(awards, &tmpAwards)
if err != nil {
log.Error("unmarshal awards details err, %+v, %s", *rank, err.Error())
return
}
tmpAwardOne := make(map[int]common.RankAward)
for _, v := range tmpAwards {
for index := v.SmallRank; index <= v.LargeRank; index++ {
tmpAwardOne[index] = v
}
}
rank.RankAwardsOneMap[rankCycle] = tmpAwardOne
3 months ago
rank.RankAwardsMap[rankCycle] = tmpAwards
}
}
3 months ago
if rank.RobotCfg != "" {
rank.RobotCfgValue = new(common.RobotCfg)
err = jsoniter.UnmarshalFromString(rank.RobotCfg, &rank.RobotCfgValue)
if err != nil {
log.Error("unmarshal RobotCfg err, %+v, %s", *rank, err.Error())
return
}
rank.RobotCfgValue.RobotRank = strings.ReplaceAll(rank.RobotCfgValue.RobotRank, " ", "")
rank.RobotCfgValue.RobotRankMap = make(map[int]struct{})
robotRanks := strings.Split(rank.RobotCfgValue.RobotRank, ",")
3 months ago
for _, rankInterval := range robotRanks {
if strings.Contains(rankInterval, "-") {
rankIntervalDetails := strings.Split(rankInterval, "-")
if len(rankIntervalDetails) != 2 {
log.Error("rankInterval is wrong, %+v, %s", *rank, rankIntervalDetails)
return
}
for i := util.ToInt(rankIntervalDetails[0]); i <= util.ToInt(rankIntervalDetails[1]); i++ {
3 months ago
rank.RobotCfgValue.RobotRankMap[i] = struct{}{}
3 months ago
}
} else {
rankNum := util.ToInt(rankInterval)
if rankNum == 0 {
log.Error("rankInterval is wrong, %+v, %s", *rank, rankInterval)
return
}
3 months ago
rank.RobotCfgValue.RobotRankMap[rankNum] = struct{}{}
3 months ago
}
}
3 months ago
for k := range rank.RobotCfgValue.RobotRankMap {
rank.RobotCfgValue.RobotRankArray = append(rank.RobotCfgValue.RobotRankArray, k)
}
sort.Ints(rank.RobotCfgValue.RobotRankArray)
3 months ago
}
}
configRank = list
return nil
}
func GetConfigRank(rankType int) (result []*common.ConfigRank) {
if len(configRank) == 0 {
LoadConfigRank()
}
for _, v := range configRank {
if rankType != 0 && v.RankType != rankType {
continue
}
result = append(result, v)
}
return
}
func GetConfigRankByCycle(rankType int, cycle string) (result *common.ConfigRank) {
if len(configRank) == 0 {
LoadConfigRank()
}
for _, v := range configRank {
if rankType != 0 && v.RankType != rankType {
continue
}
if cycle != "" {
if _, ok := v.RankCycleMap[cycle]; !ok {
continue
}
}
return v
}
return
}
func GetConfigRankById(rankId int) (result *common.ConfigRank) {
if len(configRank) == 0 {
LoadConfigRank()
}
for _, v := range configRank {
if v.ID != rankId {
continue
}
result = v
return
}
return
}
func LoadConfigGameTag() (err error) {
var list []*common.ConfigGameTag
if _, err = db.Mysql().QueryAll("`show`=1", "", &common.ConfigGameTag{}, &list); err != nil {
log.Error("err:%v", err)
return err
}
configGameTag = list
sort.Slice(configGameTag, func(i, j int) bool {
return configGameTag[i].Sort > configGameTag[j].Sort
})
return nil
}
func GetConfigGameTag() (result []*common.ConfigGameTag) {
if len(configGameTag) == 0 {
LoadConfigGameTag()
}
result = configGameTag
return
}
func GetConfigGameTagByIds(ids []int, notSort bool) (result []*common.ConfigGameTag) {
3 months ago
if len(configGameTag) == 0 {
LoadConfigGameTag()
}
idOrderMap := make(map[int]int)
for i, id := range ids {
idOrderMap[id] = i
}
3 months ago
for _, v := range configGameTag {
if util.SliceContain(ids, v.TagId) {
result = append(result, v)
}
}
if notSort {
sort.Slice(result, func(i, j int) bool {
orderI, okI := idOrderMap[result[i].TagId]
orderJ, okJ := idOrderMap[result[j].TagId]
if okI && okJ {
return orderI < orderJ
}
if okI && !okJ {
return true
}
if !okI && okJ {
return false
}
return result[i].Sort > result[j].Sort
})
} else {
sort.Slice(result, func(i, j int) bool {
return result[i].Sort > result[j].Sort
})
}
3 months ago
return
}
func GetGameListByTags(tagIds []int) (result []*common.ConfigGameList) {
for _, v := range configGameListAll {
contain := true
for _, tagId := range tagIds {
_, ok := v.TagIdMap[tagId]
if !ok {
contain = false
break
}
}
if contain {
result = append(result, v)
}
}
sort.Slice(result, func(i, j int) bool {
return result[i].Sort > result[j].Sort
})
return result
}
func GetConfigGameListByCode(provider int, gameCode string) *common.ConfigGameList {
for _, v := range configGameListAll {
if v.GameProvider == provider && v.GameCode == gameCode {
return v
}
}
return nil
}
2 months ago
func GetGameName(providerID int, gameCode string) string {
game := GetConfigGameListByCode(providerID, gameCode)
if game != nil {
return game.Name
}
return "Play Game"
}
3 months ago
func GetGameListByByID(providerID int, gameID int) (result *common.ConfigGameList) {
for _, v := range configGameListAll {
2 months ago
if v.GameProvider != providerID || v.GameID != gameID {
3 months ago
continue
}
return v
}
return nil
}
func GetGameListAll() (result []*common.ConfigGameList) {
return configGameListAll
}
func LoadConfigShowGameTag() (err error) {
var list []*common.ConfigShowGameTag
if _, err = db.Mysql().QueryAll("", "", &common.ConfigShowGameTag{}, &list); err != nil {
log.Error("err:%v", err)
return err
}
for _, v := range list {
if v.ShowTagIds != "" {
err = jsoniter.UnmarshalFromString(v.ShowTagIds, &v.ShowTagIdsInt)
if err != nil {
log.Error("unmarshal ShowTagIds err, %s, %+v", err.Error(), *v)
return
}
}
}
configShowGameTag = list
sort.Slice(configGameTag, func(i, j int) bool {
return configGameTag[i].Sort > configGameTag[j].Sort
})
return nil
}
func GetConfigShowGameTag(id int) (result []*common.ConfigShowGameTag) {
if len(configShowGameTag) == 0 {
LoadConfigShowGameTag()
}
result = make([]*common.ConfigShowGameTag, 0, len(configGameTag))
for _, v := range configShowGameTag {
if id != 0 && id != v.TagId {
continue
}
result = append(result, v)
}
return
}
func GetConfigShowGameTagIds() (result []int) {
if len(configShowGameTag) == 0 {
LoadConfigShowGameTag()
}
for _, v := range configShowGameTag {
result = append(result, v.TagId)
}
return
}
3 months ago
func LoadConfigPopUp() (err error) {
list := []*common.ConfigPopUp{}
if _, err = db.Mysql().QueryAll(" `switch` = 1 ", "", &common.ConfigPopUp{}, &list); err != nil {
log.Error("err:%v", err)
return err
}
for index, v := range list {
if v.UserTag == 2 {
userTagValue := util.ToInt(v.UserTagValue)
if userTagValue == 0 {
log.Error("get userTagValue err, %+v", *v)
err = errors.New("get user tag value err")
return
}
list[index].UserTagValueInt = userTagValue
}
err = jsoniter.UnmarshalFromString(v.Channel, &v.ChannelIds)
if err != nil {
log.Error("unmarshal channel err, %+v: %s", *v, err.Error())
}
if v.AwardInfo != "" {
err = jsoniter.UnmarshalFromString(v.AwardInfo, &v.AwardInfos)
if err != nil {
log.Error("unmarshal awardInfo err, %s", err.Error())
}
}
for _, channelId := range v.ChannelIds {
if channelId == -1 {
v.AllChannel = true
}
}
}
configPopUp = list
return nil
}
func GetConfigPopUp(popScene, channelId int) []*common.ConfigPopUp {
if len(configPopUp) == 0 {
LoadConfigPopUp()
}
result := []*common.ConfigPopUp{}
for _, v := range configPopUp {
if !v.AllChannel && !util.SliceContain(v.ChannelIds, channelId) {
continue
}
if v.PopRule == 3 && channelId >= 10000 {
continue
}
if v.PopScene == popScene {
result = append(result, v)
}
}
sort.Slice(result, func(i, j int) bool {
return result[i].Sort > result[j].Sort
})
return result
}
func GetConfigPopUpByChannel(channelId int) []*common.ConfigPopUp {
if len(configPopUp) == 0 {
LoadConfigPopUp()
}
result := []*common.ConfigPopUp{}
for _, v := range configPopUp {
if !v.AllChannel && !util.SliceContain(v.ChannelIds, channelId) {
continue
}
result = append(result, v)
}
return result
}
func LoadConfigPdd() (err error) {
var result common.ConfigPdd
err = db.Mysql().C().Model(&common.ConfigPdd{}).Where("`switch` = 1").Order("id desc").Find(&result).Error
if err != nil {
log.Error("err:%s", err.Error())
return
}
if result.ID == 0 {
return
}
err = jsoniter.UnmarshalFromString(result.PddCfg, &result.PddCfgStr)
if err != nil {
log.Error("unmarshal err, %s", err.Error())
return
}
for _, v := range result.PddCfgStr.PddAwards {
result.PddCfgStr.WeightsSum += v.Weights
}
configPdd = &result
return nil
}
func GetConfigPdd() *common.ConfigPdd {
if configPdd == nil {
LoadConfigPdd()
}
return configPdd
}
func LoadConfigLuckyWheel() (err error) {
var result common.ConfigLuckyWheel
err = db.Mysql().C().Model(&common.ConfigLuckyWheel{}).Where("`switch` = 1").Order("id desc").Find(&result).Error
if err != nil {
log.Error("err:%s", err.Error())
return
}
if result.ID == 0 {
return
}
err = json.Unmarshal([]byte(result.WheelCfg), &result.WheelCfgStr)
if err != nil {
log.Error("unmarshal err, %s", err.Error())
return
}
for index, luckyWheel := range result.WheelCfgStr {
for _, luckyAward := range luckyWheel.LuckyAwards {
result.WheelCfgStr[index].WeightsSum += luckyAward.Weights
}
}
configLuckyWheel = &result
return nil
}
func GetConfigLuckyWheel() *common.ConfigLuckyWheel {
if configLuckyWheel == nil {
LoadConfigLuckyWheel()
}
return configLuckyWheel
}
3 months ago
func LoadConfigShareBanner() (err error) {
list := []*common.ConfigShareBanner{}
if _, err = db.Mysql().QueryAll("", "sort asc", &common.ConfigShareBanner{}, &list); err != nil {
log.Error("err:%v", err)
return err
}
configShareBanner = list
return nil
}
2 months ago
func GetConfigShareBanner() []*common.ConfigShareBanner {
3 months ago
var result []*common.ConfigShareBanner
for _, v := range configShareBanner {
2 months ago
result = append(result, v)
3 months ago
}
return result
}
func LoadConfigShareTaskNew() (err error) {
list := []*common.ConfigShareTaskNew{}
if _, err = db.Mysql().QueryAll("", "task_id asc", &common.ConfigShareTaskNew{}, &list); err != nil {
log.Error("err:%v", err)
return err
}
configShareTaskNew = list
return nil
}
func GetConfigShareTaskNew() []*common.ConfigShareTaskNew {
return configShareTaskNew
}
func LoadConfigShareLimitTask() (err error) {
list := []*common.ConfigShareLimitTask{}
if _, err = db.Mysql().QueryAll("", "level asc", &common.ConfigShareLimitTask{}, &list); err != nil {
log.Error("err:%v", err)
return err
}
configShareLimitTask = list
return nil
}
func GetConfigShareLimitTask(level, channel int) *common.ConfigShareLimitTask {
for _, v := range configShareLimitTask {
if v.Level != level {
continue
}
if v.Channel == channel || v.Channel == channel-10000 {
return v
}
}
return nil
}
func LoadConfigShareWithdrawProducts() (err error) {
list := []*common.ConfigShareWithdrawProducts{}
if _, err = db.Mysql().QueryAll("", "amount asc", &common.ConfigShareWithdrawProducts{}, &list); err != nil {
log.Error("err:%v", err)
return err
}
configShareWithdrawProducts = list
return nil
}
func GetConfigShareWithdrawProducts(channel int) []*common.ConfigShareWithdrawProducts {
var result []*common.ConfigShareWithdrawProducts
for _, v := range configShareWithdrawProducts {
if v.Channel == channel || v.Channel == channel-10000 {
result = append(result, v)
continue
}
}
return result
}
func GetShareWithdrawInfo(uid int) *common.ShareWithdrawInfo {
info := &common.ShareWithdrawInfo{UID: uid}
db.Mysql().Get(info)
now := time.Now().Unix()
if info.ID == 0 {
info.DayTime = now
db.Mysql().Create(info)
}
info.SubRecord = map[int64]int{}
if info.Record != "" {
json.Unmarshal([]byte(info.Record), &info.SubRecord)
}
if !util.IsSameDayTimeStamp(now, info.DayTime) {
info.DayCount = 0
2 months ago
info.TodayWithdraw = 0
3 months ago
}
if info.DayCount < 0 {
info.DayCount = 0
}
return info
}
2 months ago
func LoadConfigShareRankAward() (err error) {
configShareRankMu.Lock()
defer configShareRankMu.Unlock()
list := []*common.ConfigShareRankAward{}
if _, err = db.Mysql().QueryAll("", "", &common.ConfigShareRankAward{}, &list); err != nil {
log.Error("err:%v", err)
return err
}
if configShareRankAwardMap == nil {
configShareRankAwardMap = make(map[int]map[int]common.RankAward)
configShareRankAward = make(map[int][]common.RankAward)
}
for _, v := range list {
var tmpRankAward []common.RankAward
err = json.Unmarshal([]byte(v.RankAwards), &tmpRankAward)
if err != nil {
log.Error("unmarshal share rank award err, %s", err.Error())
return
}
tmpRankAwardMap := make(map[int]common.RankAward)
for _, award := range tmpRankAward {
for index := award.SmallRank; index <= award.LargeRank; index++ {
tmpRankAwardMap[index] = award
}
}
configShareRankAwardMap[v.ShareRankType] = tmpRankAwardMap
configShareRankAward[v.ShareRankType] = tmpRankAward
}
return nil
}
func GetConfigShareRankAwardMap(shareRankType ...int) (result map[int]common.RankAward) {
configShareRankMu.Lock()
defer configShareRankMu.Unlock()
if configShareRankAwardMap == nil {
LoadConfigShareRankAward()
}
if configShareRankAwardMap == nil {
return nil
}
if len(shareRankType) > 0 {
return configShareRankAwardMap[shareRankType[0]]
}
return configShareRankAwardMap[2]
}
2 months ago
func LoadConfigRtpControl() (err error) {
var result []*common.ConfigRtpControl
err = db.Mysql().C().Model(&common.ConfigRtpControl{}).Order("recharge_day,withdraw_per").Find(&result).Error
if err != nil {
log.Error("err:%v", err)
return err
}
sort.Slice(result, func(i, j int) bool {
a, b := result[i], result[j]
// 处理RechargeDay:-1排到最后
if a.RechargeDay == -1 && b.RechargeDay != -1 {
return false // a排在b后面
}
if a.RechargeDay != -1 && b.RechargeDay == -1 {
return true // a排在b前面
}
if a.RechargeDay == -1 && b.RechargeDay == -1 {
// 都是-1,继续比较下一个字段
if a.WithdrawPer == -1 && b.WithdrawPer != -1 {
return false
}
if a.WithdrawPer != -1 && b.WithdrawPer == -1 {
return true
}
if a.WithdrawPer == -1 && b.WithdrawPer == -1 {
if a.PersonalRtp == -1 && b.PersonalRtp != -1 {
return false
}
if a.PersonalRtp != -1 && b.PersonalRtp == -1 {
return true
}
return a.PersonalRtp < b.PersonalRtp
} else {
if a.WithdrawPer != b.WithdrawPer {
return a.WithdrawPer < b.WithdrawPer
}
}
} else {
if a.RechargeDay != b.RechargeDay {
return a.RechargeDay < b.RechargeDay
}
}
// 处理WithdrawPer:-1排到最后
if a.WithdrawPer == -1 && b.WithdrawPer != -1 {
return false
}
if a.WithdrawPer != -1 && b.WithdrawPer == -1 {
return true
}
if a.WithdrawPer == -1 && b.WithdrawPer == -1 {
// 都是-1,继续比较下一个字段
if a.PersonalRtp == -1 && b.PersonalRtp != -1 {
return false
}
if a.PersonalRtp != -1 && b.PersonalRtp == -1 {
return true
}
return a.PersonalRtp < b.PersonalRtp
} else {
if a.WithdrawPer != b.WithdrawPer {
return a.WithdrawPer < b.WithdrawPer
}
}
// 处理PersonalRtp:-1排到最后
if a.PersonalRtp == -1 && b.PersonalRtp != -1 {
return false
}
if a.PersonalRtp != -1 && b.PersonalRtp == -1 {
return true
}
if a.PersonalRtp == -1 && b.PersonalRtp == -1 {
// 都是-1,相等
return false
} else {
return a.PersonalRtp < b.PersonalRtp
}
})
2 months ago
configRtpControl = result
return nil
}
func GetConfigRtpControl() []*common.ConfigRtpControl {
return configRtpControl
}
1 month ago
func LoadConfigEliminateBet() (err error) {
var result common.ConfigEliminateBet
err = db.Mysql().C().Model(&common.ConfigEliminateBet{}).Find(&result).Error
if err != nil {
log.Error("err:%v", err)
return err
}
configEliminateBet = result
return nil
}
func GetConfigEliminateBet() common.ConfigEliminateBet {
return configEliminateBet
}