Ver Fonte

Merge branch 'feature/v1.1.12' of http://192.168.3.207:8080/BaseService/jyMicroservices into feature/v1.1.12

wangshan há 2 anos atrás
pai
commit
9813f296f0

+ 33 - 1
jyBXSubscribe/api/bxsubscribe.api

@@ -26,6 +26,9 @@ type (
 		Subtype    string `json:"subtype,optional"`
 		Price      string `json:"price,optional"`
 		FileExists string `json:"fileExists,optional"`
+		Source     string `json:"source,optional"`                                        //信息来源
+		IsRead     string `json:"isRead,optional"`                                        //是否已读
+		Staffs     string `json:"staffs,optional"`                                        //分发的员工
 		UserType   string `path:"userType,default=fType,options=fType|vType|mType|eType"` //fType:普通用户;vType:超级订阅用户;mType:大会员用户;eType:商机管理用户;
 		NewUserId  int64  `header:"newUserId"`
 		IsEnt      bool   `json:"isEnt,optional"`
@@ -86,6 +89,29 @@ type (
 		PowerSource int64  `form:"powerSource,optional"`
 		UserPower   int64  `form:"userPower,optional"`
 	}
+	DistributorReq {
+		AppId     string `header:"appId"`
+		EntId     string `header:"entId,optional"`
+		EntUserId string `header:"entUserId,optional"`
+		UserType  string `path:"userType,optional"`
+		Region    string `json:"region,optional"`
+		SelectIds string `json:"selectIds,optional"`
+		QueryType string `json:"queryType,optional"`
+	}
+	viewStatusReq {
+		AppId     string `header:"appId"`
+		EntId     string `header:"entId,optional"`
+		EntUserId string `header:"entUserId,optional"`
+		UserType  string `path:"userType,optional"`
+		InfoId    string `json:"infoId,optional"`
+	}
+	msgDistributor {
+		AppId     string `header:"appId"`
+		EntId     string `header:"entId,optional"`
+		EntUserId string `header:"entUserId,optional"`
+		MessageId string `json:"messageId"`
+		Staffs    string `json:"staffs"`
+	}
 )
 service bxsubscribe-api {
 	@handler subscribeList
@@ -100,4 +126,10 @@ service bxsubscribe-api {
 	post /jybx/subscribe/:userType/setRead(SetReadReq) returns (commonResp)
 	@handler getKey
 	post /jybx/subscribe/:userType/getKey(GetKeyReq) returns (commonResp)
-}
+	@handler distributor
+	post /jybx/subscribe/:userType/distributor(DistributorReq) returns (commonResp)
+	@handler viewStatus
+	post /jybx/subscribe/:userType/viewStatus(viewStatusReq) returns (commonResp)
+	@handler msgDistributor
+	post /jybx/subscribe/msgDistributor(msgDistributor) returns (commonResp)
+}

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

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

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

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

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

@@ -42,6 +42,21 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/jybx/subscribe/:userType/getKey",
 				Handler: getKeyHandler(serverCtx),
 			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/jybx/subscribe/:userType/distributor",
+				Handler: distributorHandler(serverCtx),
+			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/jybx/subscribe/:userType/viewStatus",
+				Handler: viewStatusHandler(serverCtx),
+			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/jybx/subscribe/msgDistributor",
+				Handler: msgDistributorHandler(serverCtx),
+			},
 		},
 	)
 }

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

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

+ 3 - 0
jyBXSubscribe/api/internal/logic/byPushHistoryLogic.go

