Jianghan 1 年之前
父節點
當前提交
937fe51810

+ 4 - 0
api/application.api

@@ -188,6 +188,10 @@ type (
 		Key            string `json:"key"` //创建线索:more_create_clue 创建机会:more_create_chance 创建客户:more_create_custom
 	}
 	ProjectListReq {
+		PositionId   int64  `header:"positionId,optional"`
+		EntId        string `header:"entId,optional"`
+		EntUserId    string `header:"entUserId,optional"`
+		DeptId       string `header:"deptId,optional"` //部门id
 		pageNum      int64  `json:"pageNum"`
 		pageSize     int64  `json:"pageSize"`
 		businessType string `json:"businessType"`

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

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

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

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

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

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

+ 70 - 10
api/internal/service/plistService.go

@@ -3,13 +3,17 @@ package service
 import (
 	"app.yhyue.com/moapp/jybase/common"
 	P "app.yhyue.com/moapp/jybase/mapping"
+	T "bp.jydev.jianyu360.cn/CRM/application/api/common"
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
+	"context"
 	"fmt"
 	"strings"
 )
 
 const (
 	pageSize = 100
+
+	sql_1 = `SELECT count(1) FROM information.transaction_info WHERE buyer_id = ?`
 )
 
 type ProjectData struct {
@@ -22,15 +26,17 @@ type ProjectEntry struct {
 	projectName string
 }
 
-func GetProjectList(req *types.ProjectListReq) (resultList []interface{}, hasNextPage bool, total int) {
+func GetProjectList(req *types.ProjectListReq) (resultList *[]map[string]interface{}, hasNextPage bool, total int) {
 
 	getSql(req)
 
-	total = len(resultList)
-	if total > pageSize {
-		resultList = resultList[:pageSize]
-		hasNextPage = true
-	}
+	//get(req, resultList)
+	//
+	//total = len(resultList)
+	//if total > pageSize {
+	//	resultList = resultList[:pageSize]
+	//	hasNextPage = true
+	//}
 	return
 }
 
@@ -125,9 +131,63 @@ func getSql(req *types.ProjectListReq) (countSql, findSql string) {
 		querys = append(querys, fmt.Sprintf(" a.property_form in (%s) ", strings.Join(arr, ",")))
 	}
 
-	//查询数量
-	countSql = fmt.Sprintf("select count(1) as count from %s  a  where  %s   %s", "", userStr, strings.Join(querys, " and "))
-	//列表查询语句
-	findSql = "select a.id,a.date,a.infoid,a.matchways,a.isvisit,REPLACE(a.matchkeys,'+',' ') as matchkeys,a.type,a.attachment_count"
+	findSql = "select a.project_id,a.project_name,a.project_budget,a.project_money,a.business_type,a.buyer"
 	return
 }
+
+// @Author jianghan
+// @Description 处理状态/我的人脉
+// @Date 2024/4/17
+func get(req *types.ProjectListReq, list []map[string]interface{}) (result []map[string]interface{}) {
+	field := "is_handle,is_ignore,is_create"
+	for _, m := range list {
+		query := map[string]interface{}{
+			"position_id": req.PositionId,
+			"relate_id":   common.ObjToString(m["project_id"]),
+			"itype":       2,
+		}
+		info := T.CrmMysql.FindOne("connection_status", query, field, "")
+		if info != nil && len(*info) > 0 {
+			m["is_handle"] = (*info)["is_handle"]
+			m["is_ignore"] = (*info)["is_ignore"]
+			m["is_create"] = (*info)["is_create"]
+		}
+
+		// 人脉、人脉所在单位项目 conn_type: 1/人脉可转介绍项目 conn_type: 2
+		field1 := ""
+		query1 := map[string]interface{}{
+			"position_id": req.PositionId,
+			"company_id":  common.ObjToString(m["buyer_id"]),
+			"status":      1,
+		}
+		info1 := T.CrmMysql.FindOne("connection", query1, field1, "")
+		if info1 != nil && len(*info1) > 0 {
+			m["my_conn"] = true
+			m["conn_type"] = 1
+		} else {
+			m["my_conn"] = false
+		}
+		if m["conn_type"] != nil {
+			query2 := map[string]interface{}{
+				"company_id": common.ObjToString(m["buyer_id"]),
+			}
+			info2 := T.CrmMysql.FindOne("connection", query2, field1, "")
+			if info2 != nil && len(*info2) > 0 {
+				m["conn_type"] = 1
+			} else {
+				m["conn_type"] = 2
+			}
+		}
+		// 转介绍成功率高标签
+		count := 0
+		err := T.ClickhouseConn.QueryRow(context.TODO(), sql_1, common.ObjToString(m["buyer_id"])).Scan(&count)
+		if err != nil && count > 2 {
+			m["high_success"] = true
+		} else {
+			m["high_success"] = false
+		}
+
+	}
+
+	return list
+}

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

@@ -154,6 +154,10 @@ type PnameAssReq struct {
 }
 
 type ProjectListReq struct {
+	PositionId   int64  `header:"positionId,optional"`
+	EntId        string `header:"entId,optional"`
+	EntUserId    string `header:"entUserId,optional"`
+	DeptId       string `header:"deptId,optional"` //部门id
 	PageNum      int64  `json:"pageNum"`
 	PageSize     int64  `json:"pageSize"`
 	BusinessType string `json:"businessType"`

+ 6 - 0
api/logs/access.log

@@ -0,0 +1,6 @@
+{"@timestamp":"2024-04-17T18:01:25.448+08:00","caller":"common/initconfig.go:70","content":"info--日志记录","level":"info"}
+{"@timestamp":"2024-04-17T18:01:25.448+08:00","caller":"common/initconfig.go:70","content":"error--日志记录","level":"info"}
+{"@timestamp":"2024-04-17T18:01:25.624+08:00","caller":"common/initconfig.go:125","content":"--初始化 mongodb--","level":"info"}
+{"@timestamp":"2024-04-17T18:01:25.625+08:00","caller":"common/initconfig.go:134","content":"--初始化 mongodb Bidding --","level":"info"}
+{"@timestamp":"2024-04-17T18:01:25.625+08:00","caller":"common/initconfig.go:145","content":"--初始化 mongodb ent --","level":"info"}
+{"@timestamp":"2024-04-17T18:01:25.626+08:00","caller":"common/initconfig.go:156","content":"--初始化 mongodb ent --","level":"info"}

+ 0 - 0
api/logs/error.log


+ 0 - 0
api/logs/severe.log


+ 0 - 0
api/logs/slow.log


+ 0 - 0
api/logs/stat.log