Commit d2f067d8495e029066c87f3efb0db5207d8a979d
1 parent
6b096748
Exists in
ver2.3.0
and in
1 other branch
增加兼容老表
Showing
2 changed files
with
125 additions
and
2 deletions
Show diff stats
src/HttpServer/logic/datadef.go
... | ... | @@ -325,9 +325,24 @@ type WithDrawRecord struct { |
325 | 325 | Typ int `json:"typ"` |
326 | 326 | } |
327 | 327 | |
328 | +type WithDrawDescs []WithDrawDesc | |
329 | + | |
330 | +func (v WithDrawDescs) Len() int { | |
331 | + return len(v) | |
332 | +} | |
333 | + | |
334 | +func (v WithDrawDescs) Swap(i, j int) { | |
335 | + v[i], v[j] = v[j], v[i] | |
336 | +} | |
337 | + | |
338 | +func (v WithDrawDescs) Less(i, j int) bool { | |
339 | + | |
340 | + return v[i].Cid < v[j].Cid | |
341 | +} | |
342 | + | |
328 | 343 | type WithDrawInfo struct { |
329 | - Cashdata []WithDrawDesc `json:"cashdata"` | |
330 | - SpecialCashdata []WithDrawDesc `json:"specialcashdata"` | |
344 | + Cashdata WithDrawDescs `json:"cashdata"` | |
345 | + SpecialCashdata WithDrawDescs `json:"specialcashdata"` | |
331 | 346 | } |
332 | 347 | |
333 | 348 | type WithDrawDesc struct { | ... | ... |
src/HttpServer/logic/function.go
... | ... | @@ -469,6 +469,90 @@ func (uinfo *UserData) RewardUser(rtype int, num int, gameid string, channel str |
469 | 469 | return 0, 0, 0, 0, 0, 0, 0 |
470 | 470 | } |
471 | 471 | |
472 | +func (u *UserData) ReInitWithDraw(uniqueuid string) error { | |
473 | + //u.WithDraw.Cashdata = u.WithDraw.Cashdata[:0] | |
474 | + //重新读取配置 | |
475 | + for _, val := range jsonconf.GetJsonConf().WithDrawConfig { | |
476 | + | |
477 | + isin, idx := u.IsInWithList(val.Id) | |
478 | + if isin && idx > 0 && idx < len(u.WithDraw.Cashdata) { | |
479 | + //已经有了的话更新一下配置 | |
480 | + u.WithDraw.Cashdata[idx].Day = val.Day | |
481 | + u.WithDraw.Cashdata[idx].Limitlv = val.Level | |
482 | + u.WithDraw.Cashdata[idx].Cnum = val.Money | |
483 | + } else { | |
484 | + //还没有 新加入 | |
485 | + var tmp WithDrawDesc | |
486 | + tmp.Cid = val.Id | |
487 | + tmp.Cnum = val.Money | |
488 | + if val.Isnew == 1 { | |
489 | + tmp.Isnew = 1 | |
490 | + } else { | |
491 | + tmp.Isnew = 2 | |
492 | + } | |
493 | + tmp.Limitlv = val.Level | |
494 | + if val.Id == 1 { | |
495 | + tmp.Preisfind = 1 | |
496 | + } else { | |
497 | + tmp.Preisfind = 0 | |
498 | + } | |
499 | + tmp.Day = val.Day | |
500 | + u.WithDraw.Cashdata = append(u.WithDraw.Cashdata, tmp) | |
501 | + } | |
502 | + | |
503 | + } | |
504 | + | |
505 | + //需要统一处理一下前置条件 | |
506 | + for i := 0; i < len(u.WithDraw.Cashdata); i++ { | |
507 | + if i > 0 { | |
508 | + //需要判断下前面的前置条件 | |
509 | + if u.WithDraw.Cashdata[i-1].Preisfind == 1 { | |
510 | + //前面已完成,拿自己也变成完成状态 | |
511 | + u.WithDraw.Cashdata[i].Preisfind = 1 | |
512 | + } | |
513 | + } | |
514 | + } | |
515 | + | |
516 | + for _, val := range jsonconf.GetJsonConf().ActiveWithdrawConfig { | |
517 | + | |
518 | + isin, idx := u.IsInSpeaialWithList(val.Id) | |
519 | + if isin && idx > 0 && idx < len(u.WithDraw.SpecialCashdata) { | |
520 | + //已经有了的话更新一下配置 | |
521 | + u.WithDraw.SpecialCashdata[idx].Day = val.Day | |
522 | + u.WithDraw.SpecialCashdata[idx].Limitlv = val.Level | |
523 | + u.WithDraw.SpecialCashdata[idx].Cnum = val.Money | |
524 | + } else { | |
525 | + //还没有 新加入 | |
526 | + var tmp WithDrawDesc | |
527 | + tmp.Cid = val.Id | |
528 | + tmp.Cnum = val.Money | |
529 | + if val.Isnew == 1 { | |
530 | + tmp.Isnew = 1 | |
531 | + } else { | |
532 | + tmp.Isnew = 2 | |
533 | + } | |
534 | + tmp.Limitlv = val.Level | |
535 | + //没有前置条件 | |
536 | + tmp.Preisfind = 1 | |
537 | + | |
538 | + tmp.Day = val.Day | |
539 | + u.WithDraw.SpecialCashdata = append(u.WithDraw.SpecialCashdata, tmp) | |
540 | + } | |
541 | + | |
542 | + } | |
543 | + | |
544 | + //做一个排序 | |
545 | + sort.Sort(u.WithDraw.Cashdata) | |
546 | + sort.Sort(u.WithDraw.SpecialCashdata) | |
547 | + | |
548 | + err := SaveUserInfo(u, uniqueuid) | |
549 | + if err != nil { | |
550 | + logger.Error("ReInitWithDraw failed") | |
551 | + } | |
552 | + | |
553 | + return err | |
554 | +} | |
555 | + | |
472 | 556 | func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int, uniqueuid string) error { |
473 | 557 | |
474 | 558 | var initdata UserData |
... | ... | @@ -543,6 +627,24 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int, uniqueuid s |
543 | 627 | return err |
544 | 628 | } |
545 | 629 | |
630 | +func (u *UserData) IsInWithList(id int) (bool, int) { | |
631 | + for k, val := range u.WithDraw.Cashdata { | |
632 | + if val.Cid == id { | |
633 | + return true, k | |
634 | + } | |
635 | + } | |
636 | + return false, -1 | |
637 | +} | |
638 | + | |
639 | +func (u *UserData) IsInSpeaialWithList(id int) (bool, int) { | |
640 | + for k, val := range u.WithDraw.SpecialCashdata { | |
641 | + if val.Cid == id { | |
642 | + return true, k | |
643 | + } | |
644 | + } | |
645 | + return false, -1 | |
646 | +} | |
647 | + | |
546 | 648 | func (t *TaskList) IsInTaskList(id int) bool { |
547 | 649 | for _, val := range t.Taskdata { |
548 | 650 | if val.Taskid == id { |
... | ... | @@ -752,6 +854,12 @@ func GetUserData(uuid int, uniqueuid string, req *UserLoginReq, resp *UserLoginR |
752 | 854 | //此处要处理一下跨天逻辑 |
753 | 855 | data.HandlePassDay(uuid, req.Channel) |
754 | 856 | |
857 | + //需要处理下提现表信息 | |
858 | + err = data.ReInitWithDraw(uniqueuid) | |
859 | + if err != nil { | |
860 | + logger.Error("GetUserData err=%v", err) | |
861 | + } | |
862 | + | |
755 | 863 | //此处处理一下从sdk拉取钱包金币数量 |
756 | 864 | gold, err := GetCoinFromSdk(uuid, req.Gameid, req.Channel) |
757 | 865 | if err == nil { | ... | ... |