|
@@ -391,12 +391,12 @@ func AddAddCygxYanxuanSpecialApprovalLog(user *models.WxUserItem, specialId, sta
|
|
|
}
|
|
|
|
|
|
// 更新文章收藏数量
|
|
|
-func UdpateYanxuanSpecialCollect(user *models.WxUserItem, specialId, status int) {
|
|
|
+func UdpateYanxuanSpecialCollect(specialId int) {
|
|
|
var err error
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
fmt.Println(err)
|
|
|
- go utils.SendAlarmMsg(fmt.Sprint("更新文章收藏数量失败,UdpateYanxuanSpecialCollect Err ", err, "userId", user.UserId), 2)
|
|
|
+ go utils.SendAlarmMsg(fmt.Sprint("更新文章收藏数量失败,UdpateYanxuanSpecialCollect Err ", err, "specialId:", specialId), 2)
|
|
|
}
|
|
|
}()
|
|
|
detail, e := models.GetYanxuanSpecialBySpecialId(specialId)
|
|
@@ -411,62 +411,67 @@ func UdpateYanxuanSpecialCollect(user *models.WxUserItem, specialId, status int)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if status == 1 {
|
|
|
- //更新文章被收藏数量
|
|
|
- e = models.UpdateYanxuanSpecialarticleCollectNumIncrease(specialId)
|
|
|
- if e != nil {
|
|
|
- err = errors.New("UpdateYanxuanSpecialarticleCollectNumIncrease, Err: " + e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition = " AND yanxuan_special_id = ? "
|
|
|
+ pars = append(pars, specialId)
|
|
|
+ //专栏被收藏的数量
|
|
|
+ totalSpecial, e := models.GetCygxYanxuanSpecialCollectCount(condition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCygxYanxuanSpecialCollectCount, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
- //更新作者文章被收藏数量
|
|
|
- e = models.UpdateYanxuanSpecialAuthorArticleCollectNumIncrease(specialAuthor.Id)
|
|
|
- if e != nil {
|
|
|
- err = errors.New("UpdateYanxuanSpecialAuthorArticleCollectNumIncrease, Err: " + e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- } else {
|
|
|
- //更新文章被收藏数量
|
|
|
- e = models.UpdateYanxuanSpecialarticleCollectNumReduce(specialId)
|
|
|
- if e != nil {
|
|
|
- err = errors.New("UpdateYanxuanSpecialarticleCollectNumReduce, Err: " + e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
+ pars = make([]interface{}, 0)
|
|
|
+ condition = " AND yanxuan_special_id IN (SELECT id FROM cygx_yanxuan_special AS a WHERE user_id = ?) "
|
|
|
+ pars = append(pars, specialAuthor.UserId)
|
|
|
+ //作者被收藏的数量
|
|
|
+ totalAuthor, e := models.GetCygxYanxuanSpecialCollectCount(condition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCygxYanxuanSpecialCollectCount, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
- //更新作者文章被收藏数量
|
|
|
- e = models.UpdateYanxuanSpecialAuthorArticleCollectNumReduce(specialAuthor.Id)
|
|
|
- if e != nil {
|
|
|
- err = errors.New("UpdateYanxuanSpecialAuthorArticleCollectNumReduce, Err: " + e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
+ //更新文章被收藏数量
|
|
|
+ e = models.UpdateYanxuanSpecialarticleCollectNum(totalSpecial, specialId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("UpdateYanxuanSpecialarticleCollectNum, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新作者文章被收藏数量
|
|
|
+ e = models.UpdateYanxuanSpecialAuthorArticleCollectNum(totalAuthor, specialAuthor.UserId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("UpdateYanxuanSpecialAuthorArticleCollectNum, Err: " + e.Error())
|
|
|
+ return
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 更新作者粉丝数量
|
|
|
-func UdpateYanxuanSpecialFansNum(user *models.WxUserItem, specialAuthorId, status int) {
|
|
|
+func UdpateYanxuanSpecialFansNum(specialUserIdId int) {
|
|
|
var err error
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
fmt.Println(err)
|
|
|
- go utils.SendAlarmMsg(fmt.Sprint("更新作者粉丝数量失败,UdpateYanxuanSpecialFansNum Err ", err, "userId", user.UserId), 2)
|
|
|
+ go utils.SendAlarmMsg(fmt.Sprint("更新作者粉丝数量失败,UdpateYanxuanSpecialFansNum Err ", err, "specialUserIdId", specialUserIdId), 2)
|
|
|
}
|
|
|
}()
|
|
|
|
|
|
- if status == 1 {
|
|
|
- //更新作者粉丝数量
|
|
|
- e := models.UpdateYanxuanSpecialAuthorFansNumIncrease(specialAuthorId)
|
|
|
- if e != nil {
|
|
|
- err = errors.New("UpdateYanxuanSpecialAuthorFansNumIncrease, Err: " + e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- } else {
|
|
|
- //更新作者粉丝数量
|
|
|
- e := models.UpdateYanxuanSpecialAuthorFansNumReduce(specialAuthorId)
|
|
|
- if e != nil {
|
|
|
- err = errors.New("UpdateYanxuanSpecialAuthorFansNumReduce, Err: " + e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition = " AND follow_user_id = ? "
|
|
|
+ pars = append(pars, specialUserIdId)
|
|
|
+ //作者粉丝数量
|
|
|
+ total, e := models.GetCygxYanxuanSpecialFollowCount(condition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCygxYanxuanSpecialFollowCount, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ e = models.UpdateYanxuanSpecialAuthorFansNum(total, specialUserIdId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("UpdateYanxuanSpecialAuthorFansNum, Err: " + e.Error())
|
|
|
+ return
|
|
|
}
|
|
|
return
|
|
|
}
|