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 }