WH01243 1 éve
szülő
commit
0823bab068

+ 103 - 74
api/application.api

@@ -20,15 +20,15 @@ type (
 		EntId        int64   `header:"entId,optional"`
 		AccountId    int64   `header:"accountId,optional"`
 		EntDeptId    int64   `header:"entDeptId,optional"`
-		CluesSource  string  `json:"cluesSource"` //线索来源
-		ClueName     string  `json:"clueName"` //线索名称
-		Summary      string  `json:"summary"` //概要信息
+		CluesSource  string  `json:"cluesSource"`           //线索来源
+		ClueName     string  `json:"clueName"`              //线索名称
+		Summary      string  `json:"summary"`               //概要信息
 		FollowUpTime int64   `json:"followUpTime,optional"` //下次跟进时间(时间戳)
-		Types        int64   `json:"types"` //处理方式 1自办;2转办;3待处理
-		User         []int64 `json:"user,optional"` //企业用户id
+		Types        int64   `json:"types"`                 //处理方式 1自办;2转办;3待处理
+		User         []int64 `json:"user,optional"`         //企业用户id
 		EmployInfoId int64   `json:"employInfoId,optional"` //资讯收录id
-		CreateName   string  `json:"createName"` //创建人
-		Channel      string  `json:"channel"` //渠道来源:网页、手动创建
+		CreateName   string  `json:"createName"`            //创建人
+		Channel      string  `json:"channel"`               //渠道来源:网页、手动创建
 	}
 	SaleChanceReq {
 		AppId             string  `header:"appId,default=10000"`
@@ -38,23 +38,23 @@ type (
 		EntId             int64   `header:"entId,optional"`
 		AccountId         int64   `header:"accountId,optional"`
 		EntDeptId         int64   `header:"entDeptId,optional"`
-		ChanceName        string  `json:"chanceName"` //机会名称
-		Summary           string  `json:"summary"` //概要信息
-		ChanceClassify    int64   `json:"chanceClassify"` //机会分类
+		ChanceName        string  `json:"chanceName"`                 //机会名称
+		Summary           string  `json:"summary"`                    //概要信息
+		ChanceClassify    int64   `json:"chanceClassify"`             //机会分类
 		ExpectedOrderTime int64   `json:"expectedOrderTime,optional"` //最初预计落单段时间 时间戳
-		ExpectedMoney     float64 `json:"expectedMoney,optional"` //最初预计落单金额
-		CustomName        string  `json:"customName"` //客户全称
-		BusinessType      int64   `json:"businessType"` //业务类型  1新客户需求 2老客户需求 3简易项目流程
-		Remarks           string  `json:"remarks,optional"` //备注
-		NextfollowUpTime  int64   `json:"nextfollowUpTime,optional"` //下次跟进时间戳
-		Types             int64   `json:"types"` //处理方式 1自办;2转办;3待处理
-		User              []int64 `json:"user,optional"` //企业用户id
-		EmployInfoId      int64   `json:"employInfoId,optional"` //资讯收录id
-		CustomId          int64   `json:"customId,optional"` //客户id
-		CreateName        string  `json:"createName"` //创建人
-		ChanceSource      int64   `json:"chanceSource"` //机会来源
-		OwnerId           int64   `json:"ownerId,optional"` //潜客收录id(人脉)
-		BusinessId        int64   `json:"businessId,optional"` //商机收录id(人脉)
+		ExpectedMoney     float64 `json:"expectedMoney,optional"`     //最初预计落单金额
+		CustomName        string  `json:"customName"`                 //客户全称
+		BusinessType      int64   `json:"businessType"`               //业务类型  1新客户需求 2老客户需求 3简易项目流程
+		Remarks           string  `json:"remarks,optional"`           //备注
+		NextfollowUpTime  int64   `json:"nextfollowUpTime,optional"`  //下次跟进时间戳
+		Types             int64   `json:"types"`                      //处理方式 1自办;2转办;3待处理
+		User              []int64 `json:"user,optional"`              //企业用户id
+		EmployInfoId      int64   `json:"employInfoId,optional"`      //资讯收录id
+		CustomId          int64   `json:"customId,optional"`          //客户id
+		CreateName        string  `json:"createName"`                 //创建人
+		ChanceSource      int64   `json:"chanceSource"`               //机会来源
+		OwnerId           int64   `json:"ownerId,optional"`           //潜客收录id(人脉)
+		BusinessId        int64   `json:"businessId,optional"`        //商机收录id(人脉)
 	}
 	EmployOperateReq {
 		AppId      string `header:"appId,default=10000"`
@@ -62,8 +62,8 @@ type (
 		PositionId int64  `header:"positionId,optional"`
 		EntUserId  int64  `header:"entUserId,optional"`
 		EntId      int64  `header:"entId,optional"`
-		IdArr      string `json:"idArr"` //信息id多条信息
-		IsEmploy   bool   `json:"isEmploy"` //是否收录true收录 false取消收录
+		IdArr      string `json:"idArr"`      //信息id多条信息
+		IsEmploy   bool   `json:"isEmploy"`   //是否收录true收录 false取消收录
 		EmployType int64  `json:"employType"` //来源方式来源;1招标采购、2企业、3采购单位、4拟在建项目
 		EntDeptId  int64  `header:"entDeptId,optional"`
 		From       string `json:"from,optional"` //来源
@@ -83,8 +83,8 @@ type (
 		PositionId int64  `header:"positionId,optional"`
 		EntUserId  int64  `header:"entUserId,optional"`
 		EntId      int64  `header:"entId,optional"`
-		IdArr      string `json:"idArr"` //id集合
-		IsIgnore   bool   `json:"isIgnore"` //是否忽略 true 忽略 false取消忽略
+		IdArr      string `json:"idArr"`      //id集合
+		IsIgnore   bool   `json:"isIgnore"`   //是否忽略 true 忽略 false取消忽略
 		EmployType int64  `json:"employType"` //来源方式来源;1招标采购、2企业、3采购单位、4拟在建项目
 	}
 	InfoEmployinfoReq {
@@ -94,13 +94,13 @@ type (
 		EntUserId    int64  `header:"entUserId,optional"`
 		EntId        int64  `header:"entId,optional"`
 		EmployType   int64  `json:"employType"` //1标采购、2企业、3采购单位、4拟在建项目
-		IdArr        string `json:"idArr"` //id
+		IdArr        string `json:"idArr"`      //id
 		EntNicheDis  int64  `header:"entNicheDis,optional"`
 		EntDeptId    int64  `header:"entDeptId,optional"`
 		PositionType int64  `header:"positionType,optional"` //职位类型 0个人 1企业
-		AccountId    int64  `header:"accountId,optional"` //账户id
+		AccountId    int64  `header:"accountId,optional"`    //账户id
 		EntAccountId int64  `header:"entAccountId,optional"` //企业账户id
-		From         string `json:"from,optional"` //来源
+		From         string `json:"from,optional"`           //来源
 	}
 	CustomAddReq {
 		AppId                string  `header:"appId,default=10000"`
@@ -110,28 +110,28 @@ type (
 		EntId                int64   `header:"entId,optional"`
 		AccountId            int64   `header:"accountId,optional"`
 		EntDeptId            int64   `header:"entDeptId,optional"`
-		CustomType           int64   `json:"customType"` //客户类型
-		Summary              string  `json:"summary"` //概要信息
-		CustomAllName        string  `json:"customAllName"` //客户全称
-		CustomAbbreviation   string  `json:"customAbbreviation"` //客户简称
-		CustomLevel          int64   `json:"customLevel,optional"` //客户级别
-		CustomIndustry       int64   `json:"customIndustry"` //客户行业
-		CustomDetailIndustry int64   `json:"customDetailIndustry"` //客户细分行业
-		Province             string  `json:"province,optional"` //省份
-		City                 string  `json:"city,optional"` //城市
-		District             string  `json:"district,optional"` //地区
-		Address              string  `json:"address,optional"` //详细地址
-		CompanyPhone         string  `json:"companyPhone,optional"` //公司电话
-		NextfollowUpTime     int64   `json:"nextfollowUpTime,optional"` //下次跟进时间戳
-		Types                int64   `json:"types"` //处理方式 1自办;2转办
-		User                 []int64 `json:"user,optional"` //转办用户
+		CustomType           int64   `json:"customType"`                       //客户类型
+		Summary              string  `json:"summary"`                          //概要信息
+		CustomAllName        string  `json:"customAllName"`                    //客户全称
+		CustomAbbreviation   string  `json:"customAbbreviation"`               //客户简称
+		CustomLevel          int64   `json:"customLevel,optional"`             //客户级别
+		CustomIndustry       int64   `json:"customIndustry"`                   //客户行业
+		CustomDetailIndustry int64   `json:"customDetailIndustry"`             //客户细分行业
+		Province             string  `json:"province,optional"`                //省份
+		City                 string  `json:"city,optional"`                    //城市
+		District             string  `json:"district,optional"`                //地区
+		Address              string  `json:"address,optional"`                 //详细地址
+		CompanyPhone         string  `json:"companyPhone,optional"`            //公司电话
+		NextfollowUpTime     int64   `json:"nextfollowUpTime,optional"`        //下次跟进时间戳
+		Types                int64   `json:"types"`                            //处理方式 1自办;2转办
+		User                 []int64 `json:"user,optional"`                    //转办用户
 		EmployCustomId       int64   `json:"employCustomId,optional,optional"` //客户收录id
-		EmployInfoId         int64   `json:"employInfoId,optional,optional"` //资讯收录id
-		Remarks              string  `json:"remarks,optional"` //备注
-		CreateName           string  `json:"createName"` //创建人
-		Source               string  `json:"source,optional"` //来源
-		OwnerId              int64   `json:"ownerId,optional"` //潜客收录id(人脉)
-		BusinessId           int64   `json:"businessId,optional"` //商机收录id(人脉)
+		EmployInfoId         int64   `json:"employInfoId,optional,optional"`   //资讯收录id
+		Remarks              string  `json:"remarks,optional"`                 //备注
+		CreateName           string  `json:"createName"`                       //创建人
+		Source               string  `json:"source,optional"`                  //来源
+		OwnerId              int64   `json:"ownerId,optional"`                 //潜客收录id(人脉)
+		BusinessId           int64   `json:"businessId,optional"`              //商机收录id(人脉)
 	}
 	FileUploadReq {
 		AppId      string `header:"appId,default=10000"`
@@ -140,8 +140,8 @@ type (
 		EntUserId  int64  `header:"entUserId,optional"`
 		EntId      int64  `header:"entId,optional"`
 		BusinessId int64  `form:"businessId"` //业务id
-		Types      int64  `form:"type"` //类型;1:跟进记录-线下 2:跟进记录-线上 3:跟进记录-备忘 4:销售机会-项目文档 5:客户-客户档案
-		FileType   int64  `form:"fileType"` //文件类型,产品介绍、项目方案、立项报告、报价文件、招标文件、投标文件、中标通知书、合同、发票、其他文件
+		Types      int64  `form:"type"`       //类型;1:跟进记录-线下 2:跟进记录-线上 3:跟进记录-备忘 4:销售机会-项目文档 5:客户-客户档案
+		FileType   int64  `form:"fileType"`   //文件类型,产品介绍、项目方案、立项报告、报价文件、招标文件、投标文件、中标通知书、合同、发票、其他文件
 	}
 	EmployDistributeReq {
 		AppId       string             `header:"appId,default=10000"`
@@ -168,12 +168,12 @@ type (
 		PositionId int64   `header:"positionId,optional"`
 		EntUserId  int64   `header:"entUserId,optional"`
 		EntId      int64   `header:"entId,optional"`
-		Title      string  `json:"title"` //标题
-		Content    string  `json:"content"` //内容
-		PcHref     string  `json:"pcHref"` //pc跳转地址
-		MobileHref string  `json:"mobileHref"` //移动端跳转地址
+		Title      string  `json:"title"`         //标题
+		Content    string  `json:"content"`       //内容
+		PcHref     string  `json:"pcHref"`        //pc跳转地址
+		MobileHref string  `json:"mobileHref"`    //移动端跳转地址
 		User       []int64 `json:"user,optional"` //企业用户id
-		MsgType    string  `json:"msgType"` //消息类型 1-活动优惠 2-服务通知 3-订阅消息 4-项目动态 5-企业动态 6-分析报告 7-系统通知 11-待办
+		MsgType    string  `json:"msgType"`       //消息类型 1-活动优惠 2-服务通知 3-订阅消息 4-项目动态 5-企业动态 6-分析报告 7-系统通知 11-待办
 	}
 	CanAddReq {
 		AppId          string `header:"appId,default=10000"`
@@ -183,20 +183,20 @@ type (
 		EntId          int64  `header:"entId,optional"`
 		AccountId      int64  `header:"accountId,optional"`
 		EntDeptId      int64  `header:"entDeptId,optional"`
-		EmployInfoId   int64  `json:"employInfoId"` //资讯收录id
+		EmployInfoId   int64  `json:"employInfoId"`            //资讯收录id
 		EmployCustomId int64  `json:"employCustomId,optional"` //客户收录id
-		Key            string `json:"key"` //创建线索:more_create_clue 创建机会:more_create_chance 创建客户:more_create_custom
+		Key            string `json:"key"`                     //创建线索:more_create_clue 创建机会:more_create_chance 创建客户:more_create_custom
 	}
 	OwnerListReq {
-		PartyA           string `json:"partyA,optional"` //甲方
-		Supplier         string `json:"supplier,optional"` //供应商
-		Heterotophy      string `json:"heterotophy,optional"` //同甲异业
-		Intermediary     string `json:"intermediary,optional"` //中间人
-		Agency           string `json:"agency,optional"` //代理机构
-		SearchEntName    string `json:"searchEntName,optional"` //搜索企业名称
-		SourceType       string `json:"sourceType,optional"` //搜索类型 1 只看转介绍成功率高2只看已监控的
+		PartyA           string `json:"partyA,optional"`           //甲方
+		Supplier         string `json:"supplier,optional"`         //供应商
+		Heterotophy      string `json:"heterotophy,optional"`      //同甲异业
+		Intermediary     string `json:"intermediary,optional"`     //中间人
+		Agency           string `json:"agency,optional"`           //代理机构
+		SearchEntName    string `json:"searchEntName,optional"`    //搜索企业名称
+		SourceType       string `json:"sourceType,optional"`       //搜索类型 1 只看转介绍成功率高2只看已监控的
 		ProcessingStatus string `json:"processingStatus,optional"` //处理状态1未处理2已忽略3已建客户
-		Area             string `json:"area,optional"` //项目地区
+		Area             string `json:"area,optional"`             //项目地区
 		PositionId       int64  `header:"positionId,optional"`
 		PageSize         int64  `json:"pageSize,optional"`
 		PageIndex        int64  `json:"pageIndex,optional"`
@@ -205,12 +205,12 @@ type (
 		PositionId   int64  `header:"positionId,optional"`
 		EntId        string `header:"entId,optional"`
 		EntUserId    string `header:"entUserId,optional"`
-		DeptId       string `header:"deptId,optional"` //部门id
-		PartyA       string `json:"partyA,optional"` //甲方
-		Supplier     string `json:"supplier,optional"` //供应商
-		Heterotophy  string `json:"heterotophy,optional"` //同甲异业
+		DeptId       string `header:"deptId,optional"`     //部门id
+		PartyA       string `json:"partyA,optional"`       //甲方
+		Supplier     string `json:"supplier,optional"`     //供应商
+		Heterotophy  string `json:"heterotophy,optional"`  //同甲异业
 		Intermediary string `json:"intermediary,optional"` //中间人
-		Agency       string `json:"agency,optional"` //代理机构
+		Agency       string `json:"agency,optional"`       //代理机构
 		PageNum      int64  `json:"pageNum"`
 		PageSize     int64  `json:"pageSize"`
 		BusinessType string `json:"businessType"`
@@ -304,6 +304,25 @@ type (
 		BuyerId  string `json:"buyerId"`
 		WinnerId string `json:"winnerId"`
 	}
+	ChannelListReq {
+		PartyA       string `json:"partyA,optional"`       //甲方
+		Supplier     string `json:"supplier,optional"`     //供应商
+		Heterotophy  string `json:"heterotophy,optional"`  //同甲异业
+		Intermediary string `json:"intermediary,optional"` //中间人
+		Agency       string `json:"agency,optional"`       //代理机构
+		PositionId   int64  `header:"positionId,optional"`
+	}
+	RouteOwnerListReq {
+		BuyerId   string `json:"buyerId,optional"`
+		BuyerName string `json:"buyerName,optional"`
+	}
+	CooperateOwnerListReq {
+		BuyerId       string `json:"buyerId,optional"`
+		BuyerName     string `json:"buyerName,optional"`
+		WinnerId      string `json:"winnerId,optional"`
+		WinnerName    string `json:"winnerName,optional"`
+		CooperateType string `json:"cooperateType,optional"`
+	}
 )
 
 @server (
@@ -406,5 +425,15 @@ service crmApplication {
 	@doc "人脉项目分析-业主合作历史"
 	@handler projectHistory
 	post /crmApplication/pr/project/history (PrjectHistoryReq) returns (Reply)
-}
+	@doc "可介绍业主路径"
+	@handler ownerRoute
+	post /crmApplication/owner/route (RouteOwnerListReq) returns (Reply)
+
+	@doc "可介绍业主合作次数"
+	@handler ownerCooperate
+	post /crmApplication/owner/cooperate (CooperateOwnerListReq) returns (Reply)
 
+	@doc "候选渠道列表"
+	@handler candidateChannel
+	post /crmApplication/candidate/channel (ChannelListReq) returns (Reply)
+}

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

@@ -0,0 +1,28 @@
+package handler
+
+import (
+	"net/http"
+
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/logic"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func candidateChannelHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.ChannelListReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := logic.NewCandidateChannelLogic(r.Context(), svcCtx)
+		resp, err := l.CandidateChannel(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 2 - 2
api/internal/handler/infodetailhandler.go

@@ -18,11 +18,11 @@ func infoDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 		}
 
 		l := logic.NewInfoDetailLogic(r.Context(), svcCtx)
-		err := l.InfoDetail(&req)
+		resp, err := l.InfoDetail(&req)
 		if err != nil {
 			httpx.ErrorCtx(r.Context(), w, err)
 		} else {
-			httpx.Ok(w)
+			httpx.OkJsonCtx(r.Context(), w, resp)
 		}
 	}
 }

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

@@ -0,0 +1,28 @@
+package handler
+
+import (
+	"net/http"
+
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/logic"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func ownerCooperateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.CooperateOwnerListReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := logic.NewOwnerCooperateLogic(r.Context(), svcCtx)
+		resp, err := l.OwnerCooperate(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

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

@@ -0,0 +1,28 @@
+package handler
+
+import (
+	"net/http"
+
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/logic"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func ownerRouteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.RouteOwnerListReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := logic.NewOwnerRouteLogic(r.Context(), svcCtx)
+		resp, err := l.OwnerRoute(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 53 - 38
api/internal/handler/routes.go

@@ -19,28 +19,33 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 			},
 			{
 				Method:  http.MethodPost,
-				Path:    "/crmApplication/custom/add",
-				Handler: customAddHandler(serverCtx),
+				Path:    "/crmApplication/saleChance/add",
+				Handler: saleChanceAddHandler(serverCtx),
 			},
 			{
 				Method:  http.MethodPost,
-				Path:    "/crmApplication/employ/distribute",
-				Handler: employDistributeHandler(serverCtx),
+				Path:    "/crmApplication/employ/operate",
+				Handler: employOperateHandler(serverCtx),
 			},
 			{
 				Method:  http.MethodPost,
-				Path:    "/crmApplication/employ/info",
-				Handler: employInfoHandler(serverCtx),
+				Path:    "/crmApplication/information/transfer",
+				Handler: transferHandler(serverCtx),
 			},
 			{
 				Method:  http.MethodPost,
-				Path:    "/crmApplication/employ/operate",
-				Handler: employOperateHandler(serverCtx),
+				Path:    "/crmApplication/ignore/operate",
+				Handler: ignoreOperateHandler(serverCtx),
 			},
 			{
 				Method:  http.MethodPost,
-				Path:    "/crmApplication/ent/info",
-				Handler: entinfoHandler(serverCtx),
+				Path:    "/crmApplication/employ/info",
+				Handler: employInfoHandler(serverCtx),
+			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/crmApplication/custom/add",
+				Handler: customAddHandler(serverCtx),
 			},
 			{
 				Method:  http.MethodPost,
@@ -49,13 +54,18 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 			},
 			{
 				Method:  http.MethodPost,
-				Path:    "/crmApplication/ignore/action",
-				Handler: ignoreActionHandler(serverCtx),
+				Path:    "/crmApplication/employ/distribute",
+				Handler: employDistributeHandler(serverCtx),
 			},
 			{
 				Method:  http.MethodPost,
-				Path:    "/crmApplication/ignore/operate",
-				Handler: ignoreOperateHandler(serverCtx),
+				Path:    "/crmApplication/ent/info",
+				Handler: entinfoHandler(serverCtx),
+			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/crmApplication/info/push",
+				Handler: pushMsgHandler(serverCtx),
 			},
 			{
 				Method:  http.MethodPost,
@@ -64,34 +74,39 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 			},
 			{
 				Method:  http.MethodPost,
-				Path:    "/crmApplication/info/push",
-				Handler: pushMsgHandler(serverCtx),
+				Path:    "/crmApplication/owner/List",
+				Handler: ownerListHandler(serverCtx),
 			},
 			{
 				Method:  http.MethodPost,
-				Path:    "/crmApplication/infomation/detail",
-				Handler: infoDetailHandler(serverCtx),
+				Path:    "/crmApplication/network/project/list",
+				Handler: projectListHandler(serverCtx),
 			},
 			{
 				Method:  http.MethodPost,
-				Path:    "/crmApplication/information/transfer",
-				Handler: transferHandler(serverCtx),
+				Path:    "/crmApplication/pr/pname/ass",
+				Handler: PrPnameAssHandler(serverCtx),
 			},
 			{
 				Method:  http.MethodPost,
-				Path:    "/crmApplication/network/addOrUpdate",
-				Handler: addOrUpdateHandler(serverCtx),
+				Path:    "/crmApplication/pr/project/analyse",
+				Handler: CoopHistoryListHandler(serverCtx),
 			},
 			{
 				Method:  http.MethodPost,
-				Path:    "/crmApplication/network/allProject",
-				Handler: allProjectHandler(serverCtx),
+				Path:    "/crmApplication/network/addOrUpdate",
+				Handler: addOrUpdateHandler(serverCtx),
 			},
 			{
 				Method:  http.MethodPost,
 				Path:    "/crmApplication/network/associate",
 				Handler: associateHandler(serverCtx),
 			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/crmApplication/network/allProject",
+				Handler: allProjectHandler(serverCtx),
+			},
 			{
 				Method:  http.MethodPost,
 				Path:    "/crmApplication/network/networkList",
@@ -99,38 +114,38 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 			},
 			{
 				Method:  http.MethodPost,
-				Path:    "/crmApplication/network/plist/pathway",
-				Handler: plistPathHandler(serverCtx),
+				Path:    "/crmApplication/ignore/action",
+				Handler: ignoreActionHandler(serverCtx),
 			},
 			{
 				Method:  http.MethodPost,
-				Path:    "/crmApplication/network/project/list",
-				Handler: projectListHandler(serverCtx),
+				Path:    "/crmApplication/infomation/detail",
+				Handler: infoDetailHandler(serverCtx),
 			},
 			{
 				Method:  http.MethodPost,
-				Path:    "/crmApplication/owner/List",
-				Handler: ownerListHandler(serverCtx),
+				Path:    "/crmApplication/network/plist/pathway",
+				Handler: plistPathHandler(serverCtx),
 			},
 			{
 				Method:  http.MethodPost,
-				Path:    "/crmApplication/pr/pname/ass",
-				Handler: PrPnameAssHandler(serverCtx),
+				Path:    "/crmApplication/pr/project/history",
+				Handler: projectHistoryHandler(serverCtx),
 			},
 			{
 				Method:  http.MethodPost,
-				Path:    "/crmApplication/pr/project/analyse",
-				Handler: CoopHistoryListHandler(serverCtx),
+				Path:    "/crmApplication/owner/route",
+				Handler: ownerRouteHandler(serverCtx),
 			},
 			{
 				Method:  http.MethodPost,
-				Path:    "/crmApplication/pr/project/history",
-				Handler: projectHistoryHandler(serverCtx),
+				Path:    "/crmApplication/owner/cooperate",
+				Handler: ownerCooperateHandler(serverCtx),
 			},
 			{
 				Method:  http.MethodPost,
-				Path:    "/crmApplication/saleChance/add",
-				Handler: saleChanceAddHandler(serverCtx),
+				Path:    "/crmApplication/candidate/channel",
+				Handler: candidateChannelHandler(serverCtx),
 			},
 		},
 		rest.WithMaxBytes(104857600),

+ 41 - 0
api/internal/logic/candidatechannellogic.go

@@ -0,0 +1,41 @@
+package logic
+
+import (
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/service"
+	"context"
+
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type CandidateChannelLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewCandidateChannelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CandidateChannelLogic {
+	return &CandidateChannelLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *CandidateChannelLogic) CandidateChannel(req *types.ChannelListReq) (resp *types.Reply, err error) {
+	// todo: add your logic here and delete this line
+	resp = &types.Reply{}
+	ownerService := &service.OwnerService{
+		PartyA:       req.PartyA,
+		Supplier:     req.Supplier,
+		Intermediary: req.Intermediary,
+		Heterotophy:  req.Heterotophy,
+		Agency:       req.Agency,
+		PositionId:   req.PositionId,
+	}
+	data := ownerService.CandidateChannel()
+	resp.Data = data
+	return
+}

+ 41 - 0
api/internal/logic/ownercooperatelogic.go

@@ -0,0 +1,41 @@
+package logic
+
+import (
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/service"
+	"context"
+
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type OwnerCooperateLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewOwnerCooperateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OwnerCooperateLogic {
+	return &OwnerCooperateLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *OwnerCooperateLogic) OwnerCooperate(req *types.CooperateOwnerListReq) (resp *types.Reply, err error) {
+	// todo: add your logic here and delete this line
+
+	resp = &types.Reply{}
+	ownerService := &service.OwnerService{
+		BuyerId:       req.BuyerId,
+		BuyerName:     req.BuyerName,
+		WinnerName:    req.WinnerName,
+		WinnerId:      req.WinnerName,
+		CooperateType: req.CooperateType,
+	}
+	data := ownerService.OwnerCooperate()
+	resp.Data = data
+	return
+}

+ 1 - 1
api/internal/logic/ownerlistlogic.go

@@ -1,7 +1,7 @@
 package logic
 
 import (
-	"bp.jydev.jianyu360.cn/CRM/application/service"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/service"
 	"context"
 
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"

+ 37 - 0
api/internal/logic/ownerroutelogic.go

@@ -0,0 +1,37 @@
+package logic
+
+import (
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/service"
+	"context"
+
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type OwnerRouteLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewOwnerRouteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OwnerRouteLogic {
+	return &OwnerRouteLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *OwnerRouteLogic) OwnerRoute(req *types.RouteOwnerListReq) (resp *types.Reply, err error) {
+	// todo: add your logic here and delete this line
+	resp = &types.Reply{}
+	ownerService := &service.OwnerService{
+		BuyerId:   req.BuyerId,
+		BuyerName: req.BuyerName,
+	}
+	data := ownerService.OwnerRoute()
+	resp.Data = data
+	return
+}

+ 1 - 1
api/internal/logic/plistpathlogic.go

@@ -1,7 +1,7 @@
 package logic
 
 import (
-	"bp.jydev.jianyu360.cn/CRM/application/service"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/service"
 	"context"
 
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"

+ 911 - 0
api/internal/service/owner.go

@@ -0,0 +1,911 @@
+package service
+
+import (
+	"app.yhyue.com/moapp/jybase/common"
+	elastic "app.yhyue.com/moapp/jybase/es"
+	. "bp.jydev.jianyu360.cn/CRM/application/api/common"
+	"bp.jydev.jianyu360.cn/CRM/application/entity"
+	"context"
+	"encoding/json"
+	"fmt"
+	"github.com/gogf/gf/v2/util/gconv"
+	"github.com/shopspring/decimal"
+	"github.com/zeromicro/go-zero/core/logx"
+	"strings"
+)
+
+const (
+	EntINDEX = "ent_info"
+	EntTYPE  = "ent_info"
+)
+
+type OwnerService struct {
+	PartyA           string
+	Supplier         string
+	Heterotophy      string
+	Intermediary     string
+	Agency           string
+	SearchEntName    string
+	SourceType       string
+	ProcessingStatus string
+	Area             string
+	PositionId       int64
+	PageIndex        int64
+	PageSize         int64
+	BuyerId          string
+	BuyerName        string
+	WinnerId         string
+	WinnerName       string
+	CooperateType    string
+	EntAccountId     int64
+}
+
+type BuyerProject struct {
+	BuyerId          string
+	BuyerName        string
+	Project          ProjectEntity
+	IsMonitor        bool
+	IsCreateCustomer bool
+	IsIgnore         bool
+	Area             string
+	Zbtime           int64
+}
+type ProjectEntity struct {
+	Number          int64
+	zbtime          int64
+	EstimatedAmount int64
+	Connections     []map[string]interface{}
+}
+type Recommend struct {
+	buyerId string `ch:"buyer_id"`
+	buyer   string `ch:"buyer"`
+}
+type Project struct {
+	BuyerId    string          `ch:"buyer_id"`
+	Area       string          `ch:"area"`
+	GroupCount uint64          `ch:"group_count"`
+	Zbtime     int64           `ch:"zbtime"`
+	Money      decimal.Decimal `ch:"money"`
+}
+
+func (t *OwnerService) OwnerlList() map[string]interface{} {
+	//先查询采购单位列表
+	dataMap := &map[string]map[string]interface{}{}
+	projectMap := &map[string]map[string]interface{}{}
+	if t.PartyA != "" || t.Supplier != "" || t.Heterotophy != "" || t.Intermediary != "" || t.Agency != "" {
+		dataMap = BuyerList(t.PartyA, t.Supplier, t.Heterotophy, t.Intermediary, t.Agency)
+		//处理状态初始化
+		if t.ProcessingStatus != "" {
+			ProcessingStatusInit(t.PositionId, dataMap, t.ProcessingStatus)
+		}
+		//监控状态处理
+		MonitorStatusInit(t.PositionId, dataMap, t.SourceType)
+		//项目数量查询
+		buyerArr := []string{}
+		for _, value := range *dataMap {
+			buyerArr = append(buyerArr, fmt.Sprintf(`"%s"`, gconv.String(value["buyerName"])))
+		}
+		//项目数量处理
+		projectMap = ProjectHandle(buyerArr, "", t.Area)
+		logx.Info(projectMap)
+	} else if t.SearchEntName != "" {
+		//1 只看转介绍成功率高2只看已监控的
+		if t.SourceType == "2" {
+			buyerArr := FindMonitor(t.PositionId, t.SearchEntName)
+			if len(buyerArr) > 0 {
+				projectMap = ProjectHandle(buyerArr, "", t.Area)
+			}
+		} else {
+			projectMap = ProjectHandle([]string{}, t.SearchEntName, t.Area)
+		}
+		dataMap = FindBuyer(t.SearchEntName)
+	}
+	if len(*dataMap) == 0 {
+		return map[string]interface{}{}
+	}
+	//采购单位和项目合并
+	returnData, connectionsNumber, highSuccessNumber, monitorNumber := BuyerProjectMerge(dataMap, projectMap, t.SourceType)
+	//数组排序
+	//分页数据处理
+	if t.PageSize == 0 {
+		t.PageSize = 10
+	}
+	if t.PageIndex == 0 {
+		t.PageIndex = 1
+	}
+	startIndex := (t.PageIndex - 1) * t.PageSize
+	endIndex := t.PageIndex * t.PageSize
+	if startIndex < gconv.Int64(len(returnData)) {
+		if endIndex > gconv.Int64(len(returnData)) {
+			endIndex = gconv.Int64(len(returnData))
+		}
+		returnData = returnData[startIndex:endIndex]
+	} else {
+		return map[string]interface{}{}
+	}
+	buyerIdArr := []string{}
+	for _, value := range returnData {
+		buyerIdArr = append(buyerIdArr, fmt.Sprintf("'%s'", value.BuyerId))
+	}
+	//可介绍业主人脉处理
+	companyList := ConnectionsHandle(buyerIdArr, t.PositionId, false)
+	for _, v := range companyList {
+		buyerId := gconv.String(v["a_id"])
+		for i, v1 := range returnData {
+			aBuyerId := v1.BuyerId
+			if buyerId == aBuyerId {
+				//组装数据
+				returnData[i].Project.Connections = append(returnData[i].Project.Connections, v)
+			}
+		}
+	}
+	//返回数据组装
+	return map[string]interface{}{
+		"connectionsNumber": connectionsNumber,
+		"highSuccessNumber": highSuccessNumber,
+		"monitorNumber":     monitorNumber,
+		"list":              returnData,
+	}
+}
+
+// 可介绍业主人脉列表
+func ConnectionsHandle(buyerArr []string, positionId int64, isAll bool) []map[string]interface{} {
+	returnData := []map[string]interface{}{}
+	//中间人  作为可介绍业主    企业名称
+	companyArr := CrmMysql.SelectBySql(
+		fmt.Sprintf("select DISTINCT  b.company_id,b.company_name,a.relate_id,a.relate_name,b.contact_person   from  connection_introduce a  INNER JOIN  connection   b  on  a.position_id=%d  and a.connection_id=b.id  and   a.relate_Id in (%s) and  a.itype =1  and  b.itype=4 and  b.status=1 ", positionId, strings.Join(buyerArr, ",")))
+	for _, v := range *companyArr {
+		companyId := gconv.String(v["company_id"])
+		companyName := gconv.String(v["company_name"])
+		relateName := gconv.String(v["relate_name"])
+		relateId := gconv.String(v["relate_id"])
+		//key := fmt.Sprintf("%s_%s", relateId, companyId)
+		returnData = append(returnData, map[string]interface{}{
+			"b_id":         companyId,
+			"b_name":       companyName,
+			"a_name":       relateName,
+			"a_id":         relateId,
+			"sourceType":   "intermediary",
+			"relationship": "业主的关系人",
+			"personName":   gconv.String(v["contact_person"]),
+		})
+	}
+	if isAll && len(returnData) > 0 {
+		return returnData
+	}
+	//采购单位 投资关系  管辖关系
+	//buyerSql := fmt.Sprintf("select  a_id,b_id,a_name,b_name,code  from  ent_map_code a  where ( a_name  in  (%s) or b_name  in  (%s)  ) and   code in('0101','0201')", strings.Join(buyerArr, ","), strings.Join(buyerArr, ","))
+	buyerSql := fmt.Sprintf(`select  a.a_id as a_id,a.b_id as b_id,a.a_name as a_name,a.b_name as b_name,a.code as code,c.legal_person as  c_person,d.legal_person d_person  from  ent_map_code   a   
+	left join  ent_info  c on  (a.a_id  in  (%s) or a.b_id  in  (%s)  ) and  a.code in('0101','0201')   and  a.a_id =c.id  
+	left join  ent_info  d on  (a.a_id  in  (%s) or a.b_id  in  (%s) ) and   a.code in('0101','0201')  and a.b_id =d.id  
+	where (a.a_id  in  (%s) or a.b_id  in  (%s)  ) and   a.code in('0101','0201')`,
+		strings.Join(buyerArr, ","),
+		strings.Join(buyerArr, ","),
+		strings.Join(buyerArr, ","),
+		strings.Join(buyerArr, ","),
+		strings.Join(buyerArr, ","),
+		strings.Join(buyerArr, ","))
+	relationshipArr := BuyerFindConnectionsHandle(buyerSql)
+	if relationshipArr != nil && len(relationshipArr) > 0 {
+		for _, v := range relationshipArr {
+			for _, v1 := range buyerArr {
+				code := v.Code
+				if fmt.Sprintf("'%s'", v.Aid) == v1 {
+					//key := fmt.Sprintf("%s_%s", a_id, b_id)
+					switch code {
+					case "0101": //管辖关系
+						returnData = append(returnData, map[string]interface{}{
+							"b_id":         v.Bid,
+							"b_name":       v.Bname,
+							"a_name":       v.Aname,
+							"a_id":         v.Aid,
+							"sourceType":   "buyer",
+							"relationship": "业主的上级机构",
+							"personName":   v.Dperson,
+						})
+
+					case "0201": //投资关系
+						returnData = append(returnData, map[string]interface{}{
+							"b_id":         v.Bid,
+							"b_name":       v.Bname,
+							"a_name":       v.Aname,
+							"a_id":         v.Aid,
+							"sourceType":   "buyer",
+							"relationship": "业主的股东",
+							"personName":   v.Dperson,
+						})
+					}
+				}
+				if fmt.Sprintf("'%s'", v.Bid) == v1 {
+					//key := fmt.Sprintf("%s_%s", b_id, a_id)
+					if code == "0101" {
+						//"0101":管辖关系
+						returnData = append(returnData, map[string]interface{}{
+							"b_id":         v.Aid,
+							"b_name":       v.Aname,
+							"a_name":       v.Bname,
+							"a_id":         v.Bid,
+							"sourceType":   "buyer",
+							"relationship": "业主的下级机构",
+							"personName":   v.Cperson,
+						})
+					}
+				}
+			}
+		}
+	}
+	//供应商  采购单位 供应商     招标代理机构  采购单位  招标代理机构  需要计算合作次数
+	winnerSql := fmt.Sprintf(`SELECT DISTINCT  a.zbtime as zbtime ,a.project_id as project_id,a.buyer_id as buyer_id,a.buyer as  buyer,a.agency_id as agency_id,a.agency as  agency,c.company_name as company_name ,b.name as personName ,a.winnerId  as awinnerId
+	FROM 
+	   (select zbtime,project_id,buyer_id,buyer,agency_id,agency,winner_id as winnerId   from  transaction_info     
+	ARRAY JOIN  winner_id ) a 
+	inner join ent_contact  b   on a.buyer_id in (%s) and  a.winnerId=b.id 
+	inner join ent_info  c   on a.winnerId=c.id order by a.zbtime,a.winnerId`, strings.Join(buyerArr, ","))
+	winnerArr := SupplierFindConnectionsHandle(winnerSql)
+	if winnerArr != nil && len(winnerArr) > 0 {
+		winnerMap := map[string]map[string]interface{}{}
+		agencyMap := map[string]map[string]interface{}{}
+		for _, m := range winnerArr {
+			buyerId := m.Buyer_id
+			winner := m.Company_name
+			buyer := m.Buyer
+			winnerId := m.AwinnerId
+			agency := m.Agency
+			agencyId := m.Agency_id
+			projectId := m.Project_id
+			zbtime := m.Zbtime
+			personName := m.PersonName
+			key := fmt.Sprintf("%s_%s", buyerId, winnerId)
+			returnData = append(returnData, map[string]interface{}{
+				"b_id":       winnerId,
+				"b_name":     winner,
+				"a_name":     buyer,
+				"a_id":       buyerId,
+				"sourceType": "supplier",
+				"personName": personName,
+			})
+			if _, ok := winnerMap[key]; ok {
+				data := winnerMap[key]
+				data["count"] = gconv.Int64(data["data"]) + 1
+				dataList := gconv.Maps(data["list"])
+				dataList = append(dataList, map[string]interface{}{
+					"zbtime":  zbtime,
+					"entName": winner,
+				})
+				data["list"] = dataList
+				winnerMap[key] = data
+			} else {
+				winnerMap[key] = map[string]interface{}{
+					"b_id":       winnerId,
+					"b_name":     winner,
+					"a_name":     buyer,
+					"a_id":       buyerId,
+					"sourceType": "supplier",
+					"personName": personName,
+					"count":      1,
+					"list": []map[string]interface{}{
+						{
+							"zbtime":  zbtime,
+							"entName": winner,
+						},
+					},
+				}
+			}
+			key = fmt.Sprintf("%s_%s_%s", buyerId, agencyId, projectId)
+			if _, ok := agencyMap[key]; ok {
+				data := agencyMap[key]
+				data["count"] = gconv.Int64(data["data"]) + 1
+				dataList := gconv.Maps(data["list"])
+				dataList = append(dataList, map[string]interface{}{
+					"zbtime":  zbtime,
+					"entName": winner,
+				})
+				data["list"] = dataList
+				agencyMap[key] = data
+			} else {
+				agencyMap[key] = map[string]interface{}{
+					"b_id":       agencyId,
+					"b_name":     agency,
+					"a_name":     buyer,
+					"a_id":       buyerId,
+					"sourceType": "agent",
+					"count":      1,
+					"personName": personName,
+					"list": []map[string]interface{}{
+						{
+							"zbtime":  zbtime,
+							"entName": agency,
+						},
+					},
+				}
+			}
+		}
+		for _, m := range winnerMap {
+			returnData = append(returnData, map[string]interface{}{
+				"b_id":         gconv.String(m["b_id"]),
+				"b_name":       gconv.String(m["b_name"]),
+				"a_name":       gconv.String(m["a_name"]),
+				"a_id":         gconv.String(m["a_id"]),
+				"sourceType":   gconv.String(m["sourceType"]),
+				"relationship": gconv.String(m["relationship"]),
+				"count":        gconv.Int64(m["count"]),
+			})
+		}
+		for _, m := range agencyMap {
+			returnData = append(returnData, map[string]interface{}{
+				"b_id":         gconv.String(m["b_id"]),
+				"b_name":       gconv.String(m["b_name"]),
+				"a_name":       gconv.String(m["a_name"]),
+				"a_id":         gconv.String(m["a_id"]),
+				"sourceType":   gconv.String(m["sourceType"]),
+				"relationship": gconv.String(m["relationship"]),
+				"count":        gconv.Int64(m["count"]),
+			})
+		}
+	}
+	return returnData
+}
+
+// 采购单位和项目合并
+func BuyerProjectMerge(dataMap, projectMap *map[string]map[string]interface{}, sourceType string) ([]BuyerProject, int64, int64, int64) {
+	returnData := []BuyerProject{}
+	connectionsNumber := int64(0)
+	highSuccessNumber := int64(0)
+	monitorNumber := int64(0)
+	for buyerId, buyerMap := range *dataMap {
+		buyerName := gconv.String(buyerMap["buyerName"])
+		if _, ok := (*projectMap)[buyerId]; ok {
+			projectMap := (*projectMap)[buyerId]
+			if isMonitor := gconv.Bool(buyerMap["isMonitor"]); isMonitor {
+				monitorNumber++
+			}
+			count := gconv.Int64(projectMap["count"])
+			money := gconv.Int64(projectMap["money"])
+			zbtime := gconv.Int64(projectMap["zbtime"])
+			if sourceType == "1" {
+				if count < 2 {
+					continue
+				}
+				highSuccessNumber++
+				returnData = append(returnData, BuyerProject{
+					BuyerId:   buyerId,
+					BuyerName: buyerName,
+					Project: ProjectEntity{
+						Number:          count,
+						EstimatedAmount: money,
+						Connections:     []map[string]interface{}{},
+					},
+					Area:   gconv.String(projectMap["area"]),
+					Zbtime: zbtime,
+				})
+			} else {
+				if count > 2 {
+					highSuccessNumber++
+				}
+				returnData = append(returnData, BuyerProject{
+					BuyerId:   buyerId,
+					BuyerName: buyerName,
+					Project: ProjectEntity{
+						Number:          count,
+						EstimatedAmount: money,
+						Connections:     []map[string]interface{}{},
+					},
+					Area:   gconv.String(projectMap["area"]),
+					Zbtime: zbtime,
+				})
+			}
+		} else {
+			returnData = append(returnData, BuyerProject{
+				BuyerId:   buyerId,
+				BuyerName: buyerName,
+				Project: ProjectEntity{
+					Number:          0,
+					EstimatedAmount: 0,
+					Connections:     []map[string]interface{}{},
+				},
+				Area:   "",
+				Zbtime: 0,
+			})
+		}
+		connectionsNumber++
+	}
+	return returnData, connectionsNumber, highSuccessNumber, monitorNumber
+}
+
+// 已监控数据处理
+func MonitorStatusInit(positionId int64, dataMap *map[string]map[string]interface{}, sourceType string) {
+	monitorMap := map[string]bool{}
+	query := map[string]interface{}{
+		"userId": positionId,
+	}
+	clist, ok := Mgo.Find("follow_customer", query, ``, `{"name":1}`, false, -1, -1)
+	if ok && clist != nil && len(*clist) > 0 {
+		for _, v := range *clist {
+			monitorMap[gconv.String(v["name"])] = true
+		}
+
+	}
+	//采购单位和自己监控的对比
+	newMap := &map[string]map[string]interface{}{}
+	for k, v := range *dataMap {
+		buyerName := gconv.String(v["buyerName"])
+		if _, ok1 := monitorMap[gconv.String(buyerName)]; ok1 {
+			v["isMonitor"] = true
+			(*newMap)[k] = v
+		} else {
+			if sourceType != "2" && sourceType != "1" {
+				v["isMonitor"] = false
+				(*newMap)[k] = v
+			}
+		}
+	}
+	if newMap != nil {
+		dataMap = newMap
+	}
+}
+
+// 监控数据查询初始化
+func FindMonitor(positionId int64, entName string) []string {
+	nameArr := []string{}
+	clist, ok := Mgo.Find("", map[string]interface{}{
+		"userId": positionId,
+		"name":   fmt.Sprintf(" /.*%s.*/i", entName),
+	}, "", `{"name":1}`, false, -1, -1)
+	if ok && clist != nil && len(*clist) > 0 {
+		for _, v := range *clist {
+			nameArr = append(nameArr, fmt.Sprintf(`"%s"`, gconv.String(v["name"])))
+		}
+
+	}
+	return nameArr
+}
+
+// 处理状态初始化
+func ProcessingStatusInit(positionId int64, dataMap *map[string]map[string]interface{}, processingStatus string) {
+	//未处理
+	untreatedMap := &map[string]bool{}
+	//已忽略
+	ignoredMap := &map[string]bool{}
+	//已创建
+	createdMap := &map[string]bool{}
+	processingArr := CrmMysql.Find(entity.CONNECTION_STATUS, map[string]interface{}{
+		"type":        1,
+		"position id": positionId,
+	}, "relate_id,is_handle,is_ignore,is_create", "", -1, -1)
+	if len(*processingArr) > 0 {
+		for _, v := range *processingArr {
+			entId := gconv.String(v["relate_id"])
+			handle := gconv.Int64(v["is_handle"])
+			ignore := gconv.Int64(v["is_ignore"])
+			create := gconv.Int64(v["is_create"])
+			if handle == 1 {
+				(*untreatedMap)[entId] = true
+			}
+			if ignore == 1 {
+				(*ignoredMap)[entId] = true
+			}
+			if create == 1 {
+				(*createdMap)[entId] = true
+			}
+		}
+	}
+	newMap := &map[string]map[string]interface{}{}
+	//所有采购单位和处理状态对比
+	for buyerId, value := range *dataMap {
+		for _, v := range strings.Split(processingStatus, ",") {
+			switch v {
+			case "1":
+				if _, ok := (*untreatedMap)[buyerId]; !ok {
+					(*newMap)[buyerId] = value
+				}
+			case "2":
+				if _, ok := (*ignoredMap)[buyerId]; ok {
+					(*newMap)[buyerId] = value
+				}
+			case "3":
+				if _, ok := (*createdMap)[buyerId]; ok {
+					(*newMap)[buyerId] = value
+				}
+			}
+		}
+	}
+	if newMap != nil {
+		dataMap = newMap
+	}
+}
+
+// 采购单位查询
+func BuyerList(partyA, supplier, heterotophy, intermediary, agency string) *map[string]map[string]interface{} {
+	dataMap := &map[string]map[string]interface{}{}
+	//甲方
+	if partyA != "" {
+		for _, v := range strings.Split(partyA, ",") {
+			intermediaryArr := strings.Split(v, "_")
+			if len(intermediaryArr) == 2 {
+				(*dataMap)[intermediaryArr[0]] = map[string]interface{}{
+					"buyerName": intermediaryArr[1],
+				}
+			}
+		}
+	}
+	//供应商 //同甲异业
+	if supplier != "" || heterotophy != "" {
+		findInSetArr := []string{}
+		for _, v := range strings.Split(supplier, ",") {
+			findInSetArr = append(findInSetArr, fmt.Sprintf("'%s'", v))
+		}
+		for _, v := range strings.Split(heterotophy, ",") {
+			findInSetArr = append(findInSetArr, fmt.Sprintf("'%s'", v))
+		}
+		sqlStr := fmt.Sprintf(`SELECT buyer, buyer_id FROM transaction_info where  hasAny(winner_id,[%s])    `, strings.Join(findInSetArr, ","))
+		FindHandle(sqlStr, dataMap)
+	}
+	//中间人
+	if intermediary != "" {
+		for _, v := range strings.Split(intermediary, ",") {
+			intermediaryArr := strings.Split(v, "_")
+			if len(intermediaryArr) == 2 {
+				(*dataMap)[intermediaryArr[0]] = map[string]interface{}{
+					"buyerName": intermediaryArr[1],
+				}
+			}
+		}
+	}
+	//招标代理
+	if agency != "" {
+		agencyArr := []string{}
+		for _, s := range strings.Split(agency, ",") {
+			agencyArr = append(agencyArr, fmt.Sprintf("'%s'"), s)
+		}
+		sqlStr := fmt.Sprintf(`SELECT buyer, buyer_id FROM transaction_info  where agency_id in (%s)   order by  userid`, strings.Join(agencyArr, ","))
+		FindHandle(sqlStr, dataMap)
+	}
+	return dataMap
+}
+
+// 项目数量查询
+func ProjectHandle(buyerArr []string, entName, area string) *map[string]map[string]interface{} {
+	projectMap := &map[string]map[string]interface{}{}
+	sql := ""
+	sqlStr := ""
+	if entName != "" {
+		sql = `{"query":{"bool":{"must":[{"terms":{"buyer":[%s]%s}}]}},"aggs":{"buyer_count":{"terms":{"field":"buyer","size":1000,"order":{"_count":"desc"}},"aggs":{"project_count":{"terms":{"field":"winner"}}}},"area_count":{"terms":{"field":"buyer","size":1000,"order":{"_count":"desc"}},"aggs":{"area_count":{"terms":{"field":"area"}}}},"money_count":{"terms":{"field":"buyer","size":1000,"order":{"_count":"desc"}},"aggs":{"money_count":{"sum":{"field":"bidendtime"}}}},"zbtime_count":{"terms":{"field":"buyer","size":1000,"order":{"_count":"desc"}},"aggs":{"zbtime_count":{"max":{"field":"bidendtime"}}}}},"size":%d}`
+		sqlStr = fmt.Sprintf(sql, strings.Join(buyerArr, ","), common.If(area != "", fmt.Sprintf(`,{"term":{"area":"%s"}}`, area), ""), len(buyerArr))
+
+	} else {
+		sql = `{"query":{"bool":{"must":[{"terms":{"buyer":[%s]%s}}]}},"aggs":{"buyer_count":{"terms":{"field":"buyer","size":1000,"order":{"_count":"desc"}},"aggs":{"project_count":{"terms":{"field":"winner"}}}},"area_count":{"terms":{"field":"buyer","size":1000,"order":{"_count":"desc"}},"aggs":{"area_count":{"terms":{"field":"area"}}}},"money_count":{"terms":{"field":"buyer","size":1000,"order":{"_count":"desc"}},"aggs":{"money_count":{"sum":{"field":"bidendtime"}}}},"zbtime_count":{"terms":{"field":"buyer","size":1000,"order":{"_count":"desc"}},"aggs":{"zbtime_count":{"max":{"field":"bidendtime"}}}}},"size":%d}`
+		sqlStr = fmt.Sprintf(sql, strings.Join(buyerArr, ","), common.If(area != "", fmt.Sprintf(`,{"term":{"area":"%s"}}`, area), ""), len(buyerArr))
+
+	}
+	data, _, _ := elastic.GetAggs(INDEX, TYPE, sqlStr)
+	for name, object := range data {
+		switch name {
+		case "buyer_count":
+			buyerArr := BuyerAggStruct{}
+			bs, ok := object.MarshalJSON()
+			if ok != nil {
+				logx.Error("解析项目数据失败", object)
+				continue
+			}
+			json.Unmarshal(bs, &buyerArr)
+			for _, v := range buyerArr.Buckets {
+				key := v.Key
+				if (*projectMap)[key] != nil {
+					value := (*projectMap)[key]
+					value["count"] = v.Doc_count
+					(*projectMap)[key] = value
+				} else {
+					(*projectMap)[key] = map[string]interface{}{
+						"count": v.Doc_count,
+					}
+				}
+			}
+		case "area_count":
+			areaArr := AreaAggStruct{}
+			bs, ok := object.MarshalJSON()
+			if ok != nil {
+				logx.Error("解析项目数据失败", object)
+				continue
+			}
+			json.Unmarshal(bs, &areaArr)
+			logx.Info(areaArr)
+			for _, v := range areaArr.Buckets {
+				key := v.Key
+				area := ""
+				for _, v1 := range v.Area_count.Buckets {
+					area = Deduplication(area, v1.Key)
+				}
+				if (*projectMap)[key] != nil {
+					value := (*projectMap)[key]
+					value["area"] = area
+					(*projectMap)[key] = value
+				} else {
+
+					(*projectMap)[key] = map[string]interface{}{
+						"area": area,
+					}
+				}
+			}
+		case "money_count":
+			moneyArr := MoneyAggStruct{}
+			bs, ok := object.MarshalJSON()
+			if ok != nil {
+				logx.Error("解析项目数据失败", object)
+				continue
+			}
+			json.Unmarshal(bs, &moneyArr)
+			logx.Info(moneyArr)
+			for _, v := range moneyArr.Buckets {
+				key := v.Key
+				if (*projectMap)[key] != nil {
+					value := (*projectMap)[key]
+					value["money"] = v.Money_count.Value
+					(*projectMap)[key] = value
+				} else {
+					(*projectMap)[key] = map[string]interface{}{
+						"money": v.Money_count.Value,
+					}
+				}
+			}
+		case "zbtime_count":
+			timeArr := TimeAggStruct{}
+			bs, ok := object.MarshalJSON()
+			if ok != nil {
+				logx.Error("解析项目数据失败", object)
+				continue
+			}
+			a := json.Unmarshal(bs, &timeArr)
+			logx.Info(timeArr, a)
+			for _, v := range timeArr.Buckets {
+				key := v.Key
+				if (*projectMap)[key] != nil {
+					value := (*projectMap)[key]
+					value["zbtime"] = v.Zbtime_count.Value
+					(*projectMap)[key] = value
+				} else {
+					(*projectMap)[key] = map[string]interface{}{
+						"zbtime": v.Zbtime_count.Value,
+					}
+				}
+			}
+		}
+	}
+	return projectMap
+}
+
+type TimeAggStruct struct {
+	Buckets []struct {
+		Key          string `json:"key,omitempty"`
+		Zbtime_count struct {
+			Value interface{} `json:"value,omitempty"`
+		} `json:"zbtime_count,omitempty"`
+	}
+}
+type MoneyAggStruct struct {
+	Buckets []struct {
+		Key         string `json:"key,omitempty"`
+		Money_count struct {
+			Value interface{} `json:"value,omitempty"`
+		} `json:"money_count,omitempty"`
+	}
+}
+type BuyerAggStruct struct {
+	Buckets []struct {
+		Key         string `json:"key,omitempty"`
+		Doc_count   int64  `json:"doc_count,omitempty"`
+		Buyer_count struct {
+			value string `json:"value,omitempty"`
+		} `json:"buyer_count,omitempty"`
+	}
+}
+type AreaAggStruct struct {
+	Buckets []struct {
+		Key        string `json:"key,omitempty"`
+		Area_count struct {
+			Buckets []struct {
+				Key       string `json:"key,omitempty"`
+				Doc_count int64  `json:"doc_count,omitempty"`
+			}
+		} `json:"area_count"`
+	}
+}
+
+// 采购单位查询sql
+func FindHandle(sqlStr string, dataMap *map[string]map[string]interface{}) {
+	rows, err := ClickhouseConn.Query(context.Background(), sqlStr)
+	if err != nil {
+		logx.Error("查询失败", sqlStr, err)
+	}
+	for rows.Next() {
+		data := Recommend{}
+		rows.ScanStruct(&data)
+		(*dataMap)[data.buyerId] = map[string]interface{}{
+			"buyerName": data.buyer,
+		}
+	}
+	return
+}
+
+type ConnectionsEntity struct {
+	Aid     string `ch:"a_id"`
+	Bid     string `ch:"b_id"`
+	Aname   string `ch:"a_name"`
+	Bname   string `ch:"b_name"`
+	Code    string `ch:"code"`
+	Cperson string `ch:"c_person"`
+	Dperson string `ch:"d_person"`
+}
+type SupplierConnectionsEntity struct {
+	Zbtime       int64  `ch:"zbtime"`
+	Project_id   string `ch:"project_id"`
+	Buyer_id     string `ch:"buyer_id"`
+	Buyer        string `ch:"buyer"`
+	Agency_id    string `ch:"agency_id"`
+	Agency       string `ch:"agency"`
+	Company_name string `ch:"company_name"`
+	PersonName   string `ch:"personName"`
+	AwinnerId    string `ch:"AwinnerId "`
+}
+type TimeConnectionsEntity struct {
+	Zbtime int64 `ch:"zbtime"`
+}
+
+// 采购单位人脉信息查询sql
+func BuyerFindConnectionsHandle(sqlStr string) []ConnectionsEntity {
+	returnData := []ConnectionsEntity{}
+	rows, err := ClickhouseConn.Query(context.Background(), sqlStr)
+	if err != nil {
+		logx.Error("查询失败", sqlStr, err)
+	}
+	for rows.Next() {
+		data := ConnectionsEntity{}
+		rows.ScanStruct(&data)
+		returnData = append(returnData, data)
+	}
+	return returnData
+}
+
+// 供应商
+func SupplierFindConnectionsHandle(sqlStr string) []SupplierConnectionsEntity {
+	returnData := []SupplierConnectionsEntity{}
+	rows, err := ClickhouseConn.Query(context.Background(), sqlStr)
+	if err != nil {
+		logx.Error("查询失败", sqlStr, err)
+	}
+	for rows.Next() {
+		data := SupplierConnectionsEntity{}
+		rows.ScanStruct(&data)
+		returnData = append(returnData, data)
+	}
+	return returnData
+}
+
+// 合作时间查询
+func TimeFindConnectionsHandle(sqlStr string) []TimeConnectionsEntity {
+	returnData := []TimeConnectionsEntity{}
+	rows, err := ClickhouseConn.Query(context.Background(), sqlStr)
+	if err != nil {
+		logx.Error("查询失败", sqlStr, err)
+	}
+	for rows.Next() {
+		data := TimeConnectionsEntity{}
+		rows.ScanStruct(&data)
+		returnData = append(returnData, data)
+	}
+	return returnData
+}
+
+// 去重处理
+func Deduplication(a, b string) string {
+	newArr := []string{}
+	if b == "全国" {
+		return a
+	}
+	if a != "" {
+		newArr = append(newArr, a)
+	}
+	if b != "" {
+		newArr = append(newArr, b)
+	}
+	return strings.Join(newArr, ",")
+}
+func FindBuyer(searchName string) *map[string]map[string]interface{} {
+	sql := `{"query":{"bool":{"must":[{"match":{"company_name":"%s"}}]}},"sort":[{"_id":"asc"}],"_source":["id","company_name"],"from":0,"size":10}`
+	sqlStr := fmt.Sprintf(sql, searchName)
+	data := elastic.Get(EntINDEX, EntTYPE, sqlStr)
+	dataMap := &map[string]map[string]interface{}{}
+	for _, m := range *data {
+		id := gconv.String(m["id"])
+		name := gconv.String(m["company_name"])
+		(*dataMap)[id] = map[string]interface{}{
+			"buyerName": name,
+		}
+	}
+	return dataMap
+}
+
+// 路径列表
+func (t *OwnerService) OwnerRoute() []map[string]interface{} {
+	companyList := ConnectionsHandle([]string{
+		fmt.Sprintf("'%s'", t.BuyerId),
+	}, t.PositionId, false)
+	return companyList
+}
+
+// 合作列表
+func (t *OwnerService) OwnerCooperate() []map[string]interface{} {
+	returData := []map[string]interface{}{}
+	dataArr := []TimeConnectionsEntity{}
+	if t.CooperateType == "supplier" {
+		//供应商
+		supplierSql := fmt.Sprintf(`SELECT DISTINCT  a.zbtime as zbtime  
+	FROM 
+	   (select zbtime,project_id,buyer_id,buyer,agency_id,agency,winner_id as winnerId   from  transaction_info     
+	ARRAY JOIN  winner_id ) a 
+	inner join ent_contact  b   on a.buyer_id = '%s' and a.winnerId='%s' and  a.winnerId=b.id
+	inner join ent_info  c   on a.winnerId=c.id order by a.zbtime,a.winnerId`, t.BuyerId, t.WinnerId)
+		dataArr = TimeFindConnectionsHandle(supplierSql)
+	} else if t.CooperateType == "agent" {
+		//代理机构
+		agentSql := fmt.Sprintf(`select  zbtime  from   transaction_info  where  buyer_id ='%s' and  agency_id ='%s' order by zbtime,winner_id `, t.BuyerId, t.WinnerId)
+		dataArr = TimeFindConnectionsHandle(agentSql)
+	}
+	if dataArr != nil && len(dataArr) > 0 {
+		for _, m := range dataArr {
+			zbtime := m.Zbtime
+			returData = append(returData, map[string]interface{}{
+				"zbtime":  zbtime,
+				"entName": t.WinnerName,
+			})
+		}
+	}
+	return returData
+}
+func (t *OwnerService) CandidateChannel() []*ResultData {
+	returnData := []*ResultData{}
+	dataMap := &map[string]map[string]interface{}{}
+	if t.PartyA != "" || t.Supplier != "" || t.Heterotophy != "" || t.Intermediary != "" || t.Agency != "" {
+		dataMap = BuyerList(t.PartyA, t.Supplier, t.Heterotophy, t.Intermediary, t.Agency)
+	}
+	if len(*dataMap) > 0 && dataMap != nil {
+		propertyForm := ""
+		m1 := CrmMysql.FindOne("config_tenant", map[string]interface{}{"account_id": t.EntAccountId}, "probusfor", "")
+		if m1 != nil && len(*m1) > 0 {
+			propertyForm = common.ObjToString((*m1)["probusfor"])
+		}
+		for buyerId, _ := range *dataMap {
+			logx.Info(buyerId)
+			r1, r2 := GetData(propertyForm, buyerId)
+			if r1 != nil && len(r1) > 0 {
+				tmp := &ResultData{
+					channelType: 1,
+					channel:     "同甲异业渠道",
+					size:        len(r1),
+					data:        r1,
+				}
+				returnData = append(returnData, tmp)
+			}
+			if r2 != nil && len(r2) > 0 {
+				tmp := &ResultData{
+					channelType: 1,
+					channel:     "招标代理机构",
+					size:        len(r2),
+					data:        r2,
+				}
+				returnData = append(returnData, tmp)
+			}
+			r3 := GetData1(t.PositionId, buyerId)
+			if r3 != nil && len(r3) > 0 {
+				tmp := &ResultData{
+					channelType: 1,
+					channel:     "中间人",
+					size:        len(r3),
+					data:        r3,
+				}
+				returnData = append(returnData, tmp)
+			}
+			GetData2(buyerId)
+		}
+	}
+	return returnData
+}

+ 3 - 5
api/internal/service/plistService.go

@@ -5,8 +5,6 @@ import (
 	"fmt"
 	"strings"
 
-	"bp.jydev.jianyu360.cn/CRM/application/service"
-
 	"app.yhyue.com/moapp/jybase/common"
 	P "app.yhyue.com/moapp/jybase/mapping"
 	T "bp.jydev.jianyu360.cn/CRM/application/api/common"
@@ -44,8 +42,8 @@ type ProjectEntry struct {
 
 func GetProjectList(req *types.ProjectListReq) (resultList []map[string]interface{}, hasNextPage bool, total int) {
 
-	buyerM := service.BuyerList(req.PartyA, req.Supplier, req.Heterotophy, req.Intermediary, req.Agency)
-	service.MonitorStatusInit(req.PositionId, buyerM, "0")
+	buyerM := BuyerList(req.PartyA, req.Supplier, req.Heterotophy, req.Intermediary, req.Agency)
+	MonitorStatusInit(req.PositionId, buyerM, "0")
 
 	preSales := preSalesStatus(req.PositionId)
 	isSqlPage := false
@@ -274,7 +272,7 @@ func moreInfo(req *types.ProjectListReq, list []map[string]interface{}) (result
 		// 人脉路径
 		// 有我的人脉标签时不需要查询人脉路径信息
 		if m["my_conn"] == false {
-			service.ConnectionsHandle([]string{common.ObjToString(m["buyer_id"])}, req.PositionId, false)
+			ConnectionsHandle([]string{common.ObjToString(m["buyer_id"])}, req.PositionId, false)
 		}
 	}
 

+ 219 - 197
api/internal/types/types.go

@@ -1,49 +1,17 @@
 // Code generated by goctl. DO NOT EDIT.
 package types
 
-type AddOrUpdateReq struct {
-	PositionId             int64  `header:"positionId"`
-	EntUserId              int64  `header:"entUserId,optional"`
-	EntId                  int64  `header:"entId,optional"`
-	EntDeptId              int64  `header:"entDeptId,optional"`
-	Company_id             string `json:"company_id,optional"`
-	Company_name           string `json:"company_name,optional"`
-	Contact_person         string `json:"contact_person,optional"`
-	Contact_phone          string `json:"contact_phone,optional"`
-	Introduce_owner_id     string `json:"introduce_owner_id,optional"`
-	Introduce_owner_name   string `json:"introduce_owner_name,optional"`
-	Introduce_project_id   string `json:"introduce_project_id,optional"`
-	Introduce_project_name string `json:"introduce_project_name,optional"`
-	Id                     int64  `json:"id,optional"`
-	Type                   string `json:"type,optional"`
-}
-
-type AllprojectReq struct {
-	EntAccountId int64  `header:"entAccountId"`
-	PositionId   int64  `header:"positionId"`
-	Name         string `json:"name,optional"`
-	Type         int64  `json:"type,optional"`
-	Id           string `json:"id,optional"`
-}
-
-type AssociateReq struct {
-	EntAccountId int64  `header:"entAccountId"`
-	EntName      string `header:"entName"`
-	Name         string `json:"name"`
-	Type         string `json:"type"`
+type Reply struct {
+	Error_code int64       `json:"error_code"`
+	Error_msg  string      `json:"error_msg"`
+	Data       interface{} `json:"data"`
 }
 
-type CanAddReq struct {
-	AppId          string `header:"appId,default=10000"`
-	BaseUserId     int64  `header:"newUserId"`
-	PositionId     int64  `header:"positionId,optional"`
-	EntUserId      int64  `header:"entUserId,optional"`
-	EntId          int64  `header:"entId,optional"`
-	AccountId      int64  `header:"accountId,optional"`
-	EntDeptId      int64  `header:"entDeptId,optional"`
-	EmployInfoId   int64  `json:"employInfoId"`            //资讯收录id
-	EmployCustomId int64  `json:"employCustomId,optional"` //客户收录id
-	Key            string `json:"key"`                     //创建线索:more_create_clue 创建机会:more_create_chance 创建客户:more_create_custom
+type InfoReply struct {
+	Error_code  int64       `json:"error_code"`
+	Error_msg   string      `json:"error_msg"`
+	Data        interface{} `json:"data"`
+	BatchEmploy int64       `json:"batchEmploy"`
 }
 
 type ClueAddReq struct {
@@ -65,14 +33,81 @@ type ClueAddReq struct {
 	Channel      string  `json:"channel"`               //渠道来源:网页、手动创建
 }
 
-type CoopHistoryReq struct {
-	EntAccountId int64  `header:"entAccountId,optional"` //企业账户id
+type SaleChanceReq struct {
+	AppId             string  `header:"appId,default=10000"`
+	BaseUserId        int64   `header:"newUserId"`
+	PositionId        int64   `header:"positionId,optional"`
+	EntUserId         int64   `header:"entUserId,optional"`
+	EntId             int64   `header:"entId,optional"`
+	AccountId         int64   `header:"accountId,optional"`
+	EntDeptId         int64   `header:"entDeptId,optional"`
+	ChanceName        string  `json:"chanceName"`                 //机会名称
+	Summary           string  `json:"summary"`                    //概要信息
+	ChanceClassify    int64   `json:"chanceClassify"`             //机会分类
+	ExpectedOrderTime int64   `json:"expectedOrderTime,optional"` //最初预计落单段时间 时间戳
+	ExpectedMoney     float64 `json:"expectedMoney,optional"`     //最初预计落单金额
+	CustomName        string  `json:"customName"`                 //客户全称
+	BusinessType      int64   `json:"businessType"`               //业务类型  1新客户需求 2老客户需求 3简易项目流程
+	Remarks           string  `json:"remarks,optional"`           //备注
+	NextfollowUpTime  int64   `json:"nextfollowUpTime,optional"`  //下次跟进时间戳
+	Types             int64   `json:"types"`                      //处理方式 1自办;2转办;3待处理
+	User              []int64 `json:"user,optional"`              //企业用户id
+	EmployInfoId      int64   `json:"employInfoId,optional"`      //资讯收录id
+	CustomId          int64   `json:"customId,optional"`          //客户id
+	CreateName        string  `json:"createName"`                 //创建人
+	ChanceSource      int64   `json:"chanceSource"`               //机会来源
+	OwnerId           int64   `json:"ownerId,optional"`           //潜客收录id(人脉)
+	BusinessId        int64   `json:"businessId,optional"`        //商机收录id(人脉)
+}
+
+type EmployOperateReq struct {
+	AppId      string `header:"appId,default=10000"`
+	BaseUserId int64  `header:"newUserId"`
+	PositionId int64  `header:"positionId,optional"`
+	EntUserId  int64  `header:"entUserId,optional"`
+	EntId      int64  `header:"entId,optional"`
+	IdArr      string `json:"idArr"`      //信息id多条信息
+	IsEmploy   bool   `json:"isEmploy"`   //是否收录true收录 false取消收录
+	EmployType int64  `json:"employType"` //来源方式来源;1招标采购、2企业、3采购单位、4拟在建项目
+	EntDeptId  int64  `header:"entDeptId,optional"`
+	From       string `json:"from,optional"` //来源
+}
+
+type TransferReq struct {
+	AppId         string   `header:"appId,default=10000"`
+	BaseUserId    int64    `header:"newUserId"`
+	PositionId    int64    `header:"positionId,optional"`
+	EntUserId     int64    `header:"entUserId,optional"`
+	EntId         int64    `header:"entId,optional"`
+	EmplouIdArr   []string `json:"emplouIdArr"`
+	PositionIdArr []string `json:"positionIdArr"`
+}
+
+type IgnoreOperateReq struct {
+	AppId      string `header:"appId,default=10000"`
+	BaseUserId int64  `header:"newUserId"`
+	PositionId int64  `header:"positionId,optional"`
+	EntUserId  int64  `header:"entUserId,optional"`
+	EntId      int64  `header:"entId,optional"`
+	IdArr      string `json:"idArr"`      //id集合
+	IsIgnore   bool   `json:"isIgnore"`   //是否忽略 true 忽略 false取消忽略
+	EmployType int64  `json:"employType"` //来源方式来源;1招标采购、2企业、3采购单位、4拟在建项目
+}
+
+type InfoEmployinfoReq struct {
+	AppId        string `header:"appId,default=10000"`
+	BaseUserId   int64  `header:"newUserId"`
 	PositionId   int64  `header:"positionId,optional"`
-	EntId        string `header:"entId,optional"`
-	EntUserId    string `header:"entUserId,optional"`
-	DeptId       string `header:"deptId,optional"` //部门id
-	Pid          string `json:"porjectId"`
-	ChannelType  int    `json:"channelType"`
+	EntUserId    int64  `header:"entUserId,optional"`
+	EntId        int64  `header:"entId,optional"`
+	EmployType   int64  `json:"employType"` //1标采购、2企业、3采购单位、4拟在建项目
+	IdArr        string `json:"idArr"`      //id
+	EntNicheDis  int64  `header:"entNicheDis,optional"`
+	EntDeptId    int64  `header:"entDeptId,optional"`
+	PositionType int64  `header:"positionType,optional"` //职位类型 0个人 1企业
+	AccountId    int64  `header:"accountId,optional"`    //账户id
+	EntAccountId int64  `header:"entAccountId,optional"` //企业账户id
+	From         string `json:"from,optional"`           //来源
 }
 
 type CustomAddReq struct {
@@ -107,10 +142,15 @@ type CustomAddReq struct {
 	BusinessId           int64   `json:"businessId,optional"`              //商机收录id(人脉)
 }
 
-type DistributePerson struct {
-	PositionId int64 `json:"positionId"`
-	EntUserId  int64 `json:"entUserId"`
-	EntDeptId  int64 `json:"entDeptId"`
+type FileUploadReq struct {
+	AppId      string `header:"appId,default=10000"`
+	BaseUserId int64  `header:"newUserId"`
+	PositionId int64  `header:"positionId,optional"`
+	EntUserId  int64  `header:"entUserId,optional"`
+	EntId      int64  `header:"entId,optional"`
+	BusinessId int64  `form:"businessId"` //业务id
+	Types      int64  `form:"type"`       //类型;1:跟进记录-线下 2:跟进记录-线上 3:跟进记录-备忘 4:销售机会-项目文档 5:客户-客户档案
+	FileType   int64  `form:"fileType"`   //文件类型,产品介绍、项目方案、立项报告、报价文件、招标文件、投标文件、中标通知书、合同、发票、其他文件
 }
 
 type EmployDistributeReq struct {
@@ -125,80 +165,127 @@ type EmployDistributeReq struct {
 	EntDeptId   int64              `header:"entDeptId,optional"`
 }
 
-type EmployOperateReq struct {
-	AppId      string `header:"appId,default=10000"`
-	BaseUserId int64  `header:"newUserId"`
-	PositionId int64  `header:"positionId,optional"`
-	EntUserId  int64  `header:"entUserId,optional"`
-	EntId      int64  `header:"entId,optional"`
-	IdArr      string `json:"idArr"`      //信息id多条信息
-	IsEmploy   bool   `json:"isEmploy"`   //是否收录true收录 false取消收录
-	EmployType int64  `json:"employType"` //来源方式来源;1招标采购、2企业、3采购单位、4拟在建项目
-	EntDeptId  int64  `header:"entDeptId,optional"`
-	From       string `json:"from,optional"` //来源
+type DistributePerson struct {
+	PositionId int64 `json:"positionId"`
+	EntUserId  int64 `json:"entUserId"`
+	EntDeptId  int64 `json:"entDeptId"`
 }
 
 type EntInfoReq struct {
 	EntName string `json:"entName"`
 }
 
-type FileUploadReq struct {
-	AppId      string `header:"appId,default=10000"`
-	BaseUserId int64  `header:"newUserId"`
-	PositionId int64  `header:"positionId,optional"`
-	EntUserId  int64  `header:"entUserId,optional"`
-	EntId      int64  `header:"entId,optional"`
-	BusinessId int64  `form:"businessId"` //业务id
-	Types      int64  `form:"type"`       //类型;1:跟进记录-线下 2:跟进记录-线上 3:跟进记录-备忘 4:销售机会-项目文档 5:客户-客户档案
-	FileType   int64  `form:"fileType"`   //文件类型,产品介绍、项目方案、立项报告、报价文件、招标文件、投标文件、中标通知书、合同、发票、其他文件
+type PushMsgReq struct {
+	AppId      string  `header:"appId,default=10000"`
+	BaseUserId int64   `header:"newUserId"`
+	PositionId int64   `header:"positionId,optional"`
+	EntUserId  int64   `header:"entUserId,optional"`
+	EntId      int64   `header:"entId,optional"`
+	Title      string  `json:"title"`         //标题
+	Content    string  `json:"content"`       //内容
+	PcHref     string  `json:"pcHref"`        //pc跳转地址
+	MobileHref string  `json:"mobileHref"`    //移动端跳转地址
+	User       []int64 `json:"user,optional"` //企业用户id
+	MsgType    string  `json:"msgType"`       //消息类型 1-活动优惠 2-服务通知 3-订阅消息 4-项目动态 5-企业动态 6-分析报告 7-系统通知 11-待办
 }
 
-type IgnoreOperateReq struct {
-	AppId      string `header:"appId,default=10000"`
-	BaseUserId int64  `header:"newUserId"`
-	PositionId int64  `header:"positionId,optional"`
-	EntUserId  int64  `header:"entUserId,optional"`
-	EntId      int64  `header:"entId,optional"`
-	IdArr      string `json:"idArr"`      //id集合
-	IsIgnore   bool   `json:"isIgnore"`   //是否忽略 true 忽略 false取消忽略
-	EmployType int64  `json:"employType"` //来源方式来源;1招标采购、2企业、3采购单位、4拟在建项目
+type CanAddReq struct {
+	AppId          string `header:"appId,default=10000"`
+	BaseUserId     int64  `header:"newUserId"`
+	PositionId     int64  `header:"positionId,optional"`
+	EntUserId      int64  `header:"entUserId,optional"`
+	EntId          int64  `header:"entId,optional"`
+	AccountId      int64  `header:"accountId,optional"`
+	EntDeptId      int64  `header:"entDeptId,optional"`
+	EmployInfoId   int64  `json:"employInfoId"`            //资讯收录id
+	EmployCustomId int64  `json:"employCustomId,optional"` //客户收录id
+	Key            string `json:"key"`                     //创建线索:more_create_clue 创建机会:more_create_chance 创建客户:more_create_custom
 }
 
-type IgnoreReq struct {
-	PositionId int64  `header:"positionId"`
-	EntUserId  int64  `header:"entUserId,optional"`
-	EntId      int64  `header:"entId,optional"`
-	EntDeptId  int64  `header:"entDeptId,optional"`
-	RelateId   string `json:"relateId,optional"`
-	Source     int    `json:"source,optional"`
-	Action     int    `json:"action,optional"`
+type OwnerListReq struct {
+	PartyA           string `json:"partyA,optional"`           //甲方
+	Supplier         string `json:"supplier,optional"`         //供应商
+	Heterotophy      string `json:"heterotophy,optional"`      //同甲异业
+	Intermediary     string `json:"intermediary,optional"`     //中间人
+	Agency           string `json:"agency,optional"`           //代理机构
+	SearchEntName    string `json:"searchEntName,optional"`    //搜索企业名称
+	SourceType       string `json:"sourceType,optional"`       //搜索类型 1 只看转介绍成功率高2只看已监控的
+	ProcessingStatus string `json:"processingStatus,optional"` //处理状态1未处理2已忽略3已建客户
+	Area             string `json:"area,optional"`             //项目地区
+	PositionId       int64  `header:"positionId,optional"`
+	PageSize         int64  `json:"pageSize,optional"`
+	PageIndex        int64  `json:"pageIndex,optional"`
 }
 
-type InfoDetailReq struct {
-	InfoId string `json:"infoId"`
+type ProjectListReq struct {
+	PositionId   int64  `header:"positionId,optional"`
+	EntId        string `header:"entId,optional"`
+	EntUserId    string `header:"entUserId,optional"`
+	DeptId       string `header:"deptId,optional"`     //部门id
+	PartyA       string `json:"partyA,optional"`       //甲方
+	Supplier     string `json:"supplier,optional"`     //供应商
+	Heterotophy  string `json:"heterotophy,optional"`  //同甲异业
+	Intermediary string `json:"intermediary,optional"` //中间人
+	Agency       string `json:"agency,optional"`       //代理机构
+	PageNum      int64  `json:"pageNum"`
+	PageSize     int64  `json:"pageSize"`
+	BusinessType string `json:"businessType"`
+	SaleStatus   int    `json:"saleStatus"`
+	ProjectName  string `json:"projectName"`
+	StartTime    int64  `json:"startTime"`
+	EntTime      int64  `json:"entTime"`
+	Area         string `json:"area"`
+	City         string `json:"city"`
+	District     string `json:"district"`
+	PropertyForm string `json:"propertyForm"`
+	SubClass     string `json:"subClass"`
+	Amount       string `json:"amount"`
 }
 
-type InfoEmployinfoReq struct {
-	AppId        string `header:"appId,default=10000"`
-	BaseUserId   int64  `header:"newUserId"`
-	PositionId   int64  `header:"positionId,optional"`
-	EntUserId    int64  `header:"entUserId,optional"`
-	EntId        int64  `header:"entId,optional"`
-	EmployType   int64  `json:"employType"` //1标采购、2企业、3采购单位、4拟在建项目
-	IdArr        string `json:"idArr"`      //id
-	EntNicheDis  int64  `header:"entNicheDis,optional"`
-	EntDeptId    int64  `header:"entDeptId,optional"`
-	PositionType int64  `header:"positionType,optional"` //职位类型 0个人 1企业
-	AccountId    int64  `header:"accountId,optional"`    //账户id
+type PnameAssReq struct {
+	ProjectName string `json:"projectName"`
+}
+
+type CoopHistoryReq struct {
 	EntAccountId int64  `header:"entAccountId,optional"` //企业账户id
-	From         string `json:"from,optional"`           //来源
+	PositionId   int64  `header:"positionId,optional"`
+	EntId        string `header:"entId,optional"`
+	EntUserId    string `header:"entUserId,optional"`
+	DeptId       string `header:"deptId,optional"` //部门id
+	Pid          string `json:"porjectId"`
+	ChannelType  int    `json:"channelType"`
 }
 
-type InfoReply struct {
-	Error_code  int64       `json:"error_code"`
-	Error_msg   string      `json:"error_msg"`
-	Data        interface{} `json:"data"`
-	BatchEmploy int64       `json:"batchEmploy"`
+type AddOrUpdateReq struct {
+	PositionId             int64  `header:"positionId"`
+	EntUserId              int64  `header:"entUserId,optional"`
+	EntId                  int64  `header:"entId,optional"`
+	EntDeptId              int64  `header:"entDeptId,optional"`
+	Company_id             string `json:"company_id,optional"`
+	Company_name           string `json:"company_name,optional"`
+	Contact_person         string `json:"contact_person,optional"`
+	Contact_phone          string `json:"contact_phone,optional"`
+	Introduce_owner_id     string `json:"introduce_owner_id,optional"`
+	Introduce_owner_name   string `json:"introduce_owner_name,optional"`
+	Introduce_project_id   string `json:"introduce_project_id,optional"`
+	Introduce_project_name string `json:"introduce_project_name,optional"`
+	Id                     int64  `json:"id,optional"`
+	Type                   string `json:"type,optional"`
+}
+
+type AssociateReq struct {
+	EntAccountId int64  `header:"entAccountId"`
+	EntName      string `header:"entName"`
+	Name         string `json:"name"`
+	Type         string `json:"type"`
+}
+
+type AllprojectReq struct {
+	EntAccountId int64  `header:"entAccountId"`
+	PositionId   int64  `header:"positionId"`
+	Name         string `json:"name,optional"`
+	Type         int64  `json:"type,optional"`
+	Id           string `json:"id,optional"`
 }
 
 type NetWorkListReq struct {
@@ -217,19 +304,18 @@ type NetWorkListReq struct {
 	Monitorcount_end   int64  `json:"monitorcount_end,optional"`
 }
 
-type OwnerListReq struct {
-	PartyA           string `json:"partyA,optional"`           //甲方
-	Supplier         string `json:"supplier,optional"`         //供应商
-	Heterotophy      string `json:"heterotophy,optional"`      //同甲异业
-	Intermediary     string `json:"intermediary,optional"`     //中间人
-	Agency           string `json:"agency,optional"`           //代理机构
-	SearchEntName    string `json:"searchEntName,optional"`    //搜索企业名称
-	SourceType       string `json:"sourceType,optional"`       //搜索类型 1 只看转介绍成功率高2只看已监控的
-	ProcessingStatus string `json:"processingStatus,optional"` //处理状态1未处理2已忽略3已建客户
-	Area             string `json:"area,optional"`             //项目地区
-	PositionId       int64  `header:"positionId,optional"`
-	PageSize         int64  `json:"pageSize,optional"`
-	PageIndex        int64  `json:"pageIndex,optional"`
+type IgnoreReq struct {
+	PositionId int64  `header:"positionId"`
+	EntUserId  int64  `header:"entUserId,optional"`
+	EntId      int64  `header:"entId,optional"`
+	EntDeptId  int64  `header:"entDeptId,optional"`
+	RelateId   string `json:"relateId,optional"`
+	Source     int    `json:"source,optional"`
+	Action     int    `json:"action,optional"`
+}
+
+type InfoDetailReq struct {
+	InfoId string `json:"infoId"`
 }
 
 type PListPathReq struct {
@@ -240,93 +326,29 @@ type PListPathReq struct {
 	BuyerId    string `json:"buyerId"`
 }
 
-type PnameAssReq struct {
-	ProjectName string `json:"projectName"`
-}
-
 type PrjectHistoryReq struct {
 	BuyerId  string `json:"buyerId"`
 	WinnerId string `json:"winnerId"`
 }
 
-type ProjectListReq struct {
-	PositionId   int64  `header:"positionId,optional"`
-	EntId        string `header:"entId,optional"`
-	EntUserId    string `header:"entUserId,optional"`
-	DeptId       string `header:"deptId,optional"`     //部门id
+type ChannelListReq struct {
 	PartyA       string `json:"partyA,optional"`       //甲方
 	Supplier     string `json:"supplier,optional"`     //供应商
 	Heterotophy  string `json:"heterotophy,optional"`  //同甲异业
 	Intermediary string `json:"intermediary,optional"` //中间人
 	Agency       string `json:"agency,optional"`       //代理机构
-	PageNum      int64  `json:"pageNum"`
-	PageSize     int64  `json:"pageSize"`
-	BusinessType string `json:"businessType"`
-	SaleStatus   int    `json:"saleStatus"`
-	ProjectName  string `json:"projectName"`
-	StartTime    int64  `json:"startTime"`
-	EntTime      int64  `json:"entTime"`
-	Area         string `json:"area"`
-	City         string `json:"city"`
-	District     string `json:"district"`
-	PropertyForm string `json:"propertyForm"`
-	SubClass     string `json:"subClass"`
-	Amount       string `json:"amount"`
-}
-
-type PushMsgReq struct {
-	AppId      string  `header:"appId,default=10000"`
-	BaseUserId int64   `header:"newUserId"`
-	PositionId int64   `header:"positionId,optional"`
-	EntUserId  int64   `header:"entUserId,optional"`
-	EntId      int64   `header:"entId,optional"`
-	Title      string  `json:"title"`         //标题
-	Content    string  `json:"content"`       //内容
-	PcHref     string  `json:"pcHref"`        //pc跳转地址
-	MobileHref string  `json:"mobileHref"`    //移动端跳转地址
-	User       []int64 `json:"user,optional"` //企业用户id
-	MsgType    string  `json:"msgType"`       //消息类型 1-活动优惠 2-服务通知 3-订阅消息 4-项目动态 5-企业动态 6-分析报告 7-系统通知 11-待办
-}
-
-type Reply struct {
-	Error_code int64       `json:"error_code"`
-	Error_msg  string      `json:"error_msg"`
-	Data       interface{} `json:"data"`
+	PositionId   int64  `header:"positionId,optional"`
 }
 
-type SaleChanceReq struct {
-	AppId             string  `header:"appId,default=10000"`
-	BaseUserId        int64   `header:"newUserId"`
-	PositionId        int64   `header:"positionId,optional"`
-	EntUserId         int64   `header:"entUserId,optional"`
-	EntId             int64   `header:"entId,optional"`
-	AccountId         int64   `header:"accountId,optional"`
-	EntDeptId         int64   `header:"entDeptId,optional"`
-	ChanceName        string  `json:"chanceName"`                 //机会名称
-	Summary           string  `json:"summary"`                    //概要信息
-	ChanceClassify    int64   `json:"chanceClassify"`             //机会分类
-	ExpectedOrderTime int64   `json:"expectedOrderTime,optional"` //最初预计落单段时间 时间戳
-	ExpectedMoney     float64 `json:"expectedMoney,optional"`     //最初预计落单金额
-	CustomName        string  `json:"customName"`                 //客户全称
-	BusinessType      int64   `json:"businessType"`               //业务类型  1新客户需求 2老客户需求 3简易项目流程
-	Remarks           string  `json:"remarks,optional"`           //备注
-	NextfollowUpTime  int64   `json:"nextfollowUpTime,optional"`  //下次跟进时间戳
-	Types             int64   `json:"types"`                      //处理方式 1自办;2转办;3待处理
-	User              []int64 `json:"user,optional"`              //企业用户id
-	EmployInfoId      int64   `json:"employInfoId,optional"`      //资讯收录id
-	CustomId          int64   `json:"customId,optional"`          //客户id
-	CreateName        string  `json:"createName"`                 //创建人
-	ChanceSource      int64   `json:"chanceSource"`               //机会来源
-	OwnerId           int64   `json:"ownerId,optional"`           //潜客收录id(人脉)
-	BusinessId        int64   `json:"businessId,optional"`        //商机收录id(人脉)
+type RouteOwnerListReq struct {
+	BuyerId   string `json:"buyerId,optional"`
+	BuyerName string `json:"buyerName,optional"`
 }
 
-type TransferReq struct {
-	AppId         string   `header:"appId,default=10000"`
-	BaseUserId    int64    `header:"newUserId"`
-	PositionId    int64    `header:"positionId,optional"`
-	EntUserId     int64    `header:"entUserId,optional"`
-	EntId         int64    `header:"entId,optional"`
-	EmplouIdArr   []string `json:"emplouIdArr"`
-	PositionIdArr []string `json:"positionIdArr"`
+type CooperateOwnerListReq struct {
+	BuyerId       string `json:"buyerId,optional"`
+	BuyerName     string `json:"buyerName,optional"`
+	WinnerId      string `json:"winnerId,optional"`
+	WinnerName    string `json:"winnerName,optional"`
+	CooperateType string `json:"cooperateType,optional"`
 }

+ 0 - 574
service/owner.go

@@ -1,574 +0,0 @@
-package service
-
-import (
-	. "bp.jydev.jianyu360.cn/CRM/application/api/common"
-	"bp.jydev.jianyu360.cn/CRM/application/entity"
-	"context"
-	"fmt"
-	"github.com/gogf/gf/v2/util/gconv"
-	"github.com/zeromicro/go-zero/core/logx"
-	"strings"
-)
-
-type OwnerService struct {
-	PartyA           string
-	Supplier         string
-	Heterotophy      string
-	Intermediary     string
-	Agency           string
-	SearchEntName    string
-	SourceType       string
-	ProcessingStatus string
-	Area             string
-	PositionId       int64
-	PageIndex        int64
-	PageSize         int64
-}
-
-type BuyerProject struct {
-	BuyerId          string
-	BuyerName        string
-	Project          ProjectEntity
-	IsMonitor        bool
-	IsCreateCustomer bool
-	IsIgnore         bool
-	Area             string
-	Zbtime           int64
-}
-type ProjectEntity struct {
-	Number          int64
-	zbtime          int64
-	EstimatedAmount int64
-	Connections     []map[string]interface{}
-}
-type Recommend struct {
-	buyerId string `ch:"buyer_id"`
-	buyer   string `ch:"buyer"`
-}
-type Project struct {
-	BuyerId    string `ch:"buyer_id"`
-	Area       string `ch:"area"`
-	GroupCount int64  `ch:"group_count"`
-	Money      int64  `ch:"money"`
-	Zbtime     int64  `ch:"zbtime"`
-}
-
-func (t *OwnerService) OwnerlList() map[string]interface{} {
-	//先查询采购单位列表
-	dataMap := &map[string]map[string]interface{}{}
-	if t.PartyA != "" || t.Supplier != "" || t.Heterotophy != "" || t.Intermediary != "" || t.Agency != "" {
-		dataMap = BuyerList(t.PartyA, t.Supplier, t.Heterotophy, t.Intermediary, t.Agency)
-	}
-	if len(*dataMap) == 0 {
-		return map[string]interface{}{}
-	}
-	if t.SearchEntName != "" {
-		//es查询
-	}
-	//处理状态初始化
-	if t.ProcessingStatus != "" {
-		ProcessingStatusInit(t.PositionId, dataMap, t.ProcessingStatus)
-	}
-	//监控状态处理
-	MonitorStatusInit(t.PositionId, dataMap, t.SourceType)
-	//项目数量查询
-	buyerArr := []string{}
-	for key := range *dataMap {
-		buyerArr = append(buyerArr, fmt.Sprintf(`'%s'`, gconv.String(key)))
-	}
-	//项目数量处理
-	projectMap := ProjectHandle(buyerArr, t.Area)
-	//采购单位和项目合并
-	returnData, monitorNumber, highSuccessNumber, connectionsNumber := BuyerProjectMerge(dataMap, projectMap, t.SourceType)
-	//分页数据处理
-	if t.PageSize == 0 {
-		t.PageSize = 10
-	}
-	if t.PageIndex == 0 {
-		t.PageIndex = 10
-	}
-	startIndex := (t.PageIndex - 1) * t.PageSize
-	endIndex := t.PageIndex * t.PageSize
-	if startIndex < connectionsNumber {
-		if endIndex > connectionsNumber {
-			endIndex = connectionsNumber
-		}
-		returnData = returnData[startIndex:endIndex]
-	} else {
-		return map[string]interface{}{}
-	}
-	buyerIdArr := []string{}
-	for _, value := range returnData {
-		buyerIdArr = append(buyerIdArr, fmt.Sprintf("'%s'", value.BuyerId))
-	}
-	//业主人脉处理
-	projectList := ConnectionsHandle(buyerIdArr, t.PositionId, false)
-	for _, v := range projectList {
-		buyerId := gconv.String(v["a_id"])
-		for i, v1 := range returnData {
-			aBuyerId := v1.BuyerId
-			if buyerId == aBuyerId {
-				//组装数据
-				returnData[i].Project.Connections = append(returnData[i].Project.Connections, v)
-			}
-		}
-	}
-	//返回数据组装
-	return map[string]interface{}{
-		"connectionsNumber": connectionsNumber,
-		"highSuccessNumber": highSuccessNumber,
-		"monitorNumber":     monitorNumber,
-		"list":              returnData,
-	}
-}
-func ConnectionsHandle(buyerArr []string, positionId int64, isAll bool) []map[string]interface{} {
-	returnData := []map[string]interface{}{}
-	//中间人  作为可介绍业主    企业名称
-	companyArr := CrmMysql.SelectBySql(
-		fmt.Sprintf("select  b.company_id,b.company_name,b.contact_name,a.relate_id,a.relate_name   from  connection_introduce a  INNER JOIN  connection   b  on  a.position_id=%d  and a.connection_id=b.id  and   a.relate_Id in (%s) and  a.type =1  and  b.type=4 and  b.state=1 ", positionId, strings.Join(buyerArr, ",")))
-	for _, v := range *companyArr {
-		companyId := gconv.String(v["company_id"])
-		companyName := gconv.String(v["company_name"])
-		relateName := gconv.String(v["relate_name"])
-		relateId := gconv.String(v["relate_id"])
-		//key := fmt.Sprintf("%s_%s", relateId, companyId)
-		returnData = append(returnData, map[string]interface{}{
-			"b_id":         companyId,
-			"b_name":       companyName,
-			"a_name":       relateName,
-			"a_id":         relateId,
-			"sourceType":   "中间人",
-			"relationship": "业主的关系人",
-		})
-	}
-	if isAll && len(returnData) > 0 {
-		return returnData
-	}
-	//采购单位 投资关系  管辖关系
-	buyerSql := fmt.Sprintf("select  a_id,b_id,a_name,b_name,code  from  ent_map_code  where ( a_name  in  (%s) or b_name  in  (%s)  ) and   code in('0101','0201')", strings.Join(buyerArr, ","), strings.Join(buyerArr, ","))
-	relationshipArr := FindConnectionsHandle(buyerSql)
-	if relationshipArr != nil && len(relationshipArr) > 0 {
-		for _, v := range relationshipArr {
-			a_id := gconv.String(v["a_id"])
-			b_id := gconv.String(v["b_id"])
-			a_name := gconv.String(v["a_name"])
-			b_name := gconv.String(v["b_name"])
-			for _, v1 := range buyerArr {
-				code := gconv.String(v["a_id"])
-				if a_id == v1 {
-					//key := fmt.Sprintf("%s_%s", a_id, b_id)
-					switch code {
-					case "0101": //管辖关系
-						returnData = append(returnData, map[string]interface{}{
-							"b_id":         b_id,
-							"b_name":       b_name,
-							"a_name":       a_name,
-							"a_id":         a_id,
-							"sourceType":   "甲方",
-							"relationship": "业主的上级机构",
-						})
-
-					case "0201": //投资关系
-						returnData = append(returnData, map[string]interface{}{
-							"b_id":       b_id,
-							"b_name":     b_name,
-							"a_name":     a_name,
-							"a_id":       a_id,
-							"sourceType": "业主的股东",
-						})
-					}
-				}
-				if b_id == v1 {
-					//key := fmt.Sprintf("%s_%s", b_id, a_id)
-					if code == "0101" {
-						//"0101":管辖关系
-						returnData = append(returnData, map[string]interface{}{
-							"b_id":         a_id,
-							"b_name":       a_name,
-							"a_name":       b_name,
-							"a_id":         b_id,
-							"sourceType":   "甲方",
-							"relationship": "业主的下级机构",
-						})
-					}
-				}
-			}
-		}
-	}
-	//供应商  采购单位 供应商     招标代理机构  采购单位  招标代理机构  需要计算合作次数
-	winnerSql := fmt.Sprintf("SELECT  zbtime,project_id,buyer_id,buyer,winner,winner_id,agency_id,agency  FROM  transaction_info WHERE  buyer_id in (%s)", strings.Join(buyerArr, ","))
-	winnerArr := FindConnectionsHandle(winnerSql)
-	if winnerArr != nil && len(winnerArr) > 0 {
-		winnerMap := map[string]map[string]interface{}{}
-		agencyMap := map[string]map[string]interface{}{}
-		for _, m := range winnerArr {
-			buyerId := gconv.String(m["buyer_id"])
-			winner := gconv.String(m["winner"])
-			buyer := gconv.String(m["buyer"])
-			winnerId := gconv.String(m["winner_id"])
-			agency := gconv.String(m["agency"])
-			agencyId := gconv.String(m["agency_id"])
-			projectId := gconv.String(m["project_id"])
-			zbtime := gconv.String(m["zbtime"])
-			key := fmt.Sprintf("%s_%s", buyerId, winnerId)
-			returnData = append(returnData, map[string]interface{}{
-				"b_id":       winnerId,
-				"b_name":     winner,
-				"a_name":     buyer,
-				"a_id":       buyerId,
-				"sourceType": "供应商",
-			})
-			if _, ok := winnerMap[key]; ok {
-				data := winnerMap[key]
-				data["count"] = gconv.Int64(data["data"]) + 1
-				dataList := gconv.Maps(data["list"])
-				dataList = append(dataList, map[string]interface{}{
-					"zbtime":  zbtime,
-					"entName": winner,
-				})
-				data["list"] = dataList
-				winnerMap[key] = data
-			} else {
-				winnerMap[key] = map[string]interface{}{
-					"b_id":       winnerId,
-					"b_name":     winner,
-					"a_name":     buyer,
-					"a_id":       buyerId,
-					"sourceType": "供应商",
-					"count":      1,
-					"list": []map[string]interface{}{
-						{
-							"zbtime":  zbtime,
-							"entName": winner,
-						},
-					},
-				}
-			}
-			key = fmt.Sprintf("%s_%s_%s", buyerId, agencyId, projectId)
-			if _, ok := agencyMap[key]; ok {
-				data := agencyMap[key]
-				data["count"] = gconv.Int64(data["data"]) + 1
-				dataList := gconv.Maps(data["list"])
-				dataList = append(dataList, map[string]interface{}{
-					"zbtime":  zbtime,
-					"entName": winner,
-				})
-				data["list"] = dataList
-				agencyMap[key] = data
-			} else {
-				agencyMap[key] = map[string]interface{}{
-					"b_id":       agencyId,
-					"b_name":     agency,
-					"a_name":     buyer,
-					"a_id":       buyerId,
-					"sourceType": "招标代理",
-					"count":      1,
-					"list": []map[string]interface{}{
-						{
-							"zbtime":  zbtime,
-							"entName": agency,
-						},
-					},
-				}
-			}
-		}
-		for _, m := range winnerMap {
-			returnData = append(returnData, map[string]interface{}{
-				"b_id":         gconv.String(m["b_id"]),
-				"b_name":       gconv.String(m["b_name"]),
-				"a_name":       gconv.String(m["a_name"]),
-				"a_id":         gconv.String(m["a_id"]),
-				"sourceType":   gconv.String(m["sourceType"]),
-				"relationship": gconv.String(m["relationship"]),
-				"count":        gconv.Int64(m["count"]),
-			})
-		}
-		for _, m := range agencyMap {
-			returnData = append(returnData, map[string]interface{}{
-				"b_id":         gconv.String(m["b_id"]),
-				"b_name":       gconv.String(m["b_name"]),
-				"a_name":       gconv.String(m["a_name"]),
-				"a_id":         gconv.String(m["a_id"]),
-				"sourceType":   gconv.String(m["sourceType"]),
-				"relationship": gconv.String(m["relationship"]),
-				"count":        gconv.Int64(m["count"]),
-			})
-		}
-	}
-	return returnData
-}
-
-// 采购单位和项目合并
-func BuyerProjectMerge(dataMap, projectMap *map[string]map[string]interface{}, sourceType string) ([]BuyerProject, int64, int64, int64) {
-	returnData := []BuyerProject{}
-	connectionsNumber := int64(0)
-	highSuccessNumber := int64(0)
-	monitorNumber := int64(0)
-	for buyerId, buyerMap := range *dataMap {
-		if _, ok := (*projectMap)[buyerId]; ok {
-			projectMap := (*projectMap)[buyerId]
-			buyerName := gconv.String(buyerMap["buyerName"])
-			if isMonitor := gconv.Bool(buyerMap["isMonitor"]); isMonitor {
-				monitorNumber++
-			}
-			count := gconv.Int64(projectMap["count"])
-			money := gconv.Int64(projectMap["money"])
-			zbtime := gconv.Int64(projectMap["zbtime"])
-			if sourceType == "1" {
-				if count < 2 {
-					continue
-				}
-				highSuccessNumber++
-				returnData = append(returnData, BuyerProject{
-					BuyerId:   buyerId,
-					BuyerName: buyerName,
-					Project: ProjectEntity{
-						Number:          count,
-						EstimatedAmount: money,
-						Connections:     nil,
-					},
-					Area:   gconv.String(projectMap["area"]),
-					Zbtime: zbtime,
-				})
-			} else {
-				if count > 2 {
-					highSuccessNumber++
-				}
-				returnData = append(returnData, BuyerProject{
-					BuyerId:   buyerId,
-					BuyerName: buyerName,
-					Project: ProjectEntity{
-						Number:          count,
-						EstimatedAmount: money,
-						Connections:     nil,
-					},
-					Area:   gconv.String(projectMap["area"]),
-					Zbtime: zbtime,
-				})
-			}
-		}
-		connectionsNumber++
-	}
-	return returnData, connectionsNumber, highSuccessNumber, monitorNumber
-}
-
-// 已监控数据处理
-func MonitorStatusInit(positionId int64, dataMap *map[string]map[string]interface{}, sourceType string) {
-	monitorMap := map[string]bool{}
-	query := map[string]interface{}{
-		"userId": positionId,
-	}
-	clist, ok := Mgo.Find("follow_customer", query, ``, `{"name":1}`, false, -1, -1)
-	if ok && clist != nil && len(*clist) > 0 {
-		for _, v := range *clist {
-			monitorMap[gconv.String(v["name"])] = true
-		}
-
-	}
-	//采购单位和自己监控的对比
-	newMap := &map[string]map[string]interface{}{}
-	for k, v := range *dataMap {
-		buyerName := gconv.String(v["buyerName"])
-		if _, ok1 := monitorMap[gconv.String(buyerName)]; ok1 {
-			v["isMonitor"] = true
-			(*newMap)[k] = v
-		} else {
-			if sourceType != "2" && sourceType != "1" {
-				v["isMonitor"] = false
-				(*newMap)[k] = v
-			}
-		}
-	}
-	if newMap != nil {
-		dataMap = newMap
-	}
-}
-
-// 处理状态初始化
-func ProcessingStatusInit(positionId int64, dataMap *map[string]map[string]interface{}, processingStatus string) {
-	//未处理
-	untreatedMap := &map[string]bool{}
-	//已忽略
-	ignoredMap := &map[string]bool{}
-	//已创建
-	createdMap := &map[string]bool{}
-	processingArr := CrmMysql.Find(entity.CONNECTION_STATUS, map[string]interface{}{
-		"type":        1,
-		"position id": positionId,
-	}, "relate_id,is_handle,is_ignore,is_create", "", -1, -1)
-	if len(*processingArr) > 0 {
-		for _, v := range *processingArr {
-			entId := gconv.String(v["relate_id"])
-			handle := gconv.Int64(v["is_handle"])
-			ignore := gconv.Int64(v["is_ignore"])
-			create := gconv.Int64(v["is_create"])
-			if handle == 1 {
-				(*untreatedMap)[entId] = true
-			}
-			if ignore == 1 {
-				(*ignoredMap)[entId] = true
-			}
-			if create == 1 {
-				(*createdMap)[entId] = true
-			}
-		}
-	}
-	newMap := &map[string]map[string]interface{}{}
-	//所有采购单位和处理状态对比
-	for buyerId, value := range *dataMap {
-		for _, v := range strings.Split(processingStatus, ",") {
-			switch v {
-			case "1":
-				if _, ok := (*untreatedMap)[buyerId]; !ok {
-					(*newMap)[buyerId] = value
-				}
-			case "2":
-				if _, ok := (*ignoredMap)[buyerId]; ok {
-					(*newMap)[buyerId] = value
-				}
-			case "3":
-				if _, ok := (*createdMap)[buyerId]; ok {
-					(*newMap)[buyerId] = value
-				}
-			}
-		}
-	}
-	if newMap != nil {
-		dataMap = newMap
-	}
-}
-
-// 采购单位查询
-func BuyerList(partyA, supplier, heterotophy, intermediary, agency string) *map[string]map[string]interface{} {
-	dataMap := &map[string]map[string]interface{}{}
-	//甲方
-	if partyA != "" {
-		for _, v := range strings.Split(partyA, ",") {
-			intermediaryArr := strings.Split(v, "_")
-			if len(intermediaryArr) == 2 {
-				(*dataMap)[intermediaryArr[1]] = map[string]interface{}{
-					"buyerName": intermediaryArr[0],
-				}
-			}
-		}
-	}
-	//供应商 //同甲异业
-	if supplier != "" || heterotophy != "" {
-		findInSetArr := []string{}
-		for _, v := range strings.Split(supplier, ",") {
-			findInSetArr = append(findInSetArr, fmt.Sprintf(" (%s)  in   winner_id", v))
-		}
-		for _, v := range strings.Split(heterotophy, ",") {
-			findInSetArr = append(findInSetArr, fmt.Sprintf(" (%s)  in   winner_id", v))
-		}
-		sqlStr := fmt.Sprintf(`SELECT buyer, buyer_id FROM transaction_info where  (%s)    `, strings.Join(findInSetArr, " or "))
-		FindHandle(sqlStr, dataMap)
-	}
-	//中间人
-	if intermediary != "" {
-		for _, v := range strings.Split(intermediary, ",") {
-			intermediaryArr := strings.Split(v, "_")
-			if len(intermediaryArr) == 2 {
-				(*dataMap)[intermediaryArr[1]] = map[string]interface{}{
-					"buyerName": intermediaryArr[0],
-				}
-			}
-		}
-	}
-	//招标代理
-	if agency != "" {
-		agencyArr := []string{}
-		for _, s := range strings.Split(agency, ",") {
-			agencyArr = append(agencyArr, fmt.Sprintf("'%s'"), s)
-		}
-		sqlStr := fmt.Sprintf(`SELECT buyer, buyer_id FROM transaction_info  where agency_id in (%s)   order by  userid`, strings.Join(agencyArr, ","))
-		FindHandle(sqlStr, dataMap)
-	}
-	return dataMap
-}
-
-// 项目数量查询
-func ProjectHandle(buyerArr []string, area string) *map[string]map[string]interface{} {
-	sqlStr := ""
-	if area != "" {
-		sqlStr = fmt.Sprintf(`SELECT buyer_id,area, count(1)  AS group_count FROM information.transaction_info WHERE buyer_id IN (%s) and  area ="%s" GROUP BY buyer_id,area `, strings.Join(buyerArr, ","), area)
-	} else {
-		sqlStr = fmt.Sprintf(`SELECT buyer_id,area, count(1)  AS group_count FROM information.transaction_info WHERE buyer_id IN (%s) GROUP BY buyer_id,area `, strings.Join(buyerArr, ","))
-	}
-	logx.Info(sqlStr)
-	rows, err := ClickhouseConn.Query(context.Background(), sqlStr)
-	projectMap := &map[string]map[string]interface{}{}
-	if err != nil {
-		return projectMap
-	}
-	for rows.Next() {
-		data := Project{}
-		rows.ScanStruct(&data)
-		if (*projectMap)[data.BuyerId] != nil {
-			dataMap := (*projectMap)[data.BuyerId]
-			dataMap[data.BuyerId] = map[string]interface{}{
-				"area":   Deduplication(gconv.String(dataMap["area"]), data.Area),
-				"count":  gconv.Int64(dataMap["count"]) + data.GroupCount,
-				"money":  gconv.Int64(dataMap["money"]) + data.Money,
-				"zbtime": gconv.Int64(dataMap["Zbtime"]),
-			}
-		} else {
-			(*projectMap)[data.BuyerId] = map[string]interface{}{
-				"area":   gconv.String(data.Area),
-				"count":  data.GroupCount,
-				"money":  data.Money,
-				"zbtime": data.Zbtime,
-			}
-		}
-	}
-	return projectMap
-}
-
-// 采购单位查询sql
-func FindHandle(sqlStr string, dataMap *map[string]map[string]interface{}) {
-	rows, err := ClickhouseConn.Query(context.Background(), sqlStr)
-	if err != nil {
-		logx.Error("查询失败", sqlStr, err)
-	}
-	for rows.Next() {
-		data := Recommend{}
-		rows.ScanStruct(&data)
-		(*dataMap)[data.buyerId] = map[string]interface{}{
-			"buyerName": data.buyer,
-		}
-	}
-	return
-}
-
-// 人脉信息查询sql
-func FindConnectionsHandle(sqlStr string) []map[string]interface{} {
-	returnData := []map[string]interface{}{}
-	rows, err := ClickhouseConn.Query(context.Background(), sqlStr)
-	if err != nil {
-		logx.Error("查询失败", sqlStr, err)
-	}
-	for rows.Next() {
-		data := map[string]interface{}{}
-		rows.ScanStruct(&data)
-		returnData = append(returnData, data)
-	}
-	return returnData
-}
-
-// 去重处理
-func Deduplication(a, b string) string {
-	newArr := []string{}
-	if a != "" || b != "" {
-		foo := false
-		newArr := strings.Split(a, ",")
-		for _, v := range newArr {
-			if v == b {
-				foo = true
-			}
-		}
-		if !foo {
-			newArr = append(newArr, b)
-		}
-	}
-	return strings.Join(newArr, ",")
-}