Bladeren bron

Merge branch 'master' of http://8.136.199.33:3000/hongze/hongze_cygx into cygx_need_wx_msg_5.9

xingzai 1 jaar geleden
bovenliggende
commit
6faf5d6a24

+ 7 - 0
controllers/activity.go

@@ -543,6 +543,10 @@ func (this *ActivityCoAntroller) Detail() {
 		}
 		//处理按钮是否展示问题
 		resp.Detail = services.ActivityButtonShow(activityInfo)
+		// 暂时写死,客户需要 5.16
+		if activityInfo.ActivityId == 2992 {
+			activityInfo.ActivityTypeName = "分析师线下沙龙"
+		}
 	} else {
 		hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo)
 		if err != nil {
@@ -606,6 +610,9 @@ func (this *ActivityCoAntroller) SignupAdd() {
 		br.ErrMsg = "参数解析失败,Err:" + err.Error()
 		return
 	}
+	if user.Mobile == "" {
+		user.Mobile = user.OutboundMobile
+	}
 	activityId := req.ActivityId
 	signupType := req.SignupType
 	hasPermission := 0

+ 97 - 0
controllers/banner.go

@@ -0,0 +1,97 @@
+package controllers
+
+import (
+	"encoding/json"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/services"
+)
+
+// Banner
+type BannerController struct {
+	BaseAuthController
+}
+
+// @Title 列表
+// @Description 列表接口
+// @Success Ret=200 {object} cygx.CygxBannerListResp
+// @router /list [get]
+func (this *BannerController) List() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	resp := new(models.CygxBannerListResp)
+	var condition string
+	var pars []interface{}
+	condition += "	 AND art.status = 1 ORDER BY art. list_type ASC   , art.sort ASC  "
+	list, err := models.GetCygxBannerList(condition, pars, 0, 99999)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	bannerImgList, err := models.GetCygxBannerImgList()
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	mapImg := make(map[int]string)
+	for _, v := range bannerImgList {
+		mapImg[v.ImgId] = v.IndexImg
+	}
+	for _, v := range list {
+		v.IndexImg = mapImg[v.ImgId]
+		v.BannerUrlResp = services.GetBannerUrlBody(v.Link)
+	}
+	resp.List = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 记录点击信息
+// @Description 记录点击信息
+// @Param	request	body cygx.CygxBannerIdReq true "type json string"
+// @Success 200 Ret=200 发布成功
+// @router /add/history [post]
+func (this *BannerController) History() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	var req models.CygxBannerIdReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	bannerId := req.BannerId
+	if bannerId == 0 {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误,id不可为空"
+		return
+	}
+	go services.AddCygxBannerHistory(user, bannerId)
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "记录成功"
+}

+ 8 - 3
controllers/home.go

@@ -672,13 +672,18 @@ func (this *HomeController) NewList() {
 	var condition string
 	var conditionInit string
 	var pars []interface{}
-	var total int
+	//var total int
 	resp := new(models.HomeResourceDataListResp)
-
+	totalRai, err := models.GetCountCompanyProductCompanyId(user.CompanyId, utils.COMPANY_PRODUCT_RAI_ID)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取失败"
+		br.ErrMsg = "GetCountCompanyProductCompanyId,Err:" + err.Error()
+		return
+	}
 	//condition += " AND source = 'article' "
 	//查询近一个月的数据
 	conditionInit = " AND publish_date  >   '" + time.Now().AddDate(0, 0, -30).Format(utils.FormatDateTime) + "'"
