|
@@ -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) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
func IndustryFllowUserLabelLogReduce(log models.CygxUserLabelLogRedis) (err error) {
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
fmt.Println(err)
|
|
|
-
|
|
|
- msg := ""
|
|
|
- go utils.SendAlarmMsg("用户关注产业更新相关标签,写入Redis队列消息失败:"+err.Error()+msg, 2)
|
|
|
+ go utils.SendAlarmMsg("用户关注产业更新相关标签,处理Redis队列消息失败:"+err.Error(), 2)
|
|
|
}
|
|
|
}()
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ 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 {
|
|
|
+
|
|
|
+ e = models.UpdateCygxUserLabelIsFollow(isFllow, industrialManagementId, 1, label)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("UpdateCygxUserLabelIsFollow" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return
|
|
|
}
|