Compare commits

..

4 Commits
dev ... release

Author SHA1 Message Date
mofangmin ce7bfe83cd pg地址修改 11 months ago
mofangmin f1ca699478 jili转发 1 year ago
mofangmin 0221534569 添加转发逻辑 1 year ago
mofangmin 6d79b3acaf 支付时间调整 1 year ago
  1. 2
      bin/conf/web/conf.toml
  2. 4
      call/redis.go
  3. 2
      cmd/build.sh
  4. 1
      cmd/gener_code.sh
  5. 1
      common/provider.go
  6. 22
      modules/web/handler/game.go
  7. 10
      modules/web/handler/recharge.go
  8. 5
      modules/web/module.go
  9. 3
      modules/web/providers/all/all.go
  10. 18
      modules/web/providers/jili2/api.go
  11. 4
      modules/web/providers/pg2/values.go
  12. 147
      modules/web/providers/pg3/api.go
  13. 84
      modules/web/providers/pg3/base.go
  14. 164
      modules/web/providers/pg3/handler.go
  15. 17
      modules/web/providers/pg3/sign.go
  16. 27
      modules/web/providers/pg3/values.go

@ -1,5 +1,5 @@
[Web] [Web]
Addr=":9615" Addr=":7615"
Release=true Release=true
TLS=false TLS=false
CertFile="" CertFile=""

@ -17,10 +17,10 @@ func AddChannel(channelID int, isSuccess bool) {
// 检查键是否存在,如果不存在则设置过期时间 // 检查键是否存在,如果不存在则设置过期时间
if client.Exists(ctx, totalKey).Val() == 0 { if client.Exists(ctx, totalKey).Val() == 0 {
client.Set(ctx, totalKey, 0, 10*time.Minute) client.Set(ctx, totalKey, 0, 30*time.Minute)
} }
if client.Exists(ctx, successKey).Val() == 0 { if client.Exists(ctx, successKey).Val() == 0 {
client.Set(ctx, successKey, 0, 10*time.Minute) client.Set(ctx, successKey, 0, 30*time.Minute)
} }
// 增加总订单数 // 增加总订单数

@ -8,5 +8,5 @@ cd pb/proto
# go generate # go generate
cd ../.. cd ../..
#go build main.go #go build main.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o indiaprovider main.go && upx -9 indiaprovider CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o indiaprovider main.go
#CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o gameserver main.go #CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o gameserver main.go

@ -27,7 +27,6 @@ func Load$input_value() (err error) {
} }
return nil return nil
} }
func GetConfig$input_value() []*common.Config$input_value { func GetConfig$input_value() []*common.Config$input_value {
return config$input_value return config$input_value
} }

@ -37,7 +37,6 @@ const (
ProviderSBO ProviderSBO
ProviderPG2 ProviderPG2
ProviderJiLi2 ProviderJiLi2
ProviderPG3
ProviderAll ProviderAll
) )

@ -98,19 +98,23 @@ func EnterGame(c *gin.Context) {
} }
a.Data = resp a.Data = resp
// step:特殊逻辑处理 // step:特殊逻辑处理
providerId := 0
if req.Provider == common.ProviderPGSoft { if req.Provider == common.ProviderPGSoft {
provider = call.GetConfigGameProvider(common.ProviderPG3) providerId = common.ProviderPG2
game := call.GetConfigGameListByID(common.ProviderPG3, req.GameID) }
if req.Provider == common.ProviderJili {
providerId = common.ProviderJiLi2
}
if providerId > 0 {
provider = call.GetConfigGameProvider(providerId)
game := call.GetConfigGameListByID(providerId, req.GameID)
if game != nil && game.Open == 1 { if game != nil && game.Open == 1 {
req.Provider = common.ProviderPG3 req.Provider = providerId
resp.Method = provider.Method resp.Method = provider.Method
} else { } else {
provider = call.GetConfigGameProvider(common.ProviderPG2) a.Code = values.CodeParam
game = call.GetConfigGameListByID(common.ProviderPG2, req.GameID) a.Msg = "Under Maintenance,please try later."
if game != nil && game.Open == 1 { return
req.Provider = common.ProviderPG2
resp.Method = provider.Method
}
} }
} }

