Commit 1c80023c45d78eea79edc822cdeb551686b236d7

Authored by 陆恒
1 parent 32e96c1d
Exists in master

提交

src/HttpServer/jsonconf/jsonconf.go
... ... @@ -84,6 +84,13 @@ type InvestmentsConfigDesc struct {
84 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 94 type GameConfig struct {
88 95 WithDrawConfig []WithDrawDesc
89 96 ActiveWithdrawConfig []ActiveWithdrawConfigDesc
... ... @@ -96,6 +103,7 @@ type GameConfig struct {
96 103 TaskConfig []AchieveDesc
97 104 SignConfig []SignConfigDesc
98 105 InvestmentsConfig []InvestmentsConfigDesc
  106 + GunBigBounceConfig []GunBigBounceConfigDesc
99 107 }
100 108  
101 109 func GetJsonConf() *GameConfig {
... ... @@ -267,10 +275,33 @@ func LoadJsonConf() error {
267 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 292 logger.Info("loadJsonConf success pconf=%v,err=%v", *g_jsonconf, err)
271 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 305 func GetsignConfig(id int) *SignConfigDesc {
275 306 for _, v := range g_jsonconf.SignConfig {
276 307 if v.Id == id {
... ...
src/HttpServer/logic/datadef.go
... ... @@ -56,6 +56,16 @@ type GettaskrewardResp struct {
56 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 69 type QuerytaskinfoReq struct {
60 70 Tasktype int `json:"tasktype"`
61 71 Gameid string `json:"gameid"`
... ... @@ -303,6 +313,7 @@ type UserData struct {
303 313 Tili int //体力
304 314 ReadNum int //玩家微转发阅读量
305 315 GetCashCnt int //当天提现次数
  316 + GunBonus []int //以领取的新枪奖励id
306 317 WithDraw WithDrawInfo //提现记录信息
307 318 Task TaskInfo //玩家任务完成相关信息
308 319 Achieve AchieveMentInfo //玩家成就完成相关数据
... ...
src/HttpServer/logic/httpserver.go
... ... @@ -54,6 +54,7 @@ func startServerHttpServe() {
54 54 http.HandleFunc("/gunshot/updatetaskandachieve", Updatetaskandachieve) //上报任务事件进度
55 55 http.HandleFunc("/gunshot/querytaskinfo", Querytaskinfo) //拉取任务或者成就列表
56 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 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 213 func Gettaskreward(w http.ResponseWriter, r *http.Request) {
192 214  
193 215 Uuid := 0
... ...
src/HttpServer/logic/logic.go
... ... @@ -8,6 +8,7 @@ import (
8 8 "encoding/json"
9 9 "fmt"
10 10 "net/http"
  11 + "sort"
11 12 "strconv"
12 13 "sync"
13 14 "time"
... ... @@ -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 350 func HandlerGettaskreward(w http.ResponseWriter, data string, uuid int) {
314 351 SetHeader(w)
315 352 var resp GettaskrewardResp
... ... @@ -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 830 /*if uinfo.SpecialLevel <= uinfo.SpecialNum {
755 831 logger.Error("HandlerFetchredbag failed err=%v", err)
756 832 resp.Message = "没有可以领取的随机红包次数了!"
... ...