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.
117 lines
3.7 KiB
117 lines
3.7 KiB
|
1 year ago
|
package gs
|
||
|
|
|
||
|
|
import (
|
||
|
|
"fmt"
|
||
|
|
"server/call"
|
||
|
|
"server/common"
|
||
|
|
"server/config"
|
||
|
|
"server/db"
|
||
|
|
"server/modules/web/providers/base"
|
||
|
|
"server/util"
|
||
|
|
"time"
|
||
|
|
|
||
|
|
"github.com/liangdas/mqant/log"
|
||
|
|
)
|
||
|
|
|
||
|
|
type Sub struct {
|
||
|
|
Base *base.Base
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewSub(base *base.Base) {
|
||
|
|
base.Sub = &Sub{Base: base}
|
||
|
|
base.SubInitRouter = GS
|
||
|
|
}
|
||
|
|
|
||
|
|
func (s *Sub) Init() {
|
||
|
|
API = APITest
|
||
|
|
AgentMap = AgentMapTest
|
||
|
|
if config.GetBase().Release {
|
||
|
|
API = APIRlease
|
||
|
|
AgentMap = AgentMapRelease
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
type EnterGameReq struct {
|
||
|
|
OperatorCode string `json:"OperatorCode"` // Seamless运算符的唯一标识符 (Yes)
|
||
|
|
MemberName string `json:"MemberName"` // 操作员的玩家唯一标识符 (Yes)
|
||
|
|
DisplayName string `json:"DisplayName,omitempty"` // 玩家的显示名称 (No)
|
||
|
|
Password string `json:"Password,omitempty"` // 操作员中的玩家密码 (No)
|
||
|
|
GameID string `json:"GameID,omitempty"` // 独特的提供商游戏代码 (No)
|
||
|
|
ProviderGameType string `json:"ProviderGameType,omitempty"` // 供应商的游戏类型 (No)
|
||
|
|
ProductID int `json:"ProductID"` // Seamless产品的唯一标识符 (Yes)
|
||
|
|
GameType int `json:"GameType"` // 游戏类型 (Yes)
|
||
|
|
LanguageCode int `json:"LanguageCode"` // 语言代码 (Yes)
|
||
|
|
Platform int `json:"Platform"` // 平台 (Yes)
|
||
|
|
IPAddress string `json:"IPAddress"` // 客户端的 IP 地址 (Yes)
|
||
|
|
OperatorLobbyURL string `json:"OperatorLobbyURL,omitempty"` // 运营商主页的URL (No)
|
||
|
|
Sign string `json:"Sign"` // 请求的签名 (Yes)
|
||
|
|
RequestTime string `json:"RequestTime"` // DateTime 格式为 yyyMDDHHMMSS (Yes)
|
||
|
|
}
|
||
|
|
|
||
|
|
type EnterGameResp struct {
|
||
|
|
ErrorCode int `json:"ErrorCode"` // 响应的状态代码 (Yes)
|
||
|
|
ErrorMessage string `json:"ErrorMessage"` // 响应消息 (Yes)
|
||
|
|
Url string `json:"Url,omitempty"` // 游戏网址 (No)
|
||
|
|
}
|
||
|
|
|
||
|
|
func (s *Sub) EnterGame() string {
|
||
|
|
uid := s.Base.EnterGameReq.UID
|
||
|
|
// ct := s.Base.EnterGameReq.CurrencyType
|
||
|
|
gameID := s.Base.EnterGameReq.GameID
|
||
|
|
// subID := s.Base.EnterGameReq.SubID
|
||
|
|
lang := s.Base.EnterGameReq.Lang
|
||
|
|
providerID := s.Base.EnterGameReq.ProviderID
|
||
|
|
ip := s.Base.EnterGameReq.IP
|
||
|
|
cid := s.Base.EnterGameReq.ChannelID
|
||
|
|
|
||
|
|
game := call.GetConfigGameListByID(providerID, gameID)
|
||
|
|
if game == nil {
|
||
|
|
return ""
|
||
|
|
}
|
||
|
|
currency, err := db.Redis().GetInt(common.GetRedisKeyGameCurrency(uid))
|
||
|
|
if err != nil {
|
||
|
|
log.Error("err:%v", err)
|
||
|
|
return ""
|
||
|
|
}
|
||
|
|
agent := GetAgentByCurrency(common.CurrencyType(currency))
|
||
|
|
if agent == nil {
|
||
|
|
return ""
|
||
|
|
}
|
||
|
|
// if !config.GetBase().Release {
|
||
|
|
// ip = "3.110.154.202"
|
||
|
|
// }
|
||
|
|
platForm := 1
|
||
|
|
if common.IsPC(s.Base.EnterGameReq.DeviceType) {
|
||
|
|
platForm = 0
|
||
|
|
}
|
||
|
|
req := &EnterGameReq{
|
||
|
|
OperatorCode: agent.OperatorCode,
|
||
|
|
MemberName: common.GetProviderUserName(fmt.Sprintf("%d", uid)),
|
||
|
|
// DisplayName: p.Nick,
|
||
|
|
GameID: game.GameCode,
|
||
|
|
// ProviderGameType: ,
|
||
|
|
ProductID: ProductIDMap[providerID],
|
||
|
|
GameType: GameTypeMap[game.GameType],
|
||
|
|
LanguageCode: LangMap[lang],
|
||
|
|
Platform: platForm,
|
||
|
|
IPAddress: ip,
|
||
|
|
// OperatorLobbyURL: ,
|
||
|
|
RequestTime: time.Now().UTC().Format("20060102150405"),
|
||
|
|
}
|
||
|
|
channel := call.GetChannelByID(cid)
|
||
|
|
if channel != nil && channel.URL != "" {
|
||
|
|
req.OperatorLobbyURL = "https://" + channel.URL
|
||
|
|
}
|
||
|
|
req.Sign = util.CalculateMD5(agent.OperatorCode + req.RequestTime + "launchgame" + agent.SecretKey)
|
||
|
|
|
||
|
|
url := API + LaunchGameURL
|
||
|
|
log.Debug("%d EnterGame:%+v,url:%s", providerID, *req, url)
|
||
|
|
ret := new(EnterGameResp)
|
||
|
|
util.HttpPost(url, req, &ret, nil)
|
||
|
|
log.Debug("%d EnterGame resp:%+v", providerID, ret)
|
||
|
|
// if str, ok := ret.Data.(string); ok {
|
||
|
|
// return str
|
||
|
|
// }
|
||
|
|
return util.ReplaceHTTPWithHTTPS(ret.Url)
|
||
|
|
}
|