Commit a9938a561ae10602c192aa8a22e508422a10c89c
1 parent
57a74a10
Exists in
ver2.3.6
提交
Showing
7 changed files
with
506 additions
and
0 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,186 @@ |
| 1 | +[ | |
| 2 | + { | |
| 3 | + "id": 3, | |
| 4 | + "tasktype": 2, | |
| 5 | + "aims": 2, | |
| 6 | + "taskdes": "累计使用%d%次道具", | |
| 7 | + "active": 4, | |
| 8 | + "days": 1 | |
| 9 | + }, | |
| 10 | + { | |
| 11 | + "id": 4, | |
| 12 | + "tasktype": 1, | |
| 13 | + "aims": 8, | |
| 14 | + "taskdes": "合到数字%d%", | |
| 15 | + "active": 4, | |
| 16 | + "days": 2 | |
| 17 | + }, | |
| 18 | + { | |
| 19 | + "id": 5, | |
| 20 | + "tasktype": 4, | |
| 21 | + "aims": 20, | |
| 22 | + "taskdes": "累计赚到%d%元", | |
| 23 | + "active": 4, | |
| 24 | + "days": 2 | |
| 25 | + }, | |
| 26 | + { | |
| 27 | + "id": 6, | |
| 28 | + "tasktype": 2, | |
| 29 | + "aims": 5, | |
| 30 | + "taskdes": "累计使用%d%次道具", | |
| 31 | + "active": 4, | |
| 32 | + "days": 2 | |
| 33 | + }, | |
| 34 | + { | |
| 35 | + "id": 7, | |
| 36 | + "tasktype": 5, | |
| 37 | + "aims": 15, | |
| 38 | + "taskdes": "累计过%d%关", | |
| 39 | + "active": 4, | |
| 40 | + "days": 3 | |
| 41 | + }, | |
| 42 | + { | |
| 43 | + "id": 8, | |
| 44 | + "tasktype": 4, | |
| 45 | + "aims": 30, | |
| 46 | + "taskdes": "累计赚到%d%元", | |
| 47 | + "active": 4, | |
| 48 | + "days": 3 | |
| 49 | + }, | |
| 50 | + { | |
| 51 | + "id": 9, | |
| 52 | + "tasktype": 3, | |
| 53 | + "aims": 50, | |
| 54 | + "taskdes": "累计观看%d%次广告", | |
| 55 | + "active": 4, | |
| 56 | + "days": 3 | |
| 57 | + }, | |
| 58 | + { | |
| 59 | + "id": 10, | |
| 60 | + "tasktype": 1, | |
| 61 | + "aims": 12, | |
| 62 | + "taskdes": "合到数字%d%", | |
| 63 | + "active": 4, | |
| 64 | + "days": 4 | |
| 65 | + }, | |
| 66 | + { | |
| 67 | + "id": 11, | |
| 68 | + "tasktype": 5, | |
| 69 | + "aims": 20, | |
| 70 | + "taskdes": "累计过%d%关", | |
| 71 | + "active": 4, | |
| 72 | + "days": 4 | |
| 73 | + }, | |
| 74 | + { | |
| 75 | + "id": 12, | |
| 76 | + "tasktype": 4, | |
| 77 | + "aims": 40, | |
| 78 | + "taskdes": "累计赚到%d%元", | |
| 79 | + "active": 4, | |
| 80 | + "days": 4 | |
| 81 | + }, | |
| 82 | + { | |
| 83 | + "id": 13, | |
| 84 | + "tasktype": 2, | |
| 85 | + "aims": 15, | |
| 86 | + "taskdes": "累计使用%d%次道具", | |
| 87 | + "active": 4, | |
| 88 | + "days": 4 | |
| 89 | + }, | |
| 90 | + { | |
| 91 | + "id": 14, | |
| 92 | + "tasktype": 5, | |
| 93 | + "aims": 30, | |
| 94 | + "taskdes": "累计过%d%关", | |
| 95 | + "active": 4, | |
| 96 | + "days": 5 | |
| 97 | + }, | |
| 98 | + { | |
| 99 | + "id": 15, | |
| 100 | + "tasktype": 4, | |
| 101 | + "aims": 50, | |
| 102 | + "taskdes": "累计赚到%d%元", | |
| 103 | + "active": 4, | |
| 104 | + "days": 5 | |
| 105 | + }, | |
| 106 | + { | |
| 107 | + "id": 16, | |
| 108 | + "tasktype": 2, | |
| 109 | + "aims": 30, | |
| 110 | + "taskdes": "累计使用%d%次道具", | |
| 111 | + "active": 4, | |
| 112 | + "days": 5 | |
| 113 | + }, | |
| 114 | + { | |
| 115 | + "id": 17, | |
| 116 | + "tasktype": 3, | |
| 117 | + "aims": 100, | |
| 118 | + "taskdes": "累计观看%d%次广告", | |
| 119 | + "active": 4, | |
| 120 | + "days": 5 | |
| 121 | + }, | |
| 122 | + { | |
| 123 | + "id": 18, | |
| 124 | + "tasktype": 1, | |
| 125 | + "aims": 15, | |
| 126 | + "taskdes": "合到数字%d%", | |
| 127 | + "active": 4, | |
| 128 | + "days": 6 | |
| 129 | + }, | |
| 130 | + { | |
| 131 | + "id": 19, | |
| 132 | + "tasktype": 4, | |
| 133 | + "aims": 60, | |
| 134 | + "taskdes": "累计赚到%d%元", | |
| 135 | + "active": 4, | |
| 136 | + "days": 6 | |
| 137 | + }, | |
| 138 | + { | |
| 139 | + "id": 20, | |
| 140 | + "tasktype": 2, | |
| 141 | + "aims": 50, | |
| 142 | + "taskdes": "累计使用%d%次道具", | |
| 143 | + "active": 4, | |
| 144 | + "days": 6 | |
| 145 | + }, | |
| 146 | + { | |
| 147 | + "id": 21, | |
| 148 | + "tasktype": 3, | |
| 149 | + "aims": 200, | |
| 150 | + "taskdes": "累计观看%d%次广告", | |
| 151 | + "active": 4, | |
| 152 | + "days": 6 | |
| 153 | + }, | |
| 154 | + { | |
| 155 | + "id": 22, | |
| 156 | + "tasktype": 5, | |
| 157 | + "aims": 100, | |
| 158 | + "taskdes": "累计过%d%关", | |
| 159 | + "active": 4, | |
| 160 | + "days": 7 | |
| 161 | + }, | |
| 162 | + { | |
| 163 | + "id": 23, | |
| 164 | + "tasktype": 4, | |
| 165 | + "aims": 100, | |
| 166 | + "taskdes": "累计赚到%d%元", | |
| 167 | + "active": 4, | |
| 168 | + "days": 7 | |
| 169 | + }, | |
| 170 | + { | |
| 171 | + "id": 24, | |
| 172 | + "tasktype": 2, | |
| 173 | + "aims": 100, | |
| 174 | + "taskdes": "累计使用%d%次道具", | |
| 175 | + "active": 4, | |
| 176 | + "days": 7 | |
| 177 | + }, | |
| 178 | + { | |
| 179 | + "id": 25, | |
| 180 | + "tasktype": 3, | |
| 181 | + "aims": 500, | |
| 182 | + "taskdes": "累计观看%d%次广告", | |
| 183 | + "active": 4, | |
| 184 | + "days": 7 | |
| 185 | + } | |
| 186 | +] | |
| 0 | 187 | \ No newline at end of file | ... | ... |
src/HttpServer/jsonconf/jsonconf.go
| ... | ... | @@ -82,6 +82,15 @@ type RedpacketConfigDesc struct { |
| 82 | 82 | Cash int `json:"cash"` |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | +type NewTaskConfigDesc struct { | |
| 86 | + Id int `json:"id"` | |
| 87 | + Tasktype int `json:"tasktype"` | |
| 88 | + Aims int `json:"aims"` | |
| 89 | + Taskdes string `json:"taskdes"` | |
| 90 | + Active int `json:"active"` | |
| 91 | + Days int `json:"days"` | |
| 92 | +} | |
| 93 | + | |
| 85 | 94 | type GameConfig struct { |
| 86 | 95 | AchieventConfig []AchieveDesc |
| 87 | 96 | TaskConfig []AchieveDesc |
| ... | ... | @@ -92,6 +101,7 @@ type GameConfig struct { |
| 92 | 101 | SignConfig SignConfigDesc |
| 93 | 102 | ActiveWithdrawConfig []ActiveWithdrawConfigDesc |
| 94 | 103 | RedpacketConfig []RedpacketConfigDesc |
| 104 | + NewTaskConfig []NewTaskConfigDesc | |
| 95 | 105 | } |
| 96 | 106 | |
| 97 | 107 | func GetJsonConf() *GameConfig { |
| ... | ... | @@ -260,10 +270,32 @@ func LoadJsonConf() error { |
| 260 | 270 | return err |
| 261 | 271 | } |
| 262 | 272 | |
| 273 | + path = "../jsonconf/NewTask.json" | |
| 274 | + content, err = file_get_contents(path) | |
| 275 | + if err != nil { | |
| 276 | + logger.Info("loadJsonConf failed1,err=%v", err) | |
| 277 | + return err | |
| 278 | + } | |
| 279 | + | |
| 280 | + err = json.Unmarshal([]byte(content), &g_jsonconf.NewTaskConfig) | |
| 281 | + if err != nil { | |
| 282 | + logger.Info("loadJsonConf failed1,err=%v", err) | |
| 283 | + return err | |
| 284 | + } | |
| 285 | + | |
| 263 | 286 | logger.Info("loadJsonConf success pconf=%v,err=%v", *g_jsonconf, err) |
| 264 | 287 | return err |
| 265 | 288 | } |
| 266 | 289 | |
| 290 | +func GetNewTaskInfo (id int) *NewTaskConfigDesc { | |
| 291 | + for _,val := range g_jsonconf.NewTaskConfig { | |
| 292 | + if val.Id == id { | |
| 293 | + return &val | |
| 294 | + } | |
| 295 | + } | |
| 296 | + return nil | |
| 297 | +} | |
| 298 | + | |
| 267 | 299 | |
| 268 | 300 | func GetRedpacketNum(id int) int { |
| 269 | 301 | if len(g_jsonconf.RedpacketConfig) == 0 { | ... | ... |
src/HttpServer/logic/constdef.go
src/HttpServer/logic/datadef.go
| ... | ... | @@ -336,6 +336,50 @@ type FetchredbagResp struct { |
| 336 | 336 | Data FetchredbagData `json:"data"` |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | + | |
| 340 | + | |
| 341 | +type QuerynewtaskReq struct { | |
| 342 | + Gameid string `json:"gameid"` | |
| 343 | + Channel string `json:"channel"` | |
| 344 | +} | |
| 345 | + | |
| 346 | +type QuerynewTaskInfoList struct { | |
| 347 | + Taskid int `json:"taskid"` | |
| 348 | + Taskstatus int `json:"taskstatus"` | |
| 349 | + Days int `json:"days"` | |
| 350 | + Taskprogress int `json:"taskprogress"` | |
| 351 | + | |
| 352 | +} | |
| 353 | + | |
| 354 | +type QuerynewtaskData struct { | |
| 355 | + Curloginday int `json:"curloginday"` | |
| 356 | + Sumactive int `json:"sumactive"` | |
| 357 | + Taskinfolist []QuerynewTaskInfoList `json:"taskinfolist"` | |
| 358 | +} | |
| 359 | +type QuerynewtaskResp struct { | |
| 360 | + Code int `json:"code"` | |
| 361 | + Message string `json:"message"` | |
| 362 | + Data QuerynewtaskData `json:"data"` | |
| 363 | +} | |
| 364 | + | |
| 365 | + | |
| 366 | +type HandlerFetchnewtaskReq struct { | |
| 367 | + Gameid string `json:"gameid"` | |
| 368 | + Channel string `json:"channel"` | |
| 369 | + Taskid int `json:"taskid"` | |
| 370 | +} | |
| 371 | + | |
| 372 | +type HandlerFetchnewtaskData struct { | |
| 373 | + Rewardactive int `json:"rewardactive"` | |
| 374 | + Sumactive int `json:"sumactive"` | |
| 375 | +} | |
| 376 | +type HandlerFetchnewtaskResp struct { | |
| 377 | + Code int `json:"code"` | |
| 378 | + Message string `json:"message"` | |
| 379 | + Data HandlerFetchnewtaskData `json:"data"` | |
| 380 | +} | |
| 381 | + | |
| 382 | + | |
| 339 | 383 | //********************************************************************************************************** |
| 340 | 384 | |
| 341 | 385 | type TaskListDesc struct { |
| ... | ... | @@ -367,6 +411,14 @@ type AchieveMentInfo struct { |
| 367 | 411 | SumUseItemCnt int //使用道具次数累计 |
| 368 | 412 | } |
| 369 | 413 | |
| 414 | +type NewAchieveInfo struct { | |
| 415 | + HeNum int //合道数字 | |
| 416 | + UseItem int //累计使用道具 | |
| 417 | + WatchAdsCnt int //累计观看广告 | |
| 418 | + GetRebBag int //累计赚到x元 | |
| 419 | + PassGuan int //累计过关 | |
| 420 | +} | |
| 421 | + | |
| 370 | 422 | type WithDrawList struct { |
| 371 | 423 | Withdata []WithDrawRecord `json:"withdata"` |
| 372 | 424 | } |
| ... | ... | @@ -445,11 +497,15 @@ type UserData struct { |
| 445 | 497 | IsNew int //新手状态// 现次数 |
| 446 | 498 | FetchRdBagNum int //当天已领的红包 |
| 447 | 499 | ShakeTime int //摇一摇 |
| 500 | + SumAc int //累计活跃度 | |
| 501 | + RegT int //注册时间 | |
| 448 | 502 | WithDraw WithDrawInfo //提现记录信息 |
| 449 | 503 | Cdkeys []CashCdKeyInfo //记录提现的cdkeys |
| 450 | 504 | //SpecialWithDraw WithDrawInfo //活跃提现记录信息 |
| 451 | 505 | Task TaskInfo //玩家任务完成相关信息 |
| 452 | 506 | Achieve AchieveMentInfo //玩家成就完成相关数据 |
| 507 | + NewAchieve NewAchieveInfo //新手12元 | |
| 508 | + FetchNewAchieved []int //已经领取的新任务id | |
| 453 | 509 | } |
| 454 | 510 | |
| 455 | 511 | //---------------------------------------------------------------------------------------------------------------------- | ... | ... |
src/HttpServer/logic/function.go
| ... | ... | @@ -112,6 +112,46 @@ func GetAchieveConfig(taskid int) *jsonconf.AchieveDesc { |
| 112 | 112 | return nil |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | +func (uinfo *UserData) CalcNewTask(resp *QuerynewtaskResp) { | |
| 116 | +//todo | |
| 117 | + for _,val := range jsonconf.GetJsonConf().NewTaskConfig { | |
| 118 | + var tmp QuerynewTaskInfoList | |
| 119 | + tmp.Taskid = val.Id | |
| 120 | + tmp.Days = val.Days | |
| 121 | + tmp.Taskstatus = 1 | |
| 122 | + usrvalue :=0 | |
| 123 | + if val.Tasktype == 1 { | |
| 124 | + usrvalue = uinfo.NewAchieve.HeNum | |
| 125 | + } | |
| 126 | + if val.Tasktype == 2 { | |
| 127 | + usrvalue = uinfo.NewAchieve.UseItem | |
| 128 | + } | |
| 129 | + if val.Tasktype == 3 { | |
| 130 | + usrvalue = uinfo.NewAchieve.WatchAdsCnt | |
| 131 | + } | |
| 132 | + if val.Tasktype == 4 { | |
| 133 | + usrvalue = uinfo.NewAchieve.GetRebBag / 10000 | |
| 134 | + } | |
| 135 | + if val.Tasktype == 5 { | |
| 136 | + usrvalue = uinfo.NewAchieve.PassGuan | |
| 137 | + } | |
| 138 | + | |
| 139 | + tmp.Taskprogress = usrvalue | |
| 140 | + if usrvalue >= val.Aims { | |
| 141 | + tmp.Taskstatus = 2 | |
| 142 | + } | |
| 143 | + | |
| 144 | + //需要判断下是否已经领取 | |
| 145 | + for _,val := range uinfo.FetchNewAchieved { | |
| 146 | + if val == tmp.Taskid { | |
| 147 | + tmp.Taskstatus = 3 | |
| 148 | + } | |
| 149 | + } | |
| 150 | + | |
| 151 | + resp.Data.Taskinfolist = append(resp.Data.Taskinfolist,tmp) | |
| 152 | + } | |
| 153 | +} | |
| 154 | + | |
| 115 | 155 | func (uinfo *UserData) CalcTaskList(list *TaskList, uniqueid string) *TaskList{ |
| 116 | 156 | newlist := new(TaskList) |
| 117 | 157 | curtype := -1 //记录当前类型 |
| ... | ... | @@ -586,6 +626,7 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int, uniqueuid s |
| 586 | 626 | initdata.UpLvCostTimeSec = int(time.Now().Unix()) |
| 587 | 627 | initdata.ShakeTime = SHAKELIMIT |
| 588 | 628 | initdata.IsNew = 1 |
| 629 | + initdata.RegT = int(time.Now().Unix()) | |
| 589 | 630 | |
| 590 | 631 | for _, val := range jsonconf.GetJsonConf().WithDrawConfig { |
| 591 | 632 | var tmp WithDrawDesc | ... | ... |
src/HttpServer/logic/httpserver.go
| ... | ... | @@ -63,6 +63,8 @@ func startServerHttpServe() { |
| 63 | 63 | http.HandleFunc("/eliminatestar/querysigndata", Querysigndata) //获取签到数据 |
| 64 | 64 | http.HandleFunc("/eliminatestar/usersign", Usersign) //玩家签到 |
| 65 | 65 | http.HandleFunc("/eliminatestar/fetchredbag", Fetchredbag) //领取红包 |
| 66 | + http.HandleFunc("/eliminatestar/querynewtask", Querynewtask) //请求当前新手12元任务数据 | |
| 67 | + http.HandleFunc("/eliminatestar/fetchnewtask", Fetchnewtask) //领取新手12元红包任务 | |
| 66 | 68 | // |
| 67 | 69 | http.HandleFunc("/eliminatestar/readNumUpload", ReadNumUpload) //阅读量上报 |
| 68 | 70 | http.HandleFunc("/eliminatestar/queryreadgold", QueryReadGold) //获取微转发金币数 |
| ... | ... | @@ -122,6 +124,49 @@ func ReadNumUpload(w http.ResponseWriter, r *http.Request) { |
| 122 | 124 | HandlerReadNumUpload(w, s) |
| 123 | 125 | } |
| 124 | 126 | |
| 127 | + | |
| 128 | +func Fetchnewtask(w http.ResponseWriter, r *http.Request) { | |
| 129 | + | |
| 130 | + Uuid := 0 | |
| 131 | + if len(r.Header) > 0 { | |
| 132 | + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) | |
| 133 | + } | |
| 134 | + | |
| 135 | + if Uuid == 0 { | |
| 136 | + SetHeader(w) | |
| 137 | + //logger.Error("Uuid is nil!") | |
| 138 | + return | |
| 139 | + } | |
| 140 | + result, _ := ioutil.ReadAll(r.Body) | |
| 141 | + r.Body.Close() | |
| 142 | + | |
| 143 | + s := string(result) | |
| 144 | + logger.Info("Fetchnewtask , body:%v,uuid=%v", s, Uuid) | |
| 145 | + | |
| 146 | + HandlerFetchnewtask(w, s, Uuid) | |
| 147 | +} | |
| 148 | + | |
| 149 | +func Querynewtask(w http.ResponseWriter, r *http.Request) { | |
| 150 | + | |
| 151 | + Uuid := 0 | |
| 152 | + if len(r.Header) > 0 { | |
| 153 | + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) | |
| 154 | + } | |
| 155 | + | |
| 156 | + if Uuid == 0 { | |
| 157 | + SetHeader(w) | |
| 158 | + //logger.Error("Uuid is nil!") | |
| 159 | + return | |
| 160 | + } | |
| 161 | + result, _ := ioutil.ReadAll(r.Body) | |
| 162 | + r.Body.Close() | |
| 163 | + | |
| 164 | + s := string(result) | |
| 165 | + logger.Info("Querynewtask , body:%v,uuid=%v", s, Uuid) | |
| 166 | + | |
| 167 | + HandlerQuerynewtask(w, s, Uuid) | |
| 168 | +} | |
| 169 | + | |
| 125 | 170 | func Fetchredbag(w http.ResponseWriter, r *http.Request) { |
| 126 | 171 | |
| 127 | 172 | Uuid := 0 | ... | ... |
src/HttpServer/logic/logic.go
| ... | ... | @@ -12,6 +12,7 @@ import ( |
| 12 | 12 | "strconv" |
| 13 | 13 | "strings" |
| 14 | 14 | "sync" |
| 15 | + "time" | |
| 15 | 16 | ) |
| 16 | 17 | |
| 17 | 18 | var llock sync.Mutex |
| ... | ... | @@ -683,6 +684,140 @@ func HandlerReadNumUpload(w http.ResponseWriter, data string) { |
| 683 | 684 | fmt.Fprint(w, string(respstr)) |
| 684 | 685 | } |
| 685 | 686 | |
| 687 | +func HandlerFetchnewtask(w http.ResponseWriter, data string, uuid int) { | |
| 688 | + SetHeader(w) | |
| 689 | + var resp HandlerFetchnewtaskResp | |
| 690 | + resp.Code = 0 | |
| 691 | + var rdata HandlerFetchnewtaskReq | |
| 692 | + err := json.Unmarshal([]byte(data), &rdata) | |
| 693 | + for { | |
| 694 | + if err != nil { | |
| 695 | + logger.Info("json decode HandlerFetchnewtask data failed:%v,for:%v", err, data) | |
| 696 | + resp.Message = "网络错误" | |
| 697 | + resp.Code = ERROR_JSONUNMASH_ERROR | |
| 698 | + break | |
| 699 | + } | |
| 700 | + | |
| 701 | + //需要加上渠道才是唯一的玩家id,不同渠道视为不同数据 | |
| 702 | + uniqueuuid := strconv.Itoa(uuid) + rdata.Channel | |
| 703 | + uinfo, err := GetUserInfo(uniqueuuid) | |
| 704 | + if err != nil || uinfo == nil { | |
| 705 | + logger.Error("redis failed err=%v", err) | |
| 706 | + resp.Message = "服务器错误" | |
| 707 | + resp.Code = ERROR_SRV_ERROR | |
| 708 | + break | |
| 709 | + } | |
| 710 | + | |
| 711 | + | |
| 712 | + taskcfg := jsonconf.GetNewTaskInfo(rdata.Taskid) | |
| 713 | + if taskcfg == nil { | |
| 714 | + logger.Error("get GetNewTaskInfo err=%v", err) | |
| 715 | + resp.Message = "读取配置表失败" | |
| 716 | + resp.Code = ERROR_SRV_ERROR | |
| 717 | + break | |
| 718 | + } | |
| 719 | + | |
| 720 | + //需要判断是否已经领取过 | |
| 721 | + isdone := false | |
| 722 | + for _,val := range uinfo.FetchNewAchieved { | |
| 723 | + if val == rdata.Taskid { | |
| 724 | + isdone = true | |
| 725 | + } | |
| 726 | + } | |
| 727 | + | |
| 728 | + if isdone { | |
| 729 | + logger.Error("get GetNewTaskInfo err=%v", err) | |
| 730 | + resp.Message = "该任务已经领取过了!" | |
| 731 | + resp.Code = ERROR_SRV_ERROR | |
| 732 | + break | |
| 733 | + } | |
| 734 | + | |
| 735 | + //判断任务是否已经完成 | |
| 736 | + usrvalue :=0 | |
| 737 | + if taskcfg.Tasktype == 1 { | |
| 738 | + usrvalue = uinfo.NewAchieve.HeNum | |
| 739 | + } | |
| 740 | + if taskcfg.Tasktype == 2 { | |
| 741 | + usrvalue = uinfo.NewAchieve.UseItem | |
| 742 | + } | |
| 743 | + if taskcfg.Tasktype == 3 { | |
| 744 | + usrvalue = uinfo.NewAchieve.WatchAdsCnt | |
| 745 | + } | |
| 746 | + if taskcfg.Tasktype == 4 { | |
| 747 | + usrvalue = uinfo.NewAchieve.GetRebBag / 10000 | |
| 748 | + } | |
| 749 | + if taskcfg.Tasktype == 5 { | |
| 750 | + usrvalue = uinfo.NewAchieve.PassGuan | |
| 751 | + } | |
| 752 | + | |
| 753 | + if usrvalue < taskcfg.Aims { | |
| 754 | + logger.Error("get GetNewTaskInfo err=%v", err) | |
| 755 | + resp.Message = "任务还未完成无法领取!" | |
| 756 | + resp.Code = ERROR_SRV_ERROR | |
| 757 | + break | |
| 758 | + } | |
| 759 | + | |
| 760 | + //领取 | |
| 761 | + uinfo.SumAc += taskcfg.Active | |
| 762 | + uinfo.FetchNewAchieved = append(uinfo.FetchNewAchieved,rdata.Taskid) | |
| 763 | + | |
| 764 | + resp.Data.Sumactive = uinfo.SumAc | |
| 765 | + resp.Data.Rewardactive = taskcfg.Active | |
| 766 | + | |
| 767 | + SaveUserInfo(uinfo,uniqueuuid) | |
| 768 | + | |
| 769 | + | |
| 770 | + resp.Code = ERROR_OK | |
| 771 | + break | |
| 772 | + } | |
| 773 | + | |
| 774 | + //回包 | |
| 775 | + respstr, _ := json.Marshal(&resp) | |
| 776 | + fmt.Fprint(w, string(respstr)) | |
| 777 | +} | |
| 778 | + | |
| 779 | +func HandlerQuerynewtask(w http.ResponseWriter, data string, uuid int) { | |
| 780 | + SetHeader(w) | |
| 781 | + var resp QuerynewtaskResp | |
| 782 | + resp.Code = 0 | |
| 783 | + var rdata QuerynewtaskReq | |
| 784 | + err := json.Unmarshal([]byte(data), &rdata) | |
| 785 | + for { | |
| 786 | + if err != nil { | |
| 787 | + logger.Info("json decode HandlerQuerynewtask data failed:%v,for:%v", err, data) | |
| 788 | + resp.Message = "网络错误" | |
| 789 | + resp.Code = ERROR_JSONUNMASH_ERROR | |
| 790 | + break | |
| 791 | + } | |
| 792 | + | |
| 793 | + //需要加上渠道才是唯一的玩家id,不同渠道视为不同数据 | |
| 794 | + uniqueuuid := strconv.Itoa(uuid) + rdata.Channel | |
| 795 | + uinfo, err := GetUserInfo(uniqueuuid) | |
| 796 | + if err != nil || uinfo == nil { | |
| 797 | + logger.Error("redis failed err=%v", err) | |
| 798 | + resp.Message = "服务器错误" | |
| 799 | + resp.Code = ERROR_SRV_ERROR | |
| 800 | + break | |
| 801 | + } | |
| 802 | + | |
| 803 | + nowdaynum := time.Now().Day() | |
| 804 | + regdaynum := time.Unix(int64(uinfo.RegT), 0).Day() | |
| 805 | + resp.Data.Curloginday = nowdaynum+1-regdaynum | |
| 806 | + resp.Data.Sumactive = uinfo.SumAc | |
| 807 | + | |
| 808 | + //计算一下任务 | |
| 809 | + uinfo.CalcNewTask(&resp) | |
| 810 | + | |
| 811 | + | |
| 812 | + resp.Code = ERROR_OK | |
| 813 | + break | |
| 814 | + } | |
| 815 | + | |
| 816 | + //回包 | |
| 817 | + respstr, _ := json.Marshal(&resp) | |
| 818 | + fmt.Fprint(w, string(respstr)) | |
| 819 | +} | |
| 820 | + | |
| 686 | 821 | func HandlerFetchredbag(w http.ResponseWriter, data string, uuid int) { |
| 687 | 822 | SetHeader(w) |
| 688 | 823 | llock.Lock() |
| ... | ... | @@ -711,6 +846,9 @@ func HandlerFetchredbag(w http.ResponseWriter, data string, uuid int) { |
| 711 | 846 | |
| 712 | 847 | readaddgold := uinfo.FetchRedPacket(rdata.Gameid, rdata.Channel, uuid) |
| 713 | 848 | |
| 849 | + //需要计算一下实际赚的钱 | |
| 850 | + uinfo.NewAchieve.GetRebBag += readaddgold | |
| 851 | + | |
| 714 | 852 | resp.Data.Walletgold = uinfo.RealGold |
| 715 | 853 | resp.Data.Getgoldnum = readaddgold |
| 716 | 854 | |
| ... | ... | @@ -960,6 +1098,7 @@ func HandlerUpdatetaskandachieve(w http.ResponseWriter, data string, uuid int) { |
| 960 | 1098 | switch rdata.Tasktype { |
| 961 | 1099 | case TASKTYPE_PASSLEVEL: |
| 962 | 1100 | uinfo.Task.PassLevel += rdata.Value |
| 1101 | + uinfo.NewAchieve.PassGuan += rdata.Value | |
| 963 | 1102 | case TASKTYPE_GETREDBAG: |
| 964 | 1103 | uinfo.Task.GetRedbagCnt += rdata.Value |
| 965 | 1104 | case TASKTYPE_WATCHADS: |
| ... | ... | @@ -968,6 +1107,7 @@ func HandlerUpdatetaskandachieve(w http.ResponseWriter, data string, uuid int) { |
| 968 | 1107 | if uinfo.LeftFreeRB > 0 { |
| 969 | 1108 | uinfo.LeftFreeRB-- |
| 970 | 1109 | } |
| 1110 | + uinfo.NewAchieve.WatchAdsCnt += rdata.Value | |
| 971 | 1111 | /*if uinfo.WatchAddsTime > 0 { |
| 972 | 1112 | uinfo.WatchAddsTime-- |
| 973 | 1113 | }*/ |
| ... | ... | @@ -976,6 +1116,7 @@ func HandlerUpdatetaskandachieve(w http.ResponseWriter, data string, uuid int) { |
| 976 | 1116 | case TASKTYPE_USEITEM: |
| 977 | 1117 | uinfo.Task.UseItemCnt += rdata.Value |
| 978 | 1118 | uinfo.Achieve.SumUseItemCnt += rdata.Value |
| 1119 | + uinfo.NewAchieve.UseItem += rdata.Value | |
| 979 | 1120 | case TASKTYPE_PLAYSMALLGAMES: |
| 980 | 1121 | uinfo.Task.PlaySmall += 1 |
| 981 | 1122 | case TASKTYPE_WATCHADSSURPRICE: |
| ... | ... | @@ -995,6 +1136,10 @@ func HandlerUpdatetaskandachieve(w http.ResponseWriter, data string, uuid int) { |
| 995 | 1136 | if uinfo.ShakeTime < 0 { |
| 996 | 1137 | uinfo.ShakeTime = 0 |
| 997 | 1138 | } |
| 1139 | + case TASKTYPE_HENUM: | |
| 1140 | + if uinfo.NewAchieve.HeNum < rdata.Value { | |
| 1141 | + uinfo.NewAchieve.HeNum = rdata.Value | |
| 1142 | + } | |
| 998 | 1143 | } |
| 999 | 1144 | logger.Info("HandlerUpdatetaskandachieve uinfo=%v rdata=%v", uinfo, rdata) |
| 1000 | 1145 | SaveUserInfo(uinfo, uniqueuuid) | ... | ... |