123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- package services
- import (
- "errors"
- "fmt"
- "hongze/hongze_clpt/models"
- "hongze/hongze_clpt/utils"
- "strconv"
- "time"
- )
- //func init() {
- // GetActivityPointsByUserAllMap()
- //}
- // GetActivityPointsByUserAllMap 获取所有针对用户扣点的活动
- func GetActivityPointsByUserAllMap() (mapResp map[int]bool) {
- var err error
- defer func() {
- if err != nil {
- fmt.Println(err)
- go utils.SendAlarmMsg("GetActivityPointsByUserAllMap,Err:"+err.Error(), 2)
- }
- }()
- var condition string
- var pars []interface{}
- //获取所有研选类型的活动
- condition = ` AND chart_permission_id = ` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN)
- listActivity, e := models.GetActivityListByCondition(condition, pars)
- if e != nil {
- err = errors.New("GetActivityListByCondition, Err: " + e.Error())
- return
- }
- var activityIds []int
- condition = ""
- pars = make([]interface{}, 0)
- for _, v := range listActivity {
- activityIds = append(activityIds, v.ActivityId)
- }
- condition += ` AND points_object IN (1,3) `
- condition += ` AND activity_id IN (` + utils.GetOrmInReplace(len(activityIds)) + `) `
- pars = append(pars, activityIds)
- list, e := models.GetCygxActivityPointsSetList(condition, pars, 0, 0)
- if e != nil {
- err = errors.New("GetCygxActivityPointsSetList, Err: " + e.Error())
- return
- }
- mapResp = make(map[int]bool, 0)
- for _, v := range list {
- mapResp[v.ActivityId] = true
- }
- return
- }
- // 用户报名添加到处理研选扣点
- func YanXuanActivityPointsBillSignupAdd(activityId, uid int) (err error) {
- defer func() {
- if err != nil {
- fmt.Println(err)
- msg := fmt.Sprint("activityId:", activityId, "userId:", uid)
- go utils.SendAlarmMsg("用户报名添加到处理研选扣点,写入Redis队列消息失败:"+err.Error()+msg, 2)
- }
- }()
- //SourceType int `description:"1:报名、 2:取消报名、3:活动编辑、4:活动发布,取消发布、5:活动到会。"`
- log := &models.YanXuanActivityPointsRedis{UserId: uid, ActivityId: activityId, SourceType: 1, RegisterPlatform: utils.REGISTER_PLATFORM, Source: 1, CreateTime: time.Now()}
- if utils.Re == nil {
- err := utils.Rc.LPush(utils.CYGX_YANXUAN_POINTS_KEY, log)
- if err != nil {
- fmt.Println("YanXuanActivityPointsRedis LPush Err:" + err.Error())
- }
- }
- return
- }
- // 用户取消报名添加到处理研选扣点
- func YanXuanActivityPointsBillSignupCancel(activityId, uid int) (err error) {
- defer func() {
- if err != nil {
- fmt.Println(err)
- msg := fmt.Sprint("activityId:", activityId, "userId:", uid)
- go utils.SendAlarmMsg("用户取消报名添加到处理研选扣点,写入Redis队列消息失败:"+err.Error()+msg, 2)
- }
- }()
- //SourceType int `description:"1:报名、 2:取消报名、3:活动编辑、4:活动发布,取消发布、5:活动到会。"`
- log := &models.YanXuanActivityPointsRedis{UserId: uid, ActivityId: activityId, SourceType: 2, RegisterPlatform: utils.REGISTER_PLATFORM, Source: 1, CreateTime: time.Now()}
- if utils.Re == nil {
- err := utils.Rc.LPush(utils.CYGX_YANXUAN_POINTS_KEY, log)
- if err != nil {
- fmt.Println("YanXuanActivityPointsRedis LPush Err:" + err.Error())
- }
- }
- return
- }
|