diff --git a/src/HttpServer/logic/datadef.go b/src/HttpServer/logic/datadef.go index b242450..80e0db8 100644 --- a/src/HttpServer/logic/datadef.go +++ b/src/HttpServer/logic/datadef.go @@ -325,9 +325,24 @@ type WithDrawRecord struct { Typ int `json:"typ"` } +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 []WithDrawDesc `json:"cashdata"` - SpecialCashdata []WithDrawDesc `json:"specialcashdata"` + Cashdata WithDrawDescs `json:"cashdata"` + SpecialCashdata WithDrawDescs `json:"specialcashdata"` } type WithDrawDesc struct { diff --git a/src/HttpServer/logic/function.go b/src/HttpServer/logic/function.go index f4fdb53..fa865d9 100644 --- a/src/HttpServer/logic/function.go +++ b/src/HttpServer/logic/function.go @@ -469,6 +469,90 @@ func (uinfo *UserData) RewardUser(rtype int, num int, gameid string, channel str return 0, 0, 0, 0, 0, 0, 0 } +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.Id) + 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 + } 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); 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.Id) + 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 InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int, uniqueuid string) error { var initdata UserData @@ -543,6 +627,24 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int, uniqueuid s return err } +func (u *UserData) IsInWithList(id int) (bool, int) { + for k, val := range u.WithDraw.Cashdata { + if val.Cid == id { + return true, k + } + } + return false, -1 +} + +func (u *UserData) IsInSpeaialWithList(id int) (bool, int) { + for k, val := range u.WithDraw.SpecialCashdata { + if val.Cid == id { + return true, k + } + } + return false, -1 +} + func (t *TaskList) IsInTaskList(id int) bool { for _, val := range t.Taskdata { if val.Taskid == id { @@ -752,6 +854,12 @@ func GetUserData(uuid int, uniqueuid string, req *UserLoginReq, resp *UserLoginR //此处要处理一下跨天逻辑 data.HandlePassDay(uuid, req.Channel) + //需要处理下提现表信息 + err = data.ReInitWithDraw(uniqueuid) + if err != nil { + logger.Error("GetUserData err=%v", err) + } + //此处处理一下从sdk拉取钱包金币数量 gold, err := GetCoinFromSdk(uuid, req.Gameid, req.Channel) if err == nil { -- libgit2 0.21.0