xingzai %!s(int64=3) %!d(string=hai) anos
pai
achega
709ae4af65
Modificáronse 4 ficheiros con 164 adicións e 7 borrados
  1. 4 6
      controllers/article.go
  2. 1 1
      controllers/home.go
  3. 152 0
      controllers/tactics.go
  4. 7 0
      utils/email.go

+ 4 - 6
controllers/article.go

@@ -378,7 +378,6 @@ func (this *ArticleCommonController) Detail() {
 	br.Data = resp
 }
 
-
 // @Title 获取报告同步
 // @Description 获取报告详情接口
 // @Param   ArticleIdMd5   query   int  true       "报告ID"
@@ -425,13 +424,13 @@ func (this *ArticleCommonController) Tongbu() {
 		if countReport > 0 {
 			v.IsReport = 1
 			//是否属于策略 策略自动归类
-			if v.CategoryId == 7  ||v.CategoryId == 11  ||v.CategoryId == 51  ||v.CategoryId == 52   {
+			if v.CategoryId == 7 || v.CategoryId == 11 || v.CategoryId == 51 || v.CategoryId == 52 {
 				v.IsClass = 1
 			}
 
-			if v.CategoryId == 64  ||v.CategoryId == 87  ||v.CategoryId == 80  {
+			if v.CategoryId == 64 || v.CategoryId == 87 || v.CategoryId == 80 {
 				v.ReportType = 2 //是否属于行业报告
-			}else {
+			} else {
 				v.ReportType = 1 //是否属于产业报告
 			}
 		}
@@ -548,5 +547,4 @@ func (this *ArticleCommonController) Tongbu() {
 	br.Success = true
 	br.Msg = "同步成功"
 
-
-}
+}

+ 1 - 1
controllers/home.go

@@ -63,7 +63,7 @@ func (this *HomeController) ListHome() {
 		}
 		condition = ` AND category_id IN(` + categoryId + `)`
 	}
-
+	condition += ` AND is_summary = 1 `
 	//condition = ` AND a.category_id NOT IN (85,71) `
 
 	total, err := models.GetHomeCount(condition, pars)

+ 152 - 0
controllers/tactics.go

@@ -1,6 +1,7 @@
 package controllers
 
 import (
+	"fmt"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/services"
 	"hongze/hongze_cygx/utils"
@@ -8,6 +9,7 @@ import (
 	"rdluck_tools/paging"
 	"strconv"
 	"strings"
+	"time"
 )
 
 //策略
@@ -93,3 +95,153 @@ func (this *TacticsController) List() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 获取报告详情
+// @Description 获取报告详情接口
+// @Param   ArticleId   query   int  true       "报告ID"
+// @Success 200 {object} models.ArticleDetailResp
+// @router /detail [get]
+func (this *TacticsController) Detail() {
+	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
+	articleId, err := this.GetInt("ArticleId")
+	if articleId <= 0 {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误"
+		return
+	}
+	detail := new(models.ArticleDetail)
+	hasPermission := 0
+	hasFree := 0
+
+	//判断是否已经申请过
+	applyCount, err := models.GetApplyRecordCount(uid)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+		return
+	}
+
+	//`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
+	if user.CompanyId > 1 {
+		companyPermission, err := models.GetCompanyPermission(user.CompanyId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
+			return
+		}
+
+		detail, err = models.GetArticleDetailById(articleId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			return
+		}
+		fmt.Println(detail.Department)
+
+		detail.Body = html.UnescapeString(detail.Body)
+		detail.Abstract = html.UnescapeString(detail.Abstract)
+		if companyPermission == "" {
+			if applyCount > 0 {
+				hasPermission = 5
+			} else {
+				hasPermission = 2
+			}
+			hasFree = 2
+			goto Loop
+		} else {
+			hasFree = 1
+			articlePermission, err := models.GetArticlePermission(detail.SubCategoryName)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取报告权限失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
+				return
+			}
+			if articlePermission == nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "报告权限不存在,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
+				return
+			}
+			for _, p := range articlePermission {
+				if strings.Contains(companyPermission, p.PermissionName) {
+					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
+					go models.AddCygxArticleHistoryRecord(historyRecord)
+					break
+				} else { //无该行业权限
+					hasPermission = 3
+				}
+			}
+		}
+		collectCount, err := models.GetArticleCollectCount(uid, articleId)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "判断是否已收藏失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
+			return
+		}
+
+		if collectCount > 0 {
+			detail.IsCollect = true
+		}
+
+		interviewApplyItem, err := models.GetArticleInterviewApply(uid, articleId)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
+			return
+		}
+
+		if interviewApplyItem != nil && interviewApplyItem.InterviewApplyId > 0 {
+			detail.IsInterviewApply = true
+			detail.InterviewApplyStatus = interviewApplyItem.Status
+		}
+		//获取销售手机号
+		sellerItem, err := models.GetSellerByCompanyId(user.CompanyId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取销售数据失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
+			return
+		}
+		if sellerItem != nil {
+			detail.SellerMobile = sellerItem.Mobile
+			detail.SellerName = sellerItem.RealName
+		}
+	} else { //潜在客户
+		if applyCount > 0 {
+			hasPermission = 5
+		} else {
+			hasPermission = 4
+		}
+	}
+Loop:
+	if hasPermission != 1 {
+		detail.Body = ""
+		detail.BodyText = ""
+	}
+	resp := new(models.ArticleDetailResp)
+	resp.HasPermission = hasPermission
+	resp.HasFree = hasFree
+	resp.Detail = detail
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 7 - 0
utils/email.go

@@ -7,6 +7,9 @@ import (
 
 //发送邮件
 func SendEmail(title, content string, touser string) bool {
+	if RunMode == "debug" {
+		return false
+	}
 	var arr []string
 	sub := strings.Index(touser, ";")
 	if sub >= 0 {
@@ -31,6 +34,10 @@ func SendEmail(title, content string, touser string) bool {
 
 //发送邮件
 func SendEmailByHz(title, content string, touser string) (result bool, err error) {
+	if RunMode == "debug" {
+		result = false
+		return result, err
+	}
 	var arr []string
 	sub := strings.Index(touser, ";")
 	if sub >= 0 {