Commit 296664f203e8aa0efd3d7bd96ccd868fc216a60c
1 parent
f5ecc2c0
Exists in
master
提交
Showing
3 changed files
with
70 additions
and
0 deletions
Show diff stats
src/HttpServer/logic/datadef.go
... | ... | @@ -45,6 +45,20 @@ type AddFlopResp struct { |
45 | 45 | Message string `json:"message"` |
46 | 46 | } |
47 | 47 | |
48 | +type SettlementReq struct { | |
49 | + Round int `json:"round"` | |
50 | + RewardNum int `json:"rewardNum"` | |
51 | +} | |
52 | + | |
53 | +type SettlementData struct { | |
54 | +} | |
55 | + | |
56 | +type SettlementResp struct { | |
57 | + Code int `json:"code"` | |
58 | + Data SettlementData `json:"data"` | |
59 | + Message string `json:"message"` | |
60 | +} | |
61 | + | |
48 | 62 | type ChangeCoinData struct { |
49 | 63 | Coin DoBuyCatCoin `json:"coin"` |
50 | 64 | } | ... | ... |
src/HttpServer/logic/httpserver.go
... | ... | @@ -114,6 +114,7 @@ func startServerHttpServe() { |
114 | 114 | http.HandleFunc("/api/test/changeCoin", ChangeCoin) //增加猫 |
115 | 115 | http.HandleFunc("/api/test/addAdCount", AddAdCount) //增加广告次数 |
116 | 116 | http.HandleFunc("/api/test/addFlop", AddFlop) //增加翻牌 |
117 | + http.HandleFunc("/api/test/settlement", Settlement) //发财猫开奖 | |
117 | 118 | |
118 | 119 | //real |
119 | 120 | http.HandleFunc("/api/account/login", UserLogin) //登录 |
... | ... | @@ -1295,6 +1296,24 @@ func Getrandredbag(w http.ResponseWriter, r *http.Request) { |
1295 | 1296 | HandlerGetrandredbag(w, s, Uuid) |
1296 | 1297 | } |
1297 | 1298 | |
1299 | +func Settlement(w http.ResponseWriter, r *http.Request) { | |
1300 | + Uuid := 0 | |
1301 | + if len(r.Header) > 0 { | |
1302 | + Uuid, _ = strconv.Atoi(r.Header.Get("uid")) | |
1303 | + } | |
1304 | + if Uuid == 0 { | |
1305 | + SetHeader(w) | |
1306 | + return | |
1307 | + } | |
1308 | + result, _ := ioutil.ReadAll(r.Body) | |
1309 | + r.Body.Close() | |
1310 | + | |
1311 | + s := string(result) | |
1312 | + logger.Info("Settlement , body:%v,uuid=%v", s, Uuid) | |
1313 | + | |
1314 | + HandlerSettlement(w, s, Uuid) | |
1315 | +} | |
1316 | + | |
1298 | 1317 | func AddFlop(w http.ResponseWriter, r *http.Request) { |
1299 | 1318 | Uuid := 0 |
1300 | 1319 | if len(r.Header) > 0 { | ... | ... |
src/HttpServer/logic/logic.go
... | ... | @@ -41,6 +41,43 @@ func SetHeader(w http.ResponseWriter) { |
41 | 41 | |
42 | 42 | } |
43 | 43 | |
44 | +func HandlerSettlement(w http.ResponseWriter, data string, uuid int) { | |
45 | + SetHeader(w) | |
46 | + var resp SettlementResp | |
47 | + resp.Code = 0 | |
48 | + resp.Message = "success" | |
49 | + var rdata SettlementReq | |
50 | + err := json.Unmarshal([]byte(data), &rdata) | |
51 | + if err != nil { | |
52 | + logger.Info("json decode HandlerSettlement data failed:%v,for:%v", err, data) | |
53 | + resp.Message = "json unmarshal failed" | |
54 | + resp.Code = 1 | |
55 | + respstr, _ := json.Marshal(&resp) | |
56 | + logger.Info("###HandlerLogin###rdata:%v", string(respstr)) | |
57 | + fmt.Fprint(w, string(respstr)) | |
58 | + return | |
59 | + } | |
60 | + | |
61 | + for { | |
62 | + | |
63 | + uinfo, err := GetUserInfo(strconv.Itoa(uuid)) | |
64 | + if err != nil || uinfo == nil { | |
65 | + logger.Error("HandlerTestaddCat getuserinfo failed=%v", err) | |
66 | + resp.Code = 1 | |
67 | + resp.Message = "get userinfo failed" | |
68 | + break | |
69 | + } | |
70 | + | |
71 | + SaveUserInfo(uinfo, strconv.Itoa(uuid)) | |
72 | + break | |
73 | + } | |
74 | + | |
75 | + //回包 | |
76 | + respstr, _ := json.Marshal(&resp) | |
77 | + fmt.Fprint(w, string(respstr)) | |
78 | + | |
79 | +} | |
80 | + | |
44 | 81 | func HandlerAddFlop(w http.ResponseWriter, data string, uuid int) { |
45 | 82 | SetHeader(w) |
46 | 83 | var resp AddFlopResp | ... | ... |