123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- 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
- }
|