Commit 6830c18757353786ff4246c0f28e23100b4f3a96
1 parent
27bd5638
Exists in
master
提交接口
Showing
5 changed files
with
340 additions
and
37 deletions
Show diff stats
@@ -0,0 +1,55 @@ | @@ -0,0 +1,55 @@ | ||
1 | +package logic | ||
2 | + | ||
3 | +//任务成就类型枚举 协议上报用 | ||
4 | +const ( | ||
5 | + TASKTYPE_PASSLEVEL = 1 //表示通过x关卡 | ||
6 | + TASKTYPE_GETREDBAG = 2 //领取x次红包 | ||
7 | + TASKTYPE_WATCHADS = 3 //3表示观看x次广告 | ||
8 | + TASKTYPE_KILLSTAR = 4 //4表示消除x颗星星 | ||
9 | + TASKTYPE_USEITEM = 5 //5表示使用x次道具 | ||
10 | +) | ||
11 | + | ||
12 | +//任务类型 对应表 | ||
13 | +const ( | ||
14 | + DAILY_TASKTYPE_LOGIN = 1 //1 每日登录 | ||
15 | + DAILY_TASKTYPE_GETGUANCNT = 2 //提取存钱罐 | ||
16 | + DAILY_TASKTYPE_PASSLEVEL = 3 //近日通过关 | ||
17 | + DAILY_TASKTYPE_USEITEM = 4 //使用道具数 | ||
18 | + DAILY_TASKTYPE_GETREDBAG = 5 //领取红包次数 | ||
19 | + DAILY_TASKTYPE_GETGUANGOLD = 6 //收取金币x枚 | ||
20 | + DAILY_TASKTYPE_ONLINEMIN = 7 //在线分钟数 | ||
21 | +) | ||
22 | + | ||
23 | +//成就类型 对应表 | ||
24 | +const ( | ||
25 | + ACHIEVETYPE_WATCHADDS = 1 //累计观看广告次数 | ||
26 | + ACHIEVETYPE_USERLV = 2 //人物等级 | ||
27 | + ACHIEVETYPE_KILLSTAR = 3 //累计消除星星数 | ||
28 | + ACHIEVETYPE_GETGUANCNT = 4 //累计存钱罐提取 | ||
29 | + ACHIEVETYPE_USEITEMCNT = 5 //累计道具使用 | ||
30 | + | ||
31 | +) | ||
32 | + | ||
33 | +//奖励类型枚举 | ||
34 | +const ( | ||
35 | + REWARDTYPE_STAR = 1 //星星 | ||
36 | + REWARDTYPE_CHUI = 2 | ||
37 | + REWARDTYPE_SHUA = 3 | ||
38 | + REWARDTYPE_SWAP = 4 | ||
39 | + REWARDTYPE_ELIMITE = 5 | ||
40 | + REWARDTYPE_EXP = 6 | ||
41 | + REWARDTYPE_GOLD = 7 | ||
42 | +) | ||
43 | + | ||
44 | +const ( | ||
45 | + //XIAOXINGXING_SERVERKEYTEST = "e2cd22102143cdcd9c181f962d031685" | ||
46 | + XIAOXINGXING_SERVERKEYTEST = "33e0c3238c108a36d87025544c6a2d2f" | ||
47 | + XIAOXINGXING_SERVERKEYTEST_1015 = "a81eb66afd923d24e65a4b542592bc41" | ||
48 | + //XIAOXINGXING_SDKURLOFFICAL = "https://testapi-gamesdk.d3games.com/" | ||
49 | + XIAOXINGXING_SDKURLOFFICAL = "https://api.gamesdk.hmjoy.cn/" | ||
50 | +) | ||
51 | + | ||
52 | +const ( | ||
53 | + WATCH_ADD_DAY_LIMIT = 50 //当天获取红包次数限制 | ||
54 | + ACCGOLDRATELIMIT = 3 //玩家每天看视频加速金币次数 | ||
55 | +) |
src/HttpServer/logic/datadef.go
@@ -98,9 +98,14 @@ type GenerateBoxResp struct { | @@ -98,9 +98,14 @@ type GenerateBoxResp struct { | ||
98 | type AcclecteReq struct { | 98 | type AcclecteReq struct { |
99 | //Uuid int `json:"uuid"` | 99 | //Uuid int `json:"uuid"` |
100 | } | 100 | } |
101 | +type AcclectData struct { | ||
102 | + LeftTimes int `json:"leftTimes"` | ||
103 | + Coin DoBuyCatCoin `json:"coin"` | ||
104 | +} | ||
101 | type AcclecteResp struct { | 105 | type AcclecteResp struct { |
102 | - Code int `json:"code"` | ||
103 | - Message string `json:"message"` | 106 | + Code int `json:"code"` |
107 | + Message string `json:"message"` | ||
108 | + Data AcclectData `json:"data"` | ||
104 | } | 109 | } |
105 | 110 | ||
106 | type AcclecteBoxResp struct { | 111 | type AcclecteBoxResp struct { |
@@ -288,6 +293,32 @@ type QueryPlayerRankResp struct { | @@ -288,6 +293,32 @@ type QueryPlayerRankResp struct { | ||
288 | Data []RankInfoDesc `json:"data"` | 293 | Data []RankInfoDesc `json:"data"` |
289 | } | 294 | } |
290 | 295 | ||
296 | +type CatPosInfo struct { | ||
297 | + Position int `json:"position"` | ||
298 | + Cat int `json:"cat"` | ||
299 | + RedPacket int `json:"redPacket"` | ||
300 | + Time int `json:"time"` | ||
301 | + StartTime int `json:"startTime"` | ||
302 | +} | ||
303 | + | ||
304 | +type adRateData struct { | ||
305 | + Multiple int `json:"multiple"` | ||
306 | + EndTime int `json:"endTime"` | ||
307 | +} | ||
308 | + | ||
309 | +type GetMainPageInfoData struct { | ||
310 | + LimitCatList []int `json:"limitCatList"` | ||
311 | + CatList []CatPosInfo `json:"catList"` | ||
312 | + Coin DoBuyCatCoin `json:"coin"` | ||
313 | + AdRate adRateData `json:"adRate"` | ||
314 | +} | ||
315 | + | ||
316 | +type GetMainPageInfoResp struct { | ||
317 | + Code int `json:"code"` | ||
318 | + Message string `json:"message"` | ||
319 | + Data GetMainPageInfoData `json:"data"` | ||
320 | +} | ||
321 | + | ||
291 | type QueryCompleteTaskDesc struct { | 322 | type QueryCompleteTaskDesc struct { |
292 | Taskid int `json:"taskid"` | 323 | Taskid int `json:"taskid"` |
293 | } | 324 | } |
@@ -435,7 +466,9 @@ type UserData struct { | @@ -435,7 +466,9 @@ type UserData struct { | ||
435 | Highestlv int //当前最高猫等级 | 466 | Highestlv int //当前最高猫等级 |
436 | InviteId int //邀请者uid | 467 | InviteId int //邀请者uid |
437 | CurBoxLv int //当前猫箱子等级 | 468 | CurBoxLv int //当前猫箱子等级 |
438 | - IsDouble int //当前加速标签 1表示双倍收益 0表示正常 | 469 | + IsDouble int //当前加速标签 1表示3倍收益 0表示正常 |
470 | + StartDoubleTime int //开始双倍时间 | ||
471 | + DoubleLeftTimes int //开始双倍时间 | ||
439 | IsAuto int //当前是否自动合成 | 472 | IsAuto int //当前是否自动合成 |
440 | IsBoxAcc int //是否处于加速生成箱子状态 | 473 | IsBoxAcc int //是否处于加速生成箱子状态 |
441 | RandGiftNum int //当前剩余空投猫粮次数 | 474 | RandGiftNum int //当前剩余空投猫粮次数 |
@@ -448,10 +481,11 @@ type UserData struct { | @@ -448,10 +481,11 @@ type UserData struct { | ||
448 | IsFirstRedBgCat int //是否合成过红包猫 0表示否1表示是 | 481 | IsFirstRedBgCat int //是否合成过红包猫 0表示否1表示是 |
449 | OfflineGold int64 //离线金币 | 482 | OfflineGold int64 //离线金币 |
450 | OfflineLove int64 //离线爱心 | 483 | OfflineLove int64 //离线爱心 |
484 | + LastLoginTime int //上次登陆时间 | ||
451 | CatShopInfo CatShopData //猫咖门店数据 | 485 | CatShopInfo CatShopData //猫咖门店数据 |
452 | Taskinfo TaskData //任务数据 | 486 | Taskinfo TaskData //任务数据 |
453 | AchieveMent AchieveMentData //成就数据 | 487 | AchieveMent AchieveMentData //成就数据 |
454 | - PosInfo []PosData //位置信息 从0开始 | 488 | + PosInfo []CatPosInfo //位置信息 从0开始 |
455 | BuyCatInfo []BuyCatInfoData //商店购买猫数据 第一个元素为1级猫 第二个为2级猫以此类推 | 489 | BuyCatInfo []BuyCatInfoData //商店购买猫数据 第一个元素为1级猫 第二个为2级猫以此类推 |
456 | CatRoomInfo []CatRoomData //猫咖店数据 | 490 | CatRoomInfo []CatRoomData //猫咖店数据 |
457 | 491 |
src/HttpServer/logic/function.go
@@ -6,10 +6,51 @@ import ( | @@ -6,10 +6,51 @@ import ( | ||
6 | "common/logger" | 6 | "common/logger" |
7 | "common/redis" | 7 | "common/redis" |
8 | "encoding/json" | 8 | "encoding/json" |
9 | + "sort" | ||
9 | "strconv" | 10 | "strconv" |
10 | "time" | 11 | "time" |
11 | ) | 12 | ) |
12 | 13 | ||
14 | +func (u *UserData) HandlePassDay() { | ||
15 | + isdiffday := false | ||
16 | + nowtime := time.Now() | ||
17 | + lasttime := time.Unix(int64(u.LastLoginTime), 0) | ||
18 | + nowdaynum := time.Now().Day() | ||
19 | + lastdaynum := time.Unix(int64(u.LastLoginTime), 0).Day() | ||
20 | + nowtimestamp := time.Date(nowtime.Year(), nowtime.Month(), nowtime.Day(), 0, 0, 0, 0, nowtime.Location()) | ||
21 | + lasttimestamp := time.Date(lasttime.Year(), lasttime.Month(), lasttime.Day(), 0, 0, 0, 0, lasttime.Location()) | ||
22 | + | ||
23 | + logger.Info("HandlePassDay lasttime=%v,lasttimestamp=%v", lasttime, lasttimestamp) | ||
24 | + if nowdaynum == lastdaynum { | ||
25 | + //同一天 | ||
26 | + if int64(u.LastLoginTime)-time.Now().Unix() > 86400 { | ||
27 | + //已经过了很多天了 | ||
28 | + | ||
29 | + isdiffday = true | ||
30 | + } else { | ||
31 | + //t同一天 不做处理 | ||
32 | + } | ||
33 | + } else { | ||
34 | + //不是同一天了 | ||
35 | + isdiffday = true | ||
36 | + if nowtimestamp.Unix() != lasttimestamp.Unix()+86400 { | ||
37 | + | ||
38 | + } else { | ||
39 | + | ||
40 | + } | ||
41 | + logger.Info("HandlePassDay now=%v,last=%v", nowtimestamp.Unix(), lasttimestamp.Unix()) | ||
42 | + } | ||
43 | + | ||
44 | + if isdiffday { | ||
45 | + //跨天了 | ||
46 | + u.DoubleLeftTimes = ACCGOLDRATELIMIT | ||
47 | + } | ||
48 | + | ||
49 | + u.LastLoginTime = int(nowtime.Unix()) | ||
50 | + | ||
51 | + SaveUserInfo(u, strconv.Itoa(u.UserId)) | ||
52 | +} | ||
53 | + | ||
13 | func SaveUserInfo(data *UserData, uniqueid string) error { | 54 | func SaveUserInfo(data *UserData, uniqueid string) error { |
14 | 55 | ||
15 | savestr, err := json.Marshal(data) | 56 | savestr, err := json.Marshal(data) |
@@ -54,12 +95,15 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int) { | @@ -54,12 +95,15 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int) { | ||
54 | udata.RandGiftTime = int(time.Now().Unix()) | 95 | udata.RandGiftTime = int(time.Now().Unix()) |
55 | udata.Redbag = 0 | 96 | udata.Redbag = 0 |
56 | udata.IsFirstRedBgCat = 0 | 97 | udata.IsFirstRedBgCat = 0 |
98 | + udata.DoubleLeftTimes = ACCGOLDRATELIMIT | ||
99 | + udata.RegTime = int(time.Now().Unix()) | ||
100 | + udata.LastLoginTime = int(time.Now().Unix()) | ||
57 | 101 | ||
58 | //初始化16个猫爬架 | 102 | //初始化16个猫爬架 |
59 | for i := 0; i < 16; i++ { | 103 | for i := 0; i < 16; i++ { |
60 | - var d1 PosData | ||
61 | - d1.Pos = i | ||
62 | - d1.Catlv = 0 | 104 | + var d1 CatPosInfo |
105 | + d1.Position = i | ||
106 | + d1.Cat = 0 | ||
63 | udata.PosInfo = append(udata.PosInfo, d1) | 107 | udata.PosInfo = append(udata.PosInfo, d1) |
64 | var d2 DataDesc | 108 | var d2 DataDesc |
65 | d2.Pos = i | 109 | d2.Pos = i |
@@ -118,9 +162,9 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int) { | @@ -118,9 +162,9 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int) { | ||
118 | func getCatPutPos(uinfo *UserData, clv int) int { | 162 | func getCatPutPos(uinfo *UserData, clv int) int { |
119 | pos := -1 | 163 | pos := -1 |
120 | for k, v := range uinfo.PosInfo { | 164 | for k, v := range uinfo.PosInfo { |
121 | - if v.Catlv == 0 { | ||
122 | - uinfo.PosInfo[k].Catlv = clv | ||
123 | - uinfo.PosInfo[k].Pos = k | 165 | + if v.Cat == 0 { |
166 | + uinfo.PosInfo[k].Cat = clv | ||
167 | + uinfo.PosInfo[k].Position = k | ||
124 | //v.Catlv = clv | 168 | //v.Catlv = clv |
125 | //v.Pos = k | 169 | //v.Pos = k |
126 | pos = k | 170 | pos = k |
@@ -140,11 +184,11 @@ func (udata *UserData) CalcGoldRate() int64 { | @@ -140,11 +184,11 @@ func (udata *UserData) CalcGoldRate() int64 { | ||
140 | return 0 | 184 | return 0 |
141 | } | 185 | } |
142 | for _, v := range udata.PosInfo { | 186 | for _, v := range udata.PosInfo { |
143 | - if v.Catlv > 0 && v.Catlv < 100 { | 187 | + if v.Cat > 0 && v.Cat < 100 { |
144 | //有猫存在的要计算一下 | 188 | //有猫存在的要计算一下 |
145 | //非红包猫 | 189 | //非红包猫 |
146 | for _, vv := range jsonconf.GetJsonConf().CatConfig { | 190 | for _, vv := range jsonconf.GetJsonConf().CatConfig { |
147 | - if vv.Id == v.Catlv { | 191 | + if vv.Id == v.Cat { |
148 | onerate, _ := strconv.ParseInt(vv.Gold_get, 10, 64) | 192 | onerate, _ := strconv.ParseInt(vv.Gold_get, 10, 64) |
149 | sumrate += onerate | 193 | sumrate += onerate |
150 | break | 194 | break |
@@ -152,16 +196,16 @@ func (udata *UserData) CalcGoldRate() int64 { | @@ -152,16 +196,16 @@ func (udata *UserData) CalcGoldRate() int64 { | ||
152 | } | 196 | } |
153 | } | 197 | } |
154 | 198 | ||
155 | - if v.Catlv > 100 { | 199 | + if v.Cat > 100 { |
156 | //红包猫 需要判断是否产金币 | 200 | //红包猫 需要判断是否产金币 |
157 | - rcfg := jsonconf.GetRedCatConfig(v.Catlv) | 201 | + rcfg := jsonconf.GetRedCatConfig(v.Cat) |
158 | if rcfg != nil { | 202 | if rcfg != nil { |
159 | if rcfg.Is_37 != 0 { | 203 | if rcfg.Is_37 != 0 { |
160 | onerate, _ := strconv.ParseInt(cfg37.Gold_get, 10, 64) | 204 | onerate, _ := strconv.ParseInt(cfg37.Gold_get, 10, 64) |
161 | sumrate += onerate | 205 | sumrate += onerate |
162 | } | 206 | } |
163 | } else { | 207 | } else { |
164 | - logger.Error("GetRedCatConfig failed lv=%v", v.Catlv) | 208 | + logger.Error("GetRedCatConfig failed lv=%v", v.Cat) |
165 | } | 209 | } |
166 | } | 210 | } |
167 | } | 211 | } |
@@ -189,6 +233,7 @@ func (udata *UserData) CalcGoldRate() int64 { | @@ -189,6 +233,7 @@ func (udata *UserData) CalcGoldRate() int64 { | ||
189 | } | 233 | } |
190 | } | 234 | } |
191 | 235 | ||
236 | + udata.Goldrate = sumrate | ||
192 | return sumrate | 237 | return sumrate |
193 | } | 238 | } |
194 | 239 | ||
@@ -205,8 +250,8 @@ func (udata *UserData) AddToRank() error { | @@ -205,8 +250,8 @@ func (udata *UserData) AddToRank() error { | ||
205 | func (u *UserData) CalcHigestCatName() string { | 250 | func (u *UserData) CalcHigestCatName() string { |
206 | higestlv := 0 | 251 | higestlv := 0 |
207 | for _, val := range u.PosInfo { | 252 | for _, val := range u.PosInfo { |
208 | - if higestlv < val.Catlv { | ||
209 | - higestlv = val.Catlv | 253 | + if higestlv < val.Cat { |
254 | + higestlv = val.Cat | ||
210 | } | 255 | } |
211 | } | 256 | } |
212 | 257 | ||
@@ -247,3 +292,36 @@ func (u *UserData) CalcHigestCatName() string { | @@ -247,3 +292,36 @@ func (u *UserData) CalcHigestCatName() string { | ||
247 | } | 292 | } |
248 | 293 | ||
249 | } | 294 | } |
295 | + | ||
296 | +//获取红包猫列表 | ||
297 | +func (u *UserData) GetRedCatIdList() []int { | ||
298 | + var rtsl []int | ||
299 | + for _, val := range u.PosInfo { | ||
300 | + if val.Cat > 100 { | ||
301 | + rtsl = append(rtsl, val.Cat-100) | ||
302 | + } | ||
303 | + } | ||
304 | + | ||
305 | + udatastr, err := redishandler.GetRedisClient().HGet(redis.USER_WAREHOUSE_INFO, strconv.Itoa(u.UserId)) | ||
306 | + if err != nil { | ||
307 | + logger.Error("CalcGoldRate failed err=%v", err) | ||
308 | + return rtsl | ||
309 | + } | ||
310 | + wdata := new(UserWareHouseData) | ||
311 | + err = json.Unmarshal([]byte(udatastr), wdata) | ||
312 | + if err != nil { | ||
313 | + logger.Error("CalcGoldRate Unmarshal redis failed ") | ||
314 | + return rtsl | ||
315 | + } | ||
316 | + for _, val := range wdata.Info { | ||
317 | + rtsl = append(rtsl, val.Warelv) | ||
318 | + } | ||
319 | + | ||
320 | + if len(rtsl) > 16 { | ||
321 | + sort.Ints(rtsl) | ||
322 | + return rtsl[:len(rtsl)-16] | ||
323 | + } else { | ||
324 | + return rtsl | ||
325 | + } | ||
326 | + | ||
327 | +} |
src/HttpServer/logic/httpserver.go
@@ -172,31 +172,33 @@ func startServerHttpServe() { | @@ -172,31 +172,33 @@ func startServerHttpServe() { | ||
172 | http.HandleFunc("/api/home/buy", DoBuyCat) //购买猫 | 172 | http.HandleFunc("/api/home/buy", DoBuyCat) //购买猫 |
173 | http.HandleFunc("/api/home/synResource", GetUserData) //同步资源 | 173 | http.HandleFunc("/api/home/synResource", GetUserData) //同步资源 |
174 | http.HandleFunc("/api/home/recvOfflineReward", GetOfflineReward) //领取离线奖励 | 174 | http.HandleFunc("/api/home/recvOfflineReward", GetOfflineReward) //领取离线奖励 |
175 | - http.HandleFunc("api/ranking/list", QueryPlayerRank) //排行榜 | 175 | + http.HandleFunc("/api/ranking/list", QueryPlayerRank) //排行榜 |
176 | + http.HandleFunc("/api/home/index", GetMainPageInfo) //主页面 | ||
177 | + http.HandleFunc("/api/home/adRate", AcclecteGold) //看广告加速 | ||
176 | 178 | ||
177 | http.HandleFunc("/happycat/exchangetwoPos", ExchangePos) //交换位置 | 179 | http.HandleFunc("/happycat/exchangetwoPos", ExchangePos) //交换位置 |
178 | http.HandleFunc("/happycat/clickcatbox", ClickCatBox) //请求点击猫箱子 | 180 | http.HandleFunc("/happycat/clickcatbox", ClickCatBox) //请求点击猫箱子 |
179 | http.HandleFunc("/happycat/upgradecatbox", UpgradeCatBox) //请求点击猫箱子 | 181 | http.HandleFunc("/happycat/upgradecatbox", UpgradeCatBox) //请求点击猫箱子 |
180 | - http.HandleFunc("/happycat/acclecte", AcclecteGold) //请求点击猫箱子 | 182 | + //http.HandleFunc("/happycat/acclecte", AcclecteGold) //请求点击猫箱子 |
181 | http.HandleFunc("/happycat/automerge", AutoMerge) //请求自动合成 | 183 | http.HandleFunc("/happycat/automerge", AutoMerge) //请求自动合成 |
182 | http.HandleFunc("/happycat/generatebox", GenerateBox) //请求点击猫箱子 | 184 | http.HandleFunc("/happycat/generatebox", GenerateBox) //请求点击猫箱子 |
183 | http.HandleFunc("/happycat/clickrandgift", ClickRandGift) //请求点击猫箱子 | 185 | http.HandleFunc("/happycat/clickrandgift", ClickRandGift) //请求点击猫箱子 |
184 | http.HandleFunc("/happycat/querybuycat", QueryBuyCat) //请求商店购买信息 | 186 | http.HandleFunc("/happycat/querybuycat", QueryBuyCat) //请求商店购买信息 |
185 | 187 | ||
186 | - http.HandleFunc("/happycat/querwarehouse", QueryWareHouse) //请求仓库信息 | ||
187 | - http.HandleFunc("/happycat/putcattowarehouse", PutCattoWareHouse) //将合成界面的猫放入仓库 | ||
188 | - http.HandleFunc("/happycat/takecatoutfromwarehouse", TakeCatoutfromWareHouse) //将仓库的猫取出 | ||
189 | - http.HandleFunc("/happycat/acclecteboxrate ", AcclecteBoxRate) //请求点击猫箱子 | ||
190 | - http.HandleFunc("/happycat/queryautomergeinfo ", QueryAutomergeInfo) //请求点击猫箱子 | ||
191 | - http.HandleFunc("/happycat/querycatroominfo ", QueryCatRoomInfo) //请求点击猫箱子 | ||
192 | - http.HandleFunc("/happycat/buycatroom ", BuyCatRoom) //请求点击猫箱子 | ||
193 | - http.HandleFunc("/happycat/upcattoroom ", UpCattoRoom) //请求点击猫箱子 | ||
194 | - http.HandleFunc("/happycat/querycatshopinfo ", QueryCatShopInfo) //请求点击猫箱子 | ||
195 | - http.HandleFunc("/happycat/catshoplay ", CatShoPlay) //请求点击猫箱子 | ||
196 | - http.HandleFunc("/happycat/getcatshopreward ", GetCatShopReward) //请求点击猫箱子 | ||
197 | - http.HandleFunc("/happycat/acclectecatstory ", AcclecteCatStory) //请求点击猫箱子 | ||
198 | - http.HandleFunc("/chappycatat/updateuserinfo ", UpdateUserInfo) //请求点击猫箱子 | ||
199 | - http.HandleFunc("/happycat/queryplayerrank ", QueryPlayerRank) //请求点击猫箱子 | 188 | + http.HandleFunc("/happycat/querwarehouse", QueryWareHouse) //请求仓库信息 |
189 | + http.HandleFunc("/happycat/putcattowarehouse", PutCattoWareHouse) //将合成界面的猫放入仓库 | ||
190 | + http.HandleFunc("/happycat/takecatoutfromwarehouse", TakeCatoutfromWareHouse) //将仓库的猫取出 | ||
191 | + http.HandleFunc("/happycat/acclecteboxrate ", AcclecteBoxRate) //请求点击猫箱子 | ||
192 | + http.HandleFunc("/happycat/queryautomergeinfo ", QueryAutomergeInfo) //请求点击猫箱子 | ||
193 | + http.HandleFunc("/happycat/querycatroominfo ", QueryCatRoomInfo) //请求点击猫箱子 | ||
194 | + http.HandleFunc("/happycat/buycatroom ", BuyCatRoom) //请求点击猫箱子 | ||
195 | + http.HandleFunc("/happycat/upcattoroom ", UpCattoRoom) //请求点击猫箱子 | ||
196 | + http.HandleFunc("/happycat/querycatshopinfo ", QueryCatShopInfo) //请求点击猫箱子 | ||
197 | + http.HandleFunc("/happycat/catshoplay ", CatShoPlay) //请求点击猫箱子 | ||
198 | + http.HandleFunc("/happycat/getcatshopreward ", GetCatShopReward) //请求点击猫箱子 | ||
199 | + http.HandleFunc("/happycat/acclectecatstory ", AcclecteCatStory) //请求点击猫箱子 | ||
200 | + http.HandleFunc("/chappycatat/updateuserinfo ", UpdateUserInfo) //请求点击猫箱子 | ||
201 | + //http.HandleFunc("/happycat/queryplayerrank ", QueryPlayerRank) //请求点击猫箱子 | ||
200 | http.HandleFunc("/happycat/querycompletetask ", QueryCompleteTask) //请求点击猫箱子 | 202 | http.HandleFunc("/happycat/querycompletetask ", QueryCompleteTask) //请求点击猫箱子 |
201 | http.HandleFunc("/happycat/querycompleteachievement ", QueryCompleteAchievement) //请求点击猫箱子 | 203 | http.HandleFunc("/happycat/querycompleteachievement ", QueryCompleteAchievement) //请求点击猫箱子 |
202 | http.HandleFunc("/happycat/gettaskreward ", GetTaskReward) //请求点击猫箱子 | 204 | http.HandleFunc("/happycat/gettaskreward ", GetTaskReward) //请求点击猫箱子 |
@@ -334,6 +336,24 @@ func UpdateUserInfo(w http.ResponseWriter, r *http.Request) { | @@ -334,6 +336,24 @@ func UpdateUserInfo(w http.ResponseWriter, r *http.Request) { | ||
334 | //HandlerUpdateUserInfo(w, s, Uuid) | 336 | //HandlerUpdateUserInfo(w, s, Uuid) |
335 | } | 337 | } |
336 | 338 | ||
339 | +func GetMainPageInfo(w http.ResponseWriter, r *http.Request) { | ||
340 | + Uuid := 0 | ||
341 | + if len(r.Header) > 0 { | ||
342 | + Uuid, _ = strconv.Atoi(r.Header.Get("uid")) | ||
343 | + } | ||
344 | + if Uuid == 0 { | ||
345 | + SetHeader(w) | ||
346 | + return | ||
347 | + } | ||
348 | + result, _ := ioutil.ReadAll(r.Body) | ||
349 | + r.Body.Close() | ||
350 | + | ||
351 | + s := string(result) | ||
352 | + logger.Info("GetMainPageInfo , body:%v,uuid=%v", s, Uuid) | ||
353 | + | ||
354 | + HandlerGetMainPageInfo(w, s, Uuid) | ||
355 | +} | ||
356 | + | ||
337 | func QueryPlayerRank(w http.ResponseWriter, r *http.Request) { | 357 | func QueryPlayerRank(w http.ResponseWriter, r *http.Request) { |
338 | Uuid := 0 | 358 | Uuid := 0 |
339 | if len(r.Header) > 0 { | 359 | if len(r.Header) > 0 { |
@@ -697,7 +717,7 @@ func AcclecteBoxRate(w http.ResponseWriter, r *http.Request) { | @@ -697,7 +717,7 @@ func AcclecteBoxRate(w http.ResponseWriter, r *http.Request) { | ||
697 | func AcclecteGold(w http.ResponseWriter, r *http.Request) { | 717 | func AcclecteGold(w http.ResponseWriter, r *http.Request) { |
698 | Uuid := 0 | 718 | Uuid := 0 |
699 | if len(r.Header) > 0 { | 719 | if len(r.Header) > 0 { |
700 | - Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) | 720 | + Uuid, _ = strconv.Atoi(r.Header.Get("uid")) |
701 | } | 721 | } |
702 | if Uuid == 0 { | 722 | if Uuid == 0 { |
703 | SetHeader(w) | 723 | SetHeader(w) |
@@ -709,7 +729,7 @@ func AcclecteGold(w http.ResponseWriter, r *http.Request) { | @@ -709,7 +729,7 @@ func AcclecteGold(w http.ResponseWriter, r *http.Request) { | ||
709 | s := string(result) | 729 | s := string(result) |
710 | logger.Info("AcclecteGold , body:%v,uuid=%v", s, Uuid) | 730 | logger.Info("AcclecteGold , body:%v,uuid=%v", s, Uuid) |
711 | 731 | ||
712 | - // HandlerAcclecteGold(w, s, Uuid) | 732 | + HandlerAcclecteGold(w, s, Uuid) |
713 | } | 733 | } |
714 | 734 | ||
715 | func ExchangePos(w http.ResponseWriter, r *http.Request) { | 735 | func ExchangePos(w http.ResponseWriter, r *http.Request) { |
src/HttpServer/logic/logic.go
@@ -69,7 +69,8 @@ func HandlerLogin(w http.ResponseWriter, data string, uuid int, token string) { | @@ -69,7 +69,8 @@ func HandlerLogin(w http.ResponseWriter, data string, uuid int, token string) { | ||
69 | resp.Data.AccessToken = token | 69 | resp.Data.AccessToken = token |
70 | resp.Data.HeadImg = uinfo.Head | 70 | resp.Data.HeadImg = uinfo.Head |
71 | resp.Data.LoginType = rdata.Lype | 71 | resp.Data.LoginType = rdata.Lype |
72 | - | 72 | + uinfo.LastLoginTime = int(time.Now().Unix()) |
73 | + SaveUserInfo(uinfo, strconv.Itoa(uuid)) | ||
73 | } | 74 | } |
74 | 75 | ||
75 | //回包 | 76 | //回包 |
@@ -203,6 +204,8 @@ func HandlerGetUserData(w http.ResponseWriter, data string, uuid int) { | @@ -203,6 +204,8 @@ func HandlerGetUserData(w http.ResponseWriter, data string, uuid int) { | ||
203 | resp.Message = "get userinfo failed" | 204 | resp.Message = "get userinfo failed" |
204 | break | 205 | break |
205 | } | 206 | } |
207 | + //处理一下跨天了 | ||
208 | + uinfo.HandlePassDay() | ||
206 | 209 | ||
207 | if nowtime-int64(lasttime) > 5*60 { | 210 | if nowtime-int64(lasttime) > 5*60 { |
208 | //算离线收益 | 211 | //算离线收益 |
@@ -220,10 +223,34 @@ func HandlerGetUserData(w http.ResponseWriter, data string, uuid int) { | @@ -220,10 +223,34 @@ func HandlerGetUserData(w http.ResponseWriter, data string, uuid int) { | ||
220 | resp.Data.OfflineReward.Income = strconv.FormatInt(uinfo.OfflineGold, 10) | 223 | resp.Data.OfflineReward.Income = strconv.FormatInt(uinfo.OfflineGold, 10) |
221 | } else { | 224 | } else { |
222 | //按费离线收益计算 | 225 | //按费离线收益计算 |
226 | + //先计算一下双倍时间是否过期了 | ||
227 | + addgold := int64(0) | ||
223 | offsec := nowtime - int64(lasttime) | 228 | offsec := nowtime - int64(lasttime) |
229 | + if uinfo.IsDouble == 1 { | ||
230 | + if nowtime > int64(uinfo.IsDouble+150) { | ||
231 | + | ||
232 | + //加速过期了 | ||
233 | + //计算部分三倍的 | ||
234 | + if lasttime > uinfo.IsDouble+150 { | ||
235 | + addgold = uinfo.Goldrate * offsec | ||
236 | + } else { | ||
237 | + noroffsec := nowtime - int64(uinfo.IsDouble+150) | ||
238 | + accoffsec := offsec - noroffsec | ||
239 | + addgold = uinfo.Goldrate*accoffsec*3 + noroffsec*uinfo.Goldrate | ||
240 | + } | ||
241 | + uinfo.IsDouble = 0 | ||
242 | + uinfo.StartDoubleTime = 0 | ||
243 | + | ||
244 | + } else { | ||
245 | + //还在加速期 | ||
246 | + addgold = uinfo.Goldrate * offsec * 3 | ||
247 | + } | ||
248 | + | ||
249 | + } | ||
250 | + | ||
224 | resp.Data.TimingReward = true | 251 | resp.Data.TimingReward = true |
225 | resp.Data.Now = int(time.Now().Unix()) | 252 | resp.Data.Now = int(time.Now().Unix()) |
226 | - addgold := uinfo.Goldrate * offsec | 253 | + |
227 | uinfo.Gold = addgold | 254 | uinfo.Gold = addgold |
228 | uinfo.GoldSum += addgold | 255 | uinfo.GoldSum += addgold |
229 | uinfo.AddToRank() | 256 | uinfo.AddToRank() |
@@ -336,3 +363,92 @@ func HandlerQueryPlayerRank(w http.ResponseWriter, data string, uuid int) { | @@ -336,3 +363,92 @@ func HandlerQueryPlayerRank(w http.ResponseWriter, data string, uuid int) { | ||
336 | respstr, _ := json.Marshal(&resp) | 363 | respstr, _ := json.Marshal(&resp) |
337 | fmt.Fprint(w, string(respstr)) | 364 | fmt.Fprint(w, string(respstr)) |
338 | } | 365 | } |
366 | + | ||
367 | +func HandlerGetMainPageInfo(w http.ResponseWriter, data string, uuid int) { | ||
368 | + SetHeader(w) | ||
369 | + var resp GetMainPageInfoResp | ||
370 | + resp.Code = 0 | ||
371 | + resp.Message = "success" | ||
372 | + for { | ||
373 | + uinfo, err := GetUserInfo(strconv.Itoa(uuid)) | ||
374 | + if err != nil || uinfo == nil { | ||
375 | + logger.Error("HandlerGetMainPageInfo getuserinfo failed=%v", err) | ||
376 | + resp.Code = 1 | ||
377 | + resp.Message = "get userinfo failed" | ||
378 | + break | ||
379 | + } | ||
380 | + redlist := uinfo.GetRedCatIdList() | ||
381 | + resp.Data.LimitCatList = append(resp.Data.LimitCatList, redlist...) | ||
382 | + | ||
383 | + resp.Data.CatList = append(resp.Data.CatList, uinfo.PosInfo...) | ||
384 | + resp.Data.Coin.UserId = uuid | ||
385 | + resp.Data.Coin.Coin = strconv.FormatInt(uinfo.Gold, 10) | ||
386 | + resp.Data.Coin.UpdateTime = int(time.Now().Unix()) | ||
387 | + resp.Data.Coin.IcomeRate = strconv.FormatInt(uinfo.Goldrate, 10) | ||
388 | + resp.Data.AdRate.Multiple = 1 | ||
389 | + if uinfo.IsDouble == 1 { | ||
390 | + resp.Data.AdRate.Multiple = 3 | ||
391 | + resp.Data.AdRate.EndTime = uinfo.StartDoubleTime + 150 | ||
392 | + accrate := uinfo.Goldrate * 3 | ||
393 | + resp.Data.Coin.IcomeRate = strconv.FormatInt(accrate, 10) | ||
394 | + } | ||
395 | + resp.Code = 0 | ||
396 | + break | ||
397 | + } | ||
398 | + | ||
399 | + //回包 | ||
400 | + respstr, _ := json.Marshal(&resp) | ||
401 | + fmt.Fprint(w, string(respstr)) | ||
402 | +} | ||
403 | + | ||
404 | +func HandlerAcclecteGold(w http.ResponseWriter, data string, uuid int) { | ||
405 | + SetHeader(w) | ||
406 | + var resp AcclecteResp | ||
407 | + resp.Code = 0 | ||
408 | + resp.Message = "success" | ||
409 | + | ||
410 | + for { | ||
411 | + | ||
412 | + uinfo, err := GetUserInfo(strconv.Itoa(uuid)) | ||
413 | + if err != nil || uinfo == nil { | ||
414 | + logger.Error("HandlerAcclecteGold getuserinfo failed=%v", err) | ||
415 | + resp.Code = 1 | ||
416 | + resp.Message = "get userinfo failed" | ||
417 | + break | ||
418 | + } | ||
419 | + | ||
420 | + if uinfo.IsDouble == 1 { | ||
421 | + //已经是加速状态 | ||
422 | + logger.Error("HandlerAcclecteGold alreadyacclete failed=%v", err) | ||
423 | + resp.Code = 1 | ||
424 | + resp.Message = "alreadyacclete" | ||
425 | + break | ||
426 | + } | ||
427 | + if uinfo.DoubleLeftTimes <= 0 { | ||
428 | + //不够次数了 | ||
429 | + logger.Error("HandlerAcclecteGold not enoughtimes failed=%v", err) | ||
430 | + resp.Code = 1 | ||
431 | + resp.Message = "enoughtimes" | ||
432 | + break | ||
433 | + } | ||
434 | + | ||
435 | + uinfo.IsDouble = 1 | ||
436 | + uinfo.StartDoubleTime = int(time.Now().Unix()) | ||
437 | + uinfo.DoubleLeftTimes-- | ||
438 | + | ||
439 | + SaveUserInfo(uinfo, strconv.Itoa(uuid)) | ||
440 | + | ||
441 | + resp.Data.LeftTimes = uinfo.DoubleLeftTimes | ||
442 | + resp.Data.Coin.UserId = uuid | ||
443 | + resp.Data.Coin.Coin = strconv.FormatInt(uinfo.Gold, 10) | ||
444 | + accrate := uinfo.Goldrate * 3 | ||
445 | + resp.Data.Coin.IcomeRate = strconv.FormatInt(accrate, 10) | ||
446 | + resp.Data.Coin.UpdateTime = int(time.Now().Unix()) | ||
447 | + resp.Code = 0 | ||
448 | + break | ||
449 | + } | ||
450 | + | ||
451 | + //回包 | ||
452 | + respstr, _ := json.Marshal(&resp) | ||
453 | + fmt.Fprint(w, string(respstr)) | ||
454 | +} |