user_share.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package gatesink
  2. import (
  3. "bet24.com/log"
  4. "bet24.com/servers/common"
  5. item "bet24.com/servers/micros/item_inventory/proto"
  6. task "bet24.com/servers/micros/task/proto"
  7. "bet24.com/servers/transaction"
  8. "encoding/json"
  9. "fmt"
  10. )
  11. func (this *user) rewardShareItems(msg string) {
  12. items := transaction.GetShareItems(this.getUserId(), 1)
  13. if len(items) == 0 {
  14. this.WriteMsg(msg, "领取失败,本日已领取")
  15. return
  16. }
  17. item.AddItems(this.getUserId(), items, "分享领取", common.LOGTYPE_SHARE)
  18. this.WriteMsg(msg, "领取成功")
  19. }
  20. func (this *user) getShareItems(msg string) {
  21. items := transaction.GetShareItems(this.getUserId(), 0)
  22. d, _ := json.Marshal(items)
  23. this.WriteMsg(msg, string(d))
  24. }
  25. func (this *user) doSharePlatform() {
  26. task.DoTaskAction(this.getUserId(), task.TaskAction_shareplatform, 1, task.TaskScope{})
  27. }
  28. func (this *user) doShareGame() {
  29. task.DoTaskAction(this.getUserId(), task.TaskAction_sharegame, 1, task.TaskScope{})
  30. }
  31. func (this *user) finishNoviceGuidance(data string) {
  32. if data == "skip" {
  33. task.RemoveTaskByAction(this.getUserId(), task.TaskAction_novice_guidance, "")
  34. } else {
  35. param := task.TaskScope{RankCrdate: common.GetNowTimeStr()}
  36. task.DoTaskAction(this.getUserId(), task.TaskAction_novice_guidance, 1, param)
  37. }
  38. }
  39. func (this *user) isShowNoviceGuidance(msg string, data string) {
  40. var ret struct {
  41. Show bool
  42. }
  43. ret.Show = task.IsActionTaskActive(this.getUserId(), task.TaskAction_novice_guidance, data)
  44. d, _ := json.Marshal(ret)
  45. this.WriteMsg(msg, string(d))
  46. }
  47. func (this *user) finishGameNoviceGuidance(msg, data string) {
  48. var req struct {
  49. IsSkip bool
  50. GameName string
  51. }
  52. if err := json.Unmarshal([]byte(data), &req); err != nil {
  53. retData := fmt.Sprintf("finishGameNoviceGuidance unmarshal fail %v", err)
  54. log.Release(retData)
  55. this.WriteMsg(msg, retData)
  56. return
  57. }
  58. if req.IsSkip {
  59. task.RemoveTaskByAction(this.getUserId(), task.TaskAction_novice_guidance, req.GameName)
  60. } else {
  61. param := task.TaskScope{RankCrdate: common.GetNowTimeStr(), GameName: req.GameName}
  62. _, taskId := task.DoTaskAction(this.getUserId(), task.TaskAction_novice_guidance, 1, param)
  63. if taskId > 0 {
  64. ret := task.AwardTaskWithItems(this.getUserId(), taskId)
  65. this.WriteMsg(msg, ret)
  66. return
  67. }
  68. }
  69. this.WriteMsg(msg, "")
  70. }