Jelajahi Sumber

附件下载包新增

WH01243 1 tahun lalu
induk
melakukan
33098250ef
7 mengubah file dengan 229 tambahan dan 567 penghapusan
  1. 2 0
      entity/entity.go
  2. 71 60
      go.mod
  3. 119 496
      go.sum
  4. 2 1
      rpc/entmanageapplication.go
  5. 5 0
      rpc/etc/entmanageapplication.yaml
  6. 1 0
      rpc/internal/config/config.go
  7. 29 10
      service/service.go

+ 2 - 0
entity/entity.go

@@ -1,6 +1,7 @@
 package entity
 
 import (
+	"app.yhyue.com/moapp/jyResourcesCenter/rpc/resourcesCenterclient"
 	"app.yhyue.com/moapp/jybase/mongodb"
 	"app.yhyue.com/moapp/jybase/mysql"
 	"bp.jydev.jianyu360.cn/BaseService/powerCheckCenter/rpc/powercheck"
@@ -60,6 +61,7 @@ var (
 	Mgo                 *mongodb.MongodbSim
 	UserCenterRpc       usercenter.UserCenter
 	PowerCheckCenterRpc powercheck.PowerCheck
+	ResourceCenterRpc   resourcesCenterclient.ResourcesCenter
 )
 
 func InitMysql(n *MysqlDb) {

+ 71 - 60
go.mod

@@ -7,99 +7,110 @@ require (
 	bp.jydev.jianyu360.cn/BaseService/gateway v1.3.4
 	bp.jydev.jianyu360.cn/BaseService/powerCheckCenter v0.0.0-20230221025500-c75817e849ea
 	bp.jydev.jianyu360.cn/BaseService/userCenter v0.0.0-20230220120914-987d2f396c82
-	github.com/zeromicro/go-zero v1.4.4
-	google.golang.org/grpc v1.53.0
-	google.golang.org/protobuf v1.28.1
+	github.com/zeromicro/go-zero v1.5.5
+	google.golang.org/grpc v1.57.0
+	google.golang.org/protobuf v1.31.0
+	app.yhyue.com/moapp/jyResourcesCenter v0.0.0-20231024011103-8a2aacdbbd3e
 )
 
 require (
 	github.com/beorn7/perks v1.0.1 // indirect
-	github.com/cenkalti/backoff/v4 v4.1.3 // indirect
+	github.com/cenkalti/backoff/v4 v4.2.0 // 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/coreos/go-semver v0.3.1 // indirect
+	github.com/coreos/go-systemd/v22 v22.5.0 // 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/emicklei/go-restful/v3 v3.9.0 // indirect
+	github.com/fatih/color v1.15.0 // indirect
 	github.com/garyburd/redigo v1.6.2 // indirect
-	github.com/go-logr/logr v1.2.3 // indirect
+	github.com/go-logr/logr v1.2.4 // indirect
 	github.com/go-logr/stdr v1.2.2 // indirect
+	github.com/go-openapi/jsonpointer v0.19.6 // indirect
+	github.com/go-openapi/jsonreference v0.20.1 // indirect
+	github.com/go-openapi/swag v0.22.3 // indirect
 	github.com/go-redis/redis/v8 v8.11.5 // indirect
-	github.com/go-sql-driver/mysql v1.7.0 // indirect
+	github.com/go-sql-driver/mysql v1.7.1 // indirect
+	github.com/gogf/gf/v2 v2.5.5 // indirect
 	github.com/gogo/protobuf v1.3.2 // indirect
-	github.com/golang-jwt/jwt/v4 v4.4.3 // indirect
+	github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
 	github.com/golang/mock v1.6.0 // indirect
-	github.com/golang/protobuf v1.5.2 // indirect
+	github.com/golang/protobuf v1.5.3 // indirect
 	github.com/golang/snappy v0.0.4 // indirect
 	github.com/gomodule/redigo v1.8.9 // indirect
+	github.com/google/gnostic v0.5.7-v3refs // 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/grpc-ecosystem/grpc-gateway/v2 v2.15.0 // indirect
 	github.com/jinzhu/inflection v1.0.0 // indirect
 	github.com/jinzhu/now v1.1.1 // indirect
+	github.com/josharian/intern v1.0.0 // 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/klauspost/compress v1.15.15 // indirect
+	github.com/mailru/easyjson v0.7.7 // indirect
+	github.com/mattn/go-colorable v0.1.13 // indirect
+	github.com/mattn/go-isatty v0.0.19 // indirect
+	github.com/matttproud/golang_protobuf_extensions v1.0.4 // 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/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/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
+	github.com/openzipkin/zipkin-go v0.4.1 // indirect
+	github.com/pelletier/go-toml/v2 v2.0.9 // indirect
+	github.com/prometheus/client_golang v1.16.0 // indirect
+	github.com/prometheus/client_model v0.3.0 // indirect
+	github.com/prometheus/common v0.42.0 // indirect
+	github.com/prometheus/procfs v0.10.1 // 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/xdg-go/scram v1.1.2 // indirect
+	github.com/xdg-go/stringprep v1.0.4 // 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.etcd.io/etcd/api/v3 v3.5.9 // indirect
+	go.etcd.io/etcd/client/pkg/v3 v3.5.9 // indirect
+	go.etcd.io/etcd/client/v3 v3.5.9 // indirect
+	go.mongodb.org/mongo-driver v1.12.1 // indirect
+	go.opentelemetry.io/otel v1.14.0 // indirect
+	go.opentelemetry.io/otel/exporters/jaeger v1.14.0 // indirect
+	go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.14.0 // indirect
+	go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.14.0 // indirect
+	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.14.0 // indirect
+	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.14.0 // indirect
+	go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.14.0 // indirect
+	go.opentelemetry.io/otel/exporters/zipkin v1.14.0 // indirect
+	go.opentelemetry.io/otel/sdk v1.14.0 // indirect
+	go.opentelemetry.io/otel/trace v1.14.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
+	go.uber.org/atomic v1.10.0 // indirect
+	go.uber.org/automaxprocs v1.5.3 // indirect
+	go.uber.org/multierr v1.9.0 // indirect
+	go.uber.org/zap v1.24.0 // indirect
+	golang.org/x/crypto v0.14.0 // indirect
+	golang.org/x/net v0.17.0 // indirect
+	golang.org/x/oauth2 v0.7.0 // indirect
+	golang.org/x/sync v0.2.0 // indirect
+	golang.org/x/sys v0.13.0 // indirect
+	golang.org/x/term v0.13.0 // indirect
+	golang.org/x/text v0.13.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
+	google.golang.org/genproto v0.0.0-20230526161137-0005af68ea54 // indirect
+	google.golang.org/genproto/googleapis/api v0.0.0-20230525234035-dd9d682886f9 // indirect
+	google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // 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
+	k8s.io/api v0.26.3 // indirect
+	k8s.io/apimachinery v0.27.0-alpha.3 // indirect
+	k8s.io/client-go v0.26.3 // indirect
+	k8s.io/klog/v2 v2.90.1 // indirect
+	k8s.io/kube-openapi v0.0.0-20230307230338-69ee2d25a840 // indirect
+	k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect
+	sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
+	sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
+	sigs.k8s.io/yaml v1.3.0 // indirect
 )

File diff ditekan karena terlalu besar
+ 119 - 496
go.sum


+ 2 - 1
rpc/entmanageapplication.go

@@ -4,6 +4,7 @@
 package main
 
 import (
+	"app.yhyue.com/moapp/jyResourcesCenter/rpc/resourcesCenterclient"
 	"flag"
 	"fmt"
 
@@ -34,11 +35,11 @@ func main() {
 	redis.InitRedisBySize(c.RedisAddrs, 100, 30, 300)
 	entity.UserCenterRpc = usercenter.NewUserCenter(zrpc.MustNewClient(c.UserCenterRpc))
 	entity.PowerCheckCenterRpc = powercheck.NewPowerCheck(zrpc.MustNewClient(c.PowerCheckRpc))
+	entity.ResourceCenterRpc = resourcesCenterclient.NewResourcesCenter(zrpc.MustNewClient(c.ResourceRpc))
 	s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
 		pb.RegisterEntManageApplicationServer(grpcServer, srv)
 	})
 	defer s.Stop()
-
 	fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
 	s.Start()
 }

+ 5 - 0
rpc/etc/entmanageapplication.yaml

@@ -15,6 +15,11 @@ PowerCheckRpc:
     Hosts:
     - 192.168.3.149:2379
     Key: powercheck.rpc
+ResourceRpc:
+  Etcd:
+    Hosts:
+      - 192.168.3.149:2379
+    Key: resourcescenter.rpc
 Mode: test
 RedisAddrs: newother=192.168.3.206:1712
 Mysql:

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

@@ -10,6 +10,7 @@ type Config struct {
 	zrpc.RpcServerConf
 	UserCenterRpc zrpc.RpcClientConf
 	PowerCheckRpc zrpc.RpcClientConf
+	ResourceRpc   zrpc.RpcClientConf
 	Logx          logx.LogConf
 	Mysql         struct {
 		JianYu *entity.MysqlDb

+ 29 - 10
service/service.go

@@ -1,6 +1,7 @@
 package service
 
 import (
+	"app.yhyue.com/moapp/jyResourcesCenter/rpc/resourcesCenterclient"
 	"encoding/json"
 	"fmt"
 	"log"
@@ -195,9 +196,7 @@ func addPower(waitEmpowerId int64, entUserId int, entId int64) {
 		orderData := JyMysql.FindOne(Order, map[string]interface{}{"id": orderId}, "", "")
 		if orderData != nil && len(*orderData) > 0 {
 			productType := common.ObjToString((*orderData)["product_type"])
-
 			posititonId := getPositionId(entUserId)
-
 			if productType == "VIP订阅" {
 				log.Println("开通超级订阅", posititonId)
 				setRule(1, int64(entUserId), entId, *orderData, posititonId)
@@ -285,8 +284,8 @@ func delPower(id int64) {
 	}
 }
 
-//获取用户信息
-//return 职位id
+// 获取用户信息
+// return 职位id
 func getPositionId(entUserId int) int64 {
 	ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
 	res, _ := UserCenterRpc.IdentityByEntUserId(ctx, &usercenter.IdentityReq{
@@ -296,8 +295,8 @@ func getPositionId(entUserId int) int64 {
 	return res.PositionId
 }
 
-//订阅设置
-//types:1超级订阅 2大会员
+// 订阅设置
+// types:1超级订阅 2大会员
 func setRule(types int64, entUserId, entId int64, orderData map[string]interface{}, posititonId int64) bool {
 	//订阅设置
 	query := map[string]interface{}{
@@ -325,11 +324,32 @@ func setRule(types int64, entUserId, entId int64, orderData map[string]interface
 		MergeKws(entId, entUserId)
 		posititonIdStr := strconv.Itoa(int(posititonId))
 		RedisDel(posititonIdStr)
+		if types == 1 {
+			now1 := time.Now()
+			currentYear, currentMonth, _ := now1.Date()
+			currentLocation := now1.Location()
+			firstOfMonth := time.Date(currentYear, currentMonth, 1, 0, 0, 0, 0, currentLocation)
+			lastOfMonth := firstOfMonth.AddDate(0, 1, -1)
+			endTime := lastOfMonth.Format("2006-01-02")
+			vipTime := time.Unix(common.Int64All(setEntUser["l_vip_endtime"]), 0).Format("2006-01-02")
+			ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
+			ResourceCenterRpc.PurchaseUserBalance(ctx, &resourcesCenterclient.Resources{
+				AppId:        "10000",
+				UserId:       common.InterfaceToStr(posititonId),
+				ResourceType: "附件下载包",
+				AccountId:    common.InterfaceToStr(posititonId),
+				Name:         "附件下载包",
+				Number:       10,
+				Spec:         "个",
+				EndTime:      endTime,
+				VipTime:      vipTime,
+				Model:        3,
+			})
+		}
 	}()
 	return ok1 && ok2
 }
 
-//
 func vipSetMap(orderData map[string]interface{}) (set map[string]interface{}, setEntUser map[string]interface{}) {
 	set, setEntUser = map[string]interface{}{}, map[string]interface{}{}
 	startTime := common.ObjToString(orderData["vip_starttime"])
@@ -527,7 +547,6 @@ func memberSetMap(userId int64, orderData map[string]interface{}) (set map[strin
 	return
 }
 
-//
 func EmpowerUserIds(ids []int64) *entmanageapplication.EmpowerUserIds {
 	result := &entmanageapplication.EmpowerUserIds{}
 	array := []string{}
@@ -543,7 +562,7 @@ func EmpowerUserIds(ids []int64) *entmanageapplication.EmpowerUserIds {
 	return result
 }
 
-//调用用户中台清除菜单缓存
+// 调用用户中台清除菜单缓存
 func delRedisMenuByUserCenter(positionId string) bool {
 	ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
 
@@ -557,7 +576,7 @@ func delRedisMenuByUserCenter(positionId string) bool {
 	return true
 }
 
-//清除权益中台缓存
+// 清除权益中台缓存
 func delRedisByPowerCheck(positionId string) bool {
 	ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
 	i_positionId, _ := strconv.Atoi(positionId)

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini