Эх сурвалжийг харах

Merge branch 'hotfix/v1.0.4.2' of https://jygit.jydev.jianyu360.cn/CRM/application into hotfix/v1.0.4.2

wangchuanjin 1 жил өмнө
parent
commit
061ab6a11d

+ 32 - 32
api/internal/service/CoopHistoryService.go

@@ -63,44 +63,44 @@ func GetPrList(req *types.CoopHistoryReq) (result []*ResultData, size_1, size_2,
 	propertyForm := T.NetworkCom.GetMyProbusfor(req.EntAccountId)
 	// firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 agency:招标代理机构 sup_sub: 上下级
 	// 1、同甲异业数据/ 3、招标代理机构渠道
-	r1, r2 := GetData(propertyForm, pTmp.BuyerId)
-	if r1 != nil && len(r1) > 0 {
-		size_1 = int64(len(r1))
-		if req.ChannelType == "0" || req.ChannelType == "1" {
-			for _, m := range r1 {
-				near, zbtime := LastTimeCoop(pTmp.BuyerId, common.ObjToString(m["name"]), "adiffb")
-				tmp := ResultData{
-					SourceType:  "adiffb",
-					EntName:     common.ObjToString(m["name"]),
-					ProjectNum:  common.IntAll(m["coop_size"]),
-					TotalAmount: common.Float64All(m["coop_amount"]),
-					RecentTime:  zbtime,
-					NearlyYears: near,
-					BuyerId:     pTmp.BuyerId,
+	if pTmp.BuyerId != "" {
+		r1, r2 := GetData(propertyForm, pTmp.BuyerId)
+		if r1 != nil && len(r1) > 0 {
+			size_1 = int64(len(r1))
+			if req.ChannelType == "0" || req.ChannelType == "1" {
+				for _, m := range r1 {
+					near, zbtime := LastTimeCoop(pTmp.BuyerId, common.ObjToString(m["name"]), "adiffb")
+					tmp := ResultData{
+						SourceType:  "adiffb",
+						EntName:     common.ObjToString(m["name"]),
+						ProjectNum:  common.IntAll(m["coop_size"]),
+						TotalAmount: common.Float64All(m["coop_amount"]),
+						RecentTime:  zbtime,
+						NearlyYears: near,
+						BuyerId:     pTmp.BuyerId,
+					}
+					result = append(result, &tmp)
 				}
-				result = append(result, &tmp)
 			}
 		}
-	}
-	if r2 != nil && len(r2) > 0 {
-		size_3 = int64(len(r2))
-		if req.ChannelType == "0" || req.ChannelType == "3" {
-			for _, m := range r2 {
-				near, zbtime := LastTimeCoop(pTmp.BuyerId, common.ObjToString(m["name"]), "agency")
-				tmp := ResultData{
-					SourceType:  "agency",
-					EntName:     common.ObjToString(m["name"]),
-					ProjectNum:  common.IntAll(m["coop_size"]),
-					TotalAmount: common.Float64All(m["coop_amount"]),
-					RecentTime:  zbtime,
-					NearlyYears: near,
-					BuyerId:     pTmp.BuyerId,
+		if r2 != nil && len(r2) > 0 {
+			size_3 = int64(len(r2))
+			if req.ChannelType == "0" || req.ChannelType == "3" {
+				for _, m := range r2 {
+					near, zbtime := LastTimeCoop(pTmp.BuyerId, common.ObjToString(m["name"]), "agency")
+					tmp := ResultData{
+						SourceType:  "agency",
+						EntName:     common.ObjToString(m["name"]),
+						ProjectNum:  common.IntAll(m["coop_size"]),
+						TotalAmount: common.Float64All(m["coop_amount"]),
+						RecentTime:  zbtime,
+						NearlyYears: near,
+						BuyerId:     pTmp.BuyerId,
+					}
+					result = append(result, &tmp)
 				}
-				result = append(result, &tmp)
 			}
 		}
-	}
-	if pTmp.BuyerId != "" {
 		// 中间人可介绍业主
 		var r3 []map[string]interface{}
 		r3 = FindMiddleman([]string{fmt.Sprintf("'%s'", pTmp.BuyerId)}, req.PositionId, r3)

+ 6 - 6
api/internal/service/employService.go

@@ -670,19 +670,19 @@ func employInfoPerson(table, employKey, findKey string, in *types.InfoEmployinfo
 	wuyeData1 := &[]map[string]interface{}{}
 	wuyeData2 := &[]map[string]interface{}{}
 	if len(infoId1Arr) > 0 {
-		infoData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select   %s, is_ignore,status,id,type from  %s   where position_id =? and  %s in ('%s')    GROUP BY %s ,type  order  by type", employKey, table, employKey, strings.Join(infoId1Arr, "','"), employKey), in.PositionId)
+		infoData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select   %s, is_ignore,status,id,type from  %s   where position_id =? and  %s in ('%s')    GROUP BY %s ,type  order  by type desc", employKey, table, employKey, strings.Join(infoId1Arr, "','"), employKey), in.PositionId)
 	}
 	if len(infoId2Arr) > 0 {
-		infoData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select  %s,  is_ignore,status,id,type from  %s   where position_id =? and  %s in '%s')    GROUP BY %s ,type order  by type ", employKey, table, employKey, strings.Join(infoId2Arr, "','"), employKey), in.PositionId)
+		infoData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select  %s,  is_ignore,status,id,type from  %s   where position_id =? and  %s in '%s')    GROUP BY %s ,type order  by type desc", employKey, table, employKey, strings.Join(infoId2Arr, "','"), employKey), in.PositionId)
 	}
 	if len(niJianIdArr) > 0 {
-		niJianData = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s,   is_ignore,status,id,type from  %s   where position_id =? and  %s in ('%s')    GROUP BY %s  ,type order  by type", employKey, table, employKey, strings.Join(niJianIdArr, "','"), employKey), in.PositionId)
+		niJianData = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s,   is_ignore,status,id,type from  %s   where position_id =? and  %s in ('%s')    GROUP BY %s  ,type order  by type desc", employKey, table, employKey, strings.Join(niJianIdArr, "','"), employKey), in.PositionId)
 	}
 	if len(wuye1Arr) > 0 {
-		wuyeData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select  %s,  is_ignore,status,id,type from  %s   where position_id =? and  %s in ('%s')  GROUP BY %s  ,type order  by type", employKey, table, employKey, strings.Join(wuye1Arr, "','"), employKey), in.PositionId)
+		wuyeData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select  %s,  is_ignore,status,id,type from  %s   where position_id =? and  %s in ('%s')  GROUP BY %s  ,type order  by type desc", employKey, table, employKey, strings.Join(wuye1Arr, "','"), employKey), in.PositionId)
 	}
 	if len(wuye2Arr) > 0 {
-		wuyeData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select   %s, is_ignore,status,id,type from  %s   where position_id =? and  %s in ('%s')    GROUP BY %s ,type order  by type ", employKey, table, employKey, strings.Join(wuye2Arr, "','"), employKey), in.PositionId)
+		wuyeData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select   %s, is_ignore,status,id,type from  %s   where position_id =? and  %s in ('%s')    GROUP BY %s ,type order  by type desc", employKey, table, employKey, strings.Join(wuye2Arr, "','"), employKey), in.PositionId)
 	}
 	for _, v := range *infoData1 {
 		valueMap := map[string]interface{}{
@@ -802,7 +802,7 @@ func employInfoEnt(table, employKey, findKey, depIDArr string, in *types.InfoEmp
 		wuyeData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s,  id,is_ignore,status ,type  from  %s   where %s in ('%s')  and status =1 and  source=? and    ent_dept_id in  (%s)  GROUP BY %s  ,type order  by type", employKey, table, employKey, strings.Join(wuye1Arr, "','"), depIDArr, employKey), 1)
 	}
 	if len(wuye2Arr) > 0 {
-		wuyeData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s id,is_ignore,status ,type  from  %s   where %s  in ('%s')  and status =1 and  source=? and    ent_dept_id in  (%s) GROUP BY %s ,type order  by type", employKey, table, employKey, strings.Join(wuye2Arr, "','"), depIDArr, employKey), 2)
+		wuyeData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, id,is_ignore,status ,type  from  %s   where %s  in ('%s')  and status =1 and  source=? and    ent_dept_id in  (%s) GROUP BY %s ,type order  by type", employKey, table, employKey, strings.Join(wuye2Arr, "','"), depIDArr, employKey), 2)
 	}
 	for _, v := range *infoData1 {
 		valueMap := map[string]interface{}{

+ 18 - 7
api/internal/service/owner.go

@@ -57,6 +57,7 @@ type BuyerProject struct {
 	IsIgnore         bool
 	Area             string
 	Zbtime           int64
+	BuyerType        string
 }
 type ProjectEntity struct {
 	Number          int64
@@ -551,6 +552,7 @@ func BuyerProjectMerge(dataMap, projectMap *map[string]map[string]interface{}, s
 			returnData = append(returnData, BuyerProject{
 				BuyerId:   buyerId,
 				BuyerName: buyerName,
+				BuyerType: gconv.String(buyerMap["buyerType"]),
 				Project: ProjectEntity{
 					Number:          count,
 					EstimatedAmount: money,
@@ -571,6 +573,7 @@ func BuyerProjectMerge(dataMap, projectMap *map[string]map[string]interface{}, s
 			returnData = append(returnData, BuyerProject{
 				BuyerId:   buyerId,
 				BuyerName: buyerName,
+				BuyerType: gconv.String(buyerMap["buyerType"]),
 				Project: ProjectEntity{
 					Number:          0,
 					EstimatedAmount: 0,
@@ -706,7 +709,7 @@ func BuyerList(partyA, supplier, heterotophy, intermediary, agency string, posit
 		}
 		if len(partyA) > 0 {
 			partyASql := fmt.Sprintf(`select  id as buyer_id,company_name as buyer  from  ent_info   where  id in (%s)`, strings.Join(intermediaryArr, ","))
-			FindHandle(partyASql, dataMap)
+			FindHandle(partyASql, dataMap, "firstparty")
 		}
 	}
 	//供应商 //同甲异业
@@ -718,17 +721,22 @@ func BuyerList(partyA, supplier, heterotophy, intermediary, agency string, posit
 			}
 		}
 	}
+	if len(findInSetArr) > 0 {
+		sqlStr := fmt.Sprintf(`SELECT buyer_id,buyer FROM transaction_info where  hasAny(winner_id,[%s])    `, strings.Join(findInSetArr, ","))
+		FindHandle(sqlStr, dataMap, "supplier")
+	}
 	//同甲异业
+	findheterotophyArr := []string{}
 	if heterotophy != "" {
 		for _, v := range strings.Split(heterotophy, ",") {
 			if v != "" {
-				findInSetArr = append(findInSetArr, fmt.Sprintf("'%s'", v))
+				findheterotophyArr = append(findheterotophyArr, fmt.Sprintf("'%s'", v))
 			}
 		}
 	}
-	if len(findInSetArr) > 0 {
-		sqlStr := fmt.Sprintf(`SELECT buyer_id,buyer FROM transaction_info where  hasAny(winner_id,[%s])    `, strings.Join(findInSetArr, ","))
-		FindHandle(sqlStr, dataMap)
+	if len(findheterotophyArr) > 0 {
+		sqlStr := fmt.Sprintf(`SELECT buyer_id,buyer FROM transaction_info where  hasAny(winner_id,[%s])    `, strings.Join(findheterotophyArr, ","))
+		FindHandle(sqlStr, dataMap, "adiffb")
 	}
 	//中间人
 	if intermediary != "" {
@@ -741,6 +749,7 @@ func BuyerList(partyA, supplier, heterotophy, intermediary, agency string, posit
 				buyerName := gconv.String(m["relate_name"])
 				(*dataMap)[buyerId] = map[string]interface{}{
 					"buyerName": buyerName,
+					"buyerType": "middleman",
 				}
 			}
 		}
@@ -752,7 +761,7 @@ func BuyerList(partyA, supplier, heterotophy, intermediary, agency string, posit
 			agencyArr = append(agencyArr, fmt.Sprintf("'%s'", s))
 		}
 		sqlStr := fmt.Sprintf(`SELECT  buyer_id,buyer FROM transaction_info  where agency_id in (%s) `, strings.Join(agencyArr, ","))
-		FindHandle(sqlStr, dataMap)
+		FindHandle(sqlStr, dataMap, "agency")
 	}
 	return dataMap
 }
@@ -823,6 +832,7 @@ func ProjectHandle(buyerArr []string, entAccountId int64, entName, area, project
 			}
 			(*returnMap)[buyerId] = map[string]interface{}{
 				"buyerName": buyerName,
+				"buyerType": "firstparty",
 			}
 
 		}
@@ -874,7 +884,7 @@ type BuyerAggStruct struct {
 }
 
 // 采购单位查询sql
-func FindHandle(sqlStr string, dataMap *map[string]map[string]interface{}) {
+func FindHandle(sqlStr string, dataMap *map[string]map[string]interface{}, buyerType string) {
 	rows, err := ClickhouseConn.Query(context.Background(), sqlStr)
 	if err != nil {
 		logx.Error("查询失败", sqlStr, err)
@@ -885,6 +895,7 @@ func FindHandle(sqlStr string, dataMap *map[string]map[string]interface{}) {
 		if data.BuyerId != "" {
 			(*dataMap)[data.BuyerId] = map[string]interface{}{
 				"buyerName": data.Buyer,
+				"buyerType": buyerType,
 			}
 		}
 	}

+ 19 - 7
api/internal/service/plistService.go

@@ -113,7 +113,7 @@ func GetProjectList(req *types.ProjectListReq) (resultList []*ProjectEntry, hasN
 			hasNextPage = false
 		}
 	}
-	moreInfo(req, resultList) //  补充信息
+	moreInfo(req, plist, resultList) //  补充信息
 
 	return
 }
@@ -320,7 +320,7 @@ func filterData(req *types.ProjectListReq, resultList []*ProjectEntry, preSales,
 // @Author jianghan
 // @Description 补充人脉 等信息
 // @Date 2024/4/17
-func moreInfo(req *types.ProjectListReq, list []*ProjectEntry) (result []*ProjectEntry) {
+func moreInfo(req *types.ProjectListReq, plist []string, list []*ProjectEntry) (result []*ProjectEntry) {
 	var buyerIds []string
 	for _, m := range list {
 		if m.BuyerId != "" {
@@ -352,17 +352,29 @@ func moreInfo(req *types.ProjectListReq, list []*ProjectEntry) (result []*Projec
 		}
 	}
 	for _, m := range list {
+		// 中间人的项目 默认 我的人脉
+		if len(plist) > 0 {
+			for _, pid := range plist {
+				if m.ProjectId == pid {
+					m.MyConn = true
+					m.ConnType = 1
+					break
+				}
+			}
+		}
 		// 补充跳转链接
 		if m.BusinessType == "采购意向" || m.BusinessType == "招标项目" {
 			m.Href = fmt.Sprintf("/article/content/%s.html", encrypt.CommonEncodeArticle("content", m.ProjectId))
 		}
 		m.ProjectId = util.EncodeId(m.ProjectId)
 		// 人脉、人脉所在单位项目 conn_type: 1 人脉可转介绍项目; conn_type: 2 人脉所在单位项目
-		if connMap[m.BuyerId] == 1 {
-			m.MyConn = true // 我的人脉
-			m.ConnType = 1
-		} else {
-			m.MyConn = false
+		if !m.MyConn {
+			if connMap[m.BuyerId] == 1 {
+				m.MyConn = true // 我的人脉
+				m.ConnType = 1
+			} else {
+				m.MyConn = false
+			}
 		}
 		if m.ConnType == 0 {
 			if connMap[m.BuyerId] != 0 {