|
@@ -3,18 +3,22 @@ package service
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
"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/db"
|
|
|
"jy/src/jfw/modules/publicapply/src/me"
|
|
|
"jy/src/jfw/modules/publicapply/src/subscribePush/entity"
|
|
|
"log"
|
|
|
+ "strings"
|
|
|
"time"
|
|
|
|
|
|
. "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/redis"
|
|
|
"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"
|
|
|
)
|
|
@@ -67,7 +71,7 @@ func (sp *SubscribePush) VipSwitch() {
|
|
|
return nil, fmt.Errorf("未知请求")
|
|
|
}
|
|
|
return map[string]interface{}{
|
|
|
- "vt": util.ObjToString(sp.GetSession(jy.SwitchService.SessionKey)),
|
|
|
+ "vt": qutil.ObjToString(sp.GetSession(jy.SwitchService.SessionKey)),
|
|
|
"flag": switchOk,
|
|
|
}, nil
|
|
|
}()
|
|
@@ -79,7 +83,7 @@ func (sp *SubscribePush) VipSwitch() {
|
|
|
|
|
|
// HasPushHistory 大会员、超级订阅,商机管理推送历史 (原wx推送更改)
|
|
|
func (sp *SubscribePush) HasPushHistory() {
|
|
|
- userId := util.ObjToString(sp.GetSession("userId"))
|
|
|
+ userId := qutil.ObjToString(sp.GetSession("userId"))
|
|
|
if userId == "" {
|
|
|
return
|
|
|
}
|
|
@@ -89,7 +93,7 @@ func (sp *SubscribePush) HasPushHistory() {
|
|
|
vipType = jy.SwitchService.GetEntniche(sp.Session(), *config.Middleground)
|
|
|
}
|
|
|
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"))
|
|
|
go entity.HistoryPush.UpdateUserPushUnread(userId, vipType)
|
|
@@ -100,7 +104,7 @@ func (sp *SubscribePush) HasPushHistory() {
|
|
|
todayNum := time.Unix(time.Now().Unix(), 1).Format("20060102")
|
|
|
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 twoRemind = int64(2 * 24 * 60 * 60)
|
|
|
var oneRemind = int64(1 * 24 * 60 * 60)
|
|
@@ -109,14 +113,14 @@ func (sp *SubscribePush) HasPushHistory() {
|
|
|
}
|
|
|
isVipFlag = true
|
|
|
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"]
|
|
|
//是否到期
|
|
|
- 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 //即将到期
|
|
|
- } 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 //即将到期
|
|
|
- } 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 //即将到期
|
|
|
}
|
|
|
//判断首次用户是否推送的带有”其他“
|
|
@@ -130,7 +134,7 @@ func (sp *SubscribePush) HasPushHistory() {
|
|
|
if (*user)["i_vip_status"] == nil {
|
|
|
isExpire = 0
|
|
|
} 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
|
|
|
}
|
|
@@ -213,9 +217,9 @@ func (sp *SubscribePush) HistoryPaging() {
|
|
|
vipType = jy.SwitchService.GetEntniche(sp.Session(), *config.Middleground)
|
|
|
}
|
|
|
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")
|
|
|
PageSize, _ := sp.GetInteger("pageSize")
|
|
|
if pageNum == 1 {
|
|
@@ -283,7 +287,7 @@ func (sp *SubscribePush) HistoryPaging() {
|
|
|
|
|
|
// SetRead 推送记录设置已读
|
|
|
func (sp *SubscribePush) SetRead() error {
|
|
|
- defer util.Catch()
|
|
|
+ defer qutil.Catch()
|
|
|
vsid, _ := sp.GetInteger("vsid")
|
|
|
if vsid <= 0 {
|
|
|
return nil
|
|
@@ -292,7 +296,7 @@ func (sp *SubscribePush) SetRead() error {
|
|
|
if vipType == "" { //默认取已切换的企业
|
|
|
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 {
|
|
|
jy.NewSubscribePush(vipType).Visit(db.MysqlMemberPush, userId, vsid)
|
|
|
} else if vipType == jy.SwitchService.Entniche {
|
|
@@ -314,19 +318,42 @@ func (sp *SubscribePush) PushSetting() {
|
|
|
|
|
|
}
|
|
|
|
|
|
-// GetPushCount 订阅设置订阅词近三个月推送数量
|
|
|
+// GetPushCount 订阅设置订阅词近三个月推送数量(帮助用户设置订阅次为15天)
|
|
|
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 != "" {
|
|
|
vipType := sp.GetString("vt")
|
|
|
- if vipType == "" { //默认取已切换的企业
|
|
|
+ if vipType == "" && !isHelp { //默认取已切换的企业
|
|
|
vipType = jy.SwitchService.GetEntniche(sp.Session(), *config.Middleground)
|
|
|
-
|
|
|
}
|
|
|
matchway, _ := sp.GetInteger("matchway")
|
|
|
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
|
|
@@ -334,7 +361,7 @@ func (sp *SubscribePush) GetPushCount() error {
|
|
|
|
|
|
// getPushAllCount 全部关键词-最近三个月推送结果预览总数
|
|
|
func (sp *SubscribePush) GetPushAllCount() error {
|
|
|
- defer util.Catch()
|
|
|
+ defer qutil.Catch()
|
|
|
userId, _ := sp.GetSession("userId").(string)
|
|
|
if userId != "" {
|
|
|
index, _ := sp.GetInteger("index")
|
|
@@ -343,7 +370,7 @@ func (sp *SubscribePush) GetPushAllCount() error {
|
|
|
vipType = jy.SwitchService.GetEntniche(sp.Session(), *config.Middleground)
|
|
|
}
|
|
|
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
|