Commit 5fcc46cd1a2e50191978bcc85917db82f536a4e8

Authored by 陆恒
1 parent 296664f2
Exists in master

提交

Showing 1 changed file with 107 additions and 1 deletions   Show diff stats
src/HttpServer/logic/logic.go
@@ -62,12 +62,118 @@ func HandlerSettlement(w http.ResponseWriter, data string, uuid int) { @@ -62,12 +62,118 @@ func HandlerSettlement(w http.ResponseWriter, data string, uuid int) {
62 62
63 uinfo, err := GetUserInfo(strconv.Itoa(uuid)) 63 uinfo, err := GetUserInfo(strconv.Itoa(uuid))
64 if err != nil || uinfo == nil { 64 if err != nil || uinfo == nil {
65 - logger.Error("HandlerTestaddCat getuserinfo failed=%v", err) 65 + logger.Error("HandlerSettlement getuserinfo failed=%v", err)
66 resp.Code = 1 66 resp.Code = 1
67 resp.Message = "get userinfo failed" 67 resp.Message = "get userinfo failed"
68 break 68 break
69 } 69 }
70 70
  71 + //先判断一下待开奖列表
  72 + iexis, err := redishandler.GetRedisClient().HExists(redis.CAIPIAOKAIJIANGWAIT_KEY, strconv.Itoa(rdata.Round))
  73 + if err == nil && iexis {
  74 + //开奖
  75 + idx := -1
  76 + list := GetWaitCaiCatList()
  77 + for k, val := range list {
  78 + if val.CurRound == rdata.Round {
  79 + idx = k
  80 + break
  81 + }
  82 + }
  83 +
  84 + if idx != -1 {
  85 + list[idx].RewardNum = rdata.RewardNum
  86 + for _, vval := range list[idx].List {
  87 + uinfo, err := GetUserInfo(strconv.Itoa(vval.UserId))
  88 + if err != nil || uinfo == nil {
  89 + continue
  90 + }
  91 + var tmp UserCaiPiaoHistory
  92 + tmp.RewardNum = rdata.RewardNum
  93 + tmp.CatId = 48
  94 + tmp.Round = rdata.Round
  95 + tmp.Cnum = vval.ChooseNum
  96 + uinfo.CaiPiaoInfo = append(uinfo.CaiPiaoInfo, tmp)
  97 +
  98 + if vval.ChooseNum == rdata.RewardNum {
  99 + list[idx].RewardUser = vval.UserId
  100 +
  101 + //给这个玩家发奖
  102 + cfg := jsonconf.GetRedCatConfig(48)
  103 + if cfg != nil {
  104 +
  105 + uinfo.AddRedPackect(cfg.Money, 100)
  106 + }
  107 +
  108 + }
  109 +
  110 + }
  111 +
  112 + //需要把这一条记录删除
  113 + redishandler.GetRedisClient().HDel(redis.CAIPIAOKAIJIANGWAIT_KEY, strconv.Itoa(rdata.Round))
  114 +
  115 + var tmp AlreadyDuboCatList
  116 + tmp.CurRound = rdata.Round
  117 + tmp.RewardNum = rdata.RewardNum
  118 + tmp.List = append(tmp.List, list[idx].List...)
  119 + tmp.RewardUser = list[idx].RewardUser
  120 + tmp.TimeStr = int(time.Now().Unix())
  121 + savestr, err := json.Marshal(&tmp)
  122 + if err == nil {
  123 + redishandler.GetRedisClient().HSet(redis.CAIPIAOKAIJIANGHISTORY_KEY, strconv.Itoa(tmp.CurRound), string(savestr))
  124 + }
  125 + }
  126 + } else {
  127 + //从当前未满彩池查看
  128 + curr := GetCurCaiCatList()
  129 + rewarduser := 0
  130 + if curr.CurRound == rdata.Round {
  131 + for _, vval := range curr.List {
  132 + uinfo, err := GetUserInfo(strconv.Itoa(vval.UserId))
  133 + if err != nil || uinfo == nil {
  134 + continue
  135 + }
  136 + var tmp UserCaiPiaoHistory
  137 + tmp.RewardNum = rdata.RewardNum
  138 + tmp.CatId = 48
  139 + tmp.Round = rdata.Round
  140 + tmp.Cnum = vval.ChooseNum
  141 + uinfo.CaiPiaoInfo = append(uinfo.CaiPiaoInfo, tmp)
  142 + if vval.ChooseNum == rdata.RewardNum {
  143 + rewarduser = vval.UserId
  144 +
  145 + //给这个玩家发奖
  146 + cfg := jsonconf.GetRedCatConfig(48)
  147 + if cfg != nil {
  148 +
  149 + uinfo.AddRedPackect(cfg.Money, 100)
  150 + }
  151 +
  152 + }
  153 +
  154 + }
  155 +
  156 + var tmp AlreadyDuboCatList
  157 + tmp.CurRound = rdata.Round
  158 + tmp.RewardNum = rdata.RewardNum
  159 + tmp.List = append(tmp.List, curr.List...)
  160 + tmp.RewardUser = rewarduser
  161 + tmp.TimeStr = int(time.Now().Unix())
  162 + savestr, err := json.Marshal(&tmp)
  163 + if err == nil {
  164 + redishandler.GetRedisClient().HSet(redis.CAIPIAOKAIJIANGHISTORY_KEY, strconv.Itoa(tmp.CurRound), string(savestr))
  165 + }
  166 +
  167 + NewCaiPiaoRound(0, 200, 200, curr.CurRound+1)
  168 +
  169 + } else {
  170 + logger.Error("HandlerSettlement paramfailed failed=%v", err)
  171 + resp.Code = 1
  172 + resp.Message = "参数不正确"
  173 + break
  174 + }
  175 + }
  176 +
71 SaveUserInfo(uinfo, strconv.Itoa(uuid)) 177 SaveUserInfo(uinfo, strconv.Itoa(uuid))
72 break 178 break
73 } 179 }