Ver código fonte

feat:标讯搜索权益调整

wangshan 2 anos atrás
pai
commit
0b6a520af9

+ 5 - 1
jyBXCore/api/bxcore.api

@@ -36,7 +36,11 @@ type (
 		KeyWords        string `json:"keyWords,optional"`
 		AdditionalWords string `json:"additionalWords,optional"`
 		ExclusionWords  string `json:"exclusionWords,optional"`
-		BidField        string `json:"bidField,optional"` //医疗领域化信息
+		BidField        string `json:"bidField,optional"`       //医疗领域化信息
+		AccountId       string `header:"accountId,optional"`    //账户id
+		PositionType    string `header:"positionType,optional"` //职位类型 0个人 1企业
+		PositionId      string `header:"positionId,optional"`   //职位id
+		MgoUserId       string `header:"mgoUserId,optional"`    //原userId
 	}
 	//
 	commonResp {

+ 4 - 0
jyBXCore/api/internal/logic/searchListLogic.go

@@ -60,6 +60,10 @@ func (l *SearchListLogic) SearchList(req *types.SearchReq) (resp *types.CommonRe
 		UserType:        req.UserType,
 		Platform:        util.CheckPlatform(l.r),
 		BidField:        req.BidField,
+		PositionType:    req.PositionType,
+		PositionId:      req.PositionId,
+		AccountId:       req.AccountId,
+		MgoUserId:       req.MgoUserId,
 	})
 	log.Println("请求接口耗时:", time.Since(t).Seconds())
 	if err != nil {

+ 5 - 1
jyBXCore/api/internal/types/types.go

@@ -29,7 +29,11 @@ type SearchReq struct {
 	KeyWords        string `json:"keyWords,optional"`
 	AdditionalWords string `json:"additionalWords,optional"`
 	ExclusionWords  string `json:"exclusionWords,optional"`
-	BidField        string `json:"bidField,optional"` //医疗领域化信息
+	BidField        string `json:"bidField,optional"`       //医疗领域化信息
+	AccountId       string `header:"accountId,optional"`    //账户id
+	PositionType    string `header:"positionType,optional"` //职位类型 0个人 1企业
+	PositionId      string `header:"positionId,optional"`   //职位id
+	MgoUserId       string `header:"mgoUserId,optional"`    //原userId
 }
 
 type CommonResp struct {

+ 81 - 0
jyBXCore/entity/rpc.go

@@ -0,0 +1,81 @@
+package entity
+
+import (
+	"bp.jydev.jianyu360.cn/BaseService/powerCheckCenter/rpc/powercheck"
+	"context"
+	"strings"
+)
+
+var (
+	PowerCheck powercheck.PowerCheck
+)
+
+type UserInfoRpc struct {
+	AppId        string //appId 剑鱼 10000
+	UserId       string //用户id
+	BaseUserId   int64  //用户基本id
+	EntId        int64  //企业id
+	EntUserId    int64  //企业用户id
+	AccountId    int64  //账户id
+	PositionType int64  //职位类型 @个人 1企业
+	PositionId   int64  //职位id
+	MgoUserId    string //原userId
+}
+
+// GetUserPowers  获取用户权益信息
+func (ui *UserInfoRpc) GetUserPowers() *powercheck.CheckResp {
+	req := &powercheck.CheckReq{
+		Appid:        ui.AppId,
+		Userid:       ui.MgoUserId,
+		BaseUserId:   ui.BaseUserId,
+		AccountId:    ui.AccountId,
+		EntId:        ui.EntId,
+		PositionType: ui.PositionType,
+		PositionId:   ui.PositionId,
+	}
+	checkResp, err := PowerCheck.Check(context.Background(), req)
+	if err == nil {
+		return checkResp
+	}
+	return nil
+}
+
+// GetQueryItems 免费 标题(title)  正文(content) 老用户【中标企业(winner)】
+// 付费用户 全部(all)、标题(title)  正文(content)  会员: 采购单位(buyer) 中标企业(winner) 招标代理机构(agency) 附件(file)
+// 项目名称projectname和标的物purchasing(ppa)
+func (ui *UserInfoRpc) GetQueryItems(selectType string, limitOldTime, registerData int64, isPay bool) (items []string) {
+	if isPay {
+		for _, t := range strings.Split(selectType, ",") {
+			if t == "content" {
+				items = append(items, "detail")
+			} else if t == "buyer" {
+				items = append(items, "mbuyer")
+			} else if t == "winner" {
+				items = append(items, "mwinner")
+			} else if t == "agency" {
+				items = append(items, "magency")
+			} else if t == "title" {
+				items = append(items, "title")
+			} else if t == "ppa" {
+				items = append(items, []string{"purchasing", "projectname.pname"}...)
+			} else if t == "file" { //dev4.7.8 标讯优化:搜索范围附件-》全部用户可用
+				items = append(items, "filetext")
+			}
+		}
+		return
+	}
+	//老用户 使用付费功能
+	isOldUser := registerData != 0 && registerData < limitOldTime
+	for _, t := range strings.Split(selectType, ",") {
+		if t == "winner" && isOldUser {
+			items = append(items, "mwinner")
+		} else if t == "title" {
+			items = append(items, "title")
+		} else if t == "content" {
+			items = append(items, "detail")
+		} else if t == "file" { //dev4.7.8 标讯优化:搜索范围附件-》全部用户可用
+			items = append(items, "filetext")
+		}
+	}
+	return
+}

+ 98 - 4
jyBXCore/go.mod

@@ -1,12 +1,106 @@
 module jyBXCore
 
-go 1.16
+go 1.18
 
 require (
+	bp.jydev.jianyu360.cn/BaseService/powerCheckCenter v0.0.0-20230210052334-7b32c3b8c773
 	app.yhyue.com/moapp/jybase v0.0.0-20230117032034-ad7c00ffe11a
 	bp.jydev.jianyu360.cn/BaseService/gateway v1.3.4
-	github.com/go-sql-driver/mysql v1.6.0
-	github.com/zeromicro/go-zero v1.4.0
-	google.golang.org/grpc v1.49.0
+	github.com/go-sql-driver/mysql v1.7.0
+	github.com/zeromicro/go-zero v1.4.4
+	google.golang.org/grpc v1.53.0
 	google.golang.org/protobuf v1.28.1
 )
+
+require (
+	app.yhyue.com/moapp/esv1 v0.0.0-20220414031211-3da4123e648d // indirect
+	github.com/beorn7/perks v1.0.1 // indirect
+	github.com/cenkalti/backoff/v4 v4.1.3 // indirect
+	github.com/cespare/xxhash/v2 v2.2.0 // indirect
+	github.com/coreos/go-semver v0.3.0 // indirect
+	github.com/coreos/go-systemd/v22 v22.3.2 // indirect
+	github.com/davecgh/go-spew v1.1.1 // indirect
+	github.com/dchest/captcha v0.0.0-20200903113550-03f5f0333e1f // indirect
+	github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
+	github.com/fatih/color v1.13.0 // indirect
+	github.com/felixge/fgprof v0.9.3 // indirect
+	github.com/garyburd/redigo v1.6.2 // indirect
+	github.com/go-logr/logr v1.2.3 // indirect
+	github.com/go-logr/stdr v1.2.2 // indirect
+	github.com/go-redis/redis/v8 v8.11.5 // indirect
+	github.com/gogo/protobuf v1.3.2 // indirect
+	github.com/golang-jwt/jwt/v4 v4.4.3 // indirect
+	github.com/golang/mock v1.6.0 // indirect
+	github.com/golang/protobuf v1.5.2 // indirect
+	github.com/golang/snappy v0.0.4 // indirect
+	github.com/gomodule/redigo v1.8.9 // indirect
+	github.com/google/go-cmp v0.5.9 // indirect
+	github.com/google/gofuzz v1.2.0 // indirect
+	github.com/google/pprof v0.0.0-20211214055906-6f57359322fd // indirect
+	github.com/google/uuid v1.3.0 // indirect
+	github.com/googleapis/gnostic v0.5.5 // indirect
+	github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect
+	github.com/jinzhu/inflection v1.0.0 // indirect
+	github.com/jinzhu/now v1.1.1 // indirect
+	github.com/json-iterator/go v1.1.12 // indirect
+	github.com/klauspost/compress v1.13.6 // indirect
+	github.com/mattn/go-colorable v0.1.9 // indirect
+	github.com/mattn/go-isatty v0.0.14 // indirect
+	github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
+	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
+	github.com/modern-go/reflect2 v1.0.2 // indirect
+	github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
+	github.com/olivere/elastic v6.2.37+incompatible // indirect
+	github.com/openzipkin/zipkin-go v0.4.0 // indirect
+	github.com/pelletier/go-toml/v2 v2.0.6 // indirect
+	github.com/pkg/errors v0.9.1 // indirect
+	github.com/prometheus/client_golang v1.13.0 // indirect
+	github.com/prometheus/client_model v0.2.0 // indirect
+	github.com/prometheus/common v0.37.0 // indirect
+	github.com/prometheus/procfs v0.8.0 // indirect
+	github.com/spaolacci/murmur3 v1.1.0 // indirect
+	github.com/xdg-go/pbkdf2 v1.0.0 // indirect
+	github.com/xdg-go/scram v1.1.1 // indirect
+	github.com/xdg-go/stringprep v1.0.3 // indirect
+	github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
+	go.etcd.io/etcd/api/v3 v3.5.5 // indirect
+	go.etcd.io/etcd/client/pkg/v3 v3.5.5 // indirect
+	go.etcd.io/etcd/client/v3 v3.5.5 // indirect
+	go.mongodb.org/mongo-driver v1.11.1 // indirect
+	go.opentelemetry.io/otel v1.10.0 // indirect
+	go.opentelemetry.io/otel/exporters/jaeger v1.10.0 // indirect
+	go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.10.0 // indirect
+	go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.10.0 // indirect
+	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.10.0 // indirect
+	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.10.0 // indirect
+	go.opentelemetry.io/otel/exporters/zipkin v1.10.0 // indirect
+	go.opentelemetry.io/otel/sdk v1.10.0 // indirect
+	go.opentelemetry.io/otel/trace v1.10.0 // indirect
+	go.opentelemetry.io/proto/otlp v0.19.0 // indirect
+	go.uber.org/atomic v1.9.0 // indirect
+	go.uber.org/automaxprocs v1.5.1 // indirect
+	go.uber.org/multierr v1.8.0 // indirect
+	go.uber.org/zap v1.21.0 // indirect
+	golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
+	golang.org/x/net v0.5.0 // indirect
+	golang.org/x/oauth2 v0.4.0 // indirect
+	golang.org/x/sync v0.1.0 // indirect
+	golang.org/x/sys v0.4.0 // indirect
+	golang.org/x/term v0.4.0 // indirect
+	golang.org/x/text v0.6.0 // indirect
+	golang.org/x/time v0.3.0 // indirect
+	google.golang.org/appengine v1.6.7 // indirect
+	google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
+	gopkg.in/inf.v0 v0.9.1 // indirect
+	gopkg.in/yaml.v2 v2.4.0 // indirect
+	gopkg.in/yaml.v3 v3.0.1 // indirect
+	gorm.io/driver/mysql v1.0.5 // indirect
+	gorm.io/gorm v1.21.3 // indirect
+	k8s.io/api v0.22.9 // indirect
+	k8s.io/apimachinery v0.22.9 // indirect
+	k8s.io/client-go v0.22.9 // indirect
+	k8s.io/klog/v2 v2.80.1 // indirect
+	k8s.io/utils v0.0.0-20221108210102-8e77b1f39fe2 // indirect
+	sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
+	sigs.k8s.io/yaml v1.2.0 // indirect
+)

+ 4 - 0
jyBXCore/rpc/bxcore.proto

@@ -36,6 +36,10 @@ message SearchReq {
   string interceptKeyWords = 30;//关键词截取后的关键词;
   string interceptOtherWords = 31;//关键词截取后 后面三个字
   string bidField = 32;//领域化标识
+  string accountId = 33; //账户id
+  string positionType =34; //职位类型 0个人 1企业
+  string positionId = 35;  //职位id
+  string mgoUserId = 36;  //原userId
 }
 
 message SearchResp {

+ 5 - 0
jyBXCore/rpc/etc/bxcore.yaml

@@ -41,3 +41,8 @@ DefaultTopTypes:
   - 拟建,采购意向
 JYKeyMark: " "
 ContextOldVipLimit: 1664553600
+PowersEtcdConf:
+  Etcd:
+    Hosts:
+      - 192.168.3.206:2379
+    Key: powercheck.rpc

+ 12 - 3
jyBXCore/rpc/init/init.go

@@ -1,11 +1,14 @@
 package init
 
 import (
+	"bp.jydev.jianyu360.cn/BaseService/powerCheckCenter/rpc/powercheck"
 	"flag"
 	"fmt"
 	_ "github.com/go-sql-driver/mysql"
 	"github.com/zeromicro/go-zero/core/conf"
+	"github.com/zeromicro/go-zero/core/discov"
 	"github.com/zeromicro/go-zero/core/logx"
+	"github.com/zeromicro/go-zero/zrpc"
 	"jyBXCore/entity"
 	"jyBXCore/rpc/internal/config"
 )
@@ -14,15 +17,13 @@ var configFile = flag.String("cf", "etc/bxcore.yaml", "the config file")
 var C config.Config
 var err error
 
-//
 var dbFile = flag.String("df", "etc/db.yaml", "the db file")
 var DB config.Db
 
-//
 var logFile = flag.String("lf", "etc/logs.yaml", "the logs file")
 var logc entity.Logc
 
-//全文或附件搜索限制
+// 全文或附件搜索限制
 var SearchLimitKey = "jy_limitSearchText_new"
 var SearchLimitFlag = "jy_limitSearchText_%s"
 
@@ -56,4 +57,12 @@ func init() {
 	LabelInit()
 	//
 	SearchLimitKey = fmt.Sprintf(C.LimitSearchText.LimitKey, "jy_limitSearchText")
+	//初始化权益中台相关
+	powersClient := zrpc.MustNewClient(zrpc.RpcClientConf{
+		Etcd: discov.EtcdConf{
+			Hosts: C.PowersEtcdConf.Etcd.Hosts,
+			Key:   C.PowersEtcdConf.Etcd.Key,
+		},
+	})
+	entity.PowerCheck = powercheck.NewPowerCheck(powersClient)
 }

+ 4 - 3
jyBXCore/rpc/internal/config/config.go

@@ -40,9 +40,10 @@ type Config struct {
 		Count    int
 		PayCount int
 	} //招标信息初始化
-	DefaultTopTypes    []string //信息类型初始值
-	JYKeyMark          string   //关键词分组标识
-	ContextOldVipLimit int64    //老版超级订阅 超前项目权限
+	DefaultTopTypes    []string           //信息类型初始值
+	JYKeyMark          string             //关键词分组标识
+	ContextOldVipLimit int64              //老版超级订阅 超前项目权限
+	PowersEtcdConf     zrpc.RpcClientConf //权益中台
 }
 
 type Db struct {

+ 42 - 2
jyBXCore/rpc/type/bxcore/bxcore.pb.go

@@ -57,6 +57,10 @@ type SearchReq struct {
 	InterceptKeyWords   string `protobuf:"bytes,30,opt,name=interceptKeyWords,proto3" json:"interceptKeyWords,omitempty"`     //关键词截取后的关键词;
 	InterceptOtherWords string `protobuf:"bytes,31,opt,name=interceptOtherWords,proto3" json:"interceptOtherWords,omitempty"` //关键词截取后 后面三个字
 	BidField            string `protobuf:"bytes,32,opt,name=bidField,proto3" json:"bidField,omitempty"`                       //领域化标识
+	AccountId           string `protobuf:"bytes,33,opt,name=accountId,proto3" json:"accountId,omitempty"`                     //账户id
+	PositionType        string `protobuf:"bytes,34,opt,name=positionType,proto3" json:"positionType,omitempty"`               //职位类型 0个人 1企业
+	PositionId          string `protobuf:"bytes,35,opt,name=positionId,proto3" json:"positionId,omitempty"`                   //职位id
+	MgoUserId           string `protobuf:"bytes,36,opt,name=mgoUserId,proto3" json:"mgoUserId,omitempty"`                     //原userId
 }
 
 func (x *SearchReq) Reset() {
@@ -315,6 +319,34 @@ func (x *SearchReq) GetBidField() string {
 	return ""
 }
 
+func (x *SearchReq) GetAccountId() string {
+	if x != nil {
+		return x.AccountId
+	}
+	return ""
+}
+
+func (x *SearchReq) GetPositionType() string {
+	if x != nil {
+		return x.PositionType
+	}
+	return ""
+}
+
+func (x *SearchReq) GetPositionId() string {
+	if x != nil {
+		return x.PositionId
+	}
+	return ""
+}
+
+func (x *SearchReq) GetMgoUserId() string {
+	if x != nil {
+		return x.MgoUserId
+	}
+	return ""
+}
+
 type SearchResp struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache
@@ -1124,7 +1156,7 @@ var File_bxcore_proto protoreflect.FileDescriptor
 
 var file_bxcore_proto_rawDesc = []byte{
 	0x0a, 0x0c, 0x62, 0x78, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06,
-	0x62, 0x78, 0x63, 0x6f, 0x72, 0x65, 0x22, 0xc1, 0x07, 0x0a, 0x09, 0x53, 0x65, 0x61, 0x72, 0x63,
+	0x62, 0x78, 0x63, 0x6f, 0x72, 0x65, 0x22, 0xc1, 0x08, 0x0a, 0x09, 0x53, 0x65, 0x61, 0x72, 0x63,
 	0x68, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x18, 0x01, 0x20,
 	0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73,
 	0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72,
@@ -1184,7 +1216,15 @@ var file_bxcore_proto_rawDesc = []byte{
 	0x72, 0x64, 0x73, 0x18, 0x1f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x13, 0x69, 0x6e, 0x74, 0x65, 0x72,
 	0x63, 0x65, 0x70, 0x74, 0x4f, 0x74, 0x68, 0x65, 0x72, 0x57, 0x6f, 0x72, 0x64, 0x73, 0x12, 0x1a,
 	0x0a, 0x08, 0x62, 0x69, 0x64, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x20, 0x20, 0x01, 0x28, 0x09,
-	0x52, 0x08, 0x62, 0x69, 0x64, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x22, 0x68, 0x0a, 0x0a, 0x53, 0x65,
+	0x52, 0x08, 0x62, 0x69, 0x64, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x63,
+	0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x21, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61,
+	0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x22, 0x0a, 0x0c, 0x70, 0x6f, 0x73, 0x69,
+	0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x22, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c,
+	0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x0a,
+	0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x23, 0x20, 0x01, 0x28, 0x09,
+	0x52, 0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09,
+	0x6d, 0x67, 0x6f, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x24, 0x20, 0x01, 0x28, 0x09, 0x52,
+	0x09, 0x6d, 0x67, 0x6f, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x68, 0x0a, 0x0a, 0x53, 0x65,
 	0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x12, 0x19, 0x0a, 0x08, 0x65, 0x72, 0x72, 0x5f,
 	0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x65, 0x72, 0x72, 0x43,
 	0x6f, 0x64, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x65, 0x72, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02,

+ 5 - 5
jyBXCore/rpc/util/userInfo.go

@@ -8,7 +8,7 @@ import (
 	"strings"
 )
 
-//是否是付费用户
+// VipState 是否是付费用户
 type VipState struct {
 	VipState     int64 //超级订阅状态(1普通 2升级版)
 	BigMember    int64 //大会员状态
@@ -62,14 +62,14 @@ func GetVipState(mysql *mysql.Mysql, mg mongodb.MongodbSim, userId string, entId
 	return
 }
 
-//是否是付费账户
+// IsPayedUser 是否是付费账户
 func (vs *VipState) IsPayedUser() bool {
 	return vs.VipState > 0 || vs.BigMember > 0 || vs.EntMember > 0
 }
 
-//免费 标题(title)  正文(content) 老用户【中标企业(winner)】
-//付费用户 全部(all)、标题(title)  正文(content)  会员: 采购单位(buyer) 中标企业(winner) 招标代理机构(agency) 附件(file)
-//项目名称projectname和标的物purchasing(ppa)
+// GetQueryItems 免费 标题(title)  正文(content) 老用户【中标企业(winner)】
+// 付费用户 全部(all)、标题(title)  正文(content)  会员: 采购单位(buyer) 中标企业(winner) 招标代理机构(agency) 附件(file)
+// 项目名称projectname和标的物purchasing(ppa)
 func (vs *VipState) GetQueryItems(selectType string, limitOldTime int64) (items []string) {
 	if vs.IsPayedUser() {
 		for _, t := range strings.Split(selectType, ",") {