|
@@ -536,12 +536,20 @@ func (this *ArticleController) InterviewApply() {
|
|
|
// @Param ArticleIdMd5 query int true "报告ID"
|
|
|
// @Success 200 {object} models.ArticleDetailResp
|
|
|
// @router /look/detail [get]
|
|
|
-func (this *ArticleCommonController) Detail() {
|
|
|
+func (this *ArticleController) DetailMd5() {
|
|
|
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
|
|
|
+ }
|
|
|
+ uid := user.UserId
|
|
|
|
|
|
articleIdMd5 := this.GetString("ArticleIdMd5")
|
|
|
if articleIdMd5 == "" {
|
|
@@ -556,32 +564,152 @@ func (this *ArticleCommonController) Detail() {
|
|
|
br.ErrMsg = "获取信息失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
+ articleId := detail.ArticleId
|
|
|
detail.Body = html.UnescapeString(detail.Body)
|
|
|
- //detail.Abstract = html.UnescapeString(detail.Abstract)
|
|
|
- sellerList, err := models.GetSellerList(detail.ArticleId)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "获取信息失败"
|
|
|
- br.ErrMsg = "获取销售数据失败,Err:" + err.Error() + ";articleId" + strconv.Itoa(detail.ArticleId)
|
|
|
- return
|
|
|
+
|
|
|
+ hasPermission := 2
|
|
|
+ //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
|
|
|
+ if user.CompanyId > 1 {
|
|
|
+ companyPermission, err := models.GetCompanyPermission(user.CompanyId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取公司权限失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ detail.Body = html.UnescapeString(detail.Body)
|
|
|
+ detail.Body = strings.Replace(detail.Body, "<p data-f-id=\"pbf\" style=\"text-align: center; font-size: 14px; margin-top: 30px; opacity: 0.65; font-family: sans-serif;\">Powered by <a href=\"https://www.froala.com/wysiwyg-editor?pb=1\" title=\"Froala Editor\">Froala Editor</a></p>", "", -1)
|
|
|
+ detail.Body = strings.Replace(detail.Body, "pre", "div", -1)
|
|
|
+ detail.Abstract, _ = services.GetReportContentTextSubNew(detail.Abstract)
|
|
|
+ if companyPermission == "" {
|
|
|
+ hasPermission = 2
|
|
|
+ } else {
|
|
|
+ var articlePermissionPermissionName string
|
|
|
+ if detail.CategoryId > 0 {
|
|
|
+ articlePermission, err := models.GetArticlePermission(detail.CategoryId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取报告权限失败,Err:" + err.Error() + articleIdMd5
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if articlePermission == nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "报告权限不存在,Err:" + articleIdMd5
|
|
|
+ return
|
|
|
+ }
|
|
|
+ articlePermissionPermissionName = articlePermission.PermissionName
|
|
|
+ } else {
|
|
|
+ articlePermissionPermissionName = detail.CategoryName
|
|
|
+ }
|
|
|
+ var hasPersion bool
|
|
|
+ slice := strings.Split(articlePermissionPermissionName, ",")
|
|
|
+ for _, v := range slice {
|
|
|
+ if strings.Contains(companyPermission, v) {
|
|
|
+ hasPersion = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ userType, _, err := services.GetUserType(user.CompanyId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if userType == 1 && strings.Contains(detail.CategoryName, "研选") {
|
|
|
+ hasPersion = false
|
|
|
+ }
|
|
|
+ if detail.IsReport == 1 {
|
|
|
+ detailCategory, err := models.GetdetailByCategoryIdSando(detail.CategoryId)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取信息失败,Err:" + err.Error() + "categoryID 不存在:" + strconv.Itoa(detail.CategoryId)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ permissionStr, err := models.GetCompanyPermissionByUser(user.CompanyId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if detailCategory != nil {
|
|
|
+ if detailCategory.PermissionType == 1 {
|
|
|
+ if !strings.Contains(permissionStr, detailCategory.ChartPermissionName+"(主观)") {
|
|
|
+ hasPersion = false
|
|
|
+ }
|
|
|
+ } else if detailCategory.PermissionType == 2 {
|
|
|
+ if !strings.Contains(permissionStr, detailCategory.ChartPermissionName+"(客观)") {
|
|
|
+ hasPersion = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if hasPersion {
|
|
|
+ hasPermission = 1
|
|
|
+ historyRecord := new(models.CygxArticleHistoryRecord)
|
|
|
+ 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
|
|
|
+ recordCount, _ := models.GetNoAddStoptimeArticleCount(uid, articleId)
|
|
|
+ if recordCount == 0 {
|
|
|
+ go models.AddCygxArticleHistoryRecord(historyRecord)
|
|
|
+ } else {
|
|
|
+ detailNew, err := models.GetNewArticleHistoryRecord(uid, articleId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if detailNew.StopTime > 0 {
|
|
|
+ go models.AddCygxArticleHistoryRecord(historyRecord)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //30分钟之内阅读同一篇文章不错二次推送
|
|
|
+ key := "CYGX_ARTICLE_READ" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
|
|
|
+ if !utils.Rc.IsExist(key) {
|
|
|
+ go services.ArticleUserRemind(user, detail, 1)
|
|
|
+ utils.Rc.Put(key, 1, 30*time.Second)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if hasPermission == 1 {
|
|
|
+ key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
|
|
|
+ if !utils.Rc.IsExist(key) {
|
|
|
+ //新增浏览记录
|
|
|
+ record := new(models.CygxArticleViewRecord)
|
|
|
+ record.UserId = uid
|
|
|
+ record.ArticleId = articleId
|
|
|
+ record.CreateTime = time.Now()
|
|
|
+ record.Mobile = user.Mobile
|
|
|
+ record.Email = user.Email
|
|
|
+ record.CompanyId = user.CompanyId
|
|
|
+ record.CompanyName = user.CompanyName
|
|
|
+ go models.AddCygxArticleViewRecord(record)
|
|
|
+ utils.Rc.Put(key, 1, 5*time.Second)
|
|
|
+ models.ModifyReportLastViewTime(uid)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //作者头像
|
|
|
+ if detail.DepartmentId > 0 {
|
|
|
+ departmentDetail, err := models.GetArticleDepartmentDateilById(detail.DepartmentId)
|
|
|
+ if err == nil {
|
|
|
+ detail.DepartmentImgUrl = departmentDetail.ImgUrl
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- //if detail.ArticleId > 1000000 {
|
|
|
- // var hrefRegexp = regexp.MustCompile("[0-9]\\d*")
|
|
|
- // match := hrefRegexp.FindAllString(detail.SellerAndMobile, -1)
|
|
|
- // if match != nil {
|
|
|
- // for _, v := range match {
|
|
|
- // sellerAndMobile := &models.SellerRep{
|
|
|
- // SellerMobile: v,
|
|
|
- // SellerName: strings.Replace(detail.SellerAndMobile, v, "", -1),
|
|
|
- // }
|
|
|
- // sellerList = append(sellerList, sellerAndMobile)
|
|
|
- // }
|
|
|
- // }
|
|
|
- //}
|
|
|
detail.SellerAndMobile = "" //业务需要强制处理为空
|
|
|
- resp.HasPermission = 1
|
|
|
- detail.Abstract, _ = services.GetReportContentTextSub(detail.Abstract)
|
|
|
- detail.SellerList = sellerList
|
|
|
- resp.Detail = detail
|
|
|
+ resp.HasPermission = hasPermission
|
|
|
+ if hasPermission == 1 {
|
|
|
+ detail.Abstract, _ = services.GetReportContentTextSub(detail.Abstract)
|
|
|
+ resp.Detail = detail
|
|
|
+ } else {
|
|
|
+ if user.Mobile != "" {
|
|
|
+ resp.Mobile = user.Mobile
|
|
|
+ } else {
|
|
|
+ resp.Mobile = user.Email
|
|
|
+ }
|
|
|
+ }
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
|
br.Msg = "获取成功"
|