-	if user.CompanyId <= 1 {
+	if user.CompanyId <= 1 || totalRai == 0 {
 		condition += " AND source IN ('roadshow','article','activityvideo','activityvoice') " + conditionInit
 		if user.Mobile == "" && user.Email == "" {
 			startSize = 0

+ 90 - 88
controllers/report.go

@@ -731,14 +731,16 @@ func (this *ReportController) List() {
 			list[k].ImgUrlPc = mapCategoryUrl[id]
 
 			if mapCategoryUrl[id] == "" {
-				if detail.ChartPermissionId == utils.YI_YAO_ID {
-					list[k].ImgUrlPc = utils.YI_YAO_QI_TA
+				if detail != nil {
+					if detail.ChartPermissionId == utils.YI_YAO_ID {
+						list[k].ImgUrlPc = utils.YI_YAO_QI_TA
+					}
 				}
 			}
 		}
 
 		resp := new(models.TimeLineReportListResp)
-		resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
+		//resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
 
 		resp.List = list
 		resp.Paging = page
@@ -1580,7 +1582,7 @@ func (this *ReportController) Detail() {
 	//	br.IsSendEmail = false
 	//	return
 	//}
-	uid := user.UserId
+	//uid := user.UserId
 	articleId, _ := this.GetInt("ArticleId")
 	isBestNew, _ := this.GetBool("IsBestNew")
 	if isBestNew {
@@ -1729,27 +1731,27 @@ func (this *ReportController) Detail() {
 		existMap[v.ChartPermissionId] = v.ChartPermissionId
 	}
 
-	historyRecord := new(models.CygxReportHistoryRecord)
-	historyRecord.UserId = uid
-	historyRecord.ArticleId = articleId
-	historyRecord.CreateTime = time.Now()
-	historyRecord.Mobile = user.Mobile
-	historyRecord.Email = user.Email
-	historyRecord.CompanyId = user.CompanyId
-	historyRecord.CompanyName = user.CompanyName
-	historyRecord.ReportType = "bgjx"
-	sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
-	if err != nil && err.Error() != utils.ErrNoRow() {
-		br.Msg = "获取信息失败"
-		br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
-		return
-	}
-	historyRecord.RealName = user.RealName
-	if sellerItem != nil {
-		historyRecord.SellerName = sellerItem.RealName
-	}
-
-	go models.AddCygxReportHistoryRecord(historyRecord)
+	//historyRecord := new(models.CygxReportHistoryRecord)
+	//historyRecord.UserId = uid
+	//historyRecord.ArticleId = articleId
+	//historyRecord.CreateTime = time.Now()
+	//historyRecord.Mobile = user.Mobile
+	//historyRecord.Email = user.Email
+	//historyRecord.CompanyId = user.CompanyId
+	//historyRecord.CompanyName = user.CompanyName
+	//historyRecord.ReportType = "bgjx"
+	//sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	//if err != nil && err.Error() != utils.ErrNoRow() {
+	//	br.Msg = "获取信息失败"
+	//	br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+	//	return
+	//}
+	//historyRecord.RealName = user.RealName
+	//if sellerItem != nil {
+	//	historyRecord.SellerName = sellerItem.RealName
+	//}
+	//
+	//go models.AddCygxReportHistoryRecord(historyRecord)
 	resp.List = items
 	resp.ListPermissionSubject = itemsSubject
 	resp.Detail = detail
@@ -1776,7 +1778,7 @@ func (this *ReportController) ResearchDetail() {
 		br.Ret = 408
 		return
 	}
-	uid := user.UserId
+	//uid := user.UserId
 	articleId, _ := this.GetInt("ArticleId")
 	if articleId < 0 {
 		br.Msg = "参数错误"
@@ -1886,26 +1888,26 @@ func (this *ReportController) ResearchDetail() {
 			listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
 		}
 	}
-	historyRecord := new(models.CygxReportHistoryRecord)
-	historyRecord.UserId = uid
-	historyRecord.ArticleId = articleId
-	historyRecord.CreateTime = time.Now()
-	historyRecord.Mobile = user.Mobile
-	historyRecord.Email = user.Email
-	historyRecord.CompanyId = user.CompanyId
-	historyRecord.CompanyName = user.CompanyName
-	historyRecord.ReportType = "bzyjhz"
-	sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
-	if err != nil && err.Error() != utils.ErrNoRow() {
-		br.Msg = "获取信息失败"
-		br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
-		return
-	}
-	historyRecord.RealName = user.RealName
-	if sellerItem != nil {
-		historyRecord.SellerName = sellerItem.RealName
-	}
-	go models.AddCygxReportHistoryRecord(historyRecord)
+	//historyRecord := new(models.CygxReportHistoryRecord)
+	//historyRecord.UserId = uid
+	//historyRecord.ArticleId = articleId
+	//historyRecord.CreateTime = time.Now()
+	//historyRecord.Mobile = user.Mobile
+	//historyRecord.Email = user.Email
+	//historyRecord.CompanyId = user.CompanyId
+	//historyRecord.CompanyName = user.CompanyName
+	//historyRecord.ReportType = "bzyjhz"
+	//sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	//if err != nil && err.Error() != utils.ErrNoRow() {
+	//	br.Msg = "获取信息失败"
+	//	br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+	//	return
+	//}
+	//historyRecord.RealName = user.RealName
+	//if sellerItem != nil {
+	//	historyRecord.SellerName = sellerItem.RealName
+	//}
+	//go models.AddCygxReportHistoryRecord(historyRecord)
 	resp.List = listFirst
 	resp.Detail = detail
 	br.Ret = 200
@@ -1931,7 +1933,7 @@ func (this *ReportController) MinutesDetailV4() {
 		br.Ret = 408
 		return
 	}
-	uid := user.UserId
+	//uid := user.UserId
 	articleId, _ := this.GetInt("ArticleId")
 	if articleId < 0 {
 		br.Msg = "参数错误"
@@ -2020,26 +2022,26 @@ func (this *ReportController) MinutesDetailV4() {
 			listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
 		}
 	}
-	historyRecord := new(models.CygxReportHistoryRecord)
-	historyRecord.UserId = uid
-	historyRecord.ArticleId = articleId
-	historyRecord.CreateTime = time.Now()
-	historyRecord.Mobile = user.Mobile
-	historyRecord.Email = user.Email
-	historyRecord.CompanyId = user.CompanyId
-	historyRecord.CompanyName = user.CompanyName
-	historyRecord.ReportType = "szjyhz"
-	sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
-	if err != nil && err.Error() != utils.ErrNoRow() {
-		br.Msg = "获取信息失败"
-		br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
-		return
-	}
-	historyRecord.RealName = user.RealName
-	if sellerItem != nil {
-		historyRecord.SellerName = sellerItem.RealName
-	}
-	go models.AddCygxReportHistoryRecord(historyRecord)
+	//historyRecord := new(models.CygxReportHistoryRecord)
+	//historyRecord.UserId = uid
+	//historyRecord.ArticleId = articleId
+	//historyRecord.CreateTime = time.Now()
+	//historyRecord.Mobile = user.Mobile
+	//historyRecord.Email = user.Email
+	//historyRecord.CompanyId = user.CompanyId
+	//historyRecord.CompanyName = user.CompanyName
+	//historyRecord.ReportType = "szjyhz"
+	//sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	//if err != nil && err.Error() != utils.ErrNoRow() {
+	//	br.Msg = "获取信息失败"
+	//	br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+	//	return
+	//}
+	//historyRecord.RealName = user.RealName
+	//if sellerItem != nil {
+	//	historyRecord.SellerName = sellerItem.RealName
+	//}
+	//go models.AddCygxReportHistoryRecord(historyRecord)
 	resp.List = listFirst
 	resp.Detail = detail
 	br.Ret = 200
@@ -2065,7 +2067,7 @@ func (this *ReportController) MinutesDetail() {
 		br.Ret = 408
 		return
 	}
-	uid := user.UserId
+	//uid := user.UserId
 	articleId, _ := this.GetInt("ArticleId")
 	if articleId < 0 {
 		br.Msg = "参数错误"
@@ -2117,26 +2119,26 @@ func (this *ReportController) MinutesDetail() {
 			}
 		}
 	}
-	historyRecord := new(models.CygxReportHistoryRecord)
-	historyRecord.UserId = uid
-	historyRecord.ArticleId = articleId
-	historyRecord.CreateTime = time.Now()
-	historyRecord.Mobile = user.Mobile
-	historyRecord.Email = user.Email
-	historyRecord.CompanyId = user.CompanyId
-	historyRecord.CompanyName = user.CompanyName
-	historyRecord.ReportType = "szjyhz"
-	sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
-	if err != nil && err.Error() != utils.ErrNoRow() {
-		br.Msg = "获取信息失败"
-		br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
-		return
-	}
-	historyRecord.RealName = user.RealName
-	if sellerItem != nil {
-		historyRecord.SellerName = sellerItem.RealName
-	}
-	go models.AddCygxReportHistoryRecord(historyRecord)
+	//historyRecord := new(models.CygxReportHistoryRecord)
+	//historyRecord.UserId = uid
+	//historyRecord.ArticleId = articleId
+	//historyRecord.CreateTime = time.Now()
+	//historyRecord.Mobile = user.Mobile
+	//historyRecord.Email = user.Email
+	//historyRecord.CompanyId = user.CompanyId
+	//historyRecord.CompanyName = user.CompanyName
+	//historyRecord.ReportType = "szjyhz"
+	//sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	//if err != nil && err.Error() != utils.ErrNoRow() {
+	//	br.Msg = "获取信息失败"
+	//	br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+	//	return
+	//}
+	//historyRecord.RealName = user.RealName
+	//if sellerItem != nil {
+	//	historyRecord.SellerName = sellerItem.RealName
+	//}
+	//go models.AddCygxReportHistoryRecord(historyRecord)
 	resp.List = listLog
 	resp.Detail = detail
 	br.Ret = 200

+ 97 - 22
controllers/report_selection.go

@@ -33,7 +33,7 @@ func (this *ReportSelectionController) Detail() {
 		br.Ret = 408
 		return
 	}
-	uid := user.UserId
+	//uid := user.UserId
 	articleId, _ := this.GetInt("ArticleId")
 	isBestNew, _ := this.GetBool("IsBestNew")
 	isBestNew = true
@@ -148,27 +148,27 @@ func (this *ReportSelectionController) Detail() {
 		existMap[v.ChartPermissionId] = v.ChartPermissionId
 	}
 
-	historyRecord := new(models.CygxReportHistoryRecord)
-	historyRecord.UserId = uid
-	historyRecord.ArticleId = articleId
-	historyRecord.CreateTime = time.Now()
-	historyRecord.Mobile = user.Mobile
-	historyRecord.Email = user.Email
-	historyRecord.CompanyId = user.CompanyId
-	historyRecord.CompanyName = user.CompanyName
-	historyRecord.ReportType = "bgjx"
-	sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
-	if err != nil && err.Error() != utils.ErrNoRow() {
-		br.Msg = "获取信息失败"
-		br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
-		return
-	}
-	historyRecord.RealName = user.RealName
-	if sellerItem != nil {
-		historyRecord.SellerName = sellerItem.RealName
-	}
-
-	go models.AddCygxReportHistoryRecord(historyRecord)
+	//historyRecord := new(models.CygxReportHistoryRecord)
+	//historyRecord.UserId = uid
+	//historyRecord.ArticleId = articleId
+	//historyRecord.CreateTime = time.Now()
+	//historyRecord.Mobile = user.Mobile
+	//historyRecord.Email = user.Email
+	//historyRecord.CompanyId = user.CompanyId
+	//historyRecord.CompanyName = user.CompanyName
+	//historyRecord.ReportType = "bgjx"
+	//sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	//if err != nil && err.Error() != utils.ErrNoRow() {
+	//	br.Msg = "获取信息失败"
+	//	br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+	//	return
+	//}
+	//historyRecord.RealName = user.RealName
+	//if sellerItem != nil {
+	//	historyRecord.SellerName = sellerItem.RealName
+	//}
+	//
+	//go models.AddCygxReportHistoryRecord(historyRecord)
 	resp.List = items
 	resp.ListPermissionSubject = itemsSubject
 	resp.Detail = detail
@@ -232,3 +232,78 @@ func (this *ReportSelectionController) ClickHistory() {
 	br.Success = true
 	br.Msg = "记录成功"
 }
+
+// @Title 上传文章阅读时间
+// @Description 上传文章阅读时间接口
+// @Param  request	body models.AddStopTimeRep true "type json string"
+// @Success 200 {object} models.ArticleDetailResp
+// @router /addStopTime [post]
+func (this *ReportSelectionController) AddStopTime() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	var req models.AddReportSelectionStopTimeRep
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	uid := user.UserId
+	articleId := req.ArticleId
+	stopTime := req.StopTime
+	outType := req.OutType
+	source := req.Source
+	var reportType string
+	if source == 1 {
+		reportType = "bgjx"
+	} else if source == 2 {
+		reportType = "bzyjhz"
+	} else if source == 3 {
+		reportType = "szjyhz"
+	}
+	hasPermission, err := services.GetUserhasPermission(user)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
+	}
+
+	if hasPermission == 1 {
+		historyRecord := new(models.CygxReportHistoryRecord)
+		historyRecord.UserId = uid
+		historyRecord.ArticleId = articleId
+		historyRecord.CreateTime = time.Now().Add(-time.Second * time.Duration(stopTime))
+		historyRecord.Mobile = user.Mobile
+		historyRecord.Email = user.Email
+		historyRecord.CompanyId = user.CompanyId
+		historyRecord.CompanyName = user.CompanyName
+		historyRecord.StopTime = stopTime
+		historyRecord.OutType = outType
+		historyRecord.ReportType = reportType
+		historyRecord.RegisterPlatform = utils.REGISTER_PLATFORM
+		sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+			return
+		}
+		historyRecord.RealName = user.RealName
+		if sellerItem != nil {
+			historyRecord.SellerName = sellerItem.RealName
+		}
+		go services.AddCygxReportHistoryRecord(historyRecord)
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "操作成功"
+}

+ 6 - 1
controllers/user.go

@@ -158,7 +158,7 @@ func (this *UserController) Login() {
 	{
 		loginLog := new(models.WxUserLog)
 		loginLog.UserId = userId
-		loginLog.OpenId = unionId
+		loginLog.OpenId = openId
 		loginLog.Mobile = req.Mobile
 		loginLog.Email = req.Email
 		loginLog.CreateTime = time.Now()
@@ -187,6 +187,11 @@ func (this *UserController) Login() {
 			}
 		}
 	}
+
+	//先关注后登录,更新用户是否关注过查研观向小助手公众号
+	{
+		services.UpdateCygxSubscribe(userId, unionId)
+	}
 	resp := new(models.LoginResp)
 	resp.UserId = userId
 	resp.Authorization = token

+ 81 - 0
models/banner.go

@@ -0,0 +1,81 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+)
+
+type CygxBannerResp struct {
+	BannerId       int            `description:"BannerId等于0新增,大于零修改"`
+	ImgId          int            `description:"cygx_banner_img主键ID"`
+	IndexImg       string         `description:"小程序封面图"`
+	ListType       string         `description:"ABC哪一列"`
+	BannerTypeName string         `description:"添加类型名称"`
+	Title          string         `description:"标题"`
+	Link           string         `description:"链接地址"`
+	Subtitle       string         `description:"副标题"`
+	BannerUrlResp  *BannerUrlResp `description:"跳转地址"`
+}
+
+type CygxBannerIdReq struct {
+	BannerId int `description:"BannerId"`
+}
+
+type GetCygxBannerImgRespDetailResp struct {
+	Detail *CygxBannerResp
+}
+
+// 通过ID获取详情
+func GetCygxBannerDetail(banneId int) (item *CygxBannerResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_banner  WHERE banner_id=? `
+	err = o.Raw(sql, banneId).QueryRow(&item)
+	return
+}
+
+// 获取数量
+func GetCygxBannerCount(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_banner as art WHERE 1= 1  `
+	if condition != "" {
+		sqlCount += condition
+	}
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+// 列表
+func GetCygxBannerList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxBannerResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_banner as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,?  `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+type CygxBannerListResp struct {
+	List []*CygxBannerResp
+}
+
+type CygxBannerImgResp struct {
+	ImgId    int    `description:"图片ID"`
+	IndexImg string `description:"小程序封面图"`
+}
+
+type BannerUrlResp struct {
+	ChartPermissionId int    `description:"行业id"`
+	SourceId          int    `description:"资源ID"`
+	Type              int    `description:"类型:1普通文本,2:文章、3:活动、4:产业、5:关于我们、6:产品内测"`
+	Body              string `description:"内容"`
+	Path              string `description:"小程序路径"`
+}
+
+// 列表
+func GetCygxBannerImgList() (items []*CygxBannerImgResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_banner_img as art WHERE 1= 1 `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 29 - 0
models/banner_history.go

@@ -0,0 +1,29 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxBannerHistory struct {
+	Id               int `orm:"column(id);pk"`
+	BannerId         int `description:"BannerId等于0新增,大于零修改"`
+	UserId           int
+	CreateTime       time.Time
+	Mobile           string    `description:"手机号"`
+	Email            string    `description:"邮箱"`
+	CompanyId        int       `description:"公司id"`
+	CompanyName      string    `description:"公司名称"`
+	ModifyTime       time.Time `description:"修改时间"`
+	RealName         string    `description:"用户实际名称"`
+	SellerName       string    `description:"所属销售"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
+}
+
+// 添加历史信息
+func AddCygxBannerHistory(item *CygxBannerHistory) (lastId int64, err error) {
+	o := orm.NewOrm()
+	item.ModifyTime = time.Now()
+	lastId, err = o.Insert(item)
+	return
+}

+ 26 - 0
models/chart.go

@@ -318,3 +318,29 @@ func GetChartDetailById(chartId, uid int) (item *CygxChartDetail, err error) {
 	err = o.Raw(sql, uid, chartId).QueryRow(&item)
 	return
 }
+
+// 删除
+func DeleteCygxChart(chartId int) (err error) {
+	o, err := orm.NewOrm().Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+
+		if err == nil {
+			o.Commit()
+		} else {
+			o.Rollback()
+		}
+	}()
+	sql := `DELETE  FROM cygx_chart   WHERE  chart_id=? `
+	_, err = o.Raw(sql, chartId).Exec()
+
+	if err != nil {
+		return err
+	}
+
+	sql = `DELETE  FROM cygx_chart_all   WHERE  chart_id=? `
+	_, err = o.Raw(sql, chartId).Exec()
+	return
+}

+ 12 - 0
models/company_product.go

@@ -0,0 +1,12 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+)
+
+// 获取是否属于权益客户
+func GetCountCompanyProductCompanyId(companyId, productId int) (count int, err error) {
+	sql := `SELECT  COUNT(1) AS count FROM company_product WHERE company_id = ?  AND product_id = ?  `
+	err = orm.NewOrm().Raw(sql, companyId, productId).QueryRow(&count)
+	return
+}

+ 14 - 6
models/cygx_user_record.go

@@ -6,23 +6,31 @@ import (
 )
 
 type CygxUserRecord struct {
-	UserRecordId int       `orm:"column(user_record_id);pk" description:"id"`
-	OpenId       string    `description:"用户openid,最大长度:32"`
-	UnionId      string    `description:"用户unionid,最大长度:64"`
-	CreateTime   time.Time `description:"提交建议时间"`
+	UserRecordId  int       `orm:"column(user_record_id);pk" description:"id"`
+	OpenId        string    `description:"用户openid,最大长度:32"`
+	UnionId       string    `description:"用户unionid,最大长度:64"`
+	Subscribe     int       `description:"是否关注,0:未关注,1:已关注"`
+	SubscribeTime string    `description:"关注/取消关注时间"`
+	CreateTime    time.Time `description:"创建时间"`
 }
 
-//添加优化建议
+// 优化建议
 func AddCygxUserRecord(item *CygxUserRecord) (lastId int64, err error) {
 	o := orm.NewOrm()
 	lastId, err = o.Insert(item)
 	return
 }
 
-//获取数量
+// 获取数量
 func GetCygxUserRecordCount(openId string) (count int, err error) {
 	o := orm.NewOrm()
 	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_user_record WHERE open_id=? `
 	err = o.Raw(sqlCount, openId).QueryRow(&count)
 	return
 }
+
+func GetCygxUserRecordSubscribe(unionId string) (item *CygxUserRecord, err error) {
+	sql := ` SELECT * FROM cygx_user_record WHERE union_id=?  AND subscribe = 1  limit 1 `
+	err = orm.NewOrm().Raw(sql, unionId).QueryRow(&item)
+	return
+}

+ 2 - 0
models/db.go

@@ -145,6 +145,8 @@ func init() {
 		new(CygxReportMappingGroup),
 		new(CygxAboutUsVideoHistory),
 		new(CygxActivitySignupBreak),
+		new(CygxBannerHistory),
+		new(CygxReportHistoryRecordLog),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 42 - 13
models/report_history_record.go

@@ -6,24 +6,53 @@ import (
 )
 
 type CygxReportHistoryRecord struct {
-	Id          int `orm:"column(id);pk"`
-	ArticleId   int
-	UserId      int
-	CreateTime  time.Time
-	Mobile      string    `description:"手机号"`
-	Email       string    `description:"邮箱"`
-	CompanyId   int       `description:"公司id"`
-	CompanyName string    `description:"公司名称"`
-	ModifyTime  time.Time `description:"修改时间"`
-	ReportType  string    `description:"报告类型,bgjx:报告精选、bzyjhz:本周研究汇总、szjyhz:上周纪要汇总"`
-	RealName    string    `description:"用户实际名称"`
-	SellerName  string    `description:"所属销售"`
+	Id               int `orm:"column(id);pk"`
+	ArticleId        int
+	UserId           int
+	CreateTime       time.Time
+	Mobile           string    `description:"手机号"`
+	Email            string    `description:"邮箱"`
+	CompanyId        int       `description:"公司id"`
+	CompanyName      string    `description:"公司名称"`
+	ModifyTime       time.Time `description:"修改时间"`
+	ReportType       string    `description:"报告类型,bgjx:报告精选、bzyjhz:本周研究汇总、szjyhz:上周纪要汇总"`
+	RealName         string    `description:"用户实际名称"`
+	SellerName       string    `description:"所属销售"`
+	StopTime         int       `description:"停留时间"`
+	OutType          int       `description:"退出方式,1正常退出,2强制关闭"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
 }
 
-//添加历史信息
+type CygxReportHistoryRecordLog struct {
+	Id               int `orm:"column(id);pk"`
+	ArticleId        int
+	UserId           int
+	CreateTime       time.Time
+	Mobile           string    `description:"手机号"`
+	Email            string    `description:"邮箱"`
+	CompanyId        int       `description:"公司id"`
+	CompanyName      string    `description:"公司名称"`
+	ModifyTime       time.Time `description:"修改时间"`
+	ReportType       string    `description:"报告类型,bgjx:报告精选、bzyjhz:本周研究汇总、szjyhz:上周纪要汇总"`
+	RealName         string    `description:"用户实际名称"`
+	SellerName       string    `description:"所属销售"`
+	StopTime         int       `description:"停留时间"`
+	OutType          int       `description:"退出方式,1正常退出,2强制关闭"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
+}
+
+// 添加历史信息
 func AddCygxReportHistoryRecord(item *CygxReportHistoryRecord) (lastId int64, err error) {
 	o := orm.NewOrm()
 	item.ModifyTime = time.Now()
 	lastId, err = o.Insert(item)
 	return
 }
+
+// 添加历史信息
+func AddCygxReportHistoryRecordLog(item *CygxReportHistoryRecordLog) (lastId int64, err error) {
+	o := orm.NewOrm()
+	item.ModifyTime = time.Now()
+	lastId, err = o.Insert(item)
+	return
+}

+ 7 - 0
models/report_selection.go

@@ -188,3 +188,10 @@ func GetIndustrialByIds(industrialManagementIds string) (items []*IndustriaRepor
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
+
+type AddReportSelectionStopTimeRep struct {
+	ArticleId int `description:"文章ID"`
+	StopTime  int `description:"停留时间"`
+	OutType   int `description:"退出方式,1正常退出,2强制关闭"`
+	Source    int `description:"来源,1:报告精选、2:本周研究汇总、3:上周纪要汇总"`
+}

+ 31 - 24
models/wx_user.go

@@ -52,7 +52,7 @@ type WxUser struct {
 	TripartiteCode      string    `description:"第三方给过来的用户编码,判断用户是否存在"`
 }
 
-//添加用户信息
+// 添加用户信息
 func AddWxUser(item *WxUser) (lastId int64, err error) {
 	o := orm.NewOrm()
 	lastId, err = o.Insert(item)
@@ -94,7 +94,7 @@ func GetWxUserItemByUnionid(unionid string) (item *WxUserItem, err error) {
 	return
 }
 
-//根据用户ID获取相关信息
+// 根据用户ID获取相关信息
 func GetWxUserItemByUserId(userId int) (item *WxUserItem, err error) {
 	sql := `SELECT a.*,b.company_name FROM wx_user AS a
 			LEFT JOIN company AS b on a.company_id=b.company_id
@@ -129,7 +129,7 @@ type WxGetUserInfoReq struct {
 	Iv            string `description:"iv"`
 }
 
-//修改用户会话key
+// 修改用户会话key
 func ModifyWxUserSessionKey(sessionKey string, userId int) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE wx_user SET session_key=? WHERE user_id=? `
@@ -137,7 +137,7 @@ func ModifyWxUserSessionKey(sessionKey string, userId int) (err error) {
 	return
 }
 
-//添加用户信息
+// 添加用户信息
 func ModifyWxUserInfo(unionId, nickName, province, city, country, avatar string, gender, userId int) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE wx_user SET union_id=?,unionid=?,nick_name=?,sex=?,province=?,city=?,country=?,headimgurl=? WHERE user_id=? `
@@ -145,7 +145,7 @@ func ModifyWxUserInfo(unionId, nickName, province, city, country, avatar string,
 	return
 }
 
-//修改用户会话key
+// 修改用户会话key
 func DeleteWxUserByUserId(userId int) (err error) {
 	o := orm.NewOrm()
 	sql := `DELETE FROM wx_user WHERE user_id=? `
@@ -188,7 +188,7 @@ type WxGetPhoneNumberResp struct {
 	CountryCode     string `description:"区号"`
 }
 
-//根据用户手机号获取相关信息
+// 根据用户手机号获取相关信息
 func GetWxUserItemByMobile(mobile string) (item *WxUserItem, err error) {
 	sql := `SELECT a.*,b.company_name FROM wx_user AS a
 			LEFT JOIN company AS b on a.company_id=b.company_id
@@ -197,7 +197,7 @@ func GetWxUserItemByMobile(mobile string) (item *WxUserItem, err error) {
 	return
 }
 
-//根据用户手机号获取相关信息
+// 根据用户手机号获取相关信息
 func GetWxUserAouthByMobile(mobile string) (item *WxUserItem, err error) {
 	sql := `SELECT
 			a.*,
@@ -229,7 +229,7 @@ func ModifyReportLastViewTime(uid int) (err error) {
 	return
 }
 
-//变更联系人是否已注册状态
+// 变更联系人是否已注册状态
 func ModifyWxUserRegisterStatus(userId int) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE wx_user SET is_register=?,source=3,register_time=NOW() WHERE user_id = ? `
@@ -237,7 +237,7 @@ func ModifyWxUserRegisterStatus(userId int) (err error) {
 	return
 }
 
-//修改用户是否绑定外呼手机号弹窗
+// 修改用户是否绑定外呼手机号弹窗
 func ModifyWxUserIsMsgOutboundMobile(userId int) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE wx_user SET is_msg_outbound_mobile=1 WHERE user_id=? `
@@ -245,7 +245,7 @@ func ModifyWxUserIsMsgOutboundMobile(userId int) (err error) {
 	return
 }
 
-//列表
+// 列表
 func GetUserListAll() (items []*WxUserItem, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM wx_user  WHERE mobile <>'' AND outbound_mobile = ''`
@@ -253,7 +253,7 @@ func GetUserListAll() (items []*WxUserItem, err error) {
 	return
 }
 
-//修改手机号区号  8位号码+852,9位号码+886,10位号码+1,11位及以上号码+86
+// 修改手机号区号  8位号码+852,9位号码+886,10位号码+1,11位及以上号码+86
 func UPdateUserCountryCode(item *WxUserItem) (err error) {
 	o := orm.NewOrm()
 	if item.CountryCode == "" && len(item.Mobile) >= 11 {
@@ -276,28 +276,28 @@ func UPdateUserCountryCode(item *WxUserItem) (err error) {
 	return
 }
 
-//判断公司下用户名称是否存在
+// 判断公司下用户名称是否存在
 func GetUserCountByName(companyId int, name string) (count int, err error) {
 	sql := `SELECT  COUNT(1) AS count FROM wx_user WHERE company_id = ? AND real_name = ?`
 	err = orm.NewOrm().Raw(sql, companyId, name).QueryRow(&count)
 	return
 }
 
-//判断这个用户是否被设置消息提醒
+// 判断这个用户是否被设置消息提醒
 func GetUserRemind(uid int) (count int, err error) {
 	sql := `SELECT  COUNT(1) AS count FROM cygx_user_remind WHERE user_id = ? `
 	err = orm.NewOrm().Raw(sql, uid).QueryRow(&count)
 	return
 }
 
-//判断公司下用户名称是否存在
+// 判断公司下用户名称是否存在
 func GetUserCountByThirdName(companyId int, name string) (count int, err error) {
 	sql := `SELECT  COUNT(1) AS count FROM wx_user WHERE company_id = ? AND tripartite_code = ?`
 	err = orm.NewOrm().Raw(sql, companyId, name).QueryRow(&count)
 	return
 }
 
-//获取公司下一共有多少用户
+// 获取公司下一共有多少用户
 func GetUserCountByCompanyId(companyId int) (count int, err error) {
 	sql := `SELECT  COUNT(1) AS count FROM wx_user WHERE company_id = ? `
 	err = orm.NewOrm().Raw(sql, companyId).QueryRow(&count)
@@ -311,7 +311,7 @@ func UpdateUserMobile(uid int, mobile string) (err error) {
 	return
 }
 
-//获取公司下用户详情详情详情
+// 获取公司下用户详情详情详情
 func GetUserByName(companyId int, name string) (item *WxUser, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT *  FROM wx_user WHERE company_id = ? AND real_name = ? `
@@ -319,7 +319,7 @@ func GetUserByName(companyId int, name string) (item *WxUser, err error) {
 	return
 }
 
-//获取公司下用户详情详情详情
+// 获取公司下用户详情详情详情
 func GetUserByThirdName(companyId int, name string) (item *WxUser, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT *  FROM wx_user WHERE company_id = ? AND tripartite_code = ? `
@@ -327,7 +327,7 @@ func GetUserByThirdName(companyId int, name string) (item *WxUser, err error) {
 	return
 }
 
-//获取所有注册的权益用户
+// 获取所有注册的权益用户
 func GetUserRegisterList() (items []*WxUser, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -370,7 +370,7 @@ type UserLabel struct {
 	Label string `description:"标签 多个用  , 隔开"`
 }
 
-//对获取关注的产业
+// 对获取关注的产业
 func GetCygxCompanyUserListSplit(userIds string) (labels string, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -388,7 +388,7 @@ func GetCygxCompanyUserListSplit(userIds string) (labels string, err error) {
 	return
 }
 
-//阅读记录
+// 阅读记录
 type ArticlePvCountResp struct {
 	ArticleId int `description:"文章ID"`
 	Pv        int `description:"Pv"`
@@ -462,7 +462,7 @@ func GetCygxArticleCollectId(uid int, dateTime string) (articleIds string, err e
 	return
 }
 
-//活动标签记录
+// 活动标签记录
 type ActivityLabelCountResp struct {
 	Label string `description:"标签"`
 	Pv    int    `description:"Pv"`
@@ -520,7 +520,7 @@ type CygxUserInteractionNumDetail struct {
 	TryStage            int    `description:"试用客户子标签:0全部、1未分类、2 推进、3 跟踪、4 预备"`
 }
 
-//获取用户的互动量
+// 获取用户的互动量
 func GetCygxCompanyUserUserInteraction(userIds string) (items []*CygxUserInteractionNumDetail, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -532,9 +532,9 @@ func GetCygxCompanyUserUserInteraction(userIds string) (items []*CygxUserInterac
 			( SELECT COUNT( 1 ) FROM cygx_industry_fllow AS h WHERE h.user_id = u.user_id  ) AS industry_fllow_num,
 			( SELECT COUNT( 1 ) FROM cygx_article_department_follow AS h WHERE h.user_id = u.user_id   ) AS department_follow_num,
 			( SELECT COUNT( 1 ) FROM cygx_search_key_word_log AS h WHERE h.user_id = u.user_id  ) AS key_word_num,
-			( SELECT COUNT( 1 ) FROM cygx_activity_signup AS h INNER JOIN cygx_activity as a ON a.activity_id = h.activity_id  INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id   WHERE h.mobile = u.mobile  
+			( SELECT COUNT( 1 ) FROM cygx_activity_signup_detail AS h INNER JOIN cygx_activity as a ON a.activity_id = h.activity_id  INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id   WHERE h.mobile = u.mobile  
 					 AND t.activity_type = 1  AND h.do_fail_type = 0 ) AS on_line_num,
-			( SELECT COUNT( 1 ) FROM cygx_activity_signup AS h INNER JOIN cygx_activity as a ON a.activity_id = h.activity_id  INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id   WHERE h.mobile = u.mobile  
+			( SELECT COUNT( 1 ) FROM cygx_activity_signup_detail AS h INNER JOIN cygx_activity as a ON a.activity_id = h.activity_id  INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id   WHERE h.mobile = u.mobile  
 					  AND t.activity_type = 0 AND h.do_fail_type = 0 ) AS office_num,
 			( SELECT COUNT( 1 ) FROM cygx_activity_special_trip AS h INNER JOIN cygx_activity_special AS a ON a.activity_id = h.activity_id WHERE h.mobile = u.mobile  AND h.is_cancel = 0 ) AS trip_num,
 						( SELECT COUNT( 1 ) FROM cygx_micro_roadshow_video_history AS h  INNER JOIN cygx_micro_roadshow_video as v ON v.video_id = h.video_id WHERE  h.mobile = u.mobile  ) AS roadshow_video_num,
@@ -583,3 +583,10 @@ func GetWxUserByMobiles(mobiles []string) (items []*WxUser, err error) {
 	_, err = o.Raw(sql, mobiles).QueryRows(&items)
 	return
 }
+
+func UserSubscribe(subscribeTime string, userId int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE wx_user SET cygx_subscribe=1,cygx_subscribe_time=? WHERE user_id = ? `
+	_, err = o.Raw(sql, subscribeTime, userId).Exec()
+	return
+}

+ 27 - 0
routers/commentsRouter.go

@@ -385,6 +385,24 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:BannerController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:BannerController"],
+        beego.ControllerComments{
+            Method: "History",
+            Router: `/add/history`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:BannerController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:BannerController"],
+        beego.ControllerComments{
+            Method: "List",
+            Router: `/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:BaseChartController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:BaseChartController"],
         beego.ControllerComments{
             Method: "Patg",
@@ -1033,6 +1051,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportSelectionController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportSelectionController"],
+        beego.ControllerComments{
+            Method: "AddStopTime",
+            Router: `/addStopTime`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportSelectionController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportSelectionController"],
         beego.ControllerComments{
             Method: "ClickHistory",

+ 5 - 0
routers/router.go

@@ -154,6 +154,11 @@ func init() {
 				&controllers.MorningMeetingController{},
 			),
 		),
+		web.NSNamespace("/banner",
+			web.NSInclude(
+				&controllers.BannerController{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }

+ 27 - 1
services/activity.go

@@ -497,10 +497,36 @@ func GetActivityDetailUserPower(user *models.WxUserItem, activityInfo *models.Ac
 	var companyDetailStatus string
 	var userTypeStr string
 	//如果是弘则的用户或者宏观的权限不做校验
-	if user.CompanyId == utils.HZ_COMPANY_ID || activityInfo.ChartPermissionName == utils.HONG_GUAN_NAME {
+	if GetBelongingRai(user.Mobile) || activityInfo.ChartPermissionName == utils.HONG_GUAN_NAME {
 		havePower = true
 		return
 	}
+	//处理决策人可见权限
+	if user.IsMaker == 0 && activityInfo.IsMakerShow == 1 {
+		havePower = false
+		return
+	}
+	// 处理本组可见权限
+	if activityInfo.VisibleRange == 1 {
+		adminIds, e := models.GetSelleridWhichGroup(user.CompanyId, 2)
+		if e != nil {
+			err = errors.New("GetSelleridWhichGroup, Err: " + e.Error())
+			return
+		}
+		haveVisibleRange := false
+		adminIdSlice := strings.Split(adminIds, ",")
+
+		for _, v := range adminIdSlice {
+			if v == strconv.Itoa(activityInfo.AdminId) {
+				haveVisibleRange = true
+			}
+		}
+		if !haveVisibleRange {
+			havePower = false
+			return
+		}
+	}
+
 	userType, permissionStr, permissionStrZhengShi, e := GetUserTypeZhengShi(user.CompanyId)
 	if e != nil {
 		err = errors.New("GetCompanyPermissionUpgrade, Err: " + e.Error())

+ 4 - 1
services/activity_special.go

@@ -634,7 +634,7 @@ func GetActivitySpecialList(user *models.WxUserItem, currentIndex, pageSize int,
 		pageSizePrepare = pageSize - len(listConfirm)
 	}
 	listPrepare, totalPrepare, e := GetActivitySpecialPrepareList(user, startSizePrepare, pageSizePrepare, keywords)
-	if e != nil {
+	if e != nil && e.Error() != utils.ErrNoRow() {
 		err = errors.New("GetActivityLabelSpecialConfirmList, Err: " + e.Error())
 		return
 	}
@@ -645,6 +645,9 @@ func GetActivitySpecialList(user *models.WxUserItem, currentIndex, pageSize int,
 		if startSizePrepare == 0 {
 			listPrepare[0].Explain = utils.ACtIVITY_SPECIAL_EXPLAIN
 		}
+	} else {
+		err = nil
+		return
 	}
 	total = totalConfirm + totalPrepare
 	//处理封面图片

+ 1 - 1
services/admin.go

@@ -6,7 +6,7 @@ import (
 )
 
 func GetAdminMobileMap() (mapItem map[string]string, err error) {
-	adminList, e := models.GetAdminByRole()
+	adminList, e := models.GetRaiAdmin()
 	if e != nil {
 		err = e
 		return

+ 1 - 1
services/article.go

@@ -1086,7 +1086,7 @@ func HandleArticleListByApi(artcleId int) (err error) {
 								industrialSubjectIdStr += strconv.Itoa(vIndustrial.IndustrialSubjectId) + ","
 								mapManagementForSubject[vIndustrial.IndustryName] += vIndustrial.SubjectName + "/"
 								if vIndustrial.LayoutTime == "0000-00-00 00:00:00" {
-									go models.UpdateIndustrialManagementLayoutTime(v.PublishDate.Format(utils.FormatDateTime), vIndustrial.IndustrialManagementId)
+									go models.UpdateIndustrialManagementLayoutTime(v.PublishDate.AddDate(0, 0, -10).Format(utils.FormatDateTime), vIndustrial.IndustrialManagementId)
 								}
 							}
 

+ 135 - 0
services/banner.go

@@ -0,0 +1,135 @@
+package services
+
+import (
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"strconv"
+	"strings"
+	"time"
+)
+
+// GetBannerUrlBody 处理banner的连接并做跳转处理
+func GetBannerUrlBody(url string) (itemResp *models.BannerUrlResp) {
+	//2:文章详情  https://web.hzinsights.com/material/info/8436  小程序路径:/pageMy/reportDetail/reportDetail?id=
+	//3:活动详情  https://web.hzinsights.com/activity/detail/2701  小程序路径:/activityPages/activityDetail/activityDetail?id=
+	//4:产业详情  https://web.hzinsights.com/indepth/info/20/79  小程序路径:/reportPages/IndustryReport/IndustryReport?id=
+	//5:关于我们  https://clpttest.hzinsights.com/about
+	//6:产品内测 https://clpttest.hzinsights.com/internal/article/29  小程序路径:/reportPages/internalDetials/internalDetials?id=
+	//7:本周研究汇总 https://clpttest.hzinsights.com/summary/2/152  小程序路径:/reportPages/reportSecretDetail/reportSecretDetail?type=2&id=
+	//8:上周研究汇总 https://clpttest.hzinsights.com/summary/3/112 小程序路径:/reportPages/reportSecretDetail/reportSecretDetail?type=3&id=
+	//9:专项调研活动 https://clpttest.hzinsights.com/activity/info/70  小程序路径:/activityPages/specialDetail/specialDetail?id=
+	//10: 重点公司 https://clpttest.hzinsights.com/recent/67  小程序路径:/reportPages/keyCompany/keyCompany
+	//11: 主题详情 https://clpttest.hzinsights.com/community/theme/117  小程序路径:/reportPages/researchTheme/researchTheme?id=
+	//12: 作者详情 https://clpttest.hzinsights.com/community/author/78 小程序路径:/reportPages/authorPages/authorPages?id=
+
+	mapPath := make(map[int]string)
+	mapPath[2] = utils.WX_MSG_PATH_ARTICLE_DETAIL          //文章详情
+	mapPath[3] = utils.WX_MSG_PATH_ACTIVITY_DETAIL         //活动详情
+	mapPath[4] = utils.WX_MSG_PATH_INDUSTRY_DETAIL         //产业详情
+	mapPath[6] = utils.WX_MSG_PATH_PRODUCTINTERIOR_DETAIL  //产品内测
+	mapPath[7] = utils.WX_MSG_PATH_THIS_WEEK_DETAIL        //本周研究汇总
+	mapPath[8] = utils.WX_MSG_PATH_LAST_WEEK_DETAIL        //上周研究汇总
+	mapPath[9] = utils.WX_MSG_PATH_ACTIVITY_SPECIAL_DETAIL //专项调研活动
+	mapPath[10] = utils.WX_MSG_PATH_KEY_COMPANY_DETAIL     //重点公司
+	mapPath[11] = utils.WX_MSG_PATH_RESEARCHTHEME_DETAIL   //主题详情
+	mapPath[12] = utils.WX_MSG_PATH_AUTHOR_DETAIL          //作者详情
+
+	material := "material/info"             //2:文章详情
+	activity := "activity/detail"           //3:活动详情
+	activityVideo := "activity/video"       //3:活动视频页,调活动详情
+	indepth := "indepth/info"               //4:产业详情
+	indepthVideo := "indepth/video"         //4:产业视频页,调详情
+	about := "/about"                       //5:关于我们
+	internal := "internal/article"          //6:产品内测
+	thisWeek := "summary/2/"                //7:本周研究汇总
+	lastWeek := "summary/3/"                //8:上周研究汇总
+	activitySpecial := "activity/info"      //9:专项调研活动
+	recent := "/recent/"                    //10:重点公司
+	communityTheme := "/community/theme/"   //11:主题详情
+	communityAuthor := "/community/author/" //12:作者详情
+	item := new(models.BannerUrlResp)
+	item.Body = url
+	urlSlice := strings.Split(url, "/")
+	lenurlSlice := len(urlSlice)
+	sourceId, _ := strconv.Atoi(urlSlice[lenurlSlice-1])
+
+	if strings.Contains(url, material) {
+		item.Type = 2
+	} else if strings.Contains(url, activity) {
+		item.Type = 3
+	} else if strings.Contains(url, activityVideo) {
+		activityVideo, err := models.GetCygxActivityVideoById(sourceId)
+		if err != nil {
+			go utils.SendAlarmMsg("banner链接解析失败"+err.Error()+url, 2)
+		}
+		if activityVideo != nil {
+			sourceId = activityVideo.ActivityId
+			item.Type = 3
+		}
+	} else if strings.Contains(url, indepth) {
+		if lenurlSlice >= 2 {
+			chartPermissionId, _ := strconv.Atoi(urlSlice[lenurlSlice-2])
+			item.ChartPermissionId = chartPermissionId
+		}
+		item.Type = 4
+	} else if strings.Contains(url, indepthVideo) {
+		if lenurlSlice >= 2 {
+			sourceId, _ = strconv.Atoi(urlSlice[lenurlSlice-2])
+		}
+		item.Type = 4
+	} else if strings.Contains(url, about) {
+		item.Type = 5
+	} else if strings.Contains(url, internal) {
+		item.Type = 6
+	} else if strings.Contains(url, thisWeek) {
+		item.Type = 7
+	} else if strings.Contains(url, lastWeek) {
+		item.Type = 8
+	} else if strings.Contains(url, activitySpecial) {
+		item.Type = 9
+	} else if strings.Contains(url, recent) {
+		item.Type = 10
+	} else if strings.Contains(url, communityTheme) {
+		item.Type = 11
+	} else if strings.Contains(url, communityAuthor) {
+		item.Type = 12
+	} else {
+		item.Type = 1
+	}
+	if mapPath[item.Type] != "" {
+		item.Path = "/" + mapPath[item.Type]
+	}
+	item.SourceId = sourceId
+	itemResp = item
+	return
+}
+
+func AddCygxBannerHistory(user *models.WxUserItem, bannerId int) (err error) {
+	if user.UserId == 0 {
+		return
+	}
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("banner点击信息记录失败"+err.Error()+"bannerId"+strconv.Itoa(bannerId)+"userId:"+strconv.Itoa(user.UserId), 2)
+		}
+	}()
+	historyRecord := new(models.CygxBannerHistory)
+	historyRecord.UserId = user.UserId
+	historyRecord.BannerId = bannerId
+	historyRecord.CreateTime = time.Now()
+	historyRecord.Mobile = user.Mobile
+	historyRecord.Email = user.Email
+	historyRecord.CompanyId = user.CompanyId
+	historyRecord.CompanyName = user.CompanyName
+	historyRecord.RegisterPlatform = utils.REGISTER_PLATFORM
+	sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return
+	}
+	historyRecord.RealName = user.RealName
+	if sellerItem != nil {
+		historyRecord.SellerName = sellerItem.RealName
+	}
+	_, err = models.AddCygxBannerHistory(historyRecord)
+	return
+}

+ 6 - 1
services/chart.go

@@ -419,7 +419,7 @@ func GetChartDetailByChartId(cont context.Context) (err error) {
 }
 
 //func init() {
-//	GetChartDetailByApi(6159)
+//	GetChartDetailByApi(6370)
 //}
 
 // 同步图表详情
@@ -460,6 +460,11 @@ func GetChartDetailByApi(chartId int) (err error) {
 		return err
 	}
 	v := resultDate.Data
+
+	if v.ChartId == 0 {
+		err = models.DeleteCygxChart(chartId)
+		return
+	}
 	item := new(models.CygxChart)
 	item.ChartId = v.ChartId
 	item.PtagId = v.PtagId

+ 4 - 4
services/keyword.go

@@ -8,7 +8,7 @@ import (
 	"time"
 )
 
-//AddSearchKeyWord 记录用户搜索关键词
+// AddSearchKeyWord 记录用户搜索关键词
 func AddSearchKeyWord(user *models.WxUserItem, keyWord string, source int) (err error) {
 	//cacheKey := fmt.Sprint("Search_uid:", user.UserId, "_KeyWord:", keyWord, "_Source:", source)
 	//isExist := utils.Rc.IsExist(cacheKey)
@@ -31,7 +31,7 @@ func AddSearchKeyWord(user *models.WxUserItem, keyWord string, source int) (err
 	keyWordItem.CompanyName = user.CompanyName
 	keyWordItem.RealName = user.RealName
 	_, err = models.AddSearchKeyWord(keyWordItem)
-	//go AddUserSearchLog(user, keyWord, source)
+	go AddUserSearchLog(user, keyWord, source)
 	////一分钟之内的相同搜索词不重复记录
 	//setNX := utils.Rc.SetNX(cacheKey, keyWord, time.Minute*1)
 	//if !setNX {
@@ -40,7 +40,7 @@ func AddSearchKeyWord(user *models.WxUserItem, keyWord string, source int) (err
 	return
 }
 
-//AddUserSearchLog 记录用户搜索关键词的日志
+// AddUserSearchLog 记录用户搜索关键词的日志
 func AddUserSearchLog(user *models.WxUserItem, keyWord string, source int) (err error) {
 	defer func() {
 		if err != nil {
@@ -64,7 +64,7 @@ func AddUserSearchLog(user *models.WxUserItem, keyWord string, source int) (err
 	return
 }
 
-//用户搜索操作操作行为,模板消息推送
+// 用户搜索操作操作行为,模板消息推送
 func SearchKeywordUserRmind(user *models.WxUserItem, keyWord string) (err error) {
 	defer func() {
 		if err != nil {

+ 10 - 0
services/product_interior.go

@@ -109,6 +109,11 @@ func GetProductInteriorUrlBody(body string) (itemResp []*models.ProductInteriorU
 }
 
 func AddCygxProductInteriorHistory(user *models.WxUserItem, articleId int) (err error) {
+	cacheKey := fmt.Sprint("ProductInterior:", user.UserId, "articleId:", articleId)
+	isExist := utils.Rc.IsExist(cacheKey)
+	if isExist {
+		return err
+	}
 	defer func() {
 		if err != nil {
 			go utils.SendAlarmMsg("产品内测用户浏览信息记录失败"+err.Error(), 2)
@@ -131,6 +136,11 @@ func AddCygxProductInteriorHistory(user *models.WxUserItem, articleId int) (err
 		historyRecord.SellerName = sellerItem.RealName
 	}
 	_, err = models.AddCygxProductInteriorHistory(historyRecord)
+	////10秒之内的阅读不重复记录
+	setNX := utils.Rc.SetNX(cacheKey, articleId, time.Second*10)
+	if !setNX {
+		go utils.SendAlarmMsg("记录用户搜索关键词失败,设置Redis Key 过期时间失败:key"+cacheKey, 3)
+	}
 	return
 }
 

+ 41 - 0
services/report_history_record.go

@@ -0,0 +1,41 @@
+package services
+
+import (
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"strconv"
+)
+
+// 添加历史信息
+func AddCygxReportHistoryRecord(item *models.CygxReportHistoryRecord) (err error) {
+	//defer func() {
+	//	if err != nil {
+	//		go utils.SendAlarmMsg("产品内测用户浏览信息记录失败"+err.Error(), 2)
+	//	}
+	//}()
+	if item.StopTime >= 5 {
+		_, err = models.AddCygxReportHistoryRecord(item)
+		if err != nil {
+			go utils.SendAlarmMsg("报告精选用户浏览信息记录失败"+err.Error()+"报告类型"+item.ReportType+"报告ID:"+strconv.Itoa(item.ArticleId), 2)
+		}
+	}
+
+	historyRecordLog := new(models.CygxReportHistoryRecordLog)
+	historyRecordLog.UserId = item.UserId
+	historyRecordLog.ArticleId = historyRecordLog.ArticleId
+	historyRecordLog.CreateTime = historyRecordLog.CreateTime
+	historyRecordLog.Mobile = historyRecordLog.Mobile
+	historyRecordLog.Email = historyRecordLog.Email
+	historyRecordLog.CompanyId = historyRecordLog.CompanyId
+	historyRecordLog.CompanyName = historyRecordLog.CompanyName
+	historyRecordLog.StopTime = historyRecordLog.StopTime
+	historyRecordLog.OutType = historyRecordLog.OutType
+	historyRecordLog.ReportType = historyRecordLog.ReportType
+	historyRecordLog.RegisterPlatform = historyRecordLog.RegisterPlatform
+
+	_, err = models.AddCygxReportHistoryRecordLog(historyRecordLog)
+	if err != nil {
+		go utils.SendAlarmMsg("报告精选用户浏览信息日志记录失败"+err.Error()+"报告类型"+item.ReportType+"报告ID:"+strconv.Itoa(item.ArticleId), 2)
+	}
+	return
+}

+ 1 - 0
services/resource_data.go

@@ -233,6 +233,7 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 				}
 			}
 			v.SourceType = 1
+			v.Expert, _ = GetReportContentTextSub(v.Expert)
 			mapItems[fmt.Sprint("activity", v.ActivityId)].Activity = v
 		}
 	}

+ 21 - 0
services/user.go

@@ -1051,3 +1051,24 @@ func SendEmailAllUserWithCompany() (err error) {
 	os.Remove(downLoadnFilePath)
 	return
 }
+
+// 先关注后登录,更新用户是否关注过查研观向小助手公众号
+func UpdateCygxSubscribe(uid int, unionId string) (err error) {
+	defer func() {
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			go utils.SendAlarmMsg("先关注后登录,更新用户是否关注过查研观向小助手公众号失败"+err.Error()+"uid:"+strconv.Itoa(uid)+"unionId:"+unionId, 2)
+		}
+	}()
+	if unionId == "" {
+		err = errors.New("unionId为空,用户ID:" + strconv.Itoa(uid))
+		return
+	}
+	detail, err := models.GetCygxUserRecordSubscribe(unionId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return
+	}
+	if detail != nil {
+		err = models.UserSubscribe(detail.SubscribeTime, uid)
+	}
+	return
+}

+ 0 - 1
utils/common.go

@@ -727,7 +727,6 @@ func StrDateTimeToWeek(strTime string) string {
 		"Sunday":    "周日",
 	}
 	var ctime = StrTimeToTime(strTime).Format("2006-01-02")
-	fmt.Println(ctime)
 	startday, _ := time.Parse("2006-01-02", ctime)
 	staweek_int := startday.Weekday().String()
 	return WeekDayMap[staweek_int]

+ 22 - 2
utils/constants.go

@@ -158,10 +158,30 @@ const (
 // 模板消息地址路由
 const (
 	WX_MSG_PATH_ARTICLE_DETAIL           = "pageMy/reportDetail/reportDetail?id="            //文章详情模板消息地址
+	WX_MSG_PATH_ACTIVITY_DETAIL          = "activityPages/activityDetail/activityDetail?id=" //活动模板消息地址
 	WX_MSG_PATH_ACTIVITY_SPECIAL_DETAIL  = "activityPages/specialDetail/specialDetail?id="   //专项调研活动模板消息地址
 	WX_MSG_PATH_ACTIVITY_INDUSTRYR_EPORT = "reportPages/IndustryReport/IndustryReport?id="   //产业文章列表模板消息地址
-	WX_MSG_PATH_ACTIVITY_DETAIL          = "activityPages/activityDetail/activityDetail?id=" //活动模板消息地址
-)
+
+	WX_MSG_PATH_AUTHOR_DETAIL          = "reportPages/authorPages/authorPages?id="                      //作者详情模板消息地址
+	WX_MSG_PATH_INDUSTRY_DETAIL        = "reportPages/IndustryReport/IndustryReport?id="                //产业详情模板消息地址
+	WX_MSG_PATH_PRODUCTINTERIOR_DETAIL = "reportPages/internalDetials/internalDetials?id="              //产品内测详情模板消息地址
+	WX_MSG_PATH_THIS_WEEK_DETAIL       = "reportPages/reportSecretDetail/reportSecretDetail?type=2&id=" //本周研究汇总详情模板消息地址
+	WX_MSG_PATH_LAST_WEEK_DETAIL       = "reportPages/reportSecretDetail/reportSecretDetail?type=3&id=" //上周纪要汇总详情模板消息地址
+	WX_MSG_PATH_KEY_COMPANY_DETAIL     = "reportPages/keyCompany/keyCompany"                            //重点公司详情模板消息地址
+	WX_MSG_PATH_RESEARCHTHEME_DETAIL   = "reportPages/researchTheme/researchTheme?id="                  //主题详情模板消息地址
+)
+
+//2:文章详情  https://web.hzinsights.com/material/info/8436  小程序路径:/pageMy/reportDetail/reportDetail?id=
+//3:活动详情  https://web.hzinsights.com/activity/detail/2701  小程序路径:/activityPages/activityDetail/activityDetail?id=
+//4:产业详情  https://web.hzinsights.com/indepth/info/20/79  小程序路径:/reportPages/IndustryReport/IndustryReport?id=
+//5:关于我们  https://clpttest.hzinsights.com/about
+//6:产品内测 https://clpttest.hzinsights.com/internal/article/29  小程序路径:/reportPages/internalDetials/internalDetials?id=
+//7:本周研究汇总 https://clpttest.hzinsights.com/summary/2/152  小程序路径:/reportPages/reportSecretDetail/reportSecretDetail?type=2&id=
+//8:上周研究汇总 https://clpttest.hzinsights.com/summary/3/112 小程序路径:/reportPages/reportSecretDetail/reportSecretDetail?type=3&id=
+//9:专项调研活动 https://clpttest.hzinsights.com/activity/info/70  小程序路径:/activityPages/specialDetail/specialDetail?id=
+//10: 重点公司 https://clpttest.hzinsights.com/recent/67  小程序路径:/reportPages/keyCompany/keyCompany
+//11: 主题详情 https://clpttest.hzinsights.com/community/theme/117  小程序路径:/reportPages/researchTheme/researchTheme?id=
+//12: 作者详情 https://clpttest.hzinsights.com/community/author/78 小程序路径:/reportPages/authorPages/authorPages?id=
 
 // 模板消息地址路由
 const (