123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- package http
- import (
- "go-common/app/interface/main/creative/model/newcomer"
- "go-common/library/ecode"
- "go-common/library/log"
- bm "go-common/library/net/http/blademaster"
- "go-common/library/net/metadata"
- "go-common/library/xstr"
- )
- func webTaskList(c *bm.Context) {
- params := c.Request.Form
- tyStr := params.Get("type")
- // check user
- midStr, ok := c.Get("mid")
- if !ok {
- c.JSON(nil, ecode.CreativeNotLogin)
- return
- }
- mid := midStr.(int64)
- // check white list
- if task := whiteSvc.TaskWhiteList(mid); task != 1 {
- c.JSON(nil, ecode.RequestErr)
- return
- }
- ty, err := toInt(tyStr)
- if err != nil {
- c.JSON(nil, err)
- return
- }
- tks, err := newcomerSvc.TaskList(c, mid, int8(ty))
- if err != nil {
- c.JSON(nil, err)
- return
- }
- c.JSON(tks, nil)
- }
- func webRewardReceive(c *bm.Context) {
- params := c.Request.Form
- ridStr := params.Get("reward_id")
- rewardTypeStr := params.Get("reward_type")
- // check user
- midI, ok := c.Get("mid")
- if !ok {
- c.JSON(nil, ecode.CreativeNotLogin)
- return
- }
- mid, _ := midI.(int64)
- ip := metadata.String(c, metadata.RemoteIP)
- var (
- err error
- rewardID int64
- rewardType int
- )
- rewardID, err = toInt64(ridStr)
- if err != nil || rewardID <= 0 {
- c.JSON(nil, ecode.RequestErr)
- return
- }
- rewardType, err = toInt(rewardTypeStr)
- if err != nil || rewardType < 0 {
- c.JSON(nil, ecode.RequestErr)
- return
- }
- msg, err := newcomerSvc.RewardReceive(c, mid, rewardID, int8(rewardType), ip)
- if err != nil {
- c.JSON(nil, err)
- return
- }
- c.JSON(map[string]interface{}{
- "msg": msg,
- }, nil)
- }
- func webRewardActivate(c *bm.Context) {
- params := c.Request.Form
- idStr := params.Get("id")
- // check user
- midI, ok := c.Get("mid")
- if !ok {
- c.JSON(nil, ecode.CreativeNotLogin)
- return
- }
- mid, _ := midI.(int64)
- id, err := toInt64(idStr)
- if err != nil || id <= 0 {
- c.JSON(nil, ecode.RequestErr)
- return
- }
- ip := metadata.String(c, metadata.RemoteIP)
- row, err := newcomerSvc.RewardActivate(c, mid, id, ip)
- if err != nil {
- c.JSON(nil, err)
- return
- }
- c.JSON(map[string]interface{}{
- "row": row,
- }, nil)
- }
- func webRewardReceiveList(c *bm.Context) {
- // check user
- midI, ok := c.Get("mid")
- if !ok {
- c.JSON(nil, ecode.CreativeNotLogin)
- return
- }
- mid, _ := midI.(int64)
- recs, err := newcomerSvc.RewardReceives(c, mid)
- if err != nil {
- c.JSON(nil, err)
- return
- }
- c.JSON(recs, nil)
- }
- func webTaskBind(c *bm.Context) {
- // check user
- midI, ok := c.Get("mid")
- if !ok {
- c.JSON(nil, ecode.CreativeNotLogin)
- return
- }
- mid, _ := midI.(int64)
- // check white list
- if task := whiteSvc.TaskWhiteList(mid); task != 1 {
- c.JSON(nil, ecode.RequestErr)
- return
- }
- id, err := newcomerSvc.TaskBind(c, mid)
- if err != nil {
- c.JSON(nil, err)
- return
- }
- c.JSON(map[string]interface{}{
- "id": id,
- }, nil)
- }
- func growAccountStateInternal(c *bm.Context) {
- params := c.Request.Form
- midsStr := params.Get("mids")
- var (
- err error
- mids []int64
- )
- mids, err = xstr.SplitInts(midsStr)
- if err != nil {
- log.Error("strconv.ParseInt(%s) error(%v)", midsStr, err)
- c.JSON(nil, ecode.RequestErr)
- return
- }
- for _, mid := range mids {
- pubSvc.TaskPub(mid, newcomer.MsgForGrowAccount, newcomer.MsgFinishedCount)
- }
- c.JSON(nil, nil)
- }
- //webTaskMakeup to compensation update task status
- func webTaskMakeup(c *bm.Context) {
- params := c.Request.Form
- // check user
- midStr, ok := c.Get("mid")
- if !ok {
- c.JSON(nil, ecode.CreativeNotLogin)
- return
- }
- mid := midStr.(int64)
- if !dataSvc.IsWhite(mid) {
- c.JSON(nil, ecode.CreativeNotLogin)
- return
- }
- tmid := params.Get("tmid")
- tid, err := toInt64(tmid)
- if err != nil {
- c.JSON(nil, ecode.RequestErr)
- return
- }
- // check white list
- if task := whiteSvc.TaskWhiteList(tid); task != 1 {
- c.JSON(nil, ecode.RequestErr)
- return
- }
- if err := newcomerSvc.TaskMakeup(c, tid); err != nil {
- c.JSON(nil, err)
- return
- }
- c.JSON("ok", nil)
- }
- // taskPubList to apply task list
- func taskPubList(c *bm.Context) {
- midI, ok := c.Get("mid")
- if !ok {
- c.JSON(nil, ecode.CreativeNotLogin)
- return
- }
- mid, _ := midI.(int64)
- data, err := newcomerSvc.TaskPubList(c, mid)
- if err != nil {
- c.JSON(nil, err)
- return
- }
- c.JSON(data, nil)
- }
|