Browse Source

Merge branch 'master' into yx_1.1

zwxi 9 months ago
parent
commit
310b74432c
2 changed files with 33 additions and 22 deletions
  1. 30 19
      controllers/yanxuan_special.go
  2. 3 3
      models/cygx_yanxuan_special_follow.go

+ 30 - 19
controllers/yanxuan_special.go

@@ -268,7 +268,7 @@ func (this *YanxuanSpecialNoLoginController) Detail() {
 		}
 	}
 
-	fllowNum, err := models.GetCygxYanxuanSpecialFollowCountByUserId(sysUser.UserId, item.UserId)
+	fllowNum, err := models.GetCygxYanxuanSpecialFollowCountByUser(sysUser.UserId, item.UserId)
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取是否关注作者失败, Err:" + err.Error()
@@ -498,7 +498,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.SendWxCategoryMsgSpecialAuthor(req.Id, 1) //研选专栏审核完成时,给提交人发送类目模板消息
 		go services.SendWxCategoryMsgSpecialFollow(req.Id) // 研选专栏有新内容审核通过时,给关注此专栏的客户发送模板消息
@@ -542,6 +542,9 @@ func (this *YanxuanSpecialNoLoginController) AuthorDetail() {
 		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
 		return
 	}
+	if item.IsFollow > 0 {
+		item.IsFollow = 1
+	}
 
 	br.Data = item
 	br.Ret = 200
@@ -847,26 +850,34 @@ func (this *YanxuanSpecialController) Follow() {
 	}
 
 	if req.Status == 1 {
-		item := models.CygxYanxuanSpecialFollow{
-			UserId:           user.UserId,
-			FollowUserId:     authorItem.UserId,
-			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, authorItem.UserId)
 		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:     authorItem.UserId,
+				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, authorItem.UserId)

+ 3 - 3
models/cygx_yanxuan_special_follow.go

@@ -67,9 +67,9 @@ func GetCygxYanxuanSpecialFollowCount(condition string, pars []interface{}) (cou
 	return
 }
 
-// 获取数量
-func GetCygxYanxuanSpecialFollowCountByUserId(userId, followUserId int) (count int, err error) {
-	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_yanxuan_special_follow as a  WHERE user_id = ? AND follow_user_id = ?   `
+// 获取数量判断用户是否关注专栏
+func GetCygxYanxuanSpecialFollowCountByUser(userId, followUserId int) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_yanxuan_special_follow as a WHERE user_id=? AND follow_user_id=? `
 	o := orm.NewOrm()
 	err = o.Raw(sqlCount, userId, followUserId).QueryRow(&count)
 	return