@ -216,11 +216,11 @@ func PlayerRecharge(c *gin.Context) {
} }
}) })
if !config.GetBase().Release { // if !config.GetBase().Release && req.PayChannel == config.GetConfig().Web.TestPay {
util.Go(func() { // util.Go(func() {
call.RechargeCallback(payImp.Order, true, "", "") // call.RechargeCallback(payImp.Order, true, "", "")
}) // })
} // }
} }
func NewRechargeImp(req *values.RechargeReq, uid, cid int, ip string) *RechargeImp { func NewRechargeImp(req *values.RechargeReq, uid, cid int, ip string) *RechargeImp {

@ -10,7 +10,6 @@ import (
edb "server/db/es" edb "server/db/es"
mdb "server/db/mysql" mdb "server/db/mysql"
rdb "server/db/redis" rdb "server/db/redis"
"server/modules/web/providers/jili2"
"server/modules/web/routers" "server/modules/web/routers"
"server/util" "server/util"
"time" "time"
@ -53,7 +52,7 @@ func (w *Web) OnInit(app module.App, settings *conf.ModuleSettings) {
// 自动初始化数据库 // 自动初始化数据库
// MigrateDB() // MigrateDB()
call.NewCaller(w) call.NewCaller(w)
jili2.GetGameList()
call.NewSnowflake(int64(config.GetConfig().WorkID)) call.NewSnowflake(int64(config.GetConfig().WorkID))
// 创建一个随机数生成器 // 创建一个随机数生成器
@ -73,7 +72,7 @@ func (w *Web) OnInit(app module.App, settings *conf.ModuleSettings) {
// 拉取缓存数据 // 拉取缓存数据
util.Go(func() { util.Go(func() {
// FetchDatas() FetchDatas()
}) })
} }

@ -9,7 +9,6 @@ import (
"server/modules/web/providers/gs" "server/modules/web/providers/gs"
"server/modules/web/providers/jili2" "server/modules/web/providers/jili2"
"server/modules/web/providers/pg2" "server/modules/web/providers/pg2"
"server/modules/web/providers/pg3"
"server/modules/web/providers/pgsoft" "server/modules/web/providers/pgsoft"
"server/modules/web/providers/tada" "server/modules/web/providers/tada"
@ -52,7 +51,6 @@ type AllProvider struct {
SBO func(b *base.Base) SBO func(b *base.Base)
PG2 func(b *base.Base) PG2 func(b *base.Base)
Jili2 func(b *base.Base) Jili2 func(b *base.Base)
PG3 func(b *base.Base)
} }
var All = &AllProvider{} var All = &AllProvider{}
@ -95,7 +93,6 @@ func initAll() {
All.SBO = gs.NewSub All.SBO = gs.NewSub
All.PG2 = pg2.NewSub All.PG2 = pg2.NewSub
All.Jili2 = jili2.NewSub All.Jili2 = jili2.NewSub
All.PG3 = pg3.NewSub
} }
func InitRouter(r *gin.RouterGroup) { func InitRouter(r *gin.RouterGroup) {

@ -6,7 +6,6 @@ import (
"server/db" "server/db"
"server/util" "server/util"
"strconv" "strconv"
"strings"
"time" "time"
) )
@ -134,16 +133,13 @@ func GetGameList() {
var gameList []*common.ConfigGameList var gameList []*common.ConfigGameList
for _, item := range response.Data.GameList { for _, item := range response.Data.GameList {
id, _ := strconv.Atoi(item.MapID) id, _ := strconv.Atoi(item.MapID)
if strings.Contains(item.GameID, "jili") { gameList = append(gameList, &common.ConfigGameList{
gameList = append(gameList, &common.ConfigGameList{ GameProvider: common.ProviderJiLi2,
GameProvider: common.ProviderJiLi2, GameID: id,
GameID: id, GameCode: item.GameID,
GameCode: item.GameID, Icon: item.Icon,
Icon: item.Icon, Name: item.Name,
Name: item.Name, })
})
}
} }
db.Mysql().Create(gameList) db.Mysql().Create(gameList)
} }

@ -21,7 +21,7 @@ var (
"E3D1A83FA82F04D9725ACB5A77578A65", "E3D1A83FA82F04D9725ACB5A77578A65",
} }
AgentMapRelease = Agent{ AgentMapRelease = Agent{
"10025", "10050",
"E21B1CFF68CD984C6ADB25554BAF16C3", "BA7600F238327FB6B70FA91611D60378",
} }
) )

