|
@@ -2,9 +2,11 @@ package services
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
+ "errors"
|
|
|
"fmt"
|
|
|
"hongze/hongze_cygx/models"
|
|
|
"hongze/hongze_cygx/utils"
|
|
|
+ "time"
|
|
|
)
|
|
|
|
|
|
func UserLabelLogReduce() (err error) {
|
|
@@ -41,23 +43,69 @@ func UserLabelLogReduce() (err error) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// 2产业关注
|
|
|
func IndustryFllowUserLabelLogReduce(log models.CygxUserLabelLogRedis) (err error) {
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
fmt.Println(err)
|
|
|
- //msg := fmt.Sprint("industrialManagementId:", industrialManagementId, "isFllow:", isFllow, "userId:", uid)
|
|
|
- msg := ""
|
|
|
- go utils.SendAlarmMsg("用户关注产业更新相关标签,写入Redis队列消息失败:"+err.Error()+msg, 2)
|
|
|
+ go utils.SendAlarmMsg("用户关注产业更新相关标签,处理Redis队列消息失败:"+err.Error(), 2)
|
|
|
}
|
|
|
}()
|
|
|
-
|
|
|
- //type CygxActivitySigninLogRedis struct {
|
|
|
- // UserId int `description:"用户ID"`
|
|
|
- // SourceId int `description:"资源ID"`
|
|
|
- // SourceType int `description:"1:文章阅读、 2产业关注、3:活动到会、4系列关注、5专项调研活动到会。"`
|
|
|
- // IsFllow int `description:"1关注、0取消关注"`
|
|
|
- // CreateTime time.Time `description:"创建时间"`
|
|
|
- //}
|
|
|
-
|
|
|
+ isFllow := log.IsFllow
|
|
|
+ industrialManagementId := log.SourceId
|
|
|
+ userId := log.UserId
|
|
|
+ detailIndustrial, e := models.GetIndustrialManagementDetail(industrialManagementId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetIndustrialManagementDetail" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ label := detailIndustrial.IndustryName
|
|
|
+ if isFllow == 0 {
|
|
|
+ e = models.UpdateCygxUserLabelIsFollow(isFllow, industrialManagementId, 1, label)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("UpdateCygxUserLabelIsFollow" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition += ` AND art.status = 1 `
|
|
|
+ total, e := models.GetCygxUserLabelCount(condition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCygxProductInteriorCount" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if total == 0 {
|
|
|
+ user, e := models.GetWxUserItemByUserId(userId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetWxUserItemByUserId" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ item := new(models.CygxUserLabel)
|
|
|
+ item.UserId = user.UserId
|
|
|
+ item.CompanyId = user.CompanyId
|
|
|
+ item.RealName = user.RealName
|
|
|
+ item.Mobile = user.Mobile
|
|
|
+ item.Email = user.Email
|
|
|
+ item.Label = label
|
|
|
+ item.SourceId = industrialManagementId
|
|
|
+ item.Source = 1
|
|
|
+ item.IsFollow = 1
|
|
|
+ item.CreateTime = time.Now()
|
|
|
+ item.CreateTime = time.Now()
|
|
|
+ _, e = models.AddCygxUserLabel(item)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("AddCygxUserLabel" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //source 来源1:产业、2:系列
|
|
|
+ e = models.UpdateCygxUserLabelIsFollow(isFllow, industrialManagementId, 1, label)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("UpdateCygxUserLabelIsFollow" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return
|
|
|
}
|