Ver Fonte

no message

xingzai há 1 ano atrás
pai
commit
2c15372cb7

+ 1 - 0
controllers/product_interior.go

@@ -123,6 +123,7 @@ func (this *ProductInteriorController) Detail() {
 	resp.Detail = detail
 	detail.BodySlice = services.GetProductInteriorUrlBody(detail.Body)
 	go services.AddCygxProductInteriorHistory(user, productInteriorId)
+	go services.ProductInteriorHistoryUserRmind(user, productInteriorId)
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"

+ 11 - 1
services/minutes_summary.go

@@ -6,13 +6,20 @@ import (
 	"hongze/hongze_clpt/models"
 	"hongze/hongze_clpt/utils"
 	"strconv"
+	"time"
 )
 
 // 上周纪要汇总用户阅读,给销售发消息提醒
 func MinutesSummaryHistoryUserRmind(user *models.WxUserItem, articleId int) (err error) {
+	//30秒内阅读同一篇报告不做重复推送
+	key := "CYGX_" + utils.CYGX_OBJ_MINUTESSUMMARY + "_READ" + strconv.Itoa(articleId) + "_" + strconv.Itoa(user.UserId)
+	if utils.Rc.IsExist(key) {
+		return
+	}
+	utils.Rc.Put(key, 1, 30*time.Second)
 	defer func() {
 		if err != nil {
-			go utils.SendAlarmMsg(fmt.Sprint("上周纪要汇总用户阅读,给销售发消息提醒,模板消息推送 ,ResearchSummaryHistoryUserRmind"+err.Error(), "userId:", user.UserId, "articleId:", articleId), 2)
+			go utils.SendAlarmMsg(fmt.Sprint("上周纪要汇总用户阅读,给销售发消息提醒,模板消息推送 ,MinutesSummaryHistoryUserRmind"+err.Error(), "userId:", user.UserId, "articleId:", articleId), 2)
 		}
 	}()
 	countUser, err := models.GetUserRemind(user.UserId)
@@ -39,6 +46,9 @@ func MinutesSummaryHistoryUserRmind(user *models.WxUserItem, articleId int) (err
 			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
 			return
 		}
+		if len(openIdList) == 0 {
+			return
+		}
 		detail, e := models.GetCygxMinutesSummaryInfoById(articleId)
 		if e != nil {
 			err = errors.New("GetCygxProductInteriorDetail, Err: " + e.Error())

+ 9 - 0
services/product_interior.go

@@ -165,6 +165,12 @@ func GetCygxProductInteriorHistoryListPvMap(productInteriorIs []int) (mapPv map[
 
 // 用户产品内测阅读,模板消息推送
 func ProductInteriorHistoryUserRmind(user *models.WxUserItem, productInteriorId int) (err error) {
+	//30秒内阅读同一篇报告不做重复推送
+	key := "CYGX_" + utils.CYGX_OBJ_PRODUCTINTERIOR + "_READ" + strconv.Itoa(productInteriorId) + "_" + strconv.Itoa(user.UserId)
+	if utils.Rc.IsExist(key) {
+		return
+	}
+	utils.Rc.Put(key, 1, 30*time.Second)
 	defer func() {
 		if err != nil {
 			go utils.SendAlarmMsg(fmt.Sprint("用户产品内测阅读,模板消息推送,模板消息推送失败 ,ProductInteriorHistoryUserRmind"+err.Error(), "userId:", user.UserId, "productInteriorId:", productInteriorId), 2)
@@ -194,6 +200,9 @@ func ProductInteriorHistoryUserRmind(user *models.WxUserItem, productInteriorId
 			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
 			return
 		}
+		if len(openIdList) == 0 {
+			return
+		}
 		detail, e := models.GetCygxProductInteriorDetail(productInteriorId)
 		if e != nil {
 			err = errors.New("GetCygxProductInteriorDetail, Err: " + e.Error())

+ 10 - 0
services/research_summary.go

@@ -6,10 +6,17 @@ import (
 	"hongze/hongze_clpt/models"
 	"hongze/hongze_clpt/utils"
 	"strconv"
+	"time"
 )
 
 // 本周研究汇总用户阅读操作操作行为,模板消息推送
 func ResearchSummaryHistoryUserRmind(user *models.WxUserItem, articleId int) (err error) {
+	//30秒内阅读同一篇报告不做重复推送
+	key := "CYGX_" + utils.CYGX_OBJ_RESEARCHSUMMARY + "_READ" + strconv.Itoa(articleId) + "_" + strconv.Itoa(user.UserId)
+	if utils.Rc.IsExist(key) {
+		return
+	}
+	utils.Rc.Put(key, 1, 30*time.Second)
 	defer func() {
 		if err != nil {
 			go utils.SendAlarmMsg(fmt.Sprint("本周研究汇总用户阅读操作操作行为,模板消息推送 ,ResearchSummaryHistoryUserRmind"+err.Error(), "userId:", user.UserId, "articleId:", articleId), 2)
@@ -39,6 +46,9 @@ func ResearchSummaryHistoryUserRmind(user *models.WxUserItem, articleId int) (er
 			err = errors.New("GetWxOpenIdByMobileList, Err: " + e.Error())
 			return
 		}
+		if len(openIdList) == 0 {
+			return
+		}
 		detail, e := models.GetCygxResearchSummaryInfoById(articleId)
 		if e != nil {
 			err = errors.New("GetCygxResearchSummaryInfoById, Err: " + e.Error())