Browse Source

活动列表升级权限修改

xingzai 2 years ago
parent
commit
442bcf0f38

+ 26 - 4
controllers/search.go

@@ -597,15 +597,37 @@ func (this *SearchController) ListHomeArtAndChartPage() {
 	var result []*models.SearchItem
 	var total int64
 	if listType == 1 || listType == 2 {
-		tmpResult, tmpTotal, tmpErr := services.EsArticleSearch(keyWord, startSize, pageSize, orderColumn)
-		result = tmpResult
-		total = tmpTotal
-		err = tmpErr
+		_, tmpTotal, err := services.EsArticleSearch(keyWord, startSize, pageSize, orderColumn, 0)
+		if err != nil {
+			br.Msg = "检索失败"
+			br.ErrMsg = "检索失败,Err:" + err.Error()
+			return
+		}
+		tmpResult, tmpTotalResult, err := services.EsArticleSearch(keyWord, startSize, pageSize, orderColumn, 1)
 		if err != nil {
 			br.Msg = "检索失败"
 			br.ErrMsg = "检索失败,Err:" + err.Error()
 			return
 		}
+		result = tmpResult
+		if int(tmpTotalResult) < currentIndex*pageSize {
+			startSizeIk := startSize - int(tmpTotalResult)
+			if startSizeIk < 0 {
+				startSizeIk = 0
+			}
+			var pageSizeIk int
+			pageSizeIk = pageSize - len(tmpResult)
+			tmpResultIk, _, err := services.EsArticleSearch(keyWord, startSizeIk, pageSizeIk, orderColumn, 2)
+			if err != nil {
+				br.Msg = "检索失败"
+				br.ErrMsg = "检索失败,Err:" + err.Error()
+				return
+			}
+			for _, v := range tmpResultIk {
+				result = append(result, v)
+			}
+		}
+		total = tmpTotal
 		if len(result) == 0 {
 			result = make([]*models.SearchItem, 0)
 		}

+ 2 - 2
controllers/tactics.go

@@ -13,7 +13,7 @@ import (
 	"time"
 )
 
-//策略
+// 策略
 type TacticsController struct {
 	BaseAuthController
 }
@@ -63,7 +63,7 @@ func (this *TacticsController) List() {
 	page := paging.GetPaging(currentIndex, pageSize, total)
 
 	//获取该产业下所对应的行业图片
-	detail, errCategory := models.GetdetailByCategoryIdOne(categoryId)
+	detail, errCategory := models.GetdetailByCategoryIdOneByHangye(categoryId)
 	if errCategory != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)

+ 2 - 2
models/company_activity_trip.go

@@ -60,7 +60,7 @@ func GetCompanyPermissionByUserTrip(companyId int) (permission string, err error
 	return
 }
 
-// 获取正式权限
+// 获取可查看升级权限的正式权限
 func GetCompanyPermissionByUserZhengShiTrip(companyId int) (permission string, err error) {
 	sql := ` SELECT GROUP_CONCAT(DISTINCT b.chart_permission_name  ORDER BY b.sort ASC  SEPARATOR ',') AS permission
 			FROM company_report_permission AS a
@@ -70,7 +70,7 @@ func GetCompanyPermissionByUserZhengShiTrip(companyId int) (permission string, e
 			AND c.is_suspend=0
             AND b.cygx_auth=1
 			AND a.is_upgrade = 1 
-			AND c.status IN('正式')  `
+			AND ( a.is_upgrade = 1 AND c.STATUS = '正式' OR c.STATUS = '永续' ) `
 	o := orm.NewOrm()
 	err = o.Raw(sql, companyId).QueryRow(&permission)
 	return

+ 22 - 14
models/report_mapping.go

@@ -46,7 +46,7 @@ type TradeReportMappingResp struct {
 	List []*TradeReportMapping
 }
 
-//获取策略下面的所有分类
+// 获取策略下面的所有分类
 func GetReportMappingStrategyAll() (items []*ReportMapping, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_report_mapping WHERE report_type=1 AND chart_permission_id=23 ORDER BY sort ASC `
@@ -54,7 +54,7 @@ func GetReportMappingStrategyAll() (items []*ReportMapping, err error) {
 	return
 }
 
-//获取策略下面的所有分类
+// 获取策略下面的所有分类
 func GetReportMappingStrategyHomeAll() (items []*ReportMappingHome, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -73,7 +73,7 @@ ORDER BY
 	return
 }
 
-//行业列表
+// 行业列表
 func GetTradeAll(ChartPermissionId int) (items []*TradeReportMapping, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -109,7 +109,7 @@ type IndustrialToArticleCategoryListRep struct {
 	List                   []*IndustrialToArticleCategoryRep
 }
 
-//通过分类ID获取详情
+// 通过分类ID获取详情
 func GetdetailByCategoryId(categoryId int) (item *ReportMapping, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_report_mapping WHERE report_type=1 AND category_id=? `
@@ -117,7 +117,7 @@ func GetdetailByCategoryId(categoryId int) (item *ReportMapping, err error) {
 	return
 }
 
-//通过分类ID获取详情
+// 通过分类ID获取详情
 func GetdetailByCategoryIdSet(categoryId int) (ids string, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -130,7 +130,7 @@ func GetdetailByCategoryIdSet(categoryId int) (ids string, err error) {
 	return
 }
 
-//通过分类ID获取详情
+// 通过分类ID获取详情
 func GetdetailByCategoryIdPush(categoryId int) (item *ReportMapping, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_report_mapping WHERE category_id=? `
@@ -138,7 +138,7 @@ func GetdetailByCategoryIdPush(categoryId int) (item *ReportMapping, err error)
 	return
 }
 
-//通过分类ID获取详情主观客观
+// 通过分类ID获取详情主观客观
 func GetdetailByCategoryIdSando(categoryId int) (item *ReportMapping, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_report_mapping WHERE permission_type>0 AND category_id=?  LIMIT 1`
@@ -146,15 +146,23 @@ func GetdetailByCategoryIdSando(categoryId int) (item *ReportMapping, err error)
 	return
 }
 
-//通过分类ID获取详情
+// 通过分类ID获取详情
 func GetdetailByCategoryIdOne(categoryId int) (item *ReportMapping, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT * FROM cygx_report_mapping WHERE category_id=? LIMIT 1`
+	sql := `SELECT * FROM cygx_report_mapping WHERE category_id=?   AND report_type = 2 LIMIT 1`
 	err = o.Raw(sql, categoryId).QueryRow(&item)
 	return
 }
 
-//判断该分类下最新的文章用户是否阅读
+// 通过分类ID获取详情
+func GetdetailByCategoryIdOneByHangye(categoryId int) (item *ReportMapping, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_report_mapping WHERE  category_id=?   AND report_type = 1 LIMIT 1`
+	err = o.Raw(sql, categoryId).QueryRow(&item)
+	return
+}
+
+// 判断该分类下最新的文章用户是否阅读
 func CheckThisCategoryNewArticleIsRead(uid, categoryId int) (count int, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT COUNT(1) count
@@ -165,7 +173,7 @@ func CheckThisCategoryNewArticleIsRead(uid, categoryId int) (count int, err erro
 	return
 }
 
-//获取策略下面的所有分类
+// 获取策略下面的所有分类
 func GetMatchTypeNamenNotNull() (items []*ReportMapping, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT category_id,category_id_set,match_type_name FROM cygx_report_mapping WHERE match_type_name <> ''`
@@ -183,7 +191,7 @@ type ReportMappingStatistical struct {
 	Uv              int    `description:"Uv"`
 }
 
-//获取报表
+// 获取报表
 func GetStatisticalReportArtilce(chartPermissionId int) (items []*ReportMappingStatistical, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -209,7 +217,7 @@ WHERE
 	return
 }
 
-//获取报表
+// 获取报表
 func GetStatisticalReportArtilceExpert() (items []*ReportMappingStatistical, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -227,7 +235,7 @@ func GetStatisticalReportArtilceExpert() (items []*ReportMappingStatistical, err
 	return
 }
 
-//通过分类ID获取详情 处理路演精华的映射
+// 通过分类ID获取详情 处理路演精华的映射
 func GetdetailByCategoryIdLyjh(categoryId int) (item *ReportMapping, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT

+ 40 - 73
services/activity.go

@@ -312,7 +312,6 @@ func EditUserOutboundMobile(cont context.Context) (err error) {
 
 // 获取 用户类型   //1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //3、分行业套餐客户(开通对应行业的正式客户) //4、仅开通专家套餐的正式客户 //5、开通对应行业套餐或专家套餐的试用客户;6、冻结客户;7、流失客户
 func GetUserType(companyId int) (userType int, permissionStrnew string, err error) {
-
 	var permissionStr, permissionZhengShiStr string
 	if companyId <= 1 {
 		userType = 0
@@ -340,28 +339,12 @@ func GetUserType(companyId int) (userType int, permissionStrnew string, err erro
 				err = errs
 				return
 			}
-
 			//1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //3、分行业套餐客户(开通对应行业的正式客户) //4、仅开通专家套餐的正式客户 //5、开通对应行业套餐或专家套餐的试用客户、 10: 30W套餐客户
 			//大套餐客户定义:医药、消费、科技、智造、策略。5个行业中任意4个及以上是正式权限的,属于大套餐客户(医药、消费、科技、智造需要主客观都开)
 			if companyDetail.Status == "永续" {
 				userType = 1
 			} else if companyDetail.Status == "试用" {
 				userType = 5
-			} else if companyDetail.Status == "正式" {
-				//userType = 0
-				//if permissionStr == "专家" {
-				//	userType = 4
-				//}
-				//else if strings.Count(permissionZhengShiStr, "医药") == 2 && strings.Count(permissionZhengShiStr, "消费") == 2 && strings.Count(permissionZhengShiStr, "科技") == 2 && strings.Count(permissionZhengShiStr, "智造") == 2 && strings.Count(permissionZhengShiStr, "策略") == 1 {
-				//	userType = 2
-				//} else {
-				//	userType = 3
-				//}
-				//if userType == 3 {
-				//	if !strings.Contains(permissionStr, "医药") && !strings.Contains(permissionStr, "消费") && !strings.Contains(permissionStr, "科技") && !strings.Contains(permissionStr, "智造") {
-				//		userType = 4
-				//	}
-				//}
 			} else if companyDetail.Status == "冻结" {
 				userType = 6
 			} else if companyDetail.Status == "流失" {
@@ -390,16 +373,7 @@ func GetUserType(companyId int) (userType int, permissionStrnew string, err erro
 				} else if permissionZhegnshiNum == 4 {
 					userType = 10
 				} else {
-					permissionShengji, errs := models.GetCompanyPermissionByUserZhengShi(companyId)
-					if errs != nil {
-						err = errs
-						return
-					}
-					if permissionShengji != "" {
-						userType = 8
-					} else {
-						userType = 3
-					}
+					userType = 9
 				}
 			}
 		}
@@ -799,58 +773,51 @@ func GetActivityonditionList(user *models.WxUserItem, activityTypeId, chartPermi
 	//condition += ` AND art.visible_range != 1  AND art.publish_status = 1 `
 	condition += `   AND art.publish_status = 1 `
 
-	//permissionZhengShiStr, errs := models.GetCompanyPermissionByUserZhengShi(user.CompanyId)
-	//if errs != nil {
-	//	err = errs
-	//	return
-	//}
+	permissionZhengShiStr, errs := models.GetCompanyPermissionByUserZhengShi(user.CompanyId)
+	if errs != nil {
+		err = errs
+		return
+	}
 	//9:其他行业正式客户:前述所有正式客户以外的正式客户 查询处理
-	//if permissionZhengShiStr != "" {
-	//	slicePerZhengshi := strings.Split(permissionZhengShiStr, ",")
-	//	permissionZhengShiStr = ""
-	//	for _, v := range slicePerZhengshi {
-	//		if userType == 1 {
-	//			//研选权限处理(永续客户无法查看研选)
-	//			if !strings.Contains(v, utils.CHART_PERMISSION_NAME_YANXUAN) {
-	//				permissionZhengShiStr += "'" + v + "',"
-	//			}
-	//		} else {
-	//			permissionZhengShiStr += "'" + v + "',"
-	//		}
-	//	}
-	//	permissionZhengShiStr = strings.Replace(permissionZhengShiStr, "(主观)", "", -1)
-	//	permissionZhengShiStr = strings.Replace(permissionZhengShiStr, "(客观)", "", -1)
-	//	permissionZhengShiStr = strings.TrimRight(permissionZhengShiStr, ",")
-	//	//conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%3%'	   AND art.chart_permission_name  IN (` + permissionZhengShiStr + `)` + condition + `) `
-	//
-	//	if userType == 9 {
-	//		conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%9%'	   AND art.chart_permission_name  NOT  IN (` + permissionZhengShiStr + `)` + condition + `) `
-	//	}
-	//}
-
-	if userType != 2 {
-		// 8: 行业升级套餐客户:该活动对应行业为升级权限的客户
-		permissionShengji, errs := models.GetCompanyPermissionByUserZhengShiTrip(user.CompanyId)
-		if errs != nil {
-			err = errs
-			return
+	if permissionZhengShiStr != "" && userType == 9 {
+		slicePerZhengshi := strings.Split(permissionZhengShiStr, ",")
+		permissionZhengShiStr = ""
+		for _, v := range slicePerZhengshi {
+			if userType == 1 {
+				//研选权限处理(永续客户无法查看研选)
+				if !strings.Contains(v, utils.CHART_PERMISSION_NAME_YANXUAN) {
+					permissionZhengShiStr += "'" + v + "',"
+				}
+			} else {
+				permissionZhengShiStr += "'" + v + "',"
+			}
 		}
-		if permissionShengji != "" {
-			slicePerShengji := strings.Split(permissionShengji, ",")
-			permissionShengji = ""
-			for _, v := range slicePerShengji {
-				if userType == 1 {
-					//研选权限处理(永续客户无法查看研选)
-					if !strings.Contains(v, utils.CHART_PERMISSION_NAME_YANXUAN) {
-						permissionShengji += "'" + v + "',"
-					}
-				} else {
+		permissionZhengShiStr = strings.Replace(permissionZhengShiStr, "(主观)", "", -1)
+		permissionZhengShiStr = strings.Replace(permissionZhengShiStr, "(客观)", "", -1)
+		permissionZhengShiStr = strings.TrimRight(permissionZhengShiStr, ",")
+		conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%9%'	   AND art.chart_permission_name  NOT  IN (` + permissionZhengShiStr + `)` + condition + `) `
+	}
+	// 8: 行业升级套餐客户:该活动对应行业为升级权限的客户
+	permissionShengji, errs := models.GetCompanyPermissionByUserZhengShiTrip(user.CompanyId)
+	if errs != nil {
+		err = errs
+		return
+	}
+	if permissionShengji != "" {
+		slicePerShengji := strings.Split(permissionShengji, ",")
+		permissionShengji = ""
+		for _, v := range slicePerShengji {
+			if userType == 1 {
+				//研选权限处理(永续客户无法查看研选)
+				if !strings.Contains(v, utils.CHART_PERMISSION_NAME_YANXUAN) {
 					permissionShengji += "'" + v + "',"
 				}
+			} else {
+				permissionShengji += "'" + v + "',"
 			}
-			permissionShengji = strings.TrimRight(permissionShengji, ",")
-			conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%8%'	   AND art.chart_permission_name  IN (` + permissionShengji + `)` + condition + `) `
 		}
+		permissionShengji = strings.TrimRight(permissionShengji, ",")
+		conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%8%'	   AND art.chart_permission_name  IN (` + permissionShengji + `)` + condition + `) `
 	}
 
 	conditionHz = condition

+ 24 - 1
services/activity_special.go

@@ -298,7 +298,6 @@ func GetActivitySpecialPrepareList(user *models.WxUserItem, startSize, pageSize
 state 进行状态 1:未开始,2:进行中,3:已结束,4:未开始、进行中 不传默认查询全部items []*CygxActivitySpecialDetail
 */
 func GetActivityLabelSpecialConfirmList(user *models.WxUserItem, startSize, pageSize, state int, keywords string) (list []*models.CygxActivitySpecialDetail, totalConfirm int, err error) {
-	//var condition string
 	companyDetail, e := models.GetCompanyDetailByIdGroupTrip(user.CompanyId)
 	if e != nil {
 		err = errors.New("GetCompanyDetailByIdGroupTrip, Err: " + e.Error())
@@ -363,6 +362,30 @@ func GetActivityLabelSpecialConfirmList(user *models.WxUserItem, startSize, page
 		conditionOr += ` OR (  art.customer_type_ids LIKE '%8%' AND art.chart_permission_name  IN (` + permissionShengji + `)` + condition + `) `
 		pars = append(pars, pars)
 	}
+	//9:其他行业正式客户:前述所有正式客户以外的正式客户 查询处理
+	permissionZhengShiStr, errs := models.GetCompanyPermissionByUserZhengShi(user.CompanyId)
+	if errs != nil {
+		err = errs
+		return
+	}
+	if permissionZhengShiStr != "" && userType == 9 {
+		slicePerZhengshi := strings.Split(permissionZhengShiStr, ",")
+		permissionZhengShiStr = ""
+		for _, v := range slicePerZhengshi {
+			if userType == 1 {
+				//研选权限处理(永续客户无法查看研选)
+				if !strings.Contains(v, utils.CHART_PERMISSION_NAME_YANXUAN) {
+					permissionZhengShiStr += "'" + v + "',"
+				}
+			} else {
+				permissionZhengShiStr += "'" + v + "',"
+			}
+		}
+		permissionZhengShiStr = strings.Replace(permissionZhengShiStr, "(主观)", "", -1)
+		permissionZhengShiStr = strings.Replace(permissionZhengShiStr, "(客观)", "", -1)
+		permissionZhengShiStr = strings.TrimRight(permissionZhengShiStr, ",")
+		conditionOr += ` OR (  art.customer_type_ids LIKE '%9%'	   AND art.chart_permission_name  NOT  IN (` + permissionZhengShiStr + `)` + condition + `) `
+	}
 
 	condition += conditionUser + conditionOr
 	totalConfirm, e = models.GetActivitySpecialCount(condition, pars)

+ 113 - 42
services/elastic.go

@@ -35,7 +35,7 @@ func NewClient() (client *elastic.Client, err error) {
 	return
 }
 
-//创建文章阅读记录的Es索引
+// 创建文章阅读记录的Es索引
 func CreateIndexNameArticleHistory() {
 	indexName := utils.IndexNameArticleHistory
 	mappingJson := `{
@@ -101,7 +101,7 @@ func CreateIndexNameArticleHistory() {
 	EsCreateIndex(indexName, mappingJson)
 }
 
-//func UpdateWxUserLabel(cont context.Context) (err error) {
+// func UpdateWxUserLabel(cont context.Context) (err error) {
 func AddAllArticleHistory(cont context.Context) (err error) {
 	defer func() {
 		if err != nil {
@@ -261,7 +261,7 @@ func AddAllArticleHistory(cont context.Context) (err error) {
 	return
 }
 
-//新增数据
+// 新增数据
 func EsAddArticleHistoryData(item *models.EsUserInteraction) (err error) {
 	defer func() {
 		if err != nil {
@@ -285,8 +285,8 @@ func EsAddArticleHistoryData(item *models.EsUserInteraction) (err error) {
 	return
 }
 
-//indexName:索引名称
-//mappingJson:表结构
+// indexName:索引名称
+// mappingJson:表结构
 func EsCreateIndex(indexName, mappingJson string) (err error) {
 
 	client := utils.Client
@@ -312,7 +312,7 @@ func EsCreateIndex(indexName, mappingJson string) (err error) {
 	return
 }
 
-//新增和修改数据
+// 新增和修改数据
 func EsAddOrEditData(indexName, docId string, item *ElasticTestArticleDetail) (err error) {
 	defer func() {
 		if err != nil {
@@ -360,7 +360,7 @@ func EsAddOrEditData(indexName, docId string, item *ElasticTestArticleDetail) (e
 	return
 }
 
-//新增和修改数据
+// 新增和修改数据
 func EsAddOrEditDataV4(indexName, docId string, item *ElasticTestArticleDetailV4) (err error) {
 	defer func() {
 		if err != nil {
@@ -409,7 +409,7 @@ func EsAddOrEditDataV4(indexName, docId string, item *ElasticTestArticleDetailV4
 	return
 }
 
-//删除数据
+// 删除数据
 func EsDeleteData(indexName, docId string) (err error) {
 	client := utils.Client
 	//if err != nil {
@@ -723,7 +723,7 @@ func EsSearchReport(indexName, keyWord string, startSize, pageSize, userId int)
 	return
 }
 
-//分页
+// 分页
 func EsMultiMatchFunctionScoreQueryTimeSortPage(indexName, keyWord string, startSize, pageSize, userId int) (result []*models.SearchItem, total int64, err error) {
 	client := utils.Client
 	keyWordArr, err := GetIndustryMapNameSliceV2(keyWord)
@@ -887,42 +887,105 @@ func EsMultiMatchFunctionScoreQuerySortPage(indexName, keyWord string, startSize
 	return
 }
 
-func init23423() {
-	EsArticleSearch("立高食品", 0, 10, "34")
-}
+//func init23423() {
+//	EsArticleSearch("立高食品", 0, 10, "34")
+//}
 
-func EsArticleSearch(keyWord string, startSize, pageSize int, orderColumn string) (result []*models.SearchItem, total int64, err error) {
+func EsArticleSearch(keyWord string, startSize, pageSize int, orderColumn string, ikType int) (result []*models.SearchItem, total int64, err error) {
 	indexName := utils.IndexName
 	client := utils.Client
 	keyWordArr, err := GetIndustryMapNameSliceV3(keyWord)
 	keyWordArr = RemoveDuplicatesAndEmpty(keyWordArr)
-	fmt.Println(keyWordArr)
 	keyWordLen := len(keyWordArr)
 	if keyWordLen <= 0 {
 		keyWordArr = append(keyWordArr, keyWord)
 		keyWordLen = len(keyWordArr)
 	}
-	fmt.Println(keyWordArr)
+	//Es 的高级查询有 自定义排序 文档一时半会儿撸不懂,先做多次查询手动过滤 2023.2.2
+	//ikType 查询方式 ,0:查所有 、 1:查询键入词 、 2:查询除了查询键入词之外的联想词
 	mustMap := make([]interface{}, 0)
 	shouldMap := make(map[string]interface{}, 0)
-	//shouldMapquery := make(map[string]interface{}, 0)
 	shouldMapquery := make([]interface{}, 0)
+
+	mustNotMap := make([]interface{}, 0)
+	shouldNotMap := make(map[string]interface{}, 0)
+	shouldNotMapquery := make([]interface{}, 0)
 	// @Param   OrderColumn   query   int  true       "排序字段 ,Comprehensive综合 ,Matching匹配度 ,PublishDate 发布时间 "
 	//keyWordWeight := GetWeight(keyWordLen)
-	//var boost int
+	var boost int
 	//lenkeyWordArr := len(keyWordArr)
-	for _, v := range keyWordArr {
-		//if k == 0 {
-		//	boost = 2 * 1000
-		//} else {
-		//	boost = 1000
-		//}
+	for k, v := range keyWordArr {
+		if k == 0 {
+			boost = 2 * 1000
+		} else {
+			boost = 1
+		}
+
+		//如果是 2:查询除了查询键入词之外的联想词
+		if k == 0 && ikType == 2 {
+			if v != "" {
+				shouldNotMapquery = append(shouldNotMapquery, map[string]interface{}{
+					"function_score": map[string]interface{}{
+						"query": map[string]interface{}{
+							"multi_match": map[string]interface{}{
+								//"boost":  (lenkeyWordArr - k) * boost, //给查询的值赋予权重
+								"boost":  boost, //给查询的值赋予权重
+								"fields": []interface{}{"Title"},
+								"query":  v,
+							},
+						},
+					},
+				})
+				shouldNotMapquery = append(shouldNotMapquery, map[string]interface{}{
+					"function_score": map[string]interface{}{
+						"query": map[string]interface{}{
+							"multi_match": map[string]interface{}{
+								"boost":  boost, //给查询的值赋予权重
+								"fields": []interface{}{"Abstract"},
+								"query":  v,
+							},
+						},
+					},
+				})
+				shouldNotMapquery = append(shouldNotMapquery, map[string]interface{}{
+					"function_score": map[string]interface{}{
+						"query": map[string]interface{}{
+							"multi_match": map[string]interface{}{
+								"boost":  boost, //给查询的值赋予权重
+								"fields": []interface{}{"Annotation"},
+								"query":  v,
+							},
+						},
+					},
+				})
+
+				shouldNotMapquery = append(shouldNotMapquery, map[string]interface{}{
+					"function_score": map[string]interface{}{
+						"query": map[string]interface{}{
+							"multi_match": map[string]interface{}{
+								//"boost":  (lenkeyWordArr-k)*boost - 1, //给查询的值赋予权重
+								"boost":  boost, //给查询的值赋予权重
+								"fields": []interface{}{"BodyText"},
+								"query":  v,
+							},
+						},
+					},
+				})
+			}
+			continue
+		}
+		//如果是 1:查询键入词
+		if k > 0 && ikType == 1 {
+			continue
+		}
+
 		if v != "" {
 			shouldMapquery = append(shouldMapquery, map[string]interface{}{
 				"function_score": map[string]interface{}{
 					"query": map[string]interface{}{
 						"multi_match": map[string]interface{}{
 							//"boost":  (lenkeyWordArr - k) * boost, //给查询的值赋予权重
+							"boost":  boost, //给查询的值赋予权重
 							"fields": []interface{}{"Title"},
 							"query":  v,
 						},
@@ -933,7 +996,7 @@ func EsArticleSearch(keyWord string, startSize, pageSize int, orderColumn string
 				"function_score": map[string]interface{}{
 					"query": map[string]interface{}{
 						"multi_match": map[string]interface{}{
-							//"boost":  (lenkeyWordArr - k) * boost, //给查询的值赋予权重
+							"boost":  boost, //给查询的值赋予权重
 							"fields": []interface{}{"Abstract"},
 							"query":  v,
 						},
@@ -944,18 +1007,20 @@ func EsArticleSearch(keyWord string, startSize, pageSize int, orderColumn string
 				"function_score": map[string]interface{}{
 					"query": map[string]interface{}{
 						"multi_match": map[string]interface{}{
-							//"boost":  (lenkeyWordArr - k) * boost, //给查询的值赋予权重
+							"boost":  boost, //给查询的值赋予权重
 							"fields": []interface{}{"Annotation"},
 							"query":  v,
 						},
 					},
 				},
 			})
+
 			shouldMapquery = append(shouldMapquery, map[string]interface{}{
 				"function_score": map[string]interface{}{
 					"query": map[string]interface{}{
 						"multi_match": map[string]interface{}{
 							//"boost":  (lenkeyWordArr-k)*boost - 1, //给查询的值赋予权重
+							"boost":  boost, //给查询的值赋予权重
 							"fields": []interface{}{"BodyText"},
 							"query":  v,
 						},
@@ -967,8 +1032,13 @@ func EsArticleSearch(keyWord string, startSize, pageSize int, orderColumn string
 	shouldMap = map[string]interface{}{
 		"should": shouldMapquery,
 	}
+
+	shouldNotMap = map[string]interface{}{
+		"should": shouldNotMapquery,
+	}
 	//排序
 	sortMap := make([]interface{}, 0)
+
 	//时间
 	sortMap = append(sortMap, map[string]interface{}{
 		"PublishDate": map[string]interface{}{
@@ -992,6 +1062,10 @@ func EsArticleSearch(keyWord string, startSize, pageSize int, orderColumn string
 	mustMap = append(mustMap, map[string]interface{}{
 		"bool": shouldMap,
 	})
+	mustNotMap = append(mustNotMap, map[string]interface{}{
+		"bool": shouldNotMap,
+	})
+
 	queryMap := map[string]interface{}{
 		"query": map[string]interface{}{
 			"bool": map[string]interface{}{
@@ -999,14 +1073,25 @@ func EsArticleSearch(keyWord string, startSize, pageSize int, orderColumn string
 			},
 		},
 	}
+	//把第一次键入词的筛选条件过滤掉
+	if ikType == 2 {
+		queryMap = map[string]interface{}{
+			"query": map[string]interface{}{
+				"bool": map[string]interface{}{
+					"must":     mustMap,
+					"must_not": mustNotMap,
+				},
+			},
+		}
+	}
 	if orderColumn == "Matching" {
 		queryMap["sort"] = sortMap
 	}
 	queryMap["from"] = startSize
 	queryMap["size"] = pageSize
 	queryMap["highlight"] = highlightMap
-	//jsonBytes, _ := json.Marshal(queryMap)
-	//fmt.Println(string(jsonBytes))
+	jsonBytes, _ := json.Marshal(queryMap)
+	fmt.Println(string(jsonBytes))
 	//utils.FileLog.Info(string(jsonBytes))
 	request := client.Search(indexName).Source(queryMap) // sets the JSON request
 	searchByMatch, err := request.Do(context.Background())
@@ -1025,18 +1110,8 @@ func EsArticleSearch(keyWord string, startSize, pageSize int, orderColumn string
 				}
 				searchItem := new(models.SearchItem)
 				searchItem.ArticleId, _ = strconv.Atoi(v.Id)
-				if len(v.Highlight["BodyText"]) > 0 || len(v.Highlight["Abstract"]) > 0 || len(v.Highlight["Annotation"]) > 0 {
+				if len(v.Highlight["BodyText"]) > 0 {
 					searchItem.Body = v.Highlight["BodyText"]
-					if len(v.Highlight["Abstract"]) > 0 {
-						for _, vRed := range v.Highlight["Abstract"] {
-							searchItem.Body = append(searchItem.Body, vRed)
-						}
-					}
-					if len(v.Highlight["Annotation"]) > 0 {
-						for _, vRed := range v.Highlight["Annotation"] {
-							searchItem.Body = append(searchItem.Body, vRed)
-						}
-					}
 				} else {
 					bodyRune := []rune(article.BodyText)
 					bodyRuneLen := len(bodyRune)
@@ -1068,9 +1143,5 @@ func EsArticleSearch(keyWord string, startSize, pageSize int, orderColumn string
 		}
 		total = searchByMatch.Hits.TotalHits.Value
 	}
-	//fmt.Println(result)
-	//for _, v := range result {
-	//	fmt.Println(v)
-	//}
 	return
 }