wangchuanjin 9 ماه پیش
والد
کامیت
6cb7f20c95
1فایلهای تغییر یافته به همراه12 افزوده شده و 8 حذف شده
  1. 12 8
      api/internal/service/network.go

+ 12 - 8
api/internal/service/network.go

@@ -482,6 +482,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 			pMyType += vv.Type
 			myChildIds, myChildTypes := "", ""
 			compareId := fmt.Sprint(vv.Id)
+			thisLength := len(checkCode)
 			if in.Id == "" && v.Name == "甲方" {
 				cccNodes := []*nodeTree{}
 				cccIndexMap := map[string]int{}
@@ -562,6 +563,9 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 				for _, cccNode := range cccNodes {
 					*convList = append(*convList, cccNode)
 				}
+				if in.CheckCode != "" {
+					compareId = "-1"
+				}
 			} else {
 				if id != "" {
 					id += ","
@@ -601,7 +605,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 				MYTYPE:    vv.Type,
 			}
 			//如果甲方的子节点被选中了,父节点跟着被选中,非甲方的要对比子节点可介绍业主
-			if v.Name != "甲方" && ((in.ClickId != "" && in.ClickId == fmt.Sprint(vv.Id)) || (in.CheckCode != "" && compareId == fmt.Sprint(vv.Id))) {
+			if thisLength == len(checkCode) && ((in.ClickId != "" && in.ClickId == fmt.Sprint(vv.Id)) || (in.CheckCode != "" && compareId == fmt.Sprint(vv.Id))) {
 				checkCode = append(checkCode, cm.CODE)
 			}
 			*convList = append(*convList, cm)
@@ -614,7 +618,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 	}
 	sort.Sort(convList)
 	*parentConvList = append(*parentConvList, *convList...)
-	var newCheckCode []string
+	newCheckCode := []string{}
 	if in.CheckCode != "" {
 		m := map[string]bool{}
 		for _, v := range strings.Split(in.CheckCode, ",") {
@@ -628,7 +632,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 	} else {
 		newCheckCode = checkCode
 	}
-	if in.CheckCode == "" && in.ClickId == "" && len(checkCode) == 0 && len(*parentConvList) > 0 && (*parentConvList)[0].SZ_LEVEL == 0 {
+	if in.CheckCode == "" && in.ClickId == "" && len(newCheckCode) == 0 && len(*parentConvList) > 0 && (*parentConvList)[0].SZ_LEVEL == 0 {
 		if (*parentConvList)[0].NAME == "甲方" {
 			var level1 *nodeTree
 			var level2 *nodeTree
@@ -648,18 +652,18 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 				}
 			}
 			if level3 != nil && level2 != nil && level1 != nil && level3.SZ_PID2 == level2.CODE && level2.SZ_PID1 == level1.CODE {
-				checkCode = append(checkCode, level3.CODE)
+				newCheckCode = append(newCheckCode, level3.CODE)
 			} else if level2 != nil && level1 != nil && level2.SZ_PID1 == level1.CODE {
-				checkCode = append(checkCode, level2.CODE)
+				newCheckCode = append(newCheckCode, level2.CODE)
 			} else if level1 != nil {
-				checkCode = append(checkCode, level1.CODE)
+				newCheckCode = append(newCheckCode, level1.CODE)
 			}
 		} else {
 			for _, v := range *parentConvList {
 				if (*parentConvList)[0].NAME != v.SZ_PID0 {
 					continue
 				}
-				checkCode = append(checkCode, v.CODE)
+				newCheckCode = append(newCheckCode, v.CODE)
 				break
 			}
 		}
@@ -668,7 +672,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 		Data: map[string]interface{}{
 			"count":   count,
 			"list":    parentConvList,
-			"checked": checkCode,
+			"checked": newCheckCode,
 		},
 	}
 	redis.Put("newother", key, reply, C.CacheTimeOut)