소스 검색

Merge branch 'dev_v1.0.4_wh' of CRM/application into feature/v1.0.4

王浩 1 년 전
부모
커밋
4dacc0f673
1개의 변경된 파일20개의 추가작업 그리고 9개의 파일을 삭제
  1. 20 9
      api/internal/service/owner.go

+ 20 - 9
api/internal/service/owner.go

@@ -101,11 +101,11 @@ func (t *OwnerService) OwnerlList() map[string]interface{} {
 			buyerArr = append(buyerArr, fmt.Sprintf(`"%s"`, gconv.String(value["buyerName"])))
 		}
 		//项目数量处理
-		projectMap, _ = ProjectHandle(buyerArr, t.EntAccountId, t.SearchEntName, t.Area, t.ProjectType)
+		projectMap, _, dataMap = ProjectHandle(buyerArr, t.EntAccountId, t.SearchEntName, t.Area, t.ProjectType, dataMap)
 	} else if t.SearchEntName != "" {
 		//1 只看转介绍成功率高2只看已监控的
 		//先查找采购单位数据
-		projectMap, dataMap = ProjectHandle([]string{}, t.EntAccountId, t.SearchEntName, t.Area, t.ProjectType)
+		projectMap, dataMap, _ = ProjectHandle([]string{}, t.EntAccountId, t.SearchEntName, t.Area, t.ProjectType, dataMap)
 		a7 := time.Now().Unix()
 		fmt.Println("es用时", a7-startTime)
 		if t.ProcessingStatus != "" {
@@ -717,7 +717,7 @@ func BuyerList(partyA, supplier, heterotophy, intermediary, agency string, posit
 }
 
 // 项目数量查询
-func ProjectHandle(buyerArr []string, entAccountId int64, entName, area, projectType string) (*map[string]map[string]interface{}, *map[string]map[string]interface{}) {
+func ProjectHandle(buyerArr []string, entAccountId int64, entName, area, projectType string, dataMap *map[string]map[string]interface{}) (*map[string]map[string]interface{}, *map[string]map[string]interface{}, *map[string]map[string]interface{}) {
 	projectMap := &map[string]map[string]interface{}{}
 	returnMap := &map[string]map[string]interface{}{}
 	sql := ""
@@ -747,7 +747,7 @@ func ProjectHandle(buyerArr []string, entAccountId int64, entName, area, project
 	endTime := time.Now().Unix()
 	fmt.Println("es用时时间:", endTime-startTime)
 	if len(data) == 0 {
-		return projectMap, returnMap
+		return projectMap, returnMap, dataMap
 	}
 	for _, object := range data {
 		buyerArr := BuyerAggStruct{}
@@ -780,17 +780,28 @@ func ProjectHandle(buyerArr []string, entAccountId int64, entName, area, project
 			(*returnMap)[buyerId] = map[string]interface{}{
 				"buyerName": buyerName,
 			}
+
 		}
 	}
 	if projectType == "1" {
-		for _, v := range *returnMap {
-			buyerName := gconv.String(v["buyerName"])
-			if _, ok := (*projectMap)[buyerName]; !ok {
-				delete(*returnMap, buyerName)
+		if entName == "" {
+			for buyerId, v := range *dataMap {
+				buyerName := gconv.String(v["buyerName"])
+				if _, ok := (*projectMap)[buyerName]; !ok {
+					delete(*dataMap, buyerId)
+				}
+			}
+		} else {
+			for buyerId, v := range *returnMap {
+				buyerName := gconv.String(v["buyerName"])
+				if _, ok := (*projectMap)[buyerName]; !ok {
+					delete(*returnMap, buyerId)
+				}
 			}
 		}
+
 	}
-	return projectMap, returnMap
+	return projectMap, returnMap, dataMap
 }
 
 type BuyerAggStruct struct {