Commit 537b64ea1ca93f95f61096d18be84f9bcc56f7a7
1 parent
87f77056
Exists in
master
提交接口
Showing
5 changed files
with
152 additions
and
5 deletions
Show diff stats
src/HttpServer/logic/constdef.go
| @@ -59,6 +59,8 @@ const ( | @@ -59,6 +59,8 @@ const ( | ||
| 59 | SDKOPGOLD_TYPEWE = 302 //微转发金币类型 | 59 | SDKOPGOLD_TYPEWE = 302 //微转发金币类型 |
| 60 | GUANGOLDNUMLIMIT = 900 //存钱罐金币上限 | 60 | GUANGOLDNUMLIMIT = 900 //存钱罐金币上限 |
| 61 | LUCKYBAGDAYLIMIT = 10 //每日福袋次数 | 61 | LUCKYBAGDAYLIMIT = 10 //每日福袋次数 |
| 62 | + FREETICKETCOUNT = 1 //免费抽奖次数 | ||
| 63 | + TICKETCOUNT = 5 //看视频抽奖次数 | ||
| 62 | ) | 64 | ) |
| 63 | 65 | ||
| 64 | const ( | 66 | const ( |
src/HttpServer/logic/datadef.go
| @@ -62,6 +62,8 @@ type SyncuserdataData struct { | @@ -62,6 +62,8 @@ type SyncuserdataData struct { | ||
| 62 | Sumloginday int `json:"sumloginday"` | 62 | Sumloginday int `json:"sumloginday"` |
| 63 | Nowtime int `json:"nowtime"` | 63 | Nowtime int `json:"nowtime"` |
| 64 | Luckbaglefttime int `json:"luckbaglefttime"` | 64 | Luckbaglefttime int `json:"luckbaglefttime"` |
| 65 | + Leftfreeticket int `json:"leftfreeticket"` | ||
| 66 | + Leftticket int `json:"leftticket"` | ||
| 65 | } | 67 | } |
| 66 | 68 | ||
| 67 | type SyncuserdataResp struct { | 69 | type SyncuserdataResp struct { |
| @@ -250,6 +252,17 @@ type QueryrankinfoResp struct { | @@ -250,6 +252,17 @@ type QueryrankinfoResp struct { | ||
| 250 | Data QueryrankinfoData `json:"data"` | 252 | Data QueryrankinfoData `json:"data"` |
| 251 | } | 253 | } |
| 252 | 254 | ||
| 255 | +type QuerydrawrewardData struct { | ||
| 256 | + Getgold int `json:"getgold"` | ||
| 257 | + Walletgold int `json:"walletgold"` | ||
| 258 | +} | ||
| 259 | + | ||
| 260 | +type QuerydrawrewardResp struct { | ||
| 261 | + Code int `json:"code"` | ||
| 262 | + Message string `json:"message"` | ||
| 263 | + Data QuerydrawrewardData `json:"data"` | ||
| 264 | +} | ||
| 265 | + | ||
| 253 | type GetcashReq struct { | 266 | type GetcashReq struct { |
| 254 | Gameid string `json:"gameid"` | 267 | Gameid string `json:"gameid"` |
| 255 | Channel string `json:"channel"` | 268 | Channel string `json:"channel"` |
| @@ -498,6 +511,8 @@ type UserData struct { | @@ -498,6 +511,8 @@ type UserData struct { | ||
| 498 | LastUpdateTime int //上一次同步时间 | 511 | LastUpdateTime int //上一次同步时间 |
| 499 | OfflineGold int //离线金币数量 | 512 | OfflineGold int //离线金币数量 |
| 500 | HighScore int64 //玩家历史最高分 | 513 | HighScore int64 //玩家历史最高分 |
| 514 | + FreeTicket int //免费抽奖次数 | ||
| 515 | + Ticket int //看视频抽奖次数 | ||
| 501 | WithDraw WithDrawInfo //提现记录信息 | 516 | WithDraw WithDrawInfo //提现记录信息 |
| 502 | Task TaskInfo //玩家任务完成相关信息 | 517 | Task TaskInfo //玩家任务完成相关信息 |
| 503 | Achieve AchieveMentInfo //玩家成就完成相关数据 | 518 | Achieve AchieveMentInfo //玩家成就完成相关数据 |
src/HttpServer/logic/function.go
| @@ -82,6 +82,8 @@ func (u *UserData) HandlePassDay(uuid int, channel string) { | @@ -82,6 +82,8 @@ func (u *UserData) HandlePassDay(uuid int, channel string) { | ||
| 82 | u.Task.PlaySmall = 0 | 82 | u.Task.PlaySmall = 0 |
| 83 | u.RedBagFetchIdlist = u.RedBagFetchIdlist[:0] | 83 | u.RedBagFetchIdlist = u.RedBagFetchIdlist[:0] |
| 84 | u.LuckyBagLeftTimes = LUCKYBAGDAYLIMIT | 84 | u.LuckyBagLeftTimes = LUCKYBAGDAYLIMIT |
| 85 | + u.FreeTicket = FREETICKETCOUNT | ||
| 86 | + u.Ticket = TICKETCOUNT | ||
| 85 | 87 | ||
| 86 | err := InitTaskAndAchievement(uuid, channel) | 88 | err := InitTaskAndAchievement(uuid, channel) |
| 87 | if err != nil { | 89 | if err != nil { |
| @@ -397,6 +399,8 @@ func InitUserInfo(resp *UserLoginResp, uniqueuid, gameid, channel string, uuid i | @@ -397,6 +399,8 @@ func InitUserInfo(resp *UserLoginResp, uniqueuid, gameid, channel string, uuid i | ||
| 397 | initdata.HeadUrl = "1" | 399 | initdata.HeadUrl = "1" |
| 398 | initdata.RegTime = int(time.Now().Unix()) | 400 | initdata.RegTime = int(time.Now().Unix()) |
| 399 | initdata.LuckyBagLeftTimes = LUCKYBAGDAYLIMIT | 401 | initdata.LuckyBagLeftTimes = LUCKYBAGDAYLIMIT |
| 402 | + initdata.FreeTicket = FREETICKETCOUNT | ||
| 403 | + initdata.Ticket = TICKETCOUNT | ||
| 400 | 404 | ||
| 401 | for _, val := range jsonconf.GetJsonConf().RmbConfig { | 405 | for _, val := range jsonconf.GetJsonConf().RmbConfig { |
| 402 | var tmp WithDrawDesc | 406 | var tmp WithDrawDesc |
| @@ -539,6 +543,40 @@ func AddCoinToSdk(uuid int, goldnum int, gameid string, channel string, atype in | @@ -539,6 +543,40 @@ func AddCoinToSdk(uuid int, goldnum int, gameid string, channel string, atype in | ||
| 539 | return resp.Data.Mycoin, nil | 543 | return resp.Data.Mycoin, nil |
| 540 | } | 544 | } |
| 541 | 545 | ||
| 546 | +//计算转盘抽奖 | ||
| 547 | +func CalcTurnTableNum() int { | ||
| 548 | + rtnum := 0 | ||
| 549 | + | ||
| 550 | + sumrate := 0 | ||
| 551 | + tmprate := 0 | ||
| 552 | + idx := -1 | ||
| 553 | + rand.Seed(time.Now().UnixNano()) | ||
| 554 | + randnum := rand.Intn(100) | ||
| 555 | + cflist := jsonconf.GetJsonConf().TrunTableConfig | ||
| 556 | + for _, vv := range cflist { | ||
| 557 | + sumrate += vv.Rate | ||
| 558 | + } | ||
| 559 | + logger.Info("CalcTurnTableNum sumrate=%v,randnum=%v,cflist=%+v", sumrate, randnum, cflist) | ||
| 560 | + for k, v := range cflist { | ||
| 561 | + tmprate += int(v.Rate * 100 / sumrate) | ||
| 562 | + logger.Info("CalcTurnTableNum tmprate=%v", tmprate) | ||
| 563 | + if tmprate >= randnum { | ||
| 564 | + idx = k | ||
| 565 | + break | ||
| 566 | + } | ||
| 567 | + } | ||
| 568 | + | ||
| 569 | + if idx == -1 { | ||
| 570 | + if len(cflist) > 0 { | ||
| 571 | + rtnum = cflist[0].Desc | ||
| 572 | + } | ||
| 573 | + } else { | ||
| 574 | + rtnum = cflist[idx].Desc | ||
| 575 | + } | ||
| 576 | + | ||
| 577 | + return rtnum | ||
| 578 | +} | ||
| 579 | + | ||
| 542 | //计算福袋金额 | 580 | //计算福袋金额 |
| 543 | func CalcLuckYBagNum() int { | 581 | func CalcLuckYBagNum() int { |
| 544 | rtnum := 0 | 582 | rtnum := 0 |
src/HttpServer/logic/httpserver.go
| @@ -58,9 +58,10 @@ func startServerHttpServe() { | @@ -58,9 +58,10 @@ func startServerHttpServe() { | ||
| 58 | http.HandleFunc("/russiaxiaoxiao/fetchoffliengold", Fetchoffliengold) //请求领取离线金币 | 58 | http.HandleFunc("/russiaxiaoxiao/fetchoffliengold", Fetchoffliengold) //请求领取离线金币 |
| 59 | http.HandleFunc("/russiaxiaoxiao/uploadhigestscore", Uploadhigestscore) //上报玩家历史最高分 | 59 | http.HandleFunc("/russiaxiaoxiao/uploadhigestscore", Uploadhigestscore) //上报玩家历史最高分 |
| 60 | http.HandleFunc("/russiaxiaoxiao/queryrankinfo", Queryrankinfo) //查询排行榜 | 60 | http.HandleFunc("/russiaxiaoxiao/queryrankinfo", Queryrankinfo) //查询排行榜 |
| 61 | + http.HandleFunc("/russiaxiaoxiao/querydrawreward", Querydrawreward) //请求抽奖 | ||
| 61 | 62 | ||
| 62 | //.......................................... | 63 | //.......................................... |
| 63 | - http.HandleFunc("/eliminatestar/getuserdata", Getuserdata) //获取玩家数据 | 64 | + /*http.HandleFunc("/eliminatestar/getuserdata", Getuserdata) //获取玩家数据 |
| 64 | http.HandleFunc("/eliminatestar/watchads", Watchads) //观看激励视频 | 65 | http.HandleFunc("/eliminatestar/watchads", Watchads) //观看激励视频 |
| 65 | http.HandleFunc("/eliminatestar/queryguaninfo", Queryguaninfo) //获取存钱罐数据 | 66 | http.HandleFunc("/eliminatestar/queryguaninfo", Queryguaninfo) //获取存钱罐数据 |
| 66 | //http.HandleFunc("/eliminatestar/getguangold", Getguangold) //获取金币到存钱罐 | 67 | //http.HandleFunc("/eliminatestar/getguangold", Getguangold) //获取金币到存钱罐 |
| @@ -75,10 +76,10 @@ func startServerHttpServe() { | @@ -75,10 +76,10 @@ func startServerHttpServe() { | ||
| 75 | http.HandleFunc("/eliminatestar/getnewlevelreward", Getnewlevelreward) //领取任务或者成就奖励 | 76 | http.HandleFunc("/eliminatestar/getnewlevelreward", Getnewlevelreward) //领取任务或者成就奖励 |
| 76 | http.HandleFunc("/eliminatestar/querysigndata", Querysigndata) //获取签到数据 | 77 | http.HandleFunc("/eliminatestar/querysigndata", Querysigndata) //获取签到数据 |
| 77 | http.HandleFunc("/eliminatestar/usersign", Usersign) //玩家签到 | 78 | http.HandleFunc("/eliminatestar/usersign", Usersign) //玩家签到 |
| 78 | - // | ||
| 79 | - http.HandleFunc("/eliminatestar/readNumUpload", ReadNumUpload) //阅读量上报 | ||
| 80 | - http.HandleFunc("/eliminatestar/queryreadgold", QueryReadGold) //获取微转发金币数 | ||
| 81 | - http.HandleFunc("/eliminatestar/fetchreadgold", Fetchreadgold) //领取微转发金币数 | 79 | + //*/ |
| 80 | + http.HandleFunc("/russiaxiaoxiao/readNumUpload", ReadNumUpload) //阅读量上报 | ||
| 81 | + http.HandleFunc("/russiaxiaoxiao/queryreadgold", QueryReadGold) //获取微转发金币数 | ||
| 82 | + http.HandleFunc("/russiaxiaoxiao/fetchreadgold", Fetchreadgold) //领取微转发金币数 | ||
| 82 | 83 | ||
| 83 | err := http.ListenAndServe(conf.GetServerHttpAddrConf(), nil) | 84 | err := http.ListenAndServe(conf.GetServerHttpAddrConf(), nil) |
| 84 | CheckErr(err) | 85 | CheckErr(err) |
| @@ -487,6 +488,34 @@ func Querdrawinfo(w http.ResponseWriter, r *http.Request) { | @@ -487,6 +488,34 @@ func Querdrawinfo(w http.ResponseWriter, r *http.Request) { | ||
| 487 | //HandlerQuerdrawinfo(w, s, Uuid) | 488 | //HandlerQuerdrawinfo(w, s, Uuid) |
| 488 | } | 489 | } |
| 489 | 490 | ||
| 491 | +func Querydrawreward(w http.ResponseWriter, r *http.Request) { | ||
| 492 | + | ||
| 493 | + gameid := "" | ||
| 494 | + channel := "" | ||
| 495 | + uniqueid := "" | ||
| 496 | + Uuid := 0 | ||
| 497 | + if len(r.Header) > 0 { | ||
| 498 | + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) | ||
| 499 | + gameid = r.Header.Get("Gameid") | ||
| 500 | + channel = r.Header.Get("Channel") | ||
| 501 | + uniqueid = r.Header.Get("Uuid") + r.Header.Get("Channel") | ||
| 502 | + } | ||
| 503 | + | ||
| 504 | + if Uuid == 0 { | ||
| 505 | + SetHeader(w) | ||
| 506 | + logger.Error("Uuid is nil!") | ||
| 507 | + return | ||
| 508 | + } | ||
| 509 | + result, _ := ioutil.ReadAll(r.Body) | ||
| 510 | + r.Body.Close() | ||
| 511 | + | ||
| 512 | + s := string(result) | ||
| 513 | + logger.Info("Querydrawreward , body:%v,uuid=%v", s, uniqueid) | ||
| 514 | + | ||
| 515 | + HandlerQuerydrawreward(w, s, uniqueid, gameid, channel, Uuid) | ||
| 516 | + | ||
| 517 | +} | ||
| 518 | + | ||
| 490 | func Queryrankinfo(w http.ResponseWriter, r *http.Request) { | 519 | func Queryrankinfo(w http.ResponseWriter, r *http.Request) { |
| 491 | 520 | ||
| 492 | gameid := "" | 521 | gameid := "" |
src/HttpServer/logic/logic.go
| @@ -38,6 +38,8 @@ func HandlerSyncuserdata(w http.ResponseWriter, data string, uniqueuuid, gameid, | @@ -38,6 +38,8 @@ func HandlerSyncuserdata(w http.ResponseWriter, data string, uniqueuuid, gameid, | ||
| 38 | resp.Data.Sumloginday = uinfo.SumLoginDay | 38 | resp.Data.Sumloginday = uinfo.SumLoginDay |
| 39 | resp.Data.Nowtime = int(time.Now().Unix()) | 39 | resp.Data.Nowtime = int(time.Now().Unix()) |
| 40 | resp.Data.Luckbaglefttime = uinfo.LuckyBagLeftTimes | 40 | resp.Data.Luckbaglefttime = uinfo.LuckyBagLeftTimes |
| 41 | + resp.Data.Leftfreeticket = uinfo.FreeTicket | ||
| 42 | + resp.Data.Leftticket = uinfo.Ticket | ||
| 41 | break | 43 | break |
| 42 | } | 44 | } |
| 43 | 45 | ||
| @@ -117,6 +119,67 @@ func HandlerUploaduserbasicinfo(w http.ResponseWriter, data string, uniqueuuid s | @@ -117,6 +119,67 @@ func HandlerUploaduserbasicinfo(w http.ResponseWriter, data string, uniqueuuid s | ||
| 117 | fmt.Fprint(w, string(respstr)) | 119 | fmt.Fprint(w, string(respstr)) |
| 118 | } | 120 | } |
| 119 | 121 | ||
| 122 | +func HandlerQuerydrawreward(w http.ResponseWriter, data string, uniqueuuid, gameid, channel string, uuid int) { | ||
| 123 | + SetHeader(w) | ||
| 124 | + var resp QuerydrawrewardResp | ||
| 125 | + resp.Code = 0 | ||
| 126 | + resp.Message = "success" | ||
| 127 | + | ||
| 128 | + for { | ||
| 129 | + | ||
| 130 | + uinfo, err := GetUserInfo(uniqueuuid) | ||
| 131 | + if err != nil { | ||
| 132 | + logger.Info("GetUserInfo HandlerQuerydrawreward data failed:%v,for:%v", err, data) | ||
| 133 | + resp.Message = "GetUserInfo failed" | ||
| 134 | + resp.Code = 1 | ||
| 135 | + break | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + if uinfo.FreeTicket == 0 && uinfo.Ticket == 0 { | ||
| 139 | + //已经没有抽奖次数了 | ||
| 140 | + logger.Info("GetUserInfo HandlerQuerydrawreward data failed:%v,for:%v", err, data) | ||
| 141 | + resp.Message = "已经没有抽奖次数了" | ||
| 142 | + resp.Code = 1 | ||
| 143 | + break | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + addgold := CalcTurnTableNum() | ||
| 147 | + | ||
| 148 | + if addgold == 0 { | ||
| 149 | + logger.Info("GetUserInfo HandlerQuerydrawreward data failed:%v,for:%v", err, data) | ||
| 150 | + resp.Message = "CalcTurnTableNumfaile" | ||
| 151 | + resp.Code = 1 | ||
| 152 | + break | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + realgold, err := AddCoinToSdk(uuid, addgold, gameid, channel, REDBAGTYPE_106) | ||
| 156 | + if err != nil { | ||
| 157 | + logger.Info("GetUserInfo HandlerQuerydrawreward data failed:%v,for:%v", err, data) | ||
| 158 | + resp.Message = "后台加金币失败了" | ||
| 159 | + resp.Code = 1 | ||
| 160 | + break | ||
| 161 | + } | ||
| 162 | + | ||
| 163 | + uinfo.RealGold = realgold | ||
| 164 | + if uinfo.FreeTicket > 0 { | ||
| 165 | + uinfo.FreeTicket-- | ||
| 166 | + } else { | ||
| 167 | + uinfo.Ticket-- | ||
| 168 | + } | ||
| 169 | + | ||
| 170 | + SaveUserInfo(uinfo, uniqueuuid) | ||
| 171 | + resp.Data.Getgold = addgold | ||
| 172 | + resp.Data.Walletgold = uinfo.RealGold | ||
| 173 | + | ||
| 174 | + resp.Code = ERROR_OK | ||
| 175 | + break | ||
| 176 | + } | ||
| 177 | + | ||
| 178 | + //回包 | ||
| 179 | + respstr, _ := json.Marshal(&resp) | ||
| 180 | + fmt.Fprint(w, string(respstr)) | ||
| 181 | +} | ||
| 182 | + | ||
| 120 | func HandlerQueryrankinfo(w http.ResponseWriter, data string, uniqueuuid, gameid, channel string, uuid int) { | 183 | func HandlerQueryrankinfo(w http.ResponseWriter, data string, uniqueuuid, gameid, channel string, uuid int) { |
| 121 | SetHeader(w) | 184 | SetHeader(w) |
| 122 | var resp QueryrankinfoResp | 185 | var resp QueryrankinfoResp |