ソースを参照

权限效验中台添加

WH01243 2 年 前
コミット
9e022f375e

+ 4 - 0
src/jfw/modules/bigmember/src/config.yaml

@@ -0,0 +1,4 @@
+etcd:
+  hosts:
+  - 192.168.3.206:2379
+powercheckKey: "powercheck.rpc" #用户中台rpc

+ 75 - 72
src/jfw/modules/bigmember/src/config/config.go

@@ -1,91 +1,94 @@
 package config
 
 import (
-	qutil "app.yhyue.com/moapp/jybase/common"
-	"app.yhyue.com/moapp/jybase/mail"
-	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/middleGround"
+        qutil "app.yhyue.com/moapp/jybase/common"
+        "app.yhyue.com/moapp/jybase/mail"
+        "app.yhyue.com/moapp/jypkg/common/src/qfw/util/middleGround"
+        "github.com/gogf/gf/v2/frame/g"
+        "github.com/gogf/gf/v2/os/gcfg"
 )
 
 type config struct {
-	WebPort string
-	Mail    []struct {
-		Addr string
-		Port int
-		Pwd  string
-		User string
-	}
-	PortraitPool        int
-	PortraitCacheDay    int
-	PortraitScreenPool  int64
-	RdProLimit          int
-	FollowPushRpc       string
-	FollowEnt           followConfig
-	FollowProject       followConfig
-	AttachmentRPC       string
-	AttachmentMail      string
-	AttachmentMailTitle string
-	ReTry               int
-	Industry            map[string]interface{}
-	KeyMaxLength        int
-	WarnMailbox         []string
-	WarnMbTitle         string
-	TimeSpan            int
-	RegWinner           string
-	OldSubscribeMoveTip int64
-	Customers           []CustomerInfo
-	NewFreeUser         int64          //免费用户 -- 订阅升级新用户
-	FileUploadNum       map[string]int //每月附件下载次数
-	CreatePdfServer     string         //生成pdf文件服务地址
-	PdfServerPoor       int            //生成pdf线程数量控制
-	PdfDataApiWhiteList []string       //pdf数据接口白名单
-	MainWebDomain       string         //附件剑鱼地址
-	marketAnalysisPool  int
-	MarketAnalysisPool  struct {
-		Limit           int `json:"limit"`           //查询并发池
-		TimeOut         int `json:"timeOut"`         //并发池等待超时时长,单位秒
-		ProjectNumLimit int `json:"projectNumLimit"` //自定义报告限制项目个数
-	} `json:"marketAnalysisPool"` //市场分析
-	ForecastTime   int //中标预测结果redis 缓存时间
-	IsAddCacheTime int //isadd 接口数据存储时间 + 120 内随机数
-	IsAddUrls      struct {
-		Free      []string `json:"free"`
-		Vip       []string `json:"vip"`
-		BigMember []string `json:"bigMember"`
-		EntNiche  []string `json:"entNiche"`
-	}
-	PotentialSwitch       bool `json:"potentialSwitch"`       //潜在客户 潜在竞争对手 新逻辑开关
-	PortraitEntnicheCount int  `json:"portraitEntnicheCount"` //商机管理 默认画像每月权限次数
+        WebPort string
+        Mail    []struct {
+                Addr string
+                Port int
+                Pwd  string
+                User string
+        }
+        PortraitPool        int
+        PortraitCacheDay    int
+        PortraitScreenPool  int64
+        RdProLimit          int
+        FollowPushRpc       string
+        FollowEnt           followConfig
+        FollowProject       followConfig
+        AttachmentRPC       string
+        AttachmentMail      string
+        AttachmentMailTitle string
+        ReTry               int
+        Industry            map[string]interface{}
+        KeyMaxLength        int
+        WarnMailbox         []string
+        WarnMbTitle         string
+        TimeSpan            int
+        RegWinner           string
+        OldSubscribeMoveTip int64
+        Customers           []CustomerInfo
+        NewFreeUser         int64          //免费用户 -- 订阅升级新用户
+        FileUploadNum       map[string]int //每月附件下载次数
+        CreatePdfServer     string         //生成pdf文件服务地址
+        PdfServerPoor       int            //生成pdf线程数量控制
+        PdfDataApiWhiteList []string       //pdf数据接口白名单
+        MainWebDomain       string         //附件剑鱼地址
+        marketAnalysisPool  int
+        MarketAnalysisPool  struct {
+                Limit           int `json:"limit"`           //查询并发池
+                TimeOut         int `json:"timeOut"`         //并发池等待超时时长,单位秒
+                ProjectNumLimit int `json:"projectNumLimit"` //自定义报告限制项目个数
+        } `json:"marketAnalysisPool"` //市场分析
+        ForecastTime   int //中标预测结果redis 缓存时间
+        IsAddCacheTime int //isadd 接口数据存储时间 + 120 内随机数
+        IsAddUrls      struct {
+                Free      []string `json:"free"`
+                Vip       []string `json:"vip"`
+                BigMember []string `json:"bigMember"`
+                EntNiche  []string `json:"entNiche"`
+        }
+        PotentialSwitch       bool `json:"potentialSwitch"`       //潜在客户 潜在竞争对手 新逻辑开关
+        PortraitEntnicheCount int  `json:"portraitEntnicheCount"` //商机管理 默认画像每月权限次数
 
-	Claim struct {
-		Details  string `json:"details"`
-		ListPage string `json:"listPage"`
-	} `json:"claim"`
+        Claim struct {
+                Details  string `json:"details"`
+                ListPage string `json:"listPage"`
+        } `json:"claim"`
 }
 
 type CustomerInfo struct {
-	Name   string `json:"name"`
-	Wxer   string `json:"wxer"`
-	Remark string `json:"remark"`
+        Name   string `json:"name"`
+        Wxer   string `json:"wxer"`
+        Remark string `json:"remark"`
 }
 type followConfig struct {
-	Normal int
-	BigVip int
+        Normal int
+        BigVip int
 }
 
 var Config *config
 var GmailAuth []*mail.GmailAuth
 
 func init() {
-	//程序配置文件
-	qutil.ReadConfig(&Config)
-	qutil.ReadConfig("./baseApi.json", &middleGround.JyApiConfig) //初始化中台请求接口
-	for _, v := range Config.Mail {
-		mail := &mail.GmailAuth{
-			SmtpHost: v.Addr,
-			SmtpPort: v.Port,
-			User:     v.User,
-			Pwd:      v.Pwd,
-		}
-		GmailAuth = append(GmailAuth, mail)
-	}
+        g.Cfg().GetAdapter().(*gcfg.AdapterFile).SetFileName("config.yaml")
+        //程序配置文件
+        qutil.ReadConfig(&Config)
+        qutil.ReadConfig("./baseApi.json", &middleGround.JyApiConfig) //初始化中台请求接口
+        for _, v := range Config.Mail {
+                mail := &mail.GmailAuth{
+                        SmtpHost: v.Addr,
+                        SmtpPort: v.Port,
+                        User:     v.User,
+                        Pwd:      v.Pwd,
+                }
+                GmailAuth = append(GmailAuth, mail)
+        }
 }

