xuzhiheng 1 жил өмнө
parent
commit
881031c92e

+ 2 - 0
api/biService.api

@@ -90,4 +90,6 @@ service biService-api {
 	post /biService/ClueAdd (ClueAddReq) returns (resp)
 	@handler ClueImportTl
 	post /biService/clueImportTt (ClueImportReq) returns (resp)
+	@handler AutoFollow
+	post /biService/autoFollow (callReq) returns (resp)
 }

+ 28 - 0
api/internal/handler/autofollowhandler.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 AutoFollowHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.CallReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.Error(w, err)
+			return
+		}
+
+		l := logic.NewAutoFollowLogic(r.Context(), svcCtx)
+		resp, err := l.AutoFollow(&req)
+		if err != nil {
+			httpx.Error(w, err)
+		} else {
+			httpx.OkJson(w, resp)
+		}
+	}
+}

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

@@ -57,6 +57,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/biService/clueImportTt",
 				Handler: ClueImportTlHandler(serverCtx),
 			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/biService/autoFollow",
+				Handler: AutoFollowHandler(serverCtx),
+			},
 		},
 	)
 }

+ 33 - 0
api/internal/logic/autofollowlogic.go

@@ -0,0 +1,33 @@
+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 AutoFollowLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewAutoFollowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AutoFollowLogic {
+	return &AutoFollowLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *AutoFollowLogic) AutoFollow(req *types.CallReq) (resp *types.Resp, err error) {
+	// todo: add your logic here and delete this line
+	callresp, err := l.svcCtx.BiServiceRpc.AutoFollow(l.ctx, &biservice.CallReq{
+		PositionId: req.PositionId,
+		Phone:      req.Phone,
+	})
+	return &types.Resp{Error_code: 1, Data: callresp.Data}, err
+}

+ 1 - 0
rpc/biService.proto

@@ -127,4 +127,5 @@ service BiService {
 	rpc clueImport (ClueImportReq) returns (ClueImportResp); //线索导入
 	rpc clueAdd (ClueAddReq) returns (AddProjectResp); //合力亿捷新增线索
 	rpc clueImportTt (ClueImportReq) returns (ClueImportResp); //线索导入tt
+	rpc autoFollow (CallReq) returns (ClueImportResp);
 }

+ 6 - 0
rpc/biservice/biservice.go

