Răsfoiți Sursa

Merge branch 'feature/v1.1.64' of https://jygit.jydev.jianyu360.cn/BaseService/jyMicroservices into feature/v1.1.64

wangshan 7 luni în urmă
părinte
comite
3bd2595328

+ 1 - 0
go.mod

@@ -153,3 +153,4 @@ require (
 	sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
 	sigs.k8s.io/yaml v1.3.0 // indirect
 )
+replace github.com/go-xorm/xorm v0.7.9 => gitea.com/xorm/xorm v0.7.9

+ 17 - 0
jyBXSubscribe/api/bxsubscribe.api

@@ -52,6 +52,21 @@ type (
 		PositionType string `header:"positionType,optional"`
 		PositionId   string `header:"positionId,optional"`
 	}
+	saveTsGuideReq {
+		AppId        string   `header:"appId"`
+		UserType     string   `path:"userType"`
+		UserId       string   `header:"userId,optional"`
+		NewUserId    string   `header:"newUserId,optional"`
+		EntId        string   `header:"entId,optional"`
+		AccountId    string   `header:"accountId,optional"`
+		PositionType string   `header:"positionType,optional"`
+		PositionId   string   `header:"positionId,optional"`
+		Area         string   `json:"area"`                // 省份、城市  格式  {"福建" : ["福州市","厦门市",]}
+		District     string   `json:"district,optional"`   // 区县 格式  {"莆田市" : ["城厢区","荔城区","秀屿区","仙游县"]}
+		Keywords     []string `json:"keywords"`            // 关键词 ["关键词1 附加词","关键词2"]
+		AppSwitch    bool     `json:"app_switch,optional"` // app提醒总开关
+
+	}
 	//
 	commonResp {
 		Err_code int64       `json:"error_code"`
@@ -259,4 +274,6 @@ service bxsubscribe-api {
 	
 	@handler bidRecList // 订阅推荐列表
 	post /jybx/subscribe/getRecList (BidRecListReq) returns (commonResp)
+	@handler saveTSGuide  // 保存订阅向导设置信息
+	post /jybx/subscribe/:userType/saveTSGuide (saveTsGuideReq) returns (commonResp)
 }

+ 5 - 0
jyBXSubscribe/api/internal/handler/routes.go

@@ -97,6 +97,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/jybx/subscribe/getRecList",
 				Handler: bidRecListHandler(serverCtx),
 			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/jybx/subscribe/:userType/saveTSGuide",
+				Handler: saveTSGuideHandler(serverCtx),
+			},
 		},
 	)
 }

+ 28 - 0
jyBXSubscribe/api/internal/handler/saveTSGuideHandler.go

@@ -0,0 +1,28 @@
+package handler
+
+import (
+	"net/http"
+
+	"bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/api/internal/logic"
+	"bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/api/internal/svc"
+	"bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/api/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func saveTSGuideHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.SaveTsGuideReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.Error(w, err)
+			return
+		}
+
+		l := logic.NewSaveTSGuideLogic(r.Context(), svcCtx)
+		resp, err := l.SaveTSGuide(&req)
+		if err != nil {
+			httpx.Error(w, err)
+		} else {
+			httpx.OkJson(w, resp)
+		}
+	}
+}

+ 52 - 0
jyBXSubscribe/api/internal/logic/saveTSGuideLogic.go