@@ -38,6 +38,9 @@ func (l *ByPushHistoryLogic) ByPushHistory(req *types.SubscribeReq) (resp *types
 		UserType:   req.UserType,
 		Price:      req.Price,
 		FileExists: req.FileExists,
+		IsRead:     req.IsRead,
+		Source:     req.Source,
+		Staffs:     req.Staffs,
 		UserId:     req.UserId,
 		EntId:      req.EntId,
 		EntUserId:  req.EntUserId,

+ 57 - 0
jyBXSubscribe/api/internal/logic/distributorlogic.go

@@ -0,0 +1,57 @@
+package logic
+
+import (
+	"context"
+	"jyBXSubscribe/rpc/type/bxsubscribe"
+
+	"jyBXSubscribe/api/internal/svc"
+	"jyBXSubscribe/api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type DistributorLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewDistributorLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DistributorLogic {
+	return &DistributorLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *DistributorLogic) Distributor(req *types.DistributorReq) (resp *types.CommonResp, err error) {
+	// todo: add your logic here and delete this line
+	res, err := l.svcCtx.Suscribe.GetDistributor(l.ctx, &bxsubscribe.GetDistributorReq{
+		AppId:     req.AppId,
+		EntId:     req.EntId,
+		EntUserId: req.EntUserId,
+		Region:    req.Region,
+		QueryType: req.QueryType,
+	})
+	if err != nil {
+		return &types.CommonResp{
+			Err_code: res.ErrCode,
+			Err_msg:  res.ErrMsg,
+			Data:     nil,
+		}, nil
+	}
+	var data []map[string]interface{}
+	for _, v := range res.Items {
+		_d := make(map[string]interface{})
+		_d["name"] = v.Name
+		_d["id"] = v.Id
+		_d["phone"] = v.Phone
+		data = append(data, _d)
+	}
+	return &types.CommonResp{
+		Err_code: res.ErrCode,
+		Err_msg:  res.ErrMsg,
+		Data:     data,
+	}, nil
+	return
+}

+ 40 - 0
jyBXSubscribe/api/internal/logic/msgDistributorLogic.go

@@ -0,0 +1,40 @@
+package logic
+
+import (
+	"context"
+	"jyBXSubscribe/rpc/type/bxsubscribe"
+
+	"jyBXSubscribe/api/internal/svc"
+	"jyBXSubscribe/api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type MsgDistributorLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewMsgDistributorLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MsgDistributorLogic {
+	return &MsgDistributorLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *MsgDistributorLogic) MsgDistributor(req *types.MsgDistributor) (resp *types.CommonResp, err error) {
+	res, err := l.svcCtx.Suscribe.MsgDistributor(l.ctx, &bxsubscribe.MsgDistributorReq{
+		AppId:     req.AppId,
+		EntId:     req.EntId,
+		EntUserId: req.EntUserId,
+		MessageId: req.MessageId,
+		Staffs:    req.Staffs,
+	})
+	return &types.CommonResp{
+		Err_code: res.ErrorCode,
+		Err_msg:  res.ErrorMsg,
+		Data:     res.Status,
+	}, err
+}

+ 3 - 0
jyBXSubscribe/api/internal/logic/subscribeListLogic.go

@@ -40,6 +40,9 @@ func (l *SubscribeListLogic) SubscribeList(req *types.SubscribeReq) (resp *types
 		UserType:   req.UserType,
 		Price:      req.Price,
 		FileExists: req.FileExists,
+		IsRead:     req.IsRead,
+		Source:     req.Source,
+		Staffs:     req.Staffs,
 		UserId:     req.UserId,
 		EntId:      req.EntId,
 		EntUserId:  req.EntUserId,

+ 57 - 0
jyBXSubscribe/api/internal/logic/viewStatusLogic.go

@@ -0,0 +1,57 @@
+package logic
+
+import (
+	"context"
+	"jyBXSubscribe/api/internal/svc"
+	"jyBXSubscribe/api/internal/types"
+	"jyBXSubscribe/rpc/type/bxsubscribe"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type ViewStatusLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewViewStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ViewStatusLogic {
+	return &ViewStatusLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *ViewStatusLogic) ViewStatus(req *types.ViewStatusReq) (resp *types.CommonResp, err error) {
+	// todo: add your logic here and delete this line
+	res, err := l.svcCtx.Suscribe.GetViewStatus(l.ctx, &bxsubscribe.GetViewStatusReq{
+		AppId:     req.AppId,
+		EntId:     req.EntId,
+		EntUserId: req.EntUserId,
+		InfoId:    req.InfoId,
+	})
+	if err != nil {
+		return &types.CommonResp{
+			Err_code: res.ErrCode,
+			Err_msg:  res.ErrMsg,
+			Data:     nil,
+		}, nil
+	}
+	var data []map[string]interface{}
+	for _, v := range res.Items {
+		_d := make(map[string]interface{})
+		_d["name"] = v.Name
+		_d["id"] = v.Id
+		_d["visittime"] = v.Visittime
+		_d["isvisit"] = v.Isvisit
+		_d["date"] = v.Date
+		data = append(data, _d)
+	}
+	return &types.CommonResp{
+		Err_code: res.ErrCode,
+		Err_msg:  res.ErrMsg,
+		Data:     data,
+	}, nil
+	return
+}

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

@@ -18,6 +18,9 @@ type SubscribeReq struct {
 	Subtype    string `json:"subtype,optional"`
 	Price      string `json:"price,optional"`
 	FileExists string `json:"fileExists,optional"`
+	Source     string `json:"source,optional"`                                        //信息来源
+	IsRead     string `json:"isRead,optional"`                                        //是否已读
+	Staffs     string `json:"staffs,optional"`                                        //分发的员工
 	UserType   string `path:"userType,default=fType,options=fType|vType|mType|eType"` //fType:普通用户;vType:超级订阅用户;mType:大会员用户;eType:商机管理用户;
 	NewUserId  int64  `header:"newUserId"`
 	IsEnt      bool   `json:"isEnt,optional"`
@@ -80,3 +83,29 @@ type GetKeyReq struct {
 	PowerSource int64  `form:"powerSource,optional"`
 	UserPower   int64  `form:"userPower,optional"`
 }
+
+type DistributorReq struct {
+	AppId     string `header:"appId"`
+	EntId     string `header:"entId,optional"`
+	EntUserId string `header:"entUserId,optional"`
+	UserType  string `path:"userType,optional"`
+	Region    string `json:"region,optional"`
+	SelectIds string `json:"selectIds,optional"`
+	QueryType string `json:"queryType,optional"`
+}
+
+type ViewStatusReq struct {
+	AppId     string `header:"appId"`
+	EntId     string `header:"entId,optional"`
+	EntUserId string `header:"entUserId,optional"`
+	UserType  string `path:"userType,optional"`
+	InfoId    string `json:"infoId,optional"`
+}
+
+type MsgDistributor struct {
+	AppId     string `header:"appId"`
+	EntId     string `header:"entId,optional"`
+	EntUserId string `header:"entUserId,optional"`
+	MessageId string `json:"messageId"`
+	Staffs    string `json:"staffs"`
+}

+ 63 - 5
jyBXSubscribe/rpc/bxsubscribe.proto

@@ -19,11 +19,14 @@ message SubscribeInfosReq {
   string  appId = 13;
   string  price = 14;
   string  fileExists = 15;
-  string  entUserId = 16;
-  string deptId = 17;
-  int64 newUserId = 18;
-  bool IsEnt = 19;
-  string SelectIds = 20;
+  string  isRead = 16; //是否已读
+  string  staffs = 17;//分发人员
+  string  source = 18; //信息来源
+  string  entUserId = 19;
+  string  deptId = 20;
+  int64 newUserId = 21;
+  bool IsEnt = 22;
+  string SelectIds = 23;
 }
 
 message SubscribeInfosResp {
@@ -185,12 +188,61 @@ message GetKeyReq{
   int64   userPower = 12;
   string  deptId = 13;
 }
+
+message GetDistributorReq{
+  string  appId = 1;
+  string  entId = 2;
+  string  entUserId = 3;
+  string  region = 4;
+  string  selectIds = 5;
+  string  queryType = 6;
+}
+
+message MsgDistributorReq{
+  string  appId = 1;
+  string  entId = 2;
+  string  entUserId = 3;
+  string  messageId = 4;//分发信息
+  string  staffs = 5; //分发的员工
+}
+
 message KeyResp {
   int64 err_code = 1;
   string err_msg = 2;
   repeated KeyItems items = 3;//关键词
 }
 
+message DistributorResp {
+  int64 err_code = 1;
+  string err_msg = 2;
+  repeated userResp items = 3;//分发人员
+}
+
+message userResp {
+  string name = 1;
+  int64 id = 2;
+  string phone = 3;
+}
+
+message GetViewStatusReq{
+  string  appId = 1;
+  string  entId = 2;
+  string  entUserId = 3;
+  string  infoId = 4;
+}
+
+message ViewStatusResp {
+  int64 err_code = 1;
+  string err_msg = 2;
+  repeated UserStatus items = 3;//分发人员
+}
+message UserStatus {
+  string name = 1;
+  int64 id = 2;
+  int64 isvisit = 3;
+  string visittime = 4;
+  string date = 5;
+}
 
 
 service Bxsubscribe {
@@ -206,4 +258,10 @@ service Bxsubscribe {
   rpc SetRead(SetReadReq)returns(StatusResp);
   //关键词获取
   rpc GetKey(GetKeyReq)returns(KeyResp);
+  //信息分发
+  rpc MsgDistributor(MsgDistributorReq)returns(StatusResp);
+  //手动分发人员查询
+  rpc GetDistributor(GetDistributorReq)returns(DistributorResp);
+  //查看状态
+  rpc GetViewStatus(GetViewStatusReq)returns(ViewStatusResp);
 }

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

@@ -15,12 +15,16 @@ import (
 type (
 	ByPushHistoryResp      = bxsubscribe.ByPushHistoryResp
 	CityList               = bxsubscribe.CityList
+	DistributorResp        = bxsubscribe.DistributorResp
+	GetDistributorReq      = bxsubscribe.GetDistributorReq
 	GetKeyReq              = bxsubscribe.GetKeyReq
+	GetViewStatusReq       = bxsubscribe.GetViewStatusReq
 	Items                  = bxsubscribe.Items
 	Key                    = bxsubscribe.Key
 	KeyItems               = bxsubscribe.KeyItems
 	KeyResp                = bxsubscribe.KeyResp
 	Keys                   = bxsubscribe.Keys
+	MsgDistributorReq      = bxsubscribe.MsgDistributorReq
 	SetReadReq             = bxsubscribe.SetReadReq
 	SomeInfo               = bxsubscribe.SomeInfo
 	SomeInfoReq            = bxsubscribe.SomeInfoReq
@@ -31,6 +35,9 @@ type (
 	SubscribeInfosReq      = bxsubscribe.SubscribeInfosReq
 	SubscribeInfosResp     = bxsubscribe.SubscribeInfosResp
 	UpdateSubScribeInfoReq = bxsubscribe.UpdateSubScribeInfoReq
+	UserResp               = bxsubscribe.UserResp
+	UserStatus             = bxsubscribe.UserStatus
+	ViewStatusResp         = bxsubscribe.ViewStatusResp
 
 	Bxsubscribe interface {
 		// 获取订阅推送列表
@@ -45,6 +52,12 @@ type (
 		SetRead(ctx context.Context, in *SetReadReq, opts ...grpc.CallOption) (*StatusResp, error)
 		// 关键词获取
 		GetKey(ctx context.Context, in *GetKeyReq, opts ...grpc.CallOption) (*KeyResp, error)
+		// 信息分发
+		MsgDistributor(ctx context.Context, in *MsgDistributorReq, opts ...grpc.CallOption) (*StatusResp, error)
+		// 手动分发人员查询
+		GetDistributor(ctx context.Context, in *GetDistributorReq, opts ...grpc.CallOption) (*DistributorResp, error)
+		// 查看状态
+		GetViewStatus(ctx context.Context, in *GetViewStatusReq, opts ...grpc.CallOption) (*ViewStatusResp, error)
 	}
 
 	defaultBxsubscribe struct {
@@ -93,3 +106,21 @@ func (m *defaultBxsubscribe) GetKey(ctx context.Context, in *GetKeyReq, opts ...
 	client := bxsubscribe.NewBxsubscribeClient(m.cli.Conn())
 	return client.GetKey(ctx, in, opts...)
 }
+
+// 信息分发
+func (m *defaultBxsubscribe) MsgDistributor(ctx context.Context, in *MsgDistributorReq, opts ...grpc.CallOption) (*StatusResp, error) {
+	client := bxsubscribe.NewBxsubscribeClient(m.cli.Conn())
+	return client.MsgDistributor(ctx, in, opts...)
+}
+
+// 手动分发人员查询
+func (m *defaultBxsubscribe) GetDistributor(ctx context.Context, in *GetDistributorReq, opts ...grpc.CallOption) (*DistributorResp, error) {
+	client := bxsubscribe.NewBxsubscribeClient(m.cli.Conn())
+	return client.GetDistributor(ctx, in, opts...)
+}
+
+// 查看状态
+func (m *defaultBxsubscribe) GetViewStatus(ctx context.Context, in *GetViewStatusReq, opts ...grpc.CallOption) (*ViewStatusResp, error) {
+	client := bxsubscribe.NewBxsubscribeClient(m.cli.Conn())
+	return client.GetViewStatus(ctx, in, opts...)
+}

+ 10 - 0
jyBXSubscribe/rpc/internal/logic/bypushhistorylogic.go

@@ -31,6 +31,13 @@ func NewByPushHistoryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ByP
 func (l *ByPushHistoryLogic) ByPushHistory(in *bxsubscribe.SubscribeInfosReq) (*bxsubscribe.ByPushHistoryResp, error) {
 	// todo: add your logic here and delete this line
 	vipType := in.UserType
+	//分发员工
+	var staffIds []string
+	for _, staffId := range strings.Split(in.Staffs, ",") {
+		if staffId != "" {
+			staffIds = append(staffIds, staffId)
+		}
+	}
 	spqp := &model.SubPushQueryParam{
 		Mgo_bidding:      IC.MgoBidding,                      //mongo
 		Bidding:          IC.DB.Mongo.Bidding.Collection,     //招标信息 表
@@ -51,6 +58,9 @@ func (l *ByPushHistoryLogic) ByPushHistory(in *bxsubscribe.SubscribeInfosReq) (*
 		EntId:            in.EntId,      //商机管理企业id
 		EntUserId:        in.EntUserId,  //商机管理用户id
 		DeptId:           in.DeptId,     //商机管理部门id
+		IsRead:           in.IsRead,
+		Source:           in.Source,
+		Staffs:           staffIds,
 		NewUserId:        in.NewUserId,
 		BaseServiceMysql: IC.BaseServiceMysql,
 		IsEnt:            in.IsEnt,

+ 55 - 0
jyBXSubscribe/rpc/internal/logic/getdistributorlogic.go

@@ -0,0 +1,55 @@
+package logic
+
+import (
+	"app.yhyue.com/moapp/jybase/common"
+	"context"
+	"jyBXSubscribe/rpc/model"
+	"log"
+	"strings"
+
+	"jyBXSubscribe/rpc/internal/svc"
+	"jyBXSubscribe/rpc/type/bxsubscribe"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GetDistributorLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewGetDistributorLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDistributorLogic {
+	return &GetDistributorLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+// 手动分发人员
+func (l *GetDistributorLogic) GetDistributor(in *bxsubscribe.GetDistributorReq) (*bxsubscribe.DistributorResp, error) {
+	// todo: add your logic here and delete this line
+	da := new(bxsubscribe.DistributorResp)
+	var (
+		users []*model.User
+	)
+	log.Printf("分发人员参数entuserid:%s;entid:%s;region:%s;QueryType:%s", in.EntUserId, in.EntId, in.Region, in.QueryType)
+	//搜索分发人员
+	if in.QueryType == "1" {
+		users = model.AllDistributor(common.IntAll(in.EntId), common.IntAll(in.EntUserId))
+	} else {
+		//手动分发人员
+		users = model.Distributor(strings.Split(in.Region, ","), common.IntAll(in.EntId), common.IntAll(in.EntUserId))
+	}
+	if len(users) > 0 {
+		for _, v := range users {
+			var data bxsubscribe.UserResp
+			data.Id = common.Int64All(v.Id)
+			data.Name = v.Name
+			data.Phone = v.Phone
+			da.Items = append(da.Items, &data)
+		}
+	}
+	return da, nil
+}

+ 14 - 3
jyBXSubscribe/rpc/internal/logic/getsublistlogic.go

@@ -7,6 +7,7 @@ import (
 	"jyBXSubscribe/rpc/model"
 	"jyBXSubscribe/rpc/type/bxsubscribe"
 	"jyBXSubscribe/rpc/util"
+	"strings"
 	"time"
 
 	"app.yhyue.com/moapp/jybase/common"
@@ -46,6 +47,13 @@ func (l *GetSubListLogic) GetSubList(in *bxsubscribe.SubscribeInfosReq) (*bxsubs
 	if in.UserType != "fType" && userInfo.IsPayedUser() {
 		isPayUser = true
 	}
+	//分发员工
+	var staffIds []string
+	for _, staffId := range strings.Split(in.Staffs, ",") {
+		if staffId != "" {
+			staffIds = append(staffIds, staffId)
+		}
+	}
 	spqp := &model.SubPushQueryParam{
 		Mgo_bidding:      IC.MgoBidding,                      //mongo
 		Bidding:          IC.DB.Mongo.Bidding.Collection,     //招标信息 表
@@ -62,9 +70,12 @@ func (l *GetSubListLogic) GetSubList(in *bxsubscribe.SubscribeInfosReq) (*bxsubs
 		Key:              in.KeyWords,                        //关键词
 		Price:            in.Price,                           //价格区间
 		FileExists:       in.FileExists,                      //是否有附件
-		EntId:            in.EntId,                           //商机管理企业id
-		EntUserId:        in.EntUserId,                       //商机管理用户id
-		DeptId:           in.DeptId,                          //商机管理部门id
+		IsRead:           in.IsRead,
+		Source:           in.Source,
+		Staffs:           staffIds,
+		EntId:            in.EntId,     //商机管理企业id
+		EntUserId:        in.EntUserId, //商机管理用户id
+		DeptId:           in.DeptId,    //商机管理部门id
 		NewUserId:        in.NewUserId,
 		BaseServiceMysql: IC.BaseServiceMysql,
 		IsEnt:            in.IsEnt,

+ 106 - 0
jyBXSubscribe/rpc/internal/logic/getviewstatuslogic.go

@@ -0,0 +1,106 @@
+package logic
+
+import (
+	"app.yhyue.com/moapp/jybase/common"
+	"context"
+	"fmt"
+	IC "jyBXSubscribe/rpc/init"
+	"jyBXSubscribe/rpc/model"
+	"jyBXSubscribe/rpc/util"
+	"log"
+	"strings"
+	"time"
+
+	"jyBXSubscribe/rpc/internal/svc"
+	"jyBXSubscribe/rpc/type/bxsubscribe"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GetViewStatusLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewGetViewStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetViewStatusLogic {
+	return &GetViewStatusLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+// 查看状态
+func (l *GetViewStatusLogic) GetViewStatus(in *bxsubscribe.GetViewStatusReq) (*bxsubscribe.ViewStatusResp, error) {
+	// todo: add your logic here and delete this line
+	user := model.EntInfo(common.IntAll(in.EntId), common.IntAll(in.EntUserId))
+	var (
+		users  *[]*model.User
+		ss     []string
+		finsql string
+	)
+	in.InfoId = util.DecodeId(in.InfoId)
+	log.Println("查看状态参数", in)
+	res := new(bxsubscribe.ViewStatusResp)
+	finsql = `SELECT userid,isvisit,visittime,date FROM pushentniche where  infoid =? and source in (2,3) order By date asc`
+	if user.Role_admin_department {
+		users = model.GetDisUsers(common.IntAll(in.EntId), user.Dept.Id)
+		if users != nil && len(*users) > 0 {
+			//获取所有部门和子部门员工
+			for _, v := range *users {
+				ss = append(ss, common.InterfaceToStr(v.Id))
+			}
+		} else {
+			log.Println("部门管理员下为获取到员工", in.EntUserId)
+			return &bxsubscribe.ViewStatusResp{}, nil
+		}
+	} else if user.Role_admin_system {
+		//获取企业所有用户
+		users = model.GetEntUsers(common.IntAll(in.EntId))
+	}
+	if len(ss) > 0 {
+		finsql = fmt.Sprintf(`SELECT userid,isvisit,visittime,date FROM pushentniche where  infoid =? and source in (2,3) %s order By date asc`, fmt.Sprintf(`and userid in (%s)`, strings.Join(ss, ",")))
+	}
+	data := IC.BaseServiceMysql.SelectBySql(finsql, in.InfoId)
+	userMap := make(map[int]string)
+	for _, u := range *users {
+		userMap[u.Id] = u.Name
+	}
+	if data != nil && len(*data) > 0 {
+		//d := make(map[string]int)
+		for _, v := range *data {
+			userid := common.IntAll(v["userid"])
+			if name, ok := userMap[userid]; ok && name != "" {
+				var da bxsubscribe.UserStatus
+				da.Name = name
+				da.Isvisit = common.Int64All(v["isvisit"])
+				visittime := common.InterfaceToStr(v["visittime"])
+				date := common.Int64All(v["date"])
+				if date > 0 {
+					da.Date = time.Unix(date, 0).Format("2006-01-02 15:04:05")
+				}
+				da.Visittime = visittime
+				da.Id = common.Int64All(userid)
+				res.Items = append(res.Items, &da)
+				//if _, ok1 := d[common.InterfaceToStr(userid)]; !ok1 {
+				//	res.Items = append(res.Items, &da)
+				//	d[common.InterfaceToStr(userid)] = len(res.Items) - 1
+				//}
+			}
+		}
+	}
+	//Reverse(&res.Items)
+	return res, nil
+}
+
+// 数组倒序函数
+func Reverse(arr *[]*bxsubscribe.UserStatus) {
+	var temp *bxsubscribe.UserStatus
+	length := len(*arr)
+	for i := 0; i < length/2; i++ {
+		temp = (*arr)[i]
+		(*arr)[i] = (*arr)[length-1-i]
+		(*arr)[length-1-i] = temp
+	}
+}

+ 123 - 0
jyBXSubscribe/rpc/internal/logic/msgdistributorlogic.go

@@ -0,0 +1,123 @@
+package logic
+
+import (
+	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/redis"
+	"context"
+	"database/sql"
+	"fmt"
+	IC "jyBXSubscribe/rpc/init"
+	"jyBXSubscribe/rpc/model"
+	"strings"
+	"time"
+
+	"jyBXSubscribe/rpc/internal/svc"
+	"jyBXSubscribe/rpc/type/bxsubscribe"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type MsgDistributorLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewMsgDistributorLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MsgDistributorLogic {
+	return &MsgDistributorLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+// 信息分发
+func (l *MsgDistributorLogic) MsgDistributor(in *bxsubscribe.MsgDistributorReq) (*bxsubscribe.StatusResp, error) {
+	userEnt := model.EntInfo(common.IntAll(in.EntId), common.IntAll(in.EntUserId))
+	if !(userEnt.Role_admin_system || userEnt.Role_admin_department) {
+		return &bxsubscribe.StatusResp{ErrorCode: -1, ErrorMsg: "无权限"}, nil
+	}
+	//根据信息查询区域列表
+	var regin, pushIds, staffs []string
+	staffs = strings.Split(in.Staffs, ",")
+	var pushCas []*model.PushCa
+	for _, id := range strings.Split(in.MessageId, ",") {
+		if id != "" {
+			pushIds = append(pushIds, id)
+		}
+	}
+	if len(pushIds) == 0 || in.Staffs == "" {
+		return &bxsubscribe.StatusResp{ErrorCode: -1, ErrorMsg: "缺少参数"}, nil
+	}
+	//获取分发信息的地区
+	infoRes := IC.BaseServiceMysql.SelectBySql(fmt.Sprintf("SELECT infoid FROM pushentniche WHERE id in('%s')", strings.Join(pushIds, "','")))
+	if infoRes == nil || len(*infoRes) == 0 {
+		return &bxsubscribe.StatusResp{ErrorCode: -1, ErrorMsg: "获取分发地区异常"}, nil
+	}
+	for _, m := range *infoRes {
+		if infoId, _ := m["infoid"].(string); infoId != "" {
+			pushCas = append(pushCas, &model.PushCa{InfoId: infoId})
+		}
+	}
+	infoList := model.NewSubscribePush().GetInfoByIds(IC.MgoBidding, IC.DB.Mongo.Bidding.Collection, IC.DB.Mongo.Bidding.CollectionBack, pushCas, false)
+	for _, info := range infoList {
+		if info.Area != "" && info.Area != "全国" {
+			regin = append(regin, info.Area)
+		}
+	}
+	//区域人员校验
+	userArr := model.Distributor(regin, common.IntAll(in.EntId), common.IntAll(in.EntUserId))
+	for _, uid := range staffs {
+		check := false
+		for _, user := range userArr {
+			if user.Id == common.IntAll(uid) {
+				check = true
+				break
+			}
+		}
+		if !check {
+			return &bxsubscribe.StatusResp{ErrorCode: -1, ErrorMsg: "选择人员异常"}, nil
+		}
+	}
+	//查询分发信息内容
+	msgRes := IC.BaseServiceMysql.SelectBySql(fmt.Sprintf("SELECT * FROM pushentniche WHERE id in ('%s') and entid =? and source = 2 ", strings.Join(pushIds, "','")), in.EntId)
+	if msgRes == nil || len(*msgRes) == 0 {
+		return &bxsubscribe.StatusResp{ErrorCode: -1, ErrorMsg: "获取分发信息内容异常"}, nil
+	}
+	//分发数据库修改
+	ok := IC.BaseServiceMysql.ExecTx("分发数据库修改", func(tx *sql.Tx) bool {
+		insertRow := []string{"entid", "deptid", "infoid", "matchkeys", "type", "product", "matchways", "matchitems", "disid", "source", "date", "userid", "isvisit", "visittime", "pid"}
+		msgItems := []string{"entid", "deptid", "infoid", "matchkeys", "type", "product", "matchways", "matchitems", "disid"}
+		dateNew := time.Now().Unix()
+		for _, m := range *msgRes {
+			var msgValues, insertValue []interface{}
+			for _, key := range msgItems {
+				msgValues = append(msgValues, m[key])
+			}
+			for _, uid := range staffs {
+				insertValue = append(insertValue, msgValues...)
+				insertValue = append(insertValue, []interface{}{3, dateNew, uid, nil, nil, m["id"]}...)
+			}
+			affected, _ := IC.BaseServiceMysql.InsertBatchByTx(tx, "pushentniche", insertRow, insertValue)
+			if affected == 0 {
+				return false
+			}
+		}
+		return true
+	})
+	//清除推送列表缓存
+	for _, staff := range staffs {
+		//today
+		redis.Del("pushcache_2_b", fmt.Sprintf("entnichepush_%s", staff))
+
+		//all
+		redis.Del("pushcache_2_a", fmt.Sprintf("all_entnichepush_%s", staff))
+		redis.Del("pushcache_2_a", fmt.Sprintf("all_entnichepush_vip_%s", staff))
+		redis.Del("pushcache_2_a", fmt.Sprintf("all_entnichepush_member_%s", staff))
+	}
+
+	if !ok {
+		return &bxsubscribe.StatusResp{ErrorCode: -1, ErrorMsg: "数据分发异常"}, nil
+	}
+	return &bxsubscribe.StatusResp{Status: 1}, nil
+}

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

@@ -57,3 +57,21 @@ func (s *BxsubscribeServer) GetKey(ctx context.Context, in *bxsubscribe.GetKeyRe
 	l := logic.NewGetKeyLogic(ctx, s.svcCtx)
 	return l.GetKey(in)
 }
+
+// 信息分发
+func (s *BxsubscribeServer) MsgDistributor(ctx context.Context, in *bxsubscribe.MsgDistributorReq) (*bxsubscribe.StatusResp, error) {
+	l := logic.NewMsgDistributorLogic(ctx, s.svcCtx)
+	return l.MsgDistributor(in)
+}
+
+// 手动分发人员查询
+func (s *BxsubscribeServer) GetDistributor(ctx context.Context, in *bxsubscribe.GetDistributorReq) (*bxsubscribe.DistributorResp, error) {
+	l := logic.NewGetDistributorLogic(ctx, s.svcCtx)
+	return l.GetDistributor(in)
+}
+
+// 查看状态
+func (s *BxsubscribeServer) GetViewStatus(ctx context.Context, in *bxsubscribe.GetViewStatusReq) (*bxsubscribe.ViewStatusResp, error) {
+	l := logic.NewGetViewStatusLogic(ctx, s.svcCtx)
+	return l.GetViewStatus(in)
+}

+ 178 - 0
jyBXSubscribe/rpc/model/distributor.go

@@ -0,0 +1,178 @@
+package model
+
+import (
+	"app.yhyue.com/moapp/jybase/common"
+	IC "jyBXSubscribe/rpc/init"
+	"strings"
+)
+
+func AllDistributor(entId, entUserId int) []*User {
+	var (
+		users []*User
+	)
+	entInfo := EntInfo(entId, entUserId)
+	if entInfo.Role_admin_department {
+		users = *GetDisUsers(entId, entInfo.Dept.Id)
+	} else if entInfo.Role_admin_system {
+		users = *GetEntUsers(entId)
+	}
+	return users
+}
+func Distributor(region []string, entId, entUserId int) []*User {
+	var (
+		ss, users []*User
+	)
+	entInfo := EntInfo(entId, entUserId)
+	if entInfo.Role_admin_department {
+		users = *GetDisUsers(entId, entInfo.Dept.Id)
+	} else if entInfo.Role_admin_system {
+		users = *GetEntUsers(entId)
+	}
+	//获取所有分配权益的用户
+	powerUser := GetEntPowerUsers(entId)
+	//判断企业是否为商机管理企业
+	isEnt := GetIsEnt(entId)
+	regions := []string{}
+	for _, v := range region {
+		//剔除空与全国
+		if v == "" || strings.Contains(v, "全国") {
+			continue
+		}
+		regions = append(regions, v)
+	}
+
+	for _, v := range users {
+		var _n namePower
+		_n.entUserId = common.InterfaceToStr(v.Id)
+		_n.power = 1
+		n1 := powerUser[_n]
+		_n.power = 2
+		n2 := powerUser[_n]
+		if (isEnt && v.Power == 1) || n1 != 0 || n2 != 0 { //有权益用户 判断是否被设置分配区域
+			if len(regions) == 0 { //判断区域
+				ss = append(ss, v)
+				continue
+			}
+			var rule_id string
+			//有区域限制 过滤筛选
+			rules := IC.MainMysql.Find("entniche_user_rule", map[string]interface{}{"user_id": v.Id}, "rule_id,dept_id", "", -1, -1)
+			if rules != nil && len(*rules) > 0 {
+				if len(*rules) > 1 { //多条规则 查询优先级最高的规则
+					ruleIds := make(map[int]string)
+					for _, v2 := range *rules {
+						ruleIds[common.IntAll(v2["dept_id"])] = common.InterfaceToStr(v2["rule_id"])
+					}
+					//获取部门优先级
+					var ids []int
+					departSort(&ids, v.Dept_id)
+					ids = append(ids, v.Dept_id)
+					//Reverse(&ids)
+					for _, v1 := range ids {
+						if v2, ok := ruleIds[v1]; ok && v2 != "" {
+							rule_id = v2
+							break
+						}
+					}
+				} else {
+					rule_id = common.InterfaceToStr((*rules)[0]["rule_id"])
+				}
+				if rule_id != "" {
+					data, ok := IC.Mgo.FindById("entniche_distribute", rule_id, "")
+					if ok && data != nil && len(*data) > 0 {
+						o_area, _ := (*data)["o_area"].(map[string]interface{})
+						if regionCheck(o_area, regions) {
+							ss = append(ss, v)
+						}
+						continue //企业设置分发区域
+					}
+				}
+			}
+			if isEnt && v.Power == 1 { // 企业未分配规则 商机管理用户查询个人
+				data, ok := IC.Mgo.FindOne("entniche_rule", map[string]interface{}{
+					"i_userid": v.Id,
+					"i_entid":  entId,
+				})
+				if ok && data != nil && len(*data) > 0 {
+					o_entniche, _ := (*data)["o_entniche"].(map[string]interface{})
+					o_area, _ := o_entniche["o_area"].(map[string]interface{})
+					if regionCheck(o_area, regions) {
+						ss = append(ss, v)
+						continue //商机管理
+					}
+				}
+			}
+
+			// 企业未分配规则 非商机管理用户  判断是否分配大会员或超级订阅
+			//user表 判断区域是否符合
+			if (n1 != 0 || n2 != 0) && v.Phone != "" {
+				//查询user表订阅区域
+				data, ok := IC.Mgo.FindOne("user", map[string]interface{}{
+					"$or": []map[string]interface{}{{"s_phone": v.Phone}, {"s_m_phone": v.Phone}},
+				})
+				if ok && data != nil && len(*data) > 0 {
+					o_area := make(map[string]interface{})
+					i_member_status := common.IntAll((*data)["i_member_status"])
+					i_vip_status := common.IntAll((*data)["i_vip_status"])
+					o_member_jy, _ := (*data)["o_member_jy"].(map[string]interface{})
+					o_vipjy, _ := (*data)["o_vipjy"].(map[string]interface{})
+					if n2 != 0 && i_member_status > 0 { //有大会员权益 校验区域
+						o_area, _ = o_member_jy["o_area"].(map[string]interface{})
+						if regionCheck(o_area, regions) {
+							ss = append(ss, v)
+							continue
+						}
+					}
+					if n1 != 0 && i_vip_status > 0 { //有超级订阅权益 校验区域
+						o_area, _ = o_vipjy["o_area"].(map[string]interface{})
+						if regionCheck(o_area, regions) {
+							ss = append(ss, v)
+							continue
+						}
+					}
+				}
+			}
+		}
+
+	}
+
+	return ss
+}
+
+func regionCheck(o_area map[string]interface{}, regions []string) bool {
+	if o_area == nil || len(o_area) == 0 {
+		return true
+	} else {
+		regionBool := true
+		for _, v1 := range regions {
+			if _, ok1 := o_area[v1]; ok1 {
+				continue
+			} else {
+				regionBool = false
+				break
+			}
+		}
+		return regionBool
+	}
+}
+
+func departSort(ids *[]int, deptId int) {
+	list := IC.MainMysql.FindOne("entniche_department", map[string]interface{}{"id": deptId}, "id,pid", "")
+	if list != nil && len(*list) > 0 {
+		pid := common.IntAll((*list)["pid"])
+		if pid != 0 {
+			departSort(ids, pid)
+			*ids = append(*ids, pid)
+		}
+	}
+}
+
+// 数组倒序函数
+func Reverse(arr *[]int) {
+	var temp int
+	length := len(*arr)
+	for i := 0; i < length/2; i++ {
+		temp = (*arr)[i]
+		(*arr)[i] = (*arr)[length-1-i]
+		(*arr)[length-1-i] = temp
+	}
+}

+ 167 - 0
jyBXSubscribe/rpc/model/entity.go

@@ -0,0 +1,167 @@
+package model
+
+import (
+	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/date"
+	"encoding/json"
+	IC "jyBXSubscribe/rpc/init"
+	"strings"
+)
+
+type User struct {
+	Id        int
+	Name      string //员工姓名
+	Mail      string //邮箱
+	Phone     string //手机号
+	Dept_id   int    //部门id
+	Dept_name string //部门名称
+	//Role      string //角色
+	Power int //权限
+}
+
+type CurrentUser struct {
+	Role_admin_department bool        //是否是部门管理员
+	Role_admin_system     bool        //是否是系统管理员
+	Dept                  *Department //部门信息
+	BondPhone             string      //手机号
+	NickName              string      //昵称
+	HeadImageUrl          string      //头像
+	PersonalAuth          int         //个人认证
+	PersonalAuthReason    string      //个人认证不通过原因
+	User_power            int         //是否分配权限
+	User_name             string      //用户姓名
+}
+
+type Department struct {
+	Id         int
+	Name       string //部门名
+	Pid        int    //上级部门id
+	Pname      string //上级部门名称
+	Nodiff     int    //全员无差别接收 0:关闭 1:打开
+	Subdis     int    //订阅分发 0:关闭 1:打开
+	Aid        int    //管理员id
+	Aname      string //管理员姓名
+	Rname      string //角色名
+	User_count int    //该部门下员工的总数
+	Dept_count int    //该部门下子部门总数
+	Ent_id     int    //公司id
+}
+
+type namePower struct {
+	entUserId string
+	power     int //1 超级订阅权益 2大会员权益
+}
+
+const (
+	//角色
+	Role_admin_system     = 1 //系统管理员
+	Role_admin_department = 2 //部门管理员
+)
+
+// 当前登录用户的信息
+func EntInfo(entId, entUserId int) *CurrentUser {
+	currentUser := &CurrentUser{
+		Dept: &Department{},
+	}
+	user := IC.MainMysql.SelectBySql(`SELECT a.name as user_name from entniche_user a INNER JOIN entniche_user_role b on (a.id=b.user_id) where a.id=? and b.role_id=? limit 1`, entUserId, Role_admin_system)
+	if user != nil && len(*user) > 0 {
+		currentUser.Role_admin_system = true
+		currentUser.User_name, _ = (*user)[0]["user_name"].(string)
+		currentUser.User_power = 1
+		r := IC.MainMysql.SelectBySql(`SELECT id,name,subdis,nodiff from entniche_department where ent_id=? and pid=0 limit 1`, entId)
+		if r != nil && len(*r) == 1 {
+			department := JsonUnmarshal((*r)[0], &Department{}).(*Department)
+			if department != nil {
+				department.Pid = department.Id
+				currentUser.Dept = department
+			}
+		}
+	} else {
+		//角色、权限
+		r := IC.MainMysql.SelectBySql(`SELECT a.name as user_name,a.power as user_power,b.role_id,d.id as dept_id,d.name as dept_name,d.subdis as dept_subdis,d.nodiff as dept_nodiff,e.id as dept_pid from entniche_user a 
+			LEFT JOIN entniche_user_role b on (b.user_id=?) 
+			INNER JOIN entniche_department_user c on (a.id=? and a.id=c.user_id) 
+			INNER JOIN entniche_department d on (c.dept_id=d.id) 
+			INNER JOIN entniche_department e on (e.ent_id=? and e.pid=0) 
+			order by a.id desc limit 1`, entUserId, entUserId, entId)
+		if r != nil && len(*r) == 1 {
+			currentUser.User_name, _ = (*r)[0]["user_name"].(string)
+			currentUser.User_power = common.IntAll((*r)[0]["user_power"])
+			if common.IntAll((*r)[0]["role_id"]) == Role_admin_department {
+				currentUser.Role_admin_department = true
+			}
+			currentUser.Dept.Id = common.IntAll((*r)[0]["dept_id"])
+			currentUser.Dept.Pid = common.IntAll((*r)[0]["dept_pid"])
+			currentUser.Dept.Name = common.ObjToString((*r)[0]["dept_name"])
+			currentUser.Dept.Subdis = common.IntAll((*r)[0]["dept_subdis"])
+			currentUser.Dept.Nodiff = common.IntAll((*r)[0]["dept_nodiff"])
+		}
+	}
+	return currentUser
+}
+
+// map转结构体
+func JsonUnmarshal(m interface{}, s interface{}) interface{} {
+	var b []byte
+	if v, ok := m.(string); ok {
+		b = []byte(v)
+	} else if v, ok := m.([]byte); ok {
+		b = v
+	} else {
+		b, _ = json.Marshal(m)
+	}
+	json.Unmarshal(b, &s)
+	return s
+}
+
+// 获取部门下可以进行分发的人员(不包含部门名称和部门id)
+func GetDisUsers(entId, deptId int) *[]*User {
+	r := IC.MainMysql.SelectBySql(`select DISTINCT c.id,c.name,c.phone,c.power,b.dept_id from entniche_department_parent a 
+		INNER JOIN entniche_department_user b on (b.dept_id=? or (a.pid=? and a.id=b.dept_id)) 
+		INNER JOIN entniche_user c on (c.ent_id=? and b.user_id=c.id) 
+		order by convert(c.name using gbk) COLLATE gbk_chinese_ci asc`, deptId, deptId, entId)
+	users, _ := JsonUnmarshal(r, &[]*User{}).(*[]*User)
+	if users == nil {
+		return &[]*User{}
+	}
+	return users
+}
+
+// 获取企业下所有的员工(不包含部门名称和部门id)
+func GetEntUsers(entId int) *[]*User {
+	r := IC.MainMysql.SelectBySql(`select a.id,a.name,a.phone,a.power,b.dept_id from entniche_user a  LEFT JOIN entniche_department_user b on  (a.id=b.user_id )  where ent_id=?
+		order by convert(name using gbk) COLLATE gbk_chinese_ci asc`, entId)
+	users, _ := JsonUnmarshal(*r, &[]*User{}).(*[]*User)
+	if users == nil {
+		return &[]*User{}
+	}
+	return users
+}
+
+// 获取企业下分配权益的用户
+func GetEntPowerUsers(entId int) map[namePower]int {
+	nowFormat := date.NowFormat(date.Date_Short_Layout)
+	r := IC.MainMysql.SelectBySql(`select a.ent_user_id,b.product_type from entniche_power a  LEFT JOIN entniche_wait_empower b ON (a.wait_empower_id = b.id) where a.ent_id=? and a.status = 1 and b.start_time <=? and b.end_time>=? `, entId, nowFormat, nowFormat)
+	if r == nil {
+		return nil
+	}
+	data := make(map[namePower]int)
+	for _, v := range *r {
+		if strings.Contains(common.InterfaceToStr(v["product_type"]), "VIP") {
+			var _n namePower
+			_n.entUserId = common.InterfaceToStr(v["ent_user_id"])
+			_n.power = 1
+			data[_n] = 1
+		} else if strings.Contains(common.InterfaceToStr(v["product_type"]), "大会员") {
+			var _n namePower
+			_n.entUserId = common.InterfaceToStr(v["ent_user_id"])
+			_n.power = 2
+			data[_n] = 2
+		}
+	}
+	return data
+}
+
+func GetIsEnt(entId int) bool {
+	return IC.MainMysql.CountBySql(`select count(*) from entniche_info where id=? and status = 1`, entId) > 0
+}

+ 125 - 56
jyBXSubscribe/rpc/model/push.go

@@ -98,6 +98,9 @@ type SubPushQueryParam struct {
 	FileExists       string             //是否有附件;默认全部;1:有附件;-1:无附件
 	EntUserId        string             //商机管理用户id
 	DeptId           string             //商机管理用户部门id
+	IsRead           string             //是否已读
+	Source           string             //信息来源
+	Staffs           []string           //分发人员
 	BaseServiceMysql *mysql.Mysql
 	NewUserId        int64
 	IsEnt            bool
@@ -122,7 +125,7 @@ type KeyParam struct {
 }
 
 func (spqp *SubPushQueryParam) IsEmpty() bool {
-	return (spqp.SelectTime == "" || spqp.SelectTime == "all") && spqp.Area == "" && spqp.City == "" && spqp.Buyerclass == "" && spqp.Subscopeclass == "" && spqp.Subtype == "" && spqp.Key == "" && spqp.Price == "" && spqp.FileExists == ""
+	return (spqp.SelectTime == "" || spqp.SelectTime == "all") && spqp.Area == "" && spqp.City == "" && spqp.Buyerclass == "" && spqp.Subscopeclass == "" && spqp.Subtype == "" && spqp.Key == "" && spqp.Price == "" && spqp.FileExists == "" && len(spqp.Staffs) == 0 && spqp.Source == "" && spqp.IsRead == ""
 }
 
 type subscribePush struct {
@@ -280,7 +283,7 @@ func (s *subscribePush) Datas(spqp *SubPushQueryParam) (hasNextPage bool, total
 	start := (spqp.PageNum - 1) * spqp.PageSize
 	end := start + spqp.PageSize
 	//时间是今天,没有别的过滤条件--首先读取当前推送缓存数据 其次查询数据库
-	if nowFormat == date.FormatDateByInt64(&starttime, date.Date_Short_Layout) && spqp.Area == "" && spqp.City == "" && spqp.Buyerclass == "" && spqp.Subscopeclass == "" && spqp.Subtype == "" && spqp.Key == "" && spqp.Price == "" && spqp.FileExists == "" {
+	if nowFormat == date.FormatDateByInt64(&starttime, date.Date_Short_Layout) && spqp.Area == "" && spqp.City == "" && spqp.Buyerclass == "" && spqp.Subscopeclass == "" && spqp.Subtype == "" && spqp.Key == "" && spqp.Price == "" && spqp.FileExists == "" && len(spqp.Staffs) == 0 && spqp.Source == "" && spqp.IsRead == "" {
 		subPush := &SubPush{}
 		var err error
 		if spqp.IsEnt == false {
@@ -363,7 +366,7 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 	userStr := " "
 	leftJoinStr := " "
 	var (
-		countSql, searchSql, findSql string
+		countSql, findSql string
 	)
 	codeMap, err := IC.CodeLib.CodeTransformation(context.Background(), &codeservice.Request{})
 	if codeMap.Data == nil || err != nil {
@@ -374,47 +377,11 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 	if spqp.SelectInfoIds != nil && len(spqp.SelectInfoIds) > 0 {
 		countSql = fmt.Sprintf("select count(1) as count from %s a LEFT JOIN %s b ON a.infoid = b.infoid where %s", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, fmt.Sprintf("a.id in ('%s')", strings.Join(spqp.SelectInfoIds, "','")))
 		logx.Info("countSql", countSql)
-		searchSql = fmt.Sprintf(" from %s a LEFT JOIN %s b ON a.infoid = b.infoid where %s order by a.date desc,a.id desc", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, fmt.Sprintf("a.id in ('%s')", strings.Join(spqp.SelectInfoIds, "','")))
+		findSql = fmt.Sprintf("select a.id,a.date,a.infoid,a.isvisit,a.matchkeys,a.type,b.isvalidfile as attachment_count from %s a LEFT JOIN %s b ON a.infoid = b.infoid where %s order by a.date desc,a.id desc", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, fmt.Sprintf("a.id in ('%s')", strings.Join(spqp.SelectInfoIds, "','")))
 		//查询总数
 		count = spqp.BaseServiceMysql.CountBySql(countSql)
-		findSql = "select a.id,a.date,a.infoid,a.isvisit,a.matchkeys,a.type,b.isvalidfile as attachment_count"
 	} else {
-		if spqp.IsEnt {
-			isNew := 1
-			//商机管理判断
-			newCount := IC.MainMysql.CountBySql("select  count(id) from  entniche_info where  id =? and  isNew != 1 and  status=1", spqp.EntId)
-			if newCount > 0 {
-				//新商机管理
-				isNew = 0
-			}
-			if isNew == 1 {
-				//企业主体是企业的企业查询
-				userStr = fmt.Sprintf("   a.entid='%s' and (a.source > 1) ", spqp.EntId)
-			} else {
-				userStr = fmt.Sprintf("   a.entid='%s' ", spqp.EntId)
-			}
-		} else {
-			if spqp.BuySubject == 1 {
-				//企业主体是企业的个人查询
-				if spqp.UserType == SubVipFlag {
-					userStr = fmt.Sprintf("  a.userid='%s' and (  a.product=1 or a.source>1     ) ", common.If(s.ModuleFlag == EntnicheFlag, spqp.EntUserId, common.InterfaceToStr(spqp.NewUserId)))
-				} else if spqp.UserType == MemberFlag {
-					userStr = fmt.Sprintf("  a.userid='%s' and (  a.product=2  or a.source>1  ) ", common.If(s.ModuleFlag == EntnicheFlag, spqp.EntUserId, common.InterfaceToStr(spqp.NewUserId)))
-				} else {
-					userStr = fmt.Sprintf("  a.userid='%s' and (  a.product is null  or a.source>1  ) ", common.If(s.ModuleFlag == EntnicheFlag, spqp.EntUserId, common.InterfaceToStr(spqp.NewUserId)))
-				}
-			} else {
-				if s.ModuleFlag == EntnicheFlag {
-					//老商机管理个人订阅查询
-					userStr = fmt.Sprintf("  a.userid='%s'  and a.product is null", common.If(s.ModuleFlag == EntnicheFlag, spqp.EntUserId, common.InterfaceToStr(spqp.NewUserId)))
-				} else {
-					//个人订阅查询
-					userStr = fmt.Sprintf("  a.userid='%s'", common.If(s.ModuleFlag == EntnicheFlag, spqp.EntUserId, common.InterfaceToStr(spqp.NewUserId)))
-				}
-
-			}
-		}
-
+		//公共查询条件
 		//时间
 		if starttime > 0 && endtime > 0 {
 			userStr += fmt.Sprintf(" and a.date>=%d and a.date<=%d", starttime, endtime)
@@ -423,6 +390,7 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 		} else if starttime == 0 && endtime > 0 {
 			userStr += fmt.Sprintf(" and a.date<=%d", endtime)
 		}
+
 		if spqp.Area != "" || spqp.City != "" {
 			var sqlAreaCity = ""
 			//城市
@@ -545,25 +513,126 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 				querys = append(querys, fmt.Sprintf("b.isvalidfile =0 "))
 			}
 		}
-		if len(querys) > 1 {
-			countSql = fmt.Sprintf("select count(1) as count from %s  a STRAIGHT_JOIN %s b ON %s and a.infoid = b.infoid  %s where %s", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, userStr, leftJoinStr, strings.Join(querys, " and "))
+
+		if spqp.IsEnt {
+			var staffs []string
+			userStr += fmt.Sprintf(" and  a.entid='%s' ", spqp.EntId)
+
+			//判断是企业管理员还是部门管理员 部门管理员获取所有子部门
+			userEnt := EntInfo(common.IntAll(spqp.EntId), common.IntAll(spqp.EntUserId))
+			if !(userEnt.Role_admin_system || userEnt.Role_admin_department) {
+				result = []*bxsubscribe.SubscribeInfo{}
+				return
+			}
+			if userEnt.Role_admin_department { //部门管理员 获取所有部门和子部门员工
+				users := GetDisUsers(common.IntAll(spqp.EntId), userEnt.Dept.Id)
+				if users != nil && len(*users) > 0 {
+					for _, v := range *users {
+						if len(spqp.Staffs) > 0 {
+							for _, vv := range spqp.Staffs {
+								if fmt.Sprintf("%d", v.Id) == vv {
+									staffs = append(staffs, common.InterfaceToStr(v.Id))
+								}
+							}
+						} else {
+							staffs = append(staffs, common.InterfaceToStr(v.Id))
+						}
+					}
+				} else {
+					log.Printf("部门管理员为获取到部门员工:%s", spqp.EntUserId)
+					result = []*bxsubscribe.SubscribeInfo{}
+					return
+				}
+			} else if len(spqp.Staffs) > 0 {
+				staffs = spqp.Staffs
+			}
+
+			// 无查询分配人员、是否已读
+			if spqp.IsRead == "" && len(staffs) == 0 {
+				//查询数量(需要去重)
+				//if len(querys) > 1 {
+				countSql = fmt.Sprintf("select count(1) from %s a STRAIGHT_JOIN %s b ON  a.infoid = b.infoid  %s where  %s %s and a.source = 2", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, leftJoinStr, strings.Join(querys, " and "), userStr)
+				//} else {
+				//	countSql = fmt.Sprintf("select count(1) from %s a WHERE 1=1 %s ", aboutDbMsg[s.ModuleFlag].MysqlTable, userStr)
+				//}
+				//列表查询
+				findSql = fmt.Sprintf("select a.id,a.infoid,a.matchkeys,b.isvalidfile as attachment_count from %s a STRAIGHT_JOIN %s b ON a.infoid = b.infoid  %s where  %s %s and a.source = 2 order by a.date desc,a.id desc",
+					aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, leftJoinStr, strings.Join(querys, " and "), userStr)
+			} else {
+				//查询分配人员或是否已读
+				staffQuery := " 1=1 "
+				if len(staffs) > 0 {
+					staffQuery += fmt.Sprintf(" and  a.userid in ('%s')  ", strings.Join(staffs, "','"))
+				}
+				if spqp.IsRead != "" {
+					if spqp.IsRead == "0" {
+						staffQuery += " and a.isvisit IS NULL"
+					} else if spqp.IsRead == "1" {
+						staffQuery += " and a.isvisit=1"
+					}
+				}
+				//if len(querys) > 1 {
+				countSql = fmt.Sprintf("select count(1) from %s a STRAIGHT_JOIN %s b ON  a.infoid = b.infoid  %s where a.source=2 %s and %s and ((%s) or EXISTS (SELECT 1 from %s c STRAIGHT_JOIN %s b ON c.infoid = b.infoid  %s WHERE c.source=3 %s and %s and a.id=c.pid and (%s))) ", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, leftJoinStr, userStr, strings.Join(querys, " and "), staffQuery, aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, leftJoinStr, strings.ReplaceAll(userStr, "a.", "c."), strings.Join(querys, " and "), strings.ReplaceAll(staffQuery, "a.", "c."))
+				//} else {
+				//	countSql = fmt.Sprintf("select count(1) from %s a WHERE a.source=2 %s and ((%s) or EXISTS (SELECT 1 from %s c WHERE c.source=3 %s and a.id=pid and (%s))) ", aboutDbMsg[s.ModuleFlag].MysqlTable, userStr, staffQuery, aboutDbMsg[s.ModuleFlag].MysqlTable, strings.ReplaceAll(userStr, "a.", "c."), strings.ReplaceAll(staffQuery, "a.", "c."))
+				//}
+				//列表查询
+				findSql = fmt.Sprintf("select a.id,a.infoid,a.matchkeys,b.isvalidfile as attachment_count from %s a STRAIGHT_JOIN %s b ON  a.infoid = b.infoid  %s where a.source=2 %s and %s and ((%s) or EXISTS (SELECT 1 from %s c STRAIGHT_JOIN %s b ON c.infoid = b.infoid  %s WHERE c.source=3 %s and %s and a.id=c.pid and (%s))) order by a.date desc,a.id desc ", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, leftJoinStr, userStr, strings.Join(querys, " and "), staffQuery, aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, leftJoinStr, strings.ReplaceAll(userStr, "a.", "c."), strings.Join(querys, " and "), strings.ReplaceAll(staffQuery, "a.", "c."))
+			}
 		} else {
-			countSql = fmt.Sprintf("select count(1) as count from %s  a where %s", aboutDbMsg[s.ModuleFlag].MysqlTable, userStr)
+			// 是否已读
+			if spqp.IsRead != "" {
+				if spqp.IsRead == "0" {
+					userStr += " and a.isvisit IS NULL"
+				} else if spqp.IsRead == "1" {
+					userStr += " and a.isvisit=1"
+				}
+			}
+			// 信息来源
+			if spqp.Source == "1" || spqp.Source == "2" || spqp.Source == "3" {
+				userStr += " and a.source=" + spqp.Source
+			}
+
+			if spqp.BuySubject == 1 {
+				//企业主体是企业的个人查询
+				if spqp.UserType == SubVipFlag {
+					userStr += fmt.Sprintf(" and  a.userid='%s' and (  a.product=1 or a.source>1     ) ", common.If(s.ModuleFlag == EntnicheFlag, spqp.EntUserId, common.InterfaceToStr(spqp.NewUserId)))
+				} else if spqp.UserType == MemberFlag {
+					userStr += fmt.Sprintf(" and  a.userid='%s' and (  a.product=2  or a.source>1  ) ", common.If(s.ModuleFlag == EntnicheFlag, spqp.EntUserId, common.InterfaceToStr(spqp.NewUserId)))
+				} else {
+					userStr += fmt.Sprintf(" and  a.userid='%s' and (  a.product is null  or a.source>1  ) ", common.If(s.ModuleFlag == EntnicheFlag, spqp.EntUserId, common.InterfaceToStr(spqp.NewUserId)))
+				}
+			} else {
+				if s.ModuleFlag == EntnicheFlag {
+					//老商机管理个人订阅查询
+					userStr += fmt.Sprintf(" and  a.userid='%s'  and a.product is null", common.If(s.ModuleFlag == EntnicheFlag, spqp.EntUserId, common.InterfaceToStr(spqp.NewUserId)))
+				} else {
+					//个人订阅查询
+					userStr += fmt.Sprintf(" and  a.userid='%s'", common.If(s.ModuleFlag == EntnicheFlag, spqp.EntUserId, common.InterfaceToStr(spqp.NewUserId)))
+				}
+			}
+
+			//查询数量
+			//if len(querys) > 1 {
+			countSql = fmt.Sprintf("select count(1) as count from %s  a STRAIGHT_JOIN %s b ON a.infoid = b.infoid  %s where 1=1 %s and %s", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, leftJoinStr, userStr, strings.Join(querys, " and "))
+			//} else {
+			//	countSql = fmt.Sprintf("select count(1) as count from %s  a where 1=1 %s", aboutDbMsg[s.ModuleFlag].MysqlTable, userStr)
+			//}
+			//列表查询语句
+			findSql = "select a.id,a.date,a.infoid,a.isvisit,a.matchkeys,a.type,b.isvalidfile as attachment_count"
+			if s.ModuleFlag == EntnicheFlag {
+				findSql += ", IF(a.source is NULL,1,a.source) as  source "
+			}
+			if s.ModuleFlag != MemberFlag && s.ModuleFlag != EntnicheFlag {
+				findSql += ",a.isvip"
+			}
+			findSql = fmt.Sprintf("%s from %s  a STRAIGHT_JOIN %s b ON 1=1 %s and a.infoid = b.infoid  %s where %s"+
+				" order by a.date desc,a.id desc", findSql, aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, userStr, leftJoinStr, strings.Join(querys, " and "))
 		}
-		logx.Info("countSql", countSql)
-		searchSql = fmt.Sprintf(" from %s  a STRAIGHT_JOIN %s b ON %s and a.infoid = b.infoid  %s where %s"+
-			" order by a.date desc,a.id desc", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, userStr, leftJoinStr, strings.Join(querys, " and "))
 		//查询总数
+		logx.Info("countSql", countSql)
 		count = spqp.BaseServiceMysql.CountBySql(countSql)
-		findSql = "select a.id,a.date,a.infoid,a.isvisit,a.matchkeys,a.type,b.isvalidfile as attachment_count"
-		if s.ModuleFlag == EntnicheFlag {
-			findSql += ", IF(a.source is NULL,1,a.source) as  source "
-		}
-	}
-	if s.ModuleFlag != MemberFlag && s.ModuleFlag != EntnicheFlag {
-		findSql += ",a.isvip"
 	}
-	findSql += searchSql
 	if isLimit {
 		findSql += fmt.Sprintf(" limit %d,%d", (spqp.PageNum-1)*size, size)
 	}
@@ -1567,7 +1636,7 @@ func (s *subscribePush) Keys(spqp *KeyParam) (result []*bxsubscribe.KeyItems) {
 
 }
 
-//关键词处理
+// 关键词处理
 func KeyHandle(a_items map[string]interface{}) []interface{} {
 	keyArr := []interface{}{}
 	if a_items["a_key"] != nil {

Diff do ficheiro suprimidas por serem muito extensas
+ 871 - 268
jyBXSubscribe/rpc/type/bxsubscribe/bxsubscribe.pb.go


+ 114 - 0
jyBXSubscribe/rpc/type/bxsubscribe/bxsubscribe_grpc.pb.go

@@ -34,6 +34,12 @@ type BxsubscribeClient interface {
 	SetRead(ctx context.Context, in *SetReadReq, opts ...grpc.CallOption) (*StatusResp, error)
 	//关键词获取
 	GetKey(ctx context.Context, in *GetKeyReq, opts ...grpc.CallOption) (*KeyResp, error)
+	//信息分发
+	MsgDistributor(ctx context.Context, in *MsgDistributorReq, opts ...grpc.CallOption) (*StatusResp, error)
+	//手动分发人员查询
+	GetDistributor(ctx context.Context, in *GetDistributorReq, opts ...grpc.CallOption) (*DistributorResp, error)
+	//查看状态
+	GetViewStatus(ctx context.Context, in *GetViewStatusReq, opts ...grpc.CallOption) (*ViewStatusResp, error)
 }
 
 type bxsubscribeClient struct {
@@ -98,6 +104,33 @@ func (c *bxsubscribeClient) GetKey(ctx context.Context, in *GetKeyReq, opts ...g
 	return out, nil
 }
 
+func (c *bxsubscribeClient) MsgDistributor(ctx context.Context, in *MsgDistributorReq, opts ...grpc.CallOption) (*StatusResp, error) {
+	out := new(StatusResp)
+	err := c.cc.Invoke(ctx, "/bxsubscribe.Bxsubscribe/MsgDistributor", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *bxsubscribeClient) GetDistributor(ctx context.Context, in *GetDistributorReq, opts ...grpc.CallOption) (*DistributorResp, error) {
+	out := new(DistributorResp)
+	err := c.cc.Invoke(ctx, "/bxsubscribe.Bxsubscribe/GetDistributor", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *bxsubscribeClient) GetViewStatus(ctx context.Context, in *GetViewStatusReq, opts ...grpc.CallOption) (*ViewStatusResp, error) {
+	out := new(ViewStatusResp)
+	err := c.cc.Invoke(ctx, "/bxsubscribe.Bxsubscribe/GetViewStatus", 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
@@ -114,6 +147,12 @@ type BxsubscribeServer interface {
 	SetRead(context.Context, *SetReadReq) (*StatusResp, error)
 	//关键词获取
 	GetKey(context.Context, *GetKeyReq) (*KeyResp, error)
+	//信息分发
+	MsgDistributor(context.Context, *MsgDistributorReq) (*StatusResp, error)
+	//手动分发人员查询
+	GetDistributor(context.Context, *GetDistributorReq) (*DistributorResp, error)
+	//查看状态
+	GetViewStatus(context.Context, *GetViewStatusReq) (*ViewStatusResp, error)
 	mustEmbedUnimplementedBxsubscribeServer()
 }
 
@@ -139,6 +178,15 @@ func (UnimplementedBxsubscribeServer) SetRead(context.Context, *SetReadReq) (*St
 func (UnimplementedBxsubscribeServer) GetKey(context.Context, *GetKeyReq) (*KeyResp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method GetKey not implemented")
 }
+func (UnimplementedBxsubscribeServer) MsgDistributor(context.Context, *MsgDistributorReq) (*StatusResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method MsgDistributor not implemented")
+}
+func (UnimplementedBxsubscribeServer) GetDistributor(context.Context, *GetDistributorReq) (*DistributorResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method GetDistributor not implemented")
+}
+func (UnimplementedBxsubscribeServer) GetViewStatus(context.Context, *GetViewStatusReq) (*ViewStatusResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method GetViewStatus not implemented")
+}
 func (UnimplementedBxsubscribeServer) mustEmbedUnimplementedBxsubscribeServer() {}
 
 // UnsafeBxsubscribeServer may be embedded to opt out of forward compatibility for this service.
@@ -260,6 +308,60 @@ func _Bxsubscribe_GetKey_Handler(srv interface{}, ctx context.Context, dec func(
 	return interceptor(ctx, in, info, handler)
 }
 
+func _Bxsubscribe_MsgDistributor_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(MsgDistributorReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(BxsubscribeServer).MsgDistributor(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/bxsubscribe.Bxsubscribe/MsgDistributor",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(BxsubscribeServer).MsgDistributor(ctx, req.(*MsgDistributorReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _Bxsubscribe_GetDistributor_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(GetDistributorReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(BxsubscribeServer).GetDistributor(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/bxsubscribe.Bxsubscribe/GetDistributor",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(BxsubscribeServer).GetDistributor(ctx, req.(*GetDistributorReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _Bxsubscribe_GetViewStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(GetViewStatusReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(BxsubscribeServer).GetViewStatus(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/bxsubscribe.Bxsubscribe/GetViewStatus",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(BxsubscribeServer).GetViewStatus(ctx, req.(*GetViewStatusReq))
+	}
+	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)
@@ -291,6 +393,18 @@ var Bxsubscribe_ServiceDesc = grpc.ServiceDesc{
 			MethodName: "GetKey",
 			Handler:    _Bxsubscribe_GetKey_Handler,
 		},
+		{
+			MethodName: "MsgDistributor",
+			Handler:    _Bxsubscribe_MsgDistributor_Handler,
+		},
+		{
+			MethodName: "GetDistributor",
+			Handler:    _Bxsubscribe_GetDistributor_Handler,
+		},
+		{
+			MethodName: "GetViewStatus",
+			Handler:    _Bxsubscribe_GetViewStatus_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "bxsubscribe.proto",

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff