Commit 0b83ec05106f6670a186ab19c53b85a3ead1156b
1 parent
5744e41d
Exists in
master
第一波提交
Showing
3 changed files
with
134 additions
and
2 deletions
Show diff stats
src/HttpServer/logic/datadef.go
... | ... | @@ -50,6 +50,19 @@ type WithDrawDesc struct { |
50 | 50 | |
51 | 51 | type WithDrawDescs []WithDrawDesc |
52 | 52 | |
53 | +func (v WithDrawDescs) Len() int { | |
54 | + return len(v) | |
55 | +} | |
56 | + | |
57 | +func (v WithDrawDescs) Swap(i, j int) { | |
58 | + v[i], v[j] = v[j], v[i] | |
59 | +} | |
60 | + | |
61 | +func (v WithDrawDescs) Less(i, j int) bool { | |
62 | + | |
63 | + return v[i].Cid < v[j].Cid | |
64 | +} | |
65 | + | |
53 | 66 | type WithDrawInfo struct { |
54 | 67 | Cashdata WithDrawDescs `json:"cashdata"` |
55 | 68 | SpecialCashdata WithDrawDescs `json:"specialcashdata"` | ... | ... |
src/HttpServer/logic/function.go
... | ... | @@ -400,6 +400,125 @@ func GetCashFromSDK(uuid int, goldnum int, gameid, channel, openid, nickname, he |
400 | 400 | return newnum, nil |
401 | 401 | } |
402 | 402 | |
403 | +func (u *UserData) IsInWithList(num float32) (bool, int) { | |
404 | + for k, val := range u.WithDraw.Cashdata { | |
405 | + if val.Cnum == num { | |
406 | + return true, k | |
407 | + } | |
408 | + } | |
409 | + return false, -1 | |
410 | +} | |
411 | + | |
412 | +func (u *UserData) IsInSpeaialWithList(num float32) (bool, int) { | |
413 | + for k, val := range u.WithDraw.SpecialCashdata { | |
414 | + if val.Cnum == num { | |
415 | + return true, k | |
416 | + } | |
417 | + } | |
418 | + return false, -1 | |
419 | +} | |
420 | + | |
421 | +func (u *UserData) ReInitWithDraw(uniqueuid string) error { | |
422 | + //u.WithDraw.Cashdata = u.WithDraw.Cashdata[:0] | |
423 | + //重新读取配置 | |
424 | + for _, val := range jsonconf.GetJsonConf().WithDrawConfig { | |
425 | + | |
426 | + isin, idx := u.IsInWithList(val.Money) | |
427 | + if isin && idx >= 0 && idx < len(u.WithDraw.Cashdata) { | |
428 | + //已经有了的话更新一下配置 | |
429 | + u.WithDraw.Cashdata[idx].Day = val.Day | |
430 | + u.WithDraw.Cashdata[idx].Limitlv = val.Level | |
431 | + u.WithDraw.Cashdata[idx].Cnum = val.Money | |
432 | + u.WithDraw.Cashdata[idx].Cid = val.Id | |
433 | + } else { | |
434 | + //还没有 新加入 | |
435 | + var tmp WithDrawDesc | |
436 | + tmp.Cid = val.Id | |
437 | + tmp.Cnum = val.Money | |
438 | + if val.Isnew == 1 { | |
439 | + tmp.Isnew = 1 | |
440 | + } else { | |
441 | + tmp.Isnew = 2 | |
442 | + } | |
443 | + tmp.Limitlv = val.Level | |
444 | + if val.Id == 1 { | |
445 | + tmp.Preisfind = 1 | |
446 | + } else { | |
447 | + tmp.Preisfind = 0 | |
448 | + } | |
449 | + tmp.Day = val.Day | |
450 | + u.WithDraw.Cashdata = append(u.WithDraw.Cashdata, tmp) | |
451 | + } | |
452 | + | |
453 | + } | |
454 | + | |
455 | + //需要反过来判断一下 如果此时提现档位在表里面不存在 则删除 | |
456 | + for i := 0; i < len(u.WithDraw.Cashdata); { | |
457 | + exist := false | |
458 | + for _, val := range jsonconf.GetJsonConf().WithDrawConfig { | |
459 | + if val.Money == u.WithDraw.Cashdata[i].Cnum { | |
460 | + exist = true | |
461 | + } | |
462 | + } | |
463 | + | |
464 | + if !exist { | |
465 | + u.WithDraw.Cashdata = append(u.WithDraw.Cashdata[:i], u.WithDraw.Cashdata[i+1:]...) | |
466 | + } else { | |
467 | + i++ | |
468 | + } | |
469 | + } | |
470 | + | |
471 | + //需要统一处理一下前置条件 | |
472 | + for i := 0; i < len(u.WithDraw.Cashdata); i++ { | |
473 | + if i > 0 { | |
474 | + //需要判断下前面的前置条件 | |
475 | + if u.WithDraw.Cashdata[i-1].Preisfind == 1 { | |
476 | + //前面已完成,拿自己也变成完成状态 | |
477 | + u.WithDraw.Cashdata[i].Preisfind = 1 | |
478 | + } | |
479 | + } | |
480 | + } | |
481 | + | |
482 | + for _, val := range jsonconf.GetJsonConf().ActiveWithdrawConfig { | |
483 | + | |
484 | + isin, idx := u.IsInSpeaialWithList(val.Money) | |
485 | + if isin && idx >= 0 && idx < len(u.WithDraw.SpecialCashdata) { | |
486 | + //已经有了的话更新一下配置 | |
487 | + u.WithDraw.SpecialCashdata[idx].Day = val.Day | |
488 | + u.WithDraw.SpecialCashdata[idx].Limitlv = val.Level | |
489 | + u.WithDraw.SpecialCashdata[idx].Cnum = val.Money | |
490 | + } else { | |
491 | + //还没有 新加入 | |
492 | + var tmp WithDrawDesc | |
493 | + tmp.Cid = val.Id | |
494 | + tmp.Cnum = val.Money | |
495 | + if val.Isnew == 1 { | |
496 | + tmp.Isnew = 1 | |
497 | + } else { | |
498 | + tmp.Isnew = 2 | |
499 | + } | |
500 | + tmp.Limitlv = val.Level | |
501 | + //没有前置条件 | |
502 | + tmp.Preisfind = 1 | |
503 | + | |
504 | + tmp.Day = val.Day | |
505 | + u.WithDraw.SpecialCashdata = append(u.WithDraw.SpecialCashdata, tmp) | |
506 | + } | |
507 | + | |
508 | + } | |
509 | + | |
510 | + //做一个排序 | |
511 | + sort.Sort(u.WithDraw.Cashdata) | |
512 | + sort.Sort(u.WithDraw.SpecialCashdata) | |
513 | + | |
514 | + err := SaveUserInfo(u, uniqueuid) | |
515 | + if err != nil { | |
516 | + logger.Error("ReInitWithDraw failed") | |
517 | + } | |
518 | + | |
519 | + return err | |
520 | +} | |
521 | + | |
403 | 522 | func GetCashList(uuid int, gameid string, channel string, start int, number int) (*[]WithDrawRecord, error) { |
404 | 523 | SERVERKEY := XIAOXINGXING_SERVERKEYTEST |
405 | 524 | if gameid == "1015" { | ... | ... |
src/HttpServer/logic/logic.go
... | ... | @@ -139,9 +139,9 @@ func GetUserData(uuid int, uniqueuid string, req *UserLoginReq, resp *UserLoginR |
139 | 139 | data.HandlePassDay(uuid, req.Channel) |
140 | 140 | |
141 | 141 | //需要处理下提现表信息 等待提现表 |
142 | - //err = data.ReInitWithDraw(uniqueuid) | |
142 | + err = data.ReInitWithDraw(uniqueuid) | |
143 | 143 | if err != nil { |
144 | - logger.Error("GetUserData err=%v", err) | |
144 | + logger.Error("GetUserData ReInitWithDraw err=%v", err) | |
145 | 145 | } |
146 | 146 | |
147 | 147 | //此处处理一下从sdk拉取钱包金币数量 | ... | ... |