Commit 87f7705683acf0c79a282512aa2b538abd22f1e5
1 parent
eef4f826
Exists in
master
提交新增加的一系列接口
Showing
10 changed files
with
1382 additions
and
108 deletions
Show diff stats
src/HttpServer/conf/conf.go
| @@ -14,10 +14,16 @@ type RedisConf struct { | @@ -14,10 +14,16 @@ type RedisConf struct { | ||
| 14 | Password string `xml:",attr"` | 14 | Password string `xml:",attr"` |
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | +type ConiSrvConf struct { | ||
| 18 | + Host string `xml:",attr"` | ||
| 19 | + Key string `xml:",attr"` | ||
| 20 | +} | ||
| 21 | + | ||
| 17 | type TexasConf struct { | 22 | type TexasConf struct { |
| 18 | GameDB MysqlConf `xml:"GameDB"` | 23 | GameDB MysqlConf `xml:"GameDB"` |
| 19 | ServerHttpAddr ServerHttpAddrConf `xml:"ServerHttpAddr"` | 24 | ServerHttpAddr ServerHttpAddrConf `xml:"ServerHttpAddr"` |
| 20 | Redis RedisConf `xml:"Redis"` | 25 | Redis RedisConf `xml:"Redis"` |
| 26 | + CoinSrv ConiSrvConf `xml:"CoinSrv"` | ||
| 21 | } | 27 | } |
| 22 | 28 | ||
| 23 | var ( | 29 | var ( |
| @@ -70,3 +76,7 @@ type ServerHttpAddrConf struct { | @@ -70,3 +76,7 @@ type ServerHttpAddrConf struct { | ||
| 70 | Host string `xml:",attr"` | 76 | Host string `xml:",attr"` |
| 71 | IsTest string `xml:",attr"` | 77 | IsTest string `xml:",attr"` |
| 72 | } | 78 | } |
| 79 | + | ||
| 80 | +func GetCoinConf() ConiSrvConf { | ||
| 81 | + return config.CoinSrv | ||
| 82 | +} |
| @@ -0,0 +1,37 @@ | @@ -0,0 +1,37 @@ | ||
| 1 | +[ | ||
| 2 | + { | ||
| 3 | + "id": 1, | ||
| 4 | + "coin": 88, | ||
| 5 | + "rate": 5 | ||
| 6 | + }, | ||
| 7 | + { | ||
| 8 | + "id": 2, | ||
| 9 | + "coin": 108, | ||
| 10 | + "rate": 15 | ||
| 11 | + }, | ||
| 12 | + { | ||
| 13 | + "id": 3, | ||
| 14 | + "coin": 148, | ||
| 15 | + "rate": 25 | ||
| 16 | + }, | ||
| 17 | + { | ||
| 18 | + "id": 4, | ||
| 19 | + "coin": 168, | ||
| 20 | + "rate": 25 | ||
| 21 | + }, | ||
| 22 | + { | ||
| 23 | + "id": 5, | ||
| 24 | + "coin": 188, | ||
| 25 | + "rate": 15 | ||
| 26 | + }, | ||
| 27 | + { | ||
| 28 | + "id": 6, | ||
| 29 | + "coin": 228, | ||
| 30 | + "rate": 10 | ||
| 31 | + }, | ||
| 32 | + { | ||
| 33 | + "id": 7, | ||
| 34 | + "coin": 268, | ||
| 35 | + "rate": 5 | ||
| 36 | + } | ||
| 37 | +] | ||
| 0 | \ No newline at end of file | 38 | \ No newline at end of file |
| @@ -0,0 +1,152 @@ | @@ -0,0 +1,152 @@ | ||
| 1 | +[ | ||
| 2 | + { | ||
| 3 | + "id": 1, | ||
| 4 | + "point": 200, | ||
| 5 | + "free_coin": 60, | ||
| 6 | + "video_coin": 150 | ||
| 7 | + }, | ||
| 8 | + { | ||
| 9 | + "id": 2, | ||
| 10 | + "point": 500, | ||
| 11 | + "free_coin": 60, | ||
| 12 | + "video_coin": 150 | ||
| 13 | + }, | ||
| 14 | + { | ||
| 15 | + "id": 3, | ||
| 16 | + "point": 800, | ||
| 17 | + "free_coin": 50, | ||
| 18 | + "video_coin": 150 | ||
| 19 | + }, | ||
| 20 | + { | ||
| 21 | + "id": 4, | ||
| 22 | + "point": 1200, | ||
| 23 | + "free_coin": 50, | ||
| 24 | + "video_coin": 150 | ||
| 25 | + }, | ||
| 26 | + { | ||
| 27 | + "id": 5, | ||
| 28 | + "point": 1600, | ||
| 29 | + "free_coin": 40, | ||
| 30 | + "video_coin": 150 | ||
| 31 | + }, | ||
| 32 | + { | ||
| 33 | + "id": 6, | ||
| 34 | + "point": 2000, | ||
| 35 | + "free_coin": 40, | ||
| 36 | + "video_coin": 150 | ||
| 37 | + }, | ||
| 38 | + { | ||
| 39 | + "id": 7, | ||
| 40 | + "point": 2400, | ||
| 41 | + "free_coin": 40, | ||
| 42 | + "video_coin": 150 | ||
| 43 | + }, | ||
| 44 | + { | ||
| 45 | + "id": 8, | ||
| 46 | + "point": 2800, | ||
| 47 | + "free_coin": 40, | ||
| 48 | + "video_coin": 150 | ||
| 49 | + }, | ||
| 50 | + { | ||
| 51 | + "id": 9, | ||
| 52 | + "point": 3200, | ||
| 53 | + "free_coin": 35, | ||
| 54 | + "video_coin": 150 | ||
| 55 | + }, | ||
| 56 | + { | ||
| 57 | + "id": 10, | ||
| 58 | + "point": 3600, | ||
| 59 | + "free_coin": 35, | ||
| 60 | + "video_coin": 150 | ||
| 61 | + }, | ||
| 62 | + { | ||
| 63 | + "id": 11, | ||
| 64 | + "point": 3800, | ||
| 65 | + "free_coin": 30, | ||
| 66 | + "video_coin": 150 | ||
| 67 | + }, | ||
| 68 | + { | ||
| 69 | + "id": 12, | ||
| 70 | + "point": 4000, | ||
| 71 | + "free_coin": 30, | ||
| 72 | + "video_coin": 150 | ||
| 73 | + }, | ||
| 74 | + { | ||
| 75 | + "id": 13, | ||
| 76 | + "point": 4200, | ||
| 77 | + "free_coin": 30, | ||
| 78 | + "video_coin": 150 | ||
| 79 | + }, | ||
| 80 | + { | ||
| 81 | + "id": 14, | ||
| 82 | + "point": 4400, | ||
| 83 | + "free_coin": 25, | ||
| 84 | + "video_coin": 150 | ||
| 85 | + }, | ||
| 86 | + { | ||
| 87 | + "id": 15, | ||
| 88 | + "point": 4600, | ||
| 89 | + "free_coin": 25, | ||
| 90 | + "video_coin": 150 | ||
| 91 | + }, | ||
| 92 | + { | ||
| 93 | + "id": 16, | ||
| 94 | + "point": 4800, | ||
| 95 | + "free_coin": 25, | ||
| 96 | + "video_coin": 150 | ||
| 97 | + }, | ||
| 98 | + { | ||
| 99 | + "id": 17, | ||
| 100 | + "point": 5000, | ||
| 101 | + "free_coin": 25, | ||
| 102 | + "video_coin": 150 | ||
| 103 | + }, | ||
| 104 | + { | ||
| 105 | + "id": 18, | ||
| 106 | + "point": 5200, | ||
| 107 | + "free_coin": 20, | ||
| 108 | + "video_coin": 150 | ||
| 109 | + }, | ||
| 110 | + { | ||
| 111 | + "id": 19, | ||
| 112 | + "point": 5400, | ||
| 113 | + "free_coin": 20, | ||
| 114 | + "video_coin": 150 | ||
| 115 | + }, | ||
| 116 | + { | ||
| 117 | + "id": 20, | ||
| 118 | + "point": 5600, | ||
| 119 | + "free_coin": 20, | ||
| 120 | + "video_coin": 150 | ||
| 121 | + }, | ||
| 122 | + { | ||
| 123 | + "id": 21, | ||
| 124 | + "point": 5800, | ||
| 125 | + "free_coin": 20, | ||
| 126 | + "video_coin": 150 | ||
| 127 | + }, | ||
| 128 | + { | ||
| 129 | + "id": 22, | ||
| 130 | + "point": 6000, | ||
| 131 | + "free_coin": 20, | ||
| 132 | + "video_coin": 150 | ||
| 133 | + }, | ||
| 134 | + { | ||
| 135 | + "id": 23, | ||
| 136 | + "point": 6200, | ||
| 137 | + "free_coin": 20, | ||
| 138 | + "video_coin": 150 | ||
| 139 | + }, | ||
| 140 | + { | ||
| 141 | + "id": 24, | ||
| 142 | + "point": 6400, | ||
| 143 | + "free_coin": 20, | ||
| 144 | + "video_coin": 150 | ||
| 145 | + }, | ||
| 146 | + { | ||
| 147 | + "id": 25, | ||
| 148 | + "point": 6600, | ||
| 149 | + "free_coin": 20, | ||
| 150 | + "video_coin": 150 | ||
| 151 | + } | ||
| 152 | +] | ||
| 0 | \ No newline at end of file | 153 | \ No newline at end of file |
src/HttpServer/jsonconf/jsonconf.go
| @@ -12,64 +12,71 @@ var ( | @@ -12,64 +12,71 @@ var ( | ||
| 12 | ) | 12 | ) |
| 13 | 13 | ||
| 14 | type AchieveDesc struct { | 14 | type AchieveDesc struct { |
| 15 | - Type int `json:"type"` | ||
| 16 | - Id int `json:"id"` | ||
| 17 | - Desc string `json:"desc"` | ||
| 18 | - Aim int `json:"aim"` | ||
| 19 | - Coin int `json:"coin"` | 15 | + Type int `json:"type"` |
| 16 | + Id int `json:"id"` | ||
| 17 | + Desc string `json:"desc"` | ||
| 18 | + Aim int `json:"aim"` | ||
| 19 | + Coin int `json:"coin"` | ||
| 20 | Is_video int `json:"is_video"` | 20 | Is_video int `json:"is_video"` |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | type TaskDesc struct { | 23 | type TaskDesc struct { |
| 24 | - Id int `json:"id"` | ||
| 25 | - Type int `json:"type"` | ||
| 26 | - Day_type int `json:"day_type"` | ||
| 27 | - Active int `json:"active"` | ||
| 28 | - Coin int `json:"coin"` | ||
| 29 | - Desc string `json:"desc"` | 24 | + Id int `json:"id"` |
| 25 | + Type int `json:"type"` | ||
| 26 | + Day_type int `json:"day_type"` | ||
| 27 | + Active int `json:"active"` | ||
| 28 | + Coin int `json:"coin"` | ||
| 29 | + Desc string `json:"desc"` | ||
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | - | ||
| 33 | - | ||
| 34 | type TrunTableConfigDesc struct { | 32 | type TrunTableConfigDesc struct { |
| 35 | - Id int `json:"id"` | 33 | + Id int `json:"id"` |
| 36 | Name string `json:"name"` | 34 | Name string `json:"name"` |
| 37 | - Type int `json:"type"` | ||
| 38 | - Desc int `json:"desc"` | ||
| 39 | - Rate int `json:"rate"` | 35 | + Type int `json:"type"` |
| 36 | + Desc int `json:"desc"` | ||
| 37 | + Rate int `json:"rate"` | ||
| 40 | } | 38 | } |
| 41 | 39 | ||
| 42 | type RmbConfigDesc struct { | 40 | type RmbConfigDesc struct { |
| 43 | - Id int `json:"id"` | ||
| 44 | - Rmb_num float32 `json:"rmb_num"` | ||
| 45 | - Time int `json:"time"` | ||
| 46 | - Login_day int `json:"login_day"` | 41 | + Id int `json:"id"` |
| 42 | + Rmb_num float32 `json:"rmb_num"` | ||
| 43 | + Time int `json:"time"` | ||
| 44 | + Login_day int `json:"login_day"` | ||
| 47 | } | 45 | } |
| 48 | 46 | ||
| 49 | - | ||
| 50 | - | ||
| 51 | - | ||
| 52 | - | ||
| 53 | type SignConfigDesc struct { | 47 | type SignConfigDesc struct { |
| 54 | - Id int `json:"id"` | ||
| 55 | - Sign_coin int `json:"sign_coin"` | 48 | + Id int `json:"id"` |
| 49 | + Sign_coin int `json:"sign_coin"` | ||
| 56 | Video_coin int `json:"video_coin"` | 50 | Video_coin int `json:"video_coin"` |
| 57 | } | 51 | } |
| 58 | 52 | ||
| 53 | +type RedPackageConfigDesc struct { | ||
| 54 | + Id int `json:"id"` | ||
| 55 | + Point int `json:"point"` | ||
| 56 | + Free_coin int `json:"free_coin"` | ||
| 57 | + Video_coin int `json:"video_coin"` | ||
| 58 | +} | ||
| 59 | + | ||
| 60 | +type LuckyBagConfigDesc struct { | ||
| 61 | + Id int `json:"id"` | ||
| 62 | + Coin int `json:"coin"` | ||
| 63 | + Rate int `json:"rate"` | ||
| 64 | +} | ||
| 65 | + | ||
| 59 | type GameConfig struct { | 66 | type GameConfig struct { |
| 60 | - AchieventConfig []AchieveDesc | ||
| 61 | - TaskConfig []TaskDesc | ||
| 62 | - SignConfig []SignConfigDesc | ||
| 63 | - RmbConfig []RmbConfigDesc | ||
| 64 | - TrunTableConfig []TrunTableConfigDesc | 67 | + AchieventConfig []AchieveDesc |
| 68 | + TaskConfig []TaskDesc | ||
| 69 | + SignConfig []SignConfigDesc | ||
| 70 | + RmbConfig []RmbConfigDesc | ||
| 71 | + TrunTableConfig []TrunTableConfigDesc | ||
| 72 | + RedPackageConfig []RedPackageConfigDesc | ||
| 73 | + LuckyBagConfig []LuckyBagConfigDesc | ||
| 65 | } | 74 | } |
| 66 | 75 | ||
| 67 | func GetJsonConf() *GameConfig { | 76 | func GetJsonConf() *GameConfig { |
| 68 | return g_jsonconf | 77 | return g_jsonconf |
| 69 | } | 78 | } |
| 70 | 79 | ||
| 71 | - | ||
| 72 | - | ||
| 73 | func file_get_contents(path string) ([]byte, error) { | 80 | func file_get_contents(path string) ([]byte, error) { |
| 74 | f, err := os.Open(path) | 81 | f, err := os.Open(path) |
| 75 | if err != nil { | 82 | if err != nil { |
| @@ -146,8 +153,50 @@ func LoadJsonConf() error { | @@ -146,8 +153,50 @@ func LoadJsonConf() error { | ||
| 146 | return err | 153 | return err |
| 147 | } | 154 | } |
| 148 | 155 | ||
| 156 | + path = "../jsonconf/RedPackageConfig.json" | ||
| 157 | + content, err = file_get_contents(path) | ||
| 158 | + if err != nil { | ||
| 159 | + logger.Info("loadJsonConf failed1,err=%v", err) | ||
| 160 | + return err | ||
| 161 | + } | ||
| 149 | 162 | ||
| 163 | + err = json.Unmarshal([]byte(content), &g_jsonconf.RedPackageConfig) | ||
| 164 | + if err != nil { | ||
| 165 | + logger.Info("loadJsonConf failed1,err=%v", err) | ||
| 166 | + return err | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + path = "../jsonconf/LuckyBagConfig.json" | ||
| 170 | + content, err = file_get_contents(path) | ||
| 171 | + if err != nil { | ||
| 172 | + logger.Info("loadJsonConf failed1,err=%v", err) | ||
| 173 | + return err | ||
| 174 | + } | ||
| 175 | + | ||
| 176 | + err = json.Unmarshal([]byte(content), &g_jsonconf.LuckyBagConfig) | ||
| 177 | + if err != nil { | ||
| 178 | + logger.Info("loadJsonConf failed1,err=%v", err) | ||
| 179 | + return err | ||
| 180 | + } | ||
| 150 | 181 | ||
| 151 | logger.Info("loadJsonConf success pconf=%+v,err=%v", *g_jsonconf, err) | 182 | logger.Info("loadJsonConf success pconf=%+v,err=%v", *g_jsonconf, err) |
| 152 | return err | 183 | return err |
| 153 | } | 184 | } |
| 185 | + | ||
| 186 | +func GetRedPackageConfig(id int) *RedPackageConfigDesc { | ||
| 187 | + for _, val := range g_jsonconf.RedPackageConfig { | ||
| 188 | + if val.Id == id { | ||
| 189 | + return &val | ||
| 190 | + } | ||
| 191 | + } | ||
| 192 | + return nil | ||
| 193 | +} | ||
| 194 | + | ||
| 195 | +func GetsignConfig(id int) *SignConfigDesc { | ||
| 196 | + for _, v := range g_jsonconf.SignConfig { | ||
| 197 | + if v.Id == id { | ||
| 198 | + return &v | ||
| 199 | + } | ||
| 200 | + } | ||
| 201 | + return nil | ||
| 202 | +} |
src/HttpServer/logic/constdef.go
| @@ -57,4 +57,17 @@ const ( | @@ -57,4 +57,17 @@ const ( | ||
| 57 | FREE_REDBAG_NUM = 3 //玩家免费红包次数 | 57 | FREE_REDBAG_NUM = 3 //玩家免费红包次数 |
| 58 | READGOLDMULTI = 700 //阅读量到金币转化倍数 | 58 | READGOLDMULTI = 700 //阅读量到金币转化倍数 |
| 59 | SDKOPGOLD_TYPEWE = 302 //微转发金币类型 | 59 | SDKOPGOLD_TYPEWE = 302 //微转发金币类型 |
| 60 | + GUANGOLDNUMLIMIT = 900 //存钱罐金币上限 | ||
| 61 | + LUCKYBAGDAYLIMIT = 10 //每日福袋次数 | ||
| 62 | +) | ||
| 63 | + | ||
| 64 | +const ( | ||
| 65 | + REDBAGTYPE_101 = 101 //免费人物升级 | ||
| 66 | + REDBAGTYPE_102 = 102 //任务 | ||
| 67 | + REDBAGTYPE_103 = 103 //,免费红包 | ||
| 68 | + REDBAGTYPE_104 = 104 //付费人物升级 | ||
| 69 | + REDBAGTYPE_105 = 105 //存钱罐 | ||
| 70 | + REDBAGTYPE_106 = 106 //付费红包 | ||
| 71 | + REDBAGTYPE_107 = 107 //签到 | ||
| 72 | + REDBAGTYPE_302 = 302 //微转发 | ||
| 60 | ) | 73 | ) |
src/HttpServer/logic/datadef.go
| @@ -12,10 +12,11 @@ type UserLoginReq struct { | @@ -12,10 +12,11 @@ type UserLoginReq struct { | ||
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | type UserLoginData struct { | 14 | type UserLoginData struct { |
| 15 | - Isnew int `json:"isnew"` | ||
| 16 | - Walletgold int `json:"walletgold"` | ||
| 17 | - Guangold int `json:"guangold"` | ||
| 18 | - PlayerData string `json:"playerData"` | 15 | + Isnew int `json:"isnew"` |
| 16 | + Walletgold int `json:"walletgold"` | ||
| 17 | + Guangold int `json:"guangold"` | ||
| 18 | + PlayerData string `json:"playerData"` | ||
| 19 | + Offlinegold int `json:"offlinegold"` | ||
| 19 | } | 20 | } |
| 20 | 21 | ||
| 21 | type UserLoginResp struct { | 22 | type UserLoginResp struct { |
| @@ -56,10 +57,11 @@ type UpdatedataResp struct { | @@ -56,10 +57,11 @@ type UpdatedataResp struct { | ||
| 56 | } | 57 | } |
| 57 | 58 | ||
| 58 | type SyncuserdataData struct { | 59 | type SyncuserdataData struct { |
| 59 | - Walletgold int `json:"walletgold"` | ||
| 60 | - Guangold int `json:"guangold"` | ||
| 61 | - Sumloginday int `json:"sumloginday"` | ||
| 62 | - Nowtime int `json:"nowtime"` | 60 | + Walletgold int `json:"walletgold"` |
| 61 | + Guangold int `json:"guangold"` | ||
| 62 | + Sumloginday int `json:"sumloginday"` | ||
| 63 | + Nowtime int `json:"nowtime"` | ||
| 64 | + Luckbaglefttime int `json:"luckbaglefttime"` | ||
| 63 | } | 65 | } |
| 64 | 66 | ||
| 65 | type SyncuserdataResp struct { | 67 | type SyncuserdataResp struct { |
| @@ -116,9 +118,7 @@ type QueryguaninfoResp struct { | @@ -116,9 +118,7 @@ type QueryguaninfoResp struct { | ||
| 116 | } | 118 | } |
| 117 | 119 | ||
| 118 | type GetguangoldReq struct { | 120 | type GetguangoldReq struct { |
| 119 | - Goldnum int `json:"goldnum"` | ||
| 120 | - Gameid string `json:"gameid"` | ||
| 121 | - Channel string `json:"channel"` | 121 | + Goldnum int `json:"goldnum"` |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | type GetguangoldData struct { | 124 | type GetguangoldData struct { |
| @@ -132,15 +132,13 @@ type GetguangoldResp struct { | @@ -132,15 +132,13 @@ type GetguangoldResp struct { | ||
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | type DrawguangoldReq struct { | 134 | type DrawguangoldReq struct { |
| 135 | - Goldnum int `json:"goldnum"` | ||
| 136 | - Gameid string `json:"gameid"` | ||
| 137 | - Channel string `json:"channel"` | 135 | + Goldnum int `json:"goldnum"` |
| 138 | } | 136 | } |
| 139 | 137 | ||
| 140 | type DrawguangoldData struct { | 138 | type DrawguangoldData struct { |
| 141 | - Guangold int `json:"guangold"` | ||
| 142 | - Wallgold int `json:"wallgold"` | ||
| 143 | - Totalfetchcnt int `json:"totalfetchcnt"` | 139 | + Guangold int `json:"guangold"` |
| 140 | + Wallgold int `json:"wallgold"` | ||
| 141 | + //Totalfetchcnt int `json:"totalfetchcnt"` | ||
| 144 | } | 142 | } |
| 145 | 143 | ||
| 146 | type DrawguangoldResp struct { | 144 | type DrawguangoldResp struct { |
| @@ -149,12 +147,109 @@ type DrawguangoldResp struct { | @@ -149,12 +147,109 @@ type DrawguangoldResp struct { | ||
| 149 | Data DrawguangoldData `json:"data"` | 147 | Data DrawguangoldData `json:"data"` |
| 150 | } | 148 | } |
| 151 | 149 | ||
| 150 | +type FetchfenredbagReq struct { | ||
| 151 | + Id int `json:"id"` | ||
| 152 | + Ftype int `json:"ftype"` | ||
| 153 | +} | ||
| 154 | + | ||
| 155 | +type FetchfenredbagData struct { | ||
| 156 | + Wallgold int `json:"wallgold"` | ||
| 157 | +} | ||
| 158 | + | ||
| 159 | +type FetchfenredbagResp struct { | ||
| 160 | + Code int `json:"code"` | ||
| 161 | + Message string `json:"message"` | ||
| 162 | + Data FetchfenredbagData `json:"data"` | ||
| 163 | +} | ||
| 164 | + | ||
| 165 | +type FetchluckybagData struct { | ||
| 166 | + Wallgold int `json:"wallgold"` | ||
| 167 | + Lefttimes int `json:"lefttimes"` | ||
| 168 | +} | ||
| 169 | + | ||
| 170 | +type FetchluckybagResp struct { | ||
| 171 | + Code int `json:"code"` | ||
| 172 | + Message string `json:"message"` | ||
| 173 | + Data FetchluckybagData `json:"data"` | ||
| 174 | +} | ||
| 175 | + | ||
| 176 | +type QuersigndataData struct { | ||
| 177 | + Curday int `json:"curday"` | ||
| 178 | + Issigntaday int `json:"issigntaday"` | ||
| 179 | +} | ||
| 180 | + | ||
| 181 | +type QuersigndataResp struct { | ||
| 182 | + Code int `json:"code"` | ||
| 183 | + Message string `json:"message"` | ||
| 184 | + Data QuersigndataData `json:"data"` | ||
| 185 | +} | ||
| 186 | + | ||
| 187 | +type FetchoffliengoldData struct { | ||
| 188 | + Walletgold int `json:"walletgold"` | ||
| 189 | + Getgold int `json:"getgold"` | ||
| 190 | +} | ||
| 191 | + | ||
| 192 | +type FetchoffliengoldResp struct { | ||
| 193 | + Code int `json:"code"` | ||
| 194 | + Message string `json:"message"` | ||
| 195 | + Data FetchoffliengoldData `json:"data"` | ||
| 196 | +} | ||
| 197 | + | ||
| 198 | +type DosignData struct { | ||
| 199 | + Curday int `json:"curday"` | ||
| 200 | + Issigntaday int `json:"issigntaday"` | ||
| 201 | + Walletgold int `json:"walletgold"` | ||
| 202 | +} | ||
| 203 | + | ||
| 204 | +type DosignReq struct { | ||
| 205 | + Ftype int `json:"ftype"` | ||
| 206 | +} | ||
| 207 | + | ||
| 208 | +type DosignResp struct { | ||
| 209 | + Code int `json:"code"` | ||
| 210 | + Message string `json:"message"` | ||
| 211 | + Data DosignData `json:"data"` | ||
| 212 | +} | ||
| 213 | + | ||
| 152 | type QuerdrawinfoResp struct { | 214 | type QuerdrawinfoResp struct { |
| 153 | Code int `json:"code"` | 215 | Code int `json:"code"` |
| 154 | Message string `json:"message"` | 216 | Message string `json:"message"` |
| 155 | Data WithDrawInfo `json:"data"` | 217 | Data WithDrawInfo `json:"data"` |
| 156 | } | 218 | } |
| 157 | 219 | ||
| 220 | +type UploadhigestscoreReq struct { | ||
| 221 | + Score int64 `json:"score"` | ||
| 222 | +} | ||
| 223 | + | ||
| 224 | +type UploadhigestscoreData struct { | ||
| 225 | +} | ||
| 226 | + | ||
| 227 | +type UploadhigestscoreResp struct { | ||
| 228 | + Code int `json:"code"` | ||
| 229 | + Message string `json:"message"` | ||
| 230 | + Data UploadhigestscoreData `json:"data"` | ||
| 231 | +} | ||
| 232 | + | ||
| 233 | +type Queryrankinfolist struct { | ||
| 234 | + Rank int `json:"rank"` | ||
| 235 | + Nickname string `json:"nickname"` | ||
| 236 | + Headurl string `json:"headurl"` | ||
| 237 | + Socre int64 `json:"socre"` | ||
| 238 | + UniqueId string `json:"uniqueId"` | ||
| 239 | +} | ||
| 240 | + | ||
| 241 | +type QueryrankinfoData struct { | ||
| 242 | + Selfrank int `json:"selfrank"` | ||
| 243 | + Selfsocre int64 `json:"selfsocre"` | ||
| 244 | + Ranklist []Queryrankinfolist `json:"ranklist"` | ||
| 245 | +} | ||
| 246 | + | ||
| 247 | +type QueryrankinfoResp struct { | ||
| 248 | + Code int `json:"code"` | ||
| 249 | + Message string `json:"message"` | ||
| 250 | + Data QueryrankinfoData `json:"data"` | ||
| 251 | +} | ||
| 252 | + | ||
| 158 | type GetcashReq struct { | 253 | type GetcashReq struct { |
| 159 | Gameid string `json:"gameid"` | 254 | Gameid string `json:"gameid"` |
| 160 | Channel string `json:"channel"` | 255 | Channel string `json:"channel"` |
| @@ -376,31 +471,36 @@ type WithDrawDesc struct { | @@ -376,31 +471,36 @@ type WithDrawDesc struct { | ||
| 376 | 471 | ||
| 377 | //玩家数据 | 472 | //玩家数据 |
| 378 | type UserData struct { | 473 | type UserData struct { |
| 379 | - Userid string //玩家w唯一id | ||
| 380 | - Lv int //玩家当前等级 | ||
| 381 | - LvRewardGet int //当前等级奖励是否已经领取 1未领取 2普通领取 3双倍领取 | ||
| 382 | - Exp int //玩家当前经验值 | ||
| 383 | - NickName string //昵称 | ||
| 384 | - HeadUrl string //头像 | ||
| 385 | - RegTime int //注册时间 | ||
| 386 | - GuanGold int //玩家存钱罐中金币数量 | ||
| 387 | - RealGold int //玩家实际金币数量(可用于提现的) | ||
| 388 | - WatchAddsTime int //当天剩余红包次数 初始化50次 | ||
| 389 | - LastLoginTime int //上次登陆时间 | ||
| 390 | - ContinueLoginDay int //连续登录天数 | ||
| 391 | - SumLoginDay int //累计登陆天数 | ||
| 392 | - GetFromGuanCnt int //当天从存钱款提取金币次数 | ||
| 393 | - SignRound int //签到轮数 | ||
| 394 | - SignSum int //累计签到天数 | ||
| 395 | - IsSignToday int //今日是否已经签到 1是 0否 | ||
| 396 | - LeftFreeRB int //剩余免费红包次数 | ||
| 397 | - UpLvCostTime int //上一个等级升级时间 | ||
| 398 | - UpLvCostTimeSec int //上一个等级升级的时间点时刻 | ||
| 399 | - ReadNum int //玩家微转发阅读量 | ||
| 400 | - GetCashCnt int //当天提现次数 | ||
| 401 | - WithDraw WithDrawInfo //提现记录信息 | ||
| 402 | - Task TaskInfo //玩家任务完成相关信息 | ||
| 403 | - Achieve AchieveMentInfo //玩家成就完成相关数据 | 474 | + Userid string //玩家w唯一id |
| 475 | + Lv int //玩家当前等级 | ||
| 476 | + LvRewardGet int //当前等级奖励是否已经领取 1未领取 2普通领取 3双倍领取 | ||
| 477 | + Exp int //玩家当前经验值 | ||
| 478 | + NickName string //昵称 | ||
| 479 | + HeadUrl string //头像 | ||
| 480 | + RegTime int //注册时间 | ||
| 481 | + GuanGold int //玩家存钱罐中金币数量 | ||
| 482 | + RealGold int //玩家实际金币数量(可用于提现的) | ||
| 483 | + WatchAddsTime int //当天剩余红包次数 初始化50次 | ||
| 484 | + LastLoginTime int //上次登陆时间 | ||
| 485 | + ContinueLoginDay int //连续登录天数 | ||
| 486 | + SumLoginDay int //累计登陆天数 | ||
| 487 | + GetFromGuanCnt int //当天从存钱款提取金币次数 | ||
| 488 | + SignRound int //签到轮数 | ||
| 489 | + SignSum int //累计签到天数 | ||
| 490 | + IsSignToday int //今日是否已经签到 1是 0否 | ||
| 491 | + LeftFreeRB int //剩余免费红包次数 | ||
| 492 | + UpLvCostTime int //上一个等级升级时间 | ||
| 493 | + UpLvCostTimeSec int //上一个等级升级的时间点时刻 | ||
| 494 | + ReadNum int //玩家微转发阅读量 | ||
| 495 | + GetCashCnt int //当天提现次数 | ||
| 496 | + RedBagFetchIdlist []int //记录当前以及领取的红包id | ||
| 497 | + LuckyBagLeftTimes int //当日福袋剩余次数 | ||
| 498 | + LastUpdateTime int //上一次同步时间 | ||
| 499 | + OfflineGold int //离线金币数量 | ||
| 500 | + HighScore int64 //玩家历史最高分 | ||
| 501 | + WithDraw WithDrawInfo //提现记录信息 | ||
| 502 | + Task TaskInfo //玩家任务完成相关信息 | ||
| 503 | + Achieve AchieveMentInfo //玩家成就完成相关数据 | ||
| 404 | } | 504 | } |
| 405 | 505 | ||
| 406 | //---------------------------------------------------------------------------------------------------------------------- | 506 | //---------------------------------------------------------------------------------------------------------------------- |
src/HttpServer/logic/function.go
| 1 | package logic | 1 | package logic |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | + "HttpServer/conf" | ||
| 4 | "HttpServer/jsonconf" | 5 | "HttpServer/jsonconf" |
| 5 | "HttpServer/redishandler" | 6 | "HttpServer/redishandler" |
| 6 | "bytes" | 7 | "bytes" |
| @@ -11,6 +12,7 @@ import ( | @@ -11,6 +12,7 @@ import ( | ||
| 11 | "encoding/json" | 12 | "encoding/json" |
| 12 | "errors" | 13 | "errors" |
| 13 | "io/ioutil" | 14 | "io/ioutil" |
| 15 | + "math/rand" | ||
| 14 | "net/http" | 16 | "net/http" |
| 15 | "sort" | 17 | "sort" |
| 16 | "strconv" | 18 | "strconv" |
| @@ -23,6 +25,91 @@ func SetHeader(w http.ResponseWriter) { | @@ -23,6 +25,91 @@ func SetHeader(w http.ResponseWriter) { | ||
| 23 | w.Header().Set("Access-Control-Allow-Headers", "Content-Type,Uuid,Gameid,Channel") | 25 | w.Header().Set("Access-Control-Allow-Headers", "Content-Type,Uuid,Gameid,Channel") |
| 24 | } | 26 | } |
| 25 | 27 | ||
| 28 | +func (u *UserData) IsRedIdInList(id int) bool { | ||
| 29 | + for _, v := range u.RedBagFetchIdlist { | ||
| 30 | + if v == id { | ||
| 31 | + return true | ||
| 32 | + } | ||
| 33 | + } | ||
| 34 | + return false | ||
| 35 | +} | ||
| 36 | + | ||
| 37 | +func (u *UserData) HandlePassDay(uuid int, channel string) { | ||
| 38 | + isdiffday := false | ||
| 39 | + nowtime := time.Now() | ||
| 40 | + lasttime := time.Unix(int64(u.LastLoginTime), 0) | ||
| 41 | + nowdaynum := time.Now().Day() | ||
| 42 | + lastdaynum := time.Unix(int64(u.LastLoginTime), 0).Day() | ||
| 43 | + nowtimestamp := time.Date(nowtime.Year(), nowtime.Month(), nowtime.Day(), 0, 0, 0, 0, nowtime.Location()) | ||
| 44 | + lasttimestamp := time.Date(lasttime.Year(), lasttime.Month(), lasttime.Day(), 0, 0, 0, 0, lasttime.Location()) | ||
| 45 | + | ||
| 46 | + logger.Info("HandlePassDay lasttime=%v,lasttimestamp=%v", lasttime, lasttimestamp) | ||
| 47 | + if nowdaynum == lastdaynum { | ||
| 48 | + //同一天 | ||
| 49 | + if int64(u.LastLoginTime)-time.Now().Unix() > 86400 { | ||
| 50 | + //已经过了很多天了 | ||
| 51 | + //u.LastLoginTime = int(time.Now().Unix()) | ||
| 52 | + u.ContinueLoginDay = 1 | ||
| 53 | + isdiffday = true | ||
| 54 | + } else { | ||
| 55 | + //t同一天 不做处理 | ||
| 56 | + } | ||
| 57 | + } else { | ||
| 58 | + //不是同一天了 | ||
| 59 | + isdiffday = true | ||
| 60 | + if nowtimestamp.Unix() != lasttimestamp.Unix()+86400 { | ||
| 61 | + //超过一天了 | ||
| 62 | + u.ContinueLoginDay = 1 | ||
| 63 | + } else { | ||
| 64 | + u.ContinueLoginDay++ | ||
| 65 | + } | ||
| 66 | + logger.Info("HandlePassDay now=%v,last=%v", nowtimestamp.Unix(), lasttimestamp.Unix()) | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + if isdiffday { | ||
| 70 | + //跨天了 | ||
| 71 | + u.SumLoginDay++ | ||
| 72 | + u.WatchAddsTime = WATCH_ADD_DAY_LIMIT | ||
| 73 | + //todo 重置任务相关的数据 | ||
| 74 | + u.GetFromGuanCnt = 0 | ||
| 75 | + u.GetCashCnt = 0 | ||
| 76 | + | ||
| 77 | + u.Task.GetGuanGold = 0 | ||
| 78 | + u.Task.GetRedbagCnt = 0 | ||
| 79 | + u.Task.OnlineMin = 0 | ||
| 80 | + u.Task.PassLevel = 0 | ||
| 81 | + u.Task.UseItemCnt = 0 | ||
| 82 | + u.Task.PlaySmall = 0 | ||
| 83 | + u.RedBagFetchIdlist = u.RedBagFetchIdlist[:0] | ||
| 84 | + u.LuckyBagLeftTimes = LUCKYBAGDAYLIMIT | ||
| 85 | + | ||
| 86 | + err := InitTaskAndAchievement(uuid, channel) | ||
| 87 | + if err != nil { | ||
| 88 | + logger.Error("InitTaskAndAchievement err=%v", err) | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + //签到数据处理 | ||
| 92 | + u.IsSignToday = 0 | ||
| 93 | + if u.SignSum >= 7 { | ||
| 94 | + //进入新的一轮 | ||
| 95 | + u.SignSum = 0 | ||
| 96 | + u.SignRound++ | ||
| 97 | + } | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + u.LastLoginTime = int(nowtime.Unix()) | ||
| 101 | + uniqueid := strconv.Itoa(uuid) + channel | ||
| 102 | + SaveUserInfo(u, uniqueid) | ||
| 103 | +} | ||
| 104 | + | ||
| 105 | +func (udata *UserData) AddToRank() error { | ||
| 106 | + err := redishandler.GetRedisClient().Zadd(redis.USER_SCORE_RANK, float64(udata.HighScore), udata.Userid) | ||
| 107 | + if err != nil { | ||
| 108 | + logger.Error("AddToRank failed err=%v", err) | ||
| 109 | + } | ||
| 110 | + return err | ||
| 111 | +} | ||
| 112 | + | ||
| 26 | func GettotalParam(paramlist []string) string { | 113 | func GettotalParam(paramlist []string) string { |
| 27 | //排序 | 114 | //排序 |
| 28 | sort.Strings(paramlist) | 115 | sort.Strings(paramlist) |
| @@ -48,7 +135,7 @@ func GetHashValue(signsum string) string { | @@ -48,7 +135,7 @@ func GetHashValue(signsum string) string { | ||
| 48 | 135 | ||
| 49 | func DoHttpPost(bys []byte, apistr string) (string, error) { | 136 | func DoHttpPost(bys []byte, apistr string) (string, error) { |
| 50 | body := bytes.NewBuffer(bys) | 137 | body := bytes.NewBuffer(bys) |
| 51 | - url1 := XIAOXINGXING_SDKURLOFFICAL + apistr //"api/server/addcoin" | 138 | + url1 := conf.GetCoinConf().Host + apistr //"api/server/addcoin" |
| 52 | 139 | ||
| 53 | res, err := http.Post(url1, "application/json;charset=utf-8", body) | 140 | res, err := http.Post(url1, "application/json;charset=utf-8", body) |
| 54 | if err != nil { | 141 | if err != nil { |
| @@ -63,10 +150,10 @@ func DoHttpPost(bys []byte, apistr string) (string, error) { | @@ -63,10 +150,10 @@ func DoHttpPost(bys []byte, apistr string) (string, error) { | ||
| 63 | 150 | ||
| 64 | func GetCoinFromSdk(uuid int, gameid string, channel string) (int, error) { | 151 | func GetCoinFromSdk(uuid int, gameid string, channel string) (int, error) { |
| 65 | 152 | ||
| 66 | - SERVERKEY := XIAOXINGXING_SERVERKEYTEST | ||
| 67 | - if gameid == "1015" { | 153 | + SERVERKEY := conf.GetCoinConf().Key |
| 154 | + /*if gameid == "1015" { | ||
| 68 | SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1015 | 155 | SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1015 |
| 69 | - } | 156 | + }*/ |
| 70 | 157 | ||
| 71 | var paramlist []string | 158 | var paramlist []string |
| 72 | var params GetCoinDesc | 159 | var params GetCoinDesc |
| @@ -288,8 +375,7 @@ func InitTaskAndAchievement(uuid int, channel string) error { | @@ -288,8 +375,7 @@ func InitTaskAndAchievement(uuid int, channel string) error { | ||
| 288 | return nil | 375 | return nil |
| 289 | } | 376 | } |
| 290 | 377 | ||
| 291 | - | ||
| 292 | -func InitUserInfo(resp *UserLoginResp, uniqueuid ,gameid ,channel string,uuid int) error { | 378 | +func InitUserInfo(resp *UserLoginResp, uniqueuid, gameid, channel string, uuid int) error { |
| 293 | 379 | ||
| 294 | var initdata UserData | 380 | var initdata UserData |
| 295 | initdata.Lv = 1 | 381 | initdata.Lv = 1 |
| @@ -310,6 +396,7 @@ func InitUserInfo(resp *UserLoginResp, uniqueuid ,gameid ,channel string,uuid in | @@ -310,6 +396,7 @@ func InitUserInfo(resp *UserLoginResp, uniqueuid ,gameid ,channel string,uuid in | ||
| 310 | initdata.NickName = "著名沙雕" | 396 | initdata.NickName = "著名沙雕" |
| 311 | initdata.HeadUrl = "1" | 397 | initdata.HeadUrl = "1" |
| 312 | initdata.RegTime = int(time.Now().Unix()) | 398 | initdata.RegTime = int(time.Now().Unix()) |
| 399 | + initdata.LuckyBagLeftTimes = LUCKYBAGDAYLIMIT | ||
| 313 | 400 | ||
| 314 | for _, val := range jsonconf.GetJsonConf().RmbConfig { | 401 | for _, val := range jsonconf.GetJsonConf().RmbConfig { |
| 315 | var tmp WithDrawDesc | 402 | var tmp WithDrawDesc |
| @@ -372,17 +459,116 @@ func GetUserInfo(uniqueid string) (*UserData, error) { | @@ -372,17 +459,116 @@ func GetUserInfo(uniqueid string) (*UserData, error) { | ||
| 372 | return &tmp, nil | 459 | return &tmp, nil |
| 373 | } | 460 | } |
| 374 | 461 | ||
| 375 | -func SaveUserSelfData(uniqueid ,savedata string) error { | 462 | +func SaveUserSelfData(uniqueid, savedata string) error { |
| 376 | err := redishandler.GetRedisClient().HSet(redis.USER_DATA_KEY, uniqueid, savedata) | 463 | err := redishandler.GetRedisClient().HSet(redis.USER_DATA_KEY, uniqueid, savedata) |
| 377 | return err | 464 | return err |
| 378 | } | 465 | } |
| 379 | 466 | ||
| 380 | -func GetUserSelfData(uniqueid string) (string,error) { | 467 | +func GetUserSelfData(uniqueid string) (string, error) { |
| 381 | data, err := redishandler.GetRedisClient().HGet(redis.USER_SELF_DATA_KEY, uniqueid) | 468 | data, err := redishandler.GetRedisClient().HGet(redis.USER_SELF_DATA_KEY, uniqueid) |
| 382 | if err != nil { | 469 | if err != nil { |
| 383 | return "", err | 470 | return "", err |
| 384 | } | 471 | } |
| 385 | 472 | ||
| 386 | - | ||
| 387 | return data, nil | 473 | return data, nil |
| 388 | -} | ||
| 389 | \ No newline at end of file | 474 | \ No newline at end of file |
| 475 | +} | ||
| 476 | + | ||
| 477 | +func AddCoinToSdk(uuid int, goldnum int, gameid string, channel string, atype int) (int, error) { | ||
| 478 | + SERVERKEY := conf.GetCoinConf().Key | ||
| 479 | + /*if gameid == "1015" { | ||
| 480 | + SERVERKEY = XIAOXINGXING_SERVERKEYTEST_1015 | ||
| 481 | + }*/ | ||
| 482 | + var paramlist []string | ||
| 483 | + sign_type := "sign_type=md5" | ||
| 484 | + paramlist = append(paramlist, sign_type) | ||
| 485 | + time_stamp := "time_stamp=" + strconv.Itoa(int(time.Now().Unix())) | ||
| 486 | + paramlist = append(paramlist, time_stamp) | ||
| 487 | + paramgameid := "gameid=" + gameid | ||
| 488 | + paramlist = append(paramlist, paramgameid) | ||
| 489 | + pchannel := "channel=" + channel | ||
| 490 | + paramlist = append(paramlist, pchannel) | ||
| 491 | + puid := "uid=" + strconv.Itoa(uuid) | ||
| 492 | + paramlist = append(paramlist, puid) | ||
| 493 | + pcoin := "coin=" + strconv.Itoa(goldnum) | ||
| 494 | + paramlist = append(paramlist, pcoin) | ||
| 495 | + ptyp := "typ=" + strconv.Itoa(atype) | ||
| 496 | + paramlist = append(paramlist, ptyp) | ||
| 497 | + | ||
| 498 | + sumparam := GettotalParam(paramlist) | ||
| 499 | + //加serverkey | ||
| 500 | + signsum := sumparam + SERVERKEY | ||
| 501 | + logger.Info("AddCoinToSdk sumparam=%v", signsum) | ||
| 502 | + | ||
| 503 | + //进行hash | ||
| 504 | + sign := GetHashValue(signsum) | ||
| 505 | + | ||
| 506 | + var req AddCoinDesc | ||
| 507 | + req.Channel = channel | ||
| 508 | + req.Gameid = gameid | ||
| 509 | + req.Coin = goldnum | ||
| 510 | + req.Sign = sign | ||
| 511 | + req.Sign_type = "md5" | ||
| 512 | + req.Time_stamp = strconv.Itoa(int(time.Now().Unix())) | ||
| 513 | + req.Typ = atype | ||
| 514 | + req.Uid = uuid | ||
| 515 | + | ||
| 516 | + bys, err := json.Marshal(&req) | ||
| 517 | + if err != nil { | ||
| 518 | + logger.Error("AddCoinToSdk failed=%v", err) | ||
| 519 | + return 0, err | ||
| 520 | + } | ||
| 521 | + res, err := DoHttpPost(bys, "api/server/addcoin") | ||
| 522 | + if err != nil { | ||
| 523 | + logger.Error("AddCoinToSdk failed=%v", err) | ||
| 524 | + return 0, err | ||
| 525 | + } | ||
| 526 | + | ||
| 527 | + logger.Info("AddCoinToSdk res=%v", res) | ||
| 528 | + var resp AddCoinResp | ||
| 529 | + err = json.Unmarshal([]byte(res), &resp) | ||
| 530 | + if err != nil { | ||
| 531 | + logger.Error("AddCoinToSdk failed=%v", err) | ||
| 532 | + return 0, err | ||
| 533 | + } | ||
| 534 | + | ||
| 535 | + if resp.Code != "0" { | ||
| 536 | + gold, _ := GetCoinFromSdk(uuid, gameid, channel) | ||
| 537 | + logger.Error("AddCoinToSdk failed=%v", resp.Msg) | ||
| 538 | + return gold, err | ||
| 539 | + } | ||
| 540 | + return resp.Data.Mycoin, nil | ||
| 541 | +} | ||
| 542 | + | ||
| 543 | +//计算福袋金额 | ||
| 544 | +func CalcLuckYBagNum() int { | ||
| 545 | + rtnum := 0 | ||
| 546 | + | ||
| 547 | + sumrate := 0 | ||
| 548 | + tmprate := 0 | ||
| 549 | + idx := -1 | ||
| 550 | + rand.Seed(time.Now().UnixNano()) | ||
| 551 | + randnum := rand.Intn(100) | ||
| 552 | + cflist := jsonconf.GetJsonConf().LuckyBagConfig | ||
| 553 | + for _, vv := range cflist { | ||
| 554 | + sumrate += vv.Rate | ||
| 555 | + } | ||
| 556 | + logger.Info("CalcLuckYBagNum sumrate=%v,randnum=%v,cflist=%+v", sumrate, randnum, cflist) | ||
| 557 | + for k, v := range cflist { | ||
| 558 | + tmprate += int(v.Rate * 100 / sumrate) | ||
| 559 | + logger.Info("DrawTable tmprate=%v", tmprate) | ||
| 560 | + if tmprate >= randnum { | ||
| 561 | + idx = k | ||
| 562 | + break | ||
| 563 | + } | ||
| 564 | + } | ||
| 565 | + | ||
| 566 | + if idx == -1 { | ||
| 567 | + if len(cflist) > 0 { | ||
| 568 | + rtnum = cflist[0].Coin | ||
| 569 | + } | ||
| 570 | + } else { | ||
| 571 | + rtnum = cflist[idx].Coin | ||
| 572 | + } | ||
| 573 | + | ||
| 574 | + return rtnum | ||
| 575 | +} |
src/HttpServer/logic/httpserver.go
| @@ -49,13 +49,22 @@ func startServerHttpServe() { | @@ -49,13 +49,22 @@ func startServerHttpServe() { | ||
| 49 | http.HandleFunc("/russiaxiaoxiao/uploaduserbasicinfo", Uploaduserbasicinfo) //上传基本信息 | 49 | http.HandleFunc("/russiaxiaoxiao/uploaduserbasicinfo", Uploaduserbasicinfo) //上传基本信息 |
| 50 | http.HandleFunc("/russiaxiaoxiao/updatedata", Updatedata) //update数据 | 50 | http.HandleFunc("/russiaxiaoxiao/updatedata", Updatedata) //update数据 |
| 51 | http.HandleFunc("/russiaxiaoxiao/syncuserdata", Syncuserdata) //同步玩家数据 | 51 | http.HandleFunc("/russiaxiaoxiao/syncuserdata", Syncuserdata) //同步玩家数据 |
| 52 | + http.HandleFunc("/russiaxiaoxiao/getguangold", Getguangold) //获取金币存入存钱罐 | ||
| 53 | + http.HandleFunc("/russiaxiaoxiao/drawguangold", Drawguangold) //提取存钱罐金币 | ||
| 54 | + http.HandleFunc("/russiaxiaoxiao/fetchfenredbag", Fetchfenredbag) //请求领取每日消除红包 | ||
| 55 | + http.HandleFunc("/russiaxiaoxiao/fetchluckybag", Fetchluckybag) //请求领取每日福袋 | ||
| 56 | + http.HandleFunc("/russiaxiaoxiao/quersigndata", Quersigndata) //获取签到数据 | ||
| 57 | + http.HandleFunc("/russiaxiaoxiao/dosign", Dosign) //签到 | ||
| 58 | + http.HandleFunc("/russiaxiaoxiao/fetchoffliengold", Fetchoffliengold) //请求领取离线金币 | ||
| 59 | + http.HandleFunc("/russiaxiaoxiao/uploadhigestscore", Uploadhigestscore) //上报玩家历史最高分 | ||
| 60 | + http.HandleFunc("/russiaxiaoxiao/queryrankinfo", Queryrankinfo) //查询排行榜 | ||
| 52 | 61 | ||
| 53 | //.......................................... | 62 | //.......................................... |
| 54 | - http.HandleFunc("/eliminatestar/getuserdata", Getuserdata) //获取玩家数据 | ||
| 55 | - http.HandleFunc("/eliminatestar/watchads", Watchads) //观看激励视频 | ||
| 56 | - http.HandleFunc("/eliminatestar/queryguaninfo", Queryguaninfo) //获取存钱罐数据 | ||
| 57 | - http.HandleFunc("/eliminatestar/getguangold", Getguangold) //获取金币到存钱罐 | ||
| 58 | - http.HandleFunc("/eliminatestar/drawguangold", Drawguangold) //提取存钱罐的金币到个人钱包 | 63 | + http.HandleFunc("/eliminatestar/getuserdata", Getuserdata) //获取玩家数据 |
| 64 | + http.HandleFunc("/eliminatestar/watchads", Watchads) //观看激励视频 | ||
| 65 | + http.HandleFunc("/eliminatestar/queryguaninfo", Queryguaninfo) //获取存钱罐数据 | ||
| 66 | + //http.HandleFunc("/eliminatestar/getguangold", Getguangold) //获取金币到存钱罐 | ||
| 67 | + //http.HandleFunc("/eliminatestar/drawguangold", Drawguangold) //提取存钱罐的金币到个人钱包 | ||
| 59 | http.HandleFunc("/eliminatestar/querdrawinfo", Querdrawinfo) //获取提现档位信息接口 | 68 | http.HandleFunc("/eliminatestar/querdrawinfo", Querdrawinfo) //获取提现档位信息接口 |
| 60 | http.HandleFunc("/eliminatestar/getcash", Getcash) //提现 | 69 | http.HandleFunc("/eliminatestar/getcash", Getcash) //提现 |
| 61 | http.HandleFunc("/eliminatestar/getcashrecord", Getcashrecord) //提现记录列表 | 70 | http.HandleFunc("/eliminatestar/getcashrecord", Getcashrecord) //提现记录列表 |
| @@ -478,46 +487,255 @@ func Querdrawinfo(w http.ResponseWriter, r *http.Request) { | @@ -478,46 +487,255 @@ func Querdrawinfo(w http.ResponseWriter, r *http.Request) { | ||
| 478 | //HandlerQuerdrawinfo(w, s, Uuid) | 487 | //HandlerQuerdrawinfo(w, s, Uuid) |
| 479 | } | 488 | } |
| 480 | 489 | ||
| 490 | +func Queryrankinfo(w http.ResponseWriter, r *http.Request) { | ||
| 491 | + | ||
| 492 | + gameid := "" | ||
| 493 | + channel := "" | ||
| 494 | + uniqueid := "" | ||
| 495 | + Uuid := 0 | ||
| 496 | + if len(r.Header) > 0 { | ||
| 497 | + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) | ||
| 498 | + gameid = r.Header.Get("Gameid") | ||
| 499 | + channel = r.Header.Get("Channel") | ||
| 500 | + uniqueid = r.Header.Get("Uuid") + r.Header.Get("Channel") | ||
| 501 | + } | ||
| 502 | + | ||
| 503 | + if Uuid == 0 { | ||
| 504 | + SetHeader(w) | ||
| 505 | + logger.Error("Uuid is nil!") | ||
| 506 | + return | ||
| 507 | + } | ||
| 508 | + result, _ := ioutil.ReadAll(r.Body) | ||
| 509 | + r.Body.Close() | ||
| 510 | + | ||
| 511 | + s := string(result) | ||
| 512 | + logger.Info("Queryrankinfo , body:%v,uuid=%v", s, uniqueid) | ||
| 513 | + | ||
| 514 | + HandlerQueryrankinfo(w, s, uniqueid, gameid, channel, Uuid) | ||
| 515 | + | ||
| 516 | +} | ||
| 517 | + | ||
| 518 | +func Uploadhigestscore(w http.ResponseWriter, r *http.Request) { | ||
| 519 | + | ||
| 520 | + gameid := "" | ||
| 521 | + channel := "" | ||
| 522 | + uniqueid := "" | ||
| 523 | + Uuid := 0 | ||
| 524 | + if len(r.Header) > 0 { | ||
| 525 | + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) | ||
| 526 | + gameid = r.Header.Get("Gameid") | ||
| 527 | + channel = r.Header.Get("Channel") | ||
| 528 | + uniqueid = r.Header.Get("Uuid") + r.Header.Get("Channel") | ||
| 529 | + } | ||
| 530 | + | ||
| 531 | + if Uuid == 0 { | ||
| 532 | + SetHeader(w) | ||
| 533 | + logger.Error("Uuid is nil!") | ||
| 534 | + return | ||
| 535 | + } | ||
| 536 | + result, _ := ioutil.ReadAll(r.Body) | ||
| 537 | + r.Body.Close() | ||
| 538 | + | ||
| 539 | + s := string(result) | ||
| 540 | + logger.Info("Uploadhigestscore , body:%v,uuid=%v", s, uniqueid) | ||
| 541 | + | ||
| 542 | + HandlerUploadhigestscore(w, s, uniqueid, gameid, channel, Uuid) | ||
| 543 | + | ||
| 544 | +} | ||
| 545 | + | ||
| 546 | +func Fetchoffliengold(w http.ResponseWriter, r *http.Request) { | ||
| 547 | + | ||
| 548 | + gameid := "" | ||
| 549 | + channel := "" | ||
| 550 | + uniqueid := "" | ||
| 551 | + Uuid := 0 | ||
| 552 | + if len(r.Header) > 0 { | ||
| 553 | + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) | ||
| 554 | + gameid = r.Header.Get("Gameid") | ||
| 555 | + channel = r.Header.Get("Channel") | ||
| 556 | + uniqueid = r.Header.Get("Uuid") + r.Header.Get("Channel") | ||
| 557 | + } | ||
| 558 | + | ||
| 559 | + if Uuid == 0 { | ||
| 560 | + SetHeader(w) | ||
| 561 | + logger.Error("Uuid is nil!") | ||
| 562 | + return | ||
| 563 | + } | ||
| 564 | + result, _ := ioutil.ReadAll(r.Body) | ||
| 565 | + r.Body.Close() | ||
| 566 | + | ||
| 567 | + s := string(result) | ||
| 568 | + logger.Info("Fetchoffliengold , body:%v,uuid=%v", s, uniqueid) | ||
| 569 | + | ||
| 570 | + HandlerFetchoffliengold(w, s, uniqueid, gameid, channel, Uuid) | ||
| 571 | + | ||
| 572 | +} | ||
| 573 | + | ||
| 574 | +func Dosign(w http.ResponseWriter, r *http.Request) { | ||
| 575 | + | ||
| 576 | + gameid := "" | ||
| 577 | + channel := "" | ||
| 578 | + uniqueid := "" | ||
| 579 | + Uuid := 0 | ||
| 580 | + if len(r.Header) > 0 { | ||
| 581 | + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) | ||
| 582 | + gameid = r.Header.Get("Gameid") | ||
| 583 | + channel = r.Header.Get("Channel") | ||
| 584 | + uniqueid = r.Header.Get("Uuid") + r.Header.Get("Channel") | ||
| 585 | + } | ||
| 586 | + | ||
| 587 | + if Uuid == 0 { | ||
| 588 | + SetHeader(w) | ||
| 589 | + logger.Error("Uuid is nil!") | ||
| 590 | + return | ||
| 591 | + } | ||
| 592 | + result, _ := ioutil.ReadAll(r.Body) | ||
| 593 | + r.Body.Close() | ||
| 594 | + | ||
| 595 | + s := string(result) | ||
| 596 | + logger.Info("Dosign , body:%v,uuid=%v", s, uniqueid) | ||
| 597 | + | ||
| 598 | + HandlerDosign(w, s, uniqueid, gameid, channel, Uuid) | ||
| 599 | + | ||
| 600 | +} | ||
| 601 | + | ||
| 602 | +func Quersigndata(w http.ResponseWriter, r *http.Request) { | ||
| 603 | + | ||
| 604 | + gameid := "" | ||
| 605 | + channel := "" | ||
| 606 | + uniqueid := "" | ||
| 607 | + Uuid := 0 | ||
| 608 | + if len(r.Header) > 0 { | ||
| 609 | + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) | ||
| 610 | + gameid = r.Header.Get("Gameid") | ||
| 611 | + channel = r.Header.Get("Channel") | ||
| 612 | + uniqueid = r.Header.Get("Uuid") + r.Header.Get("Channel") | ||
| 613 | + } | ||
| 614 | + | ||
| 615 | + if Uuid == 0 { | ||
| 616 | + SetHeader(w) | ||
| 617 | + logger.Error("Uuid is nil!") | ||
| 618 | + return | ||
| 619 | + } | ||
| 620 | + result, _ := ioutil.ReadAll(r.Body) | ||
| 621 | + r.Body.Close() | ||
| 622 | + | ||
| 623 | + s := string(result) | ||
| 624 | + logger.Info("Quersigndata , body:%v,uuid=%v", s, uniqueid) | ||
| 625 | + | ||
| 626 | + HandlerQuersigndata(w, s, uniqueid, gameid, channel, Uuid) | ||
| 627 | + | ||
| 628 | +} | ||
| 629 | + | ||
| 630 | +func Fetchluckybag(w http.ResponseWriter, r *http.Request) { | ||
| 631 | + | ||
| 632 | + gameid := "" | ||
| 633 | + channel := "" | ||
| 634 | + uniqueid := "" | ||
| 635 | + Uuid := 0 | ||
| 636 | + if len(r.Header) > 0 { | ||
| 637 | + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) | ||
| 638 | + gameid = r.Header.Get("Gameid") | ||
| 639 | + channel = r.Header.Get("Channel") | ||
| 640 | + uniqueid = r.Header.Get("Uuid") + r.Header.Get("Channel") | ||
| 641 | + } | ||
| 642 | + | ||
| 643 | + if Uuid == 0 { | ||
| 644 | + SetHeader(w) | ||
| 645 | + logger.Error("Uuid is nil!") | ||
| 646 | + return | ||
| 647 | + } | ||
| 648 | + result, _ := ioutil.ReadAll(r.Body) | ||
| 649 | + r.Body.Close() | ||
| 650 | + | ||
| 651 | + s := string(result) | ||
| 652 | + logger.Info("Fetchluckybag , body:%v,uuid=%v", s, uniqueid) | ||
| 653 | + | ||
| 654 | + HandlerFetchluckybag(w, s, uniqueid, gameid, channel, Uuid) | ||
| 655 | + | ||
| 656 | +} | ||
| 657 | + | ||
| 658 | +func Fetchfenredbag(w http.ResponseWriter, r *http.Request) { | ||
| 659 | + | ||
| 660 | + gameid := "" | ||
| 661 | + channel := "" | ||
| 662 | + uniqueid := "" | ||
| 663 | + Uuid := 0 | ||
| 664 | + if len(r.Header) > 0 { | ||
| 665 | + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) | ||
| 666 | + gameid = r.Header.Get("Gameid") | ||
| 667 | + channel = r.Header.Get("Channel") | ||
| 668 | + uniqueid = r.Header.Get("Uuid") + r.Header.Get("Channel") | ||
| 669 | + } | ||
| 670 | + | ||
| 671 | + if Uuid == 0 { | ||
| 672 | + SetHeader(w) | ||
| 673 | + logger.Error("Uuid is nil!") | ||
| 674 | + return | ||
| 675 | + } | ||
| 676 | + result, _ := ioutil.ReadAll(r.Body) | ||
| 677 | + r.Body.Close() | ||
| 678 | + | ||
| 679 | + s := string(result) | ||
| 680 | + logger.Info("Fetchfenredbag , body:%v,uuid=%v", s, uniqueid) | ||
| 681 | + | ||
| 682 | + HandlerFetchfenredbag(w, s, uniqueid, gameid, channel, Uuid) | ||
| 683 | + | ||
| 684 | +} | ||
| 685 | + | ||
| 481 | func Drawguangold(w http.ResponseWriter, r *http.Request) { | 686 | func Drawguangold(w http.ResponseWriter, r *http.Request) { |
| 482 | 687 | ||
| 688 | + gameid := "" | ||
| 689 | + channel := "" | ||
| 690 | + uniqueid := "" | ||
| 483 | Uuid := 0 | 691 | Uuid := 0 |
| 484 | if len(r.Header) > 0 { | 692 | if len(r.Header) > 0 { |
| 485 | Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) | 693 | Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) |
| 694 | + gameid = r.Header.Get("Gameid") | ||
| 695 | + channel = r.Header.Get("Channel") | ||
| 696 | + uniqueid = r.Header.Get("Uuid") + r.Header.Get("Channel") | ||
| 486 | } | 697 | } |
| 487 | 698 | ||
| 488 | if Uuid == 0 { | 699 | if Uuid == 0 { |
| 489 | SetHeader(w) | 700 | SetHeader(w) |
| 490 | - //logger.Error("Uuid is nil!") | 701 | + logger.Error("Uuid is nil!") |
| 491 | return | 702 | return |
| 492 | } | 703 | } |
| 493 | result, _ := ioutil.ReadAll(r.Body) | 704 | result, _ := ioutil.ReadAll(r.Body) |
| 494 | r.Body.Close() | 705 | r.Body.Close() |
| 495 | 706 | ||
| 496 | s := string(result) | 707 | s := string(result) |
| 497 | - logger.Info("Drawguangold , body:%v,uuid=%v", s, Uuid) | 708 | + logger.Info("Drawguangold , body:%v,uuid=%v", s, uniqueid) |
| 709 | + | ||
| 710 | + HandlerDrawguangold(w, s, uniqueid, gameid, channel, Uuid) | ||
| 498 | 711 | ||
| 499 | - //HandlerDrawguangold(w, s, Uuid) | ||
| 500 | } | 712 | } |
| 501 | 713 | ||
| 502 | func Getguangold(w http.ResponseWriter, r *http.Request) { | 714 | func Getguangold(w http.ResponseWriter, r *http.Request) { |
| 503 | 715 | ||
| 716 | + gameid := "" | ||
| 717 | + channel := "" | ||
| 718 | + uniqueid := "" | ||
| 504 | Uuid := 0 | 719 | Uuid := 0 |
| 505 | if len(r.Header) > 0 { | 720 | if len(r.Header) > 0 { |
| 506 | Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) | 721 | Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) |
| 722 | + gameid = r.Header.Get("Gameid") | ||
| 723 | + channel = r.Header.Get("Channel") | ||
| 724 | + uniqueid = r.Header.Get("Uuid") + r.Header.Get("Channel") | ||
| 507 | } | 725 | } |
| 508 | 726 | ||
| 509 | if Uuid == 0 { | 727 | if Uuid == 0 { |
| 510 | SetHeader(w) | 728 | SetHeader(w) |
| 511 | - //logger.Error("Uuid is nil!") | 729 | + logger.Error("Uuid is nil!") |
| 512 | return | 730 | return |
| 513 | } | 731 | } |
| 514 | result, _ := ioutil.ReadAll(r.Body) | 732 | result, _ := ioutil.ReadAll(r.Body) |
| 515 | r.Body.Close() | 733 | r.Body.Close() |
| 516 | 734 | ||
| 517 | s := string(result) | 735 | s := string(result) |
| 518 | - logger.Info("Getguangold , body:%v,uuid=%v", s, Uuid) | 736 | + logger.Info("Getguangold , body:%v,uuid=%v", s, uniqueid) |
| 519 | 737 | ||
| 520 | - // HandlerGetguangold(w, s, Uuid) | 738 | + HandlerGetguangold(w, s, uniqueid, gameid, channel, Uuid) |
| 521 | } | 739 | } |
| 522 | 740 | ||
| 523 | func Queryguaninfo(w http.ResponseWriter, r *http.Request) { | 741 | func Queryguaninfo(w http.ResponseWriter, r *http.Request) { |
| @@ -569,14 +787,14 @@ func Watchads(w http.ResponseWriter, r *http.Request) { | @@ -569,14 +787,14 @@ func Watchads(w http.ResponseWriter, r *http.Request) { | ||
| 569 | 787 | ||
| 570 | func Syncuserdata(w http.ResponseWriter, r *http.Request) { | 788 | func Syncuserdata(w http.ResponseWriter, r *http.Request) { |
| 571 | 789 | ||
| 572 | - //gameid := "" | ||
| 573 | - //channel := "" | 790 | + gameid := "" |
| 791 | + channel := "" | ||
| 574 | uniqueid := "" | 792 | uniqueid := "" |
| 575 | Uuid := 0 | 793 | Uuid := 0 |
| 576 | if len(r.Header) > 0 { | 794 | if len(r.Header) > 0 { |
| 577 | Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) | 795 | Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) |
| 578 | - // gameid = r.Header.Get("Gameid") | ||
| 579 | - //channel = r.Header.Get("Channel") | 796 | + gameid = r.Header.Get("Gameid") |
| 797 | + channel = r.Header.Get("Channel") | ||
| 580 | uniqueid = r.Header.Get("Uuid") + r.Header.Get("Channel") | 798 | uniqueid = r.Header.Get("Uuid") + r.Header.Get("Channel") |
| 581 | } | 799 | } |
| 582 | 800 | ||
| @@ -591,7 +809,7 @@ func Syncuserdata(w http.ResponseWriter, r *http.Request) { | @@ -591,7 +809,7 @@ func Syncuserdata(w http.ResponseWriter, r *http.Request) { | ||
| 591 | s := string(result) | 809 | s := string(result) |
| 592 | logger.Info("Syncuserdata , body:%v,uuid=%v", s, uniqueid) | 810 | logger.Info("Syncuserdata , body:%v,uuid=%v", s, uniqueid) |
| 593 | 811 | ||
| 594 | - HandlerSyncuserdata(w, s, uniqueid) | 812 | + HandlerSyncuserdata(w, s, uniqueid, gameid, channel, Uuid) |
| 595 | } | 813 | } |
| 596 | 814 | ||
| 597 | func Updatedata(w http.ResponseWriter, r *http.Request) { | 815 | func Updatedata(w http.ResponseWriter, r *http.Request) { |
src/HttpServer/logic/logic.go
| 1 | package logic | 1 | package logic |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | + "HttpServer/jsonconf" | ||
| 4 | "HttpServer/redishandler" | 5 | "HttpServer/redishandler" |
| 5 | "common/logger" | 6 | "common/logger" |
| 6 | "common/redis" | 7 | "common/redis" |
| @@ -10,7 +11,7 @@ import ( | @@ -10,7 +11,7 @@ import ( | ||
| 10 | "time" | 11 | "time" |
| 11 | ) | 12 | ) |
| 12 | 13 | ||
| 13 | -func HandlerSyncuserdata(w http.ResponseWriter, data string, uniqueuuid string) { | 14 | +func HandlerSyncuserdata(w http.ResponseWriter, data string, uniqueuuid, gameid, channel string, uuid int) { |
| 14 | SetHeader(w) | 15 | SetHeader(w) |
| 15 | 16 | ||
| 16 | var resp SyncuserdataResp | 17 | var resp SyncuserdataResp |
| @@ -28,10 +29,15 @@ func HandlerSyncuserdata(w http.ResponseWriter, data string, uniqueuuid string) | @@ -28,10 +29,15 @@ func HandlerSyncuserdata(w http.ResponseWriter, data string, uniqueuuid string) | ||
| 28 | break | 29 | break |
| 29 | } | 30 | } |
| 30 | 31 | ||
| 32 | + uinfo.LastUpdateTime = int(time.Now().Unix()) | ||
| 33 | + //此处要处理一下跨天逻辑 | ||
| 34 | + uinfo.HandlePassDay(uuid, channel) | ||
| 35 | + | ||
| 31 | resp.Data.Walletgold = uinfo.RealGold | 36 | resp.Data.Walletgold = uinfo.RealGold |
| 32 | resp.Data.Guangold = uinfo.GuanGold | 37 | resp.Data.Guangold = uinfo.GuanGold |
| 33 | resp.Data.Sumloginday = uinfo.SumLoginDay | 38 | resp.Data.Sumloginday = uinfo.SumLoginDay |
| 34 | resp.Data.Nowtime = int(time.Now().Unix()) | 39 | resp.Data.Nowtime = int(time.Now().Unix()) |
| 40 | + resp.Data.Luckbaglefttime = uinfo.LuckyBagLeftTimes | ||
| 35 | break | 41 | break |
| 36 | } | 42 | } |
| 37 | 43 | ||
| @@ -111,6 +117,494 @@ func HandlerUploaduserbasicinfo(w http.ResponseWriter, data string, uniqueuuid s | @@ -111,6 +117,494 @@ func HandlerUploaduserbasicinfo(w http.ResponseWriter, data string, uniqueuuid s | ||
| 111 | fmt.Fprint(w, string(respstr)) | 117 | fmt.Fprint(w, string(respstr)) |
| 112 | } | 118 | } |
| 113 | 119 | ||
| 120 | +func HandlerQueryrankinfo(w http.ResponseWriter, data string, uniqueuuid, gameid, channel string, uuid int) { | ||
| 121 | + SetHeader(w) | ||
| 122 | + var resp QueryrankinfoResp | ||
| 123 | + resp.Code = 0 | ||
| 124 | + resp.Message = "success" | ||
| 125 | + | ||
| 126 | + for { | ||
| 127 | + selfrank := -1 | ||
| 128 | + selfscore := int64(0) | ||
| 129 | + vv, err := redishandler.GetRedisClient().ZRevRangewithIndex(redis.USER_SCORE_RANK, 0, 99) | ||
| 130 | + if err == nil { | ||
| 131 | + rank := 0 | ||
| 132 | + for _, v := range vv { | ||
| 133 | + rank++ | ||
| 134 | + | ||
| 135 | + rinfobyte, _ := v.([]byte) | ||
| 136 | + logger.Info("HandlerQueryPlayerRank ,v=%v", string(rinfobyte)) | ||
| 137 | + //ruid, _ := strconv.Atoi(string(rinfobyte)) | ||
| 138 | + rindo, err := GetUserInfo(string(rinfobyte)) | ||
| 139 | + if err == nil && rindo != nil { | ||
| 140 | + var tmp Queryrankinfolist | ||
| 141 | + tmp.UniqueId = string(rinfobyte) | ||
| 142 | + tmp.Socre = rindo.HighScore | ||
| 143 | + tmp.Nickname = rindo.NickName | ||
| 144 | + tmp.Headurl = rindo.HeadUrl | ||
| 145 | + tmp.Rank = rank | ||
| 146 | + | ||
| 147 | + resp.Data.Ranklist = append(resp.Data.Ranklist, tmp) | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + if string(rinfobyte) == uniqueuuid { | ||
| 151 | + selfrank = rank | ||
| 152 | + selfscore = rindo.HighScore | ||
| 153 | + } | ||
| 154 | + } | ||
| 155 | + } else { | ||
| 156 | + logger.Error("HandlerUpdateUserInfo redisfailed ") | ||
| 157 | + resp.Code = 1 | ||
| 158 | + resp.Message = "redisfailed" | ||
| 159 | + break | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + if selfrank == -1 { | ||
| 163 | + uinfo, err := GetUserInfo(uniqueuuid) | ||
| 164 | + if err != nil { | ||
| 165 | + logger.Info("GetUserInfo HandlerQueryrankinfo data failed:%v,for:%v", err, data) | ||
| 166 | + resp.Message = "GetUserInfo failed" | ||
| 167 | + resp.Code = 1 | ||
| 168 | + break | ||
| 169 | + } | ||
| 170 | + | ||
| 171 | + resp.Data.Selfsocre = uinfo.HighScore | ||
| 172 | + resp.Data.Selfrank = 101 //表示100+ | ||
| 173 | + } else { | ||
| 174 | + resp.Data.Selfrank = selfrank | ||
| 175 | + resp.Data.Selfsocre = selfscore | ||
| 176 | + } | ||
| 177 | + | ||
| 178 | + resp.Code = ERROR_OK | ||
| 179 | + break | ||
| 180 | + } | ||
| 181 | + | ||
| 182 | + //回包 | ||
| 183 | + respstr, _ := json.Marshal(&resp) | ||
| 184 | + fmt.Fprint(w, string(respstr)) | ||
| 185 | +} | ||
| 186 | + | ||
| 187 | +func HandlerUploadhigestscore(w http.ResponseWriter, data string, uniqueuuid, gameid, channel string, uuid int) { | ||
| 188 | + SetHeader(w) | ||
| 189 | + var resp UploadhigestscoreResp | ||
| 190 | + resp.Code = 0 | ||
| 191 | + resp.Message = "success" | ||
| 192 | + var rdata UploadhigestscoreReq | ||
| 193 | + err := json.Unmarshal([]byte(data), &rdata) | ||
| 194 | + for { | ||
| 195 | + if err != nil { | ||
| 196 | + logger.Info("json decode HandlerUploadhigestscore data failed:%v,for:%v", err, data) | ||
| 197 | + resp.Message = "json解析错误" | ||
| 198 | + resp.Code = ERROR_JSONUNMASH_ERROR | ||
| 199 | + break | ||
| 200 | + } | ||
| 201 | + uinfo, err := GetUserInfo(uniqueuuid) | ||
| 202 | + if err != nil { | ||
| 203 | + logger.Info("GetUserInfo HandlerUploadhigestscore data failed:%v,for:%v", err, data) | ||
| 204 | + resp.Message = "GetUserInfo failed" | ||
| 205 | + resp.Code = 1 | ||
| 206 | + break | ||
| 207 | + } | ||
| 208 | + | ||
| 209 | + if rdata.Score < uinfo.HighScore { | ||
| 210 | + logger.Info("GetUserInfo HandlerUploadhigestscore data failed:%v,for:%v", err, data) | ||
| 211 | + resp.Message = "分数不足最高分" | ||
| 212 | + resp.Code = 1 | ||
| 213 | + break | ||
| 214 | + } | ||
| 215 | + | ||
| 216 | + uinfo.HighScore = rdata.Score | ||
| 217 | + | ||
| 218 | + uinfo.AddToRank() | ||
| 219 | + //加入排行榜 | ||
| 220 | + SaveUserInfo(uinfo, uniqueuuid) | ||
| 221 | + resp.Code = ERROR_OK | ||
| 222 | + break | ||
| 223 | + } | ||
| 224 | + | ||
| 225 | + //回包 | ||
| 226 | + respstr, _ := json.Marshal(&resp) | ||
| 227 | + fmt.Fprint(w, string(respstr)) | ||
| 228 | +} | ||
| 229 | + | ||
| 230 | +func HandlerDosign(w http.ResponseWriter, data string, uniqueuuid, gameid, channel string, uuid int) { | ||
| 231 | + SetHeader(w) | ||
| 232 | + var resp DosignResp | ||
| 233 | + resp.Code = 0 | ||
| 234 | + resp.Message = "success" | ||
| 235 | + var rdata DosignReq | ||
| 236 | + err := json.Unmarshal([]byte(data), &rdata) | ||
| 237 | + for { | ||
| 238 | + if err != nil { | ||
| 239 | + logger.Info("json decode HandlerDosign data failed:%v,for:%v", err, data) | ||
| 240 | + resp.Message = "json解析错误" | ||
| 241 | + resp.Code = ERROR_JSONUNMASH_ERROR | ||
| 242 | + break | ||
| 243 | + } | ||
| 244 | + uinfo, err := GetUserInfo(uniqueuuid) | ||
| 245 | + if err != nil { | ||
| 246 | + logger.Info("GetUserInfo HandlerDosign data failed:%v,for:%v", err, data) | ||
| 247 | + resp.Message = "GetUserInfo failed" | ||
| 248 | + resp.Code = 1 | ||
| 249 | + break | ||
| 250 | + } | ||
| 251 | + | ||
| 252 | + if uinfo.IsSignToday == 1 { | ||
| 253 | + logger.Info(" HandlerDosign issign failed:%v,for:%v", err, data) | ||
| 254 | + resp.Message = "当天已签到" | ||
| 255 | + resp.Code = 1 | ||
| 256 | + break | ||
| 257 | + } | ||
| 258 | + | ||
| 259 | + uinfo.IsSignToday = 1 | ||
| 260 | + uinfo.SignSum++ | ||
| 261 | + if uinfo.SignSum > 7 { | ||
| 262 | + uinfo.SignSum = 1 | ||
| 263 | + uinfo.SignRound++ | ||
| 264 | + } | ||
| 265 | + | ||
| 266 | + cfg := jsonconf.GetsignConfig(uinfo.SignSum) | ||
| 267 | + if cfg == nil { | ||
| 268 | + logger.Info("GetUserInfo HandlerDosign data failed:%v,for:%v", err, data) | ||
| 269 | + resp.Message = "参数错误" | ||
| 270 | + resp.Code = 1 | ||
| 271 | + break | ||
| 272 | + } | ||
| 273 | + | ||
| 274 | + readgold := 0 | ||
| 275 | + readgold, err = AddCoinToSdk(uuid, cfg.Sign_coin, gameid, channel, REDBAGTYPE_107) | ||
| 276 | + if err != nil { | ||
| 277 | + logger.Info("GetUserInfo HandlerDosign data failed:%v,for:%v", err, data) | ||
| 278 | + resp.Message = "后台失败!" | ||
| 279 | + resp.Code = 1 | ||
| 280 | + break | ||
| 281 | + } | ||
| 282 | + | ||
| 283 | + if rdata.Ftype == 2 { | ||
| 284 | + readgold, err = AddCoinToSdk(uuid, cfg.Video_coin, gameid, channel, REDBAGTYPE_107) | ||
| 285 | + if err != nil { | ||
| 286 | + logger.Info("GetUserInfo HandlerDosign data failed:%v,for:%v", err, data) | ||
| 287 | + resp.Message = "后台失败!" | ||
| 288 | + resp.Code = 1 | ||
| 289 | + break | ||
| 290 | + } | ||
| 291 | + } | ||
| 292 | + | ||
| 293 | + uinfo.RealGold = readgold | ||
| 294 | + | ||
| 295 | + resp.Data.Curday = uinfo.SignSum | ||
| 296 | + resp.Data.Issigntaday = uinfo.IsSignToday | ||
| 297 | + resp.Data.Walletgold = uinfo.RealGold | ||
| 298 | + | ||
| 299 | + SaveUserInfo(uinfo, uniqueuuid) | ||
| 300 | + resp.Code = ERROR_OK | ||
| 301 | + break | ||
| 302 | + } | ||
| 303 | + | ||
| 304 | + //回包 | ||
| 305 | + respstr, _ := json.Marshal(&resp) | ||
| 306 | + fmt.Fprint(w, string(respstr)) | ||
| 307 | +} | ||
| 308 | + | ||
| 309 | +func HandlerFetchoffliengold(w http.ResponseWriter, data string, uniqueuuid, gameid, channel string, uuid int) { | ||
| 310 | + SetHeader(w) | ||
| 311 | + var resp FetchoffliengoldResp | ||
| 312 | + resp.Code = 0 | ||
| 313 | + for { | ||
| 314 | + | ||
| 315 | + uinfo, err := GetUserInfo(uniqueuuid) | ||
| 316 | + if err != nil { | ||
| 317 | + logger.Info("GetUserInfo HandlerFetchoffliengold data failed:%v,for:%v", err, data) | ||
| 318 | + resp.Message = "GetUserInfo failed" | ||
| 319 | + resp.Code = 1 | ||
| 320 | + break | ||
| 321 | + } | ||
| 322 | + | ||
| 323 | + if uinfo.OfflineGold <= 0 { | ||
| 324 | + logger.Info("GetUserInfo HandlerFetchoffliengold data failed:%v,for:%v", err, data) | ||
| 325 | + resp.Message = "没有离线金币可以领取" | ||
| 326 | + resp.Code = 1 | ||
| 327 | + break | ||
| 328 | + } | ||
| 329 | + | ||
| 330 | + readgold, err := AddCoinToSdk(uuid, uinfo.OfflineGold, gameid, channel, REDBAGTYPE_106) | ||
| 331 | + if err != nil { | ||
| 332 | + logger.Info("GetUserInfo HandlerFetchoffliengold data failed:%v,for:%v", err, data) | ||
| 333 | + resp.Message = "后台失败!" | ||
| 334 | + resp.Code = 1 | ||
| 335 | + break | ||
| 336 | + } | ||
| 337 | + | ||
| 338 | + uinfo.RealGold = readgold | ||
| 339 | + | ||
| 340 | + resp.Data.Walletgold = uinfo.RealGold | ||
| 341 | + resp.Data.Getgold = uinfo.OfflineGold | ||
| 342 | + | ||
| 343 | + uinfo.OfflineGold = 0 | ||
| 344 | + | ||
| 345 | + SaveUserInfo(uinfo, uniqueuuid) | ||
| 346 | + resp.Code = ERROR_OK | ||
| 347 | + break | ||
| 348 | + } | ||
| 349 | + | ||
| 350 | + //回包 | ||
| 351 | + respstr, _ := json.Marshal(&resp) | ||
| 352 | + fmt.Fprint(w, string(respstr)) | ||
| 353 | +} | ||
| 354 | + | ||
| 355 | +func HandlerQuersigndata(w http.ResponseWriter, data string, uniqueuuid, gameid, channel string, uuid int) { | ||
| 356 | + SetHeader(w) | ||
| 357 | + var resp QuersigndataResp | ||
| 358 | + resp.Code = 0 | ||
| 359 | + for { | ||
| 360 | + | ||
| 361 | + uinfo, err := GetUserInfo(uniqueuuid) | ||
| 362 | + if err != nil { | ||
| 363 | + logger.Info("GetUserInfo HandlerQuersigndata data failed:%v,for:%v", err, data) | ||
| 364 | + resp.Message = "GetUserInfo failed" | ||
| 365 | + resp.Code = 1 | ||
| 366 | + break | ||
| 367 | + } | ||
| 368 | + | ||
| 369 | + resp.Data.Curday = uinfo.SignSum | ||
| 370 | + resp.Data.Issigntaday = uinfo.IsSignToday | ||
| 371 | + | ||
| 372 | + resp.Code = ERROR_OK | ||
| 373 | + break | ||
| 374 | + } | ||
| 375 | + | ||
| 376 | + //回包 | ||
| 377 | + respstr, _ := json.Marshal(&resp) | ||
| 378 | + fmt.Fprint(w, string(respstr)) | ||
| 379 | +} | ||
| 380 | + | ||
| 381 | +func HandlerFetchluckybag(w http.ResponseWriter, data string, uniqueuuid, gameid, channel string, uuid int) { | ||
| 382 | + SetHeader(w) | ||
| 383 | + | ||
| 384 | + var resp FetchluckybagResp | ||
| 385 | + resp.Code = 0 | ||
| 386 | + | ||
| 387 | + for { | ||
| 388 | + | ||
| 389 | + uinfo, err := GetUserInfo(uniqueuuid) | ||
| 390 | + if err != nil { | ||
| 391 | + logger.Info("GetUserInfo HandlerFetchluckybag data failed:%v,for:%v", err, data) | ||
| 392 | + resp.Message = "GetUserInfo failed" | ||
| 393 | + resp.Code = 1 | ||
| 394 | + break | ||
| 395 | + } | ||
| 396 | + | ||
| 397 | + //先判断次数是否足够 | ||
| 398 | + if uinfo.LuckyBagLeftTimes < 1 { | ||
| 399 | + logger.Info("GetUserInfo HandlerFetchluckybag data failed:%v,for:%v", err, data) | ||
| 400 | + resp.Message = "当日已经没有福袋可以领取了!" | ||
| 401 | + resp.Code = 1 | ||
| 402 | + break | ||
| 403 | + } | ||
| 404 | + | ||
| 405 | + addcoin := CalcLuckYBagNum() | ||
| 406 | + if addcoin == 0 { | ||
| 407 | + logger.Info("GetUserInfo HandlerFetchluckybag data failed:%v,for:%v", err, data) | ||
| 408 | + resp.Message = "CalcLuckYBagNum!" | ||
| 409 | + resp.Code = 1 | ||
| 410 | + break | ||
| 411 | + } | ||
| 412 | + | ||
| 413 | + realgold, err := AddCoinToSdk(uuid, addcoin, gameid, channel, REDBAGTYPE_106) | ||
| 414 | + if err != nil { | ||
| 415 | + logger.Info("GetUserInfo HandlerFetchluckybag data failed:%v,for:%v", err, data) | ||
| 416 | + resp.Message = "后台加金币失败了" | ||
| 417 | + resp.Code = 1 | ||
| 418 | + break | ||
| 419 | + } | ||
| 420 | + | ||
| 421 | + uinfo.RealGold = realgold | ||
| 422 | + uinfo.LuckyBagLeftTimes-- | ||
| 423 | + | ||
| 424 | + resp.Data.Wallgold = uinfo.RealGold | ||
| 425 | + resp.Data.Lefttimes = uinfo.LuckyBagLeftTimes | ||
| 426 | + | ||
| 427 | + SaveUserInfo(uinfo, uniqueuuid) | ||
| 428 | + | ||
| 429 | + resp.Code = ERROR_OK | ||
| 430 | + break | ||
| 431 | + } | ||
| 432 | + | ||
| 433 | + //回包 | ||
| 434 | + respstr, _ := json.Marshal(&resp) | ||
| 435 | + fmt.Fprint(w, string(respstr)) | ||
| 436 | +} | ||
| 437 | + | ||
| 438 | +func HandlerFetchfenredbag(w http.ResponseWriter, data string, uniqueuuid, gameid, channel string, uuid int) { | ||
| 439 | + SetHeader(w) | ||
| 440 | + | ||
| 441 | + var resp FetchfenredbagResp | ||
| 442 | + resp.Code = 0 | ||
| 443 | + var rdata FetchfenredbagReq | ||
| 444 | + err := json.Unmarshal([]byte(data), &rdata) | ||
| 445 | + for { | ||
| 446 | + | ||
| 447 | + if err != nil { | ||
| 448 | + logger.Info("json decode HandlerFetchfenredbag data failed:%v,for:%v", err, data) | ||
| 449 | + resp.Message = "json解析错误" | ||
| 450 | + resp.Code = ERROR_JSONUNMASH_ERROR | ||
| 451 | + break | ||
| 452 | + } | ||
| 453 | + | ||
| 454 | + uinfo, err := GetUserInfo(uniqueuuid) | ||
| 455 | + if err != nil { | ||
| 456 | + logger.Info("GetUserInfo HandlerFetchfenredbag data failed:%v,for:%v", err, data) | ||
| 457 | + resp.Message = "GetUserInfo failed" | ||
| 458 | + resp.Code = 1 | ||
| 459 | + break | ||
| 460 | + } | ||
| 461 | + | ||
| 462 | + cfg := jsonconf.GetRedPackageConfig(rdata.Id) | ||
| 463 | + if cfg == nil { | ||
| 464 | + logger.Info("GetUserInfo HandlerFetchfenredbag data failed:%v,for:%v", err, data) | ||
| 465 | + resp.Message = "参数错误" | ||
| 466 | + resp.Code = 1 | ||
| 467 | + break | ||
| 468 | + } | ||
| 469 | + | ||
| 470 | + //需要判断一下当天是否已经领取过了 | ||
| 471 | + if uinfo.IsRedIdInList(rdata.Id) { | ||
| 472 | + logger.Info("GetUserInfo HandlerFetchfenredbag data failed:%v,for:%v", err, data) | ||
| 473 | + resp.Message = "此档位奖励已经领取过了!" | ||
| 474 | + resp.Code = 1 | ||
| 475 | + break | ||
| 476 | + } | ||
| 477 | + | ||
| 478 | + readgold := 0 | ||
| 479 | + readgold, err = AddCoinToSdk(uuid, cfg.Free_coin, gameid, channel, REDBAGTYPE_103) | ||
| 480 | + if err != nil { | ||
| 481 | + logger.Info("GetUserInfo HandlerFetchfenredbag data failed:%v,for:%v", err, data) | ||
| 482 | + resp.Message = "后台失败!" | ||
| 483 | + resp.Code = 1 | ||
| 484 | + break | ||
| 485 | + } | ||
| 486 | + | ||
| 487 | + if rdata.Ftype == 2 { | ||
| 488 | + readgold, err = AddCoinToSdk(uuid, cfg.Video_coin, gameid, channel, REDBAGTYPE_106) | ||
| 489 | + if err != nil { | ||
| 490 | + logger.Info("GetUserInfo HandlerFetchfenredbag data failed:%v,for:%v", err, data) | ||
| 491 | + resp.Message = "后台失败!" | ||
| 492 | + resp.Code = 1 | ||
| 493 | + break | ||
| 494 | + } | ||
| 495 | + } | ||
| 496 | + | ||
| 497 | + uinfo.RealGold = readgold | ||
| 498 | + uinfo.RedBagFetchIdlist = append(uinfo.RedBagFetchIdlist, rdata.Id) | ||
| 499 | + | ||
| 500 | + resp.Data.Wallgold = uinfo.RealGold | ||
| 501 | + | ||
| 502 | + SaveUserInfo(uinfo, uniqueuuid) | ||
| 503 | + | ||
| 504 | + resp.Code = ERROR_OK | ||
| 505 | + break | ||
| 506 | + } | ||
| 507 | + | ||
| 508 | + //回包 | ||
| 509 | + respstr, _ := json.Marshal(&resp) | ||
| 510 | + fmt.Fprint(w, string(respstr)) | ||
| 511 | +} | ||
| 512 | + | ||
| 513 | +func HandlerDrawguangold(w http.ResponseWriter, data string, uniqueuuid, gameid, channel string, uuid int) { | ||
| 514 | + SetHeader(w) | ||
| 515 | + | ||
| 516 | + var resp DrawguangoldResp | ||
| 517 | + resp.Code = 0 | ||
| 518 | + var rdata DrawguangoldReq | ||
| 519 | + err := json.Unmarshal([]byte(data), &rdata) | ||
| 520 | + for { | ||
| 521 | + | ||
| 522 | + if err != nil { | ||
| 523 | + logger.Info("json decode HandlerDrawguangold data failed:%v,for:%v", err, data) | ||
| 524 | + resp.Message = "json解析错误" | ||
| 525 | + resp.Code = ERROR_JSONUNMASH_ERROR | ||
| 526 | + break | ||
| 527 | + } | ||
| 528 | + | ||
| 529 | + uinfo, err := GetUserInfo(uniqueuuid) | ||
| 530 | + if err != nil { | ||
| 531 | + logger.Info("GetUserInfo HandlerDrawguangold data failed:%v,for:%v", err, data) | ||
| 532 | + resp.Message = "GetUserInfo failed" | ||
| 533 | + resp.Code = 1 | ||
| 534 | + break | ||
| 535 | + } | ||
| 536 | + | ||
| 537 | + if rdata.Goldnum == 0 || uinfo.GuanGold < rdata.Goldnum { | ||
| 538 | + logger.Info("GetUserInfo HandlerDrawguangold data failed:%v,for:%v", err, data) | ||
| 539 | + resp.Message = "Goldnum is zero" | ||
| 540 | + resp.Code = 1 | ||
| 541 | + break | ||
| 542 | + } | ||
| 543 | + realgold, err := AddCoinToSdk(uuid, rdata.Goldnum, gameid, channel, REDBAGTYPE_105) | ||
| 544 | + if err != nil { | ||
| 545 | + logger.Info("GetUserInfo HandlerDrawguangold data failed:%v,for:%v", err, data) | ||
| 546 | + resp.Message = "后台提现失败" | ||
| 547 | + resp.Code = 1 | ||
| 548 | + break | ||
| 549 | + } | ||
| 550 | + | ||
| 551 | + uinfo.RealGold = realgold | ||
| 552 | + | ||
| 553 | + uinfo.GuanGold -= rdata.Goldnum | ||
| 554 | + | ||
| 555 | + SaveUserInfo(uinfo, uniqueuuid) | ||
| 556 | + | ||
| 557 | + resp.Code = ERROR_OK | ||
| 558 | + break | ||
| 559 | + } | ||
| 560 | + | ||
| 561 | + //回包 | ||
| 562 | + respstr, _ := json.Marshal(&resp) | ||
| 563 | + fmt.Fprint(w, string(respstr)) | ||
| 564 | +} | ||
| 565 | + | ||
| 566 | +func HandlerGetguangold(w http.ResponseWriter, data string, uniqueuuid, gameid, channel string, uuid int) { | ||
| 567 | + SetHeader(w) | ||
| 568 | + | ||
| 569 | + var resp GetguangoldResp | ||
| 570 | + resp.Code = 0 | ||
| 571 | + var rdata GetguangoldReq | ||
| 572 | + err := json.Unmarshal([]byte(data), &rdata) | ||
| 573 | + for { | ||
| 574 | + | ||
| 575 | + if err != nil { | ||
| 576 | + logger.Info("json decode HandlerGetguangold data failed:%v,for:%v", err, data) | ||
| 577 | + resp.Message = "json解析错误" | ||
| 578 | + resp.Code = ERROR_JSONUNMASH_ERROR | ||
| 579 | + break | ||
| 580 | + } | ||
| 581 | + | ||
| 582 | + uinfo, err := GetUserInfo(uniqueuuid) | ||
| 583 | + if err != nil { | ||
| 584 | + logger.Info("GetUserInfo HandlerGetguangold data failed:%v,for:%v", err, data) | ||
| 585 | + resp.Message = "GetUserInfo failed" | ||
| 586 | + resp.Code = 1 | ||
| 587 | + break | ||
| 588 | + } | ||
| 589 | + | ||
| 590 | + uinfo.GuanGold += rdata.Goldnum | ||
| 591 | + if uinfo.GuanGold > GUANGOLDNUMLIMIT { | ||
| 592 | + uinfo.GuanGold = GUANGOLDNUMLIMIT | ||
| 593 | + } | ||
| 594 | + | ||
| 595 | + resp.Data.Guangold = uinfo.GuanGold | ||
| 596 | + | ||
| 597 | + SaveUserInfo(uinfo, uniqueuuid) | ||
| 598 | + | ||
| 599 | + resp.Code = ERROR_OK | ||
| 600 | + break | ||
| 601 | + } | ||
| 602 | + | ||
| 603 | + //回包 | ||
| 604 | + respstr, _ := json.Marshal(&resp) | ||
| 605 | + fmt.Fprint(w, string(respstr)) | ||
| 606 | +} | ||
| 607 | + | ||
| 114 | func HandlerLogin(w http.ResponseWriter, data string, uniqueuuid, gameid, channel string, uuid int) { | 608 | func HandlerLogin(w http.ResponseWriter, data string, uniqueuuid, gameid, channel string, uuid int) { |
| 115 | SetHeader(w) | 609 | SetHeader(w) |
| 116 | 610 | ||
| @@ -134,6 +628,7 @@ func HandlerLogin(w http.ResponseWriter, data string, uniqueuuid, gameid, channe | @@ -134,6 +628,7 @@ func HandlerLogin(w http.ResponseWriter, data string, uniqueuuid, gameid, channe | ||
| 134 | //不存在老的数据 之间走新号流程 | 628 | //不存在老的数据 之间走新号流程 |
| 135 | err = InitUserInfo(&resp, uniqueuuid, gameid, channel, uuid) | 629 | err = InitUserInfo(&resp, uniqueuuid, gameid, channel, uuid) |
| 136 | 630 | ||
| 631 | + resp.Data.Offlinegold = 0 | ||
| 137 | } else { | 632 | } else { |
| 138 | uinfo, err := GetUserInfo(uniqueuuid) | 633 | uinfo, err := GetUserInfo(uniqueuuid) |
| 139 | 634 | ||
| @@ -148,6 +643,20 @@ func HandlerLogin(w http.ResponseWriter, data string, uniqueuuid, gameid, channe | @@ -148,6 +643,20 @@ func HandlerLogin(w http.ResponseWriter, data string, uniqueuuid, gameid, channe | ||
| 148 | resp.Data.Walletgold = uinfo.RealGold | 643 | resp.Data.Walletgold = uinfo.RealGold |
| 149 | 644 | ||
| 150 | resp.Data.Isnew = 0 | 645 | resp.Data.Isnew = 0 |
| 646 | + | ||
| 647 | + //需要计算一下是否有离线金币 | ||
| 648 | + offset := (int(time.Now().Unix()) - uinfo.LastUpdateTime) / 60 | ||
| 649 | + if offset > 10 { | ||
| 650 | + offgold := int(float32(offset-10) * 1.5) | ||
| 651 | + if offgold > 150 { | ||
| 652 | + offgold = 150 | ||
| 653 | + } | ||
| 654 | + | ||
| 655 | + uinfo.OfflineGold = offgold | ||
| 656 | + uinfo.LastUpdateTime = int(time.Now().Unix()) | ||
| 657 | + } | ||
| 658 | + | ||
| 659 | + resp.Data.Offlinegold = uinfo.OfflineGold | ||
| 151 | } | 660 | } |
| 152 | 661 | ||
| 153 | pdata, err := GetUserSelfData(uniqueuuid) | 662 | pdata, err := GetUserSelfData(uniqueuuid) |
src/common/redis/def.go
| 1 | package redis | 1 | package redis |
| 2 | 2 | ||
| 3 | const ( | 3 | const ( |
| 4 | - USER_DATA_KEY = "RUSSIAXIAOXIAO_USER_DATA_KEY" //玩家数据 | ||
| 5 | - USER_SELF_DATA_KEY = "RUSSIAXIAOXIAO_USER_SELF_DATA_KEY" //玩家自定义数据 | ||
| 6 | - USER_TASKINFO_LIST = "RUSSIAXIAOXIAO_USER_TASKINFO_LIST" //任务列表数据缓存 | ||
| 7 | - USER_ACHIEVEMENTINFO_LIST = "RUSSIAXIAOXIAO_USER_ACHIEVEMENTINFO_LIST" //成就列表数据缓存 | ||
| 8 | - | 4 | + USER_DATA_KEY = "RUSSIAXIAOXIAO_USER_DATA_KEY" //玩家数据 |
| 5 | + USER_SELF_DATA_KEY = "RUSSIAXIAOXIAO_USER_SELF_DATA_KEY" //玩家自定义数据 | ||
| 6 | + USER_TASKINFO_LIST = "RUSSIAXIAOXIAO_USER_TASKINFO_LIST" //任务列表数据缓存 | ||
| 7 | + USER_ACHIEVEMENTINFO_LIST = "RUSSIAXIAOXIAO_USER_ACHIEVEMENTINFO_LIST" //成就列表数据缓存 | ||
| 8 | + USER_SCORE_RANK = "RUSSIAXIAOXIAO_USER_SCORE_RANK" //玩家排行榜 | ||
| 9 | ) | 9 | ) |