ソースを参照

首页添加判断是否已购

xiexiaoyuan 3 年 前
コミット
30169f377b

+ 11 - 0
models/response/permission.go

@@ -22,6 +22,11 @@ type PermissionFiccSecondItem struct {
 	AuthOk     bool   `json:"auth_ok"`
 }
 
+type PermissionFiccResp struct {
+	PermissionList 	PermissionFiccList `json:"permission_list"`
+	ContactInfo     PermissionCheckContactInfo    `json:"contact_info"`
+	CheckFlag    bool        `json:"check_flag"`
+}
 type PermissionFiccList []*PermissionFiccItem
 
 func (p PermissionFiccList) Len() int {
@@ -58,6 +63,12 @@ type PermissionCheckInfo struct {
 	CustomerInfo CustomerInfo `json:"customer_info" description:"客户信息"`
 }
 
+// PermissionCheckInfoContact 权限校验完成后的结果
+type PermissionCheckContactInfo struct {
+	Name         string       `json:"name" description:"销售名称"`
+	Mobile       string       `json:"mobile" description:"手机号"`
+}
+
 // CustomerInfo 客户信息
 type CustomerInfo struct {
 	CompanyName string `json:"company_name" description:"客户(公司)名称"`

+ 44 - 2
services/company/permission.go

@@ -1,7 +1,9 @@
 package company
 
 import (
+	"errors"
 	"fmt"
+	"hongze/hongze_yb/global"
 	"hongze/hongze_yb/models/response"
 	"hongze/hongze_yb/models/tables/admin"
 	"hongze/hongze_yb/models/tables/chart_permission"
@@ -598,7 +600,13 @@ func GetFiccPermissionList() (list []*FiccPermissionList, err error) {
 	return
 }
 
-func GetHomeFiccPermissions(user user.UserInfo) (list response.PermissionFiccList, err error){
+func GetHomeFiccPermissions(user user.UserInfo) (ret response.PermissionFiccResp, err error){
+	var errMsg string
+	defer func() {
+		if err != nil {
+			global.LOG.Critical(fmt.Sprintf("GetHomeFiccPermissions: userId=%d, err:%s, errMsg:%s", user.UserID, err.Error(), errMsg))
+		}
+	}()
 	validPermissionList, err := GetValidPermissionByCompany2ProductId(user.CompanyID, 1)
 	if err != nil {
 		return
@@ -658,7 +666,7 @@ func GetHomeFiccPermissions(user user.UserInfo) (list response.PermissionFiccLis
 
 
 	}
-
+	var list response.PermissionFiccList
 	for k, v := range permissionFirstMap {
 		temp := new(response.PermissionFiccItem)
 		temp.Sort = v.Sort
@@ -690,11 +698,45 @@ func GetHomeFiccPermissions(user user.UserInfo) (list response.PermissionFiccLis
 	if len(list) > 0 {
 		sort.Sort(list)
 	}
+	//判断是否是已购用户,如果是已购用户,需要返回对应的联系人方式
+	companyProduct, err := company_product.GetByCompany2ProductId(user.CompanyID, 1)
+	if err != nil {
+		if err == utils.ErrNoRow {
+			err = nil
+		}
+	}
+
+	if err != nil {
+		errMsg = err.Error()
+		err = errors.New("查询用户状态失败")
+		return
+	}
+	// 已购仅付费用户可见
+	var contactInfo response.PermissionCheckContactInfo
+	checkFlag := false
+	if strings.Contains("永续,正式", companyProduct.Status) {
+		//查询对应的销售
+		//查找对应客户的销售信息
+		adminInfo, tmpErr := admin.GetByAdminId(companyProduct.SellerID)
+		if tmpErr != nil {
+			errMsg = tmpErr.Error()
+			err = errors.New("查询销售信息出错")
+			return
+		}
+		contactInfo.Name = adminInfo.RealName
+		contactInfo.Mobile = adminInfo.Mobile
+		checkFlag = true
+	}
+
 	temp := new(response.PermissionFiccItem)
 	temp.SelectIconUrl = utils.ALIYUN_YBIMG_HOST+"ficc_icon_idx_more_select.png"
 	temp.IconUrl = utils.ALIYUN_YBIMG_HOST+"ficc_icon_idx_more.png"
 	temp.ClassifyName = "更多报告"
 	temp.Sort = 100000
 	list = append(list, temp)
+
+	ret.PermissionList = list
+	ret.CheckFlag = checkFlag
+	ret.ContactInfo = contactInfo
 	return
 }

+ 6 - 3
services/elastic/report.go

@@ -94,8 +94,10 @@ func SearchReport(keyWord string, classifyIdFirsts []int, classifyIdSeconds []in
 	}
 	filterMustNot := []map[string]interface{}{
 		map[string]interface{}{
-			"exists": map[string]interface{}{
-				"field": "BodyContent",                     //过滤没有内容的报告(晨报和周报)bodyContent 不能为空
+			"term": map[string]interface{}{
+				"BodyContent.keyword": map[string]interface{}{
+					"value": "",                     //过滤没有内容的报告(晨报和周报)bodyContent 不能为空
+				},
 			},
 		},
 	}
@@ -137,7 +139,8 @@ func SearchReport(keyWord string, classifyIdFirsts []int, classifyIdSeconds []in
 			},
 		},
 	}
-	fmt.Println(source)
+	jsonstr, err := json.Marshal(source)
+	fmt.Printf("%s",jsonstr)
 	request := global.EsClient.Search(indexName).Source(source) // sets the JSON request
 
 	searchResp, err = request.Do(context.Background())

+ 4 - 3
services/report/report.go

@@ -615,10 +615,10 @@ func GetReportList(user user.UserInfo, keyWord string, classifyIdFirst, classify
 					temp.Title = v.Highlight["Title"][0]
 				}
 				if len(v.Highlight["Abstract"]) > 0 {
-					temp.Title = v.Highlight["Abstract"][0]
+					temp.Abstract = v.Highlight["Abstract"][0]
 				}
 				if len(v.Highlight["StageStr"]) > 0 {
-					temp.Title = v.Highlight["StageStr"][0]
+					temp.StageStr = v.Highlight["StageStr"][0]
 				}
 				list = append(list, temp)
 			}
@@ -747,6 +747,7 @@ func GetCollectReportList(user user.UserInfo, chartPermissionId, pageIndex, page
 			sort.Sort(list)
 		}
 	}
+
 	ret = new(response.ReportCollectResp)
 	ret.List = list
 	ret.Paging = response.GetPaging(pageIndex, pageSize, int(total))
@@ -807,7 +808,7 @@ func SearchReport(user user.UserInfo, keyWord string, pageIndex, pageSize int)(r
 			temp.Title = reportItem.Title
 			temp.ContentSub = html.UnescapeString(html.UnescapeString(reportItem.BodyContent))
 			temp.PublishTime, err = time.Parse("2006-01-02 15:04:05", reportItem.PublishTime)
-			fmt.Println(*reportItem)
+
 			if len(v.Highlight["Title"]) > 0 {
 				temp.Title = v.Highlight["Title"][0]
 			}