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.
144 lines
3.6 KiB
144 lines
3.6 KiB
package handler |
|
|
|
import ( |
|
"fmt" |
|
"server/call" |
|
"server/common" |
|
"server/config" |
|
"server/db" |
|
"server/modules/web/app" |
|
"server/modules/web/values" |
|
"server/util" |
|
"strconv" |
|
"time" |
|
|
|
"github.com/gin-gonic/gin" |
|
"github.com/liangdas/mqant/log" |
|
"github.com/olivere/elastic/v7" |
|
) |
|
|
|
func SysConfig(c *gin.Context) { |
|
a := app.NewApp(c) |
|
resp := &values.SysConfigResp{} |
|
defer func() { |
|
a.Response() |
|
}() |
|
req := new(values.SysConfigReq) |
|
if !a.S(req) { |
|
return |
|
} |
|
ip := a.GetRemoteIP() |
|
uuid := a.UUID |
|
log.Debug("sysconfig ip:%v,req:%+v,uuid:%v", ip, *req, uuid) |
|
if call.CheckChannel(req.Channel, ip) { |
|
a.Code = values.CodeParam |
|
return |
|
} |
|
channel := call.GetChannelByID(req.Channel) |
|
if channel == nil { |
|
log.Error("invalid channel:%v", req.Channel) |
|
a.Code = values.CodeParam |
|
return |
|
} |
|
isExamine := call.CheckExamine(req.Version, ip, uuid, channel) |
|
if !isExamine && !req.IsRecord { |
|
cid := a.Channel |
|
if len(uuid) > 0 { |
|
// 处理一下新增安装 |
|
util.Go(func() { |
|
q := elastic.NewBoolQuery() |
|
q.Must(elastic.NewMatchQuery("UUID.keyword", uuid)) |
|
q.Must(elastic.NewMatchQuery("Channel", cid)) |
|
if db.ES().Count(common.ESIndexBackOpenRecord, q) > 0 { |
|
return |
|
} |
|
id := fmt.Sprintf("%v_%v", cid, uuid) |
|
db.ES().InsertToESByIDGO(common.ESIndexBackOpenRecord, id, &common.ESOpenRecord{Time: time.Now().Unix(), UUID: uuid, Channel: cid}) |
|
}) |
|
} |
|
} |
|
|
|
// ok |
|
url := channel.URL |
|
if url == "" { |
|
url = config.GetBase().Server.GameURL |
|
if isExamine { |
|
url = config.GetBase().Server.ExamineURL |
|
} |
|
} else { |
|
if isExamine { |
|
url = "web." + url + config.GetConfig().Web.Addr |
|
} else { |
|
url = "game." + url + config.GetConfig().Web.Addr |
|
} |
|
} |
|
resp.Is = isExamine |
|
resp.URL = url |
|
resp.IsHot = channel.IsHot == 2 |
|
resp.NewPlayerGift = call.GetConfigPlatform().NewPlayerGift |
|
resp.PhoneBonus = call.GetConfigPlatform().BindPhoneGift |
|
resp.ServiceEmail = call.GetConfigPlatform().Email |
|
resp.ServiceTelegram = call.GetConfigPlatform().Telegram |
|
resp.ServiceWhatsapp = call.GetConfigPlatform().Whatsapp |
|
|
|
ver := c.GetHeader("version") |
|
version, _ := strconv.Atoi(ver) |
|
if call.WhitePass(ip, uuid, "/sys/hotUpdate", version, a.Channel) { |
|
resp.Version = channel.MainVersion |
|
} |
|
log.Debug("resp:%+v", resp) |
|
a.Data = resp |
|
} |
|
|
|
func SysConfig2(c *gin.Context) { |
|
a := app.NewApp(c) |
|
defer a.Response() |
|
req := new(values.SysConfigReq) |
|
if !a.S(req) { |
|
a.Code = values.CodeRetry |
|
return |
|
} |
|
channel := call.GetChannelByID(req.Channel) |
|
if channel == nil { |
|
log.Error("invalid channel:%v", req.Channel) |
|
a.Code = values.CodeParam |
|
return |
|
} |
|
gpsID := req.GPSAdid |
|
isExamine := len(gpsID) == 0 |
|
if channel.IgnoreOrganic == 2 && len(gpsID) > 0 { |
|
isOrganic := false |
|
if util.SliceContain(config.GetConfig().Web.OldChannels, channel.ChannelID) { |
|
isOrganic = call.IsOrganic2(gpsID, channel.AdjustAppToken, channel.ChannelID, 3) |
|
} else { |
|
isOrganic = call.IsOrganic(gpsID, channel.AdjustAppToken, channel.ChannelID, 3) |
|
} |
|
if isOrganic { |
|
count := db.Mysql().Count(&common.PlayerDBInfo{}, fmt.Sprintf("channel_id = %v and deviceid = '%v'", channel.ChannelID, gpsID)) |
|
if count == 0 { |
|
isExamine = true |
|
} |
|
} |
|
} |
|
a.Data = isExamine |
|
} |
|
|
|
func Config(c *gin.Context) { |
|
a := app.NewApp(c) |
|
defer func() { |
|
a.ResponseB() |
|
}() |
|
resp := &values.ConfigResp{} |
|
a.Data = resp |
|
channel := call.GetChannelByID(a.Channel) |
|
log.Debug("Config channel:%v,channel:%+v", a.Channel, channel) |
|
if channel == nil { |
|
return |
|
} |
|
resp.AdjustAppToken = channel.AdjustAppToken |
|
resp.AdjustEvents = channel.AdjustEventID |
|
resp.FBPixelID = channel.FBPixelID |
|
// resp.FBAccessToken = channel.FBAccessToken |
|
resp.Channel = channel.ChannelID |
|
|
|
}
|
|
|