补充接口

dev_aagame_provider
zhora 3 months ago
parent 196abed4dc
commit 6acb097d44
  1. 3
      common/config.go
  2. 22
      modules/backend/app/response.go
  3. 2
      modules/backend/values/gm.go
  4. 59
      modules/web/handler/pdd.go
  5. 23
      modules/web/handler/recharge.go
  6. 1
      modules/web/routers/routers_balance.go
  7. 9
      modules/web/values/pay.go

@ -65,6 +65,7 @@ const (
ReloadConfigShowGameTag
ReloadConfigPopUp
ReloadConfigPdd
ReloadConfigLuckyCodeList
ReloadConfigLuckyWheel
)
@ -131,6 +132,8 @@ func GetConfigStructByType(t int) (interface{}, interface{}) {
return &ConfigActivityFirstRechargeBack{}, &[]ConfigActivityFirstRechargeBack{}
case ReloadConfigLuckyCode:
return &ConfigActivityLuckyCode{}, &[]ConfigActivityLuckyCode{}
case ReloadConfigLuckyCodeList:
return &ActivityLuckyCode{}, &[]ActivityLuckyCode{}
case ReloadConfigBanner:
return &ConfigBanner{}, &[]ConfigBanner{}
case ReloadConfigActivitySign:

@ -8,6 +8,7 @@ import (
"server/db"
"server/modules/backend/bdb"
"server/modules/backend/values"
"strings"
"time"
"github.com/gin-gonic/gin"
@ -41,11 +42,18 @@ func NewApp(c *gin.Context) *Gin {
// Response setting gin.JSON
func (g *Gin) Response() {
var msgBak string
if strings.ToLower(g.Msg) != "ok" {
msgBak = g.Msg
}
if g.Code == values.CodeRetry {
g.Msg = "内部错误"
} else if g.Code == values.CodePower {
g.Msg = "您无权操作此项"
}
if msgBak != "" {
g.Msg += fmt.Sprintf(",%s", msgBak)
}
g.C.JSON(http.StatusOK, g.R)
}
@ -108,11 +116,19 @@ func (g *Gin) MGetAll(model, tar interface{}) (pass bool) {
}
func (g *Gin) MUpdateAll(updates []map[string]interface{}, element interface{}) (pass bool) {
var err error
defer func() {
if err != nil {
if strings.Contains(err.Error(), "Duplicate") {
g.Msg = "重复数据"
}
}
}()
for _, v := range updates {
tmp := reflect.New(reflect.TypeOf(element).Elem()).Interface()
// log.Debug("%v", v)
tmpbyte, _ := json.Marshal(v)
err := json.Unmarshal(tmpbyte, &tmp)
err = json.Unmarshal(tmpbyte, &tmp)
if err != nil {
log.Error("err%v", err)
return
@ -124,7 +140,7 @@ func (g *Gin) MUpdateAll(updates []map[string]interface{}, element interface{})
reft := reflect.TypeOf(tmp).Elem()
id := reflect.ValueOf(tmp).Elem().FieldByName("ID").Int()
if id == 0 {
if err := db.Mysql().Create(tmp); err != nil {
if err = db.Mysql().Create(tmp); err != nil {
g.Code = values.CodeRetry
return
}
@ -147,7 +163,7 @@ func (g *Gin) MUpdateAll(updates []map[string]interface{}, element interface{})
// log.Debug("element:%v", element)
log.Debug("update:%v", update)
// log.Debug("model:%v", model)
if err := db.Mysql().Update(model.Interface(), update); err != nil {
if err = db.Mysql().Update(model.Interface(), update); err != nil {
g.Code = values.CodeRetry
return
}

@ -128,6 +128,8 @@ func GetControlType(path string) int {
return common.ReloadConfigActivityFirstRechargeBack
case "luckCode":
return common.ReloadConfigLuckyCode
case "luckCodeList":
return common.ReloadConfigLuckyCodeList
case "banner":
return common.ReloadConfigBanner
case "sign":

@ -5,6 +5,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/liangdas/mqant/log"
"gorm.io/gorm"
"math"
"math/rand"
"server/call"
"server/common"
@ -67,7 +68,7 @@ func PddCfg(c *gin.Context) {
case 2:
realValue = float64(rand.Intn(pdd.WithdrawalAmount*30) + pdd.WithdrawalAmount*60)
case 3:
realValue = float64(rand.Intn(pdd.WithdrawalAmount*3) + pdd.WithdrawalAmount*95)
realValue = float64(rand.Intn(pdd.WithdrawalAmount*4) + pdd.WithdrawalAmount*95)
}
resp.InitialAmount[index] = fmt.Sprintf("%.2f", realValue/100)
if index == 3 {
@ -175,37 +176,35 @@ func PddLottery(c *gin.Context) {
amountFinal = fmt.Sprintf("%d", pdd.WithdrawalAmount)
updateValues["amount"] = amountFinal
} else {
// todo 更改规则
randValue := rand.Intn(10)
var addAmount float64
if randValue < 4 { // 加剩余金额的1/5
addAmount = lessAmount / 5
} else if randValue < 6 { // 加剩余金额的1/4
addAmount = lessAmount / 4
} else { // 加剩余金额的1/2
addAmount = lessAmount / 2
}
if lessAmount <= 1 {
if randValue < 8 { // 加剩余金额的1/6
addAmount = lessAmount * 5 / 100
} else if randValue < 9 { // 加剩余金额的1/4
addAmount = lessAmount * 10 / 100
} else { // 加剩余金额的1/2
addAmount = lessAmount * 25 / 100
}
}
if lessAmount <= 0.1 {
if randValue < 8 { // 加剩余金额的1/6
addAmount = lessAmount * 1 / 1000
} else if randValue < 9 { // 加剩余金额的1/4
addAmount = lessAmount * 2 / 1000
} else { // 加剩余金额的1/2
addAmount = lessAmount * 4 / 1000
}
}
award = fmt.Sprintf("%.14f", addAmount)
if lessAmount > 1 {
addAmountMax := lessAmount - 1
if addAmountMax <= 0.01 {
addAmount = 0.01
} else {
maxCents := int(math.Round(addAmountMax * 100))
if maxCents <= 0 {
maxCents = 1 // 确保至少为1分钱
}
randValue := rand.Intn(maxCents) + 1
addAmount = float64(randValue) / float64(100)
}
} else { // 0.03
randValue := rand.Intn(10)
if randValue < 7 { // 70%给0.01
addAmount = 0.01
} else if randValue < 9 { // 20%给0.02
addAmount = 0.02
} else { // 10%给0.03
addAmount = 0.03
}
}
award = fmt.Sprintf("%.2f", addAmount)
userAmount += addAmount
amountFinal = fmt.Sprintf("%v", userAmount)
if userAmount > float64(pdd.WithdrawalAmount) {
userAmount = float64(pdd.WithdrawalAmount)
}
amountFinal = fmt.Sprintf("%.2f", userAmount)
updateValues["amount"] = amountFinal
}
err = db.Mysql().C().Model(&common.PddDataNew{}).Where("id = ?", pddData.ID).Updates(updateValues).Error

@ -36,6 +36,29 @@ func CheckRechargeOrder(c *gin.Context) {
// log.Debug("resp:%+v", resp)
}
func RechargeInfoFirst(c *gin.Context) {
a := app.NewApp(c)
defer func() {
a.Response()
}()
resp := &values.RechargeInfoFirstResp{}
a.Data = resp
a.GetUID()
resp.List = make([]values.PayInfo, 0, len(call.GetConfigFirstPay()))
rechargeInfo := call.GetRechargeInfo(a.UID)
for _, v := range call.GetConfigFirstPay() {
var bonus int64
per, _ := call.GetConfigFirstPayByCount(v.Amount, rechargeInfo.BuyAmountDataMap[v.Amount])
if per > 0 {
bonus = v.Amount * per / 100
}
resp.List = append(resp.List, values.PayInfo{
Amount: v.Amount,
Bonus: bonus,
})
}
}
func RechargeInfo(c *gin.Context) {
a := app.NewApp(c)
defer func() {

@ -8,6 +8,7 @@ import (
func balance(e *gin.RouterGroup) {
e.POST("/balance/recharge/order", handler.CheckRechargeOrder)
e.POST("/balance/recharge/info/first", handler.RechargeInfoFirst)
e.POST("/balance/recharge/info", handler.RechargeInfo)
e.POST("/balance/recharge/do", handler.PlayerRecharge)
e.POST("/balance/recharge/history", handler.RechargeHistory)

@ -28,6 +28,15 @@ type RechargeInfoResp struct {
DiscountTicket []*DiscountTicket
}
type PayInfo struct {
Amount int64 `json:"amount"`
Bonus int64 `json:"bonus"`
}
type RechargeInfoFirstResp struct {
List []PayInfo `json:"list"`
}
type DiscountTicket struct {
Id int
Discount int64

Loading…
Cancel
Save