123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- package cygx
- import (
- "errors"
- "fmt"
- "hongze/hz_crm_api/models/cygx"
- "hongze/hz_crm_api/services/alarm_msg"
- "hongze/hz_crm_api/utils"
- "time"
- )
- // GetUserLabelByUserIdArr 根据多个userId 获取每个UserId最新的十条数据
- func GetUserLabelByUserIdArr(userIdArr []int) (mapRsp map[int][]*cygx.WxUserRaiLabelListResp) {
- if len(userIdArr) == 0 {
- return
- }
- var err error
- defer func() {
- if err != nil {
- fmt.Println(err)
- go alarm_msg.SendAlarmMsg(fmt.Sprint("根据多个userId 获取每个UserId最新的十条数据失败:"+err.Error(), "userIdArr", userIdArr), 2)
- }
- }()
- labelList, e := cygx.GetWxUserRaiLabelListByUserIds(userIdArr)
- if e != nil {
- err = errors.New("GetWxUserRaiLabelListByUserIds, Err: " + e.Error())
- return
- }
- mapRsp = make(map[int][]*cygx.WxUserRaiLabelListResp)
- for _, v := range labelList {
- mapRsp[v.UserId] = append(mapRsp[v.UserId], v)
- }
- return
- }
- // 添加用户参加活动标签到Redis
- func ActivityWxUserRaiLabelRedisAdd(sourceId, uid int, createTime time.Time) (err error) {
- defer func() {
- if err != nil {
- fmt.Println(err)
- msg := fmt.Sprint("sourceId:", sourceId, "userId:", uid)
- go alarm_msg.SendAlarmMsg("添加用户参加活动标签,写入Redis队列消息失败:"+err.Error()+msg, 2)
- }
- }()
- log := &cygx.WxUserRaiLabelRedis{UserId: uid, SourceId: sourceId, SourceType: 2, CreateTime: createTime}
- if utils.Re == nil {
- err := utils.Rc.LPush(utils.WX_USER_RAI_LABEL_KEY, log)
- if err != nil {
- fmt.Println("ActivityWxUserRaiLabelRedisAdd LPush Err:" + err.Error())
- }
- }
- return
- }
- // 添加用户参加路演标签到Redis
- func RoadShowWxUserRaiLabelRedisAdd(sourceId, uid int, createTime time.Time) (err error) {
- defer func() {
- if err != nil {
- fmt.Println(err)
- msg := fmt.Sprint("sourceId:", sourceId, "userId:", uid)
- go alarm_msg.SendAlarmMsg("添加用户参加路演标签,写入Redis队列消息失败:"+err.Error()+msg, 2)
- }
- }()
- log := &cygx.WxUserRaiLabelRedis{UserId: uid, SourceId: sourceId, SourceType: 3, CreateTime: createTime}
- if utils.Re == nil {
- err := utils.Rc.LPush(utils.WX_USER_RAI_LABEL_KEY, log)
- if err != nil {
- fmt.Println("RoadShowWxUserRaiLabelRedisAdd LPush Err:" + err.Error())
- }
- }
- return
- }
|