diff --git a/src/HttpServer/jsonconf/SignConfig.json b/src/HttpServer/jsonconf/SignConfig.json index 21f2818..b43686f 100644 --- a/src/HttpServer/jsonconf/SignConfig.json +++ b/src/HttpServer/jsonconf/SignConfig.json @@ -1,66 +1,37 @@ -{ - "rule": 0, - "round": 100, - "reward": { - "reward1": [ - { - "id": 1, - "num": 300 - }, - { - "id": 2, - "num": 300 - }, - { - "id": 3, - "num": 350 - }, - { - "id": 4, - "num": 350 - }, - { - "id": 5, - "num": 400 - }, - { - "id": 6, - "num": 400 - }, - { - "id": 7, - "num": 500 - } - ], - "reward2": [ - { - "id": 1, - "num": 10 - }, - { - "id": 2, - "num": 10 - }, - { - "id": 3, - "num": 10 - }, - { - "id": 4, - "num": 15 - }, - { - "id": 5, - "num": 15 - }, - { - "id": 6, - "num": 15 - }, - { - "id": 7, - "num": 20 - } - ] +[ + { + "id": 1, + "day": 1, + "reward": 1000 + }, + { + "id": 2, + "day": 2, + "reward": 5000 + }, + { + "id": 3, + "day": 3, + "reward": 1500 + }, + { + "id": 4, + "day": 4, + "reward": 2000 + }, + { + "id": 5, + "day": 5, + "reward": 2500 + }, + { + "id": 6, + "day": 6, + "reward": 3000 + }, + { + "id": 7, + "day": 7, + "reward": 10000 } -} \ No newline at end of file +] \ No newline at end of file diff --git a/src/HttpServer/jsonconf/jsonconf.go b/src/HttpServer/jsonconf/jsonconf.go index 560adeb..656d3f1 100644 --- a/src/HttpServer/jsonconf/jsonconf.go +++ b/src/HttpServer/jsonconf/jsonconf.go @@ -62,9 +62,9 @@ type SignReward struct { } type SignConfigDesc struct { - Rule int `json:"rule"` - Round int `json:"round"` - Reward SignReward `json:"reward"` + Id int `json:"id"` + Day int `json:"day"` + Reward int `json:"reward"` } type ActiveWithdrawConfigDesc struct { @@ -89,7 +89,7 @@ type GameConfig struct { MoneyBoxConfig []MoneyBoxLevelDesc MoneyBoxTimeConfig []MoneyBoxTimesDesc WithDrawConfig []WithDrawDesc - SignConfig SignConfigDesc + SignConfig []SignConfigDesc ActiveWithdrawConfig []ActiveWithdrawConfigDesc RedpacketConfig []RedpacketConfigDesc } @@ -98,25 +98,13 @@ func GetJsonConf() *GameConfig { return g_jsonconf } -func GetSignConfig(round, daynum int) *SignRewardDetail { - if round+1 > g_jsonconf.SignConfig.Round { - //取reward2 - if daynum > len(g_jsonconf.SignConfig.Reward.Reward2) { - logger.Error("GetSignConfig failed") - return nil +func GetsignConfig(id int) *SignConfigDesc { + for _, v := range g_jsonconf.SignConfig { + if v.Id == id { + return &v } - - return &g_jsonconf.SignConfig.Reward.Reward2[daynum-1] - - } else { - //取reward1 - if daynum > len(g_jsonconf.SignConfig.Reward.Reward1) { - logger.Error("GetSignConfig failed") - return nil - } - - return &g_jsonconf.SignConfig.Reward.Reward1[daynum-1] } + return nil } func GetRedpacketNum(id int) int { diff --git a/src/HttpServer/logic/constdef.go b/src/HttpServer/logic/constdef.go index 44571de..f93e46f 100644 --- a/src/HttpServer/logic/constdef.go +++ b/src/HttpServer/logic/constdef.go @@ -65,4 +65,5 @@ const ( READGOLDMULTI = 700 //阅读量到金币转化倍数 SDKOPGOLD_TYPEWE = 302 //微转发金币类型 SHAKELIMIT = 20 //摇一摇限制次数 + DAILYFETCHREDBAGNUMLIMIT = 50//每天红包领取次数限制 ) diff --git a/src/HttpServer/logic/datadef.go b/src/HttpServer/logic/datadef.go index 071add2..a40d6ab 100644 --- a/src/HttpServer/logic/datadef.go +++ b/src/HttpServer/logic/datadef.go @@ -24,6 +24,8 @@ type UserLoginData struct { Sumloginday int `json:"sumloginday"` Shakeleftcnt int `json:"shakeleftcnt"` IsNew int `json:"isnew"` + Issignshow int `json:"issignshow"` + Leftredbagnum int `json:"leftredbagnum"` } type UserLoginResp struct { @@ -226,9 +228,8 @@ type GetnewlevelrewardResp struct { } type QuerysigndataData struct { - Signround int `json:"signround"` - Continuessign int `json:"continuessign"` - IssignToday int `json:"issignToday"` + Curday int `json:"curday"` + Issigntaday int `json:"issigntaday"` } type QueryReadGoldData struct { @@ -266,6 +267,7 @@ type FetchredbagReq struct { type FetchredbagData struct { Getgoldnum int `json:"getgoldnum"` Walletgold int `json:"walletgold"` + Leftredbagnum int `json:"leftredbagnum"` } type FetchredbagResp struct { Code int `json:"code"` @@ -342,7 +344,10 @@ type UsersignReq struct { } type UsersignData struct { - Goldnum int `json:"goldnum"` + Curday int `json:"curday"` + Issigntaday int `json:"issigntaday"` + Walletgold int `json:"walletgold"` + Getgold int `json:"getgold"` } type UsersignResp struct { Code int `json:"code"` @@ -466,6 +471,7 @@ type UserData struct { Hfen int64 //当日最高积分 用于计算排行榜 Nickname string //逆臣 HeadUrl string //头像 + SignShow int //是否弹出签到 WithDraw WithDrawInfo //提现记录信息 //SpecialWithDraw WithDrawInfo //活跃提现记录信息 Task TaskInfo //玩家任务完成相关信息 diff --git a/src/HttpServer/logic/function.go b/src/HttpServer/logic/function.go index 7d1d6e8..a779553 100644 --- a/src/HttpServer/logic/function.go +++ b/src/HttpServer/logic/function.go @@ -715,6 +715,8 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int, uniqueuid s resp.Data.Sumloginday = initdata.SumLoginDay resp.Data.Shakeleftcnt = initdata.ShakeTime resp.Data.IsNew = initdata.IsNew + resp.Data.Issignshow = initdata.SignShow + resp.Data.Leftredbagnum = DAILYFETCHREDBAGNUMLIMIT - initdata.FetchRdBagNum err := SaveUserInfo(&initdata, uniqueuid) logger.Info("InitUserInfoddddd uinfo=%+v", initdata) @@ -913,6 +915,7 @@ func (u *UserData) HandlePassDay(uuid int, channel string) { u.ShakeTime = SHAKELIMIT u.FetchRdBagNum = 0 u.Hfen = 0 + u.SignShow = 1 //任务也需要处理 /*tasklist, err := GetTaskInfo(u.Userid, 1) @@ -1006,6 +1009,8 @@ func GetUserData(uuid int, uniqueuid string, req *UserLoginReq, resp *UserLoginR resp.Data.Sumloginday = data.SumLoginDay resp.Data.Shakeleftcnt = data.ShakeTime resp.Data.IsNew = data.IsNew + resp.Data.Issignshow = data.SignShow + resp.Data.Leftredbagnum = DAILYFETCHREDBAGNUMLIMIT - data.FetchRdBagNum return nil } diff --git a/src/HttpServer/logic/httpserver.go b/src/HttpServer/logic/httpserver.go index 0e433c0..fbdcdad 100644 --- a/src/HttpServer/logic/httpserver.go +++ b/src/HttpServer/logic/httpserver.go @@ -70,7 +70,7 @@ func startServerHttpServe() { http.HandleFunc("/sixstar/gettaskreward", Gettaskreward) //领取任务或者成就奖励 http.HandleFunc("/sixstar/getnewlevelreward", Getnewlevelreward) //领取任务或者成就奖励 http.HandleFunc("/sixstar/querysigndata", Querysigndata) //获取签到数据 - http.HandleFunc("/sixstar/usersign", Usersign) //玩家签到 + http.HandleFunc("/sixstar/dosign", Usersign) //玩家签到 http.HandleFunc("/sixstar/fetchredbag", Fetchredbag) //领取红包 http.HandleFunc("/sixstar/savadata", Savadata) //保存数据 http.HandleFunc("/sixstar/getdata", Getdata) //获取数据 diff --git a/src/HttpServer/logic/logic.go b/src/HttpServer/logic/logic.go index 2a1361d..912845a 100644 --- a/src/HttpServer/logic/logic.go +++ b/src/HttpServer/logic/logic.go @@ -385,9 +385,8 @@ func HandlerQuerysigndata(w http.ResponseWriter, data string, uuid int) { //此处要处理一下跨天逻辑 uinfo.HandlePassDay(uuid, rdata.Channel) - resp.Data.Continuessign = uinfo.SignSum - resp.Data.IssignToday = uinfo.IsSignToday - resp.Data.Signround = uinfo.SignRound + resp.Data.Curday = uinfo.SignSum + resp.Data.Issigntaday = uinfo.IsSignToday logger.Info("HandlerQuerysigndata resp=%v", resp) @@ -740,13 +739,21 @@ func HandlerFetchredbag(w http.ResponseWriter, data string, uuid int) { break } + if uinfo.FetchRdBagNum >= DAILYFETCHREDBAGNUMLIMIT { + resp.Message = "当日;领取红包次数已达上限" + resp.Code = ERROR_SRV_ERROR + break + } + readaddgold := uinfo.FetchRedPacket(rdata.Gameid, rdata.Channel, uuid) + uinfo.IsNew = 0 + uinfo.FetchRdBagNum++ + resp.Data.Walletgold = uinfo.RealGold resp.Data.Getgoldnum = readaddgold + resp.Data.Leftredbagnum = DAILYFETCHREDBAGNUMLIMIT - uinfo.FetchRdBagNum - uinfo.IsNew = 0 - uinfo.FetchRdBagNum++ //保存数据 err = SaveUserInfo(uinfo, uniqueuuid) @@ -802,7 +809,7 @@ func HandlerUsersign(w http.ResponseWriter, data string, uuid int) { } //获取配置 - cfg := jsonconf.GetSignConfig(uinfo.SignRound, uinfo.SignSum) + cfg := jsonconf.GetsignConfig(uinfo.SignRound) if cfg == nil { uinfo.SignSum-- logger.Error("GetSignConfig failed err=%v", err) @@ -811,8 +818,8 @@ func HandlerUsersign(w http.ResponseWriter, data string, uuid int) { break } - //uinfo.RealGold = - goldnum, _, err := AddCoinToSdk(uuid, cfg.Num, rdata.Gameid, rdata.Channel, 107) + addnum := cfg.Reward / 100 + goldnum, _, err := AddCoinToSdk(uuid, addnum, rdata.Gameid, rdata.Channel, 107) if err != nil { uinfo.SignSum-- logger.Error("AddCoinToSdk failed err=%v", err) @@ -821,11 +828,16 @@ func HandlerUsersign(w http.ResponseWriter, data string, uuid int) { break } + uinfo.SignShow = 0 + uinfo.IsSignToday = 1 uinfo.RealGold = goldnum //uinfo.RealGold += cfg.Num - resp.Data.Goldnum = uinfo.RealGold + resp.Data.Curday = uinfo.SignSum + resp.Data.Issigntaday = uinfo.IsSignToday + resp.Data.Walletgold = goldnum + resp.Data.Getgold = cfg.Reward //保存数据 err = SaveUserInfo(uinfo, uniqueuuid) -- libgit2 0.21.0