|
@@ -36,92 +36,116 @@ func (this *ArticleController) Detail() {
|
|
|
return
|
|
|
}
|
|
|
uid := user.UserId
|
|
|
- articleId, _ := this.GetInt("ArticleId")
|
|
|
+ articleId, err := this.GetInt("ArticleId")
|
|
|
if articleId <= 0 {
|
|
|
br.Msg = "参数错误"
|
|
|
br.ErrMsg = "参数错误"
|
|
|
return
|
|
|
}
|
|
|
- detail, err := models.GetArticleDetailById(articleId)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "获取信息失败"
|
|
|
- br.ErrMsg = "获取信息失败"
|
|
|
- return
|
|
|
- }
|
|
|
+ detail := new(models.ArticleDetail)
|
|
|
+ hasPermission := 0
|
|
|
+ hasFree := 0
|
|
|
|
|
|
- collectCount, err := models.GetArticleCollectCount(uid, articleId)
|
|
|
+ //判断是否已经申请过
|
|
|
+ applyCount, err := models.GetApplyRecordCount(uid)
|
|
|
if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
br.Msg = "获取信息失败"
|
|
|
- br.ErrMsg = "判断是否已收藏失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
|
|
|
+ br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if collectCount > 0 {
|
|
|
- detail.IsCollect = true
|
|
|
- }
|
|
|
+ //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ if companyPermission == "" {
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ if strings.Contains(companyPermission, articlePermission.PermissionName) {
|
|
|
+ hasPermission = 1
|
|
|
+ //新增浏览记录
|
|
|
+ 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)
|
|
|
+ } else { //无该行业权限
|
|
|
+ if applyCount > 0 {
|
|
|
+ hasPermission = 3
|
|
|
+ } else {
|
|
|
+ hasPermission = 4
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ detail, err = models.GetArticleDetailById(articleId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
- 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
|
|
|
- }
|
|
|
+ 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 interviewApplyItem != nil && interviewApplyItem.InterviewApplyId > 0 {
|
|
|
- detail.IsInterviewApply = true
|
|
|
- detail.InterviewApplyStatus = interviewApplyItem.Status
|
|
|
- }
|
|
|
+ if collectCount > 0 {
|
|
|
+ detail.IsCollect = true
|
|
|
+ }
|
|
|
|
|
|
- hasPermission := 2
|
|
|
- hasFree := 2
|
|
|
- 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
|
|
|
- }
|
|
|
- //GetCompanyPermission
|
|
|
- companyPermission, err := models.GetCompanyPermission(user.CompanyId)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "获取信息失败"
|
|
|
- br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
|
|
|
- return
|
|
|
- }
|
|
|
- if companyPermission != "" {
|
|
|
- hasFree = 1
|
|
|
- }
|
|
|
- if strings.Contains(companyPermission, articlePermission.PermissionName) {
|
|
|
- hasPermission = 1
|
|
|
- }
|
|
|
- if hasPermission == 1 {
|
|
|
- //新增浏览记录
|
|
|
- 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)
|
|
|
- } else {
|
|
|
- detail.Body = ""
|
|
|
- }
|
|
|
- //获取销售手机号
|
|
|
- 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
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ } else { //潜在客户
|
|
|
+ if applyCount > 0 {
|
|
|
+ hasPermission = 6
|
|
|
+ } else {
|
|
|
+ hasPermission = 5
|
|
|
+ }
|
|
|
}
|
|
|
+Loop:
|
|
|
resp := new(models.ArticleDetailResp)
|
|
|
resp.HasPermission = hasPermission
|
|
|
resp.HasFree = hasFree
|