+ 84 - 5
src/jfw/modules/bigmember/src/go.mod

@@ -3,38 +3,117 @@ module jy/src/jfw/modules/bigmember/src
 go 1.18
 
 require (
+	app.yhyue.com/moapp/esv1 v0.0.0-20220414031211-3da4123e648d
 	app.yhyue.com/moapp/jybase v0.0.0-20221229074840-790b25997170
 	app.yhyue.com/moapp/jypkg v0.0.0-20221229090523-854669eee0ff
+	bp.jydev.jianyu360.cn/BaseService/powerCheckCenter v0.0.0-20230105092632-86c294a87b14
 	github.com/donnie4w/go-logger v0.0.0-20170827050443-4740c51383f4
+	github.com/gogf/gf/v2 v2.0.6
+	github.com/zeromicro/go-zero v1.4.3
 	go.mongodb.org/mongo-driver v1.11.1
-	gopkg.in/olivere/elastic.v1 v1.0.1
 )
 
 require (
-	app.yhyue.com/moapp/esv1 v0.0.0-20220414031211-3da4123e648d // indirect
 	app.yhyue.com/moapp/message v0.0.0-20221202072401-d825fc65512c // indirect
+	github.com/BurntSushi/toml v0.4.1 // indirect
+	github.com/beorn7/perks v1.0.1 // indirect
+	github.com/cenkalti/backoff/v4 v4.1.3 // indirect
+	github.com/cespare/xxhash/v2 v2.1.2 // indirect
+	github.com/clbanning/mxj/v2 v2.5.5 // 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/fsnotify/fsnotify v1.5.1 // indirect
 	github.com/garyburd/redigo v1.6.2 // indirect
-	github.com/go-sql-driver/mysql v1.6.0 // 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/go-sql-driver/mysql v1.7.0 // indirect
+	github.com/gogo/protobuf v1.3.2 // 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/googleapis/gnostic v0.5.5 // indirect
+	github.com/gorilla/websocket v1.5.0 // indirect
+	github.com/grokify/html-strip-tags-go v0.0.1 // indirect
+	github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect
 	github.com/howeyc/fsnotify v0.9.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/longbridgeapp/sqlparser v0.3.1 // indirect
+	github.com/mattn/go-colorable v0.1.9 // indirect
+	github.com/mattn/go-isatty v0.0.14 // indirect
+	github.com/mattn/go-runewidth v0.0.13 // 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/nsqio/go-nsq v1.1.0 // indirect
+	github.com/olekukonko/tablewriter v0.0.5 // 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/rivo/uniseg v0.2.0 // indirect
 	github.com/robfig/cron v1.2.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.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/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/sync v0.0.0-20210220032951-036812b2e83c // indirect
-	golang.org/x/text v0.3.8-0.20211105212822-18b340fc7af2 // indirect
+	golang.org/x/net v0.0.0-20221014081412-f15817d10f9b // indirect
+	golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 // indirect
+	golang.org/x/sync v0.1.0 // indirect
+	golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 // indirect
+	golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
+	golang.org/x/text v0.4.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-20221111202108-142d8a6fa32e // indirect
+	google.golang.org/grpc v1.51.0 // indirect
+	google.golang.org/protobuf v1.28.1 // indirect
 	gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // 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
 )

