Browse Source

Merge branch 'master' of http://8.136.199.33:3000/hongze/hongze_cygx into debug

xingzai 11 months ago
parent
commit
d1a7ce676f
1 changed files with 30 additions and 19 deletions
  1. 30 19
      controllers/yanxuan_special.go

+ 30 - 19
controllers/yanxuan_special.go

@@ -259,7 +259,7 @@ func (this *YanxuanSpecialController) Detail() {
 			br.ErrMsg = "获取失败, Err:" + err.Error()
 			return
 		}
-		if followCount == 1 {
+		if followCount > 0 {
 			resp.IsFollowAuthor = true
 		}
 	}
@@ -450,7 +450,7 @@ func (this *YanxuanSpecialController) Save() {
 		go services.UpdateYanxuanSpecialResourceData(specialId)        //  写入首页最新  cygx_resource_data 表
 		go services.EsAddYanxuanSpecial(specialId)                     //  写入es 综合搜索
 		go services.SendWxMsgSpecialFollow(req.Id)                     //研选专栏有新内容审核通过时,给关注此专栏的客户发送模板消息
-		go services.SendWxMsgSpecialAuthor(req.Id, 2)                  //研选专栏审核完成时,给提交人发送模板消息
+		go services.SendWxMsgSpecialAuthor(req.Id, 1)                  //研选专栏审核完成时,给提交人发送模板消息
 		go services.UdpateYanxuanSpecialauthorArticleNum(authorUserId) //  更新作者发布文章的数量
 		go services.MakeYanxuanSpecialMomentsImg(specialId)            //  生成研选专栏分享到朋友圈的图片
 	} else {
@@ -495,6 +495,9 @@ func (this *YanxuanSpecialController) AuthorDetail() {
 		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
 		return
 	}
+	if item.IsFollow > 0 {
+		item.IsFollow = 1
+	}
 
 	br.Data = item
 	br.Ret = 200
@@ -799,26 +802,34 @@ func (this *YanxuanSpecialController) Follow() {
 	}
 
 	if req.Status == 1 {
-		item := models.CygxYanxuanSpecialFollow{
-			UserId:           user.UserId,
-			FollowUserId:     req.FollowUserId,
-			Mobile:           user.Mobile,
-			Email:            user.Email,
-			CompanyId:        user.CompanyId,
-			CompanyName:      user.CompanyName,
-			RealName:         user.RealName,
-			SellerName:       sellerName,
-			CreateTime:       time.Now(),
-			ModifyTime:       time.Now(),
-			RegisterPlatform: utils.REGISTER_PLATFORM,
-			YanxuanSpecialId: req.SpecialId,
-		}
-		err = models.AddCygxYanxuanSpecialFollow(&item)
+		followCount, err := models.GetCygxYanxuanSpecialFollowCountByUser(user.UserId, req.FollowUserId)
 		if err != nil {
-			br.Msg = "新增失败"
-			br.ErrMsg = "新增失败,Err:" + err.Error()
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败, Err:" + err.Error()
 			return
 		}
+		if followCount == 0 {
+			item := models.CygxYanxuanSpecialFollow{
+				UserId:           user.UserId,
+				FollowUserId:     req.FollowUserId,
+				Mobile:           user.Mobile,
+				Email:            user.Email,
+				CompanyId:        user.CompanyId,
+				CompanyName:      user.CompanyName,
+				RealName:         user.RealName,
+				SellerName:       sellerName,
+				CreateTime:       time.Now(),
+				ModifyTime:       time.Now(),
+				RegisterPlatform: utils.REGISTER_PLATFORM,
+				YanxuanSpecialId: req.SpecialId,
+			}
+			err = models.AddCygxYanxuanSpecialFollow(&item)
+			if err != nil {
+				br.Msg = "新增失败"
+				br.ErrMsg = "新增失败,Err:" + err.Error()
+				return
+			}
+		}
 		br.Msg = "关注成功"
 	} else {
 		err = models.DelCygxYanxuanSpecialFollow(user.UserId, req.FollowUserId)