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

94 lines
2.2 KiB

package pg2
import (
"encoding/json"
"fmt"
"server/call"
"server/common"
"server/config"
"server/modules/web/providers/base"
utils "server/util"
"strconv"
"time"
"github.com/liangdas/mqant/log"
)
type Sub struct {
Base *base.Base
}
func NewSub(base *base.Base) {
base.Sub = &Sub{Base: base}
base.SubInitRouter = PG
}
func (s *Sub) Init() {
API = APITest
AgentMap = AgentMapTest
if config.GetBase().Release {
API = APIRlease
AgentMap = AgentMapRelease
}
}
func (s *Sub) EnterGame() string {
url := fmt.Sprintf("%s/api/usr/ingame", API)
timestamp := time.Now().Unix()
uid := s.Base.EnterGameReq.UID
token := s.Base.EnterGameReq.Token
providerID := s.Base.EnterGameReq.ProviderID
gameID := s.Base.EnterGameReq.GameID
/**
玩家再次点击游戏,根据玩家盈利倍数(盈利倍数=(玩家余额+已提现金额)/玩家总充值金额),调取假PG不同档位的接口:
1、盈利倍数≤1,进入90%档位
2、盈利倍数1-7,进入80%档位
3、盈利倍数7-10,进入60%档位
4、盈利倍数≥10,进入30%档位
*/
rechargeInfo := call.GetRechargeInfo(uid)
cash := call.GetUserCurrency(uid, common.CurrencyINR)
earnBet := (rechargeInfo.TotalWithdraw + cash) / rechargeInfo.TotalRecharge
log.Info("uid:%d,earnBet:%d", uid, earnBet)
mchid := ""
key := ""
if earnBet <= 7 {
mchid = AgentMap[80].MchId
key = AgentMap[80].Key
} else if earnBet <= 10 {
mchid = AgentMap[60].MchId
key = AgentMap[60].Key
} else {
mchid = AgentMap[30].MchId
key = AgentMap[30].Key
}
headers := map[string]string{
"X-Atgame-Mchid": mchid,
"X-Atgame-Timestamp": strconv.FormatInt(timestamp, 10),
"Content-Type": "application/json;charset=UTF-8",
}
// Generate sign
game := call.GetConfigGameListByID(providerID, gameID)
if game == nil {
return ""
}
request := EnterGameRequest{
Uname: fmt.Sprintf("%d", uid),
GameID: game.GameCode,
Token: token,
Lang: Lang,
Nick: "",
}
body, _ := json.Marshal(request)
sign := GenerateSign(string(body), timestamp, key)
headers["X-Atgame-Sign"] = sign
// Decode response
var response EnterGameResponse
err := utils.HttpPost(url, request, &response, headers)
if err != nil {
log.Error("err:%v", err)
return ""
}
return response.Data.GameURL
}