From 6acb097d4424d58c370b70c2f0029ea3ec41452c Mon Sep 17 00:00:00 2001 From: zhora Date: Fri, 22 Aug 2025 10:56:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/config.go | 19 +++++---- modules/backend/app/response.go | 22 +++++++++-- modules/backend/values/gm.go | 2 + modules/web/handler/pdd.go | 53 +++++++++++++------------- modules/web/handler/recharge.go | 23 +++++++++++ modules/web/routers/routers_balance.go | 1 + modules/web/values/pay.go | 9 +++++ 7 files changed, 91 insertions(+), 38 deletions(-) diff --git a/common/config.go b/common/config.go index a4dd6af..3889bb1 100644 --- a/common/config.go +++ b/common/config.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: @@ -409,14 +412,14 @@ func (c *ConfigBroadcast) TableName() string { type ConfigNotice struct { ID int `gorm:"primarykey"` - Title1 string `gorm:"column:title1;type:varchar(255);comment:标题1" web:"title1"` // 公告标题_1(英语) - Content1 string `gorm:"column:content1;type:varchar(255);comment:正文1" web:"content1"` // 公告内容_1(英语) - Title2 string `gorm:"column:title2;type:varchar(255);comment:标题2" web:"title2"` // 公告标题_2 - Content2 string `gorm:"column:content2;type:varchar(255);comment:正文2" web:"content2"` // 公告内容_2 + Title1 string `gorm:"column:title1;type:varchar(255);comment:标题1" web:"title1"` // 公告标题_1(英语) + Content1 string `gorm:"column:content1;type:varchar(255);comment:正文1" web:"content1"` // 公告内容_1(英语) + Title2 string `gorm:"column:title2;type:varchar(255);comment:标题2" web:"title2"` // 公告标题_2 + Content2 string `gorm:"column:content2;type:varchar(255);comment:正文2" web:"content2"` // 公告内容_2 Type int `gorm:"column:type;type:int(11);comment:公告类型 (1.紧急 2.常规)" web:"type"` // 公告类型 (1.紧急 2.常规) - Open int `gorm:"column:open;type:int(11);comment:是否打开 1打开" web:"open"` // 是否发布 - Method int `gorm:"column:method;type:int(11);comment:发布方式" web:"method"` // 发布方式 - Time int64 `gorm:"column:time;type:int(11);comment:发布时间" web:"time"` // 发布时间 + Open int `gorm:"column:open;type:int(11);comment:是否打开 1打开" web:"open"` // 是否发布 + Method int `gorm:"column:method;type:int(11);comment:发布方式" web:"method"` // 发布方式 + Time int64 `gorm:"column:time;type:int(11);comment:发布时间" web:"time"` // 发布时间 Interval int `gorm:"column:interval;type:int(11);comment:间隔" web:"interval"` PushTimes int `gorm:"column:push_times;type:int(11);comment:推送次数" web:"push_times"` // 推送次数 } @@ -515,7 +518,7 @@ type ConfigTgRobot struct { Type int `gorm:"column:type;type:int(11);default:0;comment:机器人类型" web:"type"` ChannelName string `gorm:"column:channel_name;type:varchar(255);comment:频道名称" web:"channel_name"` // 频道id ChannelType string `gorm:"column:channel_type;type:varchar(255);comment:频道类型" web:"channel_type"` // 频道类型 vip 普通 - Content string `gorm:"column:content;type:text;comment:内容" web:"content"` // 内容 + Content string `gorm:"column:content;type:text;comment:内容" web:"content"` // 内容 ContentType string `gorm:"column:content_type;type:varchar(255);comment:发送类型" web:"content_type"` // 发送类型 Image string `gorm:"column:image;type:longtext;comment:发送类型" web:"image"` // 图片 Time string `gorm:"column:time;type:varchar(255);comment:发送类型" web:"time"` // 时间 diff --git a/modules/backend/app/response.go b/modules/backend/app/response.go index 7579a2c..a958355 100644 --- a/modules/backend/app/response.go +++ b/modules/backend/app/response.go @@ -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 } diff --git a/modules/backend/values/gm.go b/modules/backend/values/gm.go index bcac755..e3e4c84 100644 --- a/modules/backend/values/gm.go +++ b/modules/backend/values/gm.go @@ -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": diff --git a/modules/web/handler/pdd.go b/modules/web/handler/pdd.go index a80cb40..327b46d 100644 --- a/modules/web/handler/pdd.go +++ b/modules/web/handler/pdd.go @@ -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 > 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) } - } - 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 + } 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("%.14f", addAmount) + 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 diff --git a/modules/web/handler/recharge.go b/modules/web/handler/recharge.go index 6859f26..4d03b71 100644 --- a/modules/web/handler/recharge.go +++ b/modules/web/handler/recharge.go @@ -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() { diff --git a/modules/web/routers/routers_balance.go b/modules/web/routers/routers_balance.go index e275c30..2c546ce 100644 --- a/modules/web/routers/routers_balance.go +++ b/modules/web/routers/routers_balance.go @@ -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) diff --git a/modules/web/values/pay.go b/modules/web/values/pay.go index e0cf3ac..22111fd 100644 --- a/modules/web/values/pay.go +++ b/modules/web/values/pay.go @@ -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