ファイルの差分が大きいため隠しています
+ 527 - 3
src/jfw/modules/bigmember/src/go.sum


+ 40 - 0
src/jfw/modules/bigmember/src/grpc/powerCheckCenter.go

@@ -0,0 +1,40 @@
+package grpc
+
+import (
+        "bp.jydev.jianyu360.cn/BaseService/powerCheckCenter/rpc/pb"
+        "bp.jydev.jianyu360.cn/BaseService/powerCheckCenter/rpc/powercheck"
+        "context"
+        "github.com/gogf/gf/v2/frame/g"
+        "github.com/gogf/gf/v2/os/gctx"
+        "github.com/zeromicro/go-zero/core/discov"
+        "github.com/zeromicro/go-zero/zrpc"
+        "log"
+)
+
+var PowerCheck = &powerCheck{}
+
+type powerCheck struct {
+}
+
+func (p *powerCheck) Check(appid, userId string, baseUserId, accountId, entId int64) *pb.CheckResp {
+        var ctx = gctx.New()
+        client, err := zrpc.NewClient(zrpc.RpcClientConf{
+                Etcd: discov.EtcdConf{
+                        Hosts: g.Cfg().MustGet(ctx, "etcd.hosts").Strings(),
+                        Key:   g.Cfg().MustGet(ctx, "powercheckKey").String(),
+                },
+        })
+        if err != nil {
+                log.Println(err)
+                return nil
+        }
+        defer client.Conn().Close()
+        resp, err := powercheck.NewPowerCheck(client).Check(context.Background(), &pb.CheckReq{
+                Appid:      appid,
+                Userid:     userId,
+                BaseUserId: baseUserId,
+                AccountId:  accountId,
+                EntId:      entId,
+        })
+        return resp
+}

ファイルの差分が大きいため隠しています
+ 805 - 770
src/jfw/modules/bigmember/src/service/use/use.go


+ 17 - 60
src/jfw/modules/publicapply/src/bidcollection/entity/entity.go

