From 6a23c091459824607a15145bbfcd3f764b270551 Mon Sep 17 00:00:00 2001 From: 陆恒 Date: Wed, 13 May 2020 19:10:38 +0800 Subject: [PATCH] 修改提现相关的内容 --- src/HttpServer/logic/errordef.go | 3 +++ src/HttpServer/logic/function.go | 10 ++++++++++ src/HttpServer/logic/logic.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 0 deletions(-) diff --git a/src/HttpServer/logic/errordef.go b/src/HttpServer/logic/errordef.go index ab1ba60..344153d 100644 --- a/src/HttpServer/logic/errordef.go +++ b/src/HttpServer/logic/errordef.go @@ -13,4 +13,7 @@ const ( ERROR_GETCASH_FAILED =8 //从后台提现失败了 ERROR_GETCASH_GOLDNOTENOUGH_FAILED =9 //提现金币不足 ERROR_ADDWITHDRAW_LISTFAILED =10 //添加提现记录失败 + ERROR_WITHDRAWLVLIMIT =11 //提现等级不够 + ERROR_WITHDRAWONLYONE =12 //新人专享只能提取一次 + ERROR_PRENOTFINISH =13 //前置档位未提现 ) \ No newline at end of file diff --git a/src/HttpServer/logic/function.go b/src/HttpServer/logic/function.go index 8bc64c8..88cd651 100644 --- a/src/HttpServer/logic/function.go +++ b/src/HttpServer/logic/function.go @@ -190,6 +190,16 @@ func GetWithDrawList(uuid int) (*WithDrawList,error) { return list,nil } +func (uinfo *UserData)GetWithDrawData(money float32) (int,*WithDrawDesc){ + //处理提现状态 + for k,val := range uinfo.WithDraw.Cashdata { + if val.Cnum == money{ + return k,&val + } + } + return -1,nil +} + //添加提现记录 func AddWithDrawList(uuid int,data *WithDrawRecord) error { exist,err := redishandler.GetRedisClient().HExists(redis.USER_WITHDRAW_RECORDLIST,strconv.Itoa(uuid)) diff --git a/src/HttpServer/logic/logic.go b/src/HttpServer/logic/logic.go index 6370cdf..039dbb0 100644 --- a/src/HttpServer/logic/logic.go +++ b/src/HttpServer/logic/logic.go @@ -130,7 +130,43 @@ func HandlerGetcash(w http.ResponseWriter, data string, uuid int) { break } + index,info := uinfo.GetWithDrawData(rdata.Money) + if index == -1 || info == nil { + logger.Error("AddWithDrawList failed err=%v", err) + resp.Message = "网络错误" + resp.Code = ERROR_SRV_ERROR + break + } + + if uinfo.Lv < info.Limitlv { + logger.Error("AddWithDrawList failed err=%v", err) + resp.Message = "提现等级不够" + resp.Code = ERROR_WITHDRAWLVLIMIT + break + } + + if info.Isnew == 0 { + logger.Error("AddWithDrawList failed err=%v", err) + resp.Message = "新人专享只能提取一次" + resp.Code = ERROR_WITHDRAWONLYONE + break + } + if info.Preisfind == 0 { + logger.Error("AddWithDrawList failed err=%v", err) + resp.Message = "新人专享只能提取一次" + resp.Code = ERROR_PRENOTFINISH + break + } + + //判断一下前置条件的下一档 + if index == len(uinfo.WithDraw.Cashdata) - 1 { + //最后一档了不用处理 + }else { + if index < len(uinfo.WithDraw.Cashdata) - 1{ + uinfo.WithDraw.Cashdata[index+1].Preisfind = 1 + } + } //需要保存一下提现记录 data := new(WithDrawRecord) @@ -144,6 +180,12 @@ func HandlerGetcash(w http.ResponseWriter, data string, uuid int) { break } + + + if info.Isnew == 1 { + uinfo.WithDraw.Cashdata[index].Isnew = 0 + } + uinfo.RealGold -= drawnum * 100 resp.Data.Walletgold = uinfo.RealGold -- libgit2 0.21.0