Commit 3728ca706d2ca644906bb2f7fa8ed4f34b1d9b93

Authored by 陆恒
1 parent 7331684a
Exists in master

提交

src/HttpServer/logic/datadef.go
@@ -148,6 +148,36 @@ type GetcashResp struct { @@ -148,6 +148,36 @@ type GetcashResp struct {
148 Data GetcashData `json:"data"` 148 Data GetcashData `json:"data"`
149 } 149 }
150 150
  151 +type GetcashwechatData struct {
  152 + Cdkey string `json:"cdkey"`
  153 +}
  154 +type GetcashwechatResp struct {
  155 + Code int `json:"code"`
  156 + Message string `json:"message"`
  157 + Data GetcashwechatData `json:"data"`
  158 +}
  159 +
  160 +type GetcashwechatReq struct {
  161 + Gameid string `json:"gameid"`
  162 + Channel string `json:"channel"`
  163 + Money float32 `json:"money"`
  164 + Openid string `json:"openid"`
  165 + Nickname string `json:"nickname"`
  166 + Headurl string `json:"headurl"`
  167 + Ver string `json:"ver"`
  168 + Ctype int `json:"ctype"`
  169 +}
  170 +
  171 +type GetCashWechatData struct {
  172 + Cdkey string `json:"cdkey"`
  173 +}
  174 +
  175 +type GetCashWechatResp struct {
  176 + Code string `json:"code"`
  177 + Data GetCashWechatData `json:"data"`
  178 + Msg string `json:"msg"`
  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 {
@@ -463,6 +500,7 @@ type UserData struct { @@ -463,6 +500,7 @@ type UserData struct {
463 HeadUrl string //头像 500 HeadUrl string //头像
464 SignShow int //是否弹出签到 501 SignShow int //是否弹出签到
465 WithDraw WithDrawInfo //提现记录信息 502 WithDraw WithDrawInfo //提现记录信息
  503 + Cdkeys []CashCdKeyInfo //记录提现的cdkeys
466 //SpecialWithDraw WithDrawInfo //活跃提现记录信息 504 //SpecialWithDraw WithDrawInfo //活跃提现记录信息
467 Task TaskInfo //玩家任务完成相关信息 505 Task TaskInfo //玩家任务完成相关信息
468 Achieve AchieveMentInfo //玩家成就完成相关数据 506 Achieve AchieveMentInfo //玩家成就完成相关数据
src/HttpServer/logic/function.go
@@ -1322,6 +1322,121 @@ func AddCoinToSdk(uuid int, goldnum int, gameid string, channel string, atype in @@ -1322,6 +1322,121 @@ func AddCoinToSdk(uuid int, goldnum int, gameid string, channel string, atype in
1322 return resp.Data.Mycoin, realaddgoldnum, nil 1322 return resp.Data.Mycoin, realaddgoldnum, nil
1323 } 1323 }
1324 1324
  1325 +
  1326 +func GetCashWechatFromSDK(uuid int, goldnum int, gameid, channel, openid, nickname, headurl, ver string, checkcoin int) (string, error) {
  1327 +
  1328 + SERVERKEY := XIAOXINGXING_SERVERKEYTEST
  1329 + if gameid == "1015" {
  1330 + SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1015
  1331 + }
  1332 +
  1333 + if gameid == "1016" {
  1334 + SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1016
  1335 + }
  1336 + if gameid == "1019" {
  1337 + SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1019
  1338 + }
  1339 + if gameid == "1020" {
  1340 + SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1020
  1341 + }
  1342 + if gameid == "1021" {
  1343 + SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1021
  1344 + }
  1345 + if gameid == "1023" {
  1346 + SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1023
  1347 + }
  1348 + if goldnum == 0 || uuid == 0 || gameid == "" || channel == "" || ver == "" {
  1349 + logger.Error("GetCashFromSDK param empty")
  1350 + return "error", errors.New("param empty")
  1351 + }
  1352 +
  1353 + if openid == "" {
  1354 + openid = "test"
  1355 + }
  1356 + var paramlist []string
  1357 + var params TixianDesc
  1358 + params.Sign_type = "md5"
  1359 + params.Gameid = gameid
  1360 + params.Channel = channel
  1361 + params.Uid = uuid
  1362 + params.Time_stamp = strconv.Itoa(int(time.Now().Unix()))
  1363 + params.Headurl = headurl
  1364 + params.Money = goldnum
  1365 + params.Openid = openid
  1366 + params.Nickname = nickname
  1367 + params.Typ = 11
  1368 + params.Ver = ver
  1369 + params.Editcoin = 1
  1370 + params.Checkcoin = checkcoin
  1371 + signtypestr := "sign_type=" + params.Sign_type
  1372 + timestampstr := "time_stamp=" + strconv.Itoa(int(time.Now().Unix()))
  1373 + paramgameid := "gameid=" + gameid
  1374 + pchannel := "channel=" + channel
  1375 + puid := "uid=" + strconv.Itoa(uuid)
  1376 + phead := "headurl=" + headurl
  1377 + pnickname := "nickname=" + nickname
  1378 + popenid := "openid=" + openid
  1379 + pmoney := "money=" + strconv.Itoa(goldnum)
  1380 + ptype := "typ=" + "11" //微信
  1381 + ped := "editcoin=1"
  1382 + pcheco := "checkcoin=" + strconv.Itoa(checkcoin)
  1383 + //pver := "ver=" + params.Ver
  1384 + paramlist = append(paramlist, signtypestr)
  1385 + paramlist = append(paramlist, timestampstr)
  1386 + paramlist = append(paramlist, paramgameid)
  1387 + paramlist = append(paramlist, pchannel)
  1388 + paramlist = append(paramlist, puid)
  1389 + if headurl != "" {
  1390 + paramlist = append(paramlist, phead)
  1391 + }
  1392 + if nickname != "" {
  1393 + paramlist = append(paramlist, pnickname)
  1394 + }
  1395 + paramlist = append(paramlist, popenid)
  1396 + paramlist = append(paramlist, pmoney)
  1397 + paramlist = append(paramlist, ptype)
  1398 + paramlist = append(paramlist, ped)
  1399 + paramlist = append(paramlist, pcheco)
  1400 + //paramlist = append(paramlist, pver)
  1401 +
  1402 + sumparam := GettotalParam(paramlist)
  1403 + //加serverkey
  1404 + signsum := sumparam + SERVERKEY
  1405 +
  1406 + //进行hash
  1407 + sign := GetHashValue(signsum)
  1408 + params.Sign = sign
  1409 +
  1410 + bys, err := json.Marshal(&params)
  1411 + if err != nil {
  1412 + logger.Error("GetCashWechatFromSDK failed=%v", err)
  1413 + return "error", err
  1414 + }
  1415 + res, err := DoHttpPost(bys, "api/server/tixiancdkey")
  1416 + logger.Info("GetCashWechatFromSDK sumparam is:%v,sign is:%v", signsum, sign)
  1417 + logger.Info("GetCashWechatFromSDK sumparam param=%v", string(bys))
  1418 + if err != nil {
  1419 + logger.Error("GetCashWechatFromSDK failed=%v", err)
  1420 + return "error", err
  1421 + }
  1422 +
  1423 + logger.Info("GetCashWechatFromSDK res=%v", res)
  1424 +
  1425 + var resp GetCashWechatResp
  1426 + err = json.Unmarshal([]byte(res), &resp)
  1427 + if err != nil {
  1428 + logger.Error("GetCashWechatFromSDK failed=%v", err)
  1429 + return "error", err
  1430 + }
  1431 +
  1432 + if resp.Code != "0" {
  1433 + logger.Error("GetCashWechatFromSDK failed=%v", resp.Msg)
  1434 + return "error", errors.New(resp.Msg)
  1435 + }
  1436 +
  1437 + return resp.Data.Cdkey, nil
  1438 +}
  1439 +
1325 func GetCashFromSDK(uuid int, goldnum int, gameid, channel, openid, nickname, headurl, ver string, checkcoin int) (int, error) { 1440 func GetCashFromSDK(uuid int, goldnum int, gameid, channel, openid, nickname, headurl, ver string, checkcoin int) (int, error) {
1326 1441
1327 SERVERKEY := XIAOXINGXING_SERVERKEYTEST 1442 SERVERKEY := XIAOXINGXING_SERVERKEYTEST
src/HttpServer/logic/httpserver.go
@@ -62,7 +62,8 @@ func startServerHttpServe() { @@ -62,7 +62,8 @@ func startServerHttpServe() {
62 http.HandleFunc("/sixstar/getguangold", Getguangold) //获取金币到存钱罐 62 http.HandleFunc("/sixstar/getguangold", Getguangold) //获取金币到存钱罐
63 http.HandleFunc("/sixstar/drawguangold", Drawguangold) //提取存钱罐的金币到个人钱包 63 http.HandleFunc("/sixstar/drawguangold", Drawguangold) //提取存钱罐的金币到个人钱包
64 http.HandleFunc("/sixstar/querdrawinfo", Querdrawinfo) //获取提现档位信息接口 64 http.HandleFunc("/sixstar/querdrawinfo", Querdrawinfo) //获取提现档位信息接口
65 - http.HandleFunc("/sixstar/getcash", Getcash) //提现 65 + http.HandleFunc("/sixstar/getcash", Getcash)
  66 + http.HandleFunc("/sixstar/getcashwechat", Getcashwechat) //提现//提现
66 http.HandleFunc("/sixstar/getcashrecord", Getcashrecord) //提现记录列表 67 http.HandleFunc("/sixstar/getcashrecord", Getcashrecord) //提现记录列表
67 http.HandleFunc("/sixstar/onlinentf", Onlinentf) //在线通知 68 http.HandleFunc("/sixstar/onlinentf", Onlinentf) //在线通知
68 http.HandleFunc("/sixstar/updatetaskandachieve", Updatetaskandachieve) //上报任务事件进度 69 http.HandleFunc("/sixstar/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,161 @@ func HandlerWatchads(w http.ResponseWriter, data string, uuid int) { @@ -107,6 +107,161 @@ 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 +
  264 +
110 func HandlerGetcash(w http.ResponseWriter, data string, uuid int) { 265 func HandlerGetcash(w http.ResponseWriter, data string, uuid int) {
111 SetHeader(w) 266 SetHeader(w)
112 var resp GetcashResp 267 var resp GetcashResp
@@ -1121,6 +1276,7 @@ func HandlerQuerdrawinfo(w http.ResponseWriter, data string, uuid int) { @@ -1121,6 +1276,7 @@ func HandlerQuerdrawinfo(w http.ResponseWriter, data string, uuid int) {
1121 //返回 1276 //返回
1122 resp.Data.Cashdata = append(resp.Data.Cashdata, uinfo.WithDraw.Cashdata...) 1277 resp.Data.Cashdata = append(resp.Data.Cashdata, uinfo.WithDraw.Cashdata...)
1123 resp.Data.SpecialCashdata = append(resp.Data.SpecialCashdata, uinfo.WithDraw.SpecialCashdata...) 1278 resp.Data.SpecialCashdata = append(resp.Data.SpecialCashdata, uinfo.WithDraw.SpecialCashdata...)
  1279 + resp.Data.Cdkeycashdata = append(resp.Data.Cdkeycashdata, uinfo.Cdkeys...)
1124 1280
1125 resp.Code = ERROR_OK 1281 resp.Code = ERROR_OK
1126 break 1282 break