activity_points.go 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. package services
  2. import (
  3. "errors"
  4. "fmt"
  5. "hongze/hongze_mfyx/models"
  6. "hongze/hongze_mfyx/utils"
  7. "strconv"
  8. "time"
  9. )
  10. // GetActivityPointsByUserAllMap 获取所有针对用户扣点的活动
  11. func GetActivityPointsByUserAllMap() (mapResp map[int]bool) {
  12. var err error
  13. defer func() {
  14. if err != nil {
  15. fmt.Println(err)
  16. go utils.SendAlarmMsg("GetActivityPointsByUserAllMap,Err:"+err.Error(), 2)
  17. }
  18. }()
  19. var condition string
  20. var pars []interface{}
  21. //获取所有研选类型的活动
  22. condition = ` AND chart_permission_id = ` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN)
  23. listActivity, e := models.GetActivityListByCondition(condition, pars)
  24. if e != nil {
  25. err = errors.New("GetActivityListByCondition, Err: " + e.Error())
  26. return
  27. }
  28. var activityIds []int
  29. condition = ""
  30. pars = make([]interface{}, 0)
  31. for _, v := range listActivity {
  32. activityIds = append(activityIds, v.ActivityId)
  33. }
  34. condition += ` AND points_object IN (1,3) `
  35. condition += ` AND activity_id IN (` + utils.GetOrmInReplace(len(activityIds)) + `) `
  36. pars = append(pars, activityIds)
  37. list, e := models.GetCygxActivityPointsSetList(condition, pars, 0, 0)
  38. if e != nil {
  39. err = errors.New("GetCygxActivityPointsSetList, Err: " + e.Error())
  40. return
  41. }
  42. mapResp = make(map[int]bool, 0)
  43. for _, v := range list {
  44. mapResp[v.ActivityId] = true
  45. }
  46. return
  47. }
  48. // GetActivityPointsAll 获取所有带有扣点的活动
  49. func GetActivityPointsAll() (mapResp map[int]bool, err error) {
  50. defer func() {
  51. if err != nil {
  52. fmt.Println(err)
  53. go utils.SendAlarmMsg("获取所有带有扣点的活动失败"+err.Error(), 2)
  54. }
  55. }()
  56. var condition string
  57. var pars []interface{}
  58. mapResp = make(map[int]bool, 0)
  59. list, e := models.GetCygxActivityPointsSetList(condition, pars, 0, 0)
  60. if e != nil && e.Error() != utils.ErrNoRow() {
  61. err = errors.New("GetCygxActivityPointsSetList,Err: " + e.Error())
  62. return
  63. }
  64. for _, v := range list {
  65. mapResp[v.ActivityId] = true
  66. }
  67. return
  68. }
  69. // 用户报名添加到处理研选扣点
  70. func YanXuanActivityPointsBillSignupAdd(activityId, uid int) (err error) {
  71. defer func() {
  72. if err != nil {
  73. fmt.Println(err)
  74. msg := fmt.Sprint("activityId:", activityId, "userId:", uid)
  75. go utils.SendAlarmMsg("用户报名添加到处理研选扣点,写入Redis队列消息失败:"+err.Error()+msg, 2)
  76. }
  77. }()
  78. //SourceType int `description:"1:报名、 2:取消报名、3:活动编辑、4:活动发布,取消发布、5:活动到会。"`
  79. log := &models.YanXuanActivityPointsRedis{UserId: uid, ActivityId: activityId, SourceType: 1, RegisterPlatform: utils.REGISTER_PLATFORM, Source: 1, CreateTime: time.Now()}
  80. if utils.Re == nil {
  81. err := utils.Rc.LPush(utils.CYGX_YANXUAN_POINTS_KEY, log)
  82. if err != nil {
  83. fmt.Println("YanXuanActivityPointsRedis LPush Err:" + err.Error())
  84. }
  85. }
  86. return
  87. }
  88. // 用户取消报名添加到处理研选扣点
  89. func YanXuanActivityPointsBillSignupCancel(activityId, uid int) (err error) {
  90. defer func() {
  91. if err != nil {
  92. fmt.Println(err)
  93. msg := fmt.Sprint("activityId:", activityId, "userId:", uid)
  94. go utils.SendAlarmMsg("用户取消报名添加到处理研选扣点,写入Redis队列消息失败:"+err.Error()+msg, 2)
  95. }
  96. }()
  97. //SourceType int `description:"1:报名、 2:取消报名、3:活动编辑、4:活动发布,取消发布、5:活动到会。"`
  98. log := &models.YanXuanActivityPointsRedis{UserId: uid, ActivityId: activityId, SourceType: 2, RegisterPlatform: utils.REGISTER_PLATFORM, Source: 1, CreateTime: time.Now()}
  99. if utils.Re == nil {
  100. err := utils.Rc.LPush(utils.CYGX_YANXUAN_POINTS_KEY, log)
  101. if err != nil {
  102. fmt.Println("YanXuanActivityPointsRedis LPush Err:" + err.Error())
  103. }
  104. }
  105. return
  106. }
  107. // 5 活动到会研选扣点处理
  108. func YanXuanActivityPointsBillSubmitMeeting(activityId, adminId int) (err error) {
  109. defer func() {
  110. if err != nil {
  111. fmt.Println(err)
  112. msg := fmt.Sprint("activityId:", activityId)
  113. go utils.SendAlarmMsg("活动到会研选扣点处理,写入Redis队列消息失败:"+err.Error()+msg, 2)
  114. }
  115. }()
  116. //SourceType int `description:"1:报名、 2:取消报名、3:活动编辑、4:活动发布,取消发布、5:活动到会。6:研选审批通过的时候研选扣点更新、 7:正式专试用定时任务更新研选扣点"`
  117. log := &models.YanXuanActivityPointsRedis{ActivityId: activityId, SourceType: 5, AdminId: adminId, Source: 2, CreateTime: time.Now()}
  118. if utils.Re == nil {
  119. err := utils.Rc.LPush(utils.CYGX_YANXUAN_POINTS_KEY, log)
  120. if err != nil {
  121. fmt.Println("YanXuanActivityPointsRedis LPush Err:" + err.Error())
  122. }
  123. }
  124. return
  125. }
  126. // 8 用户观看音视频研选扣点
  127. func YanXuanActivityVivoPointsBillSignupAdd(activityId, uid int) (err error) {
  128. defer func() {
  129. if err != nil {
  130. fmt.Println(err)
  131. msg := fmt.Sprint("activityId:", activityId, "userId:", uid)
  132. go utils.SendAlarmMsg("用户观看音视频研选扣点,写入Redis队列消息失败:"+err.Error()+msg, 2)
  133. }
  134. }()
  135. //SourceType int `description:"1:报名、 2:取消报名、3:活动编辑、4:活动发布,取消发布、5:活动到会。 8:用户观看音视频研选扣点"`
  136. log := &models.YanXuanActivityPointsRedis{UserId: uid, ActivityId: activityId, SourceType: 8, RegisterPlatform: utils.REGISTER_PLATFORM, Source: 1, CreateTime: time.Now()}
  137. if utils.Re == nil {
  138. err := utils.Rc.LPush(utils.CYGX_YANXUAN_POINTS_KEY, log)
  139. if err != nil {
  140. fmt.Println("YanXuanActivityPointsRedis LPush Err:" + err.Error())
  141. }
  142. }
  143. return
  144. }