Commit e0bc4350664c3b8fd6886a3496dac9c5568f19f1
1 parent
d5c03f72
Exists in
master
提交
Showing
4 changed files
with
95 additions
and
0 deletions
Show diff stats
src/HttpServer/logic/datadef.go
@@ -25,6 +25,7 @@ type UserLoginData struct { | @@ -25,6 +25,7 @@ type UserLoginData struct { | ||
25 | Shakeleftcnt int `json:"shakeleftcnt"` | 25 | Shakeleftcnt int `json:"shakeleftcnt"` |
26 | IsNew int `json:"isnew"` | 26 | IsNew int `json:"isnew"` |
27 | Issignshow int `json:"issignshow"` | 27 | Issignshow int `json:"issignshow"` |
28 | + Curtime int `json:"curtime"` | ||
28 | //Leftredbagnum int `json:"leftredbagnum"` | 29 | //Leftredbagnum int `json:"leftredbagnum"` |
29 | } | 30 | } |
30 | 31 | ||
@@ -470,6 +471,24 @@ type WithDrawDesc struct { | @@ -470,6 +471,24 @@ type WithDrawDesc struct { | ||
470 | Day int `json:"day"` | 471 | Day int `json:"day"` |
471 | } | 472 | } |
472 | 473 | ||
474 | + | ||
475 | +type TurntablebagReq struct { | ||
476 | + Num int `json:"num"` | ||
477 | + Gameid string `json:"gameid"` | ||
478 | + Channel string `json:"channel"` | ||
479 | +} | ||
480 | + | ||
481 | +type TurntablebagData struct { | ||
482 | + Getgoldnum int `json:"getgoldnum"` | ||
483 | + Walletgold int `json:"walletgold"` | ||
484 | +} | ||
485 | + | ||
486 | +type TurntablebagResp struct { | ||
487 | + Code int `json:"code"` | ||
488 | + Message string `json:"message"` | ||
489 | + Data TurntablebagData `json:"data"` | ||
490 | +} | ||
491 | + | ||
473 | //玩家数据 | 492 | //玩家数据 |
474 | type UserData struct { | 493 | type UserData struct { |
475 | Userid int //玩家id | 494 | Userid int //玩家id |
src/HttpServer/logic/function.go
@@ -697,6 +697,7 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int, uniqueuid s | @@ -697,6 +697,7 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int, uniqueuid s | ||
697 | resp.Data.Shakeleftcnt = initdata.ShakeTime | 697 | resp.Data.Shakeleftcnt = initdata.ShakeTime |
698 | resp.Data.IsNew = initdata.IsNew | 698 | resp.Data.IsNew = initdata.IsNew |
699 | resp.Data.Issignshow = initdata.SignShow | 699 | resp.Data.Issignshow = initdata.SignShow |
700 | + resp.Data.Curtime = int(time.Now().Unix()) | ||
700 | //resp.Data.Leftredbagnum = DAILYFETCHREDBAGNUMLIMIT - initdata.FetchRdBagNum | 701 | //resp.Data.Leftredbagnum = DAILYFETCHREDBAGNUMLIMIT - initdata.FetchRdBagNum |
701 | 702 | ||
702 | err := SaveUserInfo(&initdata, uniqueuid) | 703 | err := SaveUserInfo(&initdata, uniqueuid) |
@@ -990,6 +991,7 @@ func GetUserData(uuid int, uniqueuid string, req *UserLoginReq, resp *UserLoginR | @@ -990,6 +991,7 @@ func GetUserData(uuid int, uniqueuid string, req *UserLoginReq, resp *UserLoginR | ||
990 | resp.Data.Shakeleftcnt = data.ShakeTime | 991 | resp.Data.Shakeleftcnt = data.ShakeTime |
991 | resp.Data.IsNew = data.IsNew | 992 | resp.Data.IsNew = data.IsNew |
992 | resp.Data.Issignshow = data.SignShow | 993 | resp.Data.Issignshow = data.SignShow |
994 | + resp.Data.Curtime = int(time.Now().Unix()) | ||
993 | //resp.Data.Leftredbagnum = DAILYFETCHREDBAGNUMLIMIT - data.FetchRdBagNum | 995 | //resp.Data.Leftredbagnum = DAILYFETCHREDBAGNUMLIMIT - data.FetchRdBagNum |
994 | return nil | 996 | return nil |
995 | } | 997 | } |
src/HttpServer/logic/httpserver.go
@@ -77,6 +77,7 @@ func startServerHttpServe() { | @@ -77,6 +77,7 @@ func startServerHttpServe() { | ||
77 | http.HandleFunc("/guessge/getdata", Getdata) //获取数据 | 77 | http.HandleFunc("/guessge/getdata", Getdata) //获取数据 |
78 | http.HandleFunc("/guessge/uploadsong", Uploadsong) //上报猜歌数据 | 78 | http.HandleFunc("/guessge/uploadsong", Uploadsong) //上报猜歌数据 |
79 | http.HandleFunc("/guessge/queryrankinfo", Queryrankinfo) //获取排行榜信息 | 79 | http.HandleFunc("/guessge/queryrankinfo", Queryrankinfo) //获取排行榜信息 |
80 | + http.HandleFunc("/guessge/turntablebag", Turntablebag) //转盘红包 | ||
80 | 81 | ||
81 | err := http.ListenAndServe(conf.GetServerHttpAddrConf(), nil) | 82 | err := http.ListenAndServe(conf.GetServerHttpAddrConf(), nil) |
82 | CheckErr(err) | 83 | CheckErr(err) |
@@ -153,6 +154,28 @@ func Savadata(w http.ResponseWriter, r *http.Request) { | @@ -153,6 +154,28 @@ func Savadata(w http.ResponseWriter, r *http.Request) { | ||
153 | HandlerSavadata(w, s, Uuid) | 154 | HandlerSavadata(w, s, Uuid) |
154 | } | 155 | } |
155 | 156 | ||
157 | + | ||
158 | +func Turntablebag(w http.ResponseWriter, r *http.Request) { | ||
159 | + | ||
160 | + Uuid := 0 | ||
161 | + if len(r.Header) > 0 { | ||
162 | + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) | ||
163 | + } | ||
164 | + | ||
165 | + if Uuid == 0 { | ||
166 | + SetHeader(w) | ||
167 | + //logger.Error("Uuid is nil!") | ||
168 | + return | ||
169 | + } | ||
170 | + result, _ := ioutil.ReadAll(r.Body) | ||
171 | + r.Body.Close() | ||
172 | + | ||
173 | + s := string(result) | ||
174 | + logger.Info("Turntablebag , body:%v,uuid=%v", s, Uuid) | ||
175 | + | ||
176 | + HandlerTurntablebag(w, s, Uuid) | ||
177 | +} | ||
178 | + | ||
156 | func Queryrankinfo(w http.ResponseWriter, r *http.Request) { | 179 | func Queryrankinfo(w http.ResponseWriter, r *http.Request) { |
157 | 180 | ||
158 | Uuid := 0 | 181 | Uuid := 0 |
src/HttpServer/logic/logic.go
@@ -795,6 +795,57 @@ func HandlerUploadsong(w http.ResponseWriter, data string, uuid int) { | @@ -795,6 +795,57 @@ func HandlerUploadsong(w http.ResponseWriter, data string, uuid int) { | ||
795 | fmt.Fprint(w, string(respstr)) | 795 | fmt.Fprint(w, string(respstr)) |
796 | } | 796 | } |
797 | 797 | ||
798 | + | ||
799 | + | ||
800 | +func HandlerTurntablebag(w http.ResponseWriter, data string, uuid int) { | ||
801 | + SetHeader(w) | ||
802 | + var resp TurntablebagResp | ||
803 | + resp.Code = 0 | ||
804 | + resp.Message = "success" | ||
805 | + var rdata TurntablebagReq | ||
806 | + err := json.Unmarshal([]byte(data), &rdata) | ||
807 | + for { | ||
808 | + if err != nil { | ||
809 | + logger.Info("json decode HandlerTurntablebag data failed:%v,for:%v", err, data) | ||
810 | + resp.Message = "网络错误" | ||
811 | + resp.Code = ERROR_JSONUNMASH_ERROR | ||
812 | + break | ||
813 | + } | ||
814 | + | ||
815 | + //需要加上渠道才是唯一的玩家id,不同渠道视为不同数据 | ||
816 | + uniqueuuid := strconv.Itoa(uuid) + rdata.Channel | ||
817 | + uinfo, err := GetUserInfo(uniqueuuid) | ||
818 | + if err != nil || uinfo == nil { | ||
819 | + logger.Error("redis failed err=%v", err) | ||
820 | + resp.Message = "服务器错误" | ||
821 | + resp.Code = ERROR_SRV_ERROR | ||
822 | + break | ||
823 | + } | ||
824 | + | ||
825 | + goldnum, _, err := AddCoinToSdk(uuid, rdata.Num, rdata.Gameid, rdata.Channel, 104) | ||
826 | + if err != nil { | ||
827 | + logger.Error("AddCoinToSdk failed rdata=%v", rdata) | ||
828 | + resp.Message = "网络错误" | ||
829 | + resp.Code = ERROR_SRV_ERROR | ||
830 | + break | ||
831 | + } | ||
832 | + uinfo.RealGold = goldnum | ||
833 | + | ||
834 | + resp.Data.Walletgold = goldnum | ||
835 | + resp.Data.Getgoldnum = rdata.Num | ||
836 | + //加入排行榜 | ||
837 | + SaveUserInfo(uinfo, uniqueuuid) | ||
838 | + | ||
839 | + resp.Code = ERROR_OK | ||
840 | + break | ||
841 | + } | ||
842 | + | ||
843 | + //回包 | ||
844 | + respstr, _ := json.Marshal(&resp) | ||
845 | + fmt.Fprint(w, string(respstr)) | ||
846 | +} | ||
847 | + | ||
848 | + | ||
798 | func HandlerSavadata(w http.ResponseWriter, data string, uuid int) { | 849 | func HandlerSavadata(w http.ResponseWriter, data string, uuid int) { |
799 | SetHeader(w) | 850 | SetHeader(w) |
800 | var resp SavadataResp | 851 | var resp SavadataResp |