Bläddra i källkod

Merge branch 'master' of http://8.136.199.33:3000/cxzhang/hongze_clpt into cygx_10.6

xingzai 1 år sedan
förälder
incheckning
0dd9711e39

+ 15 - 0
controllers/activity_special.go

@@ -284,6 +284,21 @@ func (this *ActivitySpecialController) SpecialTripAdd() {
 				if sellerItem != nil {
 					item.SellerName = sellerItem.RealName
 				}
+				if user.OutboundMobile != "" {
+					item.OutboundMobile = user.OutboundMobile
+					if user.OutboundCountryCode == "" {
+						item.CountryCode = "86"
+					} else {
+						item.CountryCode = user.OutboundCountryCode
+					}
+				} else {
+					item.OutboundMobile = user.Mobile
+					if user.CountryCode == "" {
+						item.CountryCode = "86"
+					} else {
+						item.CountryCode = user.CountryCode
+					}
+				}
 				err = models.AddCygxActivitySpecialTrip(item)
 				if err != nil {
 					br.Msg = "操作失败"

+ 8 - 1
controllers/search.go

@@ -7,6 +7,7 @@ import (
 	"hongze/hongze_clpt/services"
 	"hongze/hongze_clpt/utils"
 	"strings"
+	"time"
 )
 
 type SearchController struct {
@@ -308,7 +309,13 @@ func (this *MobileSearchController) BrowseHistoryList() {
 		item.KeyWord = v
 		resp.ListRecommend = append(resp.ListRecommend, item)
 	}
-	hotList, err := models.GetSearchKeyWordTop()
+	var condition string
+	var pars []interface{}
+	currentTime := time.Now()
+	starTime := currentTime.AddDate(0, 0, -8).Format("2006-01-02") + " 00:00:00"
+	endTime := currentTime.AddDate(0, 0, -1).Format("2006-01-02") + " 23:59:59"
+	condition += ` AND create_time < ` + "'" + endTime + "'" + `AND create_time > ` + "'" + starTime + "'"
+	hotList, err := models.GetSearchKeyWordTop(condition, pars)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取用户信息失败,Err:" + err.Error()

+ 8 - 8
models/search_key_word.go

@@ -17,14 +17,14 @@ type CygxSearchKeyWord struct {
 	RealName    string `description:"用户实际名称"`
 }
 
-//新增搜索
+// 新增搜索
 func AddSearchKeyWord(item *CygxSearchKeyWord) (lastId int64, err error) {
 	o := orm.NewOrm()
 	lastId, err = o.Insert(item)
 	return
 }
 
-//获取用户搜索这个关键词的最新时间
+// 获取用户搜索这个关键词的最新时间
 func GetNewSearchKeyWordByThisUser(uid int, keyWord string) (item *CygxSearchKeyWord, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_search_key_word WHERE user_id = ? AND key_word = ? ORDER BY id DESC LIMIT 1 `
@@ -32,11 +32,11 @@ func GetNewSearchKeyWordByThisUser(uid int, keyWord string) (item *CygxSearchKey
 	return
 }
 
-//获取用户搜索词汇频率较高的词
-func GetSearchKeyWordTop() (items []*CygxSearchKeyWord, err error) {
+// 获取用户搜索词汇频率较高的词
+func GetSearchKeyWordTop(condition string, pars []interface{}) (items []*CygxSearchKeyWord, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT key_word, COUNT(*) AS num FROM cygx_search_key_word GROUP BY key_word ORDER BY num DESC LIMIT 8 `
-	_, err = o.Raw(sql).QueryRows(&items)
+	sql := `SELECT key_word, MAX(create_time) as create_time, COUNT(*) AS num FROM cygx_search_key_word  WHERE 1=1  ` + condition + ` GROUP BY key_word ORDER BY num DESC,create_time DESC LIMIT 12 `
+	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }
 
@@ -47,7 +47,7 @@ func GetCygxSearchKeyWordList(condition string) (items []*CygxSearchKeyWord, err
 	return
 }
 
-//修改用户搜索的相关信息
+// 修改用户搜索的相关信息
 func UpdateCygxSearchKeyWord(wxUser *WxUserItem) (err error) {
 	o := orm.NewOrm()
 	var sql string
@@ -61,7 +61,7 @@ func UpdateCygxSearchKeyWord(wxUser *WxUserItem) (err error) {
 	return
 }
 
-//GetSearchKeyWordByUser 获取用户搜索历史记录
+// GetSearchKeyWordByUser 获取用户搜索历史记录
 func GetSearchKeyWordByUser(uid int) (items []*KeyWord, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT key_word, MAX( id ) AS maxId  FROM	cygx_search_key_word_log WHERE	user_id = ? GROUP BY	key_word ORDER BY	maxId DESC 	LIMIT 8 `

+ 9 - 13
services/activity.go

@@ -889,20 +889,16 @@ func GetActivityNewLabelMap(activityIds []int) (labelMap map[int]bool, industryN
 			}
 		}
 	}
-
-	//for _, v := range activityIds {
-	//	labelMap[v] = true
+	//
+	//////产业关联的弘则报告发布日期在三个月以内的活动、产业显示 NEW标签
+	//articNewLabel, e := GetArticNewLabelWhithActivity3Month()
+	//if e != nil {
+	//	err = errors.New("获取产业新标签Map失败, Err: " + e.Error())
+	//	return
+	//}
+	//for k := range articNewLabel {
+	//	labelMap[k] = true
 	//}
-	//fmt.Println(labelMap)
-	////产业关联的弘则报告发布日期在三个月以内的活动、产业显示 NEW标签
-	articNewLabel, e := GetArticNewLabelWhithActivity3Month()
-	if e != nil {
-		err = errors.New("获取产业新标签Map失败, Err: " + e.Error())
-		return
-	}
-	for k := range articNewLabel {
-		labelMap[k] = true
-	}
 	return
 }
 

+ 13 - 10
services/article_history.go

@@ -15,15 +15,7 @@ func ArticleHistory(articleId int, user *models.WxUserItem) (err error) {
 			go utils.SendAlarmMsg("记录用户文章浏览记录,失败"+err.Error(), 2)
 		}
 	}()
-	recordRedis := new(ReportViewRecord)
-	recordRedis.UserId = user.UserId
-	recordRedis.ReportId = articleId
-	recordRedis.Mobile = user.Mobile
-	recordRedis.Email = user.Email
-	recordRedis.RealName = user.RealName
-	recordRedis.CompanyName = user.CompanyName
-	recordRedis.CreateTime = time.Now()
-	go PushViewRecordNewRedisData(recordRedis, user.CompanyId)
+
 	uid := user.UserId
 	key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
 	if !utils.Rc.IsExist(key) {
@@ -79,11 +71,22 @@ func ArticleHistoryStopTime(articleId, stopTime, outType int, user *models.WxUse
 		record.StopTime = stopTime
 		record.OutType = outType
 		record.Source = "WEB"
-		_, e := models.AddCygxArticleViewRecordNewpv(record)
+		newId, e := models.AddCygxArticleViewRecordNewpv(record)
 		if e != nil {
 			err = errors.New("AddCygxArticleViewRecordNewpv, Err: " + e.Error())
 			return
 		}
+		recordRedis := new(ReportViewRecord)
+		recordRedis.UserId = user.UserId
+		recordRedis.ReportId = articleId
+		recordRedis.Mobile = user.Mobile
+		recordRedis.Email = user.Email
+		recordRedis.RealName = user.RealName
+		recordRedis.CompanyName = user.CompanyName
+		recordRedis.StopTime = stopTime
+		recordRedis.OutId = int(newId)
+		recordRedis.CreateTime = time.Now()
+		go PushViewRecordNewRedisData(recordRedis, user.CompanyId)
 		utils.Rc.Put(key, 1, 2*time.Second)
 	}
 	go ArticleHistoryUserLabelLogAdd(articleId, uid)

+ 46 - 23
services/article_red.go

@@ -64,38 +64,61 @@ func GetShowTimeLineIsRed(user *models.WxUserItem, industrialManagementId int) (
 
 }
 
-// UserViewRedisData 阅读数据
+//// UserViewRedisData 阅读数据
+//type UserViewRedisData struct {
+//	Mobile      string `json:"mobile"`
+//	Email       string `json:"email"`
+//	RealName    string `json:"real_name"`
+//	CompanyName string `json:"company_name"`
+//	ViewTime    string `json:"view_time" description:"阅读时间,格式:2022-02-17 13:06:13"`
+//	ProductId   int    `json:"product_id" description:"报告所属产品,ficc:1,权益:2"`
+//	CompanyId   int    `json:"company_id" description:"客户id"`
+//}
+
 type UserViewRedisData struct {
-	Mobile      string `json:"mobile"`
-	Email       string `json:"email"`
-	RealName    string `json:"real_name"`
-	CompanyName string `json:"company_name"`
-	ViewTime    string `json:"view_time" description:"阅读时间,格式:2022-02-17 13:06:13"`
-	ProductId   int    `json:"product_id" description:"报告所属产品,ficc:1,权益:2"`
-	CompanyId   int    `json:"company_id" description:"客户id"`
+	Mobile          string `json:"mobile"`
+	Email           string `json:"email"`
+	RealName        string `json:"real_name"`
+	CompanyName     string `json:"company_name"`
+	ViewTime        string `json:"view_time" description:"阅读时间,格式:2022-02-17 13:06:13"`
+	ProductId       int    `json:"product_id" description:"报告所属产品,ficc:1,权益:2"`
+	CompanyId       int    `json:"company_id" description:"客户id"`
+	UserId          int    `json:"user_id" description:"用户id"`
+	ReportId        int    `json:"report_id" description:"报告id"`
+	StopTime        int    `json:"stop_time" description:"停留时间"`
+	ReportChapterId int    `json:"report_chapter_id" description:"章节ID"`
+	OutId           int    `json:"out_id" description:"记录ID"`
 }
 
 type ReportViewRecord struct {
-	Id          int       `orm:"column(id);pk"`
-	UserId      int       `description:"用户id"`
-	ReportId    int       `description:"报告id"`
-	Mobile      string    `description:"手机号"`
-	Email       string    `description:"邮箱"`
-	RealName    string    `description:"用户实际姓名"`
-	CompanyName string    `description:"公司名称"`
-	CreateTime  time.Time `description:"创建时间"`
+	Id              int       `orm:"column(id);pk"`
+	UserId          int       `description:"用户id"`
+	ReportId        int       `description:"报告id"`
+	Mobile          string    `description:"手机号"`
+	Email           string    `description:"邮箱"`
+	RealName        string    `description:"用户实际姓名"`
+	CompanyName     string    `description:"公司名称"`
+	CreateTime      time.Time `description:"创建时间"`
+	StopTime        int       `json:"stop_time" description:"停留时间"`
+	ReportChapterId int       `json:"report_chapter_id" description:"章节ID"`
+	OutId           int       `json:"out_id" description:"记录ID"`
 }
 
 // PushViewRecordNewRedisData 阅读数据加入到redis
 func PushViewRecordNewRedisData(reportViewRecord *ReportViewRecord, companyId int) bool {
 	data := &UserViewRedisData{
-		Mobile:      reportViewRecord.Mobile,
-		Email:       reportViewRecord.Email,
-		RealName:    reportViewRecord.RealName,
-		CompanyName: reportViewRecord.CompanyName,
-		ViewTime:    reportViewRecord.CreateTime.Format(utils.FormatDateTime),
-		ProductId:   2,
-		CompanyId:   companyId,
+		Mobile:          reportViewRecord.Mobile,
+		Email:           reportViewRecord.Email,
+		RealName:        reportViewRecord.RealName,
+		CompanyName:     reportViewRecord.CompanyName,
+		ViewTime:        reportViewRecord.CreateTime.Format(utils.FormatDateTime),
+		ProductId:       2,
+		CompanyId:       companyId,
+		UserId:          reportViewRecord.UserId,
+		ReportId:        reportViewRecord.ReportId,
+		StopTime:        reportViewRecord.StopTime,
+		ReportChapterId: reportViewRecord.ReportChapterId,
+		OutId:           reportViewRecord.OutId,
 	}
 	if utils.Re == nil {
 		err := utils.Rc.LPush(utils.CACHE_KEY_USER_VIEW, data)