Эх сурвалжийг харах

Merge branch 'dev4.5.5' of http://127.0.0.1:8080/qmx/jy into dev4.5.5

TANGSHIZHE 4 жил өмнө
parent
commit
3b4cc50655

+ 23 - 9
src/jfw/modules/subscribepay/src/service/afterPay.go

@@ -25,15 +25,16 @@ var VIP_user_lock = map[string]*VIPLOCK{}
 //完成支付数据交互接口
 type AfterPay struct {
 	*xweb.Action
-	getUserInfo    xweb.Mapper `xweb:"/afterPay/getUserInfo"`    //获取用户当前支付后的信息
-	setUserInfo    xweb.Mapper `xweb:"/afterPay/setUserInfo"`    //保存用户当前支付后的信息
-	getPushView    xweb.Mapper `xweb:"/afterPay/getPushView"`    //VIP推送预览-列表
-	getPushCount   xweb.Mapper `xweb:"/afterPay/getPushCount"`   //VIP推送预览-总数
-	updateUserTips xweb.Mapper `xweb:"/afterPay/updateUserTips"` //修改用户未分类关键词提醒
-	directSubKWS   xweb.Mapper `xweb:"/afterPay/directSubKWS"`   //搜索列表直接订阅关键词
-	fastImport     xweb.Mapper `xweb:"/afterPay/fastImport"`     //快速导入关键词
-	modification   xweb.Mapper `xweb:"/afterPay/modification"`   //关键词修改记录
-	aaa            xweb.Mapper `xweb:"/aaa"`
+	getUserInfo        xweb.Mapper `xweb:"/afterPay/getUserInfo"`         //获取用户当前支付后的信息
+	setUserInfo        xweb.Mapper `xweb:"/afterPay/setUserInfo"`         //保存用户当前支付后的信息
+	getPushView        xweb.Mapper `xweb:"/afterPay/getPushView"`         //VIP推送预览-列表
+	getPushCount       xweb.Mapper `xweb:"/afterPay/getPushCount"`        //VIP推送预览-总数
+	keysetGetPushCount xweb.Mapper `xweb:"/afterPay/keyset/getPushCount"` //VIP推送预览-某组关键词-总数
+	updateUserTips     xweb.Mapper `xweb:"/afterPay/updateUserTips"`      //修改用户未分类关键词提醒
+	directSubKWS       xweb.Mapper `xweb:"/afterPay/directSubKWS"`        //搜索列表直接订阅关键词
+	fastImport         xweb.Mapper `xweb:"/afterPay/fastImport"`          //快速导入关键词
+	modification       xweb.Mapper `xweb:"/afterPay/modification"`        //关键词修改记录
+	aaa                xweb.Mapper `xweb:"/aaa"`
 }
 
 func (a *AfterPay) Aaa() {
@@ -324,6 +325,19 @@ func (a *AfterPay) GetPushCount() error {
 	return nil
 }
 
+//
+func (a *AfterPay) KeysetGetPushCount() error {
+	defer qutil.Catch()
+	userId, _ := a.GetSession("userId").(string)
+	if userId != "" {
+		matchway, _ := a.GetInteger("matchway")
+		a.ServeJson(map[string]interface{}{
+			"count": util.KeysetViewDatasCount(userId, a.GetString("key"), a.GetString("notkey"), matchway),
+		})
+	}
+	return nil
+}
+
 //
 func (a *AfterPay) SetUserInfo() error {
 	defer qutil.Catch()

+ 46 - 0
src/jfw/modules/subscribepay/src/util/vrew.go

@@ -84,6 +84,40 @@ func SubViewDatasCount(userId, item string, index int) int64 {
 	return elastic.Count(INDEX, TYPE, qstr)
 }
 
+/*某组关键词-推送结果预览总数
+ *@param userId 用户id
+ *@param key 关键词
+ *@param notkey 排除词
+ *@param matchway 0:精准 1:模糊
+ */
+func KeysetViewDatasCount(userId, key, notkey string, matchway int) int64 {
+	key = strings.TrimSpace(key)
+	notkey = strings.TrimSpace(notkey)
+	if key == "" {
+		return 0
+	}
+	sql := GetSqlObjFromId(userId, "", -1)
+	viewKeyWords := []ViewKeyWord{}
+	if matchway == 0 {
+		viewKeyWords = append(viewKeyWords, ViewKeyWord{
+			Keyword:  strings.Split(key, " "),
+			Exclude:  strings.Split(notkey, " "),
+			MatchWay: matchway,
+		})
+	} else {
+		for _, v := range strings.Split(key, " ") {
+			viewKeyWords = append(viewKeyWords, ViewKeyWord{
+				Keyword:  []string{v},
+				Exclude:  strings.Split(notkey, " "),
+				MatchWay: matchway,
+			})
+		}
+	}
+	sql.Keyword = viewKeyWords
+	qstr := GetVIPViewSql(userId, sql)
+	return elastic.Count(INDEX, TYPE, qstr)
+}
+
 //获取vip订阅预览的查询语句
 func GetVIPViewSql(userId string, scd *ViewCondition) string {
 	query := `{"query":{"bool":{"must":[%s],"should":[%s],"minimum_should_match": %d}}}`
@@ -161,15 +195,27 @@ func GetVIPViewSql(userId string, scd *ViewCondition) string {
 			must_not := []string{}
 			//附加词
 			for _, vv := range v.Keyword {
+				vv = strings.TrimSpace(vv)
+				if vv == "" {
+					continue
+				}
 				shoulds = append(shoulds, fmt.Sprintf(multi_match, "\""+vv+"\""))
 			}
 
 			for _, vv := range v.Appended {
+				vv = strings.TrimSpace(vv)
+				if vv == "" {
+					continue
+				}
 				shoulds = append(shoulds, fmt.Sprintf(multi_match, "\""+vv+"\""))
 			}
 
 			//排除词
 			for _, vv := range v.Exclude {
+				vv = strings.TrimSpace(vv)
+				if vv == "" {
+					continue
+				}
 				must_not = append(must_not, fmt.Sprintf(multi_match, "\""+vv+"\""))
 			}