|
@@ -18,7 +18,6 @@ const (
|
|
|
|
|
|
sql_1 = `SELECT count(1) FROM information.transaction_info WHERE buyer_id = ?`
|
|
sql_1 = `SELECT count(1) FROM information.transaction_info WHERE buyer_id = ?`
|
|
sql_2 = `SELECT relate_id, is_handle, is_ignore, is_create FROM crm.connection_status WHERE position_id = ? AND itype = 2`
|
|
sql_2 = `SELECT relate_id, is_handle, is_ignore, is_create FROM crm.connection_status WHERE position_id = ? AND itype = 2`
|
|
- sql_3 = `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 ND a.connection_id = b.idAND b.state = 1AND a.type = 1AND b.type = 4AND a.relate_Id = %s`
|
|
|
|
)
|
|
)
|
|
|
|
|
|
type ProjectData struct {
|
|
type ProjectData struct {
|
|
@@ -28,42 +27,48 @@ type ProjectData struct {
|
|
}
|
|
}
|
|
|
|
|
|
type ProjectEntry struct {
|
|
type ProjectEntry struct {
|
|
- projectName string
|
|
|
|
- buyer string
|
|
|
|
- buyerId string
|
|
|
|
- sWinner string
|
|
|
|
- area string
|
|
|
|
- city string
|
|
|
|
- district string
|
|
|
|
- startTime int64
|
|
|
|
- entTime int64
|
|
|
|
- subClass string
|
|
|
|
- propertyForm string
|
|
|
|
- businessType string
|
|
|
|
|
|
+ ProjectId string `ch:"project_id"`
|
|
|
|
+ projectName string `ch:"project_name"`
|
|
|
|
+ Buyer string `ch:"buyer"`
|
|
|
|
+ BuyerId string `ch:"buyer_id"`
|
|
|
|
+ Winner []string `ch:"winner"`
|
|
|
|
+ Area string `ch:"area"`
|
|
|
|
+ city string `ch:"city"`
|
|
|
|
+ District string `ch:"district"`
|
|
|
|
+ ZbTime int64 `ch:"zbtime"`
|
|
|
|
+ EndTime int64 `ch:"endtime"`
|
|
|
|
+ IsHandle int `json:"is_handle"`
|
|
|
|
+ IsIgnore int `json:"is_ignore"`
|
|
|
|
+ IsCreate int `json:"is_create"`
|
|
|
|
+ MyConn bool `json:"my_conn"`
|
|
|
|
+ ConnType int `json:"conn_type"`
|
|
|
|
+ HighSuccess bool `json:"high_success"`
|
|
}
|
|
}
|
|
|
|
|
|
-func GetProjectList(req *types.ProjectListReq) (resultList []map[string]interface{}, hasNextPage bool, total int) {
|
|
|
|
|
|
+func GetProjectList(req *types.ProjectListReq) (resultList []*ProjectEntry, hasNextPage bool, total int) {
|
|
|
|
|
|
buyerM := service.BuyerList(req.PartyA, req.Supplier, req.Heterotophy, req.Intermediary, req.Agency)
|
|
buyerM := service.BuyerList(req.PartyA, req.Supplier, req.Heterotophy, req.Intermediary, req.Agency)
|
|
service.MonitorStatusInit(req.PositionId, buyerM, "0")
|
|
service.MonitorStatusInit(req.PositionId, buyerM, "0")
|
|
|
|
+ buyerArr := make([]string, len(*buyerM))
|
|
|
|
+ for b := range *buyerM {
|
|
|
|
+ buyerArr = append(buyerArr, b)
|
|
|
|
+ }
|
|
|
|
|
|
preSales := preSalesStatus(req.PositionId)
|
|
preSales := preSalesStatus(req.PositionId)
|
|
isSqlPage := false
|
|
isSqlPage := false
|
|
if req.SaleStatus == 0 {
|
|
if req.SaleStatus == 0 {
|
|
isSqlPage = true // 是否sql分页
|
|
isSqlPage = true // 是否sql分页
|
|
}
|
|
}
|
|
- findSql := getQuerySql(req, isSqlPage)
|
|
|
|
|
|
+ findSql := getQuerySql(req, isSqlPage, buyerArr)
|
|
rows, err := T.ClickhouseConn.Query(context.TODO(), findSql)
|
|
rows, err := T.ClickhouseConn.Query(context.TODO(), findSql)
|
|
defer rows.Close()
|
|
defer rows.Close()
|
|
if err != nil {
|
|
if err != nil {
|
|
return nil, false, 0
|
|
return nil, false, 0
|
|
}
|
|
}
|
|
- i := 0
|
|
|
|
- info := make(map[string]interface{})
|
|
|
|
for rows.Next() {
|
|
for rows.Next() {
|
|
- rows.Scan(&info)
|
|
|
|
- resultList = append(resultList, info)
|
|
|
|
- i++
|
|
|
|
|
|
+ project := ProjectEntry{}
|
|
|
|
+ rows.Scan(&project)
|
|
|
|
+ resultList = append(resultList, &project)
|
|
}
|
|
}
|
|
|
|
|
|
filterData(req, resultList, preSales, isSqlPage)
|
|
filterData(req, resultList, preSales, isSqlPage)
|
|
@@ -102,11 +107,15 @@ func preSalesStatus(posid int64) (m1 map[string]interface{}) {
|
|
return m1
|
|
return m1
|
|
}
|
|
}
|
|
|
|
|
|
-func getQuerySql(req *types.ProjectListReq, isPage bool) (findSql string) {
|
|
|
|
|
|
+func getQuerySql(req *types.ProjectListReq, isPage bool, buyerArr []string) (findSql string) {
|
|
querys := []string{}
|
|
querys := []string{}
|
|
|
|
+ // 左侧选中的业主id
|
|
|
|
+ if len(buyerArr) > 0 {
|
|
|
|
+ querys = append(querys, fmt.Sprintf(" a.buyer_id in (%s) ", strings.Join(buyerArr, ",")))
|
|
|
|
+ }
|
|
// 商机类型
|
|
// 商机类型
|
|
if req.BusinessType != "" {
|
|
if req.BusinessType != "" {
|
|
- querys = append(querys, fmt.Sprintf(" a.business_type in (%s) ", req.BusinessType))
|
|
|
|
|
|
+ querys = append(querys, fmt.Sprintf(" a.business_type in ('%s') ", req.BusinessType))
|
|
}
|
|
}
|
|
if req.ProjectName != "" {
|
|
if req.ProjectName != "" {
|
|
querys = append(querys, " a.projectname like '% "+req.ProjectName+"%'")
|
|
querys = append(querys, " a.projectname like '% "+req.ProjectName+"%'")
|
|
@@ -121,8 +130,6 @@ func getQuerySql(req *types.ProjectListReq, isPage bool) (findSql string) {
|
|
} else if req.StartTime == 0 && req.EntTime > 0 {
|
|
} else if req.StartTime == 0 && req.EntTime > 0 {
|
|
et := req.StartTime + 90*24*60*60
|
|
et := req.StartTime + 90*24*60*60
|
|
querys = append(querys, fmt.Sprintf(" a.endtime<=%d", et))
|
|
querys = append(querys, fmt.Sprintf(" a.endtime<=%d", et))
|
|
- } else {
|
|
|
|
- querys = append(querys, " a.endtime>0")
|
|
|
|
}
|
|
}
|
|
var regionArr = []string{}
|
|
var regionArr = []string{}
|
|
if req.Area != "" || req.City != "" || req.District != "" {
|
|
if req.Area != "" || req.City != "" || req.District != "" {
|
|
@@ -192,7 +199,7 @@ func getQuerySql(req *types.ProjectListReq, isPage bool) (findSql string) {
|
|
}
|
|
}
|
|
querys = append(querys, fmt.Sprintf(" a.property_form in (%s) ", strings.Join(arr, ",")))
|
|
querys = append(querys, fmt.Sprintf(" a.property_form in (%s) ", strings.Join(arr, ",")))
|
|
}
|
|
}
|
|
- findSql = "select a.project_id,a.project_name,a.project_budget,a.project_money,a.business_type,a.buyer from"
|
|
|
|
|
|
+ findSql = "select a.project_id, a.project_name, a.buyer, a.buyer_id, a.winner, a.winner_id, a.area, a.city, a.district, a.zbtime, a.endtime "
|
|
findSql = fmt.Sprintf("%s from %s a where %s ", findSql, "information.transaction_info", strings.Join(querys, " and "))
|
|
findSql = fmt.Sprintf("%s from %s a where %s ", findSql, "information.transaction_info", strings.Join(querys, " and "))
|
|
if isPage {
|
|
if isPage {
|
|
findSql += fmt.Sprintf(" limit %d,%d", (req.PageNum-1)*pageSize, pageSize)
|
|
findSql += fmt.Sprintf(" limit %d,%d", (req.PageNum-1)*pageSize, pageSize)
|
|
@@ -203,8 +210,8 @@ func getQuerySql(req *types.ProjectListReq, isPage bool) (findSql string) {
|
|
// @Author jianghan
|
|
// @Author jianghan
|
|
// @Description 过滤数据/补充销售机会状态信息,返回分页结果数据
|
|
// @Description 过滤数据/补充销售机会状态信息,返回分页结果数据
|
|
// @Date 2024/4/18
|
|
// @Date 2024/4/18
|
|
-func filterData(req *types.ProjectListReq, resultList []map[string]interface{}, preSales map[string]interface{}, isSqlPage bool) {
|
|
|
|
- var newList []map[string]interface{}
|
|
|
|
|
|
+func filterData(req *types.ProjectListReq, resultList []*ProjectEntry, preSales map[string]interface{}, isSqlPage bool) {
|
|
|
|
+ var newList []*ProjectEntry
|
|
f := ""
|
|
f := ""
|
|
v := 0
|
|
v := 0
|
|
if req.SaleStatus == 1 {
|
|
if req.SaleStatus == 1 {
|
|
@@ -218,10 +225,10 @@ func filterData(req *types.ProjectListReq, resultList []map[string]interface{},
|
|
v = 1
|
|
v = 1
|
|
}
|
|
}
|
|
for _, m := range resultList {
|
|
for _, m := range resultList {
|
|
- if m1, ok := preSales[common.ObjToString(m["project_id"])].(map[string]interface{}); ok {
|
|
|
|
- m["is_handle"] = m1["is_handle"]
|
|
|
|
- m["is_ignore"] = m1["is_ignore"]
|
|
|
|
- m["is_create"] = m1["is_create"]
|
|
|
|
|
|
+ if m1, ok := preSales[m.ProjectId].(map[string]interface{}); ok {
|
|
|
|
+ m.IsHandle = common.IntAll(m1["is_handle"])
|
|
|
|
+ m.IsIgnore = common.IntAll(m1["is_ignore"])
|
|
|
|
+ m.IsCreate = common.IntAll(m1["is_create"])
|
|
if !isSqlPage && m1[f] == v {
|
|
if !isSqlPage && m1[f] == v {
|
|
newList = append(newList, m)
|
|
newList = append(newList, m)
|
|
}
|
|
}
|
|
@@ -235,46 +242,46 @@ func filterData(req *types.ProjectListReq, resultList []map[string]interface{},
|
|
// @Author jianghan
|
|
// @Author jianghan
|
|
// @Description 补充人脉 等信息
|
|
// @Description 补充人脉 等信息
|
|
// @Date 2024/4/17
|
|
// @Date 2024/4/17
|
|
-func moreInfo(req *types.ProjectListReq, list []map[string]interface{}) (result []map[string]interface{}) {
|
|
|
|
|
|
+func moreInfo(req *types.ProjectListReq, list []*ProjectEntry) (result []*ProjectEntry) {
|
|
for _, m := range list {
|
|
for _, m := range list {
|
|
- // 人脉、人脉所在单位项目 conn_type: 1/人脉可转介绍项目 conn_type: 2
|
|
|
|
|
|
+ // 人脉、人脉所在单位项目 conn_type: 1 人脉可转介绍项目; conn_type: 2 人脉所在单位项目
|
|
field1 := ""
|
|
field1 := ""
|
|
query1 := map[string]interface{}{
|
|
query1 := map[string]interface{}{
|
|
"position_id": req.PositionId,
|
|
"position_id": req.PositionId,
|
|
- "company_id": common.ObjToString(m["buyer_id"]),
|
|
|
|
|
|
+ "company_id": m.BuyerId,
|
|
"status": 1,
|
|
"status": 1,
|
|
}
|
|
}
|
|
info1 := T.CrmMysql.FindOne("connection", query1, field1, "")
|
|
info1 := T.CrmMysql.FindOne("connection", query1, field1, "")
|
|
if info1 != nil && len(*info1) > 0 {
|
|
if info1 != nil && len(*info1) > 0 {
|
|
- m["my_conn"] = true
|
|
|
|
- m["conn_type"] = 1
|
|
|
|
|
|
+ m.MyConn = true // 我的人脉
|
|
|
|
+ m.ConnType = 1
|
|
} else {
|
|
} else {
|
|
- m["my_conn"] = false
|
|
|
|
|
|
+ m.MyConn = false
|
|
}
|
|
}
|
|
- if m["conn_type"] != nil {
|
|
|
|
|
|
+ if m.ConnType == 0 {
|
|
query2 := map[string]interface{}{
|
|
query2 := map[string]interface{}{
|
|
- "company_id": common.ObjToString(m["buyer_id"]),
|
|
|
|
|
|
+ "company_id": m.BuyerId,
|
|
}
|
|
}
|
|
info2 := T.CrmMysql.FindOne("connection", query2, field1, "")
|
|
info2 := T.CrmMysql.FindOne("connection", query2, field1, "")
|
|
if info2 != nil && len(*info2) > 0 {
|
|
if info2 != nil && len(*info2) > 0 {
|
|
- m["conn_type"] = 1
|
|
|
|
|
|
+ m.ConnType = 1
|
|
} else {
|
|
} else {
|
|
- m["conn_type"] = 2
|
|
|
|
|
|
+ m.ConnType = 2
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// 转介绍成功率高标签
|
|
// 转介绍成功率高标签
|
|
count := 0
|
|
count := 0
|
|
- err := T.ClickhouseConn.QueryRow(context.TODO(), sql_1, common.ObjToString(m["buyer_id"])).Scan(&count)
|
|
|
|
|
|
+ err := T.ClickhouseConn.QueryRow(context.TODO(), sql_1, m.BuyerId).Scan(&count)
|
|
if err != nil && count > 2 {
|
|
if err != nil && count > 2 {
|
|
- m["high_success"] = true
|
|
|
|
|
|
+ m.HighSuccess = true
|
|
} else {
|
|
} else {
|
|
- m["high_success"] = false
|
|
|
|
|
|
+ m.HighSuccess = false
|
|
}
|
|
}
|
|
|
|
|
|
// 人脉路径
|
|
// 人脉路径
|
|
// 有我的人脉标签时不需要查询人脉路径信息
|
|
// 有我的人脉标签时不需要查询人脉路径信息
|
|
- if m["my_conn"] == false {
|
|
|
|
- service.ConnectionsHandle([]string{common.ObjToString(m["buyer_id"])}, req.PositionId, false)
|
|
|
|
|
|
+ if m.MyConn == false {
|
|
|
|
+ service.ConnectionsHandle([]string{m.BuyerId}, req.PositionId, false)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|