@@ -0,0 +1,52 @@
+package logic
+
+import (
+	"bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/api/internal/svc"
+	"bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/api/internal/types"
+	"bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/rpc/type/bxsubscribe"
+	"context"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type SaveTSGuideLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewSaveTSGuideLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SaveTSGuideLogic {
+	return &SaveTSGuideLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *SaveTSGuideLogic) SaveTSGuide(req *types.SaveTsGuideReq) (resp *types.CommonResp, err error) {
+	// todo: add your logic here and delete this line
+	_, err = l.svcCtx.Suscribe.SaveTSGuide(l.ctx, &bxsubscribe.SaveTSGuideReq{
+		AppId:        req.AppId,
+		UserType:     req.UserType,
+		UserId:       req.UserId,
+		NewUserId:    req.NewUserId,
+		EntId:        req.EntId,
+		PositionId:   req.PositionId,
+		AccountId:    req.AccountId,
+		PositionType: req.PositionType,
+		Area:         req.Area,
+		District:     req.District,
+		Keywords:     req.Keywords,
+		AppSwitch:    req.AppSwitch,
+	})
+	if err != nil {
+		return &types.CommonResp{
+			Err_code: -1,
+			Err_msg:  err.Error(),
+			Data:     nil,
+		}, nil
+	}
+	return &types.CommonResp{
+		Err_code: 0,
+	}, nil
+}

+ 15 - 0
jyBXSubscribe/api/internal/types/types.go

@@ -47,6 +47,21 @@ type SomeInfoReq struct {
 	PositionId   string `header:"positionId,optional"`
 }
 
+type SaveTsGuideReq struct {
+	AppId        string   `header:"appId"`
+	UserType     string   `path:"userType"`
+	UserId       string   `header:"userId,optional"`
+	NewUserId    string   `header:"newUserId,optional"`
+	EntId        string   `header:"entId,optional"`
+	AccountId    string   `header:"accountId,optional"`
+	PositionType string   `header:"positionType,optional"`
+	PositionId   string   `header:"positionId,optional"`
+	Area         string   `json:"area"`                // 省份、城市  格式  {"福建" : ["福州市","厦门市",]}
+	District     string   `json:"district,optional"`   // 区县 格式  {"莆田市" : ["城厢区","荔城区","秀屿区","仙游县"]}
+	Keywords     []string `json:"keywords"`            // 关键词 ["关键词1 附加词","关键词2"]
+	AppSwitch    bool     `json:"app_switch,optional"` // app提醒总开关
+}
+
 type CommonResp struct {
 	Err_code int64       `json:"error_code"`
 	Err_msg  string      `json:"error_msg"`

+ 23 - 0
jyBXSubscribe/rpc/bxsubscribe.proto

@@ -127,8 +127,15 @@ message SomeInfo{
   bool isRead = 7;//某个通知??是否已读
   repeated string  industry = 8;//会员订阅的行业
   string userId = 9;//用户id
+  SubSetInfo subsetinfo = 10;// 订阅设置信息
 }
 //
+message SubSetInfo {
+    string  area =1;  // 地区
+    string    district = 2;  // 区县
+    repeated string key = 3; // 关键词
+    int64 areacount =4;  // 地区数量限制
+}
 message StatusResp{
   string error_msg = 1;
   int64 error_code = 2;
@@ -427,6 +434,20 @@ message BidRecListReq {
   string  entUserId = 5;
   int64  positionType = 6;
 }
+message SaveTSGuideReq {
+  string  appId = 1;
+  string  userId = 2;
+  string  userType = 3;
+  string  newUserId = 4;
+  string  entId = 5;
+  string  accountId = 6;
+  string  positionType = 7;
+  string  positionId = 8;
+  string  area = 9 ; // 省份、城市  格式  {"福建" : ["福州市","厦门市",]}
+  string  district = 10 ;// 区县 格式  {"莆田市" : ["城厢区","荔城区","秀屿区","仙游县"]}
+  repeated string keywords = 11 ; // 关键词 ["关键词1 附加词","关键词2"]
+  bool  appSwitch = 12 ; // app提醒总开关
+}
 
 
 service Bxsubscribe {
@@ -466,4 +487,6 @@ service Bxsubscribe {
   rpc bidDistributor(BidDistributorReq)returns(StatusResp);
   // 订阅推荐列表
   rpc bidRecList(BidRecListReq)returns(SubscribeInfosResp);
+  // 保存订阅向导设置
+  rpc SaveTSGuide(SaveTSGuideReq)returns(StatusResp);
 }

+ 10 - 0
jyBXSubscribe/rpc/bxsubscribe/bxsubscribe.go

@@ -34,6 +34,7 @@ type (
 	List                    = bxsubscribe.List
 	MsgDistributorReq       = bxsubscribe.MsgDistributorReq
 	PushSet                 = bxsubscribe.PushSet
+	SaveTSGuideReq          = bxsubscribe.SaveTSGuideReq
 	SetPushSetReq           = bxsubscribe.SetPushSetReq
 	SetReadReq              = bxsubscribe.SetReadReq
 	SetUserInfoReq          = bxsubscribe.SetUserInfoReq
@@ -46,6 +47,7 @@ type (
 	StaffSubscribeListResp  = bxsubscribe.StaffSubscribeListResp
 	StaffSubscribeReq       = bxsubscribe.StaffSubscribeReq
 	StatusResp              = bxsubscribe.StatusResp
+	SubSetInfo              = bxsubscribe.SubSetInfo
 	Subscribe               = bxsubscribe.Subscribe
 	SubscribeData           = bxsubscribe.SubscribeData
 	SubscribeInfo           = bxsubscribe.SubscribeInfo
@@ -97,6 +99,8 @@ type (
 		BidDistributor(ctx context.Context, in *BidDistributorReq, opts ...grpc.CallOption) (*StatusResp, error)
 		//  订阅推荐列表
 		BidRecList(ctx context.Context, in *BidRecListReq, opts ...grpc.CallOption) (*SubscribeInfosResp, error)
+		//  保存订阅向导设置
+		SaveTSGuide(ctx context.Context, in *SaveTSGuideReq, opts ...grpc.CallOption) (*StatusResp, error)
 	}
 
 	defaultBxsubscribe struct {
@@ -217,3 +221,9 @@ func (m *defaultBxsubscribe) BidRecList(ctx context.Context, in *BidRecListReq,
 	client := bxsubscribe.NewBxsubscribeClient(m.cli.Conn())
 	return client.BidRecList(ctx, in, opts...)
 }
+
+//  保存订阅向导设置
+func (m *defaultBxsubscribe) SaveTSGuide(ctx context.Context, in *SaveTSGuideReq, opts ...grpc.CallOption) (*StatusResp, error) {
+	client := bxsubscribe.NewBxsubscribeClient(m.cli.Conn())
+	return client.SaveTSGuide(ctx, in, opts...)
+}

+ 1 - 0
jyBXSubscribe/rpc/etc/bxsubscribe.yaml

@@ -22,4 +22,5 @@ AppUrl: "/front/downloadJyApp/qr?page=%&source=%s"
 Nsq: 192.168.3.240:4260
 NsqTopic: jy_event
 Registedate: 1705556502
+GuideRegistedate: 1735034400  #该时间之前注册的付费用户不用进订阅向导
 SubListTip: 为您预加载最近15天发布的%s商机

+ 1 - 0
jyBXSubscribe/rpc/internal/config/config.go

@@ -22,6 +22,7 @@ type Config struct {
 	Nsq                  string
 	NsqTopic             string
 	Registedate          int64
+	GuideRegistedate     int64 // 付费用户判断注册向导的时间
 	SubListTip           string
 }
 

+ 102 - 14
jyBXSubscribe/rpc/internal/logic/getsubsomeinfologic.go

@@ -3,9 +3,11 @@ package logic
 import (
 	"app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/redis"
-	"context"
 	IC "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/rpc/init"
+	"context"
+	"fmt"
 	"strconv"
+	"strings"
 	"time"
 
 	"bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/rpc/internal/svc"
@@ -29,10 +31,11 @@ func NewGetSubSomeInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge
 }
 
 const (
-	SubFreeFlag  = "fType"
-	SubVipFlag   = "vType"
-	MemberFlag   = "mType"
-	EntnicheFlag = "eType"
+	SubFreeFlag     = "fType"
+	SubVipFlag      = "vType"
+	MemberFlag      = "mType"
+	EntnicheFlag    = "eType"
+	tsGuideFinished = 1
 )
 
 // 获取订阅推送相关信息
@@ -48,6 +51,7 @@ func (l *GetSubSomeInfoLogic) GetSubSomeInfo(in *bxsubscribe.SomeInfoReq) (*bxsu
 			IsRead:      false,
 			Industry:    nil,
 			UserId:      "",
+			Subsetinfo:  &bxsubscribe.SubSetInfo{},
 		},
 	}
 	baseUserId, _ := strconv.ParseInt(in.NewUserId, 10, 64)
@@ -109,17 +113,101 @@ func (l *GetSubSomeInfoLogic) GetSubSomeInfo(in *bxsubscribe.SomeInfoReq) (*bxsu
 			}
 			resp.Data.IsPassCount = redis.GetInt("pushcache_2_a", "oncecount_"+todayNum+"_"+in.UserId) >= 150
 		}
-		//是否进入向导查询
-		resp.Data.IsInTSguide = func() bool {
-			//付费用户无免费订阅,不进入订阅向导页面
-			if user.Member.Status > 0 || user.Vip.Status > 0 {
-				return false
+		//  查询订阅信息中的关键词和向导查询
+		var field string
+		switch in.UserType {
+		case SubFreeFlag:
+			field = "o_jy"
+			resp.Data.Subsetinfo.Areacount = 1 // 地区数量
+		case SubVipFlag:
+			field = "o_vipjy"
+			resp.Data.Subsetinfo.Areacount = 1 //  后面查到再修改
+		case MemberFlag:
+			field = "o_member_jy"
+			resp.Data.Subsetinfo.Areacount = -1
+		case EntnicheFlag:
+			field = "o_entniche"
+			resp.Data.Subsetinfo.Areacount = -1
+		}
+		data := IC.Compatible.Select(in.UserId, fmt.Sprintf(`{"%s":1,"i_ts_guide":1,"l_registedate":1}`, field))
+		if data != nil && len(*data) > 0 {
+			subinfo, b := (*data)[field].(map[string]interface{})
+			if b && subinfo != nil {
+				if area, ok := subinfo["o_area"].(map[string]interface{}); ok {
+					resp.Data.Subsetinfo.Area = common.MapToJson(area)
+				}
+				if district, ok := subinfo["o_district"].(map[string]interface{}); ok {
+					resp.Data.Subsetinfo.District = common.MapToJson(district)
+				}
+				switch in.UserType {
+				case SubFreeFlag:
+					resp.Data.Subsetinfo.Key = freegetsubKey(subinfo)
+				case SubVipFlag:
+					o_buyset := common.ObjToMap(subinfo["o_buyset"])
+					if o_buyset != nil {
+						resp.Data.Subsetinfo.Areacount = common.Int64All((*o_buyset)["areacount"])
+					}
+					resp.Data.Subsetinfo.Key = paygetsubKey(subinfo)
+				case MemberFlag:
+					if common.Int64All(subinfo["i_areacount"]) > 0 {
+						resp.Data.Subsetinfo.Areacount = common.Int64All(subinfo["i_areacount"]) // 单省版大会员
+					}
+					resp.Data.Subsetinfo.Key = paygetsubKey(subinfo)
+				case EntnicheFlag:
+					resp.Data.Subsetinfo.Key = paygetsubKey(subinfo)
+				}
 			}
-			if !user.Vip.HasKey {
-				return true
+			registedate := common.Int64All((*data)["l_registedate"])
+			if in.UserType == SubFreeFlag || registedate > IC.C.GuideRegistedate {
+				if common.Int64All((*data)["i_ts_guide"]) != tsGuideFinished { // 判断字段未完成
+					resp.Data.IsInTSguide = true
+				}
 			}
-			return false
-		}()
+		}
 	}
 	return resp, nil
 }
+
+// 处理订阅词
+func freegetsubKey(subinfo map[string]interface{}) (arr []string) {
+	a_key, b := subinfo["a_key"].([]interface{})
+	if !b {
+		return
+	}
+	for i := 0; i < len(a_key); i++ {
+		a_keyi := common.ObjToMap(a_key[i])
+		if a_keyi != nil {
+			a_keyiarr := (*a_keyi)["key"].([]interface{})
+			arr = append(arr, common.ObjToString(a_keyiarr[0]))
+		}
+	}
+	return arr
+}
+func paygetsubKey(subinfo map[string]interface{}) (arr []string) {
+
+	a_items, b := subinfo["a_items"].([]interface{})
+	if !b || len(a_items) == 0 {
+		return
+	}
+	a_items0, b1 := a_items[0].(map[string]interface{})
+	if !b1 {
+		return
+	}
+	a_key, b3 := a_items0["a_key"].([]interface{})
+	if a_key == nil || !b3 {
+		return
+	}
+	for i := 0; i < len(a_key); i++ {
+		a_keyi := common.ObjToMap(a_key[i])
+		if a_keyi != nil {
+			if a_keyiarr, ok := (*a_keyi)["key"].([]interface{}); ok {
+				s := strings.Join(common.ObjArrToStringArr(a_keyiarr), " ")
+				if a_appendkeyiarr, ok := (*a_keyi)["appendkey"].([]interface{}); ok {
+					s += " " + strings.Join(common.ObjArrToStringArr(a_appendkeyiarr), " ")
+				}
+				arr = append(arr, s)
+			}
+		}
+	}
+	return
+}

+ 203 - 0
jyBXSubscribe/rpc/internal/logic/savetsguidelogic.go

@@ -0,0 +1,203 @@
+package logic
+
+import (
+	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/date"
+	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
+	IC "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/rpc/init"
+	"bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/rpc/internal/svc"
+	"bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/rpc/type/bxsubscribe"
+	"context"
+	"encoding/json"
+	"errors"
+	"fmt"
+	"regexp"
+	"strconv"
+	"strings"
+	"time"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type SaveTSGuideLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewSaveTSGuideLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SaveTSGuideLogic {
+	return &SaveTSGuideLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+// 保存订阅向导设置
+func (l *SaveTSGuideLogic) SaveTSGuide(in *bxsubscribe.SaveTSGuideReq) (*bxsubscribe.StatusResp, error) {
+
+	// 校验用户身份
+	baseUserId, _ := strconv.ParseInt(in.NewUserId, 10, 64)
+	accountId, _ := strconv.ParseInt(in.AccountId, 10, 64)
+	positionType, _ := strconv.ParseInt(in.PositionType, 10, 64)
+	positionId, _ := strconv.ParseInt(in.PositionId, 10, 64)
+	entId, _ := strconv.ParseInt(in.EntId, 10, 64)
+	// 校验是否已经完成过订阅向导
+	//  查询订阅信息中的关键词和向导查询
+	data := IC.Compatible.Select(in.UserId, `{"i_ts_guide":1,"l_registedate":1,"o_member_jy":1}`)
+	if data != nil && len(*data) > 0 {
+		registedate := common.Int64All((*data)["l_registedate"])
+		if (in.UserType != SubFreeFlag && registedate < IC.C.GuideRegistedate) || common.Int64All((*data)["i_ts_guide"]) == tsGuideFinished {
+			// 已经设置过
+			return nil, errors.New("重复设置向导")
+		}
+	}
+	user := IC.Compatible.Middleground.PowerCheckCenter.Check(in.AppId, in.UserId, baseUserId, accountId, entId, positionType, positionId)
+	if user == nil {
+		return nil, errors.New("身份异常")
+	}
+	var field string
+	countLimit := 0
+	areaCountLimit := 0
+	switch in.UserType {
+	case SubFreeFlag:
+		if !user.Free.IsFree {
+			return nil, errors.New("身份异常")
+		}
+		countLimit = 10
+		field = "o_jy.%s"
+		areaCountLimit = 1 // 免费用户
+	case SubVipFlag:
+		if user.Vip.Status <= 0 {
+			return nil, errors.New("身份异常")
+		}
+		field = "o_vipjy.%s"
+		areaCountLimit = int(user.Vip.Areacount)
+		countLimit = 300
+	case MemberFlag:
+		if user.Member.Status <= 0 {
+			return nil, errors.New("身份异常")
+		}
+		field = "o_member_jy.%s"
+		countLimit = 300
+		areaCountLimit = -1
+		//  判断单省版
+		o_member_jy, o_member_jyb := (*data)["o_member_jy"].(map[string]interface{})
+		if o_member_jy != nil && o_member_jyb {
+			if common.IntAll(o_member_jy["i_areacount"]) > 0 {
+				areaCountLimit = common.IntAll(o_member_jy["i_areacount"])
+			}
+		}
+	case EntnicheFlag:
+		if user.Entniche.Status <= 0 {
+			return nil, errors.New("身份异常")
+		}
+		field = "o_entniche.%s"
+		countLimit = 300
+		areaCountLimit = -1
+
+	}
+	updateMap := map[string]interface{}{}
+	area := map[string]interface{}{}
+	err := json.Unmarshal([]byte(in.Area), &area)
+	//  验证地区数量   //会有没有走过订阅向导买过省份订阅包的情况吗? 暂时不考虑
+	if err != nil {
+		logx.Error("反序列化失败", in.Area, err)
+		return nil, errors.New("地区有误")
+	} else {
+		updateMap[fmt.Sprintf(field, "o_area")] = area
+	}
+	if areaCountLimit > 0 && len(area) > areaCountLimit {
+		return nil, errors.New("地区数量有误")
+	}
+	// 处理地区
+	if in.District != "" {
+		district := map[string]interface{}{}
+		err = json.Unmarshal([]byte(in.District), &district)
+		if err != nil {
+			logx.Error("反序列化失败", in.District, err)
+			return nil, errors.New("地区有误")
+		} else {
+			updateMap[fmt.Sprintf(field, "o_district")] = district
+		}
+	}
+
+	// 处理关键词
+	// 免费 处理掉空格
+	arryMap := []interface{}{}
+	key := []string{}
+	if in.UserType == SubFreeFlag {
+		for i := 0; i < len(in.Keywords); i++ {
+			tmp := processKeyword(in.Keywords[i])
+			if len(tmp) > 0 {
+				arryMap = append(arryMap, map[string]interface{}{"matchway": 1, "key": tmp[0:1], "notkey": nil, "updatetime": time.Now().Unix()})
+			}
+			if len(key) >= countLimit {
+				break
+			}
+		}
+		updateMap[fmt.Sprintf(field, "a_key")] = arryMap
+	} else {
+		// 付费 按一组词
+		for i := 0; i < len(in.Keywords); i++ {
+			tmp := processKeyword(in.Keywords[i])
+			if len(tmp) > 0 {
+				arryMap = append(arryMap, map[string]interface{}{"matchway": 0, "key": tmp, "notkey": nil, "updatetime": time.Now().Unix()})
+			}
+			if len(key) >= countLimit {
+				break
+			}
+		}
+		item := map[string]interface{}{
+			"a_key":      arryMap,
+			"s_item":     "未分类",
+			"updatetime": date.NowFormat(date.Date_Full_Layout),
+		}
+		updateMap[fmt.Sprintf(field, "a_items")] = []map[string]interface{}{item}
+	}
+
+	updateMap[fmt.Sprintf(field, "l_modifydate")] = time.Now().Unix()
+	updateMap["i_ts_guide"] = tsGuideFinished
+	//  判断app提醒总开关是否打开  如果打开 我的订阅APP提醒初始值为“开启”状态。
+	if in.AppSwitch {
+		updateMap["o_pushset.o_subset.i_apppush"] = 1
+	}
+	go SetLog(in.UserId, strings.ReplaceAll(field, ".%s", ""))
+	if !IC.Compatible.Update(in.UserId, map[string]interface{}{
+		"$set": updateMap,
+	}) {
+		logx.Error("设置订阅向导更新失败", in.UserId, updateMap)
+		return nil, errors.New("设置订阅向导更新失败")
+	}
+	go jy.Publish(IC.MgoLog, IC.C.Nsq, IC.C.NsqTopic, "task", in.UserId, jy.Jyweb_node2, map[string]interface{}{
+		"code":       1015, //首次订阅
+		"types":      "subscribeKeyWords",
+		"num":        50,
+		"baseUserId": baseUserId,
+		"positionId": positionId,
+	})
+	return &bxsubscribe.StatusResp{}, nil
+}
+
+// SetLog 订阅设置记录
+func SetLog(userid, types string) {
+	if data := IC.Compatible.Select(userid, `{"o_vipjy":1,"o_member_jy":1,"o_jy":1}`); len(*data) > 0 && data != nil {
+		(*data)["userid"] = userid
+		(*data)["type"] = types
+		(*data)["createtime"] = time.Now().Unix()
+		IC.MgoLog.Save("ovipjy_log", data)
+	}
+}
+
+// 保存入库之前,处理订阅的关键词
+func processKeyword(keyword string) []string {
+	keywordReg := regexp.MustCompile("([\\s\u3000\u2003\u00a0+,,])+")
+	spaceReg := regexp.MustCompile("\\s+")
+	keyword = keywordReg.ReplaceAllString(keyword, " ")
+	keyword = spaceReg.ReplaceAllString(keyword, " ")
+	keyword = strings.Trim(keyword, " ")
+	if keyword == "" {
+		return nil
+	}
+	return strings.Split(keyword, " ")
+}

+ 6 - 0
jyBXSubscribe/rpc/internal/server/bxsubscribeserver.go

@@ -129,3 +129,9 @@ func (s *BxsubscribeServer) BidRecList(ctx context.Context, in *bxsubscribe.BidR
 	l := logic.NewBidRecListLogic(ctx, s.svcCtx)
 	return l.BidRecList(in)
 }
+
+//  保存订阅向导设置
+func (s *BxsubscribeServer) SaveTSGuide(ctx context.Context, in *bxsubscribe.SaveTSGuideReq) (*bxsubscribe.StatusResp, error) {
+	l := logic.NewSaveTSGuideLogic(ctx, s.svcCtx)
+	return l.SaveTSGuide(in)
+}

Fișier diff suprimat deoarece este prea mare
+ 187 - 108
jyBXSubscribe/rpc/type/bxsubscribe/bxsubscribe.pb.go


+ 39 - 1
jyBXSubscribe/rpc/type/bxsubscribe/bxsubscribe_grpc.pb.go

@@ -1,7 +1,7 @@
 // Code generated by protoc-gen-go-grpc. DO NOT EDIT.
 // versions:
 // - protoc-gen-go-grpc v1.2.0
-// - protoc             v3.15.5
+// - protoc             v3.19.4
 // source: bxsubscribe.proto
 
 package bxsubscribe
@@ -58,6 +58,8 @@ type BxsubscribeClient interface {
 	BidDistributor(ctx context.Context, in *BidDistributorReq, opts ...grpc.CallOption) (*StatusResp, error)
 	// 订阅推荐列表
 	BidRecList(ctx context.Context, in *BidRecListReq, opts ...grpc.CallOption) (*SubscribeInfosResp, error)
+	// 保存订阅向导设置
+	SaveTSGuide(ctx context.Context, in *SaveTSGuideReq, opts ...grpc.CallOption) (*StatusResp, error)
 }
 
 type bxsubscribeClient struct {
@@ -230,6 +232,15 @@ func (c *bxsubscribeClient) BidRecList(ctx context.Context, in *BidRecListReq, o
 	return out, nil
 }
 
+func (c *bxsubscribeClient) SaveTSGuide(ctx context.Context, in *SaveTSGuideReq, opts ...grpc.CallOption) (*StatusResp, error) {
+	out := new(StatusResp)
+	err := c.cc.Invoke(ctx, "/bxsubscribe.Bxsubscribe/SaveTSGuide", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
 // BxsubscribeServer is the server API for Bxsubscribe service.
 // All implementations must embed UnimplementedBxsubscribeServer
 // for forward compatibility
@@ -270,6 +281,8 @@ type BxsubscribeServer interface {
 	BidDistributor(context.Context, *BidDistributorReq) (*StatusResp, error)
 	// 订阅推荐列表
 	BidRecList(context.Context, *BidRecListReq) (*SubscribeInfosResp, error)
+	// 保存订阅向导设置
+	SaveTSGuide(context.Context, *SaveTSGuideReq) (*StatusResp, error)
 	mustEmbedUnimplementedBxsubscribeServer()
 }
 
@@ -331,6 +344,9 @@ func (UnimplementedBxsubscribeServer) BidDistributor(context.Context, *BidDistri
 func (UnimplementedBxsubscribeServer) BidRecList(context.Context, *BidRecListReq) (*SubscribeInfosResp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method BidRecList not implemented")
 }
+func (UnimplementedBxsubscribeServer) SaveTSGuide(context.Context, *SaveTSGuideReq) (*StatusResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method SaveTSGuide not implemented")
+}
 func (UnimplementedBxsubscribeServer) mustEmbedUnimplementedBxsubscribeServer() {}
 
 // UnsafeBxsubscribeServer may be embedded to opt out of forward compatibility for this service.
@@ -668,6 +684,24 @@ func _Bxsubscribe_BidRecList_Handler(srv interface{}, ctx context.Context, dec f
 	return interceptor(ctx, in, info, handler)
 }
 
+func _Bxsubscribe_SaveTSGuide_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(SaveTSGuideReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(BxsubscribeServer).SaveTSGuide(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/bxsubscribe.Bxsubscribe/SaveTSGuide",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(BxsubscribeServer).SaveTSGuide(ctx, req.(*SaveTSGuideReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 // Bxsubscribe_ServiceDesc is the grpc.ServiceDesc for Bxsubscribe service.
 // It's only intended for direct use with grpc.RegisterService,
 // and not to be introspected or modified (even as a copy)
@@ -747,6 +781,10 @@ var Bxsubscribe_ServiceDesc = grpc.ServiceDesc{
 			MethodName: "bidRecList",
 			Handler:    _Bxsubscribe_BidRecList_Handler,
 		},
+		{
+			MethodName: "SaveTSGuide",
+			Handler:    _Bxsubscribe_SaveTSGuide_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "bxsubscribe.proto",

+ 41 - 0
jyBXSubscribe/test/618.http

@@ -0,0 +1,41 @@
+POST https://jybx3-webtest.jydev.jianyu360.com/jyapi/jybx/subscribe/fType/someInfo
+Content-Type: application/json
+Cookie: SESSIONID=5696788f98bb1cc7e24b9d2e6c4ba58c0ee38ddd
+
+###
+POST https://jybx3-webtest.jydev.jianyu360.com/jyapi/jybx/subscribe/mType/someInfo
+Content-Type: application/json
+Cookie: SESSIONID=5696788f98bb1cc7e24b9d2e6c4ba58c0ee38ddd
+
+###
+POST https://jybx3-webtest.jydev.jianyu360.com/jyapi/jybx/subscribe/vType/someInfo
+Content-Type: application/json
+Cookie: SESSIONID=5696788f98bb1cc7e24b9d2e6c4ba58c0ee38ddd
+
+###
+POST https://jybx3-webtest.jydev.jianyu360.com/jyapi/jybx/subscribe/eType/someInfo
+Content-Type: application/json
+Cookie: SESSIONID=5696788f98bb1cc7e24b9d2e6c4ba58c0ee38ddd
+
+###
+POST https://jybx3-webtest.jydev.jianyu360.com/jyapi/jybx/subscribe/fType/saveTSGuide
+Content-Type: application/json
+Cookie: SESSIONID=5696788f98bb1cc7e24b9d2e6c4ba58c0ee38ddd
+
+{
+  "area": "{\"福建\" : [\"福州市\",\"厦门市\"]}",
+  "keywords": ["设备"]
+}
+
+
+###
+POST https://jybx3-webtest.jydev.jianyu360.com/jyapi/jybx/subscribe/mType/saveTSGuide
+Content-Type: application/json
+Cookie: SESSIONID=5696788f98bb1cc7e24b9d2e6c4ba58c0ee38ddd
+
+{
+  "area": "{\"福建\" : [\"福州市\",\"厦门市\"],\"河南\" : []}",
+  "keywords": ["设备"]
+}
+
+

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff