Commit 9aabb576520b9b3a3eb461d6a9fc72d33e29e1b3
1 parent
ff7df593
Exists in
ver2.3.6
提交微信公众号功能
Showing
4 changed files
with
318 additions
and
0 deletions
Show diff stats
src/HttpServer/logic/datadef.go
@@ -150,6 +150,38 @@ type GetcashResp struct { | @@ -150,6 +150,38 @@ type GetcashResp struct { | ||
150 | Data GetcashData `json:"data"` | 150 | Data GetcashData `json:"data"` |
151 | } | 151 | } |
152 | 152 | ||
153 | + | ||
154 | +type GetcashwechatData struct { | ||
155 | + Cdkey string `json:"cdkey"` | ||
156 | +} | ||
157 | +type GetcashwechatResp struct { | ||
158 | + Code int `json:"code"` | ||
159 | + Message string `json:"message"` | ||
160 | + Data GetcashwechatData `json:"data"` | ||
161 | +} | ||
162 | + | ||
163 | + | ||
164 | +type GetCashWechatData struct { | ||
165 | + Cdkey string `json:"cdkey"` | ||
166 | +} | ||
167 | + | ||
168 | +type GetCashWechatResp struct { | ||
169 | + Code string `json:"code"` | ||
170 | + Data GetCashWechatData `json:"data"` | ||
171 | + Msg string `json:"msg"` | ||
172 | +} | ||
173 | + | ||
174 | +type GetcashwechatReq struct { | ||
175 | + Gameid string `json:"gameid"` | ||
176 | + Channel string `json:"channel"` | ||
177 | + Money float32 `json:"money"` | ||
178 | + Openid string `json:"openid"` | ||
179 | + Nickname string `json:"nickname"` | ||
180 | + Headurl string `json:"headurl"` | ||
181 | + Ver string `json:"ver"` | ||
182 | + Ctype int `json:"ctype"` | ||
183 | +} | ||
184 | + | ||
153 | type GetcashrecordReq struct { | 185 | type GetcashrecordReq struct { |
154 | Gameid string `json:"gameid"` | 186 | Gameid string `json:"gameid"` |
155 | Channel string `json:"channel"` | 187 | Channel string `json:"channel"` |
@@ -368,6 +400,7 @@ func (v WithDrawDescs) Less(i, j int) bool { | @@ -368,6 +400,7 @@ func (v WithDrawDescs) Less(i, j int) bool { | ||
368 | type WithDrawInfo struct { | 400 | type WithDrawInfo struct { |
369 | Cashdata WithDrawDescs `json:"cashdata"` | 401 | Cashdata WithDrawDescs `json:"cashdata"` |
370 | SpecialCashdata WithDrawDescs `json:"specialcashdata"` | 402 | SpecialCashdata WithDrawDescs `json:"specialcashdata"` |
403 | + Cdkeycashdata []CashCdKeyInfo `json:"cdkeycashdata"` | ||
371 | } | 404 | } |
372 | 405 | ||
373 | type WithDrawDesc struct { | 406 | type WithDrawDesc struct { |
@@ -379,6 +412,12 @@ type WithDrawDesc struct { | @@ -379,6 +412,12 @@ type WithDrawDesc struct { | ||
379 | Day int `json:"day"` | 412 | Day int `json:"day"` |
380 | } | 413 | } |
381 | 414 | ||
415 | +type CashCdKeyInfo struct { | ||
416 | + Id int `json:"id"` | ||
417 | + Money float32 `json:"money"` | ||
418 | + Cdkey string `json:"cdkey"` | ||
419 | +} | ||
420 | + | ||
382 | //玩家数据 | 421 | //玩家数据 |
383 | type UserData struct { | 422 | type UserData struct { |
384 | Userid int //玩家id | 423 | Userid int //玩家id |
@@ -407,6 +446,7 @@ type UserData struct { | @@ -407,6 +446,7 @@ type UserData struct { | ||
407 | FetchRdBagNum int //当天已领的红包 | 446 | FetchRdBagNum int //当天已领的红包 |
408 | ShakeTime int //摇一摇 | 447 | ShakeTime int //摇一摇 |
409 | WithDraw WithDrawInfo //提现记录信息 | 448 | WithDraw WithDrawInfo //提现记录信息 |
449 | + Cdkeys []CashCdKeyInfo //记录提现的cdkeys | ||
410 | //SpecialWithDraw WithDrawInfo //活跃提现记录信息 | 450 | //SpecialWithDraw WithDrawInfo //活跃提现记录信息 |
411 | Task TaskInfo //玩家任务完成相关信息 | 451 | Task TaskInfo //玩家任务完成相关信息 |
412 | Achieve AchieveMentInfo //玩家成就完成相关数据 | 452 | Achieve AchieveMentInfo //玩家成就完成相关数据 |
src/HttpServer/logic/function.go
@@ -1340,6 +1340,105 @@ func AddCoinToSdk(uuid int, goldnum int, gameid string, channel string, atype in | @@ -1340,6 +1340,105 @@ func AddCoinToSdk(uuid int, goldnum int, gameid string, channel string, atype in | ||
1340 | return resp.Data.Mycoin,realaddgoldnum, nil | 1340 | return resp.Data.Mycoin,realaddgoldnum, nil |
1341 | } | 1341 | } |
1342 | 1342 | ||
1343 | +func GetCashWechatFromSDK(uuid int, goldnum int, gameid, channel, openid, nickname, headurl, ver string, checkcoin int) (string, error) { | ||
1344 | + | ||
1345 | + SERVERKEY := XIAOXINGXING_SERVERKEYTEST | ||
1346 | + if gameid == "1015" { | ||
1347 | + SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1015 | ||
1348 | + } | ||
1349 | + | ||
1350 | + if gameid == "1020" { | ||
1351 | + SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1020 | ||
1352 | + } | ||
1353 | + | ||
1354 | + if goldnum == 0 || uuid == 0 || gameid == "" || channel == "" || openid == "" || ver == "" { | ||
1355 | + logger.Error("GetCashFromSDK param empty") | ||
1356 | + return "error", errors.New("param empty") | ||
1357 | + } | ||
1358 | + var paramlist []string | ||
1359 | + var params TixianDesc | ||
1360 | + params.Sign_type = "md5" | ||
1361 | + params.Gameid = gameid | ||
1362 | + params.Channel = channel | ||
1363 | + params.Uid = uuid | ||
1364 | + params.Time_stamp = strconv.Itoa(int(time.Now().Unix())) | ||
1365 | + params.Headurl = headurl | ||
1366 | + params.Money = goldnum | ||
1367 | + params.Openid = openid | ||
1368 | + params.Nickname = nickname | ||
1369 | + params.Typ = 11 | ||
1370 | + params.Ver = ver | ||
1371 | + params.Editcoin = 1 | ||
1372 | + params.Checkcoin = checkcoin | ||
1373 | + signtypestr := "sign_type=" + params.Sign_type | ||
1374 | + timestampstr := "time_stamp=" + strconv.Itoa(int(time.Now().Unix())) | ||
1375 | + paramgameid := "gameid=" + gameid | ||
1376 | + pchannel := "channel=" + channel | ||
1377 | + puid := "uid=" + strconv.Itoa(uuid) | ||
1378 | + phead := "headurl=" + headurl | ||
1379 | + pnickname := "nickname=" + nickname | ||
1380 | + popenid := "openid=" + openid | ||
1381 | + pmoney := "money=" + strconv.Itoa(goldnum) | ||
1382 | + ptype := "typ=" + "11" //微信 | ||
1383 | + ped := "editcoin=1" | ||
1384 | + pcheco := "checkcoin=" + strconv.Itoa(checkcoin) | ||
1385 | + //pver := "ver=" + params.Ver | ||
1386 | + paramlist = append(paramlist, signtypestr) | ||
1387 | + paramlist = append(paramlist, timestampstr) | ||
1388 | + paramlist = append(paramlist, paramgameid) | ||
1389 | + paramlist = append(paramlist, pchannel) | ||
1390 | + paramlist = append(paramlist, puid) | ||
1391 | + if headurl != "" { | ||
1392 | + paramlist = append(paramlist, phead) | ||
1393 | + } | ||
1394 | + if nickname != "" { | ||
1395 | + paramlist = append(paramlist, pnickname) | ||
1396 | + } | ||
1397 | + paramlist = append(paramlist, popenid) | ||
1398 | + paramlist = append(paramlist, pmoney) | ||
1399 | + paramlist = append(paramlist, ptype) | ||
1400 | + paramlist = append(paramlist, ped) | ||
1401 | + paramlist = append(paramlist, pcheco) | ||
1402 | + //paramlist = append(paramlist, pver) | ||
1403 | + | ||
1404 | + sumparam := GettotalParam(paramlist) | ||
1405 | + //加serverkey | ||
1406 | + signsum := sumparam + SERVERKEY | ||
1407 | + | ||
1408 | + //进行hash | ||
1409 | + sign := GetHashValue(signsum) | ||
1410 | + params.Sign = sign | ||
1411 | + | ||
1412 | + bys, err := json.Marshal(¶ms) | ||
1413 | + if err != nil { | ||
1414 | + logger.Error("GetCashWechatFromSDK failed=%v", err) | ||
1415 | + return "error", err | ||
1416 | + } | ||
1417 | + res, err := DoHttpPost(bys, "api/server/tixiancdkey") | ||
1418 | + logger.Info("GetCashWechatFromSDK sumparam is:%v,sign is:%v", signsum, sign) | ||
1419 | + logger.Info("GetCashWechatFromSDK sumparam param=%v", string(bys)) | ||
1420 | + if err != nil { | ||
1421 | + logger.Error("GetCashWechatFromSDK failed=%v", err) | ||
1422 | + return "error", err | ||
1423 | + } | ||
1424 | + | ||
1425 | + logger.Info("GetCashWechatFromSDK res=%v", res) | ||
1426 | + | ||
1427 | + var resp GetCashWechatResp | ||
1428 | + err = json.Unmarshal([]byte(res), &resp) | ||
1429 | + if err != nil { | ||
1430 | + logger.Error("GetCashWechatFromSDK failed=%v", err) | ||
1431 | + return "error", err | ||
1432 | + } | ||
1433 | + | ||
1434 | + if resp.Code != "0" { | ||
1435 | + logger.Error("GetCashWechatFromSDK failed=%v", resp.Msg) | ||
1436 | + return "error", errors.New(resp.Msg) | ||
1437 | + } | ||
1438 | + | ||
1439 | + return resp.Data.Cdkey, nil | ||
1440 | +} | ||
1441 | + | ||
1343 | func GetCashFromSDK(uuid int, goldnum int, gameid, channel, openid, nickname, headurl, ver string, checkcoin int) (int, error) { | 1442 | func GetCashFromSDK(uuid int, goldnum int, gameid, channel, openid, nickname, headurl, ver string, checkcoin int) (int, error) { |
1344 | 1443 | ||
1345 | SERVERKEY := XIAOXINGXING_SERVERKEYTEST | 1444 | SERVERKEY := XIAOXINGXING_SERVERKEYTEST |
src/HttpServer/logic/httpserver.go
@@ -53,6 +53,7 @@ func startServerHttpServe() { | @@ -53,6 +53,7 @@ func startServerHttpServe() { | ||
53 | http.HandleFunc("/eliminatestar/drawguangold", Drawguangold) //提取存钱罐的金币到个人钱包 | 53 | http.HandleFunc("/eliminatestar/drawguangold", Drawguangold) //提取存钱罐的金币到个人钱包 |
54 | http.HandleFunc("/eliminatestar/querdrawinfo", Querdrawinfo) //获取提现档位信息接口 | 54 | http.HandleFunc("/eliminatestar/querdrawinfo", Querdrawinfo) //获取提现档位信息接口 |
55 | http.HandleFunc("/eliminatestar/getcash", Getcash) //提现 | 55 | http.HandleFunc("/eliminatestar/getcash", Getcash) //提现 |
56 | + http.HandleFunc("/eliminatestar/getcashwechat", Getcashwechat) //提现公众号 | ||
56 | http.HandleFunc("/eliminatestar/getcashrecord", Getcashrecord) //提现记录列表 | 57 | http.HandleFunc("/eliminatestar/getcashrecord", Getcashrecord) //提现记录列表 |
57 | http.HandleFunc("/eliminatestar/onlinentf", Onlinentf) //在线通知 | 58 | http.HandleFunc("/eliminatestar/onlinentf", Onlinentf) //在线通知 |
58 | http.HandleFunc("/eliminatestar/updatetaskandachieve", Updatetaskandachieve) //上报任务事件进度 | 59 | http.HandleFunc("/eliminatestar/updatetaskandachieve", Updatetaskandachieve) //上报任务事件进度 |
@@ -530,6 +531,27 @@ func Getcash(w http.ResponseWriter, r *http.Request) { | @@ -530,6 +531,27 @@ func Getcash(w http.ResponseWriter, r *http.Request) { | ||
530 | HandlerGetcash(w, s, Uuid) | 531 | HandlerGetcash(w, s, Uuid) |
531 | } | 532 | } |
532 | 533 | ||
534 | +func Getcashwechat(w http.ResponseWriter, r *http.Request) { | ||
535 | + | ||
536 | + Uuid := 0 | ||
537 | + if len(r.Header) > 0 { | ||
538 | + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) | ||
539 | + } | ||
540 | + | ||
541 | + if Uuid == 0 { | ||
542 | + SetHeader(w) | ||
543 | + //logger.Error("Uuid is nil!") | ||
544 | + return | ||
545 | + } | ||
546 | + result, _ := ioutil.ReadAll(r.Body) | ||
547 | + r.Body.Close() | ||
548 | + | ||
549 | + s := string(result) | ||
550 | + logger.Info("Getcashwechat , body:%v,uuid=%v", s, Uuid) | ||
551 | + | ||
552 | + HandlerGetcashwechat(w, s, Uuid) | ||
553 | +} | ||
554 | + | ||
533 | func Querdrawinfo(w http.ResponseWriter, r *http.Request) { | 555 | func Querdrawinfo(w http.ResponseWriter, r *http.Request) { |
534 | 556 | ||
535 | Uuid := 0 | 557 | Uuid := 0 |
src/HttpServer/logic/logic.go
@@ -108,6 +108,162 @@ func HandlerWatchads(w http.ResponseWriter, data string, uuid int) { | @@ -108,6 +108,162 @@ func HandlerWatchads(w http.ResponseWriter, data string, uuid int) { | ||
108 | fmt.Fprint(w, string(respstr))*/ | 108 | fmt.Fprint(w, string(respstr))*/ |
109 | } | 109 | } |
110 | 110 | ||
111 | + | ||
112 | +func HandlerGetcashwechat(w http.ResponseWriter, data string, uuid int) { | ||
113 | + SetHeader(w) | ||
114 | + var resp GetcashwechatResp | ||
115 | + resp.Code = 0 | ||
116 | + var rdata GetcashwechatReq | ||
117 | + err := json.Unmarshal([]byte(data), &rdata) | ||
118 | + for { | ||
119 | + if err != nil { | ||
120 | + logger.Info("json decode HandlerDrawguangold data failed:%v,for:%v", err, data) | ||
121 | + resp.Message = "json解析错误" | ||
122 | + resp.Code = ERROR_JSONUNMASH_ERROR | ||
123 | + break | ||
124 | + } | ||
125 | + //临时处理一下 | ||
126 | + /*if rdata.Ver == "" { | ||
127 | + rdata.Ver = "2.0.0" | ||
128 | + }*/ | ||
129 | + | ||
130 | + //需要加上渠道才是唯一的玩家id,不同渠道视为不同数据 | ||
131 | + uniqueuuid := strconv.Itoa(uuid) + rdata.Channel | ||
132 | + uinfo, err := GetUserInfo(uniqueuuid) | ||
133 | + if err != nil || uinfo == nil { | ||
134 | + logger.Error("redis failed err=%v", err) | ||
135 | + resp.Message = "服务器错误" | ||
136 | + resp.Code = ERROR_SRV_ERROR | ||
137 | + break | ||
138 | + } | ||
139 | + | ||
140 | + drawnum := int(rdata.Money * 100) | ||
141 | + //需要判断一下金币是否足够 | ||
142 | + if drawnum*100 > uinfo.RealGold { | ||
143 | + logger.Error("gold nor enough failed err=%v", err) | ||
144 | + resp.Message = "提现金币不足" | ||
145 | + resp.Code = ERROR_GETCASH_GOLDNOTENOUGH_FAILED | ||
146 | + break | ||
147 | + } | ||
148 | + | ||
149 | + //需要处理一下提现级别 | ||
150 | + | ||
151 | + index := 0 | ||
152 | + var info *WithDrawDesc | ||
153 | + if rdata.Ctype == 1 { | ||
154 | + index, info = uinfo.GetWithDrawData(rdata.Money) | ||
155 | + } else { | ||
156 | + index, info = uinfo.GetSpecialWithDrawData(rdata.Money) | ||
157 | + } | ||
158 | + | ||
159 | + if index == -1 || info == nil { | ||
160 | + logger.Error("AddWithDrawList failed err=%v", err) | ||
161 | + resp.Message = "网络错误" | ||
162 | + resp.Code = ERROR_SRV_ERROR | ||
163 | + break | ||
164 | + } | ||
165 | + | ||
166 | + if uinfo.Lv < info.Limitlv { | ||
167 | + logger.Error("AddWithDrawList failed err=%v", err) | ||
168 | + resp.Message = "完成日常任务可以提升人物等级哦~" | ||
169 | + resp.Code = ERROR_WITHDRAWLVLIMIT | ||
170 | + break | ||
171 | + } | ||
172 | + | ||
173 | + if info.Isnew == 0 { | ||
174 | + logger.Error("AddWithDrawList failed err=%v", err) | ||
175 | + resp.Message = "新人专享只能提取一次" | ||
176 | + resp.Code = ERROR_WITHDRAWONLYONE | ||
177 | + break | ||
178 | + } | ||
179 | + | ||
180 | + if info.Preisfind == 0 { | ||
181 | + logger.Error("HandlerGetcash Preisfind err=%v", err) | ||
182 | + resp.Message = "请先完成前一档提现" | ||
183 | + resp.Code = ERROR_PRENOTFINISH | ||
184 | + break | ||
185 | + } | ||
186 | + | ||
187 | + //普通提现需要判断前置条件 | ||
188 | + if rdata.Ctype == 1 { | ||
189 | + //判断一下前置条件的下一档 | ||
190 | + if index == len(uinfo.WithDraw.Cashdata)-1 { | ||
191 | + //最后一档了不用处理 | ||
192 | + } else { | ||
193 | + if index < len(uinfo.WithDraw.Cashdata)-1 { | ||
194 | + uinfo.WithDraw.Cashdata[index+1].Preisfind = 1 | ||
195 | + } | ||
196 | + } | ||
197 | + } | ||
198 | + | ||
199 | + //如果是2.2.7版本开启提现次数限制 | ||
200 | + if rdata.Ver == "2.2.7" && uinfo.GetCashCnt > 0 { | ||
201 | + logger.Error("HandlerGetcash GetCashCnt err=%v", err) | ||
202 | + resp.Message = "当天已经提现过了,请明天再来" | ||
203 | + resp.Code = ERROR_PRENOTFINISH | ||
204 | + break | ||
205 | + } | ||
206 | + | ||
207 | + if uinfo.SumLoginDay < info.Day { | ||
208 | + logger.Error("HandlerGetcash GetCashCnt err=%v", err) | ||
209 | + resp.Message = "累计登陆天数不足" | ||
210 | + resp.Code = ERROR_PRENOTFINISH | ||
211 | + break | ||
212 | + } | ||
213 | + | ||
214 | + //2.2.5版本开启自动审核 | ||
215 | + checkcoin := 2 | ||
216 | + if rdata.Ver == "2.2.5" || rdata.Ver == "2.2.6" || rdata.Ver == "2.2.7" { | ||
217 | + logger.Info("HandlerGetcash autocheckcoin") | ||
218 | + if drawnum <= 150 { | ||
219 | + //1.5挡位以下不需要审核 | ||
220 | + checkcoin = 1 //临时关闭u | ||
221 | + } | ||
222 | + } | ||
223 | + | ||
224 | + cdkey, err := GetCashWechatFromSDK(uuid, drawnum, rdata.Gameid, rdata.Channel, rdata.Openid, rdata.Nickname, rdata.Headurl, rdata.Ver, checkcoin) | ||
225 | + if err != nil { | ||
226 | + logger.Error("GetCashFromSDK failed err=%v", err) | ||
227 | + resp.Message = "从后台提现失败了" | ||
228 | + resp.Code = ERROR_GETCASH_FAILED | ||
229 | + break | ||
230 | + } | ||
231 | + logger.Info("HandlerGetcashwechat cdkey=%v", cdkey) | ||
232 | + | ||
233 | + //保存cdkey | ||
234 | + var tmp CashCdKeyInfo | ||
235 | + tmp.Cdkey = cdkey | ||
236 | + tmp.Money = rdata.Money | ||
237 | + tmp.Id = info.Cid | ||
238 | + uinfo.Cdkeys = append(uinfo.Cdkeys, tmp) | ||
239 | + | ||
240 | + uinfo.GetCashCnt++ | ||
241 | + //如果是前六挡 | ||
242 | + if info.Cid <= 6 && rdata.Ctype == 1 { | ||
243 | + uinfo.WithDraw.Cashdata[index].Isnew = 0 | ||
244 | + } | ||
245 | + if rdata.Ctype == 2 { | ||
246 | + uinfo.WithDraw.SpecialCashdata[index].Isnew = 0 | ||
247 | + } | ||
248 | + | ||
249 | + uinfo.RealGold += drawnum * 100 | ||
250 | + //uinfo.RealGold -= drawnum * 100 | ||
251 | + | ||
252 | + resp.Data.Cdkey = cdkey | ||
253 | + SaveUserInfo(uinfo, uniqueuuid) | ||
254 | + | ||
255 | + resp.Code = ERROR_OK | ||
256 | + break | ||
257 | + } | ||
258 | + | ||
259 | + //回包 | ||
260 | + logger.Info("HandlerGetcashwechat resp=%+v", resp) | ||
261 | + respstr, _ := json.Marshal(&resp) | ||
262 | + fmt.Fprint(w, string(respstr)) | ||
263 | + | ||
264 | +} | ||
265 | + | ||
266 | + | ||
111 | func HandlerGetcash(w http.ResponseWriter, data string, uuid int) { | 267 | func HandlerGetcash(w http.ResponseWriter, data string, uuid int) { |
112 | SetHeader(w) | 268 | SetHeader(w) |
113 | var resp GetcashResp | 269 | var resp GetcashResp |
@@ -958,6 +1114,7 @@ func HandlerQuerdrawinfo(w http.ResponseWriter, data string, uuid int) { | @@ -958,6 +1114,7 @@ func HandlerQuerdrawinfo(w http.ResponseWriter, data string, uuid int) { | ||
958 | //返回 | 1114 | //返回 |
959 | resp.Data.Cashdata = append(resp.Data.Cashdata, uinfo.WithDraw.Cashdata...) | 1115 | resp.Data.Cashdata = append(resp.Data.Cashdata, uinfo.WithDraw.Cashdata...) |
960 | resp.Data.SpecialCashdata = append(resp.Data.SpecialCashdata, uinfo.WithDraw.SpecialCashdata...) | 1116 | resp.Data.SpecialCashdata = append(resp.Data.SpecialCashdata, uinfo.WithDraw.SpecialCashdata...) |
1117 | + resp.Data.Cdkeycashdata = append(resp.Data.Cdkeycashdata, uinfo.Cdkeys...) | ||
961 | 1118 | ||
962 | resp.Code = ERROR_OK | 1119 | resp.Code = ERROR_OK |
963 | break | 1120 | break |