Commit 1c80023c45d78eea79edc822cdeb551686b236d7
1 parent
32e96c1d
Exists in
master
提交
Showing
4 changed files
with
141 additions
and
1 deletions
Show diff stats
src/HttpServer/jsonconf/jsonconf.go
| @@ -84,6 +84,13 @@ type InvestmentsConfigDesc struct { | @@ -84,6 +84,13 @@ type InvestmentsConfigDesc struct { | ||
| 84 | Reward []int `json:"reward"` | 84 | Reward []int `json:"reward"` |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | +type GunBigBounceConfigDesc struct { | ||
| 88 | + Id int `json:"id"` | ||
| 89 | + Gun_level int `json:"gun_level"` | ||
| 90 | + Luckybag float32 `json:"Luckybag"` | ||
| 91 | + RewardVideo int `json:"RewardVideo"` | ||
| 92 | +} | ||
| 93 | + | ||
| 87 | type GameConfig struct { | 94 | type GameConfig struct { |
| 88 | WithDrawConfig []WithDrawDesc | 95 | WithDrawConfig []WithDrawDesc |
| 89 | ActiveWithdrawConfig []ActiveWithdrawConfigDesc | 96 | ActiveWithdrawConfig []ActiveWithdrawConfigDesc |
| @@ -96,6 +103,7 @@ type GameConfig struct { | @@ -96,6 +103,7 @@ type GameConfig struct { | ||
| 96 | TaskConfig []AchieveDesc | 103 | TaskConfig []AchieveDesc |
| 97 | SignConfig []SignConfigDesc | 104 | SignConfig []SignConfigDesc |
| 98 | InvestmentsConfig []InvestmentsConfigDesc | 105 | InvestmentsConfig []InvestmentsConfigDesc |
| 106 | + GunBigBounceConfig []GunBigBounceConfigDesc | ||
| 99 | } | 107 | } |
| 100 | 108 | ||
| 101 | func GetJsonConf() *GameConfig { | 109 | func GetJsonConf() *GameConfig { |
| @@ -267,10 +275,33 @@ func LoadJsonConf() error { | @@ -267,10 +275,33 @@ func LoadJsonConf() error { | ||
| 267 | return err | 275 | return err |
| 268 | } | 276 | } |
| 269 | 277 | ||
| 278 | + | ||
| 279 | + path = "../jsonconf/GunBigBounceConfig.json" | ||
| 280 | + content, err = file_get_contents(path) | ||
| 281 | + if err != nil { | ||
| 282 | + logger.Info("loadJsonConf failed1,err=%v", err) | ||
| 283 | + return err | ||
| 284 | + } | ||
| 285 | + | ||
| 286 | + err = json.Unmarshal([]byte(content), &g_jsonconf.GunBigBounceConfig) | ||
| 287 | + if err != nil { | ||
| 288 | + logger.Info("loadJsonConf failed1,err=%v", err) | ||
| 289 | + return err | ||
| 290 | + } | ||
| 291 | + | ||
| 270 | logger.Info("loadJsonConf success pconf=%v,err=%v", *g_jsonconf, err) | 292 | logger.Info("loadJsonConf success pconf=%v,err=%v", *g_jsonconf, err) |
| 271 | return nil | 293 | return nil |
| 272 | } | 294 | } |
| 273 | 295 | ||
| 296 | +func GetGunBigBonusCfg(id int) *GunBigBounceConfigDesc { | ||
| 297 | + for _, v := range g_jsonconf.GunBigBounceConfig { | ||
| 298 | + if v.Id == id { | ||
| 299 | + return &v | ||
| 300 | + } | ||
| 301 | + } | ||
| 302 | + return nil | ||
| 303 | +} | ||
| 304 | + | ||
| 274 | func GetsignConfig(id int) *SignConfigDesc { | 305 | func GetsignConfig(id int) *SignConfigDesc { |
| 275 | for _, v := range g_jsonconf.SignConfig { | 306 | for _, v := range g_jsonconf.SignConfig { |
| 276 | if v.Id == id { | 307 | if v.Id == id { |
src/HttpServer/logic/datadef.go
| @@ -56,6 +56,16 @@ type GettaskrewardResp struct { | @@ -56,6 +56,16 @@ type GettaskrewardResp struct { | ||
| 56 | Data GettaskrewardData `json:"data"` | 56 | Data GettaskrewardData `json:"data"` |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | +type QuerygunbonusData struct { | ||
| 60 | + Finished []int `json:"finished"` | ||
| 61 | +} | ||
| 62 | + | ||
| 63 | +type QuerygunbonusResp struct { | ||
| 64 | + Code int `json:"code"` | ||
| 65 | + Message string `json:"message"` | ||
| 66 | + Data QuerygunbonusData `json:"data"` | ||
| 67 | +} | ||
| 68 | + | ||
| 59 | type QuerytaskinfoReq struct { | 69 | type QuerytaskinfoReq struct { |
| 60 | Tasktype int `json:"tasktype"` | 70 | Tasktype int `json:"tasktype"` |
| 61 | Gameid string `json:"gameid"` | 71 | Gameid string `json:"gameid"` |
| @@ -303,6 +313,7 @@ type UserData struct { | @@ -303,6 +313,7 @@ type UserData struct { | ||
| 303 | Tili int //体力 | 313 | Tili int //体力 |
| 304 | ReadNum int //玩家微转发阅读量 | 314 | ReadNum int //玩家微转发阅读量 |
| 305 | GetCashCnt int //当天提现次数 | 315 | GetCashCnt int //当天提现次数 |
| 316 | + GunBonus []int //以领取的新枪奖励id | ||
| 306 | WithDraw WithDrawInfo //提现记录信息 | 317 | WithDraw WithDrawInfo //提现记录信息 |
| 307 | Task TaskInfo //玩家任务完成相关信息 | 318 | Task TaskInfo //玩家任务完成相关信息 |
| 308 | Achieve AchieveMentInfo //玩家成就完成相关数据 | 319 | Achieve AchieveMentInfo //玩家成就完成相关数据 |
src/HttpServer/logic/httpserver.go
| @@ -54,6 +54,7 @@ func startServerHttpServe() { | @@ -54,6 +54,7 @@ func startServerHttpServe() { | ||
| 54 | http.HandleFunc("/gunshot/updatetaskandachieve", Updatetaskandachieve) //上报任务事件进度 | 54 | http.HandleFunc("/gunshot/updatetaskandachieve", Updatetaskandachieve) //上报任务事件进度 |
| 55 | http.HandleFunc("/gunshot/querytaskinfo", Querytaskinfo) //拉取任务或者成就列表 | 55 | http.HandleFunc("/gunshot/querytaskinfo", Querytaskinfo) //拉取任务或者成就列表 |
| 56 | http.HandleFunc("/gunshot/gettaskreward", Gettaskreward) //领取任务或者成就奖励 | 56 | http.HandleFunc("/gunshot/gettaskreward", Gettaskreward) //领取任务或者成就奖励 |
| 57 | + http.HandleFunc("/gunshot/querygunbonus", Querygunbonus) //获取合成新枪奖励列表 | ||
| 57 | 58 | ||
| 58 | 59 | ||
| 59 | 60 | ||
| @@ -188,6 +189,27 @@ func Querytaskinfo(w http.ResponseWriter, r *http.Request) { | @@ -188,6 +189,27 @@ func Querytaskinfo(w http.ResponseWriter, r *http.Request) { | ||
| 188 | HandlerQuerytaskinfo(w, s, Uuid) | 189 | HandlerQuerytaskinfo(w, s, Uuid) |
| 189 | } | 190 | } |
| 190 | 191 | ||
| 192 | +func Querygunbonus(w http.ResponseWriter, r *http.Request) { | ||
| 193 | + | ||
| 194 | + Uuid := 0 | ||
| 195 | + if len(r.Header) > 0 { | ||
| 196 | + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) | ||
| 197 | + } | ||
| 198 | + | ||
| 199 | + if Uuid == 0 { | ||
| 200 | + SetHeader(w) | ||
| 201 | + //logger.Error("Uuid is nil!") | ||
| 202 | + return | ||
| 203 | + } | ||
| 204 | + result, _ := ioutil.ReadAll(r.Body) | ||
| 205 | + r.Body.Close() | ||
| 206 | + | ||
| 207 | + s := string(result) | ||
| 208 | + logger.Info("Querygunbonus , body:%v,uuid=%v", s, Uuid) | ||
| 209 | + | ||
| 210 | + HandlerQuerygunbonus(w, s, Uuid) | ||
| 211 | +} | ||
| 212 | + | ||
| 191 | func Gettaskreward(w http.ResponseWriter, r *http.Request) { | 213 | func Gettaskreward(w http.ResponseWriter, r *http.Request) { |
| 192 | 214 | ||
| 193 | Uuid := 0 | 215 | Uuid := 0 |
src/HttpServer/logic/logic.go
| @@ -8,6 +8,7 @@ import ( | @@ -8,6 +8,7 @@ import ( | ||
| 8 | "encoding/json" | 8 | "encoding/json" |
| 9 | "fmt" | 9 | "fmt" |
| 10 | "net/http" | 10 | "net/http" |
| 11 | + "sort" | ||
| 11 | "strconv" | 12 | "strconv" |
| 12 | "sync" | 13 | "sync" |
| 13 | "time" | 14 | "time" |
| @@ -310,6 +311,42 @@ func HandlerQuerytaskinfo(w http.ResponseWriter, data string, uuid int) { | @@ -310,6 +311,42 @@ func HandlerQuerytaskinfo(w http.ResponseWriter, data string, uuid int) { | ||
| 310 | 311 | ||
| 311 | } | 312 | } |
| 312 | 313 | ||
| 314 | +func HandlerQuerygunbonus(w http.ResponseWriter, data string, uuid int) { | ||
| 315 | + SetHeader(w) | ||
| 316 | + var resp QuerygunbonusResp | ||
| 317 | + resp.Code = 0 | ||
| 318 | + var rdata CommReq | ||
| 319 | + err := json.Unmarshal([]byte(data), &rdata) | ||
| 320 | + for { | ||
| 321 | + if err != nil { | ||
| 322 | + logger.Info("json decode HandlerQuerygunbonus data failed:%v,for:%v", err, data) | ||
| 323 | + resp.Message = "网络错误" | ||
| 324 | + resp.Code = 1 | ||
| 325 | + break | ||
| 326 | + } | ||
| 327 | + | ||
| 328 | + //需要加上渠道才是唯一的玩家id,不同渠道视为不同数据 | ||
| 329 | + uniqueuuid := strconv.Itoa(uuid) + rdata.Channel | ||
| 330 | + uinfo, err := GetUserInfo(uniqueuuid) | ||
| 331 | + if err != nil || uinfo == nil { | ||
| 332 | + logger.Error("redis failed err=%v", err) | ||
| 333 | + resp.Message = "服务器错误" | ||
| 334 | + resp.Code = 1 | ||
| 335 | + break | ||
| 336 | + } | ||
| 337 | + | ||
| 338 | + resp.Data.Finished = append(resp.Data.Finished,uinfo.GunBonus...) | ||
| 339 | + | ||
| 340 | + resp.Code = 0 | ||
| 341 | + break | ||
| 342 | + } | ||
| 343 | + | ||
| 344 | + //回包 | ||
| 345 | + respstr, _ := json.Marshal(&resp) | ||
| 346 | + fmt.Fprint(w, string(respstr)) | ||
| 347 | + | ||
| 348 | +} | ||
| 349 | + | ||
| 313 | func HandlerGettaskreward(w http.ResponseWriter, data string, uuid int) { | 350 | func HandlerGettaskreward(w http.ResponseWriter, data string, uuid int) { |
| 314 | SetHeader(w) | 351 | SetHeader(w) |
| 315 | var resp GettaskrewardResp | 352 | var resp GettaskrewardResp |
| @@ -750,7 +787,46 @@ func HandlerFetchredbag(w http.ResponseWriter, data string, uuid int) { | @@ -750,7 +787,46 @@ func HandlerFetchredbag(w http.ResponseWriter, data string, uuid int) { | ||
| 750 | 787 | ||
| 751 | } | 788 | } |
| 752 | 789 | ||
| 753 | - } else { | 790 | + } else if rdata.Rtype == 5 { |
| 791 | + isin := false | ||
| 792 | + for _,v := range uinfo.GunBonus { | ||
| 793 | + if v == rdata.Param { | ||
| 794 | + isin = true | ||
| 795 | + break | ||
| 796 | + } | ||
| 797 | + } | ||
| 798 | + | ||
| 799 | + if isin { | ||
| 800 | + logger.Info("GetUserInfo HandlerFetchredbag data failed:%v,for:%v", err, data) | ||
| 801 | + resp.Message = "已经领取过了!" | ||
| 802 | + resp.Code = 1 | ||
| 803 | + break | ||
| 804 | + } | ||
| 805 | + | ||
| 806 | + cfg := jsonconf.GetGunBigBonusCfg(rdata.Param) | ||
| 807 | + if cfg == nil { | ||
| 808 | + logger.Info("GetUserInfo HandlerFetchredbag data failed:%v,for:%v", err, data) | ||
| 809 | + resp.Message = "获取配置失败!" | ||
| 810 | + resp.Code = 1 | ||
| 811 | + break | ||
| 812 | + } | ||
| 813 | + | ||
| 814 | + | ||
| 815 | + getnum := int(cfg.Luckybag) | ||
| 816 | + realgold, err := AddCoinToSdk(uuid, getnum, rdata.Gameid, rdata.Channel, 108) | ||
| 817 | + if err !=nil { | ||
| 818 | + logger.Error("HandlerFetchredbag failed err=%v", err) | ||
| 819 | + resp.Message = "服务器错误!" | ||
| 820 | + resp.Code = 1 | ||
| 821 | + break | ||
| 822 | + } | ||
| 823 | + | ||
| 824 | + resp.Data.Getgold = getnum | ||
| 825 | + resp.Data.Walletgold = realgold | ||
| 826 | + | ||
| 827 | + uinfo.GunBonus = append(uinfo.GunBonus,rdata.Param) | ||
| 828 | + sort.Ints(uinfo.GunBonus) | ||
| 829 | + }else { | ||
| 754 | /*if uinfo.SpecialLevel <= uinfo.SpecialNum { | 830 | /*if uinfo.SpecialLevel <= uinfo.SpecialNum { |
| 755 | logger.Error("HandlerFetchredbag failed err=%v", err) | 831 | logger.Error("HandlerFetchredbag failed err=%v", err) |
| 756 | resp.Message = "没有可以领取的随机红包次数了!" | 832 | resp.Message = "没有可以领取的随机红包次数了!" |