package services import ( "errors" "fmt" "hongze/hongze_mfyx/models" "hongze/hongze_mfyx/utils" "strconv" "time" ) // 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 } // GetActivityPointsAll 获取所有带有扣点的活动 func GetActivityPointsAll() (mapResp map[int]bool, err error) { defer func() { if err != nil { fmt.Println(err) go utils.SendAlarmMsg("获取所有带有扣点的活动失败"+err.Error(), 2) } }() var condition string var pars []interface{} mapResp = make(map[int]bool, 0) list, e := models.GetCygxActivityPointsSetList(condition, pars, 0, 0) if e != nil && e.Error() != utils.ErrNoRow() { err = errors.New("GetCygxActivityPointsSetList,Err: " + e.Error()) return } 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 } // 5 活动到会研选扣点处理 func YanXuanActivityPointsBillSubmitMeeting(activityId, adminId int) (err error) { defer func() { if err != nil { fmt.Println(err) msg := fmt.Sprint("activityId:", activityId) go utils.SendAlarmMsg("活动到会研选扣点处理,写入Redis队列消息失败:"+err.Error()+msg, 2) } }() //SourceType int `description:"1:报名、 2:取消报名、3:活动编辑、4:活动发布,取消发布、5:活动到会。6:研选审批通过的时候研选扣点更新、 7:正式专试用定时任务更新研选扣点"` log := &models.YanXuanActivityPointsRedis{ActivityId: activityId, SourceType: 5, AdminId: adminId, Source: 2, 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 } // 8 用户观看音视频研选扣点 func YanXuanActivityVivoPointsBillSignupAdd(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:活动到会。 8:用户观看音视频研选扣点"` log := &models.YanXuanActivityPointsRedis{UserId: uid, ActivityId: activityId, SourceType: 8, 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 }