浏览代码

no message

xingzai 1 年之前
父节点
当前提交
fed5c582c2
共有 4 个文件被更改,包括 81 次插入6 次删除
  1. 26 6
      controllers/yanxuan_special.go
  2. 9 0
      models/cygx_yanxuan_special_user.go
  3. 26 0
      services/cygx_yanxuan_special.go
  4. 20 0
      services/init12.8.go

+ 26 - 6
controllers/yanxuan_special.go

@@ -360,6 +360,7 @@ func (this *YanxuanSpecialController) Save() {
 	} else {
 		item.Status = 2
 	}
+	var authorUserId int
 	// 如果是审批人员操作的那么就是修改内容,加审批通过
 	if isApprovalPersonnel {
 		item.Status = 3
@@ -377,6 +378,8 @@ func (this *YanxuanSpecialController) Save() {
 			return
 		}
 		item.UserId = specialItem.UserId // 专栏userid还是原有userId
+
+		authorUserId = specialItem.UserId
 	}
 
 	specialId := 0
@@ -400,10 +403,11 @@ func (this *YanxuanSpecialController) Save() {
 	}
 
 	if isApprovalPersonnel {
-		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.UpdateYanxuanSpecialResourceData(specialId)        //  写入首页最新  cygx_resource_data 表
+		go services.EsAddYanxuanSpecial(specialId)                     //  写入es 综合搜索
+		go services.SendWxMsgSpecialFollow(req.Id)                     //研选专栏有新内容审核通过时,给关注此专栏的客户发送模板消息
+		go services.SendWxMsgSpecialAuthor(req.Id, 2)                  //研选专栏审核完成时,给提交人发送模板消息
+		go services.UdpateYanxuanSpecialauthorArticleNum(authorUserId) //  更新作者发布文章的数量
 	} else {
 		if req.DoType == 2 {
 			go services.SendReviewTemplateMsgAdmin(specialId)
@@ -493,6 +497,12 @@ func (this *YanxuanSpecialController) Enable() {
 	} else {
 		status = 4
 	}
+	detail, err := models.GetYanxuanSpecialItemById(req.Id)
+	if err != nil {
+		br.Msg = "审批失败"
+		br.ErrMsg = "审批失败, Err:" + err.Error()
+		return
+	}
 	if tmpErr := models.EnableYanxuanSpecial(req.Id, status, req.Reason, user.RealName); tmpErr != nil {
 		br.Msg = "审批失败"
 		br.ErrMsg = "审批失败, Err:" + tmpErr.Error()
@@ -505,6 +515,7 @@ func (this *YanxuanSpecialController) Enable() {
 	go services.UpdateYanxuanSpecialResourceData(req.Id)                                  //  写入首页最新  cygx_resource_data 表
 	go services.EsAddYanxuanSpecial(req.Id)                                               //  写入es 综合搜索
 	go services.AddAddCygxYanxuanSpecialApprovalLog(user, req.Id, req.Status, req.Reason) //  添加审核记录日志
+	go services.UdpateYanxuanSpecialauthorArticleNum(detail.UserId)                       //  更新作者发布文章的数量
 	br.Msg = "审批成功"
 	br.Ret = 200
 	br.Success = true
@@ -875,16 +886,25 @@ func (this *YanxuanSpecialController) Cancel() {
 		return
 	}
 
+	specialItem, err := models.GetYanxuanSpecialItemById(req.Id)
+	if err != nil {
+		br.Msg = "专栏取消发布失败"
+		br.ErrMsg = "专栏取消发布失败,Err:" + err.Error()
+		return
+	}
+
 	if tmpErr := models.CancelPublishYanxuanSpecial(req.Id); tmpErr != nil {
 		br.Msg = "取消发布失败"
 		br.ErrMsg = "取消发布失败, Err:" + tmpErr.Error()
 		return
 	}
-	go services.UpdateYanxuanSpecialResourceData(req.Id) //  写入首页最新  cygx_resource_data 表
-	go services.EsAddYanxuanSpecial(req.Id)              //  写入es 综合搜索
+	go services.UpdateYanxuanSpecialResourceData(req.Id)                 //  写入首页最新  cygx_resource_data 表
+	go services.EsAddYanxuanSpecial(req.Id)                              //  写入es 综合搜索
+	go services.UdpateYanxuanSpecialauthorArticleNum(specialItem.UserId) //  更新作者发布文章的数量
 	br.Msg = "取消发布成功"
 	br.Ret = 200
 	br.Success = true
+
 }
 
 // @Title 作者列表

+ 9 - 0
models/cygx_yanxuan_special_user.go

@@ -220,3 +220,12 @@ func UpdateYanxuanSpecialAuthorFansNumReduce(userId int) (err error) {
 	_, err = o.Raw(sql, userId).Exec()
 	return
 }
+
+// 更新作者发布文章的数量
+func UdpateYanxuanSpecialauthorArticleNum(articleNum, userId int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special_author SET article_num = ? WHERE user_id = ? `
+	_, err = o.Raw(sql, articleNum, userId).Exec()
+	return
+}

+ 26 - 0
services/cygx_yanxuan_special.go

@@ -495,3 +495,29 @@ func UdpateYanxuanSpecialFansNum(user *models.WxUserItem, specialUserIdId, statu
 	}
 	return
 }
+
+// UdpateYanxuanSpecialauthorArticleNum 更新作者发布文章的数量
+func UdpateYanxuanSpecialauthorArticleNum(authoruserId int) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg(fmt.Sprint("更新作者发布文章的数量失败,UdpateYanxuanSpecialauthorArticleNum Err ", err, "userId", authoruserId), 2)
+		}
+	}()
+	var condition string
+	var pars []interface{}
+	condition = ` AND status = 3  AND  user_id = ?  `
+	pars = append(pars, authoruserId)
+	total, e := models.GetCygxYanxuanSpecialCount(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxYanxuanSpecialCount, Err: " + e.Error())
+		return
+	}
+	e = models.UdpateYanxuanSpecialauthorArticleNum(total, authoruserId)
+	if e != nil {
+		err = errors.New("UdpateYanxuanSpecialauthorArticleNum, Err: " + e.Error())
+		return
+	}
+	return
+}

+ 20 - 0
services/init12.8.go

@@ -0,0 +1,20 @@
+package services
+
+import (
+	"fmt"
+	"hongze/hongze_cygx/models"
+)
+
+func init11() {
+	var condition string
+	var pars []interface{}
+	list, tmpErr := models.GetYanxuanSpecialAuthorList(condition, pars, 0, 9999)
+	if tmpErr != nil {
+		fmt.Println(tmpErr)
+		return
+	}
+	for _, v := range list {
+		fmt.Println(v.UserId)
+		UdpateYanxuanSpecialauthorArticleNum(v.UserId)
+	}
+}