@@ -4,6 +4,7 @@ import (
 	"fmt"
 	"jy/src/jfw/modules/publicapply/src/config"
 	"jy/src/jfw/modules/publicapply/src/db"
+	"jy/src/jfw/modules/publicapply/src/grpc"
 	"log"
 	"strconv"
 	"strings"
@@ -431,78 +432,34 @@ func GetCollList(c *util.CollList, userid string) map[string]interface{} {
 }
 
 //是否是付费用户 -bool: true:是 fasle:不是
-func Power(userid string, entId int) (bool, map[string]interface{}) {
-	/*isVip, isMember, isEnt, privatedata := false, false, false, false
+func Power(userid string, baseUserId, entId, accountId int64) (bool, map[string]interface{}) {
+	isVip, isMember, isEnt, privatedata := false, false, false, false
 	vipstatus := 0
-	phone := ""
-	var registedate int64
-	data, ok := db.Mgo.FindById("user", userid, `"i_member_status":1,"i_vip_status":1,"s_m_phone":1,"s_phone":1,"o_vipjy":1,"l_registedate":1`)
-	if data != nil && len(*data) > 0 && ok {
-		i_vip_status := qu.IntAll((*data)["i_vip_status"])
-		if i_vip_status > 1 {
+	//isVip, isMember, isEnt, privatedata
+	resp := grpc.PowerCheck.Check("10000", userid, baseUserId, accountId, entId)
+	if resp != nil {
+		if resp.Vip.Status > 1 {
 			vipstatus = 1
 			isVip = true
 		}
-		ovipjy, _ := (*data)["o_vipjy"].(map[string]interface{})
-		if ovipjy["o_buyset"] != nil {
-			o_buyset := ovipjy["o_buyset"].(map[string]interface{})
-			if o_buyset["upgrade"] != nil && isVip {
-				vipstatus = 2
-			}
+		if resp.Vip.Upgrade > 0 && isVip {
+			vipstatus = 2
 		}
-		if i_member_status := qu.IntAllDef((*data)["i_member_status"], 0); i_member_status > 0 {
+		if resp.Member.Status > 0 {
 			isMember = true
 		}
-		if s_phone, _ := (*data)["s_phone"].(string); s_phone != "" {
-			phone = s_phone
-		} else if s_m_phone, _ := (*data)["s_m_phone"].(string); s_m_phone != "" {
-			phone = s_m_phone
-		}
-		if phone != "" {
-			//已购买企业未过期
-			if entInfo := *db.Mysql.SelectBySql(`SELECT status,isNew,id,power_source FROM entniche_info WHERE id  IN (SELECT ent_id FROM entniche_user where phone = ? and power =1)`, phone); len(entInfo) > 0 {
-				for _, v := range entInfo {
-					if entId > 0 {
-						if entId == qu.IntAll(v["id"]) {
-							if qu.IntAll(v["power_source"]) == 1 {
-								break
-							} else if qu.IntAll(v["status"]) == 1 {
-								isEnt = true
-								break
-							}
-						}
-					} else {
-						if qu.IntAll(v["status"]) == 1 && qu.IntAll(v["power_source"]) != 1 {
-							isEnt = true
-							break
-						}
-					}
-					//&& qu.IntAll(v["isNew"]) == 1
-					// if qu.IntAll(v["status"]) == 1 {
-					// 	isEnt = true
-					// 	break
-					// }
-				}
-			}
-			// if db.Mysql.CountBySql(`select count(1) from entniche_user where phone = ? and power =1`, phone) > 0 {
-			// 	isEnt = true
-			// }
-			//广州移动判断
-			privatedataCount := db.Mysql.CountBySql(`select count(1) from privatedata where phone = ?`, phone)
-			if privatedataCount > 0 {
-				privatedata = true
-			}
+		if qu.IntAll(v["power_source"]) != 1 && qu.IntAll(v["status"]) == 1 {
+			isEnt = true
 		}
-		registedate, _ = (*data)["l_registedate"].(int64)
-	}*/
-	/*return isVip || isEnt || isMember, map[string]interface{}{
+		privatedata = resp.Ent.PrivateGD
+	}
+	return isVip || isEnt || isMember, map[string]interface{}{
 		"vip":         vipstatus,
 		"member":      isMember,
 		"entniche":    isEnt,
 		"privatedata": privatedata,
-		"registedate": registedate,
-	}*/
-        return true, map[string]interface{}{}
+		//"registedate": registedate,
+	}
 }
 
 type InfoList struct {

+ 4 - 0
src/jfw/modules/publicapply/src/config.yaml

@@ -0,0 +1,4 @@
+etcd:
+  hosts:
+  - 192.168.3.206:2379
+powercheckKey: "powercheck.rpc" #用户中台rpc

+ 3 - 0
src/jfw/modules/publicapply/src/config/config.go

@@ -2,6 +2,8 @@ package config
 
 import (
 	qutil "app.yhyue.com/moapp/jybase/common"
+	"github.com/gogf/gf/v2/frame/g"
+	"github.com/gogf/gf/v2/os/gcfg"
 )
 
 type config struct {
@@ -62,6 +64,7 @@ var AdLeaguefig *AdLeague
 var ShareConfig *ShareF
 
 func init() {
+	g.Cfg().GetAdapter().(*gcfg.AdapterFile).SetFileName("config.yaml")
 	//程序配置文件
 	qutil.ReadConfig(&Config)
 	qutil.ReadConfig("./bidcollection.json", &BidCollConfig)

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません