Commit c710962c62503f3433cf7bf5b767b10f0cc929d9
1 parent
7dde56e7
Exists in
master
提交
Showing
4 changed files
with
330 additions
and
0 deletions
Show diff stats
src/HttpServer/logic/datadef.go
@@ -134,6 +134,16 @@ type GetcashReq struct { | @@ -134,6 +134,16 @@ type GetcashReq struct { | ||
134 | Ctype int `json:"ctype"` | 134 | Ctype int `json:"ctype"` |
135 | } | 135 | } |
136 | 136 | ||
137 | +type GetCashWechatData struct { | ||
138 | + Cdkey string `json:"cdkey"` | ||
139 | +} | ||
140 | + | ||
141 | +type GetCashWechatResp struct { | ||
142 | + Code string `json:"code"` | ||
143 | + Data GetCashWechatData `json:"data"` | ||
144 | + Msg string `json:"msg"` | ||
145 | +} | ||
146 | + | ||
137 | type CommReq struct { | 147 | type CommReq struct { |
138 | Gameid string `json:"gameid"` | 148 | Gameid string `json:"gameid"` |
139 | Channel string `json:"channel"` | 149 | Channel string `json:"channel"` |
@@ -148,6 +158,26 @@ type GetcashResp struct { | @@ -148,6 +158,26 @@ type GetcashResp struct { | ||
148 | Data GetcashData `json:"data"` | 158 | Data GetcashData `json:"data"` |
149 | } | 159 | } |
150 | 160 | ||
161 | +type GetcashwechatData struct { | ||
162 | + Cdkey string `json:"cdkey"` | ||
163 | +} | ||
164 | +type GetcashwechatResp struct { | ||
165 | + Code int `json:"code"` | ||
166 | + Message string `json:"message"` | ||
167 | + Data GetcashwechatData `json:"data"` | ||
168 | +} | ||
169 | + | ||
170 | +type GetcashwechatReq struct { | ||
171 | + Gameid string `json:"gameid"` | ||
172 | + Channel string `json:"channel"` | ||
173 | + Money float32 `json:"money"` | ||
174 | + Openid string `json:"openid"` | ||
175 | + Nickname string `json:"nickname"` | ||
176 | + Headurl string `json:"headurl"` | ||
177 | + Ver string `json:"ver"` | ||
178 | + Ctype int `json:"ctype"` | ||
179 | +} | ||
180 | + | ||
151 | type GetcashrecordReq struct { | 181 | type GetcashrecordReq struct { |
152 | Gameid string `json:"gameid"` | 182 | Gameid string `json:"gameid"` |
153 | Channel string `json:"channel"` | 183 | Channel string `json:"channel"` |
@@ -419,9 +449,16 @@ func (v WithDrawDescs) Less(i, j int) bool { | @@ -419,9 +449,16 @@ func (v WithDrawDescs) Less(i, j int) bool { | ||
419 | return v[i].Cid < v[j].Cid | 449 | return v[i].Cid < v[j].Cid |
420 | } | 450 | } |
421 | 451 | ||
452 | +type CashCdKeyInfo struct { | ||
453 | + Id int `json:"id"` | ||
454 | + Money float32 `json:"money"` | ||
455 | + Cdkey string `json:"cdkey"` | ||
456 | +} | ||
457 | + | ||
422 | type WithDrawInfo struct { | 458 | type WithDrawInfo struct { |
423 | Cashdata WithDrawDescs `json:"cashdata"` | 459 | Cashdata WithDrawDescs `json:"cashdata"` |
424 | SpecialCashdata WithDrawDescs `json:"specialcashdata"` | 460 | SpecialCashdata WithDrawDescs `json:"specialcashdata"` |
461 | + Cdkeycashdata []CashCdKeyInfo `json:"cdkeycashdata"` | ||
425 | } | 462 | } |
426 | 463 | ||
427 | type WithDrawDesc struct { | 464 | type WithDrawDesc struct { |
@@ -465,6 +502,7 @@ type UserData struct { | @@ -465,6 +502,7 @@ type UserData struct { | ||
465 | Sunti int //总答题数 | 502 | Sunti int //总答题数 |
466 | Coti int //正确提数 | 503 | Coti int //正确提数 |
467 | WithDraw WithDrawInfo //提现记录信息 | 504 | WithDraw WithDrawInfo //提现记录信息 |
505 | + Cdkeys []CashCdKeyInfo //记录提现的cdkeys | ||
468 | //SpecialWithDraw WithDrawInfo //活跃提现记录信息 | 506 | //SpecialWithDraw WithDrawInfo //活跃提现记录信息 |
469 | Task TaskInfo //玩家任务完成相关信息 | 507 | Task TaskInfo //玩家任务完成相关信息 |
470 | Achieve AchieveMentInfo //玩家成就完成相关数据 | 508 | Achieve AchieveMentInfo //玩家成就完成相关数据 |
src/HttpServer/logic/function.go
@@ -1331,6 +1331,121 @@ func AddCoinToSdk(uuid int, goldnum int, gameid string, channel string, atype in | @@ -1331,6 +1331,121 @@ func AddCoinToSdk(uuid int, goldnum int, gameid string, channel string, atype in | ||
1331 | return resp.Data.Mycoin, realaddgoldnum, nil | 1331 | return resp.Data.Mycoin, realaddgoldnum, nil |
1332 | } | 1332 | } |
1333 | 1333 | ||
1334 | +func GetCashWechatFromSDK(uuid int, goldnum int, gameid, channel, openid, nickname, headurl, ver string, checkcoin int) (string, error) { | ||
1335 | + | ||
1336 | + SERVERKEY := XIAOXINGXING_SERVERKEYTEST | ||
1337 | + if gameid == "1015" { | ||
1338 | + SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1015 | ||
1339 | + } | ||
1340 | + | ||
1341 | + if gameid == "1016" { | ||
1342 | + SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1016 | ||
1343 | + } | ||
1344 | + if gameid == "1019" { | ||
1345 | + SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1019 | ||
1346 | + } | ||
1347 | + if gameid == "1020" { | ||
1348 | + SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1020 | ||
1349 | + } | ||
1350 | + if gameid == "1021" { | ||
1351 | + SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1021 | ||
1352 | + } | ||
1353 | + if gameid == "1023" { | ||
1354 | + SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1023 | ||
1355 | + } | ||
1356 | + if goldnum == 0 || uuid == 0 || gameid == "" || channel == "" || ver == "" { | ||
1357 | + logger.Error("GetCashFromSDK param empty") | ||
1358 | + return "error", errors.New("param empty") | ||
1359 | + } | ||
1360 | + | ||
1361 | + if openid == "" { | ||
1362 | + openid = "test" | ||
1363 | + } | ||
1364 | + var paramlist []string | ||
1365 | + var params TixianDesc | ||
1366 | + params.Sign_type = "md5" | ||
1367 | + params.Gameid = gameid | ||
1368 | + params.Channel = channel | ||
1369 | + params.Uid = uuid | ||
1370 | + params.Time_stamp = strconv.Itoa(int(time.Now().Unix())) | ||
1371 | + params.Headurl = headurl | ||
1372 | + params.Money = goldnum | ||
1373 | + params.Openid = openid | ||
1374 | + params.Nickname = nickname | ||
1375 | + params.Typ = 11 | ||
1376 | + params.Ver = ver | ||
1377 | + params.Editcoin = 1 | ||
1378 | + params.Checkcoin = checkcoin | ||
1379 | + signtypestr := "sign_type=" + params.Sign_type | ||
1380 | + timestampstr := "time_stamp=" + strconv.Itoa(int(time.Now().Unix())) | ||
1381 | + paramgameid := "gameid=" + gameid | ||
1382 | + pchannel := "channel=" + channel | ||
1383 | + puid := "uid=" + strconv.Itoa(uuid) | ||
1384 | + phead := "headurl=" + headurl | ||
1385 | + pnickname := "nickname=" + nickname | ||
1386 | + popenid := "openid=" + openid | ||
1387 | + pmoney := "money=" + strconv.Itoa(goldnum) | ||
1388 | + ptype := "typ=" + "11" //微信 | ||
1389 | + ped := "editcoin=1" | ||
1390 | + pcheco := "checkcoin=" + strconv.Itoa(checkcoin) | ||
1391 | + //pver := "ver=" + params.Ver | ||
1392 | + paramlist = append(paramlist, signtypestr) | ||
1393 | + paramlist = append(paramlist, timestampstr) | ||
1394 | + paramlist = append(paramlist, paramgameid) | ||
1395 | + paramlist = append(paramlist, pchannel) | ||
1396 | + paramlist = append(paramlist, puid) | ||
1397 | + if headurl != "" { | ||
1398 | + paramlist = append(paramlist, phead) | ||
1399 | + } | ||
1400 | + if nickname != "" { | ||
1401 | + paramlist = append(paramlist, pnickname) | ||
1402 | + } | ||
1403 | + paramlist = append(paramlist, popenid) | ||
1404 | + paramlist = append(paramlist, pmoney) | ||
1405 | + paramlist = append(paramlist, ptype) | ||
1406 | + paramlist = append(paramlist, ped) | ||
1407 | + paramlist = append(paramlist, pcheco) | ||
1408 | + //paramlist = append(paramlist, pver) | ||
1409 | + | ||
1410 | + sumparam := GettotalParam(paramlist) | ||
1411 | + //加serverkey | ||
1412 | + signsum := sumparam + SERVERKEY | ||
1413 | + | ||
1414 | + //进行hash | ||
1415 | + sign := GetHashValue(signsum) | ||
1416 | + params.Sign = sign | ||
1417 | + | ||
1418 | + bys, err := json.Marshal(¶ms) | ||
1419 | + if err != nil { | ||
1420 | + logger.Error("GetCashWechatFromSDK failed=%v", err) | ||
1421 | + return "error", err | ||
1422 | + } | ||
1423 | + res, err := DoHttpPost(bys, "api/server/tixiancdkey") | ||
1424 | + logger.Info("GetCashWechatFromSDK sumparam is:%v,sign is:%v", signsum, sign) | ||
1425 | + logger.Info("GetCashWechatFromSDK sumparam param=%v", string(bys)) | ||
1426 | + if err != nil { | ||
1427 | + logger.Error("GetCashWechatFromSDK failed=%v", err) | ||
1428 | + return "error", err | ||
1429 | + } | ||
1430 | + | ||
1431 | + logger.Info("GetCashWechatFromSDK res=%v", res) | ||
1432 | + | ||
1433 | + var resp GetCashWechatResp | ||
1434 | + err = json.Unmarshal([]byte(res), &resp) | ||
1435 | + if err != nil { | ||
1436 | + logger.Error("GetCashWechatFromSDK failed=%v", err) | ||
1437 | + return "error", err | ||
1438 | + } | ||
1439 | + | ||
1440 | + if resp.Code != "0" { | ||
1441 | + logger.Error("GetCashWechatFromSDK failed=%v", resp.Msg) | ||
1442 | + return "error", errors.New(resp.Msg) | ||
1443 | + } | ||
1444 | + | ||
1445 | + return resp.Data.Cdkey, nil | ||
1446 | +} | ||
1447 | + | ||
1448 | + | ||
1334 | func GetCashFromSDK(uuid int, goldnum int, gameid, channel, openid, nickname, headurl, ver string, checkcoin int) (int, error) { | 1449 | func GetCashFromSDK(uuid int, goldnum int, gameid, channel, openid, nickname, headurl, ver string, checkcoin int) (int, error) { |
1335 | 1450 | ||
1336 | SERVERKEY := XIAOXINGXING_SERVERKEYTEST | 1451 | SERVERKEY := XIAOXINGXING_SERVERKEYTEST |
src/HttpServer/logic/httpserver.go
@@ -63,6 +63,7 @@ func startServerHttpServe() { | @@ -63,6 +63,7 @@ func startServerHttpServe() { | ||
63 | http.HandleFunc("/guessge/drawguangold", Drawguangold) //提取存钱罐的金币到个人钱包 | 63 | http.HandleFunc("/guessge/drawguangold", Drawguangold) //提取存钱罐的金币到个人钱包 |
64 | http.HandleFunc("/guessge/querdrawinfo", Querdrawinfo) //获取提现档位信息接口 | 64 | http.HandleFunc("/guessge/querdrawinfo", Querdrawinfo) //获取提现档位信息接口 |
65 | http.HandleFunc("/guessge/getcash", Getcash) //提现 | 65 | http.HandleFunc("/guessge/getcash", Getcash) //提现 |
66 | + http.HandleFunc("/guessge/getcashwechat", Getcashwechat) //提现 | ||
66 | http.HandleFunc("/guessge/getcashrecord", Getcashrecord) //提现记录列表 | 67 | http.HandleFunc("/guessge/getcashrecord", Getcashrecord) //提现记录列表 |
67 | http.HandleFunc("/guessge/onlinentf", Onlinentf) //在线通知 | 68 | http.HandleFunc("/guessge/onlinentf", Onlinentf) //在线通知 |
68 | http.HandleFunc("/guessge/updatetaskandachieve", Updatetaskandachieve) //上报任务事件进度 | 69 | http.HandleFunc("/guessge/updatetaskandachieve", Updatetaskandachieve) //上报任务事件进度 |
@@ -546,6 +547,27 @@ func Getcashrecord(w http.ResponseWriter, r *http.Request) { | @@ -546,6 +547,27 @@ func Getcashrecord(w http.ResponseWriter, r *http.Request) { | ||
546 | HandlerGetcashrecord(w, s, Uuid) | 547 | HandlerGetcashrecord(w, s, Uuid) |
547 | } | 548 | } |
548 | 549 | ||
550 | +func Getcashwechat(w http.ResponseWriter, r *http.Request) { | ||
551 | + | ||
552 | + Uuid := 0 | ||
553 | + if len(r.Header) > 0 { | ||
554 | + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) | ||
555 | + } | ||
556 | + | ||
557 | + if Uuid == 0 { | ||
558 | + SetHeader(w) | ||
559 | + //logger.Error("Uuid is nil!") | ||
560 | + return | ||
561 | + } | ||
562 | + result, _ := ioutil.ReadAll(r.Body) | ||
563 | + r.Body.Close() | ||
564 | + | ||
565 | + s := string(result) | ||
566 | + logger.Info("Getcashwechat , body:%v,uuid=%v", s, Uuid) | ||
567 | + | ||
568 | + HandlerGetcashwechat(w, s, Uuid) | ||
569 | +} | ||
570 | + | ||
549 | func Getcash(w http.ResponseWriter, r *http.Request) { | 571 | func Getcash(w http.ResponseWriter, r *http.Request) { |
550 | 572 | ||
551 | Uuid := 0 | 573 | Uuid := 0 |
src/HttpServer/logic/logic.go
@@ -107,6 +107,160 @@ func HandlerWatchads(w http.ResponseWriter, data string, uuid int) { | @@ -107,6 +107,160 @@ func HandlerWatchads(w http.ResponseWriter, data string, uuid int) { | ||
107 | fmt.Fprint(w, string(respstr))*/ | 107 | fmt.Fprint(w, string(respstr))*/ |
108 | } | 108 | } |
109 | 109 | ||
110 | +func HandlerGetcashwechat(w http.ResponseWriter, data string, uuid int) { | ||
111 | + SetHeader(w) | ||
112 | + var resp GetcashwechatResp | ||
113 | + resp.Code = 0 | ||
114 | + var rdata GetcashwechatReq | ||
115 | + err := json.Unmarshal([]byte(data), &rdata) | ||
116 | + for { | ||
117 | + if err != nil { | ||
118 | + logger.Info("json decode HandlerDrawguangold data failed:%v,for:%v", err, data) | ||
119 | + resp.Message = "json解析错误" | ||
120 | + resp.Code = ERROR_JSONUNMASH_ERROR | ||
121 | + break | ||
122 | + } | ||
123 | + //临时处理一下 | ||
124 | + /*if rdata.Ver == "" { | ||
125 | + rdata.Ver = "2.0.0" | ||
126 | + }*/ | ||
127 | + | ||
128 | + //需要加上渠道才是唯一的玩家id,不同渠道视为不同数据 | ||
129 | + uniqueuuid := strconv.Itoa(uuid) + rdata.Channel | ||
130 | + uinfo, err := GetUserInfo(uniqueuuid) | ||
131 | + if err != nil || uinfo == nil { | ||
132 | + logger.Error("redis failed err=%v", err) | ||
133 | + resp.Message = "服务器错误" | ||
134 | + resp.Code = ERROR_SRV_ERROR | ||
135 | + break | ||
136 | + } | ||
137 | + | ||
138 | + drawnum := int(rdata.Money * 100) | ||
139 | + //需要判断一下金币是否足够 | ||
140 | + if drawnum*100 > uinfo.RealGold { | ||
141 | + logger.Error("gold nor enough failed err=%v", err) | ||
142 | + resp.Message = "提现金币不足" | ||
143 | + resp.Code = ERROR_GETCASH_GOLDNOTENOUGH_FAILED | ||
144 | + break | ||
145 | + } | ||
146 | + | ||
147 | + //需要处理一下提现级别 | ||
148 | + | ||
149 | + index := 0 | ||
150 | + var info *WithDrawDesc | ||
151 | + if rdata.Ctype == 1 { | ||
152 | + index, info = uinfo.GetWithDrawData(rdata.Money) | ||
153 | + } else { | ||
154 | + index, info = uinfo.GetSpecialWithDrawData(rdata.Money) | ||
155 | + } | ||
156 | + | ||
157 | + if index == -1 || info == nil { | ||
158 | + logger.Error("AddWithDrawList failed err=%v", err) | ||
159 | + resp.Message = "网络错误" | ||
160 | + resp.Code = ERROR_SRV_ERROR | ||
161 | + break | ||
162 | + } | ||
163 | + | ||
164 | + if uinfo.Lv < info.Limitlv { | ||
165 | + logger.Error("AddWithDrawList failed err=%v", err) | ||
166 | + resp.Message = "完成日常任务可以提升人物等级哦~" | ||
167 | + resp.Code = ERROR_WITHDRAWLVLIMIT | ||
168 | + break | ||
169 | + } | ||
170 | + | ||
171 | + if info.Isnew == 0 { | ||
172 | + logger.Error("AddWithDrawList failed err=%v", err) | ||
173 | + resp.Message = "新人专享只能提取一次" | ||
174 | + resp.Code = ERROR_WITHDRAWONLYONE | ||
175 | + break | ||
176 | + } | ||
177 | + | ||
178 | + if info.Preisfind == 0 { | ||
179 | + logger.Error("HandlerGetcash Preisfind err=%v", err) | ||
180 | + resp.Message = "请先完成前一档提现" | ||
181 | + resp.Code = ERROR_PRENOTFINISH | ||
182 | + break | ||
183 | + } | ||
184 | + | ||
185 | + //普通提现需要判断前置条件 | ||
186 | + if rdata.Ctype == 1 { | ||
187 | + //判断一下前置条件的下一档 | ||
188 | + if index == len(uinfo.WithDraw.Cashdata)-1 { | ||
189 | + //最后一档了不用处理 | ||
190 | + } else { | ||
191 | + if index < len(uinfo.WithDraw.Cashdata)-1 { | ||
192 | + uinfo.WithDraw.Cashdata[index+1].Preisfind = 1 | ||
193 | + } | ||
194 | + } | ||
195 | + } | ||
196 | + | ||
197 | + //如果是2.2.7版本开启提现次数限制 | ||
198 | + if rdata.Ver == "2.2.7" && uinfo.GetCashCnt > 0 { | ||
199 | + logger.Error("HandlerGetcash GetCashCnt err=%v", err) | ||
200 | + resp.Message = "当天已经提现过了,请明天再来" | ||
201 | + resp.Code = ERROR_PRENOTFINISH | ||
202 | + break | ||
203 | + } | ||
204 | + | ||
205 | + if uinfo.SumLoginDay < info.Day { | ||
206 | + logger.Error("HandlerGetcash GetCashCnt err=%v", err) | ||
207 | + resp.Message = "累计登陆天数不足" | ||
208 | + resp.Code = ERROR_PRENOTFINISH | ||
209 | + break | ||
210 | + } | ||
211 | + | ||
212 | + //2.2.5版本开启自动审核 | ||
213 | + checkcoin := 2 | ||
214 | + if rdata.Ver == "2.2.5" || rdata.Ver == "2.2.6" || rdata.Ver == "2.2.7" { | ||
215 | + logger.Info("HandlerGetcash autocheckcoin") | ||
216 | + if drawnum <= 150 { | ||
217 | + //1.5挡位以下不需要审核 | ||
218 | + checkcoin = 1 //临时关闭u | ||
219 | + } | ||
220 | + } | ||
221 | + | ||
222 | + cdkey, err := GetCashWechatFromSDK(uuid, drawnum, rdata.Gameid, rdata.Channel, rdata.Openid, rdata.Nickname, rdata.Headurl, rdata.Ver, checkcoin) | ||
223 | + if err != nil { | ||
224 | + logger.Error("GetCashFromSDK failed err=%v", err) | ||
225 | + resp.Message = "从后台提现失败了" | ||
226 | + resp.Code = ERROR_GETCASH_FAILED | ||
227 | + break | ||
228 | + } | ||
229 | + logger.Info("HandlerGetcashwechat cdkey=%v", cdkey) | ||
230 | + | ||
231 | + //保存cdkey | ||
232 | + var tmp CashCdKeyInfo | ||
233 | + tmp.Cdkey = cdkey | ||
234 | + tmp.Money = rdata.Money | ||
235 | + tmp.Id = info.Cid | ||
236 | + uinfo.Cdkeys = append(uinfo.Cdkeys, tmp) | ||
237 | + | ||
238 | + uinfo.GetCashCnt++ | ||
239 | + //如果是前六挡 | ||
240 | + if info.Cid <= 6 && rdata.Ctype == 1 { | ||
241 | + uinfo.WithDraw.Cashdata[index].Isnew = 0 | ||
242 | + } | ||
243 | + if rdata.Ctype == 2 { | ||
244 | + uinfo.WithDraw.SpecialCashdata[index].Isnew = 0 | ||
245 | + } | ||
246 | + | ||
247 | + uinfo.RealGold += drawnum * 100 | ||
248 | + //uinfo.RealGold -= drawnum * 100 | ||
249 | + | ||
250 | + resp.Data.Cdkey = cdkey | ||
251 | + SaveUserInfo(uinfo, uniqueuuid) | ||
252 | + | ||
253 | + resp.Code = ERROR_OK | ||
254 | + break | ||
255 | + } | ||
256 | + | ||
257 | + //回包 | ||
258 | + logger.Info("HandlerGetcashwechat resp=%+v", resp) | ||
259 | + respstr, _ := json.Marshal(&resp) | ||
260 | + fmt.Fprint(w, string(respstr)) | ||
261 | + | ||
262 | +} | ||
263 | + | ||
110 | func HandlerGetcash(w http.ResponseWriter, data string, uuid int) { | 264 | func HandlerGetcash(w http.ResponseWriter, data string, uuid int) { |
111 | SetHeader(w) | 265 | SetHeader(w) |
112 | var resp GetcashResp | 266 | var resp GetcashResp |
@@ -1110,6 +1264,7 @@ func HandlerQuerdrawinfo(w http.ResponseWriter, data string, uuid int) { | @@ -1110,6 +1264,7 @@ func HandlerQuerdrawinfo(w http.ResponseWriter, data string, uuid int) { | ||
1110 | //返回 | 1264 | //返回 |
1111 | resp.Data.Cashdata = append(resp.Data.Cashdata, uinfo.WithDraw.Cashdata...) | 1265 | resp.Data.Cashdata = append(resp.Data.Cashdata, uinfo.WithDraw.Cashdata...) |
1112 | resp.Data.SpecialCashdata = append(resp.Data.SpecialCashdata, uinfo.WithDraw.SpecialCashdata...) | 1266 | resp.Data.SpecialCashdata = append(resp.Data.SpecialCashdata, uinfo.WithDraw.SpecialCashdata...) |
1267 | + resp.Data.Cdkeycashdata = append(resp.Data.Cdkeycashdata, uinfo.Cdkeys...) | ||
1113 | 1268 | ||
1114 | resp.Code = ERROR_OK | 1269 | resp.Code = ERROR_OK |
1115 | break | 1270 | break |