瀏覽代碼

wip:提交

wkyuer 1 周之前
父節點
當前提交
1e496f5450

+ 21 - 9
src/jfw/modules/publicapply/src/subscribePush/entity/vrew.go

@@ -12,7 +12,6 @@ import (
 
 
 	qutil "app.yhyue.com/moapp/jybase/common"
 	qutil "app.yhyue.com/moapp/jybase/common"
 	elastic "app.yhyue.com/moapp/jybase/es"
 	elastic "app.yhyue.com/moapp/jybase/es"
-	"app.yhyue.com/moapp/jybase/go-xweb/httpsession"
 	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
 	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
 )
 )
 
 
@@ -45,7 +44,7 @@ const (
  *@param notkey 排除词
  *@param notkey 排除词
  *@param matchway 0:精准 1:模糊
  *@param matchway 0:精准 1:模糊
  */
  */
-func KeysetViewDatasCount(userId, vType, key, notkey string, matchway int, session *httpsession.Session) int64 {
+func KeysetViewDatasCount(userId, vType, key, notkey string, matchway int, sessionMap map[string]interface{}) int64 {
 	key = strings.TrimSpace(key)
 	key = strings.TrimSpace(key)
 	notkey = strings.TrimSpace(notkey)
 	notkey = strings.TrimSpace(notkey)
 	if key == "" {
 	if key == "" {
@@ -55,7 +54,7 @@ func KeysetViewDatasCount(userId, vType, key, notkey string, matchway int, sessi
 	if vType == "" {
 	if vType == "" {
 		sql = GetSqlObjFromFreeId(userId, "", -1)
 		sql = GetSqlObjFromFreeId(userId, "", -1)
 	} else {
 	} else {
-		sql = GetSqlObjFromId(userId, vType, "", -1, session)
+		sql = GetSqlObjFromId(userId, vType, "", -1, sessionMap)
 	}
 	}
 
 
 	viewKeyWords := []ViewKeyWord{}
 	viewKeyWords := []ViewKeyWord{}
@@ -75,7 +74,12 @@ func KeysetViewDatasCount(userId, vType, key, notkey string, matchway int, sessi
 		}
 		}
 	}
 	}
 	sql.Keyword = viewKeyWords
 	sql.Keyword = viewKeyWords
-	qstr := GetVIPViewSql(userId, sql)
+	var qstr string
+	if gconv.Bool(sessionMap["isHelpSub"]) {
+		qstr = GetVIPViewSql(userId, sql, -15)
+	} else {
+		qstr = GetVIPViewSql(userId, sql)
+	}
 	return elastic.Count(INDEX, TYPE, qstr)
 	return elastic.Count(INDEX, TYPE, qstr)
 }
 }
 
 
@@ -84,8 +88,8 @@ func KeysetViewDatasCount(userId, vType, key, notkey string, matchway int, sessi
  *@param item 分类名称
  *@param item 分类名称
  *@param index 关键词在分类下的索引位置
  *@param index 关键词在分类下的索引位置
  */
  */
-func SubViewDatasCount(userId, vType, item string, index int, session *httpsession.Session) int64 {
-	sql := GetSqlObjFromId(userId, vType, item, index, session)
+func SubViewDatasCount(userId, vType, item string, index int, sessionMap map[string]interface{}) int64 {
+	sql := GetSqlObjFromId(userId, vType, item, index, sessionMap)
 	if item != "" && index >= 0 && (sql.Keyword == nil || len(sql.Keyword) == 0) {
 	if item != "" && index >= 0 && (sql.Keyword == nil || len(sql.Keyword) == 0) {
 		log.Println("推送结果预览总数参数异常,没有找到改组订阅词", item, index)
 		log.Println("推送结果预览总数参数异常,没有找到改组订阅词", item, index)
 		return 0
 		return 0
@@ -95,16 +99,24 @@ func SubViewDatasCount(userId, vType, item string, index int, session *httpsessi
 }
 }
 
 
 // 获取vip订阅预览的查询语句
 // 获取vip订阅预览的查询语句
-func GetVIPViewSql(userId string, scd *ViewCondition) string {
+func GetVIPViewSql(userId string, scd *ViewCondition, dayLimit ...int) string {
 	query := `{"query":{"bool":{"must":[%s],"should":[%s],"minimum_should_match": %d}}}`
 	query := `{"query":{"bool":{"must":[%s],"should":[%s],"minimum_should_match": %d}}}`
 	query_bool_should := `{"bool":{"should":[%s],"minimum_should_match": 1}}`
 	query_bool_should := `{"bool":{"should":[%s],"minimum_should_match": 1}}`
 	multi_match := `{"multi_match": {"query": %s,"type": "phrase", "fields": [%s]}}`
 	multi_match := `{"multi_match": {"query": %s,"type": "phrase", "fields": [%s]}}`
 	query_bool_must_and := `{"bool":{"must":[%s]%s}}`
 	query_bool_must_and := `{"bool":{"must":[%s]%s}}`
+	var (
+		month int = -3
+		day   int
+	)
+	if dayLimit != nil && len(dayLimit) > 0 {
+		month = 0
+		day = dayLimit[0]
+	}
 
 
 	bools := []string{}
 	bools := []string{}
 	musts := []string{}
 	musts := []string{}
 	//发布时间最新三个月
 	//发布时间最新三个月
-	musts = append(musts, fmt.Sprintf(`{"range":{"publishtime":{"gte":%d}}}`, time.Now().AddDate(0, -3, 0).Unix()))
+	musts = append(musts, fmt.Sprintf(`{"range":{"publishtime":{"gte":%d}}}`, time.Now().AddDate(0, month, day).Unix()))
 	//省份
 	//省份
 	areaCity := []string{}
 	areaCity := []string{}
 	if len(scd.Area) > 0 {
 	if len(scd.Area) > 0 {
@@ -222,7 +234,7 @@ func GetVIPViewSql(userId string, scd *ViewCondition) string {
 	return qstr
 	return qstr
 }
 }
 
 
-func GetSqlObjFromId(_id, vType, item string, index int, session *httpsession.Session) *ViewCondition {
+func GetSqlObjFromId(_id, vType, item string, index int, sessionMap map[string]interface{}) *ViewCondition {
 	query := config.Compatible.Select(_id, `{"o_vipjy":1,"o_member_jy":1}`)
 	query := config.Compatible.Select(_id, `{"o_vipjy":1,"o_member_jy":1}`)
 	if query == nil || len(*query) == 0 {
 	if query == nil || len(*query) == 0 {
 		return nil
 		return nil

+ 49 - 22
src/jfw/modules/publicapply/src/subscribePush/service/pushList.go

@@ -3,18 +3,22 @@ package service
 import (
 import (
 	"encoding/json"
 	"encoding/json"
 	"fmt"
 	"fmt"
+	"github.com/gogf/gf/v2/frame/g"
+	"github.com/gogf/gf/v2/util/gconv"
 	"jy/src/jfw/modules/publicapply/src/config"
 	"jy/src/jfw/modules/publicapply/src/config"
 	"jy/src/jfw/modules/publicapply/src/db"
 	"jy/src/jfw/modules/publicapply/src/db"
 	"jy/src/jfw/modules/publicapply/src/me"
 	"jy/src/jfw/modules/publicapply/src/me"
 	"jy/src/jfw/modules/publicapply/src/subscribePush/entity"
 	"jy/src/jfw/modules/publicapply/src/subscribePush/entity"
 	"log"
 	"log"
+	"strings"
 	"time"
 	"time"
 
 
 	. "app.yhyue.com/moapp/jybase/api"
 	. "app.yhyue.com/moapp/jybase/api"
-	util "app.yhyue.com/moapp/jybase/common"
+	qutil "app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/encrypt"
 	"app.yhyue.com/moapp/jybase/encrypt"
 	"app.yhyue.com/moapp/jybase/redis"
 	"app.yhyue.com/moapp/jybase/redis"
 	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
 	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
+	"jy/src/jfw/modules/publicapply/src/util"
 
 
 	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
 	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
 )
 )
@@ -67,7 +71,7 @@ func (sp *SubscribePush) VipSwitch() {
 			return nil, fmt.Errorf("未知请求")
 			return nil, fmt.Errorf("未知请求")
 		}
 		}
 		return map[string]interface{}{
 		return map[string]interface{}{
-			"vt":   util.ObjToString(sp.GetSession(jy.SwitchService.SessionKey)),
+			"vt":   qutil.ObjToString(sp.GetSession(jy.SwitchService.SessionKey)),
 			"flag": switchOk,
 			"flag": switchOk,
 		}, nil
 		}, nil
 	}()
 	}()
@@ -79,7 +83,7 @@ func (sp *SubscribePush) VipSwitch() {
 
 
 // HasPushHistory 大会员、超级订阅,商机管理推送历史 (原wx推送更改)
 // HasPushHistory 大会员、超级订阅,商机管理推送历史 (原wx推送更改)
 func (sp *SubscribePush) HasPushHistory() {
 func (sp *SubscribePush) HasPushHistory() {
-	userId := util.ObjToString(sp.GetSession("userId"))
+	userId := qutil.ObjToString(sp.GetSession("userId"))
 	if userId == "" {
 	if userId == "" {
 		return
 		return
 	}
 	}
@@ -89,7 +93,7 @@ func (sp *SubscribePush) HasPushHistory() {
 		vipType = jy.SwitchService.GetEntniche(sp.Session(), *config.Middleground)
 		vipType = jy.SwitchService.GetEntniche(sp.Session(), *config.Middleground)
 	}
 	}
 	if vipType == jy.SwitchService.Entniche {
 	if vipType == jy.SwitchService.Entniche {
-		userId = fmt.Sprint(util.IntAll(sp.GetSession("entUserId")))
+		userId = fmt.Sprint(qutil.IntAll(sp.GetSession("entUserId")))
 	}
 	}
 	//entId := util.IntAll(sp.GetSession("entId"))
 	//entId := util.IntAll(sp.GetSession("entId"))
 	go entity.HistoryPush.UpdateUserPushUnread(userId, vipType)
 	go entity.HistoryPush.UpdateUserPushUnread(userId, vipType)
@@ -100,7 +104,7 @@ func (sp *SubscribePush) HasPushHistory() {
 	todayNum := time.Unix(time.Now().Unix(), 1).Format("20060102")
 	todayNum := time.Unix(time.Now().Unix(), 1).Format("20060102")
 	if user != nil {
 	if user != nil {
 		//超级订阅
 		//超级订阅
-		if util.IntAll((*user)["i_vip_status"]) == 1 || util.IntAll((*user)["i_vip_status"]) == 2 {
+		if qutil.IntAll((*user)["i_vip_status"]) == 1 || qutil.IntAll((*user)["i_vip_status"]) == 2 {
 			var threeRemind = int64(3 * 24 * 60 * 60)
 			var threeRemind = int64(3 * 24 * 60 * 60)
 			var twoRemind = int64(2 * 24 * 60 * 60)
 			var twoRemind = int64(2 * 24 * 60 * 60)
 			var oneRemind = int64(1 * 24 * 60 * 60)
 			var oneRemind = int64(1 * 24 * 60 * 60)
@@ -109,14 +113,14 @@ func (sp *SubscribePush) HasPushHistory() {
 			}
 			}
 			isVipFlag = true
 			isVipFlag = true
 			isPassCount = redis.GetInt("pushcache_2_a", "oncecount_"+todayNum+"_"+userId) >= 2000
 			isPassCount = redis.GetInt("pushcache_2_a", "oncecount_"+todayNum+"_"+userId) >= 2000
-			isOnTail = util.IntAll((*user)["i_vip_status"])
+			isOnTail = qutil.IntAll((*user)["i_vip_status"])
 			_endtime := (*user)["l_vip_endtime"]
 			_endtime := (*user)["l_vip_endtime"]
 			//是否到期
 			//是否到期
-			if util.Int64All(_endtime)-time.Now().Unix() < threeRemind && util.Int64All(_endtime)-time.Now().Unix() >= twoRemind {
+			if qutil.Int64All(_endtime)-time.Now().Unix() < threeRemind && qutil.Int64All(_endtime)-time.Now().Unix() >= twoRemind {
 				isExpire = 3 //即将到期
 				isExpire = 3 //即将到期
-			} else if util.Int64All(_endtime)-time.Now().Unix() < twoRemind && util.Int64All(_endtime)-time.Now().Unix() >= oneRemind {
+			} else if qutil.Int64All(_endtime)-time.Now().Unix() < twoRemind && qutil.Int64All(_endtime)-time.Now().Unix() >= oneRemind {
 				isExpire = 2 //即将到期
 				isExpire = 2 //即将到期
-			} else if util.Int64All(_endtime)-time.Now().Unix() < oneRemind && util.Int64All(_endtime)-time.Now().Unix() >= 0 {
+			} else if qutil.Int64All(_endtime)-time.Now().Unix() < oneRemind && qutil.Int64All(_endtime)-time.Now().Unix() >= 0 {
 				isExpire = 1 //即将到期
 				isExpire = 1 //即将到期
 			}
 			}
 			//判断首次用户是否推送的带有”其他“
 			//判断首次用户是否推送的带有”其他“
@@ -130,7 +134,7 @@ func (sp *SubscribePush) HasPushHistory() {
 			if (*user)["i_vip_status"] == nil {
 			if (*user)["i_vip_status"] == nil {
 				isExpire = 0
 				isExpire = 0
 			} else {
 			} else {
-				isOnTail = util.IntAll((*user)["i_vip_status"])
+				isOnTail = qutil.IntAll((*user)["i_vip_status"])
 			}
 			}
 			isPassCount = redis.GetInt("pushcache_2_a", "oncecount_"+todayNum+"_"+userId) >= 150
 			isPassCount = redis.GetInt("pushcache_2_a", "oncecount_"+todayNum+"_"+userId) >= 150
 		}
 		}
@@ -213,9 +217,9 @@ func (sp *SubscribePush) HistoryPaging() {
 		vipType = jy.SwitchService.GetEntniche(sp.Session(), *config.Middleground)
 		vipType = jy.SwitchService.GetEntniche(sp.Session(), *config.Middleground)
 	}
 	}
 	if vipType == jy.SwitchService.Entniche {
 	if vipType == jy.SwitchService.Entniche {
-		userId = fmt.Sprint(util.IntAll(sp.GetSession("entUserId")))
+		userId = fmt.Sprint(qutil.IntAll(sp.GetSession("entUserId")))
 	}
 	}
-	entId := util.IntAll(sp.GetSession("entId"))
+	entId := qutil.IntAll(sp.GetSession("entId"))
 	pageNum, _ := sp.GetInteger("pageNum")
 	pageNum, _ := sp.GetInteger("pageNum")
 	PageSize, _ := sp.GetInteger("pageSize")
 	PageSize, _ := sp.GetInteger("pageSize")
 	if pageNum == 1 {
 	if pageNum == 1 {
@@ -283,7 +287,7 @@ func (sp *SubscribePush) HistoryPaging() {
 
 
 // SetRead 推送记录设置已读
 // SetRead 推送记录设置已读
 func (sp *SubscribePush) SetRead() error {
 func (sp *SubscribePush) SetRead() error {
-	defer util.Catch()
+	defer qutil.Catch()
 	vsid, _ := sp.GetInteger("vsid")
 	vsid, _ := sp.GetInteger("vsid")
 	if vsid <= 0 {
 	if vsid <= 0 {
 		return nil
 		return nil
@@ -292,7 +296,7 @@ func (sp *SubscribePush) SetRead() error {
 	if vipType == "" { //默认取已切换的企业
 	if vipType == "" { //默认取已切换的企业
 		vipType = jy.SwitchService.GetEntniche(sp.Session(), *config.Middleground)
 		vipType = jy.SwitchService.GetEntniche(sp.Session(), *config.Middleground)
 	}
 	}
-	if userId := util.ObjToString(sp.GetSession("userId")); userId != "" {
+	if userId := qutil.ObjToString(sp.GetSession("userId")); userId != "" {
 		if vipType == jy.SwitchService.Member {
 		if vipType == jy.SwitchService.Member {
 			jy.NewSubscribePush(vipType).Visit(db.MysqlMemberPush, userId, vsid)
 			jy.NewSubscribePush(vipType).Visit(db.MysqlMemberPush, userId, vsid)
 		} else if vipType == jy.SwitchService.Entniche {
 		} else if vipType == jy.SwitchService.Entniche {
@@ -314,19 +318,42 @@ func (sp *SubscribePush) PushSetting() {
 
 
 }
 }
 
 
-// GetPushCount 订阅设置订阅词近三个月推送数量
+// GetPushCount 订阅设置订阅词近三个月推送数量(帮助用户设置订阅次为15天)
 func (sp *SubscribePush) GetPushCount() error {
 func (sp *SubscribePush) GetPushCount() error {
-	defer util.Catch()
-	userId, _ := sp.GetSession("userId").(string)
+	defer qutil.Catch()
+	var (
+		sessionMap = sp.Session().GetMultiple()
+		userId     = gconv.String(sessionMap["userId"])
+		ent_id     = gconv.Int(sessionMap["entId"])
+		isHelp     = false
+	)
+	//校验是否剑鱼员工
+	if ent_id == g.Cfg().MustGet(sp.Request.Context(), "powerEntId", 25917).Int() && strings.Index(sp.Refer(), "/free/help/set_subscribe") > -1 {
+		if helpUserId := sp.Cookie("usrDewkYanV3"); helpUserId != "" {
+			if identityInfo := util.HelpSubscribeDecode(helpUserId); identityInfo.UserId != "" {
+				userId = identityInfo.UserId
+				ent_id = identityInfo.EntId
+				sessionMap = map[string]interface{}{
+					"userId":       userId,
+					"positionId":   helpUserId,
+					"positionType": identityInfo.PositionType,
+					"mgoUserId":    identityInfo.MgoUserId,
+					"base_user_id": identityInfo.BaseUserId,
+					"isHelpSub":    true,
+				}
+				isHelp = true
+			}
+		}
+	}
+
 	if userId != "" {
 	if userId != "" {
 		vipType := sp.GetString("vt")
 		vipType := sp.GetString("vt")
-		if vipType == "" { //默认取已切换的企业
+		if vipType == "" && !isHelp { //默认取已切换的企业
 			vipType = jy.SwitchService.GetEntniche(sp.Session(), *config.Middleground)
 			vipType = jy.SwitchService.GetEntniche(sp.Session(), *config.Middleground)
-
 		}
 		}
 		matchway, _ := sp.GetInteger("matchway")
 		matchway, _ := sp.GetInteger("matchway")
 		sp.ServeJson(map[string]interface{}{
 		sp.ServeJson(map[string]interface{}{
-			"count": entity.KeysetViewDatasCount(userId, vipType, sp.GetString("key"), sp.GetString("notkey"), matchway, sp.Session()),
+			"count": entity.KeysetViewDatasCount(userId, vipType, sp.GetString("key"), sp.GetString("notkey"), matchway, sessionMap),
 		})
 		})
 	}
 	}
 	return nil
 	return nil
@@ -334,7 +361,7 @@ func (sp *SubscribePush) GetPushCount() error {
 
 
 // getPushAllCount 全部关键词-最近三个月推送结果预览总数
 // getPushAllCount 全部关键词-最近三个月推送结果预览总数
 func (sp *SubscribePush) GetPushAllCount() error {
 func (sp *SubscribePush) GetPushAllCount() error {
-	defer util.Catch()
+	defer qutil.Catch()
 	userId, _ := sp.GetSession("userId").(string)
 	userId, _ := sp.GetSession("userId").(string)
 	if userId != "" {
 	if userId != "" {
 		index, _ := sp.GetInteger("index")
 		index, _ := sp.GetInteger("index")
@@ -343,7 +370,7 @@ func (sp *SubscribePush) GetPushAllCount() error {
 			vipType = jy.SwitchService.GetEntniche(sp.Session(), *config.Middleground)
 			vipType = jy.SwitchService.GetEntniche(sp.Session(), *config.Middleground)
 		}
 		}
 		sp.ServeJson(map[string]interface{}{
 		sp.ServeJson(map[string]interface{}{
-			"count": entity.SubViewDatasCount(userId, vipType, sp.GetString("item"), index, sp.Session()),
+			"count": entity.SubViewDatasCount(userId, vipType, sp.GetString("item"), index, sp.Session().GetMultiple()),
 		})
 		})
 	}
 	}
 	return nil
 	return nil