@@ -40,6 +40,7 @@ type (
 		ClueImport(ctx context.Context, in *ClueImportReq, opts ...grpc.CallOption) (*ClueImportResp, error)
 		ClueAdd(ctx context.Context, in *ClueAddReq, opts ...grpc.CallOption) (*AddProjectResp, error)
 		ClueImportTt(ctx context.Context, in *ClueImportReq, opts ...grpc.CallOption) (*ClueImportResp, error)
+		AutoFollow(ctx context.Context, in *CallReq, opts ...grpc.CallOption) (*ClueImportResp, error)
 	}
 
 	defaultBiService struct {
@@ -97,3 +98,8 @@ func (m *defaultBiService) ClueImportTt(ctx context.Context, in *ClueImportReq,
 	client := pb.NewBiServiceClient(m.cli.Conn())
 	return client.ClueImportTt(ctx, in, opts...)
 }
+
+func (m *defaultBiService) AutoFollow(ctx context.Context, in *CallReq, opts ...grpc.CallOption) (*ClueImportResp, error) {
+	client := pb.NewBiServiceClient(m.cli.Conn())
+	return client.AutoFollow(ctx, in, opts...)
+}

+ 30 - 0
rpc/internal/logic/autofollowlogic.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"
+	"bp.jydev.jianyu360.cn/BaseService/biService/service"
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type AutoFollowLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewAutoFollowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AutoFollowLogic {
+	return &AutoFollowLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *AutoFollowLogic) AutoFollow(in *pb.CallReq) (*pb.ClueImportResp, error) {
+	// todo: add your logic here and delete this line
+
+	return service.AutoFollow(in), nil
+}

+ 5 - 0
rpc/internal/server/biserviceserver.go

@@ -66,3 +66,8 @@ func (s *BiServiceServer) ClueImportTt(ctx context.Context, in *pb.ClueImportReq
 	l := logic.NewClueImportTtLogic(ctx, s.svcCtx)
 	return l.ClueImportTt(in)
 }
+
+func (s *BiServiceServer) AutoFollow(ctx context.Context, in *pb.CallReq) (*pb.ClueImportResp, error) {
+	l := logic.NewAutoFollowLogic(ctx, s.svcCtx)
+	return l.AutoFollow(in)
+}

+ 18 - 13
rpc/pb/biService.pb.go

@@ -1328,7 +1328,7 @@ var file_biService_proto_rawDesc = []byte{
 	0x61, 0x6e, 0x74, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x12, 0x26, 0x0a, 0x0e, 0x63, 0x75, 0x73, 0x74,
 	0x6f, 0x6d, 0x65, 0x72, 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09,
 	0x52, 0x0e, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x42, 0x75, 0x64, 0x67, 0x65, 0x74,
-	0x32, 0x9d, 0x03, 0x0a, 0x09, 0x42, 0x69, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x30,
+	0x32, 0xc6, 0x03, 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,
@@ -1354,7 +1354,10 @@ var file_biService_proto_rawDesc = []byte{
 	0x2f, 0x0a, 0x0c, 0x63, 0x6c, 0x75, 0x65, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x54, 0x74, 0x12,
 	0x0e, 0x2e, 0x43, 0x6c, 0x75, 0x65, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x71, 0x1a,
 	0x0f, 0x2e, 0x43, 0x6c, 0x75, 0x65, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70,
-	0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x12, 0x27, 0x0a, 0x0a, 0x61, 0x75, 0x74, 0x6f, 0x46, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x12, 0x08,
+	0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x43, 0x6c, 0x75, 0x65, 0x49,
+	0x6d, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70,
+	0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var (
@@ -1402,17 +1405,19 @@ var file_biService_proto_depIdxs = []int32{
 	12, // 10: BiService.clueImport:input_type -> ClueImportReq
 	15, // 11: BiService.clueAdd:input_type -> ClueAddReq
 	12, // 12: BiService.clueImportTt:input_type -> ClueImportReq
-	1,  // 13: BiService.myDataAsset:output_type -> MyDataAssetResp
-	4,  // 14: BiService.addProject:output_type -> AddProjectResp
-	6,  // 15: BiService.getInfoId:output_type -> GetInfoIdResp
-	4,  // 16: BiService.drawClue:output_type -> AddProjectResp
-	9,  // 17: BiService.Call:output_type -> Resp
-	4,  // 18: BiService.distributeClue:output_type -> AddProjectResp
-	13, // 19: BiService.clueImport:output_type -> ClueImportResp
-	4,  // 20: BiService.clueAdd:output_type -> AddProjectResp
-	13, // 21: BiService.clueImportTt:output_type -> ClueImportResp
-	13, // [13:22] is the sub-list for method output_type
-	4,  // [4:13] is the sub-list for method input_type
+	8,  // 13: BiService.autoFollow:input_type -> CallReq
+	1,  // 14: BiService.myDataAsset:output_type -> MyDataAssetResp
+	4,  // 15: BiService.addProject:output_type -> AddProjectResp
+	6,  // 16: BiService.getInfoId:output_type -> GetInfoIdResp
+	4,  // 17: BiService.drawClue:output_type -> AddProjectResp
+	9,  // 18: BiService.Call:output_type -> Resp
+	4,  // 19: BiService.distributeClue:output_type -> AddProjectResp
+	13, // 20: BiService.clueImport:output_type -> ClueImportResp
+	4,  // 21: BiService.clueAdd:output_type -> AddProjectResp
+	13, // 22: BiService.clueImportTt:output_type -> ClueImportResp
+	13, // 23: BiService.autoFollow:output_type -> ClueImportResp
+	14, // [14:24] is the sub-list for method output_type
+	4,  // [4:14] is the sub-list for method input_type
 	4,  // [4:4] is the sub-list for extension type_name
 	4,  // [4:4] is the sub-list for extension extendee
 	0,  // [0:4] is the sub-list for field type_name

+ 37 - 0
rpc/pb/biService_grpc.pb.go

@@ -28,6 +28,7 @@ const (
 	BiService_ClueImport_FullMethodName     = "/BiService/clueImport"
 	BiService_ClueAdd_FullMethodName        = "/BiService/clueAdd"
 	BiService_ClueImportTt_FullMethodName   = "/BiService/clueImportTt"
+	BiService_AutoFollow_FullMethodName     = "/BiService/autoFollow"
 )
 
 // BiServiceClient is the client API for BiService service.
@@ -43,6 +44,7 @@ type BiServiceClient interface {
 	ClueImport(ctx context.Context, in *ClueImportReq, opts ...grpc.CallOption) (*ClueImportResp, error)
 	ClueAdd(ctx context.Context, in *ClueAddReq, opts ...grpc.CallOption) (*AddProjectResp, error)
 	ClueImportTt(ctx context.Context, in *ClueImportReq, opts ...grpc.CallOption) (*ClueImportResp, error)
+	AutoFollow(ctx context.Context, in *CallReq, opts ...grpc.CallOption) (*ClueImportResp, error)
 }
 
 type biServiceClient struct {
@@ -134,6 +136,15 @@ func (c *biServiceClient) ClueImportTt(ctx context.Context, in *ClueImportReq, o
 	return out, nil
 }
 
+func (c *biServiceClient) AutoFollow(ctx context.Context, in *CallReq, opts ...grpc.CallOption) (*ClueImportResp, error) {
+	out := new(ClueImportResp)
+	err := c.cc.Invoke(ctx, BiService_AutoFollow_FullMethodName, in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
 // BiServiceServer is the server API for BiService service.
 // All implementations must embed UnimplementedBiServiceServer
 // for forward compatibility
@@ -147,6 +158,7 @@ type BiServiceServer interface {
 	ClueImport(context.Context, *ClueImportReq) (*ClueImportResp, error)
 	ClueAdd(context.Context, *ClueAddReq) (*AddProjectResp, error)
 	ClueImportTt(context.Context, *ClueImportReq) (*ClueImportResp, error)
+	AutoFollow(context.Context, *CallReq) (*ClueImportResp, error)
 	mustEmbedUnimplementedBiServiceServer()
 }
 
@@ -181,6 +193,9 @@ func (UnimplementedBiServiceServer) ClueAdd(context.Context, *ClueAddReq) (*AddP
 func (UnimplementedBiServiceServer) ClueImportTt(context.Context, *ClueImportReq) (*ClueImportResp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method ClueImportTt not implemented")
 }
+func (UnimplementedBiServiceServer) AutoFollow(context.Context, *CallReq) (*ClueImportResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method AutoFollow not implemented")
+}
 func (UnimplementedBiServiceServer) mustEmbedUnimplementedBiServiceServer() {}
 
 // UnsafeBiServiceServer may be embedded to opt out of forward compatibility for this service.
@@ -356,6 +371,24 @@ func _BiService_ClueImportTt_Handler(srv interface{}, ctx context.Context, dec f
 	return interceptor(ctx, in, info, handler)
 }
 
+func _BiService_AutoFollow_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(CallReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(BiServiceServer).AutoFollow(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: BiService_AutoFollow_FullMethodName,
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(BiServiceServer).AutoFollow(ctx, req.(*CallReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 // BiService_ServiceDesc is the grpc.ServiceDesc for BiService service.
 // It's only intended for direct use with grpc.RegisterService,
 // and not to be introspected or modified (even as a copy)
@@ -399,6 +432,10 @@ var BiService_ServiceDesc = grpc.ServiceDesc{
 			MethodName: "clueImportTt",
 			Handler:    _BiService_ClueImportTt_Handler,
 		},
+		{
+			MethodName: "autoFollow",
+			Handler:    _BiService_AutoFollow_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "biService.proto",

+ 8 - 3
service/clue.go

@@ -747,11 +747,15 @@ func ClueImportSync(this *biservice.ClueImportReq) (string, int) {
 						}
 						isOks = false
 					} else {
-						userData := JyBiTidb.FindOne("dwd_f_userbase_baseinfo", map[string]interface{}{"phone": phone}, "", "")
+						userData := JyBiTidb.FindOne("dwd_f_userbase_contacts", map[string]interface{}{"phone": phone}, "", "")
 						if userData != nil && len(*userData) > 0 {
 							source := common.IntAll((*userData)["source"])
-							userId := common.ObjToString((*userData)["userid"])
-							uId := common.ObjToString((*userData)["uid"])
+							userId := ""
+							uId := common.ObjToString((*userData)["baseinfo_id"])
+							baseData := JyBiTidb.FindOne("dwd_f_userbase_baseinfo", map[string]interface{}{"uid": uId}, "", "")
+							if baseData != nil {
+								userId = common.ObjToString((*baseData)["userid"])
+							}
 							if source == 5 {
 								if !isOks {
 									result += ",“该线索已归属域外”"
@@ -868,6 +872,7 @@ func ClueImportSync(this *biservice.ClueImportReq) (string, int) {
 								"updatetime":  nowTime,
 								"phone":       phone,
 								"baseinfo_id": v["uId"],
+								"source":      4,
 							})
 						}
 					} else {

+ 54 - 0
service/hlyj.go

@@ -6,6 +6,10 @@ import (
 	"log"
 	"time"
 
+	"app.yhyue.com/moapp/jybase/common"
+
+	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/biservice"
+
 	"app.yhyue.com/moapp/jybase/date"
 	"app.yhyue.com/moapp/jybase/redis"
 	. "bp.jydev.jianyu360.cn/BaseService/biService/entity"
@@ -88,3 +92,53 @@ func (this *HlyjStruct) Call(phone string, positionId int64) string {
 	// ret := Get(this.CallUrl, g.Map{"flag": this.CallFlag, "account": this.Account, "integratedid": integratedid, "accessToken": token, "phonenum": phone})
 	// return ret == "200"
 }
+
+func AutoFollow(this *biservice.CallReq) *biservice.ClueImportResp {
+	status := 1
+	data := JyBiTidb.FindOne("dwd_f_userbase_contacts", map[string]interface{}{"phone": this.Phone}, "", "")
+	if data != nil {
+		baseInfoId := common.Int64All((*data)["baseinfo_id"])
+		clueData := JyBiTidb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"uid": baseInfoId}, "", "")
+		if clueData != nil {
+			clueId := common.Int64All((*clueData)["baseinfo_id"])
+			callData := CallTidb.FindOne("voice_record", map[string]interface{}{"phone": this.Phone}, "", "")
+			if callData != nil {
+				callMap := map[string]interface{}{
+					"":            "1",
+					"dealing":     "2",
+					"voicemail":   "3",
+					"notDeal":     "4",
+					"blackList":   "5",
+					"queueLeak":   "6",
+					"leak":        "7",
+					"robotServer": "8",
+					"autoHangup":  "9",
+				}
+				state := common.ObjToString((*callData)["State"])
+				hanguper := common.ObjToString((*callData)["Hanguper"])
+				updateData := map[string]interface{}{}
+				if state != "dealing" && hanguper != "agent" {
+					JyBiTidb.Insert("dwd_f_crm_trail_content", map[string]interface{}{
+						"clue_id":     clueId,
+						"position_id": this.PositionId,
+						"content":     "客户未接通",
+						"operator_id": -1,
+						"createtime":  time.Now().Format(date.Date_Full_Layout),
+					})
+					updateData["taskstatus"] = 1
+				}
+				updateData["STATE"] = callMap["state"]
+				JyBiTidb.Update("dwd_f_crm_clue_info", map[string]interface{}{"phone": this.Phone}, updateData)
+			}
+		}
+
+	} else {
+		status = -1
+	}
+	return &biservice.ClueImportResp{
+		ErrorCode: 0,
+		Data: &biservice.ClueImport{
+			Status: int64(status),
+		},
+	}
+}