Browse Source

Merge branch 'master' of http://8.136.199.33:3000/cxzhang/hongze_web_mfyx into mfyx_3.0

xingzai 1 năm trước cách đây
mục cha
commit
5e06143483

+ 8 - 2
controllers/user.go

@@ -227,12 +227,18 @@ func (this *UserController) Detail() {
 					return
 				}
 				companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
-				if err != nil {
+				if err != nil && err.Error() != utils.ErrNoRow() {
 					br.Msg = "获取信息失败"
 					br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
 					return
 				}
-				if companyReportPermissionDetail == nil || companyProduct.IsSuspend == 1 {
+				var isSuspend int
+				if companyProduct == nil {
+					isSuspend = 1
+				} else {
+					isSuspend = companyProduct.IsSuspend
+				}
+				if companyReportPermissionDetail == nil || isSuspend == 1 {
 					//hasPermission = 1
 					hasPermission, err = services.GetUserDetailPermissionCode(user.UserId, user.CompanyId)
 					if err != nil && err.Error() != utils.ErrNoRow() {

+ 15 - 10
controllers/yanxuan_special.go

@@ -82,6 +82,11 @@ func (this *YanxuanSpecialNoLoginController) List() {
 		br.ErrMsg = "获取失败, Err:" + err.Error()
 		return
 	}
+	var yanxuanSpecialIds []int
+	for _, v := range list {
+		yanxuanSpecialIds = append(yanxuanSpecialIds, v.Id)
+	}
+	yanxuanSpecialPv := services.GetYanxuanSpecialRecordByYanxuanSpecialId(yanxuanSpecialIds)
 	for _, v := range list {
 		hasImg, err := utils.ArticleHasImgUrl(v.Content)
 		if err != nil {
@@ -132,6 +137,7 @@ func (this *YanxuanSpecialNoLoginController) List() {
 		if len(v.TagList) == 0 {
 			v.TagList = []string{}
 		}
+		v.Pv = yanxuanSpecialPv[v.Id]
 	}
 	specialAuthorCheck := services.GetYanxuanSpecialAuthorInfo(sysUser) //用户是否没开通研选专栏以及,专栏信息是否完善
 	resp.IsAuthor = specialAuthorCheck.IsAuthor
@@ -222,7 +228,7 @@ func (this *YanxuanSpecialNoLoginController) Detail() {
 
 	var configCode string
 	//如果是研选的就推送给汪洋跟王芳,否则就推送给王芳
-	configCode = utils.TPL_MSG_WANG_FANG_WANG_YANG
+	configCode = utils.TPL_MSG_YAN_XUAN_SPECIAL_APPROVAL
 	cnf, err := models.GetConfigByCode(configCode)
 	if err != nil {
 		br.Msg = "获取失败"
@@ -634,15 +640,14 @@ func (this *YanxuanSpecialController) Collect() {
 	var sellerName string
 
 	if req.Status == 1 {
-		sellerItem, _ := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
-		//if err != nil {
-		//	br.Msg = "收藏失败!"
-		//	br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
-		//	return
-		//}
-		//无权限客户也能收藏
-		if sellerItem != nil {
-			sellerName = sellerItem.RealName
+		sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "查询栏目详情失败!"
+			br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+			return
+		}
+		if sellerItemQy != nil {
+			sellerName = sellerItemQy.RealName
 		}
 		item := models.CygxYanxuanSpecialCollect{
 			UserId:           user.UserId,

+ 32 - 0
models/article_history_record_newpv.go

@@ -227,3 +227,35 @@ func GetCygxArticleHistoryRecordNewpvListPv(condition string, pars []interface{}
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }
+
+// 查研PV列表
+func GetCygxArticleHistoryRecordNewpvListPvCy(condition string, pars []interface{}) (items []*ListPvUvResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			COUNT( 1 ) AS pv,
+			article_id
+		FROM
+			cygx_article_history_record_all  WHERE 1 = 1  AND platfor = 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` GROUP BY article_id `
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
+// 策略PV列表
+func GetCygxArticleHistoryRecordNewpvListPvCl(condition string, pars []interface{}) (items []*ListPvUvResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			COUNT( 1 ) AS pv,
+			article_id
+		FROM
+			cygx_article_history_record_all  WHERE 1 = 1  AND platfor = 2 AND is_del = 0 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` GROUP BY article_id `
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 2 - 2
models/cygx_yanxuan_special.go

@@ -58,8 +58,8 @@ type CygxYanxuanSpecialItem struct {
 	IndustryTags        string
 	Docs                []Doc
 	Annotation          string   `description:"核心观点"`
-	Pv                  string   `description:"Pv"`
-	Uv                  string   `description:"Uv"`
+	Pv                  int      `description:"Pv"`
+	Uv                  int      `description:"Uv"`
 	BodyHighlight       []string `description:"搜索高亮展示结果"`
 	LabelKeywordImgLink string   `description:"标签关键词ico"`
 }

+ 22 - 0
models/cygx_yanxuan_special_record.go

@@ -62,3 +62,25 @@ func AddCygxYanxuanSpecialRecordLog(item *CygxYanxuanSpecialRecordLog) (lastId i
 	lastId, err = o.Insert(item)
 	return
 }
+
+type LisYanxuanSpecialRecordPvResp struct {
+	YanxuanSpecialId int `description:"文章ID"`
+	Pv               int `description:"pv"`
+	Uv               int `description:"pv"`
+}
+
+// pv 列表
+func GetCygxYanxuanSpecialRecordListPv(condition string, pars []interface{}) (items []*LisYanxuanSpecialRecordPvResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			COUNT( 1 ) AS pv,
+			yanxuan_special_id
+		FROM
+			cygx_yanxuan_special_record  WHERE 1 = 1  `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` GROUP BY yanxuan_special_id  `
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 1 - 1
models/home.go

@@ -175,7 +175,7 @@ WHERE
 
 func GetHomeListPublic(condition string, pars []interface{}, startSize, pageSize int) (items []*ArticleListResp, err error) {
 	o := orm.NewOrm()
-	sql := ` SELECT * ,(SELECT count(1) FROM cygx_article_history_record_newpv as h WHERE h.article_id = a.article_id ) as pv
+	sql := ` SELECT * 
                  FROM cygx_article AS a
                 WHERE a.publish_status=1 `
 	if condition != "" {

+ 6 - 0
services/article.go

@@ -151,9 +151,12 @@ func HandleArticleCategoryImg(list []*models.ArticleListResp, user *models.WxUse
 	}
 
 	articleIds := make([]int, 0)
+	var articleIdsSpecialArr []int // 研选专栏ID
 	for _, v := range list {
 		if v.IsSpecial == 0 {
 			articleIds = append(articleIds, v.ArticleId)
+		} else {
+			articleIdsSpecialArr = append(articleIdsSpecialArr, v.ArticleId)
 		}
 	}
 	// 报告关联产业信息
@@ -193,6 +196,8 @@ func HandleArticleCategoryImg(list []*models.ArticleListResp, user *models.WxUse
 	articleCollectMap, _ := GetCygxArticleCollectMap(user.UserId)                  //用户收藏的文章
 	articleCollectNumMap, _ := GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
 	articleCollectYanxuanSpecialMap, _ := GetYanxuanSpecialCollectMap(user.UserId) //用户收藏的研选专栏
+
+	yanxuanSpecialPv := GetYanxuanSpecialRecordByYanxuanSpecialId(articleIdsSpecialArr) //研选专栏Pv
 	for k, v := range list {
 		if len(industryMap[v.ArticleId]) > 0 {
 			list[k].List = industryMap[v.ArticleId]
@@ -208,6 +213,7 @@ func HandleArticleCategoryImg(list []*models.ArticleListResp, user *models.WxUse
 			list[k].CollectNum = articleCollectNumMap[v.ArticleId]
 		} else {
 			v.IsCollect = articleCollectYanxuanSpecialMap[v.ArticleId]
+			v.Pv = yanxuanSpecialPv[v.ArticleId]
 		}
 	}
 

+ 15 - 4
services/article_history.go

@@ -94,12 +94,13 @@ func ArticleHistoryStopTime(articleId, stopTime, outType int, user *models.WxUse
 	return
 }
 
+// GetArticleHistoryByArticleId 获取文章阅读 pv map
 func GetArticleHistoryByArticleId(articleIds []int) (mapResp map[int]int) {
 	var err error
 	defer func() {
 		if err != nil {
 			fmt.Println(err)
-			go utils.SendAlarmMsg("获取用户的阅读数据,信息失败,Err:"+err.Error(), 3)
+			go utils.SendAlarmMsg("获取用户的阅读数据,信息失败,GetArticleHistoryByArticleId Err:"+err.Error(), 3)
 		}
 	}()
 	lenIds := len(articleIds)
@@ -110,13 +111,23 @@ func GetArticleHistoryByArticleId(articleIds []int) (mapResp map[int]int) {
 	var pars []interface{}
 	condition = ` AND article_id IN (` + utils.GetOrmInReplace(lenIds) + `) `
 	pars = append(pars, articleIds)
-	list, err := models.GetCygxArticleHistoryRecordNewpvListPv(condition, pars)
-	if err != nil {
+	listCy, e := models.GetCygxArticleHistoryRecordNewpvListPvCy(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxArticleHistoryRecordNewpvListPvCy, Err: " + e.Error())
 		return
 	}
 	mapResp = make(map[int]int, 0)
-	for _, v := range list {
+	for _, v := range listCy {
 		mapResp[v.ArticleId] = v.Pv
 	}
+
+	listCl, e := models.GetCygxArticleHistoryRecordNewpvListPvCl(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxArticleHistoryRecordNewpvListPvCy, Err: " + e.Error())
+		return
+	}
+	for _, v := range listCl {
+		mapResp[v.ArticleId] += v.Pv
+	}
 	return
 }

+ 1 - 1
services/config.go

@@ -118,7 +118,7 @@ func CheckYxSpecialIsApprovalPersonnel(mobile string) (isApprovalPersonnel bool)
 	}()
 	var configCode string
 	//获取配置项里面审核人员的手机号
-	configCode = utils.TPL_MSG_WANG_FANG_WANG_YANG
+	configCode = utils.TPL_MSG_YAN_XUAN_SPECIAL_APPROVAL
 	cnf, e := models.GetConfigByCode(configCode)
 	if e != nil {
 		err = errors.New("GetConfigByCode, Err: " + e.Error() + configCode)

+ 4 - 4
services/cygx_yanxuan_special.go

@@ -97,16 +97,16 @@ func SendWxMsgSpecialFollow(specialId int) (err error) {
 	return
 }
 
-// SendReviewTemplateMsgAdmin 提交审核时给王芳,汪洋发消息
+// SendReviewTemplateMsgAdmin 提交审核时给王芳,葛琳发消息
 func SendReviewTemplateMsgAdmin(specialId int) (err error) {
 	defer func() {
 		if err != nil {
-			go utils.SendAlarmMsg("处理试用申请给王芳,汪洋发消息失败, ErrMsg: "+err.Error(), 3)
+			go utils.SendAlarmMsg(fmt.Sprint("处理试用申请给王芳,汪洋发消息失败, specialId:", specialId, "ErrMsg", err.Error()), 2)
 		}
 	}()
 	var configCode string
-	//如果是研选的就推送给汪洋跟王芳,否则就推送给王芳
-	configCode = utils.TPL_MSG_WANG_FANG_WANG_YANG
+	//研选专栏修改之后给这些手机号推送审核模版消息
+	configCode = utils.TPL_MSG_YAN_XUAN_SPECIAL_APPROVAL
 	cnf, e := models.GetConfigByCode(configCode)
 	if e != nil {
 		err = errors.New("GetConfigByCode, Err: " + e.Error() + configCode)

+ 29 - 0
services/cygx_yanxuan_special_company.go

@@ -172,3 +172,32 @@ func AddSpecialRecord(user *models.WxUserItem, specialId, stopTime int) (err err
 	}
 	return
 }
+
+// GetYanxuanSpecialRecordByYanxuanSpecialId 获取研选专栏阅读 pv map
+func GetYanxuanSpecialRecordByYanxuanSpecialId(articleIds []int) (mapResp map[int]int) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("获取研选专栏阅读,信息失败,GetYanxuanSpecialRecordByYanxuanSpecialId Err:"+err.Error(), 3)
+		}
+	}()
+	lenIds := len(articleIds)
+	if lenIds == 0 {
+		return
+	}
+	var condition string
+	var pars []interface{}
+	condition = ` AND yanxuan_special_id IN (` + utils.GetOrmInReplace(lenIds) + `) `
+	pars = append(pars, articleIds)
+	listPv, e := models.GetCygxYanxuanSpecialRecordListPv(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxArticleHistoryRecordNewpvListPvCy, Err: " + e.Error())
+		return
+	}
+	mapResp = make(map[int]int, 0)
+	for _, v := range listPv {
+		mapResp[v.YanxuanSpecialId] = v.Pv
+	}
+	return
+}

+ 2 - 38
services/es_comprehensive.go

@@ -558,10 +558,11 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 			err = errors.New("GetYanxuanSpecialList, Err: " + e.Error())
 			return
 		}
-
+		yanxuanSpecialPv := GetYanxuanSpecialRecordByYanxuanSpecialId(yanxuanSpecialIds) // 专栏Pv
 		for _, v := range listyanxuanSpecial {
 			v.PublishTime = utils.TimeRemoveHms2(v.PublishTime)
 			v.Annotation, _ = GetReportContentTextSubNew(v.Content)
+			v.Pv = yanxuanSpecialPv[v.Id]
 			if len(yanXuanbodyHighlight[v.Id]) > 0 {
 				v.BodyHighlight = yanXuanbodyHighlight[v.Id]
 			} else {
@@ -579,43 +580,6 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 			if v.Article == nil && v.Newchart == nil && v.Roadshow == nil && v.Activity == nil && v.Activityvideo == nil && v.Activityvoice == nil && v.Activityspecial == nil && v.Researchsummary == nil && v.Minutessummary == nil && v.Meetingreviewchapt == nil && v.ProductInterior == nil && v.IndustrialResource == nil && v.YanxuanSpecial == nil && v.AskserieVideo == nil && v.ReportSelection == nil {
 				continue
 			}
-			//if v.Article != nil && v.SourceId == vList.SourceId {
-			//	v.Article.Title = vList.Title
-			//}
-			//if v.Newchart != nil && v.SourceId == vList.SourceId {
-			//	v.Newchart.Title = vList.Title
-			//}
-			//if v.Roadshow != nil && v.SourceId == vList.SourceId {
-			//	v.Roadshow.Title = vList.Title
-			//}
-			//if v.Activity != nil && v.SourceId == vList.SourceId {
-			//	v.Activity.ActivityName = vList.Title
-			//}
-			//if v.Activityvideo != nil && v.SourceId == vList.SourceId {
-			//	v.Activityvideo.Title = vList.Title
-			//}
-			//if v.Activityvoice != nil && v.SourceId == vList.SourceId {
-			//	v.Activityvoice.Title = vList.Title
-			//}
-			//
-			//if v.Activityspecial != nil && v.SourceId == vList.SourceId {
-			//	v.Activityspecial.ResearchTheme = vList.Title
-			//}
-			//if v.Researchsummary != nil && v.SourceId == vList.SourceId {
-			//	v.Researchsummary.Title = vList.Title
-			//}
-			//if v.Minutessummary != nil && v.SourceId == vList.SourceId {
-			//	v.Minutessummary.Title = vList.Title
-			//}
-			//if v.ProductInterior != nil && v.SourceId == vList.SourceId {
-			//	v.ProductInterior.Title = vList.Title
-			//}
-			//if v.IndustrialResource != nil && v.SourceId == vList.SourceId && v.Source == vList.Source {
-			//	v.IndustrialResource.UpdateTime = strings.Replace(vList.PublishDate, "00:00:00", "", -1)
-			//}
-			//if v.YanxuanSpecial != nil && v.SourceId == vList.SourceId {
-			//	v.YanxuanSpecial.Title = vList.Title
-			//}
 			if v.SourceId == vList.SourceId && v.Source == vList.Source {
 				items = append(items, v)
 			}

+ 2 - 22
services/resource_data.go

@@ -265,27 +265,6 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 		}
 	}
 
-	//处理报告精选
-	lenreportselectionIds := len(reportselectionIds)
-	if lenreportselectionIds > 0 {
-		pars = make([]interface{}, 0)
-		condition = ` AND article_id IN (` + utils.GetOrmInReplace(lenreportselectionIds) + `)`
-		pars = append(pars, reportselectionIds)
-		listreportselection, e := models.GetReportSelectionList(condition, pars, 0, lenreportselectionIds)
-		if e != nil {
-			err = errors.New("GetReportSelectionList, Err: " + e.Error())
-			return
-		}
-		mapPv := GetCygxReportHistoryRecordListMap(reportselectionIds, "bgjx")
-		for _, v := range listreportselection {
-			v.Title += "(第" + v.Periods + "期)"
-			v.MarketStrategy = AnnotationHtml(v.MarketStrategy)
-			v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
-			v.Pv = mapPv[v.ArticleId]
-			mapItems[fmt.Sprint("reportselection", v.ArticleId)].ReportSelection = v
-		}
-	}
-
 	//处理研选专栏
 	lenyanxuanSpecialIds := len(yanxuanSpecialIds)
 	if lenyanxuanSpecialIds > 0 {
@@ -297,10 +276,11 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 			err = errors.New("GetYanxuanSpecialList, Err: " + e.Error())
 			return
 		}
-
+		yanxuanSpecialPv := GetYanxuanSpecialRecordByYanxuanSpecialId(yanxuanSpecialIds) // 专栏Pv
 		for _, v := range listyanxuanSpecial {
 			v.PublishTime = utils.TimeRemoveHms2(v.PublishTime)
 			v.Annotation, _ = GetReportContentTextSubNew(v.Content)
+			v.Pv = yanxuanSpecialPv[v.Id]
 			v.LabelKeywordImgLink = utils.LABEL_ICO_4
 			mapItems[fmt.Sprint(utils.CYGX_OBJ_YANXUANSPECIAL, v.Id)].YanxuanSpecial = v
 		}

+ 1 - 1
utils/config.go

@@ -98,7 +98,7 @@ func init() {
 	}
 	WxAppId = "wxcc32b61f96720d2f"
 	WxAppSecret = "06894933fafb24dafead7eaae09c08e0"
-	WxMsgTemplateIdAskMsgMobileAll = "15557270714,18767183922,18621268829,18955528215"
+	WxMsgTemplateIdAskMsgMobileAll = "15557270714,18767183922,18621268829"
 	WxMsgTemplateIdAskMsgMobilePublic = "15557270714,18767183922,18621268829"
 	if RunMode == "release" {
 		WxPublicAppId = "wx2f85cdbe74585222"                                          //买方研选公众号AppId

+ 6 - 5
utils/constants.go

@@ -217,11 +217,12 @@ const (
 )
 
 const (
-	TPL_MSG_WANG_YANG                  = "tpl_msg_wang_yang"           //汪洋手机号地址参数
-	TPL_MSG_WANG_FANG_WANG_YANG        = "tpl_msg_wang_fang_wang_yang" //权限模板消息接收人,王芳,汪洋
-	TPL_MSG                            = "tpl_msg"                     //王芳手机号地址参数
-	TPL_MSG_NEI_RONG_ZU                = "tpl_msg_nei_rong_zu"         //内容组四人
-	CYGX_TAG_HOT_ACTIVITY_ID    string = "cygx_tag_hot_activity_id"    //标签管理自定义的热门活动ID
+	TPL_MSG_WANG_YANG                        = "tpl_msg_wang_yang"                 //汪洋手机号地址参数
+	TPL_MSG_WANG_FANG_WANG_YANG              = "tpl_msg_wang_fang_wang_yang"       //权限模板消息接收人,王芳,汪洋
+	TPL_MSG_YAN_XUAN_SPECIAL_APPROVAL        = "tpl_msg_yan_xuan_special_approval" //研选专栏修改之后给这些手机号推送审核模版消息
+	TPL_MSG                                  = "tpl_msg"                           //王芳手机号地址参数
+	TPL_MSG_NEI_RONG_ZU                      = "tpl_msg_nei_rong_zu"               //内容组四人
+	CYGX_TAG_HOT_ACTIVITY_ID          string = "cygx_tag_hot_activity_id"          //标签管理自定义的热门活动ID
 )
 
 const (