Commit 7c843cc37b23c90bc3ccbfe085758b11a093ca84

Authored by 陆恒
1 parent c56c045f
Exists in ver2.3.0

提交

src/HttpServer/logic/datadef.go
... ... @@ -146,6 +146,26 @@ type GetcashResp struct {
146 146 Data GetcashData `json:"data"`
147 147 }
148 148  
  149 +type GetcashwechatData struct {
  150 + Cdkey string `json:"cdkey"`
  151 +}
  152 +type GetcashwechatResp struct {
  153 + Code int `json:"code"`
  154 + Message string `json:"message"`
  155 + Data GetcashwechatData `json:"data"`
  156 +}
  157 +
  158 +type GetcashwechatReq struct {
  159 + Gameid string `json:"gameid"`
  160 + Channel string `json:"channel"`
  161 + Money float32 `json:"money"`
  162 + Openid string `json:"openid"`
  163 + Nickname string `json:"nickname"`
  164 + Headurl string `json:"headurl"`
  165 + Ver string `json:"ver"`
  166 + Ctype int `json:"ctype"`
  167 +}
  168 +
149 169 type GetcashrecordReq struct {
150 170 Gameid string `json:"gameid"`
151 171 Channel string `json:"channel"`
... ... @@ -362,8 +382,9 @@ func (v WithDrawDescs) Less(i, j int) bool {
362 382 }
363 383  
364 384 type WithDrawInfo struct {
365   - Cashdata WithDrawDescs `json:"cashdata"`
366   - SpecialCashdata WithDrawDescs `json:"specialcashdata"`
  385 + Cashdata WithDrawDescs `json:"cashdata"`
  386 + SpecialCashdata WithDrawDescs `json:"specialcashdata"`
  387 + Cdkeycashdata []CashCdKeyInfo `json:"cdkeycashdata"`
367 388 }
368 389  
369 390 type WithDrawDesc struct {
... ... @@ -375,32 +396,39 @@ type WithDrawDesc struct {
375 396 Day int `json:"day"`
376 397 }
377 398  
  399 +type CashCdKeyInfo struct {
  400 + Id int `json:"id"`
  401 + Money float32 `json:"money"`
  402 + Cdkey string `json:"cdkey"`
  403 +}
  404 +
378 405 //玩家数据
379 406 type UserData struct {
380   - Userid int //玩家id
381   - Lv int //玩家当前等级
382   - LvRewardGet int //当前等级奖励是否已经领取 1未领取 2普通领取 3双倍领取
383   - Exp int //玩家当前经验值
384   - GuanGold int //玩家存钱罐中金币数量
385   - RealGold int //玩家实际金币数量(可用于提现的)
386   - WatchAddsTime int //当天剩余红包次数 初始化50次
387   - LastLoginTime int //上次登陆时间
388   - ContinueLoginDay int //连续登录天数
389   - SumLoginDay int //累计登陆天数
390   - GetFromGuanCnt int //当天从存钱款提取金币次数
391   - SignRound int //签到轮数
392   - SignSum int //累计签到天数
393   - IsSignToday int //今日是否已经签到 1是 0否
394   - LeftFreeRB int //剩余免费红包次数
395   - UpLvCostTime int //上一个等级升级时间
396   - UpLvCostTimeSec int //上一个等级升级的时间点时刻
397   - ReadNum int //玩家微转发阅读量
398   - GetCashCnt int //当天提现次数
399   - ShakeTime int //摇一摇
400   - FetchRedCnt int //领取红包次数计数
401   - IsNew int //新手状态
402   - FetchRdBagNum int //当天已领的红包
403   - WithDraw WithDrawInfo //提现记录信息
  407 + Userid int //玩家id
  408 + Lv int //玩家当前等级
  409 + LvRewardGet int //当前等级奖励是否已经领取 1未领取 2普通领取 3双倍领取
  410 + Exp int //玩家当前经验值
  411 + GuanGold int //玩家存钱罐中金币数量
  412 + RealGold int //玩家实际金币数量(可用于提现的)
  413 + WatchAddsTime int //当天剩余红包次数 初始化50次
  414 + LastLoginTime int //上次登陆时间
  415 + ContinueLoginDay int //连续登录天数
  416 + SumLoginDay int //累计登陆天数
  417 + GetFromGuanCnt int //当天从存钱款提取金币次数
  418 + SignRound int //签到轮数
  419 + SignSum int //累计签到天数
  420 + IsSignToday int //今日是否已经签到 1是 0否
  421 + LeftFreeRB int //剩余免费红包次数
  422 + UpLvCostTime int //上一个等级升级时间
  423 + UpLvCostTimeSec int //上一个等级升级的时间点时刻
  424 + ReadNum int //玩家微转发阅读量
  425 + GetCashCnt int //当天提现次数
  426 + ShakeTime int //摇一摇
  427 + FetchRedCnt int //领取红包次数计数
  428 + IsNew int //新手状态
  429 + FetchRdBagNum int //当天已领的红包
  430 + WithDraw WithDrawInfo //提现记录信息
  431 + Cdkeys []CashCdKeyInfo //记录提现的cdkeys
404 432 //SpecialWithDraw WithDrawInfo //活跃提现记录信息
405 433 Task TaskInfo //玩家任务完成相关信息
406 434 Achieve AchieveMentInfo //玩家成就完成相关数据
... ... @@ -460,6 +488,12 @@ type GetCashResp struct {
460 488 Msg string `json:"msg"`
461 489 }
462 490  
  491 +type GetCashWechatResp struct {
  492 + Code string `json:"code"`
  493 + Cdkey string `json:"cdkey"`
  494 + Msg string `json:"msg"`
  495 +}
  496 +
463 497 type GetCashListDesc struct {
464 498 Sign string `json:"sign"`
465 499 Sign_type string `json:"sign_type"`
... ...
src/HttpServer/logic/function.go
... ... @@ -1337,6 +1337,116 @@ func AddCoinToSdk(uuid int, goldnum int, gameid string, channel string, atype in
1337 1337 return resp.Data.Mycoin, realaddgoldnum, nil
1338 1338 }
1339 1339  
  1340 +func GetCashWechatFromSDK(uuid int, goldnum int, gameid, channel, openid, nickname, headurl, ver string, checkcoin int) (string, error) {
  1341 +
  1342 + SERVERKEY := XIAOXINGXING_SERVERKEYTEST
  1343 + if gameid == "1015" {
  1344 + SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1015
  1345 + }
  1346 +
  1347 + if gameid == "1016" {
  1348 + SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1016
  1349 + }
  1350 + if gameid == "1019" {
  1351 + SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1019
  1352 + }
  1353 + if gameid == "1020" {
  1354 + SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1020
  1355 + }
  1356 + if gameid == "1021" {
  1357 + SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1021
  1358 + }
  1359 + if gameid == "1023" {
  1360 + SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1023
  1361 + }
  1362 + if goldnum == 0 || uuid == 0 || gameid == "" || channel == "" || openid == "" || ver == "" {
  1363 + logger.Error("GetCashFromSDK param empty")
  1364 + return "", errors.New("param empty")
  1365 + }
  1366 + var paramlist []string
  1367 + var params TixianDesc
  1368 + params.Sign_type = "md5"
  1369 + params.Gameid = gameid
  1370 + params.Channel = channel
  1371 + params.Uid = uuid
  1372 + params.Time_stamp = strconv.Itoa(int(time.Now().Unix()))
  1373 + params.Headurl = headurl
  1374 + params.Money = goldnum
  1375 + params.Openid = openid
  1376 + params.Nickname = nickname
  1377 + params.Typ = 6
  1378 + params.Ver = ver
  1379 + params.Editcoin = 1
  1380 + params.Checkcoin = checkcoin
  1381 + signtypestr := "sign_type=" + params.Sign_type
  1382 + timestampstr := "time_stamp=" + strconv.Itoa(int(time.Now().Unix()))
  1383 + paramgameid := "gameid=" + gameid
  1384 + pchannel := "channel=" + channel
  1385 + puid := "uid=" + strconv.Itoa(uuid)
  1386 + phead := "headurl=" + headurl
  1387 + pnickname := "nickname=" + nickname
  1388 + popenid := "openid=" + openid
  1389 + pmoney := "money=" + strconv.Itoa(goldnum)
  1390 + ptype := "typ=" + "6" //微信
  1391 + ped := "editcoin=1"
  1392 + pcheco := "checkcoin=" + strconv.Itoa(checkcoin)
  1393 + //pver := "ver=" + params.Ver
  1394 + paramlist = append(paramlist, signtypestr)
  1395 + paramlist = append(paramlist, timestampstr)
  1396 + paramlist = append(paramlist, paramgameid)
  1397 + paramlist = append(paramlist, pchannel)
  1398 + paramlist = append(paramlist, puid)
  1399 + if headurl != "" {
  1400 + paramlist = append(paramlist, phead)
  1401 + }
  1402 + if nickname != "" {
  1403 + paramlist = append(paramlist, pnickname)
  1404 + }
  1405 + paramlist = append(paramlist, popenid)
  1406 + paramlist = append(paramlist, pmoney)
  1407 + paramlist = append(paramlist, ptype)
  1408 + paramlist = append(paramlist, ped)
  1409 + paramlist = append(paramlist, pcheco)
  1410 + //paramlist = append(paramlist, pver)
  1411 +
  1412 + sumparam := GettotalParam(paramlist)
  1413 + //加serverkey
  1414 + signsum := sumparam + SERVERKEY
  1415 +
  1416 + //进行hash
  1417 + sign := GetHashValue(signsum)
  1418 + params.Sign = sign
  1419 +
  1420 + bys, err := json.Marshal(&params)
  1421 + if err != nil {
  1422 + logger.Error("GetCashWechatFromSDK failed=%v", err)
  1423 + return "", err
  1424 + }
  1425 + res, err := DoHttpPost(bys, "api/server/tixian")
  1426 + logger.Info("GetCashWechatFromSDK sumparam is:%v,sign is:%v", signsum, sign)
  1427 + logger.Info("GetCashWechatFromSDK sumparam param=%v", string(bys))
  1428 + if err != nil {
  1429 + logger.Error("GetCashWechatFromSDK failed=%v", err)
  1430 + return "", err
  1431 + }
  1432 +
  1433 + logger.Info("GetCashWechatFromSDK res=%v", res)
  1434 +
  1435 + var resp GetCashWechatResp
  1436 + err = json.Unmarshal([]byte(res), &resp)
  1437 + if err != nil {
  1438 + logger.Error("GetCashWechatFromSDK failed=%v", err)
  1439 + return "", err
  1440 + }
  1441 +
  1442 + if resp.Code != "0" {
  1443 + logger.Error("GetCashWechatFromSDK failed=%v", resp.Msg)
  1444 + return "", errors.New(resp.Msg)
  1445 + }
  1446 +
  1447 + return resp.Cdkey, nil
  1448 +}
  1449 +
1340 1450 func GetCashFromSDK(uuid int, goldnum int, gameid, channel, openid, nickname, headurl, ver string, checkcoin int) (int, error) {
1341 1451  
1342 1452 SERVERKEY := XIAOXINGXING_SERVERKEYTEST
... ...
src/HttpServer/logic/httpserver.go
... ... @@ -53,6 +53,7 @@ func startServerHttpServe() {
53 53 http.HandleFunc("/eliminatestar/drawguangold", Drawguangold) //提取存钱罐的金币到个人钱包
54 54 http.HandleFunc("/eliminatestar/querdrawinfo", Querdrawinfo) //获取提现档位信息接口
55 55 http.HandleFunc("/eliminatestar/getcash", Getcash) //提现
  56 + http.HandleFunc("/eliminatestar/getcashwechat", Getcashwechat) //提现
56 57 http.HandleFunc("/eliminatestar/getcashrecord", Getcashrecord) //提现记录列表
57 58 http.HandleFunc("/eliminatestar/onlinentf", Onlinentf) //在线通知
58 59 http.HandleFunc("/eliminatestar/updatetaskandachieve", Updatetaskandachieve) //上报任务事件进度
... ... @@ -453,6 +454,27 @@ func Getcashrecord(w http.ResponseWriter, r *http.Request) {
453 454 HandlerGetcashrecord(w, s, Uuid)
454 455 }
455 456  
  457 +func Getcashwechat(w http.ResponseWriter, r *http.Request) {
  458 +
  459 + Uuid := 0
  460 + if len(r.Header) > 0 {
  461 + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid"))
  462 + }
  463 +
  464 + if Uuid == 0 {
  465 + SetHeader(w)
  466 + //logger.Error("Uuid is nil!")
  467 + return
  468 + }
  469 + result, _ := ioutil.ReadAll(r.Body)
  470 + r.Body.Close()
  471 +
  472 + s := string(result)
  473 + logger.Info("Getcashwechat , body:%v,uuid=%v", s, Uuid)
  474 +
  475 + HandlerGetcashwechat(w, s, Uuid)
  476 +}
  477 +
456 478 func Getcash(w http.ResponseWriter, r *http.Request) {
457 479  
458 480 Uuid := 0
... ...
src/HttpServer/logic/logic.go
... ... @@ -107,6 +107,158 @@ func HandlerWatchads(w http.ResponseWriter, data string, uuid int) {
107 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 +
  230 + //保存cdkey
  231 + var tmp CashCdKeyInfo
  232 + tmp.Cdkey = cdkey
  233 + tmp.Money = rdata.Money
  234 + tmp.Id = info.Cid
  235 + uinfo.Cdkeys = append(uinfo.Cdkeys, tmp)
  236 +
  237 + uinfo.GetCashCnt++
  238 + //如果是前六挡
  239 + if info.Cid <= 6 && rdata.Ctype == 1 {
  240 + uinfo.WithDraw.Cashdata[index].Isnew = 0
  241 + }
  242 + if rdata.Ctype == 2 {
  243 + uinfo.WithDraw.SpecialCashdata[index].Isnew = 0
  244 + }
  245 +
  246 + uinfo.RealGold += drawnum * 100
  247 + //uinfo.RealGold -= drawnum * 100
  248 +
  249 + resp.Data.Cdkey = cdkey
  250 + SaveUserInfo(uinfo, uniqueuuid)
  251 +
  252 + resp.Code = ERROR_OK
  253 + break
  254 + }
  255 +
  256 + //回包
  257 + respstr, _ := json.Marshal(&resp)
  258 + fmt.Fprint(w, string(respstr))
  259 +
  260 +}
  261 +
110 262 func HandlerGetcash(w http.ResponseWriter, data string, uuid int) {
111 263 SetHeader(w)
112 264 var resp GetcashResp
... ... @@ -956,6 +1108,7 @@ func HandlerQuerdrawinfo(w http.ResponseWriter, data string, uuid int) {
956 1108 //返回
957 1109 resp.Data.Cashdata = append(resp.Data.Cashdata, uinfo.WithDraw.Cashdata...)
958 1110 resp.Data.SpecialCashdata = append(resp.Data.SpecialCashdata, uinfo.WithDraw.SpecialCashdata...)
  1111 + resp.Data.Cdkeycashdata = append(resp.Data.Cdkeycashdata, uinfo.Cdkeys...)
959 1112  
960 1113 resp.Code = ERROR_OK
961 1114 break
... ...