Commit 472eae1c7dc3a14f3bd6cb5a74341ed5ec7548b6
1 parent
d1820636
Exists in
master
公众号体现
Showing
4 changed files
with
341 additions
and
0 deletions
Show diff stats
src/HttpServer/logic/datadef.go
@@ -66,6 +66,32 @@ type WatchadsResp struct { | @@ -66,6 +66,32 @@ type WatchadsResp struct { | ||
66 | Data WatchadsData `json:"data"` | 66 | Data WatchadsData `json:"data"` |
67 | } | 67 | } |
68 | 68 | ||
69 | +type GetcashwechatData struct { | ||
70 | + Cdkey string `json:"cdkey"` | ||
71 | +} | ||
72 | +type GetcashwechatResp struct { | ||
73 | + Code int `json:"code"` | ||
74 | + Message string `json:"message"` | ||
75 | + Data GetcashwechatData `json:"data"` | ||
76 | +} | ||
77 | + | ||
78 | +type GetcashwechatReq struct { | ||
79 | + Gameid string `json:"gameid"` | ||
80 | + Channel string `json:"channel"` | ||
81 | + Money float32 `json:"money"` | ||
82 | + Openid string `json:"openid"` | ||
83 | + Nickname string `json:"nickname"` | ||
84 | + Headurl string `json:"headurl"` | ||
85 | + Ver string `json:"ver"` | ||
86 | + Ctype int `json:"ctype"` | ||
87 | +} | ||
88 | + | ||
89 | +type CashCdKeyInfo struct { | ||
90 | + Id int `json:"id"` | ||
91 | + Money float32 `json:"money"` | ||
92 | + Cdkey string `json:"cdkey"` | ||
93 | +} | ||
94 | + | ||
69 | type QueryguaninfoData struct { | 95 | type QueryguaninfoData struct { |
70 | Leftcnt int `json:"leftcnt"` | 96 | Leftcnt int `json:"leftcnt"` |
71 | Totalcnt int `json:"totalcnt"` | 97 | Totalcnt int `json:"totalcnt"` |
@@ -391,6 +417,16 @@ type UploadhigestscoreResp struct { | @@ -391,6 +417,16 @@ type UploadhigestscoreResp struct { | ||
391 | Data UploadhigestscoreData `json:"data"` | 417 | Data UploadhigestscoreData `json:"data"` |
392 | } | 418 | } |
393 | 419 | ||
420 | +type GetCashWechatData struct { | ||
421 | + Cdkey string `json:"cdkey"` | ||
422 | +} | ||
423 | + | ||
424 | +type GetCashWechatResp struct { | ||
425 | + Code string `json:"code"` | ||
426 | + Data GetCashWechatData `json:"data"` | ||
427 | + Msg string `json:"msg"` | ||
428 | +} | ||
429 | + | ||
394 | 430 | ||
395 | type TurntablebagReq struct { | 431 | type TurntablebagReq struct { |
396 | Num int `json:"num"` | 432 | Num int `json:"num"` |
@@ -450,6 +486,7 @@ func (v WithDrawDescs) Less(i, j int) bool { | @@ -450,6 +486,7 @@ func (v WithDrawDescs) Less(i, j int) bool { | ||
450 | type WithDrawInfo struct { | 486 | type WithDrawInfo struct { |
451 | Cashdata WithDrawDescs `json:"cashdata"` | 487 | Cashdata WithDrawDescs `json:"cashdata"` |
452 | SpecialCashdata WithDrawDescs `json:"specialcashdata"` | 488 | SpecialCashdata WithDrawDescs `json:"specialcashdata"` |
489 | + Cdkeycashdata []CashCdKeyInfo `json:"cdkeycashdata"` | ||
453 | } | 490 | } |
454 | 491 | ||
455 | type WithDrawDesc struct { | 492 | type WithDrawDesc struct { |
@@ -491,6 +528,7 @@ type UserData struct { | @@ -491,6 +528,7 @@ type UserData struct { | ||
491 | FetchRdBagNum int //当天已领的红包 | 528 | FetchRdBagNum int //当天已领的红包 |
492 | SignShow int //是否弹出签到 | 529 | SignShow int //是否弹出签到 |
493 | WithDraw WithDrawInfo //提现记录信息 | 530 | WithDraw WithDrawInfo //提现记录信息 |
531 | + Cdkeys []CashCdKeyInfo //记录提现的cdkeys | ||
494 | //SpecialWithDraw WithDrawInfo //活跃提现记录信息 | 532 | //SpecialWithDraw WithDrawInfo //活跃提现记录信息 |
495 | Task TaskInfo //玩家任务完成相关信息 | 533 | Task TaskInfo //玩家任务完成相关信息 |
496 | Achieve AchieveMentInfo //玩家成就完成相关数据 | 534 | Achieve AchieveMentInfo //玩家成就完成相关数据 |
src/HttpServer/logic/function.go
@@ -1192,6 +1192,128 @@ func DoHttpPost(bys []byte, apistr string) (string, error) { | @@ -1192,6 +1192,128 @@ func DoHttpPost(bys []byte, apistr string) (string, error) { | ||
1192 | return string(result), nil | 1192 | return string(result), nil |
1193 | } | 1193 | } |
1194 | 1194 | ||
1195 | + | ||
1196 | + | ||
1197 | +func GetCashWechatFromSDK(uuid int, goldnum int, gameid, channel, openid, nickname, headurl, ver string, checkcoin int) (string, error) { | ||
1198 | + | ||
1199 | + SERVERKEY := XIAOXINGXING_SERVERKEYTEST | ||
1200 | + if gameid == "1015" { | ||
1201 | + SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1015 | ||
1202 | + } | ||
1203 | + | ||
1204 | + if gameid == "1016" { | ||
1205 | + SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1016 | ||
1206 | + } | ||
1207 | + if gameid == "1019" { | ||
1208 | + SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1019 | ||
1209 | + } | ||
1210 | + if gameid == "1020" { | ||
1211 | + SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1020 | ||
1212 | + } | ||
1213 | + if gameid == "1021" { | ||
1214 | + SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1021 | ||
1215 | + } | ||
1216 | + if gameid == "1023" { | ||
1217 | + SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1023 | ||
1218 | + } | ||
1219 | + | ||
1220 | + if gameid == "1032" { | ||
1221 | + SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1032 | ||
1222 | + } | ||
1223 | + if goldnum == 0 || uuid == 0 || gameid == "" || channel == "" || ver == "" { | ||
1224 | + logger.Error("GetCashFromSDK param empty") | ||
1225 | + return "error", errors.New("param empty") | ||
1226 | + } | ||
1227 | + | ||
1228 | + if openid == "" { | ||
1229 | + openid = "test" | ||
1230 | + } | ||
1231 | + var paramlist []string | ||
1232 | + var params TixianDesc | ||
1233 | + params.Sign_type = "md5" | ||
1234 | + params.Gameid = gameid | ||
1235 | + params.Channel = channel | ||
1236 | + params.Uid = uuid | ||
1237 | + params.Time_stamp = strconv.Itoa(int(time.Now().Unix())) | ||
1238 | + params.Headurl = headurl | ||
1239 | + params.Money = goldnum | ||
1240 | + params.Openid = openid | ||
1241 | + params.Nickname = nickname | ||
1242 | + params.Typ = 11 | ||
1243 | + params.Ver = ver | ||
1244 | + params.Editcoin = 1 | ||
1245 | + params.Checkcoin = checkcoin | ||
1246 | + signtypestr := "sign_type=" + params.Sign_type | ||
1247 | + timestampstr := "time_stamp=" + strconv.Itoa(int(time.Now().Unix())) | ||
1248 | + paramgameid := "gameid=" + gameid | ||
1249 | + pchannel := "channel=" + channel | ||
1250 | + puid := "uid=" + strconv.Itoa(uuid) | ||
1251 | + phead := "headurl=" + headurl | ||
1252 | + pnickname := "nickname=" + nickname | ||
1253 | + popenid := "openid=" + openid | ||
1254 | + pmoney := "money=" + strconv.Itoa(goldnum) | ||
1255 | + ptype := "typ=" + "11" //微信 | ||
1256 | + ped := "editcoin=1" | ||
1257 | + pcheco := "checkcoin=" + strconv.Itoa(checkcoin) | ||
1258 | + //pver := "ver=" + params.Ver | ||
1259 | + paramlist = append(paramlist, signtypestr) | ||
1260 | + paramlist = append(paramlist, timestampstr) | ||
1261 | + paramlist = append(paramlist, paramgameid) | ||
1262 | + paramlist = append(paramlist, pchannel) | ||
1263 | + paramlist = append(paramlist, puid) | ||
1264 | + if headurl != "" { | ||
1265 | + paramlist = append(paramlist, phead) | ||
1266 | + } | ||
1267 | + if nickname != "" { | ||
1268 | + paramlist = append(paramlist, pnickname) | ||
1269 | + } | ||
1270 | + paramlist = append(paramlist, popenid) | ||
1271 | + paramlist = append(paramlist, pmoney) | ||
1272 | + paramlist = append(paramlist, ptype) | ||
1273 | + paramlist = append(paramlist, ped) | ||
1274 | + paramlist = append(paramlist, pcheco) | ||
1275 | + //paramlist = append(paramlist, pver) | ||
1276 | + | ||
1277 | + sumparam := GettotalParam(paramlist) | ||
1278 | + //加serverkey | ||
1279 | + signsum := sumparam + SERVERKEY | ||
1280 | + | ||
1281 | + //进行hash | ||
1282 | + sign := GetHashValue(signsum) | ||
1283 | + params.Sign = sign | ||
1284 | + | ||
1285 | + bys, err := json.Marshal(¶ms) | ||
1286 | + if err != nil { | ||
1287 | + logger.Error("GetCashWechatFromSDK failed=%v", err) | ||
1288 | + return "error", err | ||
1289 | + } | ||
1290 | + res, err := DoHttpPost(bys, "api/server/tixiancdkey") | ||
1291 | + logger.Info("GetCashWechatFromSDK sumparam is:%v,sign is:%v", signsum, sign) | ||
1292 | + logger.Info("GetCashWechatFromSDK sumparam param=%v", string(bys)) | ||
1293 | + if err != nil { | ||
1294 | + logger.Error("GetCashWechatFromSDK failed=%v", err) | ||
1295 | + return "error", err | ||
1296 | + } | ||
1297 | + | ||
1298 | + logger.Info("GetCashWechatFromSDK res=%v", res) | ||
1299 | + | ||
1300 | + var resp GetCashWechatResp | ||
1301 | + err = json.Unmarshal([]byte(res), &resp) | ||
1302 | + if err != nil { | ||
1303 | + logger.Error("GetCashWechatFromSDK failed=%v", err) | ||
1304 | + return "error", err | ||
1305 | + } | ||
1306 | + | ||
1307 | + if resp.Code != "0" { | ||
1308 | + logger.Error("GetCashWechatFromSDK failed=%v", resp.Msg) | ||
1309 | + return "error", errors.New(resp.Msg) | ||
1310 | + } | ||
1311 | + | ||
1312 | + return resp.Data.Cdkey, nil | ||
1313 | +} | ||
1314 | + | ||
1315 | + | ||
1316 | + | ||
1195 | func GetCoinFromSdk(uuid int, gameid string, channel string) (int, error) { | 1317 | func GetCoinFromSdk(uuid int, gameid string, channel string) (int, error) { |
1196 | 1318 | ||
1197 | SERVERKEY := XIAOXINGXING_SERVERKEYTEST | 1319 | SERVERKEY := XIAOXINGXING_SERVERKEYTEST |
src/HttpServer/logic/httpserver.go
@@ -75,6 +75,7 @@ func startServerHttpServe() { | @@ -75,6 +75,7 @@ func startServerHttpServe() { | ||
75 | http.HandleFunc("/ballbattle/drawguangold", Drawguangold) //提取存钱罐的金币到个人钱包 | 75 | http.HandleFunc("/ballbattle/drawguangold", Drawguangold) //提取存钱罐的金币到个人钱包 |
76 | http.HandleFunc("/ballbattle/querdrawinfo", Querdrawinfo) //获取提现档位信息接口 | 76 | http.HandleFunc("/ballbattle/querdrawinfo", Querdrawinfo) //获取提现档位信息接口 |
77 | http.HandleFunc("/ballbattle/getcash", Getcash) //提现 | 77 | http.HandleFunc("/ballbattle/getcash", Getcash) //提现 |
78 | + http.HandleFunc("/ballbattle/getcashwechat", Getcashwechat) //提现 | ||
78 | http.HandleFunc("/ballbattle/getcashrecord", Getcashrecord) //提现记录列表 | 79 | http.HandleFunc("/ballbattle/getcashrecord", Getcashrecord) //提现记录列表 |
79 | http.HandleFunc("/ballbattle/onlinentf", Onlinentf) //在线通知 | 80 | http.HandleFunc("/ballbattle/onlinentf", Onlinentf) //在线通知 |
80 | http.HandleFunc("/ballbattle/updatetaskandachieve", Updatetaskandachieve) //上报任务事件进度 | 81 | http.HandleFunc("/ballbattle/updatetaskandachieve", Updatetaskandachieve) //上报任务事件进度 |
@@ -587,6 +588,28 @@ func Getcashrecord(w http.ResponseWriter, r *http.Request) { | @@ -587,6 +588,28 @@ func Getcashrecord(w http.ResponseWriter, r *http.Request) { | ||
587 | HandlerGetcashrecord(w, s, Uuid) | 588 | HandlerGetcashrecord(w, s, Uuid) |
588 | } | 589 | } |
589 | 590 | ||
591 | + | ||
592 | +func Getcashwechat(w http.ResponseWriter, r *http.Request) { | ||
593 | + | ||
594 | + Uuid := 0 | ||
595 | + if len(r.Header) > 0 { | ||
596 | + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) | ||
597 | + } | ||
598 | + | ||
599 | + if Uuid == 0 { | ||
600 | + SetHeader(w) | ||
601 | + //logger.Error("Uuid is nil!") | ||
602 | + return | ||
603 | + } | ||
604 | + result, _ := ioutil.ReadAll(r.Body) | ||
605 | + r.Body.Close() | ||
606 | + | ||
607 | + s := string(result) | ||
608 | + logger.Info("Getcashwechat , body:%v,uuid=%v", s, Uuid) | ||
609 | + | ||
610 | + HandlerGetcashwechat(w, s, Uuid) | ||
611 | +} | ||
612 | + | ||
590 | func Getcash(w http.ResponseWriter, r *http.Request) { | 613 | func Getcash(w http.ResponseWriter, r *http.Request) { |
591 | 614 | ||
592 | Uuid := 0 | 615 | Uuid := 0 |
src/HttpServer/logic/logic.go
@@ -107,6 +107,163 @@ func HandlerWatchads(w http.ResponseWriter, data string, uuid int) { | @@ -107,6 +107,163 @@ 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 | + | ||
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 | + | ||
110 | func HandlerGetcash(w http.ResponseWriter, data string, uuid int) { | 267 | func HandlerGetcash(w http.ResponseWriter, data string, uuid int) { |
111 | SetHeader(w) | 268 | SetHeader(w) |
112 | var resp GetcashResp | 269 | var resp GetcashResp |
@@ -1204,6 +1361,7 @@ func HandlerQuerdrawinfo(w http.ResponseWriter, data string, uuid int) { | @@ -1204,6 +1361,7 @@ func HandlerQuerdrawinfo(w http.ResponseWriter, data string, uuid int) { | ||
1204 | //返回 | 1361 | //返回 |
1205 | resp.Data.Cashdata = append(resp.Data.Cashdata, uinfo.WithDraw.Cashdata...) | 1362 | resp.Data.Cashdata = append(resp.Data.Cashdata, uinfo.WithDraw.Cashdata...) |
1206 | resp.Data.SpecialCashdata = append(resp.Data.SpecialCashdata, uinfo.WithDraw.SpecialCashdata...) | 1363 | resp.Data.SpecialCashdata = append(resp.Data.SpecialCashdata, uinfo.WithDraw.SpecialCashdata...) |
1364 | + resp.Data.Cdkeycashdata = append(resp.Data.Cdkeycashdata, uinfo.Cdkeys...) | ||
1207 | 1365 | ||
1208 | resp.Code = ERROR_OK | 1366 | resp.Code = ERROR_OK |
1209 | break | 1367 | break |