From 547bc9a02ef4b08fb9dc9f1916d4183a87ac6b8f Mon Sep 17 00:00:00 2001 From: mofangmin Date: Tue, 20 Aug 2024 15:35:47 +0800 Subject: [PATCH 01/14] =?UTF-8?q?=E9=A6=96=E5=85=85=E8=BF=94=E8=BF=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- call/pay.go | 3 -- common/activity.go | 2 +- modules/common/nats.go | 4 +- modules/web/handler/activity.go | 69 +++++++++++++++---------- modules/web/routers/routers_activity.go | 5 +- modules/web/values/activity.go | 5 ++ 6 files changed, 54 insertions(+), 34 deletions(-) diff --git a/call/pay.go b/call/pay.go index 5327fb5..8c5d969 100644 --- a/call/pay.go +++ b/call/pay.go @@ -530,13 +530,10 @@ func PayActivity(r *common.RechargeOrder, notCharge bool, user *common.PlayerDBI } func ActivityFirstRechargeBack(r *common.RechargeOrder) { - now := time.Now().Unix() if IsActivityValid(common.ActivityIDFirstRechargeBack) { rechargeBackData := GetUserFirstRechargeBackData(r.UID) if rechargeBackData.RechargeTime == 0 { db.Mysql().Create(&common.ActivityFirstRechargeBackData{UID: r.UID, RechargeTime: time.Now().Unix(), Amount: r.Amount}) - } else if now-rechargeBackData.RechargeTime < common.ActivityFirstRechargeBackTime { - db.Mysql().Update(&common.ActivityFirstRechargeBackData{UID: r.UID}, map[string]interface{}{"amount": gorm.Expr("amount + ?", r.Amount)}) } } } diff --git a/common/activity.go b/common/activity.go index 9c6ee7e..e0e0c0b 100644 --- a/common/activity.go +++ b/common/activity.go @@ -198,7 +198,7 @@ const ( type ConfigActivityFirstRechargeBack struct { ID int `gorm:"primary_key;AUTO_INCREMENT;column:id" json:"ID"` MinRecharge int64 `gorm:"column:min_recharge;type:bigint(20);default:10000000000;comment:最低充值额度" web:"min_recharge"` - MaxBack int64 `gorm:"column:max_back;type:bigint(20);default:-1;comment:最大返还额度" web:"max_back"` + MaxBack int64 `gorm:"column:max_back;type:bigint(20);default:-1;comment:最大返还额度比例" web:"max_back"` } func (c *ConfigActivityFirstRechargeBack) TableName() string { diff --git a/modules/common/nats.go b/modules/common/nats.go index c7c03a9..85387e3 100644 --- a/modules/common/nats.go +++ b/modules/common/nats.go @@ -34,8 +34,8 @@ func afterSettle(d *pb.InnerAfterSettle) { log.Debug("afterSettle:%+v", *d) UpdateGameData(d) call.ShareSettle(d) - p := &Player{uid: int(d.UID), gid: int(d.GameID), settleData: d} - p.ActivityFirstRechargeBack() + // p := &Player{uid: int(d.UID), gid: int(d.GameID), settleData: d} + // p.ActivityFirstRechargeBack() } func UpdateGameData(d *pb.InnerAfterSettle) { diff --git a/modules/web/handler/activity.go b/modules/web/handler/activity.go index 0200d77..16e7916 100644 --- a/modules/web/handler/activity.go +++ b/modules/web/handler/activity.go @@ -667,35 +667,25 @@ func ActivityFirstRechargeBackInfo(c *gin.Context) { return } resp := &values.ActivityFirstRechargeBackInfoResp{} + conf := call.GetConfigActivityFirstRechargeBack() a.Data = resp data := call.GetUserFirstRechargeBackData(a.UID) - diff := time.Now().Unix() - data.RechargeTime log.Debug("ActivityFirstRechargeBackInfo:%+v", data) if data.RechargeTime == 0 { resp.CanRecharge = true - } else { - if diff > common.ActivityFirstRechargeBackTime*2 { - a.Code = values.CodeActivityExpire - return - } - resp.CanRecharge = diff < common.ActivityFirstRechargeBackTime } + resp.ProductList = call.GetConfigPayProductByActivityID(common.ActivityIDFirstRechargeBack) resp.Recharge = data.Amount - if data.Amount < call.GetConfigActivityFirstRechargeBack().MinRecharge { + if data.Amount < conf.MinRecharge { return } val := data.Amount - call.GetUserCurrencyTotal(a.UID, common.CurrencyINR) if val < 0 { val = 0 } - max := call.GetConfigActivityFirstRechargeBack().MaxBack - if max > 0 && val > max { - val = max - } - if val > data.Amount { - val = data.Amount - } + val = val * conf.MaxBack / 100 resp.Back = val + } func ActivityFirstRechargeBackDraw(c *gin.Context) { @@ -706,6 +696,7 @@ func ActivityFirstRechargeBackDraw(c *gin.Context) { if !a.CheckActivityExpire(common.ActivityIDFirstRechargeBack) { return } + conf := call.GetConfigActivityFirstRechargeBack() data := call.GetUserFirstRechargeBackData(a.UID) val := data.Amount - call.GetUserCurrencyTotal(a.UID, common.CurrencyINR) if val <= 0 { @@ -716,22 +707,12 @@ func ActivityFirstRechargeBackDraw(c *gin.Context) { a.Code = values.CodeRetry return } - if time.Now().Unix()-data.RechargeTime > common.ActivityFirstRechargeBackTime*2 { - a.Code = values.CodeActivityExpire - return - } rows, err := db.Mysql().UpdateRes(&common.ActivityFirstRechargeBackData{UID: a.UID}, map[string]interface{}{"lost": 0}) if err != nil || rows == 0 { a.Code = values.CodeRetry return } - max := call.GetConfigActivityFirstRechargeBack().MaxBack - if max > 0 || val > max { - val = max - } - if val > data.Amount { - val = data.Amount - } + val = val * conf.MaxBack / 100 _, err = call.UpdateCurrencyPro(&common.UpdateCurrency{ CurrencyBalance: &common.CurrencyBalance{ UID: a.UID, @@ -1999,3 +1980,39 @@ func ActivityPopup(c *gin.Context) { resp.List = call.GetConfigActivityPopupByType(req.JumpType) } } + +func WeekCardInfo(c *gin.Context) { + a := app.NewApp(c) + defer func() { + a.Response() + }() + req := values.ActivityPopupReq{} + if !a.S(&req) { + return + } + resp := new(values.ActivityPopupResp) + a.Data = resp + if req.JumpType == 0 { + resp.List = call.GetConfigActivityPopup() + } else { + resp.List = call.GetConfigActivityPopupByType(req.JumpType) + } +} + +func WeekCardDraw(c *gin.Context) { + a := app.NewApp(c) + defer func() { + a.Response() + }() + req := values.ActivityPopupReq{} + if !a.S(&req) { + return + } + resp := new(values.ActivityPopupResp) + a.Data = resp + if req.JumpType == 0 { + resp.List = call.GetConfigActivityPopup() + } else { + resp.List = call.GetConfigActivityPopupByType(req.JumpType) + } +} diff --git a/modules/web/routers/routers_activity.go b/modules/web/routers/routers_activity.go index 2157cba..50c7f71 100644 --- a/modules/web/routers/routers_activity.go +++ b/modules/web/routers/routers_activity.go @@ -19,8 +19,6 @@ func activity(e *gin.RouterGroup) { e.POST("/activity/pdd/reference", handler.ActivityPddReference) e.POST("/activity/freeSpin/info", handler.ActivityFreeSpinInfo) e.POST("/activity/freeSpin/draw", handler.ActivityFreeSpinDraw) - e.POST("/activity/firstRechargeBack/info", handler.ActivityFirstRechargeBackInfo) - e.POST("/activity/firstRechargeBack/draw", handler.ActivityFirstRechargeBackDraw) e.POST("/activity/luckyCode/info", handler.ActivityLuckyCodeInfo) e.POST("/activity/luckyCode/draw", handler.ActivityLuckyCodeDraw) // e.POST("/activity/sign/info", handler.ActivitySignInfo) @@ -45,4 +43,7 @@ func activity(e *gin.RouterGroup) { e.POST("/activity/betDraw/record", handler.ActivityBetDrawHistory) // 活动弹窗 e.POST("/activity/activityPopup/info", handler.ActivityPopup) + // 首充返还 + e.POST("/activity/firstRechargeBack/info", handler.ActivityFirstRechargeBackInfo) + e.POST("/activity/firstRechargeBack/draw", handler.ActivityFirstRechargeBackDraw) } diff --git a/modules/web/values/activity.go b/modules/web/values/activity.go index cd446d8..167028e 100644 --- a/modules/web/values/activity.go +++ b/modules/web/values/activity.go @@ -47,6 +47,7 @@ type ActivityFirstRechargeBackInfoResp struct { Recharge int64 Back int64 CanRecharge bool + ProductList []*common.ConfigPayProduct } // ID 物品id @@ -287,3 +288,7 @@ type ActivityPopupReq struct { type ActivityPopupResp struct { List []*common.ConfigActivityPopup } + +type ActivityFirstRechargeInfoResp struct { + List []*common.ConfigActivityPopup +} From 2d1b27cd39d61f21df961f28921df4f0505c9844 Mon Sep 17 00:00:00 2001 From: mofangmin Date: Tue, 20 Aug 2024 15:57:48 +0800 Subject: [PATCH 02/14] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=A2=86=E5=8F=96?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/web/handler/activity.go | 2 +- modules/web/values/activity.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/web/handler/activity.go b/modules/web/handler/activity.go index 16e7916..f8638d4 100644 --- a/modules/web/handler/activity.go +++ b/modules/web/handler/activity.go @@ -685,7 +685,7 @@ func ActivityFirstRechargeBackInfo(c *gin.Context) { } val = val * conf.MaxBack / 100 resp.Back = val - + resp.DrawTime = data.RechargeTime + common.ActivityFirstRechargeBackTime } func ActivityFirstRechargeBackDraw(c *gin.Context) { diff --git a/modules/web/values/activity.go b/modules/web/values/activity.go index 167028e..63eb21e 100644 --- a/modules/web/values/activity.go +++ b/modules/web/values/activity.go @@ -47,6 +47,7 @@ type ActivityFirstRechargeBackInfoResp struct { Recharge int64 Back int64 CanRecharge bool + DrawTime int64 // 领取时间 ProductList []*common.ConfigPayProduct } From 3e94fcfcc8db10677c1f3b927f2181e1760290f8 Mon Sep 17 00:00:00 2001 From: mofangmin Date: Tue, 20 Aug 2024 16:38:19 +0800 Subject: [PATCH 03/14] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/web/handler/activity.go | 1 + modules/web/middleware/token.go | 83 +++++++++++++++++---------------- modules/web/values/activity.go | 1 + 3 files changed, 44 insertions(+), 41 deletions(-) diff --git a/modules/web/handler/activity.go b/modules/web/handler/activity.go index f8638d4..413d0ec 100644 --- a/modules/web/handler/activity.go +++ b/modules/web/handler/activity.go @@ -676,6 +676,7 @@ func ActivityFirstRechargeBackInfo(c *gin.Context) { } resp.ProductList = call.GetConfigPayProductByActivityID(common.ActivityIDFirstRechargeBack) resp.Recharge = data.Amount + resp.BackPer = conf.MaxBack if data.Amount < conf.MinRecharge { return } diff --git a/modules/web/middleware/token.go b/modules/web/middleware/token.go index 120f9c1..0d3b105 100644 --- a/modules/web/middleware/token.go +++ b/modules/web/middleware/token.go @@ -15,47 +15,48 @@ import ( var ( passURLs = map[string]struct{}{ - "/firstpage": {}, - "/game/list": {}, - "/sys/config": {}, - "/account/email/code": {}, - "/account/email/regist": {}, - "/account/email/login": {}, - "/account/email/resetPass": {}, - "/account/guestLogin": {}, - "/account/gpLogin": {}, - "/account/fbLogin": {}, - "/account/tokenLogin": {}, - "/account/phoneCode/get": {}, - "/account/phoneCode/verify": {}, - "/account/phoneCode/regist": {}, - "/account/phoneCode/login": {}, - "/share/upload": {}, - "/share/config": {}, - "/game/enter": {}, - "/activity/appSpin/info": {}, - "/activity/pdd/info": {}, - "/account/phone/regist": {}, - "/account/phone/login": {}, - "/account/phone/resetPass": {}, - "/balance/recharge/info": {}, - "/share/info": {}, - "/vip/info": {}, - "/share/reference": {}, - "/share/report": {}, - "/share/transfer": {}, - "/task/info": {}, - "/activity/freeSpin/info": {}, - "/promotions": {}, - "/tg/luckyCode": {}, - "/activity/sign/info": {}, - "/ad/uploadFB": {}, - "/activity/slots/info": {}, - "/activity/sign/new/info": {}, - "/activity/betDraw/info": {}, - "/activity/betDraw/record": {}, - "/activity/activityPopup/info": {}, - "/customer/image/download": {}, + "/firstpage": {}, + "/game/list": {}, + "/sys/config": {}, + "/account/email/code": {}, + "/account/email/regist": {}, + "/account/email/login": {}, + "/account/email/resetPass": {}, + "/account/guestLogin": {}, + "/account/gpLogin": {}, + "/account/fbLogin": {}, + "/account/tokenLogin": {}, + "/account/phoneCode/get": {}, + "/account/phoneCode/verify": {}, + "/account/phoneCode/regist": {}, + "/account/phoneCode/login": {}, + "/share/upload": {}, + "/share/config": {}, + "/game/enter": {}, + "/activity/appSpin/info": {}, + "/activity/pdd/info": {}, + "/account/phone/regist": {}, + "/account/phone/login": {}, + "/account/phone/resetPass": {}, + "/balance/recharge/info": {}, + "/share/info": {}, + "/vip/info": {}, + "/share/reference": {}, + "/share/report": {}, + "/share/transfer": {}, + "/task/info": {}, + "/activity/freeSpin/info": {}, + "/promotions": {}, + "/tg/luckyCode": {}, + "/activity/sign/info": {}, + "/ad/uploadFB": {}, + "/activity/slots/info": {}, + "/activity/sign/new/info": {}, + "/activity/betDraw/info": {}, + "/activity/betDraw/record": {}, + "/activity/activityPopup/info": {}, + "/customer/image/download": {}, + "/activity/firstRechargeBack/info": {}, } ) diff --git a/modules/web/values/activity.go b/modules/web/values/activity.go index 63eb21e..671e94d 100644 --- a/modules/web/values/activity.go +++ b/modules/web/values/activity.go @@ -46,6 +46,7 @@ type ActivityFreeSpinDrawResp struct { type ActivityFirstRechargeBackInfoResp struct { Recharge int64 Back int64 + BackPer int64 CanRecharge bool DrawTime int64 // 领取时间 ProductList []*common.ConfigPayProduct From 9cc17ff8df13fa2048faacc2564e852c92fbd2b5 Mon Sep 17 00:00:00 2001 From: mofangmin Date: Tue, 20 Aug 2024 20:10:06 +0800 Subject: [PATCH 04/14] =?UTF-8?q?=E6=B4=BB=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- call/pay.go | 3 ++- common/activity.go | 1 + modules/web/handler/activity.go | 13 ++++++++----- modules/web/values/activity.go | 2 ++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/call/pay.go b/call/pay.go index 8c5d969..ac0c4f6 100644 --- a/call/pay.go +++ b/call/pay.go @@ -531,8 +531,9 @@ func PayActivity(r *common.RechargeOrder, notCharge bool, user *common.PlayerDBI func ActivityFirstRechargeBack(r *common.RechargeOrder) { if IsActivityValid(common.ActivityIDFirstRechargeBack) { + conf := GetConfigActivityFirstRechargeBack() rechargeBackData := GetUserFirstRechargeBackData(r.UID) - if rechargeBackData.RechargeTime == 0 { + if rechargeBackData.RechargeTime == 0 && r.Amount >= conf.MinRecharge { db.Mysql().Create(&common.ActivityFirstRechargeBackData{UID: r.UID, RechargeTime: time.Now().Unix(), Amount: r.Amount}) } } diff --git a/common/activity.go b/common/activity.go index e0e0c0b..9254991 100644 --- a/common/activity.go +++ b/common/activity.go @@ -210,6 +210,7 @@ type ActivityFirstRechargeBackData struct { RechargeTime int64 `gorm:"column:recharge_time;type:bigint(20);default:0;comment:首次充值时间"` Amount int64 `gorm:"column:amount;type:bigint(20);default:0;comment:总充值金额"` Lost int64 `gorm:"column:lost;type:bigint(20);default:0;comment:活动时间内总损失"` + RewardTime int64 `gorm:"column:reward_time;type:bigint(20);default:0;comment:领取时间"` } func (c *ActivityFirstRechargeBackData) TableName() string { diff --git a/modules/web/handler/activity.go b/modules/web/handler/activity.go index 413d0ec..c045b7d 100644 --- a/modules/web/handler/activity.go +++ b/modules/web/handler/activity.go @@ -663,6 +663,7 @@ func ActivityFirstRechargeBackInfo(c *gin.Context) { defer func() { a.Response() }() + a.GetUID() if !a.CheckActivityExpire(common.ActivityIDFirstRechargeBack) { return } @@ -671,21 +672,23 @@ func ActivityFirstRechargeBackInfo(c *gin.Context) { a.Data = resp data := call.GetUserFirstRechargeBackData(a.UID) log.Debug("ActivityFirstRechargeBackInfo:%+v", data) - if data.RechargeTime == 0 { - resp.CanRecharge = true - } resp.ProductList = call.GetConfigPayProductByActivityID(common.ActivityIDFirstRechargeBack) resp.Recharge = data.Amount resp.BackPer = conf.MaxBack - if data.Amount < conf.MinRecharge { + if data.RechargeTime == 0 { + resp.CanRecharge = true return } + if data.RewardTime > 0 { + resp.Draw = true + } val := data.Amount - call.GetUserCurrencyTotal(a.UID, common.CurrencyINR) if val < 0 { val = 0 } val = val * conf.MaxBack / 100 resp.Back = val + resp.PayAmount = rand.Int63n(1000000) + 10000 resp.DrawTime = data.RechargeTime + common.ActivityFirstRechargeBackTime } @@ -708,7 +711,7 @@ func ActivityFirstRechargeBackDraw(c *gin.Context) { a.Code = values.CodeRetry return } - rows, err := db.Mysql().UpdateRes(&common.ActivityFirstRechargeBackData{UID: a.UID}, map[string]interface{}{"lost": 0}) + rows, err := db.Mysql().UpdateRes(&common.ActivityFirstRechargeBackData{UID: a.UID}, map[string]interface{}{"lost": 0, "reward_time": time.Now().Unix()}) if err != nil || rows == 0 { a.Code = values.CodeRetry return diff --git a/modules/web/values/activity.go b/modules/web/values/activity.go index 671e94d..02021a4 100644 --- a/modules/web/values/activity.go +++ b/modules/web/values/activity.go @@ -48,7 +48,9 @@ type ActivityFirstRechargeBackInfoResp struct { Back int64 BackPer int64 CanRecharge bool + PayAmount int64 // 支付金额 DrawTime int64 // 领取时间 + Draw bool // 是否领取 ProductList []*common.ConfigPayProduct } From 701b9a2068a7f3bee45915f633622692fdf12c70 Mon Sep 17 00:00:00 2001 From: mofangmin Date: Wed, 21 Aug 2024 14:50:35 +0800 Subject: [PATCH 05/14] =?UTF-8?q?=E8=BD=AC=E7=9B=98=E6=B4=BB=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- call/config.go | 12 +++++++ cmd/build.sh | 1 + common/activity.go | 39 ++++++++++++++++++-- common/config.go | 13 ++++--- modules/web/app/response.go | 1 - modules/web/handler/activity.go | 64 ++++++++++++++++++++++++++++++--- modules/web/values/activity.go | 6 ++-- 7 files changed, 121 insertions(+), 15 deletions(-) diff --git a/call/config.go b/call/config.go index 6948aea..21d8a82 100644 --- a/call/config.go +++ b/call/config.go @@ -358,6 +358,18 @@ func LoadConfigPayChannels() (err error) { return nil } +// GetConfigPayChannelsByID 获取支付渠道配置 +func GetConfigPayChannelsByID(currencyType common.CurrencyType) []*common.ConfigPayChannels { + ret := []*common.ConfigPayChannels{} + for i, v := range ConfigPayChannels { + if v.PayPer <= 0 || v.CurrencyType != currencyType { + continue + } + ret = append(ret, ConfigPayChannels[i]) + } + return ret +} + // GetConfigPayChannels 获取代收渠道配置 func GetConfigPayChannels() []*common.ConfigPayChannels { ret := []*common.ConfigPayChannels{} diff --git a/cmd/build.sh b/cmd/build.sh index 4b29610..f3a9daa 100644 --- a/cmd/build.sh +++ b/cmd/build.sh @@ -8,4 +8,5 @@ cd pb/proto # go generate cd ../.. #go build 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 indiaprovider main.go \ No newline at end of file diff --git a/common/activity.go b/common/activity.go index 9254991..a3aaaa7 100644 --- a/common/activity.go +++ b/common/activity.go @@ -1,6 +1,9 @@ package common import ( + "database/sql/driver" + "encoding/json" + "errors" "time" ) @@ -493,10 +496,40 @@ func (c *ActivitySuperData) TableName() string { return "activity_super_data" } +type LuckyData struct { + LastSpinTime int64 + SpinNum int + NextSpinTIme int64 +} + +type SpinInfo map[int]*LuckyData + +func (m SpinInfo) Value() (driver.Value, error) { + return json.Marshal(m) +} + +func (m *SpinInfo) Scan(value interface{}) error { + if value == nil { + *m = SpinInfo{} + return nil + } + // 将数据库中的 JSON 字符串解析为 map + bytes, ok := value.([]byte) + if !ok { + return errors.New("type assertion to []byte failed") + } + if len(bytes) == 0 { + *m = SpinInfo{} + return nil + } + return json.Unmarshal(bytes, &m) +} + type ActivityBetDrawData struct { - ID int `gorm:"primarykey"` - UID int `gorm:"column:uid;not null;type:int(11);uniqueIndex:uid"` - Lucky int64 `gorm:"column:lucky;;not null;type:bigint(20);comment:幸运值" web:"lucky"` + ID int `gorm:"primarykey"` + UID int `gorm:"column:uid;not null;type:int(11);uniqueIndex:uid"` + Lucky int64 `gorm:"column:lucky;;not null;type:bigint(20);comment:幸运值" web:"lucky"` + SpinInfo SpinInfo `gorm:"column:spin_info;;not null;type:varchar(256);comment:转盘信息" web:"spinInfo"` } func (c *ActivityBetDrawData) TableName() string { diff --git a/common/config.go b/common/config.go index dde4b84..c8bb998 100644 --- a/common/config.go +++ b/common/config.go @@ -579,11 +579,14 @@ func (c *ConfigTgRobot) TableName() string { } type ConfigActivityBetDraw struct { - ID int `gorm:"primarykey"` - Type int `gorm:"column:type;type:int(11);default:0;comment:转盘类型" web:"type"` - Cost int64 `gorm:"column:cost;type:int(11);default:0;comment:消耗幸运值" web:"cost"` - Reward int64 `gorm:"column:reward;type:bigint(20);comment:奖励" web:"reward"` - Weight int64 `gorm:"column:weight;type:bigint(20);comment:权重" web:"weight"` + ID int `gorm:"primarykey"` + Type int `gorm:"column:type;type:int(11);default:0;comment:转盘类型" web:"type"` + Cost int64 `gorm:"column:cost;type:int(11);default:0;comment:消耗幸运值" web:"cost"` + Reward int64 `gorm:"column:reward;type:bigint(20);comment:奖励" web:"reward"` + Weight int64 `gorm:"column:weight;type:bigint(20);comment:权重" web:"weight"` + VipUnlock int `gorm:"column:vip_unlock;type:int(11);comment:vip解锁等级" web:"vipUnlock"` + Cd int64 `gorm:"column:cd;type:bigint(20);comment:冷却时间" web:"cd"` + LimitNum int `gorm:"column:limit_num;type:int(11);comment:每日领取次数" web:"limitNum"` } func (c *ConfigActivityBetDraw) TableName() string { diff --git a/modules/web/app/response.go b/modules/web/app/response.go index 2a3aa3a..778de1b 100644 --- a/modules/web/app/response.go +++ b/modules/web/app/response.go @@ -88,7 +88,6 @@ func (g *Gin) ResponseB() { // Response setting gin.JSON func (g *Gin) Response() { if g.R.Code == values.CodeRetry { - g.R.Msg = "inner error" } else if g.R.Code == values.CodeToken { g.R.Msg = "login expired" } diff --git a/modules/web/handler/activity.go b/modules/web/handler/activity.go index c045b7d..b68cf3b 100644 --- a/modules/web/handler/activity.go +++ b/modules/web/handler/activity.go @@ -675,6 +675,7 @@ func ActivityFirstRechargeBackInfo(c *gin.Context) { resp.ProductList = call.GetConfigPayProductByActivityID(common.ActivityIDFirstRechargeBack) resp.Recharge = data.Amount resp.BackPer = conf.MaxBack + resp.ChannelList = call.GetConfigPayChannelsByID(common.CurrencyINR) if data.RechargeTime == 0 { resp.CanRecharge = true return @@ -1855,16 +1856,47 @@ func ActivityBetDrawInfo(c *gin.Context) { db.Mysql().Create(drawInfo) } } + vipInfo := call.GetVIP(a.UID) + confList := call.GetConfigBetDraw() resp := &values.ActivityBetDrawInfoResp{ - List: call.GetConfigBetDraw(), + List: confList, Lucky: drawInfo.Lucky, } a.Data = resp + var types []int + var confs []*common.ConfigActivityBetDraw for _, item := range resp.List { - if resp.Lucky >= item.Cost { + if resp.Lucky >= item.Cost && vipInfo.Level >= item.VipUnlock { call.PushRed(a.UID, pb.RedPointModule_RedPointFreeSpin, uint32(1)) break } + if !util.SliceContain(types, item.Type) { + types = append(types, item.Type) + confs = append(confs, item) + } + } + now := time.Now() + update := false + for _, item := range confs { + typ := item.Type + spinInfo := drawInfo.SpinInfo[typ] + if spinInfo == nil { + drawInfo.SpinInfo[typ] = &common.LuckyData{} + spinInfo = drawInfo.SpinInfo[typ] + } + if !util.IsSameDayTimeStamp(spinInfo.LastSpinTime, now.Unix()) { + spinInfo.SpinNum = 0 + update = true + } + resp.SpinInfo = append(resp.SpinInfo, &common.LuckyData{ + SpinNum: spinInfo.SpinNum, + NextSpinTIme: spinInfo.NextSpinTIme, + }) + } + if update && a.UID > 0 { + db.Mysql().Update(&common.ActivityBetDrawData{UID: a.UID}, map[string]interface{}{ + "spin_info": drawInfo.SpinInfo, + }) } call.UploadActivityData(a.UID, common.ActivityIDBetDraw, common.ActivityDataClick, 0) } @@ -1881,6 +1913,7 @@ func ActivityBetDrawDraw(c *gin.Context) { if !a.CheckActivityExpire(common.ActivityIDBetDraw) { return } + configList, weightList := call.GetConfigBetDrawByType(req.WheelType) if len(configList) == 0 { a.Code = values.CodeRetry @@ -1889,6 +1922,23 @@ func ActivityBetDrawDraw(c *gin.Context) { conf := configList[0] drawInfo := common.ActivityBetDrawData{UID: a.UID} db.Mysql().Get(&drawInfo) + now := time.Now() + spinInfo, ok := drawInfo.SpinInfo[req.WheelType] + if !ok { + drawInfo.SpinInfo[req.WheelType] = &common.LuckyData{} + spinInfo = drawInfo.SpinInfo[req.WheelType] + } + // step:判断cd + if spinInfo.LastSpinTime != 0 && now.Unix()-spinInfo.LastSpinTime < conf.Cd { + a.Code = values.CodeRetry + a.Msg = "Unarrived spin time" + return + } + if spinInfo.SpinNum >= conf.LimitNum { + a.Code = values.CodeRetry + a.Msg = "No spin times" + return + } if drawInfo.Lucky < conf.Cost { a.Code = values.CodeRetry a.Msg = "lucky not enough" @@ -1902,8 +1952,14 @@ func ActivityBetDrawDraw(c *gin.Context) { } rewardConf := configList[idx] reward := rewardConf.Reward - err := db.Mysql().Update(&drawInfo, map[string]interface{}{ - "lucky": gorm.Expr("lucky - ?", conf.Cost), + spinInfo.LastSpinTime = time.Now().Unix() + spinInfo.SpinNum += 1 + spinInfo.NextSpinTIme = spinInfo.LastSpinTime + conf.Cd + err := db.Mysql().Update(&common.ActivityBetDrawData{ + UID: a.UID, + }, map[string]interface{}{ + "lucky": gorm.Expr("lucky - ?", conf.Cost), + "spin_info": drawInfo.SpinInfo, }) if err != nil { a.Code = values.CodeRetry diff --git a/modules/web/values/activity.go b/modules/web/values/activity.go index 02021a4..14262ba 100644 --- a/modules/web/values/activity.go +++ b/modules/web/values/activity.go @@ -51,6 +51,7 @@ type ActivityFirstRechargeBackInfoResp struct { PayAmount int64 // 支付金额 DrawTime int64 // 领取时间 Draw bool // 是否领取 + ChannelList []*common.ConfigPayChannels ProductList []*common.ConfigPayProduct } @@ -262,8 +263,9 @@ type ActivitySuperDrawResp struct { } type ActivityBetDrawInfoResp struct { - List []*common.ConfigActivityBetDraw // 配置 - Lucky int64 // 幸运值 + List []*common.ConfigActivityBetDraw // 配置 + Lucky int64 // 幸运值 + SpinInfo []*common.LuckyData } type ActivityBetDrawDrawReq struct { From 3d4f8a1b81e538c0e5de94bb60e72e1c4ceb6a22 Mon Sep 17 00:00:00 2001 From: mofangmin Date: Wed, 21 Aug 2024 15:38:49 +0800 Subject: [PATCH 06/14] =?UTF-8?q?=E6=96=B0=E5=A2=9Eeanipay?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/recharge.go | 7 ++ modules/pay/allpay/all.go | 3 + modules/pay/base/base.go | 1 + modules/pay/eanipay/base.go | 184 +++++++++++++++++++++++++++++++ modules/pay/eanipay/values.go | 196 ++++++++++++++++++++++++++++++++++ modules/pay/values/values.go | 1 + 6 files changed, 392 insertions(+) create mode 100644 modules/pay/eanipay/base.go create mode 100644 modules/pay/eanipay/values.go diff --git a/common/recharge.go b/common/recharge.go index b65dcee..b22f866 100644 --- a/common/recharge.go +++ b/common/recharge.go @@ -150,6 +150,13 @@ const ( WithdrawOrderTypeAll ) +// 支付类型 +const ( + WithdrawTypeWallet = 3 + WithdrawTypeUPI = 4 + WithdrawTypeBank = 7 +) + type WithdrawOrder struct { ID uint `gorm:"primarykey"` UID int `gorm:"column:uid;not null;type:int(11)"` diff --git a/modules/pay/allpay/all.go b/modules/pay/allpay/all.go index ff0c91b..36993e8 100644 --- a/modules/pay/allpay/all.go +++ b/modules/pay/allpay/all.go @@ -3,6 +3,7 @@ package allpay import ( "reflect" "server/modules/pay/base" + "server/modules/pay/eanipay" "server/modules/pay/gopay" "server/modules/pay/grepay" "server/modules/pay/luckyinpay" @@ -59,6 +60,7 @@ type AllPay struct { Moonpay2 func(b *base.Base) PayPlus func(b *base.Base) LuckyinPay func(b *base.Base) + Eanipay func(b *base.Base) } var All = &AllPay{} @@ -70,6 +72,7 @@ func init() { All.MLPay = mlpay.NewSub All.PayPlus = payplus.NewSub All.LuckyinPay = luckyinpay.NewSub + All.Eanipay = eanipay.NewSub } func NewSub(b *base.Base, index int) { diff --git a/modules/pay/base/base.go b/modules/pay/base/base.go index 5196bec..00a90fc 100644 --- a/modules/pay/base/base.go +++ b/modules/pay/base/base.go @@ -62,6 +62,7 @@ type Base struct { SignPassStr []string // 不参与签名的字段 KeyName string // 有时候有些渠道签名字段不一样 C *gin.Context + ReqData interface{} } type CallbackResp struct { diff --git a/modules/pay/eanipay/base.go b/modules/pay/eanipay/base.go new file mode 100644 index 0000000..0707847 --- /dev/null +++ b/modules/pay/eanipay/base.go @@ -0,0 +1,184 @@ +package eanipay + +import ( + "encoding/json" + "errors" + "fmt" + "net/http" + "server/common" + "server/modules/pay/base" + "server/modules/pay/values" + "server/pb" + "server/util" + "time" + + "github.com/gogo/protobuf/proto" + "github.com/liangdas/mqant/log" +) + +func NewSub(b *base.Base) { + sub := &Sub{ + Base: b, + } + b.HttpType = base.HttpTypeJson + b.ShouldSignUpper = true + if b.Opt == base.OPTPay { + b.Resp = new(PayResp) + b.ReqURL = baseURL + payURL + } else if b.Opt == base.OPTWithdraw { + b.Resp = new(WithdrawResp) + b.ReqURL = baseURL + withdrawURL + } else if b.Opt == base.OPTPayCB { + b.CallbackReq = new(PayCallbackReq) + b.CallbackResp.Msg = "success" + } else if b.Opt == base.OPTWithdrawCB { + b.CallbackReq = new(WithdrawCallbackReq) + b.CallbackResp.Msg = "success" + } else if b.Opt == base.OPTQueryWithdraw { // 查询 + b.Resp = new(QueryWithdrawResp) + b.ReqURL = baseURL + queryWithdrawURL + } else if b.Opt == base.OPTQueryPay { // 查询 + b.Resp = new(QueryPayResp) + b.ReqURL = baseURL + queryPayURL + } else { + return + } + b.Sub = sub +} + +type Sub struct { + Base *base.Base +} + +func (s *Sub) PackHeader(header http.Header) { + header.Set("Accept", "application/json") + url := baseURL + if s.Base.Opt == base.OPTPay { + url += payURL + } else if s.Base.Opt == base.OPTWithdraw { + url += withdrawURL + } else if s.Base.Opt == base.OPTQueryWithdraw { + url += queryWithdrawURL + } else if s.Base.Opt == base.OPTQueryPay { + url += queryPayURL + } + randomStr := util.GetSimpleRandomString(10) + bodyStr, _ := json.Marshal(s.Base.ReqData) + now := time.Now().UnixMilli() + sign := Sign(string(bodyStr), fmt.Sprintf("%d", now), randomStr, url) + header.Set("Authorization", fmt.Sprintf(`V2_SHA256 appId=%s,sign=%s,timestamp=%d,nonce=%s`, appID, sign, now, randomStr)) +} + +func (s *Sub) PackReq() interface{} { + if s.Base.Opt == base.OPTPay { + return s.PackPayReq() + } else if s.Base.Opt == base.OPTWithdraw { + return s.PackWithdrawReq() + } + return nil +} + +func (s *Sub) GetResp() (proto.Message, error) { + log.Debug("resp:%v", s.Base.Resp) + if s.Base.Opt == base.OPTPay { + resp := s.Base.Resp.(*PayResp) + if resp.Data.Action.URL == "" { + return nil, errors.New("pay fail") + } + return &pb.InnerRechargeResp{APIOrderID: resp.Data.PaymentNo, URL: resp.Data.Action.URL, Channel: uint32(values.EaniPay)}, nil + } else if s.Base.Opt == base.OPTWithdraw { + resp := s.Base.Resp.(*WithdrawResp) + if s.Base.Status == 0 && resp.Code != "OK" { + return nil, errors.New("withdraw fail") + } + return &pb.InnerWithdrawResp{APIOrderID: resp.Data.PayoutNo, Channel: uint32(values.EaniPay)}, nil + } + return nil, errors.New("unknown opt") +} + +func (s *Sub) PackPayReq() interface{} { + r := s.Base.PayReq + send := &PayReq{ + MerchantTradeNo: r.OrderID, + Amount: fmt.Sprintf("%d", r.Amount), + Currency: "INR", + Description: "TeenPatti", + Payer: Payer{UserID: fmt.Sprintf("%d", r.UID), Name: r.Name, Email: r.Email, Phone: r.Phone}, + PayMethod: struct { + Type string `json:"type"` // UPI + }{Type: "UPI"}, + TradeEnv: struct { + IP string `json:"ip"` + }{IP: r.IP}, + NotifyUrl: values.GetPayCallback(values.EaniPay), + ReturnUrl: values.GetPayCallback(values.EaniPay), + } + s.Base.ReqData = send + return send +} + +func (s *Sub) PackWithdrawReq() interface{} { + r := s.Base.WithdrawReq + send := &WithdrawReq{ + MerchantTradeNo: r.OrderID, + Amount: fmt.Sprintf("%d", r.Amount), + Currency: "INR", + Description: "TeenPatti", + NotifyUrl: values.GetWithdrawCallback(values.EaniPay), + } + if r.PayType == common.WithdrawTypeBank { + send.PayoutMethod.Type = "BANK_ACCOUNT" + send.PayoutMethod.Mode = "IMPS" + send.PayoutMethod.BankCode = r.PayCode + send.PayoutMethod.BankName = r.BankName + send.PayoutMethod.AccountNumber = r.CardNo + send.PayoutMethod.PayeeName = r.Name + send.PayoutMethod.PayeePhone = r.Phone + send.PayoutMethod.PayeeEmail = r.Email + send.PayoutMethod.PayeeAddress = r.Address + } else { + return nil + } + s.Base.ReqData = send + return send +} + +func (s *Sub) CheckSign(str string) bool { + log.Debug("callback:%v", s.Base.CallbackReq) + signStr := s.Base.C.GetHeader("Authorization") + signData := parseData(signStr) + if s.Base.Opt == base.OPTPayCB { + req := s.Base.CallbackReq.(*PayCallbackReq) + s.Base.CallbackResp.OrderID = req.Data.MerchantTradeNo + if req.Data.Status == "PENDING" || req.Data.Status == "PROCESSING" { + return false + } + s.Base.CallbackResp.APIOrderID = req.Data.PaymentNo + s.Base.CallbackResp.Success = req.Data.Status == "PAID" + return Sign(str, signData.Timestamp, signData.Nonce, values.GetPayCallback(values.EaniPay)) == signData.Sign + } else if s.Base.Opt == base.OPTWithdrawCB { + req := s.Base.CallbackReq.(*WithdrawCallbackReq) + s.Base.CallbackResp.OrderID = req.Data.MerchantTradeNo + if req.Data.Status == "PENDING" || req.Data.Status == "PROCESSING" { + return false + } + s.Base.CallbackResp.Success = req.Data.Status == "PAID" + return Sign(str, signData.Timestamp, signData.Nonce, values.GetWithdrawCallback(values.EaniPay)) == signData.Sign + } + return false +} + +func Sign(bodyStr, t, ran, url string) string { + signStr := fmt.Sprintf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n", + appID, + appSecret, + "POST", + url, + t, + ran, + bodyStr, + ) + sign := util.CalculateSHA256(signStr) + log.Debug("signStr:%s,sign:%s", signStr, sign) + return sign +} diff --git a/modules/pay/eanipay/values.go b/modules/pay/eanipay/values.go new file mode 100644 index 0000000..5360a63 --- /dev/null +++ b/modules/pay/eanipay/values.go @@ -0,0 +1,196 @@ +package eanipay + +import "strings" + +const ( + baseURL = "https://gateway.eanishop.com" + // baseURL = "https://gateway.eanishop.com" + payURL = "/pg/v2/payment/create" + queryPayURL = "/pg/v2/payment/query" + withdrawURL = "/pg/v2/payout/create" + queryWithdrawURL = "/pg/v2/payout/query" + appID = "c553240e3e3842ad98eb8ae23c3745b5" + appSecret = "8e77714f16d2487f9846cc6c3432ead5" +) + +type PayReq struct { + MerchantTradeNo string `json:"merchantTradeNo"` + Amount string `json:"amount"` + Currency string `json:"currency"` + Description string `json:"description"` + Payer Payer `json:"payer"` + PayMethod struct { + Type string `json:"type"` // UPI + } `json:"payMethod"` + TradeEnv struct { + IP string `json:"ip"` + } `json:"tradeEnv"` // 如果具体环境信息比较复杂,可以直接使用json.RawMessage + MerchantAttach string `json:"merchantAttach,omitempty"` // omitempty表示如果字段为空,则在JSON中不显示 + NotifyUrl string `json:"notifyUrl"` + ReturnUrl string `json:"returnUrl"` +} + +type Payer struct { + UserID string `json:"userId" validate:"required,max=64"` + Name string `json:"name" validate:"required,max=80"` + Email string `json:"email" validate:"required,email,max=80"` + Phone string `json:"phone" validate:"required,max=20"` +} + +type PayResp struct { + Code string `json:"code"` + ErrorMessage string `json:"errorMessage"` + Data PaymentData `json:"data"` +} + +type PaymentData struct { + PaymentNo string `json:"paymentNo"` + MerchantTradeNo string `json:"merchantTradeNo"` + Amount string `json:"amount"` + Currency string `json:"currency"` + Action Action `json:"action"` +} + +type Action struct { + PayMethodType string `json:"payMethodType"` + Type string `json:"type"` + URL string `json:"url"` + Method string `json:"method"` +} + +type PayCallbackReq struct { + Event string `json:"event"` + Code string `json:"code"` + ErrorMessage string `json:"errorMessage"` + Data struct { + PaymentNo string `json:"paymentNo"` + MerchantTradeNo string `json:"merchantTradeNo"` + Amount string `json:"amount"` + Currency string `json:"currency"` + RefundStatus string `json:"refundStatus"` + Status string `json:"status"` // PENDING 待⽀付 PROCESSING ⽀付中 PAID ⽀付成功 FAILURE ⽀付失败 CANCELLED 已取消 + MerchantAttach string `json:"merchantAttach"` + CreatedTime string `json:"createdTime"` + PaidTime string `json:"paidTime"` + } `json:"data"` +} + +type QueryPayReq struct { + MerchantTradeNo string `json:"merchantTradeNo"` +} + +type QueryPayResp struct { + Code string `json:"code"` + ErrorMessage string `json:"errorMessage"` + Data struct { + PaymentNo string `json:"paymentNo"` + MerchantTradeNo string `json:"merchantTradeNo"` + Amount string `json:"amount"` + Currency string `json:"currency"` + RefundStatus string `json:"refundStatus"` + Status string `json:"status"` // PENDING 待⽀付 PROCESSING ⽀付中 PAID ⽀付成功 FAILURE ⽀付失败 CANCELLED 已取消 + MerchantAttach string `json:"merchantAttach"` + CreatedTime string `json:"createdTime"` + PaidTime string `json:"paidTime"` + } `json:"data"` +} + +type WithdrawReq struct { + MerchantTradeNo string `json:"merchantTradeNo"` + Amount string `json:"amount"` + Currency string `json:"currency"` + Description string `json:"description"` + PayoutMethod struct { + Type string `json:"type"` // BANK_ACCOUNT + Mode string `json:"mode"` // IMPS + BankCode string `json:"bankCode"` + BankName string `json:"bankName"` + AccountNumber string `json:"accountNumber"` + PayeeName string `json:"payeeName"` + PayeePhone string `json:"payeePhone"` + PayeeEmail string `json:"payeeEmail"` + PayeeAddress string `json:"payeeAddress"` + // VPA string `json:"vpa"` + } `json:"payoutMethod"` + MerchantAttach string `json:"merchantAttach,omitempty"` + NotifyUrl string `json:"notifyUrl"` +} + +type WithdrawResp struct { + Code string `json:"code"` // OK + ErrorMessage string `json:"errorMessage"` + Data struct { + PayoutNo string `json:"payoutNo"` + MerchantTradeNo string `json:"merchantTradeNo"` + Amount string `json:"amount"` + Currency string `json:"currency"` + } `json:"data"` +} + +type WithdrawCallbackReq struct { + Event string `json:"event"` + Code string `json:"code"` + ErrorMessage string `json:"errorMessage"` + Data struct { + PayoutNo string `json:"payoutNo"` + MerchantTradeNo string `json:"merchantTradeNo"` + Amount string `json:"amount"` + Currency string `json:"currency"` + TotalFee string `json:"totalFee"` + Status string `json:"status"` // PENDING 待处理 PROCESSING 处理中 PAID 代付成功 FAILURE 代付失败 REVERSED 代付退票 CANCELLED 代付取消 + MerchantAttach string `json:"merchantAttach"` + CreatedTime string `json:"createdTime"` + PaidTime string `json:"paidTime"` + } `json:"data"` +} + +type QueryWithdrawReq struct { + MerchantTradeNo string `json:"merchantTradeNo"` +} + +type QueryWithdrawResp struct { + Code string `json:"code"` + ErrorMessage string `json:"errorMessage"` + Data struct { + PayoutNo string `json:"payoutNo"` + MerchantTradeNo string `json:"merchantTradeNo"` + Amount string `json:"amount"` + Currency string `json:"currency"` + TotalFee string `json:"totalFee"` + Status string `json:"status"` // PENDING 待处理 PROCESSING 处理中 PAID 代付成功 FAILURE 代付失败 REVERSED 代付退票 CANCELLED 代付取消 + MerchantAttach string `json:"merchantAttach"` + CreatedTime string `json:"createdTime"` + PaidTime string `json:"paidTime"` + } `json:"data"` +} + +type SignData struct { + AppId string + Sign string + Timestamp string + Nonce string +} + +func parseData(input string) SignData { + input = strings.TrimPrefix(input, "V2_SHA256 ") + pairs := strings.Split(input, ",") + data := SignData{} + for _, pair := range pairs { + keyValue := strings.Split(pair, "=") + if len(keyValue) == 2 { + key := keyValue[0] + value := keyValue[1] + switch key { + case "appId": + data.AppId = value + case "sign": + data.Sign = value + case "timestamp": + data.Timestamp = value + case "nonce": + data.Nonce = value + } + } + } + return data +} diff --git a/modules/pay/values/values.go b/modules/pay/values/values.go index ec2c4f6..3679d59 100644 --- a/modules/pay/values/values.go +++ b/modules/pay/values/values.go @@ -69,6 +69,7 @@ const ( MoonPay2 PayPlus LuckyinPay + EaniPay PayAll ) From 72011a8829f1341f2d552f476ac5bb0047291858 Mon Sep 17 00:00:00 2001 From: mofangmin Date: Wed, 21 Aug 2024 16:45:18 +0800 Subject: [PATCH 07/14] =?UTF-8?q?=E8=BD=AC=E7=9B=98=E6=B4=BB=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/activity.go | 1 + modules/web/handler/activity.go | 1 + 2 files changed, 2 insertions(+) diff --git a/common/activity.go b/common/activity.go index a3aaaa7..692e521 100644 --- a/common/activity.go +++ b/common/activity.go @@ -500,6 +500,7 @@ type LuckyData struct { LastSpinTime int64 SpinNum int NextSpinTIme int64 + Type int } type SpinInfo map[int]*LuckyData diff --git a/modules/web/handler/activity.go b/modules/web/handler/activity.go index b68cf3b..78fbc4d 100644 --- a/modules/web/handler/activity.go +++ b/modules/web/handler/activity.go @@ -1891,6 +1891,7 @@ func ActivityBetDrawInfo(c *gin.Context) { resp.SpinInfo = append(resp.SpinInfo, &common.LuckyData{ SpinNum: spinInfo.SpinNum, NextSpinTIme: spinInfo.NextSpinTIme, + Type: typ, }) } if update && a.UID > 0 { From c07517572bb4e8d8c2d06797a26f9a9658041f7b Mon Sep 17 00:00:00 2001 From: mofangmin Date: Thu, 22 Aug 2024 10:54:20 +0800 Subject: [PATCH 08/14] =?UTF-8?q?=E8=BD=AC=E7=9B=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/web/handler/activity.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/web/handler/activity.go b/modules/web/handler/activity.go index 78fbc4d..ca6d35c 100644 --- a/modules/web/handler/activity.go +++ b/modules/web/handler/activity.go @@ -1866,14 +1866,13 @@ func ActivityBetDrawInfo(c *gin.Context) { var types []int var confs []*common.ConfigActivityBetDraw for _, item := range resp.List { - if resp.Lucky >= item.Cost && vipInfo.Level >= item.VipUnlock { - call.PushRed(a.UID, pb.RedPointModule_RedPointFreeSpin, uint32(1)) - break - } if !util.SliceContain(types, item.Type) { types = append(types, item.Type) confs = append(confs, item) } + if resp.Lucky >= item.Cost && vipInfo.Level >= item.VipUnlock { + call.PushRed(a.UID, pb.RedPointModule_RedPointFreeSpin, uint32(1)) + } } now := time.Now() update := false From 8ab04ca908be95911728a346b590bd64f1cfc6e0 Mon Sep 17 00:00:00 2001 From: mofangmin Date: Thu, 22 Aug 2024 16:55:24 +0800 Subject: [PATCH 09/14] =?UTF-8?q?=E5=91=A8=E5=8D=A1=E6=B4=BB=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- call/activity.go | 28 +---- call/config.go | 28 +---- call/pay.go | 56 +++++----- cmd/build.sh | 2 +- common/activity.go | 51 ++++----- common/currency.go | 1 + modules/web/handler/activity.go | 184 ++++++++++---------------------- modules/web/handler/recharge.go | 82 +++++++------- modules/web/values/activity.go | 27 +++-- util/util.go | 76 +++++++++++++ 10 files changed, 248 insertions(+), 287 deletions(-) diff --git a/call/activity.go b/call/activity.go index 7aa6441..3a5290a 100644 --- a/call/activity.go +++ b/call/activity.go @@ -100,18 +100,8 @@ func ShouldShowActivityFirstRechargeBack(uid int) bool { if uid == 0 { return true } - now := time.Now().Unix() data := GetUserFirstRechargeBackData(uid) - if data.RechargeTime == 0 { - return true - } - if now-data.RechargeTime > 2*common.ActivityFirstRechargeBackTime { - return false - } - if now-data.RechargeTime > common.ActivityFirstRechargeBackTime && data.Lost == 0 { - return false - } - return true + return data.RewardTime == 0 } func UploadActivityData(uid, activityID, t int, amount int64) { @@ -137,18 +127,12 @@ func ShouldShowActivitySign(uid int) bool { return now-birth <= 6*common.OneDay } -func GetUserWeekCard(uid, level int) *common.ActivityWeekCardData { - data := &common.ActivityWeekCardData{UID: uid, Level: level} +func GetUserWeekCard(uid int) *common.ActivityWeekCardData { + data := &common.ActivityWeekCardData{UID: uid} db.Mysql().Get(data) return data } -func GetUserWeekCards(uid int) []*common.ActivityWeekCardData { - list := []*common.ActivityWeekCardData{} - db.Mysql().QueryAll(fmt.Sprintf("uid = %d", uid), "", &common.ActivityWeekCardData{}, &list) - return list -} - func ShouldShowActivityWeekCard(uid int) bool { if !IsActivityValid(common.ActivityIDWeekCard) { return false @@ -156,12 +140,6 @@ func ShouldShowActivityWeekCard(uid int) bool { if uid == 0 { return true } - cards := GetUserWeekCards(uid) - for _, v := range cards { - if v.Day > 0 { - return false - } - } return true } diff --git a/call/config.go b/call/config.go index 21d8a82..d9556bb 100644 --- a/call/config.go +++ b/call/config.go @@ -55,7 +55,7 @@ var ( configActivitySign []*common.ConfigActivitySign configActivityBreakGift []*common.ConfigActivityBreakGift configShareRobot []*common.ConfigShareRobot - configActivityWeekCard []*common.ConfigActivityWeekCard + configActivityWeekCard *common.ConfigActivityWeekCard configActivitySlots []*common.ConfigActivitySlots configActivityLuckyShop []*common.ConfigActivityLuckyShop configServerFlag []*common.ConfigServerFlag @@ -1353,36 +1353,18 @@ func GetConfigShareRobotByID(robotID int) *common.ConfigShareRobot { } func LoadConfigActivityWeekCard() (err error) { - list := []*common.ConfigActivityWeekCard{} - if _, err = db.Mysql().QueryAll("", "level", &common.ConfigActivityWeekCard{}, &list); err != nil { - log.Error("err:%v", err) + one := new(common.ConfigActivityWeekCard) + if err := db.Mysql().Get(one); err != nil { return err } - for _, v := range list { - if len(v.Range) > 0 { - err := json.Unmarshal([]byte(v.Range), &v.SubRange) - if err != nil { - log.Error("err:%v", err) - } - } - } - configActivityWeekCard = list + configActivityWeekCard = one return nil } -func GetConfigActivityWeekCard() []*common.ConfigActivityWeekCard { +func GetConfigActivityWeekCard() *common.ConfigActivityWeekCard { return configActivityWeekCard } -func GetConfigActivityWeekCardByLevel(level int) *common.ConfigActivityWeekCard { - for _, v := range configActivityWeekCard { - if v.Level == level { - return v - } - } - return nil -} - func LoadConfigActivitySlots() (err error) { list := []*common.ConfigActivitySlots{} if _, err = db.Mysql().QueryAll("", "rank_down", &common.ConfigActivitySlots{}, &list); err != nil { diff --git a/call/pay.go b/call/pay.go index e1b39f0..b84acd9 100644 --- a/call/pay.go +++ b/call/pay.go @@ -536,10 +536,31 @@ func PayActivity(r *common.RechargeOrder, notCharge bool, user *common.PlayerDBI func ActivityFirstRechargeBack(r *common.RechargeOrder) { if IsActivityValid(common.ActivityIDFirstRechargeBack) { conf := GetConfigActivityFirstRechargeBack() + p, _ := GetUserXInfo(r.UID, "birth") rechargeBackData := GetUserFirstRechargeBackData(r.UID) - if rechargeBackData.RechargeTime == 0 && r.Amount >= conf.MinRecharge { - db.Mysql().Create(&common.ActivityFirstRechargeBackData{UID: r.UID, RechargeTime: time.Now().Unix(), Amount: r.Amount}) + now := time.Now().Unix() + // 注册多少时间内 + if p.Birth+conf.CD <= now { + if rechargeBackData.Amount == 0 { + data := &common.ActivityFirstRechargeBackData{UID: r.UID, Amount: r.Amount} + if r.Amount >= conf.MinRecharge { + data.RechargeTime = now + } + db.Mysql().Create(data) + } else { + update := map[string]interface{}{ + "amount": gorm.Expr("amount + ?"), + } + if rechargeBackData.Amount+r.Amount >= conf.MinRecharge { + update["recharge_time"] = time.Now().Unix() + } + err := db.Mysql().Update(&common.ActivityFirstRechargeBackData{UID: r.UID}, update) + if err != nil { + log.Error("err:%v", err) + } + } } + } } @@ -601,34 +622,15 @@ func ActivityBreakGift(r *common.RechargeOrder, product *common.ConfigPayProduct } func ActivityWeekCard(r *common.RechargeOrder, product *common.ConfigPayProduct) { - level := product.Exi - card := GetUserWeekCard(r.UID, level) - con := GetConfigActivityWeekCardByLevel(level) + con := GetConfigActivityWeekCard() if con == nil { return } - if card.ID == 0 { - err := db.Mysql().Create(&common.ActivityWeekCardData{ - UID: r.UID, - Level: level, - DayReward: con.DayReward, - Day: con.Day, - // LastDraw: time.Now().Unix(), - }) - if err != nil { - return - } - } else { - if card.Day > 0 { - return - } - rows, err := db.Mysql().UpdateResW(&common.ActivityWeekCardData{}, map[string]interface{}{ - "day": con.Day, "day_reward": con.DayReward, "get_discount": 0, "last_draw": 0}, - fmt.Sprintf("uid = %d and level = %d and day = 0", r.UID, level)) - if err != nil || rows == 0 { - log.Error("err:%v", err) - return - } + rows, err := db.Mysql().UpdateRes(&common.ActivityWeekCardData{UID: r.UID}, map[string]interface{}{ + "recharge_time": time.Now().Unix()}) + if err != nil || rows == 0 { + log.Error("err:%v", err) + return } // ok UpdateCurrencyPro(&common.UpdateCurrency{ diff --git a/cmd/build.sh b/cmd/build.sh index 61a7d07..4b29610 100644 --- a/cmd/build.sh +++ b/cmd/build.sh @@ -8,4 +8,4 @@ cd pb/proto # go generate cd ../.. #go build main.go -CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o gameserver main.go \ No newline at end of file +CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o indiaprovider main.go \ No newline at end of file diff --git a/common/activity.go b/common/activity.go index 692e521..3258a7b 100644 --- a/common/activity.go +++ b/common/activity.go @@ -201,7 +201,8 @@ const ( type ConfigActivityFirstRechargeBack struct { ID int `gorm:"primary_key;AUTO_INCREMENT;column:id" json:"ID"` MinRecharge int64 `gorm:"column:min_recharge;type:bigint(20);default:10000000000;comment:最低充值额度" web:"min_recharge"` - MaxBack int64 `gorm:"column:max_back;type:bigint(20);default:-1;comment:最大返还额度比例" web:"max_back"` + MaxBack int64 `gorm:"column:max_back;type:bigint(20);default:0;comment:最大返还额度比例" web:"max_back"` + CD int64 `gorm:"column:cd;type:bigint(20);default:0;comment:持续时间" web:"cd"` } func (c *ConfigActivityFirstRechargeBack) TableName() string { @@ -212,7 +213,7 @@ type ActivityFirstRechargeBackData struct { UID int `gorm:"column:uid;not null;type:int(11);uniqueIndex:uid"` RechargeTime int64 `gorm:"column:recharge_time;type:bigint(20);default:0;comment:首次充值时间"` Amount int64 `gorm:"column:amount;type:bigint(20);default:0;comment:总充值金额"` - Lost int64 `gorm:"column:lost;type:bigint(20);default:0;comment:活动时间内总损失"` + Reward int64 `gorm:"column:reward;type:bigint(20);default:0;comment:给定金额"` RewardTime int64 `gorm:"column:reward_time;type:bigint(20);default:0;comment:领取时间"` } @@ -305,16 +306,9 @@ func (c *ConfigActivityBreakGift) TableName() string { } type ConfigActivityWeekCard struct { - ID int `gorm:"primarykey"` - Level int `gorm:"column:level;type:int(11);default:1;comment:等级" web:"level"` - ProductID int `gorm:"column:product_id;type:int(11);default:0;comment:商品id" web:"product_id"` - DayReward int64 `gorm:"column:day_reward;type:bigint(11);default:700000000;comment:每日可领取奖励" web:"day_reward"` - OriginPrice int64 `gorm:"column:origin_price;type:bigint(11);default:5000000000;comment:显示的原价" web:"origin_price"` - Day int `gorm:"column:day;type:int(11);default:6;comment:可领取天数" web:"day"` - Discount int `gorm:"column:discount;type:int(11);default:70;comment:折扣率,百分位" web:"discount"` - Rebate int `gorm:"column:rebate;type:int(11);default:240;comment:返利率,百分位" web:"rebate"` - Range string `gorm:"column:range;default:'[2000000000,100000000000]';type:varchar(255);comment:充值可用范围"` - SubRange []int64 `gorm:"-" json:"-"` + ID int `gorm:"primarykey"` + MiniLimit int64 `gorm:"column:mini_limit;type:bigint(20);default:0;comment:下限" web:"mini_limit"` // 下限 + RewardAmount int64 `gorm:"column:reward_amount;type:bigint(20);default:0;comment:前六天奖励金额" web:"reward_amount"` // 前六天奖励金额 } func (c *ConfigActivityWeekCard) TableName() string { @@ -326,13 +320,12 @@ const ( ) type ActivityWeekCardData struct { - ID int `gorm:"primarykey"` - UID int `gorm:"column:uid;type:int(11);uniqueIndex:ul"` - Level int `gorm:"column:level;type:int(11);default:0;uniqueIndex:ul;comment:周卡等级"` - DayReward int64 `gorm:"column:day_reward;type:bigint(11);default:700000000;comment:每日可领取奖励"` - Day int `gorm:"column:day;type:int(11);default:6;comment:可领取天数"` - LastDraw int64 `gorm:"column:last_draw;type:bigint(20);default:0;comment:上次领取时间"` - GetDiscount int `gorm:"column:get_discount;type:tinyint(4);default:0;comment:前面是否已经获得了折扣券"` + ID int `gorm:"primarykey"` + UID int `gorm:"column:uid;type:int(11);uniqueIndex:ul"` + Rewards string `gorm:"column:rewards;type:varchar(256);comment:前六天领取奖励"` + Day int `gorm:"column:day;type:int(11);default:0;comment:已经领取天数"` + LastDraw int64 `gorm:"column:last_draw;type:bigint(20);default:0;comment:上次领取时间"` + RechargeTime int64 `gorm:"column:recharge_time;type:bigint(20);default:0;comment:充值时间"` } func (c *ActivityWeekCardData) TableName() string { @@ -500,18 +493,16 @@ type LuckyData struct { LastSpinTime int64 SpinNum int NextSpinTIme int64 - Type int + SpinCount int // 总次数 } -type SpinInfo map[int]*LuckyData - -func (m SpinInfo) Value() (driver.Value, error) { +func (m LuckyData) Value() (driver.Value, error) { return json.Marshal(m) } -func (m *SpinInfo) Scan(value interface{}) error { +func (m *LuckyData) Scan(value interface{}) error { if value == nil { - *m = SpinInfo{} + *m = LuckyData{} return nil } // 将数据库中的 JSON 字符串解析为 map @@ -520,17 +511,17 @@ func (m *SpinInfo) Scan(value interface{}) error { return errors.New("type assertion to []byte failed") } if len(bytes) == 0 { - *m = SpinInfo{} + *m = LuckyData{} return nil } return json.Unmarshal(bytes, &m) } type ActivityBetDrawData struct { - ID int `gorm:"primarykey"` - UID int `gorm:"column:uid;not null;type:int(11);uniqueIndex:uid"` - Lucky int64 `gorm:"column:lucky;;not null;type:bigint(20);comment:幸运值" web:"lucky"` - SpinInfo SpinInfo `gorm:"column:spin_info;;not null;type:varchar(256);comment:转盘信息" web:"spinInfo"` + ID int `gorm:"primarykey"` + UID int `gorm:"column:uid;not null;type:int(11);uniqueIndex:uid"` + Lucky int64 `gorm:"column:lucky;;not null;type:bigint(20);comment:幸运值" web:"lucky"` + SpinInfo LuckyData `gorm:"column:spin_info;;not null;type:varchar(256);comment:转盘信息" web:"spinInfo"` } func (c *ActivityBetDrawData) TableName() string { diff --git a/common/currency.go b/common/currency.go index c99d194..43e1498 100644 --- a/common/currency.go +++ b/common/currency.go @@ -28,6 +28,7 @@ const ( CurrencyResourceBonus // 额外赠送 CurrencyResourceRechargeBonus // bonus充值 CurrencyResourceFirstRecharge // 首充 + CurrencyResourceWeekCard // 周卡 CurrencyResourceAll ) diff --git a/modules/web/handler/activity.go b/modules/web/handler/activity.go index ca6d35c..bb0a2a4 100644 --- a/modules/web/handler/activity.go +++ b/modules/web/handler/activity.go @@ -12,6 +12,7 @@ import ( "server/pb" "server/util" "sort" + "strings" "time" "github.com/gin-gonic/gin" @@ -574,42 +575,6 @@ func ActivityFreeSpinDraw(c *gin.Context) { resp := &values.ActivityFreeSpinDrawResp{} a.Data = resp - // 首次旋转,给予固定奖励 - // if freeSpin.LastSpin == 0 { - // items := call.GetConfigActivityFreeSpinByType(common.ActivityFreeSpinItemRandomCash) - // if len(items) == 0 { - // a.Code = values.CodeRetry - // return - // } - // err := db.Mysql().Create(&common.ActivityFreeSpinData{UID: a.UID, LastSpin: time.Now().Unix()}) - // if err != nil { - // a.Code = values.CodeRetry - // return - // } - // resp.Reward = config.GetConfig().Web.FreeSpinFirst - // if resp.Reward == 0 { - // resp.Reward = 5 * common.DecimalDigits - // } - // _, err = call.UpdateCurrencyPro(&common.UpdateCurrency{ - // CurrencyBalance: &common.CurrencyBalance{ - // Type: common.CurrencyINR, - // UID: a.UID, - // Event: common.CurrencyEventActivityFreeSpin, - // Value: resp.Reward, - // ChannelID: a.Channel, - // NeedBet: call.GetConfigCurrencyResourceNeedBet(common.CurrencyResourceBonus, resp.Reward), - // }, - // }) - // if err != nil { - // a.Code = values.CodeRetry - // return - // } - // ran := rand.Intn(len(items)) - // resp.ID = items[ran].ID - // call.UploadActivityData(a.UID, common.ActivityIDFreeSpin, common.ActivityDataJoin, resp.Reward) - // return - // } - con := call.GetConfigActivityFreeSpin() if con == nil { a.Code = values.CodeRetry @@ -671,7 +636,7 @@ func ActivityFirstRechargeBackInfo(c *gin.Context) { conf := call.GetConfigActivityFirstRechargeBack() a.Data = resp data := call.GetUserFirstRechargeBackData(a.UID) - log.Debug("ActivityFirstRechargeBackInfo:%+v", data) + resp.NeedRechargeAmount = conf.MinRecharge resp.ProductList = call.GetConfigPayProductByActivityID(common.ActivityIDFirstRechargeBack) resp.Recharge = data.Amount resp.BackPer = conf.MaxBack @@ -688,9 +653,15 @@ func ActivityFirstRechargeBackInfo(c *gin.Context) { val = 0 } val = val * conf.MaxBack / 100 + now := time.Now().Unix() + p, _ := call.GetUserXInfo(a.UID, "birth") + if p.Birth+conf.CD >= now { + db.Mysql().Update(&common.ActivityFirstRechargeBackData{UID: a.UID}, map[string]interface{}{ + "reward": val, + }) + } resp.Back = val - resp.PayAmount = rand.Int63n(1000000) + 10000 - resp.DrawTime = data.RechargeTime + common.ActivityFirstRechargeBackTime + resp.DrawTime = p.Birth + conf.CD } func ActivityFirstRechargeBackDraw(c *gin.Context) { @@ -703,21 +674,17 @@ func ActivityFirstRechargeBackDraw(c *gin.Context) { } conf := call.GetConfigActivityFirstRechargeBack() data := call.GetUserFirstRechargeBackData(a.UID) - val := data.Amount - call.GetUserCurrencyTotal(a.UID, common.CurrencyINR) - if val <= 0 { - return - } if time.Now().Unix()-data.RechargeTime < common.ActivityFirstRechargeBackTime { log.Error("not ActivityFirstRechargeBackDraw time:%+v", data) a.Code = values.CodeRetry return } - rows, err := db.Mysql().UpdateRes(&common.ActivityFirstRechargeBackData{UID: a.UID}, map[string]interface{}{"lost": 0, "reward_time": time.Now().Unix()}) + rows, err := db.Mysql().UpdateRes(&common.ActivityFirstRechargeBackData{UID: a.UID}, map[string]interface{}{"reward_time": time.Now().Unix()}) if err != nil || rows == 0 { a.Code = values.CodeRetry return } - val = val * conf.MaxBack / 100 + val := data.Reward * conf.MaxBack / 100 _, err = call.UpdateCurrencyPro(&common.UpdateCurrency{ CurrencyBalance: &common.CurrencyBalance{ UID: a.UID, @@ -1299,42 +1266,31 @@ func ActivityWeekCardInfo(c *gin.Context) { if !a.CheckActivityExpire(common.ActivityIDWeekCard) { return } - cons := call.GetConfigActivityWeekCard() - list := call.GetUserWeekCards(a.UID) resp := &values.ActivityWeekCardInfoResp{} a.Data = resp - for _, v := range cons { - product := call.GetConfigPayProductByID(v.ProductID) - if product == nil { - continue - } - one := values.OneWeekCard{ - Level: v.Level, - Rebate: fmt.Sprintf("%d", v.Rebate) + "%", - OriginPrice: v.OriginPrice, - Price: product.Amount, - Reward: product.Value, - DayReward: v.DayReward, - DayCount: v.Day, - Discount: fmt.Sprintf("%d", 100-v.Discount), - Next: -1, - ProductID: v.ProductID, - TotalReward: v.DayReward*int64(v.Day) + product.Value, + cons := call.GetConfigActivityWeekCard() + cardInfo := call.GetUserWeekCard(a.UID) + if cardInfo.ID <= 0 { + rewardList, err := util.GenerateSequence(cons.RewardAmount, cons.MiniLimit) + if err != nil { + log.Error("err:%v", err) } - for _, k := range list { - if k.Level == v.Level && k.Day > 0 { - one.DayReward = k.DayReward - one.Day = k.Day - if !util.IsSameDayTimeStamp(k.LastDraw, time.Now().Unix()) { - one.Next = 0 - } else { - one.Next = util.GetZeroTime(time.Now().AddDate(0, 0, 1)).Unix() - k.LastDraw - } - break - } + if len(rewardList) == 6 { + rewardList = append(rewardList, 0) } - resp.List = append(resp.List, one) + resp.RewardList = rewardList + cardInfo.Rewards = strings.Join(util.Int64SliceToStringSlice(rewardList), ",") + db.Mysql().Create(cardInfo) + } + if resp.RewardList == nil { + resp.RewardList, _ = util.StringToInt64Slice(cardInfo.Rewards, ",") + } + if !util.IsSameDayTimeStamp(time.Now().Unix(), cardInfo.LastDraw) { + resp.Status = true } + resp.RewardDay = cardInfo.Day + resp.ChannelList = call.GetConfigPayChannelsByID(common.CurrencyINR) + resp.ProductList = call.GetConfigPayProductByActivityID(common.ActivityIDWeekCard) } func ActivityWeekCardDraw(c *gin.Context) { @@ -1349,56 +1305,47 @@ func ActivityWeekCardDraw(c *gin.Context) { if !a.S(req) { return } - card := call.GetUserWeekCard(a.UID, req.Level) + card := call.GetUserWeekCard(a.UID) if card.ID == 0 { a.Code = values.CodeRetry return } - if card.Day <= 0 { - a.Code = values.CodeRetry - return - } now := time.Now().Unix() if util.IsSameDayTimeStamp(now, card.LastDraw) { a.Code = values.CodeRetry + a.Msg = "today has reward" return } - rows, err := db.Mysql().UpdateRes(&common.ActivityWeekCardData{UID: a.UID, Level: req.Level, Day: card.Day}, - map[string]interface{}{"day": gorm.Expr("day - 1"), "last_draw": now}) + rewards, _ := util.StringToInt64Slice(card.Rewards, ",") + rows, err := db.Mysql().UpdateRes(&common.ActivityWeekCardData{UID: a.UID}, + map[string]interface{}{"day": gorm.Expr("day + 1"), "last_draw": now}) if rows == 0 || err != nil { log.Error("err:%v", err) a.Code = values.CodeRetry return } + var reward int64 + if card.Day < len(rewards) { + reward = rewards[card.Day] * common.DecimalDigits + } else { + // 第几天折扣券 + } + resp := &values.ActivityWeekCardDrawResp{ - Reward: card.DayReward, + Reward: reward, } a.Data = resp call.UpdateCurrencyPro(&common.UpdateCurrency{ CurrencyBalance: &common.CurrencyBalance{ UID: a.UID, Type: common.CurrencyINR, - Value: card.DayReward, + Value: reward, Event: common.CurrencyEventActivityWeekCard, ChannelID: a.Channel, - NeedBet: call.GetConfigCurrencyResourceNeedBet(common.CurrencyResourceBonus, card.DayReward), + NeedBet: call.GetConfigCurrencyResourceNeedBet(common.CurrencyResourceBonus, reward), }, }) - con := call.GetConfigActivityWeekCardByLevel(card.Level) - if con != nil { - // 最后一天必得一次 - if card.Day == 1 { - call.AddUserDiscountTicket(a.UID, con.Discount) - resp.DiscountTicket = fmt.Sprintf("%d", 100-con.Discount) - } else if card.GetDiscount == 0 { // 未领取过则随机一次 - ran := rand.Intn(card.Day) - if ran == 0 { - db.Mysql().Update(&common.ActivityWeekCardData{UID: a.UID, Level: req.Level}, map[string]interface{}{"get_discount": 1}) - call.AddUserDiscountTicket(a.UID, con.Discount) - resp.DiscountTicket = fmt.Sprintf("%d", 100-con.Discount) - } - } - } + } func ActivitySlotsInfo(c *gin.Context) { @@ -1863,41 +1810,24 @@ func ActivityBetDrawInfo(c *gin.Context) { Lucky: drawInfo.Lucky, } a.Data = resp - var types []int - var confs []*common.ConfigActivityBetDraw for _, item := range resp.List { - if !util.SliceContain(types, item.Type) { - types = append(types, item.Type) - confs = append(confs, item) - } if resp.Lucky >= item.Cost && vipInfo.Level >= item.VipUnlock { call.PushRed(a.UID, pb.RedPointModule_RedPointFreeSpin, uint32(1)) } } now := time.Now() update := false - for _, item := range confs { - typ := item.Type - spinInfo := drawInfo.SpinInfo[typ] - if spinInfo == nil { - drawInfo.SpinInfo[typ] = &common.LuckyData{} - spinInfo = drawInfo.SpinInfo[typ] - } - if !util.IsSameDayTimeStamp(spinInfo.LastSpinTime, now.Unix()) { - spinInfo.SpinNum = 0 - update = true - } - resp.SpinInfo = append(resp.SpinInfo, &common.LuckyData{ - SpinNum: spinInfo.SpinNum, - NextSpinTIme: spinInfo.NextSpinTIme, - Type: typ, - }) + if !util.IsSameDayTimeStamp(drawInfo.SpinInfo.LastSpinTime, now.Unix()) { + drawInfo.SpinInfo.SpinNum = 0 + update = true } if update && a.UID > 0 { db.Mysql().Update(&common.ActivityBetDrawData{UID: a.UID}, map[string]interface{}{ "spin_info": drawInfo.SpinInfo, }) } + drawInfo.SpinInfo.SpinCount = confList[0].LimitNum + resp.SpinInfo = append(resp.SpinInfo, drawInfo.SpinInfo) call.UploadActivityData(a.UID, common.ActivityIDBetDraw, common.ActivityDataClick, 0) } @@ -1923,11 +1853,7 @@ func ActivityBetDrawDraw(c *gin.Context) { drawInfo := common.ActivityBetDrawData{UID: a.UID} db.Mysql().Get(&drawInfo) now := time.Now() - spinInfo, ok := drawInfo.SpinInfo[req.WheelType] - if !ok { - drawInfo.SpinInfo[req.WheelType] = &common.LuckyData{} - spinInfo = drawInfo.SpinInfo[req.WheelType] - } + spinInfo := drawInfo.SpinInfo // step:判断cd if spinInfo.LastSpinTime != 0 && now.Unix()-spinInfo.LastSpinTime < conf.Cd { a.Code = values.CodeRetry @@ -1959,7 +1885,7 @@ func ActivityBetDrawDraw(c *gin.Context) { UID: a.UID, }, map[string]interface{}{ "lucky": gorm.Expr("lucky - ?", conf.Cost), - "spin_info": drawInfo.SpinInfo, + "spin_info": spinInfo, }) if err != nil { a.Code = values.CodeRetry diff --git a/modules/web/handler/recharge.go b/modules/web/handler/recharge.go index 9236950..649a661 100644 --- a/modules/web/handler/recharge.go +++ b/modules/web/handler/recharge.go @@ -1,7 +1,6 @@ package handler import ( - "encoding/json" "fmt" "server/call" "server/config" @@ -110,15 +109,16 @@ func RechargeInfo(c *gin.Context) { TimeLeft: diff, // Range: , } - con := call.GetConfigActivityWeekCardByLevel(1) - if con != nil { - resp.DiscountTicket.Range = con.SubRange - } - if discount > 50 { - resp.DiscountTicket.Level = 1 - } else { - resp.DiscountTicket.Level = 2 - } + // 折扣券 + // con := call.GetConfigActivityWeekCardByLevel(1) + // if con != nil { + // resp.DiscountTicket.Range = con.SubRange + // } + // if discount > 50 { + // resp.DiscountTicket.Level = 1 + // } else { + // resp.DiscountTicket.Level = 2 + // } } } } @@ -253,39 +253,39 @@ func NewRechargeImp(req *values.RechargeReq, uid, cid int, ip string) *RechargeI ProductID: req.ProductID, } // 只有商城购买才能使用优惠券 - ticketCon := call.GetConfigActivityWeekCardByLevel(1) + // ticketCon := call.GetConfigActivityWeekCardByLevel(1) if req.ProductID == 0 { // 首先判断折扣券 - if ticketCon != nil && len(ticketCon.SubRange) == 2 { - if req.Amount >= ticketCon.SubRange[0] && req.Amount <= ticketCon.SubRange[1] { - discount := -1 - var ticket *common.PlayerItems - // 判断是否有折扣券 - tickets := call.GetUserValidItems(uid, common.ItemDiscountTicket) - for i, v := range tickets { - thisDiscount := v.Exi1 - diff := v.Time + common.ActivityWeekCardTicketExpireTime - time.Now().Unix() - if diff <= 0 { - id := v.ID - util.Go(func() { - db.Mysql().Update(&common.PlayerItems{ID: id}, map[string]interface{}{"status": common.ItemStatusInvalid}) - }) - continue - } - if discount < 0 || thisDiscount < discount { - discount = thisDiscount - ticket = tickets[i] - } - } - if discount > 0 { - ticketData := common.ActivityRechargeData{ID: common.ItemDiscountTicket, I1: ticket.Exi1, I2: req.Amount} - ticketByte, _ := json.Marshal(ticketData) - order.Extra = string(ticketByte) - req.Amount = common.RoundCurrency(common.CurrencyINR, req.Amount*int64(discount)/100) - order.Amount = req.Amount - } - } - } + // if ticketCon != nil && len(ticketCon.SubRange) == 2 { + // if req.Amount >= ticketCon.SubRange[0] && req.Amount <= ticketCon.SubRange[1] { + // discount := -1 + // var ticket *common.PlayerItems + // // 判断是否有折扣券 + // tickets := call.GetUserValidItems(uid, common.ItemDiscountTicket) + // for i, v := range tickets { + // thisDiscount := v.Exi1 + // diff := v.Time + common.ActivityWeekCardTicketExpireTime - time.Now().Unix() + // if diff <= 0 { + // id := v.ID + // util.Go(func() { + // db.Mysql().Update(&common.PlayerItems{ID: id}, map[string]interface{}{"status": common.ItemStatusInvalid}) + // }) + // continue + // } + // if discount < 0 || thisDiscount < discount { + // discount = thisDiscount + // ticket = tickets[i] + // } + // } + // if discount > 0 { + // ticketData := common.ActivityRechargeData{ID: common.ItemDiscountTicket, I1: ticket.Exi1, I2: req.Amount} + // ticketByte, _ := json.Marshal(ticketData) + // order.Extra = string(ticketByte) + // req.Amount = common.RoundCurrency(common.CurrencyINR, req.Amount*int64(discount)/100) + // order.Amount = req.Amount + // } + // } + // } } re := call.GetRechargeInfo(uid) notCharge := re.TotalRecharge == 0 diff --git a/modules/web/values/activity.go b/modules/web/values/activity.go index 14262ba..6610916 100644 --- a/modules/web/values/activity.go +++ b/modules/web/values/activity.go @@ -44,15 +44,16 @@ type ActivityFreeSpinDrawResp struct { // Recharge 充值总额 // Back 可领取的总额 type ActivityFirstRechargeBackInfoResp struct { - Recharge int64 - Back int64 - BackPer int64 - CanRecharge bool - PayAmount int64 // 支付金额 - DrawTime int64 // 领取时间 - Draw bool // 是否领取 - ChannelList []*common.ConfigPayChannels - ProductList []*common.ConfigPayProduct + Recharge int64 + Back int64 + BackPer int64 + CanRecharge bool + PayAmount int64 // 支付金额 + DrawTime int64 // 领取时间 + Draw bool // 是否领取 + NeedRechargeAmount int64 // + ChannelList []*common.ConfigPayChannels + ProductList []*common.ConfigPayProduct } // ID 物品id @@ -137,7 +138,11 @@ type OneWeekCard struct { } type ActivityWeekCardInfoResp struct { - List []OneWeekCard + RewardList []int64 // 奖励列表 + RewardDay int // 领取天数 + Status bool // 是否可领取 + ChannelList []*common.ConfigPayChannels + ProductList []*common.ConfigPayProduct } // Level 领取的周卡的等级 @@ -265,7 +270,7 @@ type ActivitySuperDrawResp struct { type ActivityBetDrawInfoResp struct { List []*common.ConfigActivityBetDraw // 配置 Lucky int64 // 幸运值 - SpinInfo []*common.LuckyData + SpinInfo []common.LuckyData } type ActivityBetDrawDrawReq struct { diff --git a/util/util.go b/util/util.go index 4d0a5d8..a40bdc4 100644 --- a/util/util.go +++ b/util/util.go @@ -11,6 +11,7 @@ import ( "os" "reflect" "regexp" + "sort" "strconv" "strings" "time" @@ -965,3 +966,78 @@ func HashUnmarshal(data map[string]string, v interface{}) error { return nil } + +func Int64SliceToStringSlice(int64Slice []int64) []string { + stringSlice := make([]string, len(int64Slice)) + for i, num := range int64Slice { + stringSlice[i] = strconv.FormatInt(num, 10) + } + return stringSlice +} + +func StringToInt64Slice(s, sep string) ([]int64, error) { + // 使用分隔符拆分字符串 + parts := strings.Split(s, sep) + + // 创建一个空的 []int64 切片用于存储转换后的数字 + int64Slice := make([]int64, len(parts)) + + // 遍历拆分后的字符串部分并转换为 int64 + for i, part := range parts { + num, err := strconv.ParseInt(part, 10, 64) + if err != nil { + return nil, err // 如果转换失败,返回错误 + } + int64Slice[i] = num + } + + return int64Slice, nil +} + +// 通过总数Count分成一个递增数列 +func GenerateSequence(totalSum, minValue int64) ([]int64, error) { + length := 6 + + // 初步生成递增数列 [minValue, minValue+1, ..., minValue+5] + sequence := make([]int64, length) + for i := 0; i < length; i++ { + sequence[i] = minValue + int64(i) + } + + // 计算初步数列的总和 + sumInitial := (2*minValue + int64(length-1)) * int64(length) / 2 + + // 如果初步数列的总和已经大于 totalSum,则无法生成 + if sumInitial > totalSum { + return nil, fmt.Errorf("cannot generate a sequence with the given totalSum and minValue") + } + + // 计算剩余需要分配的值 + remaining := totalSum - sumInitial + + // 设置随机种子 + rand.Seed(time.Now().UnixNano()) + + // 平均分配剩余的值,同时减少极端情况的出现 + for remaining > 0 { + // 每次迭代从头到尾随机增量分配,减少单个元素过度增长 + for i := 0; i < length && remaining > 0; i++ { + // 确保递增,计算可能的最大增量 + maxIncrement := remaining / int64(length-i) + if i > 0 && sequence[i] <= sequence[i-1] { + maxIncrement = sequence[i-1] - sequence[i] + 1 + } + + // 随机选择增量 + if maxIncrement > 0 { + randIncrement := rand.Int63n(maxIncrement + 1) + sequence[i] += randIncrement + remaining -= randIncrement + } + } + } + sort.Slice(sequence, func(i, j int) bool { + return sequence[i] < sequence[j] + }) + return sequence, nil +} From 967cc8bbfaa093775ef5d48a760921690e9a4d08 Mon Sep 17 00:00:00 2001 From: mofangmin Date: Fri, 23 Aug 2024 15:11:03 +0800 Subject: [PATCH 10/14] =?UTF-8?q?=E5=91=A8=E5=8D=A1=E6=B4=BB=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- call/activity.go | 16 +- call/item.go | 4 +- call/pay.go | 6 +- common/activity.go | 19 +- common/config.go | 4 +- common/excel.go | 900 ++++++++++++++++++++ common/player.go | 3 +- modules/backend/handler/notice/broadcast.go | 127 +++ modules/backend/handler/notice/notice.go | 121 +++ modules/backend/migrate.go | 2 + modules/backend/routers/routers.go | 1 + modules/backend/routers/routiers_notice.go | 21 + modules/backend/values/notice.go | 48 ++ modules/web/handler/activity.go | 88 +- modules/web/handler/recharge.go | 69 +- modules/web/handler/withdraw.go | 1 + modules/web/middleware/token.go | 1 + modules/web/values/activity.go | 16 +- modules/web/values/pay.go | 5 +- util/util.go | 51 +- 20 files changed, 1389 insertions(+), 114 deletions(-) create mode 100644 common/excel.go create mode 100644 modules/backend/handler/notice/broadcast.go create mode 100644 modules/backend/handler/notice/notice.go create mode 100644 modules/backend/routers/routiers_notice.go create mode 100644 modules/backend/values/notice.go diff --git a/call/activity.go b/call/activity.go index 3a5290a..9459728 100644 --- a/call/activity.go +++ b/call/activity.go @@ -100,8 +100,22 @@ func ShouldShowActivityFirstRechargeBack(uid int) bool { if uid == 0 { return true } + now := time.Now().Unix() + conf := GetConfigActivityFirstRechargeBack() + p, _ := GetUserXInfo(uid, "birth") data := GetUserFirstRechargeBackData(uid) - return data.RewardTime == 0 + val := int64(0) + if data.RechargeTime > 0 { + rechargeInfo := GetRechargeInfo(uid) + val = data.Amount - GetUserCurrencyTotal(uid, common.CurrencyINR) + rechargeInfo.TotalWithdrawing + if val < 0 { + val = 0 + } + } + if now >= p.Birth+conf.CD && val == 0 || data.RewardTime > 0 { + return false + } + return true } func UploadActivityData(uid, activityID, t int, amount int64) { diff --git a/call/item.go b/call/item.go index e16a2f1..5e2dd57 100644 --- a/call/item.go +++ b/call/item.go @@ -35,6 +35,6 @@ func GetUserBestDiscountTicket(uid int) *common.PlayerItems { return nil } -func AddUserDiscountTicket(uid, exi1 int) { - db.Mysql().Create(&common.PlayerItems{UID: uid, ItemID: common.ItemDiscountTicket, Time: time.Now().Unix(), Status: common.ItemStatusNormal, Exi1: exi1}) +func AddUserDiscountTicket(uid int, exi1, exi2 int64) { + db.Mysql().Create(&common.PlayerItems{UID: uid, ItemID: common.ItemDiscountTicket, Time: time.Now().Unix(), Status: common.ItemStatusNormal, Exi1: exi1, Exi2: exi2}) } diff --git a/call/pay.go b/call/pay.go index b84acd9..6d6e98c 100644 --- a/call/pay.go +++ b/call/pay.go @@ -540,7 +540,7 @@ func ActivityFirstRechargeBack(r *common.RechargeOrder) { rechargeBackData := GetUserFirstRechargeBackData(r.UID) now := time.Now().Unix() // 注册多少时间内 - if p.Birth+conf.CD <= now { + if now <= p.Birth+conf.CD { if rechargeBackData.Amount == 0 { data := &common.ActivityFirstRechargeBackData{UID: r.UID, Amount: r.Amount} if r.Amount >= conf.MinRecharge { @@ -549,7 +549,7 @@ func ActivityFirstRechargeBack(r *common.RechargeOrder) { db.Mysql().Create(data) } else { update := map[string]interface{}{ - "amount": gorm.Expr("amount + ?"), + "amount": gorm.Expr("amount + ?", r.Amount), } if rechargeBackData.Amount+r.Amount >= conf.MinRecharge { update["recharge_time"] = time.Now().Unix() @@ -627,7 +627,7 @@ func ActivityWeekCard(r *common.RechargeOrder, product *common.ConfigPayProduct) return } rows, err := db.Mysql().UpdateRes(&common.ActivityWeekCardData{UID: r.UID}, map[string]interface{}{ - "recharge_time": time.Now().Unix()}) + "recharge_time": time.Now().Unix(), "day": 0, "recharge_amount": r.Amount}) if err != nil || rows == 0 { log.Error("err:%v", err) return diff --git a/common/activity.go b/common/activity.go index 3258a7b..450787a 100644 --- a/common/activity.go +++ b/common/activity.go @@ -307,8 +307,10 @@ func (c *ConfigActivityBreakGift) TableName() string { type ConfigActivityWeekCard struct { ID int `gorm:"primarykey"` - MiniLimit int64 `gorm:"column:mini_limit;type:bigint(20);default:0;comment:下限" web:"mini_limit"` // 下限 - RewardAmount int64 `gorm:"column:reward_amount;type:bigint(20);default:0;comment:前六天奖励金额" web:"reward_amount"` // 前六天奖励金额 + DayOneReward int64 `gorm:"column:day_one_reward;type:bigint(20);default:0;comment:第一天奖励" web:"day_one_reward"` // 下限 + MiniLimit int64 `gorm:"column:mini_limit;type:bigint(20);default:0;comment:下限" web:"mini_limit"` // 下限 + RewardAmount int64 `gorm:"column:reward_amount;type:bigint(20);default:0;comment:第二到第6天奖励金额" web:"reward_amount"` // 第二到第6天奖励金额 + Discount int64 `gorm:"column:discount;type:bigint(20);default:0;comment:第二到第6天奖励金额" web:"discount"` // 满减券折扣 } func (c *ConfigActivityWeekCard) TableName() string { @@ -320,12 +322,13 @@ const ( ) type ActivityWeekCardData struct { - ID int `gorm:"primarykey"` - UID int `gorm:"column:uid;type:int(11);uniqueIndex:ul"` - Rewards string `gorm:"column:rewards;type:varchar(256);comment:前六天领取奖励"` - Day int `gorm:"column:day;type:int(11);default:0;comment:已经领取天数"` - LastDraw int64 `gorm:"column:last_draw;type:bigint(20);default:0;comment:上次领取时间"` - RechargeTime int64 `gorm:"column:recharge_time;type:bigint(20);default:0;comment:充值时间"` + ID int `gorm:"primarykey"` + UID int `gorm:"column:uid;type:int(11);uniqueIndex:ul"` + Rewards string `gorm:"column:rewards;type:varchar(256);comment:前5天领取奖励"` + Day int `gorm:"column:day;type:int(11);default:0;comment:已经领取天数"` + LastDraw int64 `gorm:"column:last_draw;type:bigint(20);default:0;comment:上次领取时间"` + RechargeTime int64 `gorm:"column:recharge_time;type:bigint(20);default:0;comment:充值时间"` + RechargeAmount int64 `gorm:"column:recharge_amount;type:bigint(20);default:0;comment:充值金额"` } func (c *ActivityWeekCardData) TableName() string { diff --git a/common/config.go b/common/config.go index c8bb998..151a115 100644 --- a/common/config.go +++ b/common/config.go @@ -584,9 +584,9 @@ type ConfigActivityBetDraw struct { Cost int64 `gorm:"column:cost;type:int(11);default:0;comment:消耗幸运值" web:"cost"` Reward int64 `gorm:"column:reward;type:bigint(20);comment:奖励" web:"reward"` Weight int64 `gorm:"column:weight;type:bigint(20);comment:权重" web:"weight"` - VipUnlock int `gorm:"column:vip_unlock;type:int(11);comment:vip解锁等级" web:"vipUnlock"` + VipUnlock int `gorm:"column:vip_unlock;type:int(11);comment:vip解锁等级" web:"vip_unlock"` Cd int64 `gorm:"column:cd;type:bigint(20);comment:冷却时间" web:"cd"` - LimitNum int `gorm:"column:limit_num;type:int(11);comment:每日领取次数" web:"limitNum"` + LimitNum int `gorm:"column:limit_num;type:int(11);comment:每日领取次数" web:"limit_num"` } func (c *ConfigActivityBetDraw) TableName() string { diff --git a/common/excel.go b/common/excel.go new file mode 100644 index 0000000..20cb5be --- /dev/null +++ b/common/excel.go @@ -0,0 +1,900 @@ +package common + +import ( + "encoding/json" + "fmt" +) + +// SheetRoomConfig 房间通用结构 +type SheetRoomConfig struct { + GameID int `json:"GameID" redis:"GameID" table:"game_id"` + RoomID int `json:"RoomID" redis:"RoomID" table:"room_id"` + RoomName string `json:"RoomName" redis:"RoomName" table:"room_name"` + RoomType int `json:"RoomType" redis:"RoomType" table:"room_type"` + MinPlayer int `json:"MinPlayer" redis:"MinPlayer" table:"min_players"` + MaxPlayer int `json:"MaxPlayer" redis:"MaxPlayer" table:"max_players"` + StartTime int `json:"StartTime" redis:"StartTime" table:"start_time"` + IsOpen bool `json:"IsOpen" redis:"IsOpen" table:"is_open"` + BootRecharge int `json:"BootRecharge" redis:"BootRecharge" table:"boot_recharge"` + CurrenyType CurrencyType `json:"CurrenyType" redis:"CurrenyType" table:"currency_type"` + CarryInitialValue int64 `json:"CarryInitial" redis:"CarryInitial" table:"carry_initial_value"` + Boot int `json:"Boot" redis:"Boot" table:"boot"` + TurnTime int `json:"TurnTime" redis:"TurnTime" table:"turn_time"` + MinTakeIn int64 `json:"MinTakeIn" redis:"MinTakeIn" table:"min_buyin"` + MaxTakeIn int64 `json:"MaxTakeIn" redis:"MaxTakeIn" table:"max_buyin"` + MaxBlinds int `json:"MaxBlinds" redis:"MaxBlinds" table:"max_blinds"` + TurnLimit int `json:"TurnLimit" redis:"TurnLimit" table:"turn_limit"` + ChaalLimit int `json:"ChaalLimit" redis:"ChaalLimit" table:"chaal_limit"` + PotLimit int64 `json:"PotLimit" redis:"PotLimit" table:"pot_limit"` + IsCharge bool `json:"IsCharge" redis:"IsCharge" table:"is_charge"` + ChargeType int `json:"ChargeType" redis:"ChargeType" table:"charge_type"` + ChargeMode int `json:"ChargeMode" redis:"ChargeMode" table:"charge_mode"` + Charge int64 `json:"Charge" redis:"Charge" table:"charge"` + PlayTime int `json:"PlayTime" redis:"PlayTime" table:"playing_time"` + BetTime int `json:"BetTime" redis:"BetTime" table:"bet_time"` + LotteryTime int `json:"LotteryTime" redis:"LotteryTime" table:"lottery_time"` + BetNumAmount []int `json:"BetNumAmount" redis:"BetNumAmount" table:"betnum_amount"` + BetAmount [][]int `json:"BetAmount" redis:"BetAmount" table:"bet_amount"` + BetLimit []int64 `json:"BetLimit" redis:"BetLimit" table:"bet_limit"` + BetOdds []int `json:"BetOdds" redis:"BetOdds" table:"bet_odds"` + BetMin int64 `json:"BetMin" redis:"BetMin" table:"bet_min"` // 最低下注限制 + ChangePer []int `json:"ChangePer" redis:"ChangePer" table:"change_pr"` +} + +func (s *SheetRoomConfig) MarshalBinary() ([]byte, error) { + return json.Marshal(s) +} + +func (s *SheetRoomConfig) UnmarshalBinary(data []byte) error { + return json.Unmarshal(data, s) +} + +type GameRoomConfig interface { + MinTake() int + MaxTake() int + Open() bool +} + +type SheetTP_Config struct { + RoomName string `gorm:"column:room_name;type:varchar(32);comment:房间名称" json:"RoomName" redis:"room_name" table:"room_name"` + RoomID int `gorm:"column:room_id;type:int(11);comment:房间id" json:"RoomID" redis:"room_id" table:"room_id"` + RoomType int `gorm:"column:room_type;type:int(11);comment:房间类型 1现金场 2练习场" json:"RoomType" redis:"room_type" table:"room_type"` + MinPlayerCount int `gorm:"column:min_players;type:int(11);comment:玩牌人数下限" json:"MinPlayerCount" redis:"min_players" table:"min_players"` + MaxPlayerCount int `gorm:"column:max_players;type:int(11);comment:玩牌人数上限" json:"MaxPlayerCount" redis:"max_players" table:"max_players"` + StartTime int `gorm:"column:start_time;type:int(11);comment:开局时长" json:"StartTime" redis:"start_time" table:"start_time"` + IsOpen bool `gorm:"column:is_open;type:int(11);comment:是否开启 0关闭 1开启" json:"IsOpen" redis:"is_open" table:"is_open"` + BootRecharge int `gorm:"column:boot_recharge;type:int(11);comment:推荐充值" json:"BootRecharge" redis:"boot_recharge" table:"boot_recharge"` + CurrenyType CurrencyType `gorm:"column:currency_type;type:int(11);comment:货币类型 1金币 2筹码" json:"CurrenyType" json:"currency_type" redis:"currency_type" table:"currency_type"` + CarryInitialValue int64 `gorm:"column:carry_initial_value;type:int(11);comment:初始携带货币" json:"CarryInitialValue" redis:"carry_initial_value" table:"carry_initial_value"` + Boot int `gorm:"column:boot;type:int(11);comment:底注" json:"Boot" redis:"boot" table:"boot"` + TurnTime int `gorm:"column:turn_time;type:int(11);comment:操作时长" json:"TurnTime" redis:"turn_time" table:"turn_time"` + MinTakeIn int `gorm:"column:min_buyin;type:int(11);comment:入场下限" json:"MinTakeIn" redis:"min_buyin" table:"min_buyin"` + MaxTakeIn int `gorm:"column:max_buyin;type:int(11);comment:入场上限" json:"MaxTakeIn" redis:"max_buyin" table:"max_buyin"` + MaxBlinds int `gorm:"column:max_blinds;type:int(11);comment:盲注轮数" json:"MaxBlinds" redis:"max_blinds" table:"max_blinds"` + TurnLimit int `gorm:"column:turn_limit;type:int(11);comment:轮数上限" json:"TurnLimit" redis:"turn_limit" table:"turn_limit"` + ChaalLimit int `gorm:"column:chaal_limit;type:int(11);comment:加注上限" json:"ChaalLimit" redis:"chaal_limit" table:"chaal_limit"` + PotLimit int `gorm:"column:pot_limit;type:int(11);comment:奖池上限" json:"PotLimit" redis:"pot_limit" table:"pot_limit"` + IsCharge int `gorm:"column:is_charge;type:int(11);comment:是否抽水 0不抽 1抽" json:"IsCharge" redis:"is_charge" table:"is_charge"` + ChargeType int `gorm:"column:charge_type;type:int(11);comment:抽水类型 1赢家 2全体" json:"ChargeType" redis:"charge_type" table:"charge_type"` + ChargeMode int `gorm:"column:charge_mode;type:int(11);comment:抽水方式 1百分比 2固定" json:"ChargeMode" redis:"charge_mode" table:"charge_mode"` + ChargeAmount int `gorm:"column:charge;type:int(11);comment:抽水金额" json:"ChargeAmount" redis:"charge" table:"charge"` +} + +func (s *SheetTP_Config) TableName() string { + return "game_teenpatti_config" +} + +func (s *SheetTP_Config) MarshalBinary() ([]byte, error) { + return json.Marshal(s) +} + +func (s *SheetTP_Config) UnmarshalBinary(data []byte) error { + return json.Unmarshal(data, s) +} + +func (s *SheetTP_Config) MinTake() int { + return s.MinTakeIn +} + +func (s *SheetTP_Config) MaxTake() int { + return s.MaxTakeIn +} + +func (s *SheetTP_Config) Open() bool { + return s.IsOpen +} + +type SheetRummy_config struct { + RoomName string `json:"room_name" redis:"room_name" table:"room_name"` + RoomID int `json:"room_id" redis:"room_id" table:"room_id"` + RoomType int `json:"room_type" redis:"room_type" table:"room_type"` + MinPlayerCount int `json:"min_players" redis:"min_players" table:"min_players"` + MaxPlayerCount int `json:"max_players" redis:"max_players" table:"max_players"` + StartTime int `json:"start_time" redis:"start_time" table:"start_time"` + IsOpen bool `json:"is_open" redis:"is_open" table:"is_open"` + BootRecharge int `json:"boot_recharge" redis:"boot_recharge" table:"boot_recharge"` + CurrenyType CurrencyType `json:"currency_type" redis:"currency_type" table:"currency_type"` + CarryInitialValue int64 `json:"carry_initial_value" redis:"carry_initial_value" table:"carry_initial_value"` + Boot int `json:"boot" redis:"boot" table:"boot"` + MinTakeIn int `json:"min_buyin" redis:"min_buyin" table:"min_buyin"` + MaxTakeIn int `json:"max_buyin" redis:"max_buyin" table:"max_buyin"` + MaxBlinds int `json:"max_blinds" redis:"max_blinds" table:"max_blinds"` + TurnLimit int `json:"turn_limit" redis:"turn_limit" table:"turn_limit"` + ChaalLimit int `json:"chaal_limit" redis:"chaal_limit" table:"chaal_limit"` + PotLimit int `json:"pot_limit" redis:"pot_limit" table:"pot_limit"` + // TurnTime int `json:"turn_time" redis:"turn_time" table:"turn_time"` + TouchTime int `json:"touch_time" redis:"touch_time" table:"touch_time"` + PlayTime int `json:"playing_time" redis:"playing_time" table:"playing_time"` + CarryAmount int `json:"carry_amount" redis:"carry_amount" table:"carry_amount"` + IsCharge int `json:"is_charge" redis:"is_charge" table:"is_charge"` + ChargeType int `json:"charge_type" redis:"charge_type" table:"charge_type"` + ChargeMode int `json:"charge_mode" redis:"charge_mode" table:"charge_mode"` + ChargeAmount int `json:"charge" redis:"charge" table:"charge"` +} + +func (s *SheetRummy_config) MarshalBinary() ([]byte, error) { + return json.Marshal(s) +} + +func (s *SheetRummy_config) UnmarshalBinary(data []byte) error { + return json.Unmarshal(data, s) +} + +func (s *SheetRummy_config) MinTake() int { + return s.MinTakeIn +} + +func (s *SheetRummy_config) MaxTake() int { + return s.MaxTakeIn +} + +func (s *SheetRummy_config) Open() bool { + return s.IsOpen +} + +type SheetDvt_config struct { + BetMin int64 `json:"bet_min" redis:"bet_min" table:"bet_min"` // 最低下注限制 + RoomName string `json:"room_name" redis:"room_name" table:"room_name"` + Poker []int `json:"poker" redis:"poker" table:"poker"` + BetOdds []int `json:"bet_odds" redis:"bet_odds" table:"bet_odds"` + BetLimit []int64 `json:"bet_limit" redis:"bet_limit" table:"bet_limit"` + BetAmount []int `json:"bet_amount" redis:"bet_amount" table:"bet_amount"` + GameID int `json:"game_id" redis:"game_id" table:"game_id"` + MeterageMode int `json:"meterage_mode" redis:"meterage_mode" table:"meterage_mode"` + CurrenyType CurrencyType `json:"currency_type" redis:"currency_type" table:"currency_type"` + CarryInitialValue int64 `json:"carry_initial_value" redis:"carry_initial_value" table:"carry_initial_value"` + MinTakeIn int `json:"min_buyin" redis:"min_buyin" table:"min_buyin"` + MaxTakeIn int `json:"max_buyin" redis:"max_buyin" table:"max_buyin"` + MaxPlayerCount int `json:"max_players" redis:"max_players" table:"max_players"` + PokerNumber int `json:"poker_number" redis:"poker_number" table:"poker_number"` + BootRecharge int `json:"boot_recharge" redis:"boot_recharge" table:"boot_recharge"` + BetTime int `json:"bet_time" redis:"bet_time" table:"bet_time"` + PKTime int `json:"pk_time" redis:"pk_time" table:"pk_time"` + MinPlayerCount int `json:"min_players" redis:"min_players" table:"min_players"` + RoomType int `json:"room_type" redis:"room_type" table:"room_type"` + RoomID int `json:"room_id" redis:"room_id" table:"room_id"` + ChargeMode int `json:"charge_mode" redis:"charge_mode" table:"charge_mode"` + ChargeAmount int `json:"charge" redis:"charge" table:"charge"` + IsOpen bool `json:"is_open" redis:"is_open" table:"is_open"` +} + +func (s *SheetDvt_config) MarshalBinary() ([]byte, error) { + return json.Marshal(s) +} + +func (s *SheetDvt_config) UnmarshalBinary(data []byte) error { + return json.Unmarshal(data, s) +} + +func (s *SheetDvt_config) MinTake() int { + return s.MinTakeIn +} + +func (s *SheetDvt_config) MaxTake() int { + return s.MaxTakeIn +} + +func (s *SheetDvt_config) Open() bool { + return s.IsOpen +} + +type Sheet7up7down_config struct { + BetMin int64 `json:"bet_min" redis:"bet_min" table:"bet_min"` // 最低下注限制 + RoomName string `json:"room_name" redis:"room_name" table:"room_name"` + Poker []int `json:"poker" redis:"poker" table:"poker"` + BetOdds []int `json:"bet_odds" redis:"bet_odds" table:"bet_odds"` + BetLimit []int64 `json:"bet_limit" redis:"bet_limit" table:"bet_limit"` + BetAmount []int `json:"bet_amount" redis:"bet_amount" table:"bet_amount"` + GameID int `json:"game_id" redis:"game_id" table:"game_id"` + MeterageMode int `json:"meterage_mode" redis:"meterage_mode" table:"meterage_mode"` + CurrenyType CurrencyType `json:"currency_type" redis:"currency_type" table:"currency_type"` + CarryInitialValue int64 `json:"carry_initial_value" redis:"carry_initial_value" table:"carry_initial_value"` + MinTakeIn int `json:"min_buyin" redis:"min_buyin" table:"min_buyin"` + MaxTakeIn int `json:"max_buyin" redis:"max_buyin" table:"max_buyin"` + MaxPlayerCount int `json:"max_players" redis:"max_players" table:"max_players"` + PokerNumber int `json:"poker_number" redis:"poker_number" table:"poker_number"` + BootRecharge int `json:"boot_recharge" redis:"boot_recharge" table:"boot_recharge"` + BetTime int `json:"bet_time" redis:"bet_time" table:"bet_time"` + LotteryTime int `json:"lottery_time" redis:"lottery_time" table:"lottery_time"` + MinPlayerCount int `json:"min_players" redis:"min_players" table:"min_players"` + RoomType int `json:"room_type" redis:"room_type" table:"room_type"` + RoomID int `json:"room_id" redis:"room_id" table:"room_id"` + ChargeMode int `json:"charge_mode" redis:"charge_mode" table:"charge_mode"` + ChargeAmount int `json:"charge" redis:"charge" table:"charge"` + IsOpen bool `json:"is_open" redis:"is_open" table:"is_open"` +} + +func (s *Sheet7up7down_config) MarshalBinary() ([]byte, error) { + return json.Marshal(s) +} + +func (s *Sheet7up7down_config) UnmarshalBinary(data []byte) error { + return json.Unmarshal(data, s) +} + +func (s *Sheet7up7down_config) MinTake() int { + return s.MinTakeIn +} + +func (s *Sheet7up7down_config) MaxTake() int { + return s.MaxTakeIn +} + +func (s *Sheet7up7down_config) Open() bool { + return s.IsOpen +} + +type SheetAndar_bahar_config struct { + BetMin int64 `json:"bet_min" redis:"bet_min" table:"bet_min"` // 最低下注限制 + RoomName string `json:"room_name" redis:"room_name" table:"room_name"` + Poker []int `json:"poker" redis:"poker" table:"poker"` + BetOdds []int `json:"bet_odds" redis:"bet_odds" table:"bet_odds"` // 扩大100倍运算 + BetLimit []int64 `json:"bet_limit" redis:"bet_limit" table:"bet_limit"` + BetAmount []int `json:"bet_amount" redis:"bet_amount" table:"bet_amount"` + GameID int `json:"game_id" redis:"game_id" table:"game_id"` + MeterageMode int `json:"meterage_mode" redis:"meterage_mode" table:"meterage_mode"` + CurrenyType CurrencyType `json:"currency_type" redis:"currency_type" table:"currency_type"` + CarryInitialValue int64 `json:"carry_initial_value" redis:"carry_initial_value" table:"carry_initial_value"` + MinTakeIn int `json:"min_buyin" redis:"min_buyin" table:"min_buyin"` + MaxTakeIn int `json:"max_buyin" redis:"max_buyin" table:"max_buyin"` + MaxPlayerCount int `json:"max_players" redis:"max_players" table:"max_players"` + PokerNumber int `json:"poker_number" redis:"poker_number" table:"poker_number"` + BootRecharge int `json:"boot_recharge" redis:"boot_recharge" table:"boot_recharge"` + BetTime int `json:"bet_time" redis:"bet_time" table:"bet_time"` + LotteryTime int `json:"lottery_time" redis:"lottery_time" table:"lottery_time"` + MinPlayerCount int `json:"min_players" redis:"min_players" table:"min_players"` + RoomType int `json:"room_type" redis:"room_type" table:"room_type"` + RoomID int `json:"room_id" redis:"room_id" table:"room_id"` + ChargeMode int `json:"charge_mode" redis:"charge_mode" table:"charge_mode"` + ChargeAmount int `json:"charge" redis:"charge" table:"charge"` + IsOpen bool `json:"is_open" redis:"is_open" table:"is_open"` +} + +func (s *SheetAndar_bahar_config) MarshalBinary() ([]byte, error) { + return json.Marshal(s) +} + +func (s *SheetAndar_bahar_config) UnmarshalBinary(data []byte) error { + return json.Unmarshal(data, s) +} + +func (s *SheetAndar_bahar_config) MinTake() int { + return s.MinTakeIn +} + +func (s *SheetAndar_bahar_config) MaxTake() int { + return s.MaxTakeIn +} + +func (s *SheetAndar_bahar_config) Open() bool { + return s.IsOpen +} + +type SheetJhandi_Munda_config struct { + BetMin int64 `json:"bet_min" redis:"bet_min" table:"bet_min"` // 最低下注限制 + RoomName string `json:"room_name" redis:"room_name" table:"room_name"` // 房间名称 + BetOdds [][]int `json:"bet_odds" redis:"bet_odds" table:"bet_odds"` // 投注赔率 + BetLimit []int64 `json:"bet_limit" redis:"bet_limit" table:"bet_limit"` // 投注上限 + BetAmount []int `json:"bet_amount" redis:"bet_amount" table:"bet_amount"` // 投注金额 + GameID int `json:"game_id" redis:"game_id" table:"game_id"` // 游戏id + MeterageMode int `json:"meterage_mode" redis:"meterage_mode" table:"meterage_mode"` // 计量方式 + CurrenyType CurrencyType `json:"currency_type" redis:"currency_type" table:"currency_type"` // 货币类型 + CarryInitialValue int64 `json:"carry_initial_value" redis:"carry_initial_value" table:"carry_initial_value"` // 初始携带货币 + MinTakeIn int `json:"min_buyin" redis:"min_buyin" table:"min_buyin"` // 入场下限货币 + MaxTakeIn int `json:"max_buyin" redis:"max_buyin" table:"max_buyin"` // 入场上限货币 + MaxPlayerCount int `json:"max_players" redis:"max_players" table:"max_players"` // 玩牌人数上限 + BootRecharge int `json:"boot_recharge" redis:"boot_recharge" table:"boot_recharge"` // 推荐充值 + BetTime int `json:"bet_time" redis:"bet_time" table:"bet_time"` // 投注时长 + LotteryTime int `json:"lottery_time" redis:"lottery_time" table:"lottery_time"` // 开奖时长 + MinPlayerCount int `json:"min_players" redis:"min_players" table:"min_players"` // 玩牌人数下限 + RoomType int `json:"room_type" redis:"room_type" table:"room_type"` // 房间类型 + RoomID int `json:"room_id" redis:"room_id" table:"room_id"` // 房间id + ChargeMode int `json:"charge_mode" redis:"charge_mode" table:"charge_mode"` // 抽水方式 + ChargeAmount int `json:"charge" redis:"charge" table:"charge"` // 抽水金额 + IsOpen bool `json:"is_open" redis:"is_open" table:"is_open"` // 是否开启 + Dice1 int `json:"dice1" redis:"dice1" table:"dice1"` // 骰子1 概率 + Dice2 int `json:"dice2" redis:"dice2" table:"dice2"` // 骰子2 概率 +} + +func (s *SheetJhandi_Munda_config) MarshalBinary() ([]byte, error) { + return json.Marshal(s) +} + +func (s *SheetJhandi_Munda_config) UnmarshalBinary(data []byte) error { + return json.Unmarshal(data, s) +} + +func (s *SheetJhandi_Munda_config) MinTake() int { + return s.MinTakeIn +} + +func (s *SheetJhandi_Munda_config) MaxTake() int { + return s.MaxTakeIn +} + +func (s *SheetJhandi_Munda_config) Open() bool { + return s.IsOpen +} + +type SheetHorse_Racing_config struct { + BetMin int64 `json:"bet_min" redis:"bet_min" table:"bet_min"` // 最低下注限制 + RoomName string `json:"room_name" redis:"room_name" table:"room_name"` + Poker []int `json:"poker" redis:"poker" table:"poker"` + // BetOdds []int `json:"bet_odds" redis:"bet_odds" table:"bet_odds"` // 扩大100倍运算 + BetLimit []int64 `json:"bet_limit" redis:"bet_limit" table:"bet_limit"` + BetAmount []int `json:"bet_amount" redis:"bet_amount" table:"bet_amount"` + GameID int `json:"game_id" redis:"game_id" table:"game_id"` + MeterageMode int `json:"meterage_mode" redis:"meterage_mode" table:"meterage_mode"` + CurrenyType CurrencyType `json:"currency_type" redis:"currency_type" table:"currency_type"` + CarryInitialValue int64 `json:"carry_initial_value" redis:"carry_initial_value" table:"carry_initial_value"` + MinTakeIn int `json:"min_buyin" redis:"min_buyin" table:"min_buyin"` + MaxTakeIn int `json:"max_buyin" redis:"max_buyin" table:"max_buyin"` + MaxPlayerCount int `json:"max_players" redis:"max_players" table:"max_players"` + PokerNumber int `json:"poker_number" redis:"poker_number" table:"poker_number"` + BootRecharge int `json:"boot_recharge" redis:"boot_recharge" table:"boot_recharge"` + BetTime int `json:"bet_time" redis:"bet_time" table:"bet_time"` + RacingTime int `json:"racing_time" redis:"racing_time" table:"racing_time"` + SettlementTime int `json:"settlement_time" redis:"settlement_time" table:"settlement_time"` + MinPlayerCount int `json:"min_players" redis:"min_players" table:"min_players"` + RoomType int `json:"room_type" redis:"room_type" table:"room_type"` + RoomID int `json:"room_id" redis:"room_id" table:"room_id"` + ChargeMode int `json:"charge_mode" redis:"charge_mode" table:"charge_mode"` + ChargeAmount int `json:"charge" redis:"charge" table:"charge"` + IsOpen bool `json:"is_open" redis:"is_open" table:"is_open"` +} + +func (s *SheetHorse_Racing_config) MarshalBinary() ([]byte, error) { + return json.Marshal(s) +} + +func (s *SheetHorse_Racing_config) UnmarshalBinary(data []byte) error { + return json.Unmarshal(data, s) +} + +func (s *SheetHorse_Racing_config) MinTake() int { + return s.MinTakeIn +} + +func (s *SheetHorse_Racing_config) MaxTake() int { + return s.MaxTakeIn +} + +func (s *SheetHorse_Racing_config) Open() bool { + return s.IsOpen +} + +type SheetFruit_config struct { + BetMin int64 `json:"bet_min" redis:"bet_min" table:"bet_min"` // 最低下注限制 + RoomName string `json:"room_name" redis:"room_name" table:"room_name"` + Poker []int `json:"poker" redis:"poker" table:"poker"` + BetOdds []int `json:"bet_odds" redis:"bet_odds" table:"bet_odds"` // 扩大100倍运算 + BetLimit []int64 `json:"bet_limit" redis:"bet_limit" table:"bet_limit"` + ChangePer []int `json:"change_pr" redis:"change_pr" table:"change_pr"` + BetAmount []int `json:"bet_amount" redis:"bet_amount" table:"bet_amount"` + GameID int `json:"game_id" redis:"game_id" table:"game_id"` + MeterageMode int `json:"meterage_mode" redis:"meterage_mode" table:"meterage_mode"` + CurrenyType CurrencyType `json:"currency_type" redis:"currency_type" table:"currency_type"` + CarryInitialValue int64 `json:"carry_initial_value" redis:"carry_initial_value" table:"carry_initial_value"` + MinTakeIn int `json:"min_buyin" redis:"min_buyin" table:"min_buyin"` + MaxTakeIn int `json:"max_buyin" redis:"max_buyin" table:"max_buyin"` + MaxPlayerCount int `json:"max_players" redis:"max_players" table:"max_players"` + PokerNumber int `json:"poker_number" redis:"poker_number" table:"poker_number"` + BootRecharge int `json:"boot_recharge" redis:"boot_recharge" table:"boot_recharge"` + BetTime int `json:"bet_time" redis:"bet_time" table:"bet_time"` + LotteryTime int `json:"lottery_time" redis:"lottery_time" table:"lottery_time"` + MinPlayerCount int `json:"min_players" redis:"min_players" table:"min_players"` + RoomType int `json:"room_type" redis:"room_type" table:"room_type"` + RoomID int `json:"room_id" redis:"room_id" table:"room_id"` + ChargeMode int `json:"charge_mode" redis:"charge_mode" table:"charge_mode"` + ChargeAmount int `json:"charge" redis:"charge" table:"charge"` + IsOpen bool `json:"is_open" redis:"is_open" table:"is_open"` +} + +func (s *SheetFruit_config) MarshalBinary() ([]byte, error) { + return json.Marshal(s) +} + +func (s *SheetFruit_config) UnmarshalBinary(data []byte) error { + return json.Unmarshal(data, s) +} + +func (s *SheetFruit_config) MinTake() int { + return s.MinTakeIn +} + +func (s *SheetFruit_config) MaxTake() int { + return s.MaxTakeIn +} + +func (s *SheetFruit_config) Open() bool { + return s.IsOpen +} + +type SheetCar_config struct { + BetMin int64 `json:"bet_min" redis:"bet_min" table:"bet_min"` // 最低下注限制 + RoomName string `json:"room_name" redis:"room_name" table:"room_name"` + Poker []int `json:"poker" redis:"poker" table:"poker"` + BetOdds []int `json:"bet_odds" redis:"bet_odds" table:"bet_odds"` // 扩大100倍运算 + BetLimit []int64 `json:"bet_limit" redis:"bet_limit" table:"bet_limit"` + ChangePer []int `json:"change_pr" redis:"change_pr" table:"change_pr"` + BetAmount []int `json:"bet_amount" redis:"bet_amount" table:"bet_amount"` + GameID int `json:"game_id" redis:"game_id" table:"game_id"` + MeterageMode int `json:"meterage_mode" redis:"meterage_mode" table:"meterage_mode"` + CurrenyType CurrencyType `json:"currency_type" redis:"currency_type" table:"currency_type"` + CarryInitialValue int64 `json:"carry_initial_value" redis:"carry_initial_value" table:"carry_initial_value"` + MinTakeIn int `json:"min_buyin" redis:"min_buyin" table:"min_buyin"` + MaxTakeIn int `json:"max_buyin" redis:"max_buyin" table:"max_buyin"` + MaxPlayerCount int `json:"max_players" redis:"max_players" table:"max_players"` + PokerNumber int `json:"poker_number" redis:"poker_number" table:"poker_number"` + BootRecharge int `json:"boot_recharge" redis:"boot_recharge" table:"boot_recharge"` + BetTime int `json:"bet_time" redis:"bet_time" table:"bet_time"` + LotteryTime int `json:"lottery_time" redis:"lottery_time" table:"lottery_time"` + MinPlayerCount int `json:"min_players" redis:"min_players" table:"min_players"` + RoomType int `json:"room_type" redis:"room_type" table:"room_type"` + RoomID int `json:"room_id" redis:"room_id" table:"room_id"` + ChargeMode int `json:"charge_mode" redis:"charge_mode" table:"charge_mode"` + ChargeAmount int `json:"charge" redis:"charge" table:"charge"` + IsOpen bool `json:"is_open" redis:"is_open" table:"is_open"` +} + +func (s *SheetCar_config) MarshalBinary() ([]byte, error) { + return json.Marshal(s) +} + +func (s *SheetCar_config) UnmarshalBinary(data []byte) error { + return json.Unmarshal(data, s) +} + +func (s *SheetCar_config) MinTake() int { + return s.MinTakeIn +} + +func (s *SheetCar_config) MaxTake() int { + return s.MaxTakeIn +} + +func (s *SheetCar_config) Open() bool { + return s.IsOpen +} + +// SheetTp_robot_ai_config +type SheetTp_robot_ai_config struct { + RandomTime []int `json:"random_time" redis:"random_time" table:"random_time"` + ID int `json:"serial" redis:"serial" table:"serial"` + GameResult bool `json:"game_result" redis:"game_result" table:"game_result"` // 输赢 + TypeID int `json:"type_id" redis:"type_id" table:"type_id"` // 方案id + PlayerLower int `json:"player_lower" redis:"player_lower" table:"player_lower"` + PlayerUpper int `json:"player_upper" redis:"player_upper" table:"player_upper"` + PokerType int `json:"poker_type" redis:"poker_type" table:"poker_type"` + PokerColor int `json:"poker_color" redis:"poker_color" table:"poker_color"` + Poker1Lower int `json:"poker1_lower" redis:"poker1_lower" table:"poker1_lower"` + Poker1Upper int `json:"poker1_upper" redis:"poker1_upper" table:"poker1_upper"` + Poker2Lower int `json:"poker2_lower" redis:"poker2_lower" table:"poker2_lower"` + Poker2Upper int `json:"poker2_upper" redis:"poker2_upper" table:"poker2_upper"` + Poker3Lower int `json:"poker3_lower" redis:"poker3_lower" table:"poker3_lower"` + Poker3Upper int `json:"poker3_upper" redis:"poker3_upper" table:"poker3_upper"` + JackpotLower float64 `json:"jackpot_lower" redis:"jackpot_lower" table:"jackpot_lower"` + JackpotUpper float64 `json:"jackpot_upper" redis:"jackpot_upper" table:"jackpot_upper"` + RoundLower int `json:"round_lower" redis:"round_lower" table:"round_lower"` + RoundUpper int `json:"round_upper" redis:"round_upper" table:"round_upper"` + MultiplesLower int `json:"multiples_lower" redis:"multiples_lower" table:"multiples_lower"` + MultiplesUpper int `json:"multiples_upper" redis:"multiples_upper" table:"multiples_upper"` + IfSideShow int `json:"if_side_show" redis:"if_side_show" table:"if_side_show"` + IfShow int `json:"if_show" redis:"if_show" table:"if_show"` + ActionType int `json:"action_type" redis:"action_type" table:"action_type"` + SeeStatus int `json:"see_status" redis:"see_status" table:"see_status"` + PackPr float64 `json:"pack_pr" redis:"pack_pr" table:"pack_pr"` + SeePr float64 `json:"see_pr" redis:"see_pr" table:"see_pr"` + BlindPr float64 `json:"blind_pr" redis:"blind_pr" table:"blind_pr"` + DoubleBlindPr float64 `json:"double_blind_pr" redis:"double_blind_pr" table:"double_blind_pr"` + ChaalPr float64 `json:"chaal_pr" redis:"chaal_pr" table:"chaal_pr"` + DoubleChaalPr float64 `json:"double_chaal_pr" redis:"double_chaal_pr" table:"double_chaal_pr"` + SideShowPr float64 `json:"side_show_pr" redis:"side_show_pr" table:"side_show_pr"` + BeSideShowPr float64 `json:"beside_show_pr" redis:"beside_show_pr" table:"beside_show_pr"` // 接受比牌概率 + ShowPr float64 `json:"show_pr" redis:"show_pr" table:"show_pr"` +} + +func (s *SheetTp_robot_ai_config) MarshalBinary() ([]byte, error) { + return json.Marshal(s) +} + +func (s *SheetTp_robot_ai_config) UnmarshalBinary(data []byte) error { + return json.Unmarshal(data, s) +} + +// SheetMillionRobotConfig 百人场机器人通用结构 +type SheetMillionRobotConfig struct { + RoomID int `json:"room_id" redis:"room_id" table:"room_id"` + Group int `json:"group_number" redis:"group_number" table:"group_number"` // 分组号 + Period [][]int `json:"incoming_period" redis:"incoming_period" table:"incoming_period"` // 入局时段 + Serial int `json:"serial" redis:"serial" table:"sserial"` + LastResult int `json:"last_result" redis:"last_result" table:"last_result"` // 上局结果 + ContinuityResult []int `json:"continuity_result" redis:"continuity_result" table:"continuity_result"` // 连开局数 + // PlayerBet [][]int `json:"player_bet" redis:"player_bet" table:"player_bet"` // 玩家投注 + BetArea []int `json:"bet_region" redis:"bet_region" table:"bet_region"` // 投注区域 + BetAmount int `json:"bet_amount" redis:"bet_amount" table:"bet_amount"` // 投注额度 + BetNumber int `json:"bet_number" redis:"bet_number" table:"bet_number"` // 投注次数 + Interval int `json:"interval_duration" redis:"interval_duration" table:"interval_duration"` // 间隔时长(s) +} + +func (s *SheetMillionRobotConfig) MarshalBinary() ([]byte, error) { + return json.Marshal(s) +} + +func (s *SheetMillionRobotConfig) UnmarshalBinary(data []byte) error { + return json.Unmarshal(data, s) +} + +// SheetRobot_config +type SheetRobot_config struct { + Name string `json:"name" redis:"name" table:"name"` + UID int `json:"uid" redis:"uid"` + ID int `json:"robot_uid" redis:"robot_uid" table:"robot_uid"` + Gold int64 `json:"gold" redis:"gold" table:"gold"` + Avatar int `json:"head" redis:"head" table:"head"` + Group int `json:"group_number" redis:"group_number"` +} + +func (s *SheetRobot_config) MarshalBinary() ([]byte, error) { + return json.Marshal(s) +} + +func (s *SheetRobot_config) UnmarshalBinary(data []byte) error { + return json.Unmarshal(data, s) +} + +// SheetRobot_play_config +type SheetRobot_play_config struct { + GameID int `json:"game_id" redis:"game_id" table:"game_id"` // gameID + Group int `json:"group_number" redis:"group_number" table:"group_number"` // 分组号 + RoomID int `json:"room_id" redis:"room_id" table:"room_id"` // room_id + RoomType int `json:"room_type" redis:"room_type" table:"room_type"` // room_type + ID int `json:"robot_uid" redis:"robot_uid" table:"robot_uid"` // id + IfCharge int `json:"if_charge" redis:"if_charge" table:"if_charge"` // 是否抽水 + ChargeType int `json:"charge_type" redis:"charge_type" table:"charge_type"` // 昵称 + ChargeMode int `json:"charge_mode" redis:"charge_mode" table:"charge_mode"` // 抽水方式,1百分比2固定值,0无 + ChargeAmount int `json:"charge" redis:"charge" table:"charge"` // 抽水金额 +} + +func (s *SheetRobot_play_config) MarshalBinary() ([]byte, error) { + return json.Marshal(s) +} + +func (s *SheetRobot_play_config) UnmarshalBinary(data []byte) error { + return json.Unmarshal(data, s) +} + +// SheetWithdraw_amount_config +type SheetWithdraw_amount_config struct { + ID int `json:"amount_id" redis:"amount_id" table:"amount_id"` // id + Method int `json:"withdrawal_method" redis:"withdrawal_method" table:"withdrawal_method"` // 提现方式 1UPI 2Bank 3UPI+Bank + Amount int `json:"withdrawal_amount" redis:"withdrawal_amount" table:"withdrawal_amount"` + ServiceCharge int `json:"service_charge" redis:"service_charge" table:"service_charge"` + PayGold int64 `json:"pay_gold" redis:"pay_gold" table:"pay_gold"` + ReceiptType int `json:"receipt_type" redis:"receipt_type" table:"receipt_type"` // 到账类型 1实时 2延时 +} + +func (s *SheetWithdraw_amount_config) MarshalBinary() ([]byte, error) { + return json.Marshal(s) +} + +func (s *SheetWithdraw_amount_config) UnmarshalBinary(data []byte) error { + return json.Unmarshal(data, s) +} + +// SheetWithdraw_condition_config +type SheetWithdraw_condition_config struct { + ID int `json:"serial" redis:"serial" table:"serial"` // id + Type int `json:"type" redis:"type" table:"type"` // 提现类型 1免费 2额外 + WithdrawTimes int `json:"withdrawal_times" redis:"withdrawal_times" table:"withdrawal_times"` // 提现次数(天) + Combination int `json:"combination" redis:"combination" table:"combination"` // 条件组合 1同时 2任一 + Event1 int `json:"event_1" redis:"event_1" table:"event_1"` // 1玩牌 2充值 3登录 + LiftingTimes1 int `json:"lifting_times_1" redis:"lifting_times_1" table:"lifting_times_1"` // 满足条件可提现次数 + SubClassEvent1 int `json:"subclass_event_1" redis:"subclass_event_1" table:"subclass_event_1"` // 达成事件 1金额 2次数 3局数 + Cycle1 int `json:"cycle_1" redis:"cycle_1" table:"cycle_1"` // 1天数 —1无限制 0无 + EventTarget1 int `json:"event_target_1" redis:"event_target_1" table:"event_target_1"` // 达成事件数量 -1任意 0无 + Event2 int `json:"event_2" redis:"event_2" table:"event_2"` // 1玩牌 2充值 3登录 + LiftingTimes2 int `json:"lifting_times_2" redis:"lifting_times_2" table:"lifting_times_2"` // 满足条件可提现次数 + SubClassEvent2 int `json:"subclass_event_2" redis:"subclass_event_2" table:"subclass_event_2"` // 达成事件 1金额 2次数 3局数 + Cycle2 int `json:"cycle_2" redis:"cycle_2" table:"cycle_2"` // 1天数 —1无限制 0无 + EventTarget2 int `json:"event_target_2" redis:"event_target_2" table:"event_target_2"` // 达成事件数量 -1任意 0无 +} + +func (s *SheetWithdraw_condition_config) MarshalBinary() ([]byte, error) { + return json.Marshal(s) +} + +func (s *SheetWithdraw_condition_config) UnmarshalBinary(data []byte) error { + return json.Unmarshal(data, s) +} + +// SheetGoods_config +type SheetGoods_config struct { + Describe string `json:"describe" redis:"describe" table:"describe"` + Name1 string `json:"goods_name_1" redis:"goods_name_1" table:"goods_name_1"` + Name2 string `json:"goods_name_2" redis:"goods_name_2" table:"goods_name_2"` + ResourcePicture string `json:"resource_picture" redis:"resource_picture" table:"resource_picture"` + ID int `json:"goods_id" redis:"goods_id" table:"goods_id"` + EffectiveTime int `json:"effective_time" redis:"effective_time" table:"effective_time"` + Type int `json:"type" redis:"type" table:"type"` + EffectiveDays int `json:"effective_days" redis:"effective_days" table:"effective_days"` + StackLimit int `json:"stack_limit" redis:"stack_limit" table:"stack_limit"` + IfStack bool `json:"if_stack" redis:"if_stack" table:"if_stack"` + IfWithdrawal bool `json:"if_withdrawal" redis:"if_withdrawal" table:"if_withdrawal"` + IfTrade bool `json:"if_trade" redis:"if_trade" table:"if_trade"` + IfDiscard bool `json:"if_discard" redis:"if_discard" table:"if_discard"` +} + +func (s *SheetGoods_config) MarshalBinary() ([]byte, error) { + return json.Marshal(s) +} + +func (s *SheetGoods_config) UnmarshalBinary(data []byte) error { + return json.Unmarshal(data, s) +} + +// SheetReport_activity_config +type SheetReport_activity_config struct { + Name1 string `json:"activity_name_1" redis:"activity_name_1" table:"activity_name_1"` + Name2 string `json:"activity_name_2" redis:"activity_name_2" table:"activity_name_2"` + CumulativeDay []int `json:"cumulative_day" redis:"cumulative_day" table:"cumulative_day"` + CumulativeReward [][]GoodsPair `json:"cumulative_reward" redis:"cumulative_reward" table:"cumulative_reward"` + Reward []GoodsPair `json:"reward_check" redis:"reward_check" table:"reward_check"` + Sort int `json:"sort" redis:"sort" table:"sort"` + ID int `json:"activity_id" redis:"activity_id" table:"activity_id"` + LoopNumber int `json:"loop_number" redis:"loop_number" table:"loop_number"` + SignCycle int `json:"sign_cycle" redis:"sign_cycle" table:"sign_cycle"` + CumulativeCycle int `json:"cumulative_cycle" redis:"cumulative_cycle" table:"cumulative_cycle"` + RewardNumber int `json:"reward_number" redis:"reward_number" table:"reward_number"` + IfLoop bool `json:"if_loop" redis:"if_loop" table:"if_loop"` +} + +func (s *SheetReport_activity_config) MarshalBinary() ([]byte, error) { + return json.Marshal(s) +} + +func (s *SheetReport_activity_config) UnmarshalBinary(data []byte) error { + return json.Unmarshal(data, s) +} + +// SheetMatching_table_config +// match_pr 匹配出现概率 +type SheetMatching_table_config struct { + WaittimeRange []int `json:"waittime_range" redis:"waittime_range" table:"waittime_range"` + PlayGold []int `json:"player_gold" redis:"player_gold" table:"player_gold"` + Quantity2 []int `json:"quantity_2" redis:"quantity_2" table:"quantity_2"` + Quantity1 []int `json:"quantity_1" redis:"quantity_1" table:"quantity_1"` + RobotRange []int `json:"robot_range" redis:"robot_range" table:"robot_range"` + EmptyPositionNumber []int `json:"empty_position_number" redis:"empty_position_number" table:"empty_position_number"` + GameID int `json:"game_id" redis:"game_id" table:"game_id"` + Order int `json:"match_table_order" redis:"match_table_order" table:"match_table_order"` + TableState int `json:"table_state" redis:"table_state" table:"table_state"` + ExitCondition1 int `json:"exit_condition_1" redis:"exit_condition_1" table:"exit_condition_1"` + RoomID int `json:"room_id" redis:"room_id" table:"room_id"` + ExitCondition2 int `json:"exit_condition_2" redis:"exit_condition_2" table:"exit_condition_2"` + RoomType int `json:"room_type" redis:"room_type" table:"room_type"` + ExitCondition3 int `json:"exit_condition_3" redis:"exit_condition_3" table:"exit_condition_3"` + Quantity3 []int `json:"quantity_3" redis:"quantity_3" table:"quantity_3"` + MatchType int `json:"type_match" redis:"type_match" table:"type_match"` + MatchPer int `json:"match_pr" redis:"match_pr" table:"match_pr"` +} + +func (s *SheetMatching_table_config) MarshalBinary() ([]byte, error) { + return json.Marshal(s) +} + +func (s *SheetMatching_table_config) UnmarshalBinary(data []byte) error { + return json.Unmarshal(data, s) +} + +// SheetNoticeConfig mysql表结构 +type SheetNoticeConfig struct { + Id int `gorm:"primary_key;AUTO_INCREMENT;column:id" json:"id" redis:"id"` + SheetNotice_config +} + +func (s *SheetNoticeConfig) TableName() string { + return fmt.Sprintf("config_sheet_notice") +} + +// SheetNotice_config +type SheetNotice_config struct { + Content2 string `json:"notice_content2" redis:"notice_content2" table:"notice_content2"` // 公告内容_2(印地语) + Title1 string `json:"notice_title1" redis:"notice_title1" table:"notice_title1"` // 公告标题_1(英语) + Content1 string `json:"notice_content1" redis:"notice_content1" table:"notice_content1"` // 公告内容_1(英语) + Title2 string `json:"notice_title2" redis:"notice_title2" table:"notice_title2"` // 公告标题_2(印地语) + Type int `json:"notice_type" redis:"notice_type" table:"notice_type"` // 公告类型 (1.紧急 2.常规) + IsRelease int `json:"is_release" redis:"is_release" table:"is_release"` // 是否发布 + ReleaseMethod int `json:"release_method" redis:"release_method" table:"release_method"` // 发布方式 + ReleaseTime int64 `json:"release_time" redis:"release_time" table:"release_time"` // 发布时间 + IsTips int `json:"is_tips" redis:"is_tips" table:"is_tips"` // 是否提示 + Interval int `json:"interval_duration" redis:"interval_duration" table:"interval_duration"` // 间隔时常 + PushTimes int `json:"push_times" redis:"push_times" table:"push_times"` // 推送次数 +} + +func (s *SheetNotice_config) MarshalBinary() ([]byte, error) { + return json.Marshal(s) +} + +func (s *SheetNotice_config) UnmarshalBinary(data []byte) error { + return json.Unmarshal(data, s) +} + +// SheetBroadcastConfig mysql表结构 +type SheetBroadcastConfig struct { + Id int `gorm:"primary_key;AUTO_INCREMENT;column:id" json:"id" redis:"id"` + Content string `json:"radio_news" redis:"radio_news" table:"radio_news"` // 广播消息 + Amount string `json:"amount" redis:"amount" table:"amount"` // 数量 eg: 111,222,333 []int 存db时需要字符串,取出来时需要转[]int + DisplayLocation string `json:"display_location" redis:"display_location" table:"display_location"` // 展示位置 eg: 111,222,333 []int 存db时需要字符串,取出来时需要转[]int + RadioId int `json:"radio_id" redis:"radio_id" table:"radio_id"` // 广播ID + Event int `json:"event" redis:"event" table:"event"` // 事件 + TargetID int `json:"target_id" redis:"target_id" table:"target_id"` // 目标Id + Type int `json:"type" redis:"type" table:"type"` // 类型 + Priority int `json:"priority" redis:"priority" table:"priority"` // 优先级 + LoopFrequency int `json:"loop_frequency" redis:"loop_frequency" table:"loop_frequency"` // 循环次数 + Interval int `json:"interval_duration" redis:"interval_duration" table:"interval_duration"` // 间隔时常 + GenerationType int `json:"generation_type" redis:"generation_type" table:"generation_type"` // 生成类型 + IsRelease int `json:"is_release" redis:"is_release" table:"is_release"` // 是否发布 +} + +func (s *SheetBroadcastConfig) TableName() string { + return fmt.Sprintf("config_sheet_broadcast") +} + +// SheetBroadcast_config +type SheetBroadcast_config struct { + Content string `json:"radio_news" redis:"radio_news" table:"radio_news"` + Amount []int `json:"amount" redis:"amount" table:"amount"` + DisplayLocation []int `json:"display_location" redis:"display_location" table:"display_location"` + ID int `json:"radio_id" redis:"radio_id" table:"radio_id"` + Event int `json:"event" redis:"event" table:"event"` // 2登录 3连赢 4赢钱 5活动奖励 + TargetID int `json:"target_id" redis:"target_id" table:"target_id"` + Type int `json:"type" redis:"type" table:"type"` // 1玩家局数 2游戏金币 3提现金币 + Priority int `json:"priority" redis:"priority" table:"priority"` + LoopFrequency int `json:"loop_frequency" redis:"loop_frequency" table:"loop_frequency"` + Interval int `json:"interval_duration" redis:"interval_duration" table:"interval_duration"` + GenerationType int `json:"generation_type" redis:"generation_type" table:"generation_type"` + IsRelease int `json:"is_release" redis:"is_release" table:"is_release"` +} + +func (s *SheetBroadcast_config) MarshalBinary() ([]byte, error) { + return json.Marshal(s) +} + +func (s *SheetBroadcast_config) UnmarshalBinary(data []byte) error { + return json.Unmarshal(data, s) +} + +// SheetActivity_config +// type SheetActivity_config struct { +// ResourcePath string `json:"resource_path" redis:"resource_path" table:"resource_path"` +// JumpPosition string `json:"jump_position" redis:"jump_position" table:"jump_position"` +// ID int `json:"activity_id" redis:"activity_id" table:"activity_id"` +// Sort int `json:"sort" redis:"sort" table:"sort"` +// Start int64 `json:"start_date" redis:"start_date" table:"start_date"` +// End int64 `json:"end_date" redis:"end_date" table:"end_date"` +// IsRelease int `json:"is_release" redis:"is_release" table:"is_release"` +// ReleaseMethod int `json:"release_method" redis:"release_method" table:"release_method"` +// ReleaseTime int64 `json:"release_time" redis:"release_time" table:"release_time"` +// ReleasePosition int64 `json:"release_position" redis:"release_position" table:"release_position"` +// PushFrequency int `json:"push_frequency" redis:"push_frequency" table:"push_frequency"` +// Push bool `json:"if_push" redis:"if_push" table:"if_push"` +// } + +// func (s *SheetActivity_config) MarshalBinary() ([]byte, error) { +// return json.Marshal(s) +// } + +// func (s *SheetActivity_config) UnmarshalBinary(data []byte) error { +// return json.Unmarshal(data, s) +// } + +// Expire 判断活动是否可用 +// func (s *SheetActivity_config) IsValid() bool { +// now := time.Now().Unix() +// if s.IsRelease == 0 || s.Start > now || (s.End < now && s.End > 0) { +// return false +// } +// return true +// } + +// SheetRecharge1_config +type SheetRecharge1_config struct { + ActivityName1 string `json:"activity_name_1" redis:"activity_name_1" table:"activity_name_1"` + ActivityName2 string `json:"activity_name_2" redis:"activity_name_2" table:"activity_name_2"` + CashbackRate string `json:"cashback_rate" redis:"cashback_rate" table:"cashback_rate"` + ID int `json:"activity_id" redis:"activity_id" table:"activity_id"` + FirstRecharge int `json:"first_recharge" redis:"first_recharge" table:"first_recharge"` + GoodsID int `json:"goods_id" redis:"goods_id" table:"goods_id"` + RechargeAmount int `json:"recharge_amount" redis:"recharge_amount" table:"recharge_amount"` + Getcoins1 int `json:"getcoins_1" redis:"getcoins_1" table:"getcoins_1"` + Amount1 int `json:"amount_1" redis:"amount_1" table:"amount_1"` + Getcoins2 int `json:"getcoins_2" redis:"getcoins_2" table:"getcoins_2"` + Amount2 int `json:"amount_2" redis:"amount_2" table:"amount_2"` + CurrencyType int `json:"currency_type" redis:"currency_type" table:"currency_type"` +} + +func (s *SheetRecharge1_config) MarshalBinary() ([]byte, error) { + return json.Marshal(s) +} + +func (s *SheetRecharge1_config) UnmarshalBinary(data []byte) error { + return json.Unmarshal(data, s) +} + +// SheetChat_config +type SheetChat_config struct { + Type int `json:"chat_type" redis:"chat_type" table:"chat_type"` // 聊天类型 + Msg string `json:"chat_message" redis:"chat_message" table:"chat_message"` // 聊天消息 + Rate int `json:"probability" redis:"probability" table:"probability"` // 概率 + Resource string `json:"resource_path" redis:"resource_path" table:"resource_path"` // 表情资源路径 +} + +func (s *SheetChat_config) MarshalBinary() ([]byte, error) { + return json.Marshal(s) +} + +func (s *SheetChat_config) UnmarshalBinary(data []byte) error { + return json.Unmarshal(data, s) +} + +// SheetHelp_config +type SheetHelp_config struct { + GameID int `json:"game_id" redis:"game_id" table:"game_id"` // 游戏ID + Languages int `json:"languages" redis:"languages" table:"languages"` // 聊天消息 + ContentEG string `json:"play_help_eg" redis:"play_help_eg" table:"play_help_eg"` // 玩法帮助英语 + ContentHI string `json:"play_help_hi" redis:"play_help_hi" table:"play_help_hi"` // 玩法帮助印地语 + IfDisplay bool `json:"if_display" redis:"if_display" table:"if_display"` // 是否显示 +} + +func (s *SheetHelp_config) MarshalBinary() ([]byte, error) { + return json.Marshal(s) +} + +func (s *SheetHelp_config) UnmarshalBinary(data []byte) error { + return json.Unmarshal(data, s) +} + +// SheetChange_config 百人场机器人投注逻辑 +type SheetChange_config struct { + GameID int `json:"game_id" redis:"game_id" table:"game_id"` // 游戏ID + RoomID int `json:"room_id" redis:"room_id" table:"room_id"` // 房间ID + ChangePer []int `json:"change_pr" redis:"change_pr" table:"change_pr"` // 下注区域数量权重 + PlacePer []int `json:"place_pr" redis:"place_pr" table:"place_pr"` // 下注区域权重 + TimePer []int `json:"time_pr" redis:"time_pr" table:"time_pr"` // 下注时间分配 +} + +func (s *SheetChange_config) MarshalBinary() ([]byte, error) { + return json.Marshal(s) +} + +func (s *SheetChange_config) UnmarshalBinary(data []byte) error { + return json.Unmarshal(data, s) +} + +// GoodsPair 物品id,数量对 +type GoodsPair struct { + ID int // 物品id + Value int64 // 数量 + Rate int // 获得概率 +} diff --git a/common/player.go b/common/player.go index fba1ea9..a648ef2 100644 --- a/common/player.go +++ b/common/player.go @@ -174,7 +174,8 @@ type PlayerItems struct { ItemID int `gorm:"column:item_id;default:0;comment:物品id"` Time int64 `gorm:"column:time;type:bigint(20);default:0;comment:获得的时间"` Status int `gorm:"column:status;type:int(11);default:0;comment:物品状态"` - Exi1 int `gorm:"column:exi1;type:int(11);default:0;comment:物品标识字段1"` + Exi1 int64 `gorm:"column:exi1;type:bigint(20);default:0;comment:物品标识字段1"` + Exi2 int64 `gorm:"column:exi2;type:bigint(20);default:0;comment:物品标识字段2"` } func (p *PlayerItems) TableName() string { diff --git a/modules/backend/handler/notice/broadcast.go b/modules/backend/handler/notice/broadcast.go new file mode 100644 index 0000000..e605c08 --- /dev/null +++ b/modules/backend/handler/notice/broadcast.go @@ -0,0 +1,127 @@ +package notice + +import ( + "server/call" + "server/common" + "server/db" + "server/modules/backend/app" + "server/modules/backend/values" + "server/natsClient" + "server/pb" + + "github.com/gin-gonic/gin" + "github.com/liangdas/mqant/log" +) + +// 添加广播 +func AddBroadcast(c *gin.Context) { + a := app.NewApp(c) + defer func() { + a.Response() + }() + req := new(values.AddAddBroadcastReq) + if !a.S(req) { + return + } + + if len(req.List) <= 0 { + a.Code = values.CodeParam + return + } + + err := db.Mysql().C().Model(&common.SheetBroadcastConfig{}).CreateInBatches(&req.List, len(req.List)).Error + if err != nil { + log.Error(err.Error()) + a.Code = values.CodeRetry + return + } + + err = call.Publish(natsClient.TopicReloadConfig, &pb.ReloadGameConfig{Type: common.ReloadBroadcast}) + if err != nil { + log.Error(err.Error()) + } +} + +// 获取广播 +func GetBroadcast(c *gin.Context) { + a := app.NewApp(c) + defer func() { + a.Response() + }() + req := new(values.GetBroadcastReq) + if !a.S(req) { + return + } + + var SheetBroadcastConfig []common.SheetBroadcastConfig + _, err := db.Mysql().QueryAll("", "", &common.SheetBroadcastConfig{}, &SheetBroadcastConfig) + if err != nil { + log.Error(err.Error()) + a.Code = values.CodeRetry + return + } + + a.Data = SheetBroadcastConfig +} + +// 编辑广播 +func EditBroadcast(c *gin.Context) { + a := app.NewApp(c) + defer func() { + a.Response() + }() + req := new(values.EditBroadcastReq) + if !a.S(req) { + a.Code = values.CodeParam + return + } + + err := db.Mysql().C().Model(&common.SheetBroadcastConfig{}).Where("id = ?", req.Id).Updates(map[string]interface{}{ + "content": req.Broadcast.Content, + "amount": req.Broadcast.Amount, + "display_location": req.Broadcast.DisplayLocation, + "event": req.Broadcast.Event, + "radio_id": req.Broadcast.RadioId, + "target_id": req.Broadcast.TargetID, + "type": req.Broadcast.Type, + "priority": req.Broadcast.Priority, + "loop_frequency": req.Broadcast.LoopFrequency, + "interval": req.Broadcast.Interval, + "generation_type": req.Broadcast.GenerationType, + "is_release": req.Broadcast.IsRelease, + }).Error + if err != nil { + log.Error(err.Error()) + a.Code = values.CodeParam + return + } + + err = call.Publish(natsClient.TopicReloadConfig, &pb.ReloadGameConfig{Type: common.ReloadBroadcast}) + if err != nil { + log.Error(err.Error()) + } +} + +// 删除广播 +func DeleteBroadcast(c *gin.Context) { + a := app.NewApp(c) + defer func() { + a.Response() + }() + req := new(values.DeleteBroadcastReq) + if !a.S(req) { + return + } + + err := db.Mysql().C().Where("id = ?", req.Id).Unscoped().Delete(&common.SheetBroadcastConfig{}).Error + if err != nil { + log.Error(err.Error()) + a.Code = values.CodeParam + return + } + + err = call.Publish(natsClient.TopicReloadConfig, &pb.ReloadGameConfig{Type: common.ReloadBroadcast}) + if err != nil { + log.Error(err.Error()) + } +} diff --git a/modules/backend/handler/notice/notice.go b/modules/backend/handler/notice/notice.go new file mode 100644 index 0000000..e04f685 --- /dev/null +++ b/modules/backend/handler/notice/notice.go @@ -0,0 +1,121 @@ +package notice + +import ( + "server/call" + "server/common" + "server/db" + "server/modules/backend/app" + "server/modules/backend/values" + "server/natsClient" + "server/pb" + "time" + + "github.com/gin-gonic/gin" + "github.com/liangdas/mqant/log" +) + +// 系统公告配置 +func AddSystemNotice(c *gin.Context) { + a := app.NewApp(c) + defer func() { + a.Response() + }() + req := new(values.AddSystemNoticeReq) + if !a.S(req) { + return + } + + if len(req.List) <= 0 { + a.Code = values.CodeParam + return + } + + for i := 0; i < len(req.List); i++ { + if req.List[i].ReleaseTime == 0 { + req.List[i].ReleaseTime = time.Now().Unix() + } + } + + err := db.Mysql().C().Model(&common.SheetNoticeConfig{}).CreateInBatches(&req.List, len(req.List)).Error + if err != nil { + log.Error(err.Error()) + a.Code = values.CodeRetry + return + } + + err = call.Publish(natsClient.TopicReloadConfig, &pb.ReloadGameConfig{Type: common.ReloadNotice}) + if err != nil { + log.Error(err.Error()) + } +} + +// 系统公告配置 +func GetSystemNotice(c *gin.Context) { + a := app.NewApp(c) + defer func() { + a.Response() + }() + req := new(values.GetSystemNoticeReq) + if !a.S(req) { + return + } + + var SheetNoticeConfig []common.SheetNoticeConfig + _, err := db.Mysql().QueryAll("", "", &common.SheetNoticeConfig{}, &SheetNoticeConfig) + if err != nil { + log.Error(err.Error()) + a.Code = values.CodeRetry + return + } + + a.Data = SheetNoticeConfig +} + +// 编辑系统公告 +func EditSystemNotice(c *gin.Context) { + a := app.NewApp(c) + defer func() { + a.Response() + }() + req := new(values.EditSystemNoticeReq) + if !a.S(req) { + a.Code = values.CodeParam + return + } + + err := db.Mysql().C().Where("id = ?", req.Id).Save(req.Notice).Error + if err != nil { + log.Error(err.Error()) + a.Code = values.CodeParam + return + } + + err = call.Publish(natsClient.TopicReloadConfig, &pb.ReloadGameConfig{Type: common.ReloadNotice}) + if err != nil { + log.Error(err.Error()) + } +} + +// 删除系统公告 +func DeleteSystemNotice(c *gin.Context) { + a := app.NewApp(c) + defer func() { + a.Response() + }() + req := new(values.DeleteSystemNoticeReq) + if !a.S(req) { + return + } + + err := db.Mysql().C().Where("id = ?", req.Id).Unscoped().Delete(&common.SheetNoticeConfig{}).Error + if err != nil { + log.Error(err.Error()) + a.Code = values.CodeParam + return + } + + err = call.Publish(natsClient.TopicReloadConfig, &pb.ReloadGameConfig{Type: common.ReloadNotice}) + if err != nil { + log.Error(err.Error()) + } +} diff --git a/modules/backend/migrate.go b/modules/backend/migrate.go index b8c8c8a..d0f1e57 100644 --- a/modules/backend/migrate.go +++ b/modules/backend/migrate.go @@ -114,6 +114,8 @@ func MigrateDB() { new(common.ConfigActivityBetDraw), new(common.ActivityBetDrawData), new(common.ConfigActivityPopup), + new(common.SheetBroadcastConfig), + new(common.SheetNoticeConfig), ) if err != nil { panic("Migrate db fail") diff --git a/modules/backend/routers/routers.go b/modules/backend/routers/routers.go index 41ae446..5a96736 100644 --- a/modules/backend/routers/routers.go +++ b/modules/backend/routers/routers.go @@ -45,5 +45,6 @@ func SetUpRouter() *gin.Engine { blockpay(r) output(r) firstPage(r) + notice(r) return r } diff --git a/modules/backend/routers/routiers_notice.go b/modules/backend/routers/routiers_notice.go new file mode 100644 index 0000000..a4b4e5b --- /dev/null +++ b/modules/backend/routers/routiers_notice.go @@ -0,0 +1,21 @@ +package routers + +import ( + handler "server/modules/backend/handler/notice" + + "github.com/gin-gonic/gin" +) + +func notice(e *gin.Engine) { + // 公告请求 + e.POST("/sys/notice/add", handler.AddSystemNotice) + e.POST("/sys/notice/get", handler.GetSystemNotice) + e.POST("/sys/notice/edit", handler.EditSystemNotice) + e.POST("/sys/notice/delete", handler.DeleteSystemNotice) + + // 广播请求 + e.POST("/sys/broadcast/add", handler.AddBroadcast) + e.POST("/sys/broadcast/get", handler.GetBroadcast) + e.POST("/sys/broadcast/edit", handler.EditBroadcast) + e.POST("/sys/broadcast/delete", handler.DeleteBroadcast) +} diff --git a/modules/backend/values/notice.go b/modules/backend/values/notice.go new file mode 100644 index 0000000..1fe46fd --- /dev/null +++ b/modules/backend/values/notice.go @@ -0,0 +1,48 @@ +package values + +import "server/common" + +// AddSystemNoticeReq 添加系统公告 +type AddSystemNoticeReq struct { + List []common.SheetNoticeConfig +} + +// GetSystemNoticeReq 获取系统公告 +type GetSystemNoticeReq struct { +} + +// GetSystemNoticeResp 获取系统公告 +type GetSystemNoticeResp struct { + List []common.SheetNoticeConfig +} + +// EditSystemNoticeReq 编辑公告 +type EditSystemNoticeReq struct { + Id int64 `json:"Id" binding:"required"` + Notice common.SheetNoticeConfig +} + +// DeleteSystemNoticeReq 删除公告 +type DeleteSystemNoticeReq struct { + Id int64 `json:"Id" binding:"required"` // 公告id +} + +// AddAddBroadcastReq 添加广播 +type AddAddBroadcastReq struct { + List []common.SheetBroadcastConfig +} + +// GetBroadcastReq 获取广播 +type GetBroadcastReq struct { +} + +// EditBroadcastReq 编辑广播 +type EditBroadcastReq struct { + Id int64 `json:"Id" binding:"required"` + Broadcast common.SheetBroadcastConfig +} + +// DeleteBroadcastReq 删除广播 +type DeleteBroadcastReq struct { + Id int64 `json:"Id" binding:"required"` // id +} diff --git a/modules/web/handler/activity.go b/modules/web/handler/activity.go index bb0a2a4..33725d9 100644 --- a/modules/web/handler/activity.go +++ b/modules/web/handler/activity.go @@ -639,29 +639,31 @@ func ActivityFirstRechargeBackInfo(c *gin.Context) { resp.NeedRechargeAmount = conf.MinRecharge resp.ProductList = call.GetConfigPayProductByActivityID(common.ActivityIDFirstRechargeBack) resp.Recharge = data.Amount + resp.PayAmount = data.Amount resp.BackPer = conf.MaxBack resp.ChannelList = call.GetConfigPayChannelsByID(common.CurrencyINR) + p, _ := call.GetUserXInfo(a.UID, "birth") + resp.DrawTime = p.Birth + conf.CD + rechargeInfo := call.GetRechargeInfo(a.UID) if data.RechargeTime == 0 { resp.CanRecharge = true return } - if data.RewardTime > 0 { - resp.Draw = true - } - val := data.Amount - call.GetUserCurrencyTotal(a.UID, common.CurrencyINR) + val := data.Amount - call.GetUserCurrencyTotal(a.UID, common.CurrencyINR) - rechargeInfo.WithdrawingCash if val < 0 { val = 0 } val = val * conf.MaxBack / 100 now := time.Now().Unix() - p, _ := call.GetUserXInfo(a.UID, "birth") if p.Birth+conf.CD >= now { db.Mysql().Update(&common.ActivityFirstRechargeBackData{UID: a.UID}, map[string]interface{}{ "reward": val, }) } + if data.RewardTime > 0 && val > 0 { + resp.Draw = true + } resp.Back = val - resp.DrawTime = p.Birth + conf.CD } func ActivityFirstRechargeBackDraw(c *gin.Context) { @@ -674,17 +676,22 @@ func ActivityFirstRechargeBackDraw(c *gin.Context) { } conf := call.GetConfigActivityFirstRechargeBack() data := call.GetUserFirstRechargeBackData(a.UID) - if time.Now().Unix()-data.RechargeTime < common.ActivityFirstRechargeBackTime { + if time.Now().Unix()-data.RechargeTime < conf.CD { log.Error("not ActivityFirstRechargeBackDraw time:%+v", data) a.Code = values.CodeRetry return } + if data.RewardTime > 0 { + a.Code = values.CodeRetry + a.Msg = "Award claimed" + return + } rows, err := db.Mysql().UpdateRes(&common.ActivityFirstRechargeBackData{UID: a.UID}, map[string]interface{}{"reward_time": time.Now().Unix()}) if err != nil || rows == 0 { a.Code = values.CodeRetry return } - val := data.Reward * conf.MaxBack / 100 + val := data.Reward _, err = call.UpdateCurrencyPro(&common.UpdateCurrency{ CurrencyBalance: &common.CurrencyBalance{ UID: a.UID, @@ -1263,31 +1270,48 @@ func ActivityWeekCardInfo(c *gin.Context) { defer func() { a.Response() }() + a.GetUID() if !a.CheckActivityExpire(common.ActivityIDWeekCard) { return } resp := &values.ActivityWeekCardInfoResp{} a.Data = resp cons := call.GetConfigActivityWeekCard() - cardInfo := call.GetUserWeekCard(a.UID) + cardInfo := new(common.ActivityWeekCardData) + if a.UID > 0 { + cardInfo = call.GetUserWeekCard(a.UID) + } + var rewardList []int64 + var err error if cardInfo.ID <= 0 { - rewardList, err := util.GenerateSequence(cons.RewardAmount, cons.MiniLimit) + cardInfo.Day = 0 + rewardList, err = util.GenerateSequence(cons.RewardAmount, cons.MiniLimit) if err != nil { log.Error("err:%v", err) } - if len(rewardList) == 6 { - rewardList = append(rewardList, 0) - } - resp.RewardList = rewardList + rewardList = append([]int64{cons.DayOneReward}, rewardList...) + rewardList = append(rewardList, 0) cardInfo.Rewards = strings.Join(util.Int64SliceToStringSlice(rewardList), ",") - db.Mysql().Create(cardInfo) + if a.UID > 0 { + db.Mysql().Create(cardInfo) + } } - if resp.RewardList == nil { - resp.RewardList, _ = util.StringToInt64Slice(cardInfo.Rewards, ",") + if rewardList == nil { + rewardList, _ = util.StringToInt64Slice(cardInfo.Rewards, ",") + } + for _, item := range rewardList { + resp.RewardList = append(resp.RewardList, values.WeekCardInfo{ + Min: cons.MiniLimit, + Max: cons.RewardAmount, + Val: item, + }) } if !util.IsSameDayTimeStamp(time.Now().Unix(), cardInfo.LastDraw) { resp.Status = true } + if cardInfo.RechargeTime != 0 { + resp.RechargeStatus = true + } resp.RewardDay = cardInfo.Day resp.ChannelList = call.GetConfigPayChannelsByID(common.CurrencyINR) resp.ProductList = call.GetConfigPayProductByActivityID(common.ActivityIDWeekCard) @@ -1305,6 +1329,7 @@ func ActivityWeekCardDraw(c *gin.Context) { if !a.S(req) { return } + conf := call.GetConfigActivityWeekCard() card := call.GetUserWeekCard(a.UID) if card.ID == 0 { a.Code = values.CodeRetry @@ -1329,6 +1354,31 @@ func ActivityWeekCardDraw(c *gin.Context) { reward = rewards[card.Day] * common.DecimalDigits } else { // 第几天折扣券 + // 用户画像一:6天内充值3笔及以上用户 + // 推送当前最高额度向上一档充值满减卷 + // 用户画像二:只解锁周卡,未充值的玩家 + // 推送当前额度向下一档充值满减卷,最低300 + q := elastic.NewBoolQuery() + q.Filter(elastic.NewRangeQuery("time").Gte(card.RechargeTime)) + q.Filter(elastic.NewRangeQuery("time").Lte(now)) + q.Filter(elastic.NewRangeQuery("event").Gte(common.CurrencyEventReCharge)) + q.Must(elastic.NewTermsQuery("uid", a.UID)) + count := db.ES().Count(common.ESIndexBalance, q) + up := false + if count >= 3 { + up = true + } + exi2 := int64(300) * common.DecimalDigits + // 判断充值的金额 + productList := call.GetConfigPayProduct() + for _, product := range productList { + if product.Amount > card.RechargeAmount && up && exi2 < product.Amount { + exi2 = product.Amount + } else if product.Amount < card.RechargeAmount && up && exi2 > product.Amount { + exi2 = product.Amount + } + } + call.AddUserDiscountTicket(a.UID, conf.Discount, exi2) } resp := &values.ActivityWeekCardDrawResp{ @@ -1673,7 +1723,7 @@ func ActivitySevenDayBoxDraw(c *gin.Context) { call.UploadActivityData(a.UID, common.ActivityIDSevenDayBox, common.ActivityDataJoin, reward) } if oneDiscount.Discount > 0 { - call.AddUserDiscountTicket(a.UID, oneDiscount.Discount) + // call.AddUserDiscountTicket(a.UID, oneDiscount.Discount) resp.Discount = oneDiscount.Discount } } @@ -1777,7 +1827,7 @@ func ActivitySuperDraw(c *gin.Context) { }) call.UploadActivityData(a.UID, common.ActivityIDSuper, 2, reward.Reward) } else { - call.AddUserDiscountTicket(a.UID, int(reward.Reward)) + // call.AddUserDiscountTicket(a.UID, int(reward.Reward)) } a.Data = &values.ActivitySuperDrawResp{ Reward: values.ActivitySuperOneReward{ diff --git a/modules/web/handler/recharge.go b/modules/web/handler/recharge.go index 649a661..274b4eb 100644 --- a/modules/web/handler/recharge.go +++ b/modules/web/handler/recharge.go @@ -1,6 +1,7 @@ package handler import ( + "encoding/json" "fmt" "server/call" "server/config" @@ -90,7 +91,7 @@ func RechargeInfo(c *gin.Context) { if a.UID > 0 { // 判断是否有折扣券 tickets := call.GetUserValidItems(a.UID, common.ItemDiscountTicket) - discount := 0 + discount := int64(0) for _, v := range tickets { thisDiscount := v.Exi1 diff := v.Time + common.ActivityWeekCardTicketExpireTime - time.Now().Unix() @@ -103,12 +104,12 @@ func RechargeInfo(c *gin.Context) { } if discount < thisDiscount { discount = thisDiscount - resp.DiscountTicket = &values.DiscountTicket{ + resp.DiscountTicket = append(resp.DiscountTicket, &values.DiscountTicket{ // Level: con.Level, Discount: fmt.Sprintf("%d", 100-discount), TimeLeft: diff, - // Range: , - } + Amount: v.Exi2, + }) // 折扣券 // con := call.GetConfigActivityWeekCardByLevel(1) // if con != nil { @@ -253,39 +254,37 @@ func NewRechargeImp(req *values.RechargeReq, uid, cid int, ip string) *RechargeI ProductID: req.ProductID, } // 只有商城购买才能使用优惠券 - // ticketCon := call.GetConfigActivityWeekCardByLevel(1) if req.ProductID == 0 { // 首先判断折扣券 - // if ticketCon != nil && len(ticketCon.SubRange) == 2 { - // if req.Amount >= ticketCon.SubRange[0] && req.Amount <= ticketCon.SubRange[1] { - // discount := -1 - // var ticket *common.PlayerItems - // // 判断是否有折扣券 - // tickets := call.GetUserValidItems(uid, common.ItemDiscountTicket) - // for i, v := range tickets { - // thisDiscount := v.Exi1 - // diff := v.Time + common.ActivityWeekCardTicketExpireTime - time.Now().Unix() - // if diff <= 0 { - // id := v.ID - // util.Go(func() { - // db.Mysql().Update(&common.PlayerItems{ID: id}, map[string]interface{}{"status": common.ItemStatusInvalid}) - // }) - // continue - // } - // if discount < 0 || thisDiscount < discount { - // discount = thisDiscount - // ticket = tickets[i] - // } - // } - // if discount > 0 { - // ticketData := common.ActivityRechargeData{ID: common.ItemDiscountTicket, I1: ticket.Exi1, I2: req.Amount} - // ticketByte, _ := json.Marshal(ticketData) - // order.Extra = string(ticketByte) - // req.Amount = common.RoundCurrency(common.CurrencyINR, req.Amount*int64(discount)/100) - // order.Amount = req.Amount - // } - // } - // } + var ticket *common.PlayerItems + discount := int64(-1) + exi2 := int64(0) + // 判断是否有折扣券 + tickets := call.GetUserValidItems(uid, common.ItemDiscountTicket) + for i, v := range tickets { + thisDiscount := v.Exi1 + diff := v.Time + common.ActivityWeekCardTicketExpireTime - time.Now().Unix() + if diff <= 0 { + id := v.ID + util.Go(func() { + db.Mysql().Update(&common.PlayerItems{ID: id}, map[string]interface{}{"status": common.ItemStatusInvalid}) + }) + continue + } + if discount < 0 || thisDiscount < discount { + discount = thisDiscount + ticket = tickets[i] + exi2 = v.Exi2 + } + } + if discount > 0 && order.Amount == exi2 && ticket != nil { + ticketData := common.ActivityRechargeData{ID: common.ItemDiscountTicket, I1: int(ticket.Exi1), I2: req.Amount} + ticketByte, _ := json.Marshal(ticketData) + order.Extra = string(ticketByte) + req.Amount = common.RoundCurrency(common.CurrencyINR, req.Amount*discount/common.DecimalDigits) + order.Amount = req.Amount + } + } re := call.GetRechargeInfo(uid) notCharge := re.TotalRecharge == 0 diff --git a/modules/web/handler/withdraw.go b/modules/web/handler/withdraw.go index 5161605..db21388 100644 --- a/modules/web/handler/withdraw.go +++ b/modules/web/handler/withdraw.go @@ -305,6 +305,7 @@ func PlayerWithdraw(c *gin.Context) { if need > has { log.Error("err not enough cash:%v,%v", has, need) a.Code = values.CodeWithdrawNotEnough + a.Msg = "not enough cash" return } diff --git a/modules/web/middleware/token.go b/modules/web/middleware/token.go index 0d3b105..68fe599 100644 --- a/modules/web/middleware/token.go +++ b/modules/web/middleware/token.go @@ -57,6 +57,7 @@ var ( "/activity/activityPopup/info": {}, "/customer/image/download": {}, "/activity/firstRechargeBack/info": {}, + "/activity/weekCard/info": {}, } ) diff --git a/modules/web/values/activity.go b/modules/web/values/activity.go index 6610916..ddda8ba 100644 --- a/modules/web/values/activity.go +++ b/modules/web/values/activity.go @@ -137,12 +137,18 @@ type OneWeekCard struct { TotalReward int64 } +type WeekCardInfo struct { + Min int64 + Val int64 + Max int64 +} type ActivityWeekCardInfoResp struct { - RewardList []int64 // 奖励列表 - RewardDay int // 领取天数 - Status bool // 是否可领取 - ChannelList []*common.ConfigPayChannels - ProductList []*common.ConfigPayProduct + RewardList []WeekCardInfo // 奖励列表 + RewardDay int // 领取天数 + Status bool // 是否可领取 + RechargeStatus bool // 是否充值 + ChannelList []*common.ConfigPayChannels + ProductList []*common.ConfigPayProduct } // Level 领取的周卡的等级 diff --git a/modules/web/values/pay.go b/modules/web/values/pay.go index cd16a76..573e502 100644 --- a/modules/web/values/pay.go +++ b/modules/web/values/pay.go @@ -25,14 +25,13 @@ type RechargeInfoResp struct { ConfigPayBonus []OneConfigPayBonus Tips string SelectID int - DiscountTicket *DiscountTicket + DiscountTicket []*DiscountTicket } type DiscountTicket struct { - Level int Discount string TimeLeft int64 - Range []int64 + Amount int64 } // RechargeReq 充值请求 地址格式为:{"city":"Mumbai","street":"sarang street","houseNumber":"-54/a"} diff --git a/util/util.go b/util/util.go index a40bdc4..95228cf 100644 --- a/util/util.go +++ b/util/util.go @@ -11,7 +11,6 @@ import ( "os" "reflect" "regexp" - "sort" "strconv" "strings" "time" @@ -995,49 +994,31 @@ func StringToInt64Slice(s, sep string) ([]int64, error) { } // 通过总数Count分成一个递增数列 -func GenerateSequence(totalSum, minValue int64) ([]int64, error) { - length := 6 +func GenerateSequence(N, M int64) ([]int64, error) { + length := int64(5) - // 初步生成递增数列 [minValue, minValue+1, ..., minValue+5] + // 初步生成一个递增数列 [M, M+1, ..., M+5] sequence := make([]int64, length) - for i := 0; i < length; i++ { - sequence[i] = minValue + int64(i) + for i := int64(0); i < length; i++ { + sequence[i] = M + i } - // 计算初步数列的总和 - sumInitial := (2*minValue + int64(length-1)) * int64(length) / 2 + // 计算初步生成数列的总和 + sumInitial := (2*M + length - 1) * length / 2 - // 如果初步数列的总和已经大于 totalSum,则无法生成 - if sumInitial > totalSum { - return nil, fmt.Errorf("cannot generate a sequence with the given totalSum and minValue") + // 如果初步生成数列的总和已经大于 N,则无法生成 + if sumInitial > N { + return nil, fmt.Errorf("无法生成满足条件的数列") } // 计算剩余需要分配的值 - remaining := totalSum - sumInitial - - // 设置随机种子 - rand.Seed(time.Now().UnixNano()) - - // 平均分配剩余的值,同时减少极端情况的出现 - for remaining > 0 { - // 每次迭代从头到尾随机增量分配,减少单个元素过度增长 - for i := 0; i < length && remaining > 0; i++ { - // 确保递增,计算可能的最大增量 - maxIncrement := remaining / int64(length-i) - if i > 0 && sequence[i] <= sequence[i-1] { - maxIncrement = sequence[i-1] - sequence[i] + 1 - } + remaining := N - sumInitial - // 随机选择增量 - if maxIncrement > 0 { - randIncrement := rand.Int63n(maxIncrement + 1) - sequence[i] += randIncrement - remaining -= randIncrement - } - } + // 将剩余的值均匀分配到数列中,从后往前加值,保持递增 + for i := length - 1; i >= 0 && remaining > 0; i-- { + sequence[i] += remaining + remaining = 0 } - sort.Slice(sequence, func(i, j int) bool { - return sequence[i] < sequence[j] - }) + return sequence, nil } From d0da615bcae62a4b78ff603f7986b9ee0b1b425f Mon Sep 17 00:00:00 2001 From: mofangmin Date: Fri, 23 Aug 2024 17:11:12 +0800 Subject: [PATCH 11/14] =?UTF-8?q?=E5=91=A8=E5=8D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- call/pay.go | 2 +- modules/web/handler/activity.go | 92 ++++++++++++++++--------- modules/web/routers/routers_activity.go | 4 +- modules/web/values/activity.go | 2 +- util/util.go | 32 ++++----- 5 files changed, 80 insertions(+), 52 deletions(-) diff --git a/call/pay.go b/call/pay.go index 6d6e98c..0eb59e4 100644 --- a/call/pay.go +++ b/call/pay.go @@ -627,7 +627,7 @@ func ActivityWeekCard(r *common.RechargeOrder, product *common.ConfigPayProduct) return } rows, err := db.Mysql().UpdateRes(&common.ActivityWeekCardData{UID: r.UID}, map[string]interface{}{ - "recharge_time": time.Now().Unix(), "day": 0, "recharge_amount": r.Amount}) + "recharge_time": time.Now().Unix(), "day": 0, "recharge_amount": r.Amount, "rewards": ""}) if err != nil || rows == 0 { log.Error("err:%v", err) return diff --git a/modules/web/handler/activity.go b/modules/web/handler/activity.go index 33725d9..7b9933e 100644 --- a/modules/web/handler/activity.go +++ b/modules/web/handler/activity.go @@ -636,7 +636,7 @@ func ActivityFirstRechargeBackInfo(c *gin.Context) { conf := call.GetConfigActivityFirstRechargeBack() a.Data = resp data := call.GetUserFirstRechargeBackData(a.UID) - resp.NeedRechargeAmount = conf.MinRecharge + resp.NeedRechargeAmount = conf.MinRecharge / common.DecimalDigits resp.ProductList = call.GetConfigPayProductByActivityID(common.ActivityIDFirstRechargeBack) resp.Recharge = data.Amount resp.PayAmount = data.Amount @@ -655,7 +655,7 @@ func ActivityFirstRechargeBackInfo(c *gin.Context) { } val = val * conf.MaxBack / 100 now := time.Now().Unix() - if p.Birth+conf.CD >= now { + if p.Birth+conf.CD >= now && data.Reward == 0 { db.Mysql().Update(&common.ActivityFirstRechargeBackData{UID: a.UID}, map[string]interface{}{ "reward": val, }) @@ -1283,22 +1283,44 @@ func ActivityWeekCardInfo(c *gin.Context) { } var rewardList []int64 var err error - if cardInfo.ID <= 0 { + rewardList, err = util.GenerateRandomSequence(cons.RewardAmount, cons.MiniLimit, 5) + if err != nil { + log.Error("err:%v", err) + } + rewardList = append([]int64{cons.DayOneReward}, rewardList...) + rewardList = append(rewardList, 0) + + if cardInfo.ID <= 0 || len(cardInfo.Rewards) == 0 { cardInfo.Day = 0 - rewardList, err = util.GenerateSequence(cons.RewardAmount, cons.MiniLimit) + rewardList, err = util.GenerateRandomSequence(cons.RewardAmount, cons.MiniLimit, 5) if err != nil { log.Error("err:%v", err) } rewardList = append([]int64{cons.DayOneReward}, rewardList...) rewardList = append(rewardList, 0) - cardInfo.Rewards = strings.Join(util.Int64SliceToStringSlice(rewardList), ",") - if a.UID > 0 { - db.Mysql().Create(cardInfo) + if cardInfo.ID <= 0 { + cardInfo.Rewards = strings.Join(util.Int64SliceToStringSlice(rewardList), ",") + if a.UID > 0 { + db.Mysql().Create(cardInfo) + } + } else { + cardInfo.Rewards = strings.Join(util.Int64SliceToStringSlice(rewardList), ",") + db.Mysql().Update(&common.ActivityWeekCardData{UID: a.UID}, map[string]interface{}{ + "rewards": cardInfo.Rewards, + }) } } + if rewardList == nil { rewardList, _ = util.StringToInt64Slice(cardInfo.Rewards, ",") } + if cardInfo.RechargeTime != 0 { + resp.RechargeStatus = true + } + // step:签完7天就重置 + if cardInfo.Day >= len(rewardList) { + resp.RechargeStatus = false + } for _, item := range rewardList { resp.RewardList = append(resp.RewardList, values.WeekCardInfo{ Min: cons.MiniLimit, @@ -1306,11 +1328,11 @@ func ActivityWeekCardInfo(c *gin.Context) { Val: item, }) } - if !util.IsSameDayTimeStamp(time.Now().Unix(), cardInfo.LastDraw) { - resp.Status = true - } - if cardInfo.RechargeTime != 0 { - resp.RechargeStatus = true + resp.Status = true + if config.GetBase().Release { + if util.IsSameDayTimeStamp(time.Now().Unix(), cardInfo.LastDraw) { + resp.Status = false + } } resp.RewardDay = cardInfo.Day resp.ChannelList = call.GetConfigPayChannelsByID(common.CurrencyINR) @@ -1329,6 +1351,8 @@ func ActivityWeekCardDraw(c *gin.Context) { if !a.S(req) { return } + resp := &values.ActivityWeekCardDrawResp{} + a.Data = resp conf := call.GetConfigActivityWeekCard() card := call.GetUserWeekCard(a.UID) if card.ID == 0 { @@ -1336,12 +1360,19 @@ func ActivityWeekCardDraw(c *gin.Context) { return } now := time.Now().Unix() - if util.IsSameDayTimeStamp(now, card.LastDraw) { + if config.GetBase().Release { + if util.IsSameDayTimeStamp(now, card.LastDraw) { + a.Code = values.CodeRetry + a.Msg = "today has reward" + return + } + } + rewards, _ := util.StringToInt64Slice(card.Rewards, ",") + if card.Day >= len(rewards) { a.Code = values.CodeRetry - a.Msg = "today has reward" + a.Msg = "The weekly card has been collected" return } - rewards, _ := util.StringToInt64Slice(card.Rewards, ",") rows, err := db.Mysql().UpdateRes(&common.ActivityWeekCardData{UID: a.UID}, map[string]interface{}{"day": gorm.Expr("day + 1"), "last_draw": now}) if rows == 0 || err != nil { @@ -1350,7 +1381,7 @@ func ActivityWeekCardDraw(c *gin.Context) { return } var reward int64 - if card.Day < len(rewards) { + if card.Day < 6 { reward = rewards[card.Day] * common.DecimalDigits } else { // 第几天折扣券 @@ -1379,22 +1410,22 @@ func ActivityWeekCardDraw(c *gin.Context) { } } call.AddUserDiscountTicket(a.UID, conf.Discount, exi2) + resp.DiscountTicket = conf.Discount } - resp := &values.ActivityWeekCardDrawResp{ - Reward: reward, + resp.Reward = reward + if reward > 0 { + call.UpdateCurrencyPro(&common.UpdateCurrency{ + CurrencyBalance: &common.CurrencyBalance{ + UID: a.UID, + Type: common.CurrencyINR, + Value: reward, + Event: common.CurrencyEventActivityWeekCard, + ChannelID: a.Channel, + NeedBet: call.GetConfigCurrencyResourceNeedBet(common.CurrencyResourceBonus, reward), + }, + }) } - a.Data = resp - call.UpdateCurrencyPro(&common.UpdateCurrency{ - CurrencyBalance: &common.CurrencyBalance{ - UID: a.UID, - Type: common.CurrencyINR, - Value: reward, - Event: common.CurrencyEventActivityWeekCard, - ChannelID: a.Channel, - NeedBet: call.GetConfigCurrencyResourceNeedBet(common.CurrencyResourceBonus, reward), - }, - }) } @@ -1893,7 +1924,6 @@ func ActivityBetDrawDraw(c *gin.Context) { if !a.CheckActivityExpire(common.ActivityIDBetDraw) { return } - configList, weightList := call.GetConfigBetDrawByType(req.WheelType) if len(configList) == 0 { a.Code = values.CodeRetry @@ -1905,7 +1935,7 @@ func ActivityBetDrawDraw(c *gin.Context) { now := time.Now() spinInfo := drawInfo.SpinInfo // step:判断cd - if spinInfo.LastSpinTime != 0 && now.Unix()-spinInfo.LastSpinTime < conf.Cd { + if spinInfo.LastSpinTime != 0 && spinInfo.NextSpinTIme > now.Unix() { a.Code = values.CodeRetry a.Msg = "Unarrived spin time" return diff --git a/modules/web/routers/routers_activity.go b/modules/web/routers/routers_activity.go index 50c7f71..9b48aab 100644 --- a/modules/web/routers/routers_activity.go +++ b/modules/web/routers/routers_activity.go @@ -27,8 +27,6 @@ func activity(e *gin.RouterGroup) { e.POST("/activity/sign/new/info", handler.ActivitySignNewInfo) e.POST("/activity/sign/new/draw", handler.ActivitySignNewDraw) e.POST("/activity/breakGift/info", handler.ActivityBreakGiftInfo) - e.POST("/activity/weekCard/info", handler.ActivityWeekCardInfo) - e.POST("/activity/weekCard/draw", handler.ActivityWeekCardDraw) e.POST("/activity/slots/info", handler.ActivitySlotsInfo) e.POST("/activity/slots/draw", handler.ActivitySlotsDraw) e.POST("/activity/slots/drawLast", handler.ActivitySlotsDrawLast) @@ -46,4 +44,6 @@ func activity(e *gin.RouterGroup) { // 首充返还 e.POST("/activity/firstRechargeBack/info", handler.ActivityFirstRechargeBackInfo) e.POST("/activity/firstRechargeBack/draw", handler.ActivityFirstRechargeBackDraw) + e.POST("/activity/weekCard/info", handler.ActivityWeekCardInfo) + e.POST("/activity/weekCard/draw", handler.ActivityWeekCardDraw) } diff --git a/modules/web/values/activity.go b/modules/web/values/activity.go index ddda8ba..91f2b85 100644 --- a/modules/web/values/activity.go +++ b/modules/web/values/activity.go @@ -160,7 +160,7 @@ type ActivityWeekCardDrawReq struct { // DiscountTicket 获得的折扣券折扣 type ActivityWeekCardDrawResp struct { Reward int64 - DiscountTicket string + DiscountTicket int64 } // Spin 可转次数 diff --git a/util/util.go b/util/util.go index 95228cf..009ea4b 100644 --- a/util/util.go +++ b/util/util.go @@ -993,31 +993,29 @@ func StringToInt64Slice(s, sep string) ([]int64, error) { return int64Slice, nil } -// 通过总数Count分成一个递增数列 -func GenerateSequence(N, M int64) ([]int64, error) { - length := int64(5) +func GenerateRandomSequence(totalSum, minValue, length int64) ([]int64, error) { - // 初步生成一个递增数列 [M, M+1, ..., M+5] sequence := make([]int64, length) for i := int64(0); i < length; i++ { - sequence[i] = M + i + sequence[i] = minValue } - // 计算初步生成数列的总和 - sumInitial := (2*M + length - 1) * length / 2 - - // 如果初步生成数列的总和已经大于 N,则无法生成 - if sumInitial > N { - return nil, fmt.Errorf("无法生成满足条件的数列") + initialSum := minValue * length + if initialSum > totalSum { + return nil, fmt.Errorf("无法生成满足条件的序列") } - // 计算剩余需要分配的值 - remaining := N - sumInitial + remaining := totalSum - initialSum - // 将剩余的值均匀分配到数列中,从后往前加值,保持递增 - for i := length - 1; i >= 0 && remaining > 0; i-- { - sequence[i] += remaining - remaining = 0 + rand.Seed(time.Now().UnixNano()) + for remaining > 0 { + batchSize := remaining / length // 计算一次性分配的批量大小 + if batchSize == 0 { + batchSize = 1 + } + index := rand.Int63n(length) + sequence[index] += batchSize + remaining -= batchSize } return sequence, nil From 8322aa15c070f61319ed2ebdf3057624590ae5b8 Mon Sep 17 00:00:00 2001 From: mofangmin Date: Fri, 23 Aug 2024 17:38:14 +0800 Subject: [PATCH 12/14] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A6=96=E5=85=85?= =?UTF-8?q?=E5=8C=85=E8=B5=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/web/handler/activity.go | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/modules/web/handler/activity.go b/modules/web/handler/activity.go index 7b9933e..2b996b2 100644 --- a/modules/web/handler/activity.go +++ b/modules/web/handler/activity.go @@ -649,21 +649,24 @@ func ActivityFirstRechargeBackInfo(c *gin.Context) { resp.CanRecharge = true return } - val := data.Amount - call.GetUserCurrencyTotal(a.UID, common.CurrencyINR) - rechargeInfo.WithdrawingCash - if val < 0 { - val = 0 - } - val = val * conf.MaxBack / 100 - now := time.Now().Unix() - if p.Birth+conf.CD >= now && data.Reward == 0 { - db.Mysql().Update(&common.ActivityFirstRechargeBackData{UID: a.UID}, map[string]interface{}{ - "reward": val, - }) + if data.Reward == 0 { + val := data.Amount - call.GetUserCurrencyTotal(a.UID, common.CurrencyINR) - rechargeInfo.WithdrawingCash + if val < 0 { + val = 0 + } + val = val * conf.MaxBack / 100 + now := time.Now().Unix() + if p.Birth+conf.CD >= now && data.Reward == 0 { + db.Mysql().Update(&common.ActivityFirstRechargeBackData{UID: a.UID}, map[string]interface{}{ + "reward": val, + }) + } + data.Reward = val } - if data.RewardTime > 0 && val > 0 { + if data.RewardTime > 0 { resp.Draw = true } - resp.Back = val + resp.Back = data.Reward } func ActivityFirstRechargeBackDraw(c *gin.Context) { From 93a56db5cb88358e5304b1cb5a931a10113c5f94 Mon Sep 17 00:00:00 2001 From: mofangmin Date: Fri, 23 Aug 2024 18:12:34 +0800 Subject: [PATCH 13/14] =?UTF-8?q?=E5=91=A8=E5=8D=A1=E6=89=93=E7=A0=81?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/web/handler/activity.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/web/handler/activity.go b/modules/web/handler/activity.go index 2b996b2..132b978 100644 --- a/modules/web/handler/activity.go +++ b/modules/web/handler/activity.go @@ -1425,7 +1425,7 @@ func ActivityWeekCardDraw(c *gin.Context) { Value: reward, Event: common.CurrencyEventActivityWeekCard, ChannelID: a.Channel, - NeedBet: call.GetConfigCurrencyResourceNeedBet(common.CurrencyResourceBonus, reward), + NeedBet: call.GetConfigCurrencyResourceNeedBet(common.CurrencyResourceWeekCard, reward), }, }) } From f97dcd02892e9a08e7fb88a8a67f79e6a5a2572f Mon Sep 17 00:00:00 2001 From: mofangmin Date: Sat, 24 Aug 2024 16:42:37 +0800 Subject: [PATCH 14/14] =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/backend/handler/common/common.go | 2 +- modules/web/handler/activity.go | 57 +++++++++++++++--------- modules/web/values/activity.go | 4 ++ pb/proto/platform.proto | 2 + 4 files changed, 44 insertions(+), 21 deletions(-) diff --git a/modules/backend/handler/common/common.go b/modules/backend/handler/common/common.go index ac0d402..a0851ed 100644 --- a/modules/backend/handler/common/common.go +++ b/modules/backend/handler/common/common.go @@ -133,5 +133,5 @@ func UploadOSS(c *gin.Context) { log.Error("UploadOSS PutObject err:%v", err) return } - rsp.Url = fmt.Sprintf("https://%s/%s%s%d_%s", ossConf.Domain, ossConf.ObjectName, req.Folder, time.Now().Unix(), file.Filename) + rsp.Url = fmt.Sprintf("https://%s/%s%s%d_%s", ossConf.Domain, ossConf.ObjectName, req.Folder, now, file.Filename) } diff --git a/modules/web/handler/activity.go b/modules/web/handler/activity.go index 132b978..aaa61fd 100644 --- a/modules/web/handler/activity.go +++ b/modules/web/handler/activity.go @@ -656,10 +656,15 @@ func ActivityFirstRechargeBackInfo(c *gin.Context) { } val = val * conf.MaxBack / 100 now := time.Now().Unix() - if p.Birth+conf.CD >= now && data.Reward == 0 { - db.Mysql().Update(&common.ActivityFirstRechargeBackData{UID: a.UID}, map[string]interface{}{ + if now >= p.Birth+conf.CD && data.Reward == 0 && data.RechargeTime == 0 { + update := map[string]interface{}{ "reward": val, - }) + } + if val == 0 { + data.RechargeTime = now + update["reward_time"] = now + } + db.Mysql().Update(&common.ActivityFirstRechargeBackData{UID: a.UID}, update) } data.Reward = val } @@ -667,6 +672,9 @@ func ActivityFirstRechargeBackInfo(c *gin.Context) { resp.Draw = true } resp.Back = data.Reward + if !resp.Draw { + call.PushRed(a.UID, pb.RedPointModule_RedPointFirstRecharge, 1) + } } func ActivityFirstRechargeBackDraw(c *gin.Context) { @@ -677,11 +685,15 @@ func ActivityFirstRechargeBackDraw(c *gin.Context) { if !a.CheckActivityExpire(common.ActivityIDFirstRechargeBack) { return } + resp := new(values.ActivityFirstRechargeBackDrawResp) + a.Data = resp conf := call.GetConfigActivityFirstRechargeBack() data := call.GetUserFirstRechargeBackData(a.UID) - if time.Now().Unix()-data.RechargeTime < conf.CD { + p, _ := call.GetUserXInfo(a.UID, "birth") + if time.Now().Unix()-p.Birth < conf.CD { log.Error("not ActivityFirstRechargeBackDraw time:%+v", data) a.Code = values.CodeRetry + a.Msg = "Unarrived time" return } if data.RewardTime > 0 { @@ -708,7 +720,9 @@ func ActivityFirstRechargeBackDraw(c *gin.Context) { a.Code = values.CodeRetry return } + resp.Reward = val call.UploadActivityData(a.UID, common.ActivityIDFirstRechargeBack, common.ActivityDataJoin, val) + call.PushRed(a.UID, pb.RedPointModule_RedPointFirstRecharge, 0) } // 幸运码活动 @@ -1327,7 +1341,7 @@ func ActivityWeekCardInfo(c *gin.Context) { for _, item := range rewardList { resp.RewardList = append(resp.RewardList, values.WeekCardInfo{ Min: cons.MiniLimit, - Max: cons.RewardAmount, + Max: cons.RewardAmount - cons.MiniLimit*4, Val: item, }) } @@ -1340,6 +1354,9 @@ func ActivityWeekCardInfo(c *gin.Context) { resp.RewardDay = cardInfo.Day resp.ChannelList = call.GetConfigPayChannelsByID(common.CurrencyINR) resp.ProductList = call.GetConfigPayProductByActivityID(common.ActivityIDWeekCard) + if resp.Status { + call.PushRed(a.UID, pb.RedPointModule_RedPointWeekCard, 1) + } } func ActivityWeekCardDraw(c *gin.Context) { @@ -1415,7 +1432,10 @@ func ActivityWeekCardDraw(c *gin.Context) { call.AddUserDiscountTicket(a.UID, conf.Discount, exi2) resp.DiscountTicket = conf.Discount } - + resource := common.CurrencyResourceWeekCard + if card.Day > 0 { + resource = common.CurrencyResourceBonus + } resp.Reward = reward if reward > 0 { call.UpdateCurrencyPro(&common.UpdateCurrency{ @@ -1425,10 +1445,11 @@ func ActivityWeekCardDraw(c *gin.Context) { Value: reward, Event: common.CurrencyEventActivityWeekCard, ChannelID: a.Channel, - NeedBet: call.GetConfigCurrencyResourceNeedBet(common.CurrencyResourceWeekCard, reward), + NeedBet: call.GetConfigCurrencyResourceNeedBet(resource, reward), }, }) } + call.PushRed(a.UID, pb.RedPointModule_RedPointWeekCard, 0) } @@ -1894,11 +1915,6 @@ func ActivityBetDrawInfo(c *gin.Context) { Lucky: drawInfo.Lucky, } a.Data = resp - for _, item := range resp.List { - if resp.Lucky >= item.Cost && vipInfo.Level >= item.VipUnlock { - call.PushRed(a.UID, pb.RedPointModule_RedPointFreeSpin, uint32(1)) - } - } now := time.Now() update := false if !util.IsSameDayTimeStamp(drawInfo.SpinInfo.LastSpinTime, now.Unix()) { @@ -1913,6 +1929,13 @@ func ActivityBetDrawInfo(c *gin.Context) { drawInfo.SpinInfo.SpinCount = confList[0].LimitNum resp.SpinInfo = append(resp.SpinInfo, drawInfo.SpinInfo) call.UploadActivityData(a.UID, common.ActivityIDBetDraw, common.ActivityDataClick, 0) + for _, item := range resp.List { + if resp.Lucky >= item.Cost && vipInfo.Level >= item.VipUnlock && + drawInfo.SpinInfo.SpinNum < drawInfo.SpinInfo.SpinCount && + now.Unix() >= drawInfo.SpinInfo.NextSpinTIme { + call.PushRed(a.UID, pb.RedPointModule_RedPointFreeSpin, uint32(1)) + } + } } func ActivityBetDrawDraw(c *gin.Context) { @@ -2000,14 +2023,8 @@ func ActivityBetDrawDraw(c *gin.Context) { drawInfo = common.ActivityBetDrawData{UID: a.UID} db.Mysql().Get(&drawInfo) - list := call.GetConfigBetDraw() - num := 0 - for _, item := range list { - if drawInfo.Lucky >= item.Cost { - num++ - } - } - call.PushRed(a.UID, pb.RedPointModule_RedPointFreeSpin, uint32(num)) + + call.PushRed(a.UID, pb.RedPointModule_RedPointFreeSpin, uint32(0)) } func ActivityBetDrawHistory(c *gin.Context) { diff --git a/modules/web/values/activity.go b/modules/web/values/activity.go index 91f2b85..de5c948 100644 --- a/modules/web/values/activity.go +++ b/modules/web/values/activity.go @@ -56,6 +56,10 @@ type ActivityFirstRechargeBackInfoResp struct { ProductList []*common.ConfigPayProduct } +type ActivityFirstRechargeBackDrawResp struct { + Reward int64 +} + // ID 物品id // Reward 奖励 // Per 概率 diff --git a/pb/proto/platform.proto b/pb/proto/platform.proto index 11f7346..bbc2173 100644 --- a/pb/proto/platform.proto +++ b/pb/proto/platform.proto @@ -56,6 +56,8 @@ enum RedPointModule{ RedPointFreeSpin = 6; // 免费转盘 RedPointVipReward = 7; // vip升级奖励 RedPointLoginAgain = 8; // 第二次登录游戏 + RedPointWeekCard = 9; // 周卡 + RedPointFirstRecharge = 10 ; // 首充 } message RedInfo {