Browse Source

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

xingzai 7 months ago
parent
commit
b6ce0b9491
5 changed files with 48 additions and 118 deletions
  1. 7 0
      controllers/article.go
  2. 5 105
      services/rai_serve_count.go
  3. 25 2
      services/wx_category_template_msg.go
  4. 10 10
      utils/config.go
  5. 1 1
      utils/constants.go

+ 7 - 0
controllers/article.go

@@ -257,6 +257,13 @@ func (this *ArticleController) Detail() {
 					hasPersion = true
 				}
 			}
+
+			if articleId == 11223 { // 这是一篇非常特殊的文章,要单独处理 需求池 976
+				if strings.Contains(companyPermission, utils.YI_YAO_NAME) || strings.Contains(companyPermission, utils.XIAO_FEI_NAME) || strings.Contains(companyPermission, utils.KE_JI_NAME) || strings.Contains(companyPermission, utils.ZHI_ZAO_NAME) {
+					hasPersion = true
+				}
+			}
+
 			if strings.Contains(detail.CategoryName, "研选") {
 				detail.IsResearch = true
 			}

+ 5 - 105
services/rai_serve_count.go

@@ -2,7 +2,6 @@ package services
 
 import (
 	"context"
-	"encoding/json"
 	"errors"
 	"fmt"
 	"hongze/hongze_cygx/models"
@@ -93,13 +92,15 @@ func UpdateRaiServeCompany() (err error) {
 
 	var condition string
 	var pars []interface{}
-	condition = `    AND p.product_id = 2 AND  (p.group_id = ? OR  p.share_group_id = ?) `
-	pars = append(pars, utils.RAI_SERVE_GROUP_ID, utils.RAI_SERVE_GROUP_ID)
+	condition = `    AND p.product_id = 2 AND  (p.group_id IN (` + utils.RAI_SERVE_GROUP_ID + `)  OR  p.share_group_id IN (` + utils.RAI_SERVE_GROUP_ID + `) ) `
+	//pars = append(pars, utils.RAI_SERVE_GROUP_ID, utils.RAI_SERVE_GROUP_ID)
 	listCompanyProduct, e := company.GetCompanyProductAndCompanyListByCondition(condition, pars)
 	if e != nil {
 		err = errors.New("GetCompanyProductListByCondition, Err: " + e.Error())
 		return
 	}
+	//fmt.Println(len(listCompanyProduct))
+	//return
 
 	raiServeCompanyList, e := rai_serve.GetCygxRaiServeCompanyAllList()
 	if e != nil {
@@ -1340,7 +1341,7 @@ func UpdateWeekAvg() (err error) {
 			if mapContractCompanyIds[v] {
 				continue
 			}
-			fmt.Println(v)
+			//fmt.Println(v)
 			item := new(rai_serve.CygxRaiServeCompany)
 			item.CompanyId = v
 
@@ -1365,104 +1366,3 @@ func UpdateWeekAvg() (err error) {
 	fmt.Println(" UpdateWeekAvg  end")
 	return
 }
-
-// 权益服务统计添加到Redis队列中
-func CygxRaiServeBillRedisAdd(content, source string, userId, comapnyId, sourceId, registerPlatform int, viewTime time.Time) (err error) {
-	defer func() {
-		if err != nil {
-			fmt.Println(err)
-			msg := fmt.Sprint("source:", source, "userId:", userId, "sourceId", sourceId)
-			go utils.SendAlarmMsg("权益服务统计添加到Redis队列中,写入Redis队列消息失败 CygxRaiServeBillRedisAdd:"+err.Error()+msg, 2)
-		}
-	}()
-	log := &rai_serve.RaiServeBillRedis{Content: content, Source: source, UserId: userId, ComapnyId: comapnyId, SourceId: sourceId, RegisterPlatform: registerPlatform, ViewTime: viewTime}
-	if utils.Re == nil {
-		err := utils.Rc.LPush(utils.CYGX_RAI_SERVE_BILL_KEY, log)
-		if err != nil {
-			fmt.Println("RaiServeBillRedis LPush Err:" + err.Error())
-		}
-	}
-	return
-}
-
-// CygxRaiServeBillRedisAddReduce 处理权益服务统计
-func CygxRaiServeBillRedisAddReduce() (err error) {
-	for {
-		//SourceType int       `description:"1:报名、 2:取消报名、3:活动编辑、4:活动发布,取消发布、5:活动到会。"`
-		utils.Rc.Brpop(utils.CYGX_RAI_SERVE_BILL_KEY, func(b []byte) {
-			var log rai_serve.RaiServeBillRedis
-			if err := json.Unmarshal(b, &log); err != nil {
-				fmt.Println("json unmarshal wrong!")
-				go utils.SendAlarmMsg("处理权益服务统计Redis队列消息失败:"+err.Error()+string(b), 2)
-			}
-			//如果不是共享给 权益服务组的,则不处理
-			taotalRaiServe, err := company.GetCompanyProductAaiServeCount(log.ComapnyId, utils.RAI_SERVE_GROUP_ID)
-			if err != nil {
-				go utils.SendAlarmMsg("处理权益服务统计Redis队列消息失败:GetCompanyProductAaiServeCount"+err.Error()+string(b), 2)
-			}
-			fmt.Println("taotaRaiServe", taotalRaiServe)
-			if taotalRaiServe == 0 {
-				return
-			}
-
-			//如果已经有记录了就不处理
-			taotalSource, err := rai_serve.GetCygxRaiServeBillCountByUserAndSource(log.UserId, log.SourceId, log.Source)
-			if err != nil {
-				go utils.SendAlarmMsg("处理权益服务统计Redis队列消息失败:GetCygxRaiServeBillCountByUserAndSource"+err.Error()+string(b), 2)
-			}
-			if taotalSource > 0 {
-				return
-			}
-			switch log.Source {
-			case utils.CYGX_OBJ_YANXUANSPECIAL: //研选专栏阅读记录处理
-				go RaiServeBillRedisAddReduceByYanxuanspecial(log)
-				fmt.Println("研选专栏阅读记录处理")
-				break
-
-			default:
-				fmt.Println(string(b))
-				go utils.SendAlarmMsg("处理研选活动扣点处理Redis队列消息失败:"+string(b), 2)
-			}
-		})
-	}
-}
-
-// 处理权益服务统计->研选阅读记录
-func RaiServeBillRedisAddReduceByYanxuanspecial(log rai_serve.RaiServeBillRedis) (err error) {
-	source := log.Source
-	userId := log.UserId
-	sourceId := log.SourceId
-	defer func() {
-		if err != nil {
-			go utils.SendAlarmMsg("用户报名活动扣点,处理Redis队列消息失败:"+err.Error()+fmt.Sprint("source:", source, "userId:", userId, "sourceId", sourceId), 2)
-		}
-	}()
-	wxUser, e := models.GetWxUserItemByUserId(userId)
-	if e != nil {
-		err = errors.New("GetWxUserItemByUserId, Err: " + e.Error())
-		return
-	}
-	item := new(rai_serve.CygxRaiServeBill)
-	item.Content = log.Content
-	item.ServeTypeId = 5
-	item.ServeTypeName = "阅读uv"
-	item.UserId = wxUser.UserId
-	item.Mobile = wxUser.Mobile
-	item.Email = wxUser.Email
-	item.CompanyId = wxUser.CompanyId
-	item.CompanyName = wxUser.CompanyName
-	item.RealName = wxUser.RealName
-	item.RegisterPlatform = log.RegisterPlatform
-	item.ServeCount = 0.5
-
-	if wxUser.IsMaker == 1 {
-		item.IsKp = wxUser.IsMaker
-		item.ServeCount = item.ServeCount * 3
-	}
-	item.SourceId = log.SourceId
-	item.Source = log.Source
-	item.CreateTime = time.Now()
-	item.ViewTime = log.ViewTime.Format(utils.FormatDateTime)
-	err = rai_serve.AddCygxRaiServeBill(item)
-	return
-}

+ 25 - 2
services/wx_category_template_msg.go

@@ -968,7 +968,7 @@ func SendReviewCategoryTemplateMsgAdmin(specialId int) (err error) {
 	keyword1 = checkNickNameString(specialItem.NickName)
 	keyword2 = specialItem.RealName + "-" + user.CompanyName
 	keyword2 = utils.TruncateActivityNameString(keyword2)
-	keyword3 = specialItem.SpecialName
+	keyword3 = checkSpecialNameString(specialItem.SpecialName)
 	keyword4 = time.Now().Format(utils.FormatDateTimeMinute2)
 	keyword5 = "研选专栏提交了内容待审核"
 	openIdArr := make([]string, 0)
@@ -1004,9 +1004,32 @@ func checkNickNameString(s string) string {
 				break
 			}
 		} else {
-			return ""
+			return "作者昵称"
 		}
 	}
+	if trimmedString == "" {
+		trimmedString = "作者昵称"
+	}
+	return trimmedString
+}
+
+func checkSpecialNameString(s string) string {
+	var trimmedString string
+	hanCount := 0
+	for _, r := range s {
+		if unicode.Is(unicode.Han, r) {
+			trimmedString += string(r)
+			hanCount++
+			if hanCount == 5 {
+				break
+			}
+		} else {
+			return "专栏名称"
+		}
+	}
+	if trimmedString == "" {
+		trimmedString = "专栏名称"
+	}
 	return trimmedString
 }
 

+ 10 - 10
utils/config.go

@@ -61,7 +61,7 @@ var (
 	RAI_MOBILE_DONG_HENG  string // 权益董衡手机号
 	RAI_MOBILE_WU_ANG_DI  string // 权益吴昂迪手机号
 	RAI_MOBILE_GE_LIN     string // 权益葛琳手机号
-	RAI_SERVE_GROUP_ID    int    // 权益服务组,所属组的ID
+	RAI_SERVE_GROUP_ID    string // 权益服务组,麦高服务组 所属组的ID
 )
 
 // 微信公众号配置信息
@@ -193,20 +193,20 @@ func init() {
 		IndexNameComprehensive = "cygx_comprehensive"
 
 		//接收附件邮箱
-		EmailTechnology = "mlluo@hzinsights.com;jxu@hzinsights.com;tshen@hzinsights.com;cxzhang@hzinsights.com;hwang@hzinsights.com;rli@hzinsights.com"       //科技行业专家邮箱
-		EmailMedicine = "xlzheng@hzinsights.com;tshen@hzinsights.com;cxzhang@hzinsights.com;yxyan@hzinsights.com;ppwang@hzinsights.com"                       //医药行业专家邮箱
-		EmailConsumption = "yrhuang@hzinsights.com;tshen@hzinsights.com;cxzhang@hzinsights.com;jxu@hzinsights.com;hychen@hzinsights.com;lwang@hzinsights.com" //消费行业专家邮箱
-		EmailZhizao = "xfma@hzinsights.com;tkding@hzinsights.com;tshen@hzinsights.com;cxzhang@hzinsights.com"                                                 //智造行业专家邮箱
-		EmailStrategy = "experts@hzinsights.com;tshen@hzinsights.com;cxzhang@hzinsights.com"                                                                  //策略行业专家邮箱
-		EmailExpert = "experts@hzinsights.com;tshen@hzinsights.com;cxzhang@hzinsights.com"                                                                    //研选行业专家邮箱
-		EmaiWhiteUserList = "tshen@hzinsights.com;cxzhang@hzinsights.com;yyli@hzinsights.com"                                                                 //白名单邮箱
+		EmailTechnology = "mlluo@hzinsights.com;jxu@hzinsights.com;tshen@hzinsights.com;cxzhang@hzinsights.com;hwang@hzinsights.com;rli@hzinsights.com"                           //科技行业专家邮箱
+		EmailMedicine = "xlzheng@hzinsights.com;tshen@hzinsights.com;cxzhang@hzinsights.com;yxyan@hzinsights.com;ppwang@hzinsights.com;tkding@hzinsights.com;xfma@hzinsights.com" //医药行业专家邮箱
+		EmailConsumption = "yrhuang@hzinsights.com;tshen@hzinsights.com;cxzhang@hzinsights.com;jxu@hzinsights.com;hychen@hzinsights.com;lwang@hzinsights.com"                     //消费行业专家邮箱
+		EmailZhizao = "xfma@hzinsights.com;tkding@hzinsights.com;tshen@hzinsights.com;cxzhang@hzinsights.com"                                                                     //智造行业专家邮箱
+		EmailStrategy = "experts@hzinsights.com;tshen@hzinsights.com;cxzhang@hzinsights.com"                                                                                      //策略行业专家邮箱
+		EmailExpert = "experts@hzinsights.com;tshen@hzinsights.com;cxzhang@hzinsights.com"                                                                                        //研选行业专家邮箱
+		EmaiWhiteUserList = "tshen@hzinsights.com;cxzhang@hzinsights.com;yyli@hzinsights.com"                                                                                     //白名单邮箱
 		WxMsgTemplateIdAskMsg = "PaoDanHGlt1kFw5q-4_ipJSwO3FyZpxSSNg4rwB7YCk"
 		WxMsgTemplateIdArticleUserRemind = "fxnlsjx-gm3dAZVJf6f3w27wA7anETl42kexXLP8FDs"
 		WxMsgTemplateIdAskMsgMobile = ""
 		//ActSendMsgMobile = "15618524605"
 		ActSendMsgMobile = "15557270714" // 汪洋手机号
 		ArticleTaskClassMobile = "15557270714,18767183922,15216736473,15000123056,18701809782,17706316791,18652179672"
-		RAI_SERVE_GROUP_ID = 68
+		RAI_SERVE_GROUP_ID = "68,72"
 
 		ShangHaiCrmApiLink = "https://crm.hzinsights.com/"
 		SendWxTemplateMsgUrl = "http://127.0.0.1:8086/v1/wechat/send_template_msg"
@@ -244,7 +244,7 @@ func init() {
 		WxMsgTemplateIdAskMsgMobile = "15557270714,17634786714,18767183922,17516315016"
 		ActSendMsgMobile = "15557270714"
 		ArticleTaskClassMobile = "15557270714,18767183922,17706316791"
-		RAI_SERVE_GROUP_ID = 132
+		RAI_SERVE_GROUP_ID = "132,134"
 
 		ShangHaiCrmApiLink = "http://106.15.192.100:8100/"
 		SendWxTemplateMsgUrl = "http://127.0.0.1:8086/v1/wechat/send_template_msg"

+ 1 - 1
utils/constants.go

@@ -135,7 +135,7 @@ const (
 	CYGX_USER_KEY_LABEL              = "CYGX_USER_KEY_LABEL"              //查研观向用户标签
 	CYGX_YANXUAN_POINTS_KEY          = "CYGX_YANXUAN_POINTS_KEY"          //查研观向研选活动扣点KEY
 	CYGX_ARTICLE_UPDATE_KEY          = "CYGX_ARTICLE_UPDATE_KEY"          //策略平台更新文章key
-	CYGX_RAI_SERVE_BILL_KEY          = "CYGX_RAI_SERVE_BILL_KEY"          //权益服务记录明细key
+	//CYGX_RAI_SERVE_BILL_KEY          = "CYGX_RAI_SERVE_BILL_KEY"          //权益服务记录明细key
 )
 
 const (