From 0b83ec05106f6670a186ab19c53b85a3ead1156b Mon Sep 17 00:00:00 2001 From: 陆恒 Date: Thu, 9 Jul 2020 16:21:03 +0800 Subject: [PATCH] 第一波提交 --- src/HttpServer/logic/datadef.go | 13 +++++++++++++ src/HttpServer/logic/function.go | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/HttpServer/logic/logic.go | 4 ++-- 3 files changed, 134 insertions(+), 2 deletions(-) diff --git a/src/HttpServer/logic/datadef.go b/src/HttpServer/logic/datadef.go index 0504a46..9d6afc3 100644 --- a/src/HttpServer/logic/datadef.go +++ b/src/HttpServer/logic/datadef.go @@ -50,6 +50,19 @@ type WithDrawDesc struct { type WithDrawDescs []WithDrawDesc +func (v WithDrawDescs) Len() int { + return len(v) +} + +func (v WithDrawDescs) Swap(i, j int) { + v[i], v[j] = v[j], v[i] +} + +func (v WithDrawDescs) Less(i, j int) bool { + + return v[i].Cid < v[j].Cid +} + type WithDrawInfo struct { Cashdata WithDrawDescs `json:"cashdata"` SpecialCashdata WithDrawDescs `json:"specialcashdata"` diff --git a/src/HttpServer/logic/function.go b/src/HttpServer/logic/function.go index 97884ae..875a8a2 100644 --- a/src/HttpServer/logic/function.go +++ b/src/HttpServer/logic/function.go @@ -400,6 +400,125 @@ func GetCashFromSDK(uuid int, goldnum int, gameid, channel, openid, nickname, he return newnum, nil } +func (u *UserData) IsInWithList(num float32) (bool, int) { + for k, val := range u.WithDraw.Cashdata { + if val.Cnum == num { + return true, k + } + } + return false, -1 +} + +func (u *UserData) IsInSpeaialWithList(num float32) (bool, int) { + for k, val := range u.WithDraw.SpecialCashdata { + if val.Cnum == num { + return true, k + } + } + return false, -1 +} + +func (u *UserData) ReInitWithDraw(uniqueuid string) error { + //u.WithDraw.Cashdata = u.WithDraw.Cashdata[:0] + //重新读取配置 + for _, val := range jsonconf.GetJsonConf().WithDrawConfig { + + isin, idx := u.IsInWithList(val.Money) + if isin && idx >= 0 && idx < len(u.WithDraw.Cashdata) { + //已经有了的话更新一下配置 + u.WithDraw.Cashdata[idx].Day = val.Day + u.WithDraw.Cashdata[idx].Limitlv = val.Level + u.WithDraw.Cashdata[idx].Cnum = val.Money + u.WithDraw.Cashdata[idx].Cid = val.Id + } else { + //还没有 新加入 + var tmp WithDrawDesc + tmp.Cid = val.Id + tmp.Cnum = val.Money + if val.Isnew == 1 { + tmp.Isnew = 1 + } else { + tmp.Isnew = 2 + } + tmp.Limitlv = val.Level + if val.Id == 1 { + tmp.Preisfind = 1 + } else { + tmp.Preisfind = 0 + } + tmp.Day = val.Day + u.WithDraw.Cashdata = append(u.WithDraw.Cashdata, tmp) + } + + } + + //需要反过来判断一下 如果此时提现档位在表里面不存在 则删除 + for i := 0; i < len(u.WithDraw.Cashdata); { + exist := false + for _, val := range jsonconf.GetJsonConf().WithDrawConfig { + if val.Money == u.WithDraw.Cashdata[i].Cnum { + exist = true + } + } + + if !exist { + u.WithDraw.Cashdata = append(u.WithDraw.Cashdata[:i], u.WithDraw.Cashdata[i+1:]...) + } else { + i++ + } + } + + //需要统一处理一下前置条件 + for i := 0; i < len(u.WithDraw.Cashdata); i++ { + if i > 0 { + //需要判断下前面的前置条件 + if u.WithDraw.Cashdata[i-1].Preisfind == 1 { + //前面已完成,拿自己也变成完成状态 + u.WithDraw.Cashdata[i].Preisfind = 1 + } + } + } + + for _, val := range jsonconf.GetJsonConf().ActiveWithdrawConfig { + + isin, idx := u.IsInSpeaialWithList(val.Money) + if isin && idx >= 0 && idx < len(u.WithDraw.SpecialCashdata) { + //已经有了的话更新一下配置 + u.WithDraw.SpecialCashdata[idx].Day = val.Day + u.WithDraw.SpecialCashdata[idx].Limitlv = val.Level + u.WithDraw.SpecialCashdata[idx].Cnum = val.Money + } else { + //还没有 新加入 + var tmp WithDrawDesc + tmp.Cid = val.Id + tmp.Cnum = val.Money + if val.Isnew == 1 { + tmp.Isnew = 1 + } else { + tmp.Isnew = 2 + } + tmp.Limitlv = val.Level + //没有前置条件 + tmp.Preisfind = 1 + + tmp.Day = val.Day + u.WithDraw.SpecialCashdata = append(u.WithDraw.SpecialCashdata, tmp) + } + + } + + //做一个排序 + sort.Sort(u.WithDraw.Cashdata) + sort.Sort(u.WithDraw.SpecialCashdata) + + err := SaveUserInfo(u, uniqueuid) + if err != nil { + logger.Error("ReInitWithDraw failed") + } + + return err +} + func GetCashList(uuid int, gameid string, channel string, start int, number int) (*[]WithDrawRecord, error) { SERVERKEY := XIAOXINGXING_SERVERKEYTEST if gameid == "1015" { diff --git a/src/HttpServer/logic/logic.go b/src/HttpServer/logic/logic.go index e450266..2acd41f 100644 --- a/src/HttpServer/logic/logic.go +++ b/src/HttpServer/logic/logic.go @@ -139,9 +139,9 @@ func GetUserData(uuid int, uniqueuid string, req *UserLoginReq, resp *UserLoginR data.HandlePassDay(uuid, req.Channel) //需要处理下提现表信息 等待提现表 - //err = data.ReInitWithDraw(uniqueuid) + err = data.ReInitWithDraw(uniqueuid) if err != nil { - logger.Error("GetUserData err=%v", err) + logger.Error("GetUserData ReInitWithDraw err=%v", err) } //此处处理一下从sdk拉取钱包金币数量 -- libgit2 0.21.0