@ -1,147 +0,0 @@
package pg3
import (
"fmt"
"server/common"
"server/db"
"server/util"
"strconv"
"time"
)
const (
ErrCodeSuccess = 0
ErrCodePlayerNotFound = 2000 // 玩家不存在
ErrCodePlayerToken = 2001 // Token错误
ErrCodeInvalidGameID = 102 // 无效的GameDI
ErrCodeInternalError = 3000 // 内部错误
ErrCodeInsufficientBal = 2010 // 投注失败,如余额不足
)
type GameListResponse struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data GameListData `json:"data"`
}
type GameListData struct {
GameList []GameListItem `json:"glist"`
}
type GameListItem struct {
Icon string `json:"icon"`
MapID string `json:"mapid"`
Name string `json:"name"`
Site string `json:"site"`
GameID string `json:"gameid"`
}
// EnterGameRequest 进入游戏
type EnterGameRequest struct {
Uname string `json:"uname"` // 用户名,最长30个字节
GameID string `json:"gameid"` // 所进游戏的编码
Token string `json:"token,omitempty"` // 用户验证token,最长120个字节,用于单一钱包的身份验证接口
Lang string `json:"lang,omitempty"` // 游戏语言,默认为en
Nick string `json:"nick,omitempty"` // 用户昵称,最长40个字节
TotalRecharge int64 `json:"totalRecharge"` // 总充值
TotalBet int64 `json:"totalBet"` // 总下注
Balance int64 `json:"balance"` // 金额
TotalWithdraw int64 `json:"totalWithdraw"` // 总提现(已提现+提现打款中+玩家审核)
}
type EnterGameResponse struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data struct {
GameURL string `json:"gameurl"`
} `json:"data"`
}
// PlaceBetRequest 下注
type PlaceBetRequest struct {
Uname string `json:"uname"`
Token string `json:"token"`
BetID string `json:"betid"`
SessionID string `json:"sessionid"`
GameID string `json:"gameid"`
Bet float64 `json:"bet"`
Award float64 `json:"award"`
IsEndRound bool `json:"is_end_round"`
Ctime int64 `json:"ctime"`
}
type PlaceBetResponse struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data struct {
Uname string `json:"uname"`
BetID string `json:"betid"`
Balance float64 `json:"balance"`
} `json:"data"`
}
type VerifySessionReq struct {
Uname string `json:"uname"`
Token string `json:"token"`
}
type VerifySessionResp struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data struct {
Uname string `json:"uname"`
Balance float64 `json:"balance"`
} `json:"data"`
}
type GetBalanceRequest struct {
GameId string `json:"gameid"`
Uname string `json:"uname"`
}
type GetBalanceResponse struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data struct {
Uname string `json:"uname"`
Balance float64 `json:"balance"`
} `json:"data"`
}
func GetGameList() {
API = APITest
AgentMap = AgentMapTest
url := fmt.Sprintf("%s/api/game/loadlist", APITest)
mchid := AgentMap.MchId
key := AgentMap.Key
timestamp := time.Now().Unix()
headers := map[string]string{
"X-Game-Mchid": mchid,
"X-Game-Timestamp": strconv.FormatInt(timestamp, 10),
"Content-Type": "application/json;charset=UTF-8",
}
type empty struct{}
var e empty
// Generate sign
emptyBody := "{}"
sign := GenerateSign(emptyBody, timestamp, key)
headers["X-Game-Sign"] = sign
var response GameListResponse
err := util.HttpPost(url, e, &response, headers)
if err != nil {
return
}
var gameList []*common.ConfigGameList
for _, item := range response.Data.GameList {
id, _ := strconv.Atoi(item.MapID)
gameList = append(gameList, &common.ConfigGameList{
GameProvider: common.ProviderPG2,
GameID: id,
GameCode: item.GameID,
Icon: item.Icon,
Name: item.Name,
})
}
db.Mysql().Create(gameList)
}

@ -1,84 +0,0 @@
package pg3
import (
"encoding/json"
"fmt"
"server/call"
"server/common"
"server/config"
"server/db"
"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
mchid := AgentMap.MchId
key := AgentMap.Key
rtp := call.GetRtpControl(uid)
log.Info("uid:%v,rtp:%v", uid, rtp)
db.Redis().SetData(common.GetRedisKeyPlayerRtp(uid), rtp)
headers := map[string]string{
"X-Game-Mchid": mchid,
"X-Game-Timestamp": strconv.FormatInt(timestamp, 10),
"Content-Type": "application/json;charset=UTF-8",
}
rechargeInfo := call.GetRechargeInfo(uid)
balance := call.GetUserCurrency(uid, common.CurrencyINR)
playerProfile := call.GetPlayerProfileByCurrency(uid, common.CurrencyINR)
// Generate sign
game := call.GetConfigGameListByID(providerID, gameID)
if game == nil {
return ""
}
request := EnterGameRequest{
Uname: common.GetProviderUserName(fmt.Sprintf("%d", uid)),
GameID: game.GameCode,
Token: common.GetProviderUserToken(token),
Lang: "pt",
Nick: "",
TotalRecharge: rechargeInfo.TotalRecharge / common.DecimalDigits,
TotalWithdraw: (rechargeInfo.TotalWithdraw + rechargeInfo.TotalWithdrawing) / common.DecimalDigits,
TotalBet: playerProfile.TotalBet / common.DecimalDigits,
Balance: balance / common.DecimalDigits,
}
body, _ := json.Marshal(request)
sign := GenerateSign(string(body), timestamp, key)
headers["X-Game-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
}

@ -1,164 +0,0 @@
package pg3
import (
"server/call"
"server/common"
"server/db"
"server/modules/web/app"
"server/modules/web/providers/base"
"server/util"
"strconv"
"time"
"github.com/gin-gonic/gin"
"github.com/liangdas/mqant/log"
)
func PG(e *gin.RouterGroup) {
e.POST("/VerifySession", VerifySession)
e.POST("/Cash/Get", GetPlayerBalance)
e.POST("/Cash/Bet", PlaceBet)
}
func GetGameID(providerID int, gameCode string) int {
game := call.GetConfigGameListByCode(providerID, gameCode)
if game != nil {
return game.GameID
}
return 0
}
func VerifySession(c *gin.Context) {
a := app.NewApp(c)
defer func() {
a.ResponseB()
}()
req := &VerifySessionReq{}
resp := &VerifySessionResp{}
a.RetData = resp
if !a.SB(req) {
resp.Code = ErrCodeInternalError
return
}
log.Debug("VerifySession req:%+v", req)
if a.ShouldRoute(req, "Uname", common.ProviderAPITypeJson) {
return
}
uid, err := strconv.Atoi(req.Uname)
if err != nil {
log.Error("err:%v", err)
resp.Code = ErrCodePlayerNotFound
return
}
currency, err := db.Redis().GetInt(common.GetRedisKeyGameCurrency(uid))
if err != nil {
log.Error("err:%v", err)
resp.Code = ErrCodeInternalError
return
}
resp.Data.Balance = call.GetUserCurrencyFloat(uid, common.CurrencyType(currency), 2)
a.Data = resp
}
func GetPlayerBalance(c *gin.Context) {
a := app.NewApp(c)
defer func() {
a.ResponseB()
}()
req := &GetBalanceRequest{}
resp := &GetBalanceResponse{}
a.RetData = resp
if !a.SB(req) {
resp.Code = ErrCodeInternalError
return
}
log.Debug("GetPlayerBalance req:%+v", req)
if a.ShouldRoute(req, "Uname", common.ProviderAPITypeJson) {
return
}
uid, err := strconv.Atoi(req.Uname)
if err != nil {
log.Error("err:%v", err)
resp.Code = ErrCodePlayerNotFound
return
}
currency, err := db.Redis().GetInt(common.GetRedisKeyGameCurrency(uid))
if err != nil {
log.Error("err:%v", err)
resp.Code = ErrCodeInternalError
return
}
resp.Data.Uname = req.Uname
resp.Data.Balance = call.GetUserCurrencyFloat(uid, common.CurrencyType(currency), 2)
a.Data = resp
log.Debug("GetPlayerBalance resp:%+v", resp)
}
func PlaceBet(c *gin.Context) {
a := app.NewApp(c)
defer func() {
a.ResponseB()
}()
req := &PlaceBetRequest{}
resp := &PlaceBetResponse{}
a.RetData = resp
if !a.SB(req) {
resp.Code = ErrCodeInternalError
return
}
log.Debug("PlaceBet:%+v", req)
if a.ShouldRoute(req, "Token", common.ProviderAPITypeJson) {
return
}
// 验证token
uid, _ := db.Redis().GetInt(common.GetRedisKeyToken(req.Token))
if uid == 0 {
resp.Code = ErrCodePlayerNotFound
return
}
provider := call.GetConfigGameProvider(common.ProviderPG2)
now := time.Now().Unix()
if req.Bet != 0 || req.Award != 0 {
betReq := &base.BetReq{
UID: uid,
CurrencyType: common.CurrencyINR,
BetAmount: int64(req.Bet * common.DecimalDigits),
TurnOver: int64(req.Bet * common.DecimalDigits),
SettleAmount: int64(req.Award * common.DecimalDigits),
SessionType: common.SessionTypeSettle,
GameID: GetGameID(common.ProviderPG2, req.GameID),
GameName: req.GameID,
Provider: provider,
BetID: req.BetID,
SessionID: req.SessionID,
Time: now,
}
betResp := base.SessionBet(betReq)
if betResp.Code != base.CodeOk {
resp.Code = ErrCodeInternalError
if betResp.Code == base.CodeAccepted {
resp.Code = ErrCodeInternalError
} else if betResp.Code == base.CodeNotEnoughAmount {
resp.Code = ErrCodeInsufficientBal
}
return
}
resp.Data.Balance = util.Decimal(float64(betResp.Balance)/common.DecimalDigits, 2)
} else {
resp.Data.Balance = util.Decimal(float64(call.GetUserCurrency(uid, common.CurrencyINR))/common.DecimalDigits, 2)
}
a.Data = resp
}

@ -1,17 +0,0 @@
package pg3
import (
"crypto/md5"
"encoding/hex"
"strconv"
"strings"
"github.com/liangdas/mqant/log"
)
func GenerateSign(body string, timestamp int64, key string) string {
data := body + strconv.FormatInt(timestamp, 10) + key
log.Info("data:%v", data)
hash := md5.Sum([]byte(data))
return strings.ToUpper(hex.EncodeToString(hash[:]))
}

@ -1,27 +0,0 @@
package pg3
const (
APIRlease = "https://pggame.ux7k.com"
APITest = "https://pggame.1iibet.com"
LaunchGameURL = "/api/usr/ingame"
GetGameListURL = "/api/game/loadlist"
Lang = "en"
)
type Agent struct {
MchId string `json:"mch_id"`
Key string `json:"key"`
}
var (
API = ""
AgentMap Agent
AgentMapTest = Agent{
"10025",
"12DD45A2758A9AEA0224DB8B7F8A36E3",
}
AgentMapRelease = Agent{
"10001",
"E21B1CFF68CD984C6ADB25554BAF16C3",
}
)
Loading…
Cancel
Save