|
|
|
@ -40,7 +40,8 @@ func GetBalance(c *gin.Context) { |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
log.Debug("sn get balance:%s", string(body)) |
|
|
|
account := c.GetHeader("account") |
|
|
|
|
|
|
|
log.Debug("sn get balance, %s:%s", account, string(body)) |
|
|
|
err = json.Unmarshal(body, &req) |
|
|
|
err = json.Unmarshal(body, &req) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Error("unmarshal err, %s", err.Error()) |
|
|
|
log.Error("unmarshal err, %s", err.Error()) |
|
|
|
@ -48,7 +49,6 @@ func GetBalance(c *gin.Context) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
account := c.GetHeader("account") |
|
|
|
|
|
|
|
headers := make(map[string]string) |
|
|
|
headers := make(map[string]string) |
|
|
|
for key, values := range c.Request.Header { |
|
|
|
for key, values := range c.Request.Header { |
|
|
|
if len(values) > 0 { |
|
|
|
if len(values) > 0 { |
|
|
|
@ -61,7 +61,7 @@ func GetBalance(c *gin.Context) { |
|
|
|
newBody, _ := json.Marshal(req) |
|
|
|
newBody, _ := json.Marshal(req) |
|
|
|
var tmpValue map[string]interface{} |
|
|
|
var tmpValue map[string]interface{} |
|
|
|
json.Unmarshal(newBody, &tmpValue) |
|
|
|
json.Unmarshal(newBody, &tmpValue) |
|
|
|
tmpSign := GeneratedSign(tmpValue, SignKey) |
|
|
|
tmpSign := GeneratedSign(tmpValue, WalletKey) |
|
|
|
if tmpSign != req.Sign { |
|
|
|
if tmpSign != req.Sign { |
|
|
|
log.Error("sign is wrong, %+v", req) |
|
|
|
log.Error("sign is wrong, %+v", req) |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
@ -84,7 +84,7 @@ func GetBalance(c *gin.Context) { |
|
|
|
|
|
|
|
|
|
|
|
resp.Msg = "success" |
|
|
|
resp.Msg = "success" |
|
|
|
resp.Data.Chips = int(call.GetUserCurrencyFloat(uid, common.CurrencyType(currency), 0) * common.DecimalDigits) |
|
|
|
resp.Data.Chips = int(call.GetUserCurrencyFloat(uid, common.CurrencyType(currency), 0) * common.DecimalDigits) |
|
|
|
log.Debug("GetBalanceResp:%+v", resp) |
|
|
|
log.Debug("sn getBalanceResp, %s:%+v", account, resp) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func GameBet(c *gin.Context) { |
|
|
|
func GameBet(c *gin.Context) { |
|
|
|
@ -101,14 +101,14 @@ func GameBet(c *gin.Context) { |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
log.Debug("sn game bet:%s", string(body)) |
|
|
|
account := c.GetHeader("account") |
|
|
|
|
|
|
|
log.Debug("sn game bet, %s:%s", account, string(body)) |
|
|
|
err = json.Unmarshal(body, &req) |
|
|
|
err = json.Unmarshal(body, &req) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Error("unmarshal err, %s", err.Error()) |
|
|
|
log.Error("unmarshal err, %s", err.Error()) |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
account := c.GetHeader("account") |
|
|
|
|
|
|
|
headers := make(map[string]string) |
|
|
|
headers := make(map[string]string) |
|
|
|
for key, values := range c.Request.Header { |
|
|
|
for key, values := range c.Request.Header { |
|
|
|
if len(values) > 0 { |
|
|
|
if len(values) > 0 { |
|
|
|
@ -126,7 +126,7 @@ func GameBet(c *gin.Context) { |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
tmpSign := GeneratedSign(tmpValue, SignKey) |
|
|
|
tmpSign := GeneratedSign(tmpValue, WalletKey) |
|
|
|
if tmpSign != req.Sign { |
|
|
|
if tmpSign != req.Sign { |
|
|
|
log.Error("sign is wrong, %+v", req) |
|
|
|
log.Error("sign is wrong, %+v", req) |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
@ -158,8 +158,8 @@ func GameBet(c *gin.Context) { |
|
|
|
GameID: req.GameId, |
|
|
|
GameID: req.GameId, |
|
|
|
GameName: configGame.GameCode, |
|
|
|
GameName: configGame.GameCode, |
|
|
|
Provider: provider, |
|
|
|
Provider: provider, |
|
|
|
BetID: req.BetId, |
|
|
|
BetID: req.OrderId, |
|
|
|
SessionID: req.OrderId, |
|
|
|
SessionID: req.BetId, |
|
|
|
Time: now, |
|
|
|
Time: now, |
|
|
|
BetAmount: int64(betAmount), |
|
|
|
BetAmount: int64(betAmount), |
|
|
|
TurnOver: int64(betAmount), |
|
|
|
TurnOver: int64(betAmount), |
|
|
|
@ -180,7 +180,7 @@ func GameBet(c *gin.Context) { |
|
|
|
resp.Data.DeductionAmount = betAmount |
|
|
|
resp.Data.DeductionAmount = betAmount |
|
|
|
resp.Data.Chips = int(call.GetUserCurrencyFloat(uid, common.CurrencyType(0), 0) * common.DecimalDigits) |
|
|
|
resp.Data.Chips = int(call.GetUserCurrencyFloat(uid, common.CurrencyType(0), 0) * common.DecimalDigits) |
|
|
|
resp.Msg = "success" |
|
|
|
resp.Msg = "success" |
|
|
|
log.Debug("GameBetResp:%+v", resp) |
|
|
|
log.Debug("sn gameBetResp, %s:%+v", account, resp) |
|
|
|
a.Data = resp |
|
|
|
a.Data = resp |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -198,14 +198,14 @@ func Settle(c *gin.Context) { |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
log.Debug("sn settle:%s", string(body)) |
|
|
|
account := c.GetHeader("account") |
|
|
|
|
|
|
|
log.Debug("sn settle, %s:%s", account, string(body)) |
|
|
|
err = json.Unmarshal(body, &req) |
|
|
|
err = json.Unmarshal(body, &req) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Error("unmarshal err, %s", err.Error()) |
|
|
|
log.Error("unmarshal err, %s", err.Error()) |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
account := c.GetHeader("account") |
|
|
|
|
|
|
|
headers := make(map[string]string) |
|
|
|
headers := make(map[string]string) |
|
|
|
for key, values := range c.Request.Header { |
|
|
|
for key, values := range c.Request.Header { |
|
|
|
if len(values) > 0 { |
|
|
|
if len(values) > 0 { |
|
|
|
@ -222,7 +222,7 @@ func Settle(c *gin.Context) { |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
tmpSign := GeneratedSign(tmpValue, SignKey) |
|
|
|
tmpSign := GeneratedSign(tmpValue, WalletKey) |
|
|
|
if tmpSign != req.Sign { |
|
|
|
if tmpSign != req.Sign { |
|
|
|
log.Error("sign is wrong, %+v", req) |
|
|
|
log.Error("sign is wrong, %+v", req) |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
@ -236,17 +236,23 @@ func Settle(c *gin.Context) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
provider := call.GetConfigGameProvider(common.ProviderSn) |
|
|
|
provider := call.GetConfigGameProvider(common.ProviderSn) |
|
|
|
{ // 订单是否合法
|
|
|
|
|
|
|
|
|
|
|
|
var betId string |
|
|
|
|
|
|
|
if len(req.Details) > 0 { |
|
|
|
|
|
|
|
betId = req.Details[0].BetId |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
{ // todo 订单是否合法
|
|
|
|
record := &common.ProviderBetRecord{ |
|
|
|
record := &common.ProviderBetRecord{ |
|
|
|
UID: uid, |
|
|
|
UID: uid, |
|
|
|
Provider: provider.ProviderID, |
|
|
|
Provider: provider.ProviderID, |
|
|
|
Type: base.SessionTypeBet, |
|
|
|
Type: base.SessionTypeBet, |
|
|
|
SessionID: req.OrderId, |
|
|
|
SessionID: betId, |
|
|
|
} |
|
|
|
} |
|
|
|
db.Mysql().Get(record) |
|
|
|
db.Mysql().Get(record) |
|
|
|
if record.ID == 0 { |
|
|
|
if record.ID == 0 { |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
resp.Data.Chips = int(call.GetUserCurrencyFloat(uid, common.CurrencyType(0), 0) * common.DecimalDigits) |
|
|
|
resp.Data.Chips = int(call.GetUserCurrencyFloat(uid, common.CurrencyType(0), 0) * common.DecimalDigits) |
|
|
|
|
|
|
|
log.Debug("sn settleResp, %s:%+v", account, resp) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -257,10 +263,7 @@ func Settle(c *gin.Context) { |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
var betId string |
|
|
|
|
|
|
|
if len(req.Details) > 0 { |
|
|
|
|
|
|
|
betId = req.Details[0].BetId |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
settleAmount := int64(req.JpBonus + req.BackAmount) |
|
|
|
settleAmount := int64(req.JpBonus + req.BackAmount) |
|
|
|
betReq := &base.BetReq{ |
|
|
|
betReq := &base.BetReq{ |
|
|
|
UID: uid, |
|
|
|
UID: uid, |
|
|
|
@ -269,13 +272,18 @@ func Settle(c *gin.Context) { |
|
|
|
GameID: req.GameId, |
|
|
|
GameID: req.GameId, |
|
|
|
GameName: configGame.GameCode, |
|
|
|
GameName: configGame.GameCode, |
|
|
|
Provider: provider, |
|
|
|
Provider: provider, |
|
|
|
BetID: betId, |
|
|
|
BetID: req.OrderId, |
|
|
|
SessionID: req.OrderId, |
|
|
|
SessionID: betId, |
|
|
|
Time: now, |
|
|
|
Time: now, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
isFinish := 1 |
|
|
|
for _, detail := range req.Details { |
|
|
|
for _, detail := range req.Details { |
|
|
|
settleAmount += int64(detail.WinAmount) |
|
|
|
settleAmount += int64(detail.WinAmount) |
|
|
|
|
|
|
|
if detail.IsFinish { |
|
|
|
|
|
|
|
isFinish = 2 |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
betReq.IsFinish = isFinish |
|
|
|
betReq.SettleAmount = settleAmount |
|
|
|
betReq.SettleAmount = settleAmount |
|
|
|
betResp := base.SessionBet(betReq) |
|
|
|
betResp := base.SessionBet(betReq) |
|
|
|
if betResp.Code != base.CodeOk { |
|
|
|
if betResp.Code != base.CodeOk { |
|
|
|
@ -287,13 +295,13 @@ func Settle(c *gin.Context) { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
resp.Msg = "operation failed." |
|
|
|
resp.Msg = "operation failed." |
|
|
|
} |
|
|
|
} |
|
|
|
log.Error("GameBetResp err:%v", resp.Code) |
|
|
|
log.Error("sn gameBetResp err, %s:%+v", account, betResp) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
resp.Data.Chips = int(call.GetUserCurrencyFloat(uid, common.CurrencyType(0), 0) * common.DecimalDigits) |
|
|
|
resp.Data.Chips = int(call.GetUserCurrencyFloat(uid, common.CurrencyType(0), 0) * common.DecimalDigits) |
|
|
|
resp.Msg = "success" |
|
|
|
resp.Msg = "success" |
|
|
|
log.Debug("SettleResp:%+v", resp) |
|
|
|
log.Debug("sn settleResp, %s:%+v", account, resp) |
|
|
|
a.Data = resp |
|
|
|
a.Data = resp |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -311,14 +319,14 @@ func Rollback(c *gin.Context) { |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
log.Debug("sn rollback:%s", string(body)) |
|
|
|
account := c.GetHeader("account") |
|
|
|
|
|
|
|
log.Debug("sn rollback, %s:%s", account, string(body)) |
|
|
|
err = json.Unmarshal(body, &req) |
|
|
|
err = json.Unmarshal(body, &req) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Error("unmarshal err, %s", err.Error()) |
|
|
|
log.Error("unmarshal err, %s", err.Error()) |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
account := c.GetHeader("account") |
|
|
|
|
|
|
|
headers := make(map[string]string) |
|
|
|
headers := make(map[string]string) |
|
|
|
for key, values := range c.Request.Header { |
|
|
|
for key, values := range c.Request.Header { |
|
|
|
if len(values) > 0 { |
|
|
|
if len(values) > 0 { |
|
|
|
@ -335,7 +343,7 @@ func Rollback(c *gin.Context) { |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
tmpSign := GeneratedSign(tmpValue, SignKey) |
|
|
|
tmpSign := GeneratedSign(tmpValue, WalletKey) |
|
|
|
if tmpSign != req.Sign { |
|
|
|
if tmpSign != req.Sign { |
|
|
|
log.Error("sign is wrong, %+v", req) |
|
|
|
log.Error("sign is wrong, %+v", req) |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
@ -399,7 +407,7 @@ func Rollback(c *gin.Context) { |
|
|
|
} |
|
|
|
} |
|
|
|
resp.Data.Chips = int(call.GetUserCurrencyFloat(uid, common.CurrencyType(0), 0) * common.DecimalDigits) |
|
|
|
resp.Data.Chips = int(call.GetUserCurrencyFloat(uid, common.CurrencyType(0), 0) * common.DecimalDigits) |
|
|
|
resp.Msg = "success" |
|
|
|
resp.Msg = "success" |
|
|
|
log.Debug("rollback:%+v", resp) |
|
|
|
log.Debug("sn rollback, %s:%+v", account, resp) |
|
|
|
a.Data = resp |
|
|
|
a.Data = resp |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -417,14 +425,14 @@ func Update(c *gin.Context) { |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
log.Debug("sn update:%s", string(body)) |
|
|
|
account := c.GetHeader("account") |
|
|
|
|
|
|
|
log.Debug("sn update, %s:%s", account, string(body)) |
|
|
|
err = json.Unmarshal(body, &req) |
|
|
|
err = json.Unmarshal(body, &req) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Error("unmarshal err, %s", err.Error()) |
|
|
|
log.Error("unmarshal err, %s", err.Error()) |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
account := c.GetHeader("account") |
|
|
|
|
|
|
|
headers := make(map[string]string) |
|
|
|
headers := make(map[string]string) |
|
|
|
for key, values := range c.Request.Header { |
|
|
|
for key, values := range c.Request.Header { |
|
|
|
if len(values) > 0 { |
|
|
|
if len(values) > 0 { |
|
|
|
@ -441,7 +449,7 @@ func Update(c *gin.Context) { |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
tmpSign := GeneratedSign(tmpValue, SignKey) |
|
|
|
tmpSign := GeneratedSign(tmpValue, WalletKey) |
|
|
|
if tmpSign != req.Sign { |
|
|
|
if tmpSign != req.Sign { |
|
|
|
log.Error("sign is wrong, %+v", req) |
|
|
|
log.Error("sign is wrong, %+v", req) |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
@ -529,7 +537,7 @@ func Update(c *gin.Context) { |
|
|
|
} |
|
|
|
} |
|
|
|
resp.Data.Chips = int(call.GetUserCurrencyFloat(uid, common.CurrencyType(0), 0) * common.DecimalDigits) |
|
|
|
resp.Data.Chips = int(call.GetUserCurrencyFloat(uid, common.CurrencyType(0), 0) * common.DecimalDigits) |
|
|
|
resp.Msg = "success" |
|
|
|
resp.Msg = "success" |
|
|
|
log.Debug("rollback:%+v", resp) |
|
|
|
log.Debug("sn rollback, %s:%+v", account, resp) |
|
|
|
a.Data = resp |
|
|
|
a.Data = resp |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -547,14 +555,14 @@ func GameControlCallback(c *gin.Context) { |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
log.Debug("sn gameControlCallback:%s", string(body)) |
|
|
|
account := c.GetHeader("account") |
|
|
|
|
|
|
|
log.Debug("sn gameControlCallback, %s:%s", account, string(body)) |
|
|
|
err = json.Unmarshal(body, &req) |
|
|
|
err = json.Unmarshal(body, &req) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Error("unmarshal err, %s", err.Error()) |
|
|
|
log.Error("unmarshal err, %s", err.Error()) |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
account := c.GetHeader("account") |
|
|
|
|
|
|
|
headers := make(map[string]string) |
|
|
|
headers := make(map[string]string) |
|
|
|
for key, values := range c.Request.Header { |
|
|
|
for key, values := range c.Request.Header { |
|
|
|
if len(values) > 0 { |
|
|
|
if len(values) > 0 { |
|
|
|
@ -571,7 +579,7 @@ func GameControlCallback(c *gin.Context) { |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
tmpSign := GeneratedSign(tmpValue, SignKey) |
|
|
|
tmpSign := GeneratedSign(tmpValue, ControlKey) |
|
|
|
if tmpSign != req.Sign { |
|
|
|
if tmpSign != req.Sign { |
|
|
|
log.Error("sign is wrong, %+v", req) |
|
|
|
log.Error("sign is wrong, %+v", req) |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
resp.Code = INVALIDREQUESTERR |
|
|
|
@ -624,7 +632,7 @@ func Control(uid int, controlId int) error { |
|
|
|
reqBody, _ := json.Marshal(req) |
|
|
|
reqBody, _ := json.Marshal(req) |
|
|
|
var tmpValue map[string]interface{} |
|
|
|
var tmpValue map[string]interface{} |
|
|
|
json.Unmarshal(reqBody, &tmpValue) |
|
|
|
json.Unmarshal(reqBody, &tmpValue) |
|
|
|
req.Sign = GeneratedSign(tmpValue, SignKey) |
|
|
|
req.Sign = GeneratedSign(tmpValue, ApiKey) |
|
|
|
|
|
|
|
|
|
|
|
var resp ControlResp |
|
|
|
var resp ControlResp |
|
|
|
err := util.HttpPost(APIControl, req, &resp, nil) |
|
|
|
err := util.HttpPost(APIControl, req, &resp, nil) |
|
|
|
|