Jianghan 1 жил өмнө
parent
commit
b597bf2245

+ 9 - 1
api/application.api

@@ -300,6 +300,10 @@ type (
 		EntDeptId  int64  `header:"entDeptId,optional"`
 		BuyerId    string `json:"buyerId"`
 	}
+	PrjectHistoryReq {
+		BuyerId  string `json:"buyerId"`
+		WinnerId string `json:"winnerId"`
+	}
 )
 
 @server (
@@ -369,7 +373,7 @@ service crmApplication {
 
 	@doc "项目公关渠道分析-与业主合作历史"
 	@handler CoopHistoryList
-	post /crmApplication/pr/coop/history (CoopHistoryReq) returns (Reply)
+	post /crmApplication/pr/project/analyse (CoopHistoryReq) returns (Reply)
 
 	@doc "人脉库-添加/修改人脉"
 	@handler addOrUpdate
@@ -398,5 +402,9 @@ service crmApplication {
 	@doc "人脉可达商机列表-人脉路径"
 	@handler plistPath
 	post /crmApplication/network/plist/pathway (PListPathReq) returns (Reply)
+
+	@doc "人脉项目分析-业主合作历史"
+	@handler projectHistory
+	post /crmApplication/pr/project/history (PrjectHistoryReq) returns (Reply)
 }
 

+ 28 - 0
api/internal/handler/projecthistoryhandler.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 projectHistoryHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.PrjectHistoryReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := logic.NewProjectHistoryLogic(r.Context(), svcCtx)
+		resp, err := l.ProjectHistory(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 8 - 3
api/internal/handler/routes.go

@@ -114,13 +114,18 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 			},
 			{
 				Method:  http.MethodPost,
-				Path:    "/crmApplication/pr/coop/history",
+				Path:    "/crmApplication/pr/pname/ass",
+				Handler: PrPnameAssHandler(serverCtx),
+			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/crmApplication/pr/project/analyse",
 				Handler: CoopHistoryListHandler(serverCtx),
 			},
 			{
 				Method:  http.MethodPost,
-				Path:    "/crmApplication/pr/pname/ass",
-				Handler: PrPnameAssHandler(serverCtx),
+				Path:    "/crmApplication/pr/project/history",
+				Handler: projectHistoryHandler(serverCtx),
 			},
 			{
 				Method:  http.MethodPost,

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

@@ -1,6 +1,7 @@
 package logic
 
 import (
+	"bp.jydev.jianyu360.cn/CRM/application/service"
 	"context"
 
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
@@ -24,7 +25,8 @@ func NewPlistPathLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PlistPa
 }
 
 func (l *PlistPathLogic) PlistPath(req *types.PListPathReq) (resp *types.Reply, err error) {
-	// todo: add your logic here and delete this line
+
+	service.ConnectionsHandle([]string{req.BuyerId}, req.PositionId, true)
 
 	return
 }

+ 36 - 0
api/internal/logic/projecthistorylogic.go

@@ -0,0 +1,36 @@
+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 ProjectHistoryLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewProjectHistoryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ProjectHistoryLogic {
+	return &ProjectHistoryLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *ProjectHistoryLogic) ProjectHistory(req *types.PrjectHistoryReq) (resp *types.Reply, err error) {
+	resp = &types.Reply{}
+	if req.BuyerId != "" && req.WinnerId != "" {
+		resp.Data = service.GetData3(req.BuyerId, req.WinnerId)
+	} else {
+		resp.Error_code = -1
+		resp.Error_msg = "参数有误"
+	}
+	return
+}

+ 14 - 24
api/internal/service/CoopHistoryService.go

@@ -15,7 +15,7 @@ import (
 var (
 	INDEX_1  = "transaction_info"
 	sql_2_0  = `SELECT buyer, buyer_id, agency, agency_id, property_form FROM information.transaction_info WHERE project_id = ?`
-	sql_2_1  = `SELECT project_id, project_name, zbtime FROM information.transaction_info WHERE buyer_id = ? AND winner winner IN ? ORDER BY zbtime DESC`
+	sql_2_1  = `SELECT project_id, project_name, zbtime FROM information.transaction_info WHERE buyer_id = ? AND winner winner_id IN ? ORDER BY zbtime DESC`
 	sql_2_2  = `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 b.position_id =%d AND a.connection_id = b.id AND b.state = 1 AND a.itype = 1 AND b.itype = 4 AND a.relate_Id = %s`
 	sql_2_3  = `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 = ? or a.b_id = ? ) and a.code in('0101', '0201') and a.a_id = c.id left join ent_info d on (a.a_id = ? or a.b_id = ? ) and a.code in('0101', '0201') and a.b_id = d.id where (a.a_id = ? or a.b_id = ? ) and a.code in('0101', '0201')`
 	es_query = `{
@@ -210,29 +210,6 @@ func GetData(propertyForm, bid string) (result1, result2 []map[string]interface{
 			result2 = append(result2, tmp)
 		}
 	}
-
-	// 合作项目, 业主与中标单位
-	for _, v := range result1 {
-		rows, err := T.ClickhouseConn.Query(context.TODO(), sql_2_1, bid, v["name"])
-		var mlist []map[string]interface{}
-		for err != nil && rows.Next() {
-			m := make(map[string]interface{})
-			rows.Scan(&m)
-			mlist = append(mlist, m)
-		}
-		v["data"] = mlist
-	}
-	// 业主与代理机构
-	for _, v := range result2 {
-		rows, err := T.ClickhouseConn.Query(context.TODO(), sql_2_1, bid, v["name"])
-		var mlist []map[string]interface{}
-		for err != nil && rows.Next() {
-			m := make(map[string]interface{})
-			rows.Scan(&m)
-			mlist = append(mlist, m)
-		}
-		v["data"] = mlist
-	}
 	return
 }
 
@@ -261,3 +238,16 @@ func GetData2(buyid string) (result []map[string]interface{}) {
 	}
 	return
 }
+
+// @Author jianghan
+// @Description 合作历史
+// @Date 2024/4/20
+func GetData3(buyerId, winnerId string) (result []map[string]interface{}) {
+	rows, err := T.ClickhouseConn.Query(context.TODO(), sql_2_1, buyerId, winnerId)
+	for err != nil && rows.Next() {
+		m := make(map[string]interface{})
+		rows.Scan(&m)
+		result = append(result, m)
+	}
+	return
+}

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

@@ -244,6 +244,11 @@ 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"`