浏览代码

Merge branch 'dev/v1.0.1_xzh' of BaseService/biService into feature/v1.0.1

xuzhiheng 2 年之前
父节点
当前提交
034505f816

+ 1 - 0
README.md

@@ -1,5 +1,6 @@
 bi页面的相关服务接口
 goctl rpc proto -src biService.proto -dir .
+goctl rpc protoc biService.proto --go_out=. --go-grpc_out=. --zrpc_out=.
 goctl api go -api biService.api -dir .
 go test -v -coverprofile=coverage
 go tool cover -html=coverage -o coverage.html

+ 8 - 2
api/biService.api

@@ -30,6 +30,11 @@ type (
 		PositionId int64 `header:"userPositionId,optional"`
 	}
 
+	drawClueReq {
+		PositionId int64 `json:"positionId,optional"`
+		Count      int64 `json:"count,optional"`
+	}
+
 	callReq {
 		PositionId int64  `header:"userPositionId,optional"`
 		Phone      string `json:"phone"`
@@ -43,7 +48,8 @@ service biService-api {
 	post /biService/addProject (addProjectReq) returns (resp)
 	@handler GetInfoId
 	post /biService/getInfoId (getInfoIdReq) returns (resp)
+	@handler DrawClue
+	post /biService/drawClue (drawClueReq) returns (resp)
 	@handler Call
-	//拨打电话
-	post /biService/call (callReq) returns (resp)
+	post /biService/call (callReq) returns (resp)	//拨打电话
 }

+ 28 - 0
api/internal/handler/drawcluehandler.go

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

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

@@ -27,6 +27,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/biService/getInfoId",
 				Handler: GetInfoIdHandler(serverCtx),
 			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/biService/drawClue",
+				Handler: DrawClueHandler(serverCtx),
+			},
 			{
 				Method:  http.MethodPost,
 				Path:    "/biService/call",

+ 34 - 0
api/internal/logic/drawcluelogic.go

@@ -0,0 +1,34 @@
+package logic
+
+import (
+	"context"
+
+	"bp.jydev.jianyu360.cn/BaseService/biService/api/internal/svc"
+	"bp.jydev.jianyu360.cn/BaseService/biService/api/internal/types"
+	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/biservice"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type DrawClueLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewDrawClueLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DrawClueLogic {
+	return &DrawClueLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *DrawClueLogic) DrawClue(req *types.DrawClueReq) (resp *types.Resp, err error) {
+	// todo: add your logic here and delete this line
+	res, err := l.svcCtx.BiServiceRpc.DrawClue(l.ctx, &biservice.DrawClueReq{
+		PositionId: req.PositionId,
+		Count:      req.Count,
+	})
+	return &types.Resp{Error_code: res.ErrorCode, Error_msg: res.ErrorMsg, Data: res.Data}, err
+}

+ 5 - 0
api/internal/types/types.go

@@ -30,6 +30,11 @@ type GetInfoIdReq struct {
 	PositionId int64 `header:"userPositionId,optional"`
 }
 
+type DrawClueReq struct {
+	PositionId int64 `json:"positionId,optional"`
+	Count      int64 `json:"count,optional"`
+}
+
 type CallReq struct {
 	PositionId int64  `header:"userPositionId,optional"`
 	Phone      string `json:"phone"`

+ 1 - 1
go.mod

@@ -8,7 +8,7 @@ require (
 	github.com/gogf/gf/v2 v2.0.6
 	github.com/golang/protobuf v1.5.2
 	github.com/nsqio/go-nsq v1.1.0
-	github.com/zeromicro/go-zero v1.4.2
+	github.com/zeromicro/go-zero v1.3.5
 	google.golang.org/grpc v1.51.0
 	google.golang.org/protobuf v1.28.1
 )

+ 1 - 0
go.sum

@@ -604,6 +604,7 @@ github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9 h1:k/gmLsJDWwWqbLC
 github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9/go.mod h1:E1AXubJBdNmFERAOucpDIxNzeGfLzg0mYh+UfMWdChA=
 github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
 github.com/zeromicro/go-zero v1.3.2/go.mod h1:DEj3Fwj1Ui1ltsgf6YqwTL9nD4+tYzIRX0c1pWtQo1E=
+github.com/zeromicro/go-zero v1.3.5 h1:+3T4Rx/5o/EgLuCE3Qo4X0i+3GCHRYEgkabmfKhhQ7Q=
 github.com/zeromicro/go-zero v1.3.5/go.mod h1:wh4o794b7Ul3W0k35Pw9nc3iB4O0OpaQTMQz/PJc1bc=
 github.com/zeromicro/go-zero v1.4.2 h1:1P9TuzxONqxQG3Bvpk7r7vPOGEnfXn3lTX/4W5Y2GlQ=
 github.com/zeromicro/go-zero v1.4.2/go.mod h1:OK8ilGkhRzhi1NRRC76h5qTNFm6NbsYrUqld38i4NF4=

+ 6 - 0
rpc/biService.proto

@@ -51,6 +51,11 @@ message GetInfoIdResp {
 	repeated string data = 3;
 }
 
+message drawClueReq {
+	int64 positionId = 1;
+	int64 count = 2;
+}
+
 message CallReq{
 	int64 position_id =1;
 	string phone =2; 
@@ -66,5 +71,6 @@ service BiService {
 	rpc myDataAsset (MyDataAssetReq) returns (MyDataAssetResp); //我的数据资产
 	rpc addProject (AddProjectReq) returns (AddProjectResp); //添加项目
 	rpc getInfoId (AddProjectReq) returns (GetInfoIdResp); //获取添加过项目的信息id
+	rpc drawClue (drawClueReq) returns (AddProjectResp); //领取线索
 	rpc Call (CallReq) returns (Resp); //外呼集成
 }

+ 8 - 1
rpc/biservice/biservice.go

@@ -1,4 +1,4 @@
-// Code generated by goctl. DO NOT EDIT!
+// Code generated by goctl. DO NOT EDIT.
 // Source: biService.proto
 
 package biservice
@@ -17,6 +17,7 @@ type (
 	AddProjectReq   = pb.AddProjectReq
 	AddProjectResp  = pb.AddProjectResp
 	CallReq         = pb.CallReq
+	DrawClueReq     = pb.DrawClueReq
 	GetInfoIdResp   = pb.GetInfoIdResp
 	MyDataAsset     = pb.MyDataAsset
 	MyDataAssetReq  = pb.MyDataAssetReq
@@ -27,6 +28,7 @@ type (
 		MyDataAsset(ctx context.Context, in *MyDataAssetReq, opts ...grpc.CallOption) (*MyDataAssetResp, error)
 		AddProject(ctx context.Context, in *AddProjectReq, opts ...grpc.CallOption) (*AddProjectResp, error)
 		GetInfoId(ctx context.Context, in *AddProjectReq, opts ...grpc.CallOption) (*GetInfoIdResp, error)
+		DrawClue(ctx context.Context, in *DrawClueReq, opts ...grpc.CallOption) (*AddProjectResp, error)
 		Call(ctx context.Context, in *CallReq, opts ...grpc.CallOption) (*Resp, error)
 	}
 
@@ -56,6 +58,11 @@ func (m *defaultBiService) GetInfoId(ctx context.Context, in *AddProjectReq, opt
 	return client.GetInfoId(ctx, in, opts...)
 }
 
+func (m *defaultBiService) DrawClue(ctx context.Context, in *DrawClueReq, opts ...grpc.CallOption) (*AddProjectResp, error) {
+	client := pb.NewBiServiceClient(m.cli.Conn())
+	return client.DrawClue(ctx, in, opts...)
+}
+
 func (m *defaultBiService) Call(ctx context.Context, in *CallReq, opts ...grpc.CallOption) (*Resp, error) {
 	client := pb.NewBiServiceClient(m.cli.Conn())
 	return client.Call(ctx, in, opts...)

+ 30 - 0
rpc/internal/logic/drawcluelogic.go

@@ -0,0 +1,30 @@
+package logic
+
+import (
+	"context"
+
+	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/internal/svc"
+	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/pb"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type DrawClueLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewDrawClueLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DrawClueLogic {
+	return &DrawClueLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *DrawClueLogic) DrawClue(in *pb.DrawClueReq) (*pb.AddProjectResp, error) {
+	// todo: add your logic here and delete this line
+
+	return service.DrawClue(in), nil
+}

+ 6 - 1
rpc/internal/server/biserviceserver.go

@@ -1,4 +1,4 @@
-// Code generated by goctl. DO NOT EDIT!
+// Code generated by goctl. DO NOT EDIT.
 // Source: biService.proto
 
 package server
@@ -37,6 +37,11 @@ func (s *BiServiceServer) GetInfoId(ctx context.Context, in *pb.AddProjectReq) (
 	return l.GetInfoId(in)
 }
 
+func (s *BiServiceServer) DrawClue(ctx context.Context, in *pb.DrawClueReq) (*pb.AddProjectResp, error) {
+	l := logic.NewDrawClueLogic(ctx, s.svcCtx)
+	return l.DrawClue(in)
+}
+
 func (s *BiServiceServer) Call(ctx context.Context, in *pb.CallReq) (*pb.Resp, error) {
 	l := logic.NewCallLogic(ctx, s.svcCtx)
 	return l.Call(in)

+ 117 - 40
rpc/pb/biService.pb.go

@@ -1,6 +1,6 @@
 // Code generated by protoc-gen-go. DO NOT EDIT.
 // versions:
-// 	protoc-gen-go v1.27.1
+// 	protoc-gen-go v1.28.1
 // 	protoc        v3.19.4
 // source: biService.proto
 
@@ -517,6 +517,61 @@ func (x *GetInfoIdResp) GetData() []string {
 	return nil
 }
 
+type DrawClueReq struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	PositionId int64 `protobuf:"varint,1,opt,name=positionId,proto3" json:"positionId,omitempty"`
+	Count      int64 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"`
+}
+
+func (x *DrawClueReq) Reset() {
+	*x = DrawClueReq{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_biService_proto_msgTypes[7]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *DrawClueReq) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*DrawClueReq) ProtoMessage() {}
+
+func (x *DrawClueReq) ProtoReflect() protoreflect.Message {
+	mi := &file_biService_proto_msgTypes[7]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use DrawClueReq.ProtoReflect.Descriptor instead.
+func (*DrawClueReq) Descriptor() ([]byte, []int) {
+	return file_biService_proto_rawDescGZIP(), []int{7}
+}
+
+func (x *DrawClueReq) GetPositionId() int64 {
+	if x != nil {
+		return x.PositionId
+	}
+	return 0
+}
+
+func (x *DrawClueReq) GetCount() int64 {
+	if x != nil {
+		return x.Count
+	}
+	return 0
+}
+
 type CallReq struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache
@@ -529,7 +584,7 @@ type CallReq struct {
 func (x *CallReq) Reset() {
 	*x = CallReq{}
 	if protoimpl.UnsafeEnabled {
-		mi := &file_biService_proto_msgTypes[7]
+		mi := &file_biService_proto_msgTypes[8]
 		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
 		ms.StoreMessageInfo(mi)
 	}
@@ -542,7 +597,7 @@ func (x *CallReq) String() string {
 func (*CallReq) ProtoMessage() {}
 
 func (x *CallReq) ProtoReflect() protoreflect.Message {
-	mi := &file_biService_proto_msgTypes[7]
+	mi := &file_biService_proto_msgTypes[8]
 	if protoimpl.UnsafeEnabled && x != nil {
 		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
 		if ms.LoadMessageInfo() == nil {
@@ -555,7 +610,7 @@ func (x *CallReq) ProtoReflect() protoreflect.Message {
 
 // Deprecated: Use CallReq.ProtoReflect.Descriptor instead.
 func (*CallReq) Descriptor() ([]byte, []int) {
-	return file_biService_proto_rawDescGZIP(), []int{7}
+	return file_biService_proto_rawDescGZIP(), []int{8}
 }
 
 func (x *CallReq) GetPositionId() int64 {
@@ -585,7 +640,7 @@ type Resp struct {
 func (x *Resp) Reset() {
 	*x = Resp{}
 	if protoimpl.UnsafeEnabled {
-		mi := &file_biService_proto_msgTypes[8]
+		mi := &file_biService_proto_msgTypes[9]
 		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
 		ms.StoreMessageInfo(mi)
 	}
@@ -598,7 +653,7 @@ func (x *Resp) String() string {
 func (*Resp) ProtoMessage() {}
 
 func (x *Resp) ProtoReflect() protoreflect.Message {
-	mi := &file_biService_proto_msgTypes[8]
+	mi := &file_biService_proto_msgTypes[9]
 	if protoimpl.UnsafeEnabled && x != nil {
 		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
 		if ms.LoadMessageInfo() == nil {
@@ -611,7 +666,7 @@ func (x *Resp) ProtoReflect() protoreflect.Message {
 
 // Deprecated: Use Resp.ProtoReflect.Descriptor instead.
 func (*Resp) Descriptor() ([]byte, []int) {
-	return file_biService_proto_rawDescGZIP(), []int{8}
+	return file_biService_proto_rawDescGZIP(), []int{9}
 }
 
 func (x *Resp) GetErrorCode() int64 {
@@ -702,27 +757,34 @@ var file_biService_proto_rawDesc = []byte{
 	0x52, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x65,
 	0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
 	0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61,
-	0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x40, 0x0a, 0x07,
-	0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x6f, 0x73, 0x69, 0x74,
-	0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x70, 0x6f,
-	0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x68, 0x6f, 0x6e,
-	0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x22, 0x5a,
-	0x0a, 0x04, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f,
-	0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x65, 0x72, 0x72, 0x6f,
-	0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d,
-	0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d,
-	0x73, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01,
-	0x28, 0x03, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x32, 0xb2, 0x01, 0x0a, 0x09, 0x42,
-	0x69, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x30, 0x0a, 0x0b, 0x6d, 0x79, 0x44, 0x61,
-	0x74, 0x61, 0x41, 0x73, 0x73, 0x65, 0x74, 0x12, 0x0f, 0x2e, 0x4d, 0x79, 0x44, 0x61, 0x74, 0x61,
-	0x41, 0x73, 0x73, 0x65, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x10, 0x2e, 0x4d, 0x79, 0x44, 0x61, 0x74,
-	0x61, 0x41, 0x73, 0x73, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2d, 0x0a, 0x0a, 0x61, 0x64,
-	0x64, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x0e, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x72,
-	0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x72,
-	0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2b, 0x0a, 0x09, 0x67, 0x65, 0x74,
-	0x49, 0x6e, 0x66, 0x6f, 0x49, 0x64, 0x12, 0x0e, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x6a,
-	0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x0e, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f,
-	0x49, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x17, 0x0a, 0x04, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x08,
+	0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x43, 0x0a, 0x0b,
+	0x64, 0x72, 0x61, 0x77, 0x43, 0x6c, 0x75, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1e, 0x0a, 0x0a, 0x70,
+	0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52,
+	0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x63,
+	0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e,
+	0x74, 0x22, 0x40, 0x0a, 0x07, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x12, 0x1f, 0x0a, 0x0b,
+	0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
+	0x03, 0x52, 0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x14, 0x0a,
+	0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x70, 0x68,
+	0x6f, 0x6e, 0x65, 0x22, 0x5a, 0x0a, 0x04, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1d, 0x0a, 0x0a, 0x65,
+	0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52,
+	0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x65, 0x72,
+	0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65,
+	0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75,
+	0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x32,
+	0xdd, 0x01, 0x0a, 0x09, 0x42, 0x69, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x30, 0x0a,
+	0x0b, 0x6d, 0x79, 0x44, 0x61, 0x74, 0x61, 0x41, 0x73, 0x73, 0x65, 0x74, 0x12, 0x0f, 0x2e, 0x4d,
+	0x79, 0x44, 0x61, 0x74, 0x61, 0x41, 0x73, 0x73, 0x65, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x10, 0x2e,
+	0x4d, 0x79, 0x44, 0x61, 0x74, 0x61, 0x41, 0x73, 0x73, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12,
+	0x2d, 0x0a, 0x0a, 0x61, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x0e, 0x2e,
+	0x41, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e,
+	0x41, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2b,
+	0x0a, 0x09, 0x67, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x49, 0x64, 0x12, 0x0e, 0x2e, 0x41, 0x64,
+	0x64, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x0e, 0x2e, 0x47, 0x65,
+	0x74, 0x49, 0x6e, 0x66, 0x6f, 0x49, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x29, 0x0a, 0x08, 0x64,
+	0x72, 0x61, 0x77, 0x43, 0x6c, 0x75, 0x65, 0x12, 0x0c, 0x2e, 0x64, 0x72, 0x61, 0x77, 0x43, 0x6c,
+	0x75, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x6a, 0x65,
+	0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x17, 0x0a, 0x04, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x08,
 	0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x05, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x42,
 	0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
@@ -739,7 +801,7 @@ func file_biService_proto_rawDescGZIP() []byte {
 	return file_biService_proto_rawDescData
 }
 
-var file_biService_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
+var file_biService_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
 var file_biService_proto_goTypes = []interface{}{
 	(*MyDataAssetReq)(nil),  // 0: MyDataAssetReq
 	(*MyDataAssetResp)(nil), // 1: MyDataAssetResp
@@ -748,8 +810,9 @@ var file_biService_proto_goTypes = []interface{}{
 	(*AddProjectResp)(nil),  // 4: AddProjectResp
 	(*AddProject)(nil),      // 5: AddProject
 	(*GetInfoIdResp)(nil),   // 6: GetInfoIdResp
-	(*CallReq)(nil),         // 7: CallReq
-	(*Resp)(nil),            // 8: Resp
+	(*DrawClueReq)(nil),     // 7: drawClueReq
+	(*CallReq)(nil),         // 8: CallReq
+	(*Resp)(nil),            // 9: Resp
 }
 var file_biService_proto_depIdxs = []int32{
 	2, // 0: MyDataAssetResp.data:type_name -> MyDataAsset
@@ -757,13 +820,15 @@ var file_biService_proto_depIdxs = []int32{
 	0, // 2: BiService.myDataAsset:input_type -> MyDataAssetReq
 	3, // 3: BiService.addProject:input_type -> AddProjectReq
 	3, // 4: BiService.getInfoId:input_type -> AddProjectReq
-	7, // 5: BiService.Call:input_type -> CallReq
-	1, // 6: BiService.myDataAsset:output_type -> MyDataAssetResp
-	4, // 7: BiService.addProject:output_type -> AddProjectResp
-	6, // 8: BiService.getInfoId:output_type -> GetInfoIdResp
-	8, // 9: BiService.Call:output_type -> Resp
-	6, // [6:10] is the sub-list for method output_type
-	2, // [2:6] is the sub-list for method input_type
+	7, // 5: BiService.drawClue:input_type -> drawClueReq
+	8, // 6: BiService.Call:input_type -> CallReq
+	1, // 7: BiService.myDataAsset:output_type -> MyDataAssetResp
+	4, // 8: BiService.addProject:output_type -> AddProjectResp
+	6, // 9: BiService.getInfoId:output_type -> GetInfoIdResp
+	4, // 10: BiService.drawClue:output_type -> AddProjectResp
+	9, // 11: BiService.Call:output_type -> Resp
+	7, // [7:12] is the sub-list for method output_type
+	2, // [2:7] is the sub-list for method input_type
 	2, // [2:2] is the sub-list for extension type_name
 	2, // [2:2] is the sub-list for extension extendee
 	0, // [0:2] is the sub-list for field type_name
@@ -860,7 +925,7 @@ func file_biService_proto_init() {
 			}
 		}
 		file_biService_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
-			switch v := v.(*CallReq); i {
+			switch v := v.(*DrawClueReq); i {
 			case 0:
 				return &v.state
 			case 1:
@@ -872,6 +937,18 @@ func file_biService_proto_init() {
 			}
 		}
 		file_biService_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*CallReq); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_biService_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
 			switch v := v.(*Resp); i {
 			case 0:
 				return &v.state
@@ -890,7 +967,7 @@ func file_biService_proto_init() {
 			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 			RawDescriptor: file_biService_proto_rawDesc,
 			NumEnums:      0,
-			NumMessages:   9,
+			NumMessages:   10,
 			NumExtensions: 0,
 			NumServices:   1,
 		},

+ 53 - 9
rpc/pb/biService_grpc.pb.go

@@ -1,6 +1,6 @@
 // Code generated by protoc-gen-go-grpc. DO NOT EDIT.
 // versions:
-// - protoc-gen-go-grpc v1.2.0
+// - protoc-gen-go-grpc v1.3.0
 // - protoc             v3.19.4
 // source: biService.proto
 
@@ -18,6 +18,14 @@ import (
 // Requires gRPC-Go v1.32.0 or later.
 const _ = grpc.SupportPackageIsVersion7
 
+const (
+	BiService_MyDataAsset_FullMethodName = "/BiService/myDataAsset"
+	BiService_AddProject_FullMethodName  = "/BiService/addProject"
+	BiService_GetInfoId_FullMethodName   = "/BiService/getInfoId"
+	BiService_DrawClue_FullMethodName    = "/BiService/drawClue"
+	BiService_Call_FullMethodName        = "/BiService/Call"
+)
+
 // BiServiceClient is the client API for BiService service.
 //
 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
@@ -25,6 +33,7 @@ type BiServiceClient interface {
 	MyDataAsset(ctx context.Context, in *MyDataAssetReq, opts ...grpc.CallOption) (*MyDataAssetResp, error)
 	AddProject(ctx context.Context, in *AddProjectReq, opts ...grpc.CallOption) (*AddProjectResp, error)
 	GetInfoId(ctx context.Context, in *AddProjectReq, opts ...grpc.CallOption) (*GetInfoIdResp, error)
+	DrawClue(ctx context.Context, in *DrawClueReq, opts ...grpc.CallOption) (*AddProjectResp, error)
 	Call(ctx context.Context, in *CallReq, opts ...grpc.CallOption) (*Resp, error)
 }
 
@@ -38,7 +47,7 @@ func NewBiServiceClient(cc grpc.ClientConnInterface) BiServiceClient {
 
 func (c *biServiceClient) MyDataAsset(ctx context.Context, in *MyDataAssetReq, opts ...grpc.CallOption) (*MyDataAssetResp, error) {
 	out := new(MyDataAssetResp)
-	err := c.cc.Invoke(ctx, "/BiService/myDataAsset", in, out, opts...)
+	err := c.cc.Invoke(ctx, BiService_MyDataAsset_FullMethodName, in, out, opts...)
 	if err != nil {
 		return nil, err
 	}
@@ -47,7 +56,7 @@ func (c *biServiceClient) MyDataAsset(ctx context.Context, in *MyDataAssetReq, o
 
 func (c *biServiceClient) AddProject(ctx context.Context, in *AddProjectReq, opts ...grpc.CallOption) (*AddProjectResp, error) {
 	out := new(AddProjectResp)
-	err := c.cc.Invoke(ctx, "/BiService/addProject", in, out, opts...)
+	err := c.cc.Invoke(ctx, BiService_AddProject_FullMethodName, in, out, opts...)
 	if err != nil {
 		return nil, err
 	}
@@ -56,7 +65,16 @@ func (c *biServiceClient) AddProject(ctx context.Context, in *AddProjectReq, opt
 
 func (c *biServiceClient) GetInfoId(ctx context.Context, in *AddProjectReq, opts ...grpc.CallOption) (*GetInfoIdResp, error) {
 	out := new(GetInfoIdResp)
-	err := c.cc.Invoke(ctx, "/BiService/getInfoId", in, out, opts...)
+	err := c.cc.Invoke(ctx, BiService_GetInfoId_FullMethodName, in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *biServiceClient) DrawClue(ctx context.Context, in *DrawClueReq, opts ...grpc.CallOption) (*AddProjectResp, error) {
+	out := new(AddProjectResp)
+	err := c.cc.Invoke(ctx, BiService_DrawClue_FullMethodName, in, out, opts...)
 	if err != nil {
 		return nil, err
 	}
@@ -65,7 +83,7 @@ func (c *biServiceClient) GetInfoId(ctx context.Context, in *AddProjectReq, opts
 
 func (c *biServiceClient) Call(ctx context.Context, in *CallReq, opts ...grpc.CallOption) (*Resp, error) {
 	out := new(Resp)
-	err := c.cc.Invoke(ctx, "/BiService/Call", in, out, opts...)
+	err := c.cc.Invoke(ctx, BiService_Call_FullMethodName, in, out, opts...)
 	if err != nil {
 		return nil, err
 	}
@@ -79,6 +97,7 @@ type BiServiceServer interface {
 	MyDataAsset(context.Context, *MyDataAssetReq) (*MyDataAssetResp, error)
 	AddProject(context.Context, *AddProjectReq) (*AddProjectResp, error)
 	GetInfoId(context.Context, *AddProjectReq) (*GetInfoIdResp, error)
+	DrawClue(context.Context, *DrawClueReq) (*AddProjectResp, error)
 	Call(context.Context, *CallReq) (*Resp, error)
 	mustEmbedUnimplementedBiServiceServer()
 }
@@ -96,6 +115,9 @@ func (UnimplementedBiServiceServer) AddProject(context.Context, *AddProjectReq)
 func (UnimplementedBiServiceServer) GetInfoId(context.Context, *AddProjectReq) (*GetInfoIdResp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method GetInfoId not implemented")
 }
+func (UnimplementedBiServiceServer) DrawClue(context.Context, *DrawClueReq) (*AddProjectResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method DrawClue not implemented")
+}
 func (UnimplementedBiServiceServer) Call(context.Context, *CallReq) (*Resp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method Call not implemented")
 }
@@ -122,7 +144,7 @@ func _BiService_MyDataAsset_Handler(srv interface{}, ctx context.Context, dec fu
 	}
 	info := &grpc.UnaryServerInfo{
 		Server:     srv,
-		FullMethod: "/BiService/myDataAsset",
+		FullMethod: BiService_MyDataAsset_FullMethodName,
 	}
 	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
 		return srv.(BiServiceServer).MyDataAsset(ctx, req.(*MyDataAssetReq))
@@ -140,7 +162,7 @@ func _BiService_AddProject_Handler(srv interface{}, ctx context.Context, dec fun
 	}
 	info := &grpc.UnaryServerInfo{
 		Server:     srv,
-		FullMethod: "/BiService/addProject",
+		FullMethod: BiService_AddProject_FullMethodName,
 	}
 	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
 		return srv.(BiServiceServer).AddProject(ctx, req.(*AddProjectReq))
@@ -158,7 +180,7 @@ func _BiService_GetInfoId_Handler(srv interface{}, ctx context.Context, dec func
 	}
 	info := &grpc.UnaryServerInfo{
 		Server:     srv,
-		FullMethod: "/BiService/getInfoId",
+		FullMethod: BiService_GetInfoId_FullMethodName,
 	}
 	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
 		return srv.(BiServiceServer).GetInfoId(ctx, req.(*AddProjectReq))
@@ -166,6 +188,24 @@ func _BiService_GetInfoId_Handler(srv interface{}, ctx context.Context, dec func
 	return interceptor(ctx, in, info, handler)
 }
 
+func _BiService_DrawClue_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(DrawClueReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(BiServiceServer).DrawClue(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: BiService_DrawClue_FullMethodName,
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(BiServiceServer).DrawClue(ctx, req.(*DrawClueReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 func _BiService_Call_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
 	in := new(CallReq)
 	if err := dec(in); err != nil {
@@ -176,7 +216,7 @@ func _BiService_Call_Handler(srv interface{}, ctx context.Context, dec func(inte
 	}
 	info := &grpc.UnaryServerInfo{
 		Server:     srv,
-		FullMethod: "/BiService/Call",
+		FullMethod: BiService_Call_FullMethodName,
 	}
 	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
 		return srv.(BiServiceServer).Call(ctx, req.(*CallReq))
@@ -203,6 +243,10 @@ var BiService_ServiceDesc = grpc.ServiceDesc{
 			MethodName: "getInfoId",
 			Handler:    _BiService_GetInfoId_Handler,
 		},
+		{
+			MethodName: "drawClue",
+			Handler:    _BiService_DrawClue_Handler,
+		},
 		{
 			MethodName: "Call",
 			Handler:    _BiService_Call_Handler,

+ 155 - 0
service/clue.go

@@ -0,0 +1,155 @@
+package service
+
+import (
+	"math"
+	"time"
+
+	common "app.yhyue.com/moapp/jybase/common"
+	. "bp.jydev.jianyu360.cn/BaseService/biService/entity"
+	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/biservice"
+)
+
+func DrawClue(this *biservice.DrawClueReq) *biservice.AddProjectResp {
+	count1 := JyBiTidb.Count("dwd_f_crm_open_sea", map[string]interface{}{"level": 1})
+	count2 := JyBiTidb.Count("dwd_f_crm_open_sea", map[string]interface{}{"level": 2})
+	count3 := JyBiTidb.Count("dwd_f_crm_open_sea", map[string]interface{}{"level": 3})
+	counts1 := int64(math.Floor(float64(this.Count) / float64(10) * 2))
+	counts2 := int64(math.Floor(float64(this.Count) / float64(10) * 4))
+	counts3 := this.Count - counts1 - counts2
+	if counts1 > count1 {
+		counts2 += counts1 - count1
+	}
+	if counts2 > count2 {
+		counts3 += counts2 - count2
+	}
+	DrawClues(this.PositionId, counts1, counts2, counts3)
+	return &biservice.AddProjectResp{
+		ErrorCode: 0,
+		Data: &biservice.AddProject{
+			Status: 1,
+		},
+	}
+}
+
+func DrawClues(positionId, count1, count2, count3 int64) {
+	data1 := JyBiTidb.Find("dwd_f_crm_open_sea", map[string]interface{}{"level": 1}, "", "", 0, count1)
+	data2 := JyBiTidb.Find("dwd_f_crm_open_sea", map[string]interface{}{"level": 2}, "", "", 0, count2)
+	data3 := JyBiTidb.Find("dwd_f_crm_open_sea", map[string]interface{}{"level": 3}, "", "", 0, count3)
+	if data1 != nil && len(*data1) > 0 {
+		for _, v := range *data1 {
+			//update postionid and update record
+			clueId := common.Int64All(v["clue_id"])
+			nowTime := time.Now().Format("2006-01-02 15:04:05")
+			seatNumber, name := getSeatNumber(positionId)
+			JyBiMysql.ExecTx("领取线索等", func(tx *sql.Tx) bool {
+				JyBiTidb.UpdateByTx(tx, "dwd_f_crm_clue_info", map[string]interface{}{"id": clue_id}, map[string]interface{}{"position_id": positionId, "seatNumber": seatNumber})
+				JyBiTidb.DeleteByTx(tx, "dwd_f_crm_open_sea", map[string]interface{}{"id": clue_id})
+				JyBiTidb.InsertByTx(tx, "dwd_f_crm_private_sea", map[string]interface{}{
+					"clue_id":      clueId,
+					"seatNumber":   seatNumber,
+					"position_id":  positionId,
+					"comeintime":   nowTime,
+					"comeinsource": 3,
+					"is_task":      0,
+				})
+				JyBiTidb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+					"clue_id":      clueId,
+					"position_id":  positionId,
+					"change_field": "position_id",
+					"change_type":  "所属人变更",
+					"old_value":    "/",
+					"new_value":    name,
+					"createtime":   nowTime,
+					"BCPCID":       common.GetRandom(32),
+					"operator_id":  positionId,
+				})
+			})
+		}
+	}
+	if data2 != nil && len(*data2) > 0 {
+		for _, v := range *data2 {
+			JyBiTidb.ExecTx("领取线索等", func(tx *sql.Tx) bool {
+				clueId := common.Int64All(v["clue_id"])
+				nowTime := time.Now().Format("2006-01-02 15:04:05")
+				seatNumber, name := getSeatNumber(positionId)
+				JyBiMysql.ExecTx("领取线索等", func(tx *sql.Tx) bool {
+					JyBiTidb.UpdateByTx(tx, "dwd_f_crm_clue_info", map[string]interface{}{"id": clue_id}, map[string]interface{}{"position_id": positionId, "seatNumber": seatNumber})
+					JyBiTidb.DeleteByTx(tx, "dwd_f_crm_open_sea", map[string]interface{}{"id": clue_id})
+					JyBiTidb.InsertByTx(tx, "dwd_f_crm_private_sea", map[string]interface{}{
+						"clue_id":      clueId,
+						"seatNumber":   seatNumber,
+						"position_id":  positionId,
+						"comeintime":   nowTime,
+						"comeinsource": 3,
+						"is_task":      0,
+					})
+					JyBiTidb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+						"clue_id":      clueId,
+						"position_id":  positionId,
+						"change_field": "position_id",
+						"change_type":  "所属人变更",
+						"old_value":    "/",
+						"new_value":    name,
+						"createtime":   nowTime,
+						"BCPCID":       common.GetRandom(32),
+						"operator_id":  positionId,
+					})
+				})
+			})
+		}
+	}
+	if data3 != nil && len(*data3) > 0 {
+		for _, v := range *data3 {
+			JyBiTidb.ExecTx("领取线索等", func(tx *sql.Tx) bool {
+				clueId := common.Int64All(v["clue_id"])
+				nowTime := time.Now().Format("2006-01-02 15:04:05")
+				seatNumber, name := getSeatNumber(positionId)
+				JyBiMysql.ExecTx("领取线索等", func(tx *sql.Tx) bool {
+					JyBiTidb.UpdateByTx(tx, "dwd_f_crm_clue_info", map[string]interface{}{"id": clue_id}, map[string]interface{}{"position_id": positionId, "seatNumber": seatNumber})
+					JyBiTidb.DeleteByTx(tx, "dwd_f_crm_open_sea", map[string]interface{}{"id": clue_id})
+					JyBiTidb.InsertByTx(tx, "dwd_f_crm_private_sea", map[string]interface{}{
+						"clue_id":      clueId,
+						"seatNumber":   seatNumber,
+						"position_id":  positionId,
+						"comeintime":   nowTime,
+						"comeinsource": 3,
+						"is_task":      0,
+					})
+					JyBiTidb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+						"clue_id":      clueId,
+						"position_id":  positionId,
+						"change_field": "position_id",
+						"change_type":  "所属人变更",
+						"old_value":    "/",
+						"new_value":    name,
+						"createtime":   nowTime,
+						"BCPCID":       common.GetRandom(32),
+						"operator_id":  positionId,
+					})
+				})
+			})
+		}
+	}
+}
+
+func getSeatNumber(positionId int64) (seatNumber, name string) {
+	positionData := JyTidb.FindOne("base_position", map[string]interface{}{"id": positionId}, "", "")
+	if positionData != nil && len(*positionData) > 0 {
+		userId := common.Int64All((*positionData)["user_id"])
+		if userId > 0 {
+			userData := Mgo.FindOne("user", map[string]interface{}{"base_user_id": userId})
+			if userData != nil && len(*userData) > 0 {
+				s_phone := common.ObjToString((*userData)["s_phone"])
+				if s_phone == "" {
+					s_phone = common.ObjToString((*userData)["s_m_phone"])
+				}
+				saleData := JyBiTidb.FindOne("jy_salesperson_info", map[string]interface{}{"phone": s_phone}, "", "")
+				if saleData != nil && len(*saleData) > 0 {
+					seatNumber = common.ObjToString((*saleData)["seatNumber"])
+					name = common.ObjToString((*saleData)["name"])
+				}
+			}
+		}
+	}
+	return
+}