|
@@ -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
|
|
|
+}
|