wangchuanjin 9 сар өмнө
parent
commit
0af8d55fdd

+ 77 - 15
api/internal/service/network.go

@@ -37,12 +37,13 @@ type networkTree struct {
 	Children []*networkTreeChild `json:"children"`
 }
 type networkTreeChild struct {
-	Count       int64  `json:"count"`
-	Id          int64  `json:"id"`
-	CompanyId   string `json:"companyId"`
-	CompanyName string `json:"companyName"`
-	Type        string `json:"type"`
-	CreateTime  string `json:"createTime"`
+	Count       int64     `json:"count"`
+	Id          int64     `json:"id"`
+	CompanyId   string    `json:"companyId"`
+	CompanyName string    `json:"companyName"`
+	Type        string    `json:"type"`
+	CreateTime  string    `json:"createTime"`
+	IdNames     []*idName `json:"idNames"`
 }
 
 func (n *networkTree) Len() int {
@@ -330,7 +331,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 	reply = &types.Reply{}
 	key := fmt.Sprintf(NetworkManageAllProjectKey, in.PositionId)
 	rbt, rerr := redis.GetNewBytes("newother", key)
-	if rerr == nil && rbt != nil {
+	if false && rerr == nil && rbt != nil {
 		json.Unmarshal(*rbt, &reply)
 		return
 	}
@@ -416,15 +417,18 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 			case 2:
 				if aio.Supplier[v.Company_id] != nil {
 					ntc.Count = aio.Supplier[v.Company_id].ProjectCount
+					ntc.IdNames = aio.Supplier[v.Company_id].IdNames
 				}
 			case 3:
 				if aio.Adiffb[v.Company_id] != nil {
 					ntc.Count = aio.Adiffb[v.Company_id].ProjectCount
+					ntc.IdNames = aio.Adiffb[v.Company_id].IdNames
 				}
 			case 4:
 				if v.Relate_buyer_id != "" {
-					for _, v := range strings.Split(v.Relate_buyer_id, ",") {
-						if aio.Middleman[v] != nil {
+					for _, rbi := range strings.Split(v.Relate_buyer_id, ",") {
+						ntc.IdNames = append(ntc.IdNames, &idName{Id: rbi})
+						if aio.Middleman[rbi] != nil {
 							ntc.Count++
 						}
 					}
@@ -432,6 +436,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 			case 5:
 				if aio.Agency[v.Company_id] != nil {
 					ntc.Count = aio.Agency[v.Company_id].ProjectCount
+					ntc.IdNames = aio.Agency[v.Company_id].IdNames
 				}
 			}
 			count += ntc.Count
@@ -439,9 +444,18 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 			list[v.Itype-1].Children = append(list[v.Itype-1].Children, ntc)
 		}
 	}
+	checkCode := []string{}
 	parentConvList := &nodeTrees{}
 	convList := &nodeTrees{}
+	hasDefaultCheck := false
+	if in.ClickId != "" {
+		hasDefaultCheck = true
+	}
 	for _, v := range list {
+		if len(v.Children) == 0 {
+			continue
+		}
+		parentStartCheckCodeLen := len(checkCode)
 		pm := &nodeTree{
 			CODE:      v.Name,
 			NAME:      v.Name,
@@ -457,6 +471,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 		sort.Sort(v)
 		id, pType, pMyType, pMyId := "", "", "", ""
 		for _, vv := range v.Children {
+			childStartCheckCodeLen := len(checkCode)
 			myId := vv.CompanyId
 			if vv.Type == "middleman" {
 				myId = fmt.Sprint(vv.Id)
@@ -470,10 +485,14 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 			}
 			pMyType += vv.Type
 			myChildIds, myChildTypes := "", ""
+			compareId := fmt.Sprint(vv.Id)
 			if in.Id == "" && v.Name == "甲方" {
 				cccNodes := []*nodeTree{}
 				cccIndexMap := map[string]int{}
 				for _, vvv := range firstpartyChild[vv.CompanyId] {
+					if in.CheckCode != "" {
+						compareId = vvv.CompanyId
+					}
 					cccIndex, cccOk := cccIndexMap[vvv.Name]
 					if cccOk {
 						cccNodes[cccIndex].ID += "," + vvv.CompanyId
@@ -481,7 +500,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 						cccNodes[cccIndex].TYPE += ",firstparty"
 						cccNodes[cccIndex].MYTYPE += ",firstparty"
 					} else {
-						cccNodes = append(cccNodes, &nodeTree{
+						nt := &nodeTree{
 							NAME:     vvv.Name,
 							ID:       vvv.CompanyId,
 							SZ_PID0:  v.Name,
@@ -494,8 +513,12 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 							TYPE:     "firstparty",
 							MYID:     vvv.CompanyId,
 							MYTYPE:   "firstparty",
-						})
+						}
+						cccNodes = append(cccNodes, nt)
 						cccIndexMap[vvv.Name] = len(cccNodes) - 1
+						if !hasDefaultCheck || compareId == in.ClickId {
+							checkCode = append(checkCode, nt.CODE)
+						}
 					}
 					if id != "" {
 						id += ","
@@ -513,7 +536,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 						myChildTypes += ","
 					}
 					myChildTypes += vv.Type
-					*convList = append(*convList, &nodeTree{
+					nt := &nodeTree{
 						NAME:     vvv.CompanyName,
 						ID:       vvv.CompanyId,
 						SZ_PID0:  v.Name,
@@ -527,7 +550,11 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 						TYPE:     "firstparty",
 						MYID:     vvv.CompanyId,
 						MYTYPE:   "firstparty",
-					})
+					}
+					if !hasDefaultCheck || compareId == in.ClickId {
+						checkCode = append(checkCode, nt.CODE)
+					}
+					*convList = append(*convList, nt)
 				}
 				for _, cccNode := range cccNodes {
 					*convList = append(*convList, cccNode)
@@ -543,6 +570,18 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 				pType += vv.Type
 				myChildIds = myId
 				myChildTypes = vv.Type
+				if in.CheckCode != "" {
+					if len(vv.IdNames) == 0 {
+						compareId = "-1"
+					}
+					for in_k, in_v := range vv.IdNames {
+						if in_v.Id == in.ClickId {
+							break
+						} else if in_k == len(vv.IdNames)-1 {
+							compareId = "-1"
+						}
+					}
+				}
 			}
 			cm := &nodeTree{
 				NAME:      vv.CompanyName,
@@ -558,6 +597,10 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 				MYID:      myId,
 				MYTYPE:    vv.Type,
 			}
+			//如果甲方的子节点被选中了,父节点跟着被选中,非甲方的要对比子节点可介绍业主
+			if !hasDefaultCheck || childStartCheckCodeLen != len(checkCode) || (v.Name != "甲方" && compareId == fmt.Sprint(vv.Id)) {
+				checkCode = append(checkCode, cm.CODE)
+			}
 			*convList = append(*convList, cm)
 		}
 		pm.ID = id
@@ -565,13 +608,32 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 		pm.MYTYPE = pMyType
 		pm.MYID = pMyId
 		*parentConvList = append(*parentConvList, pm)
+		if parentStartCheckCodeLen != len(checkCode) {
+			checkCode = append(checkCode, pm.CODE)
+		}
+		hasDefaultCheck = true
 	}
 	sort.Sort(convList)
 	*parentConvList = append(*parentConvList, *convList...)
+	var newCheckCode []string
+	if in.CheckCode != "" {
+		m := map[string]bool{}
+		for _, v := range strings.Split(in.CheckCode, ",") {
+			m[v] = true
+		}
+		for _, v := range checkCode {
+			if m[v] {
+				newCheckCode = append(newCheckCode, v)
+			}
+		}
+	} else {
+		newCheckCode = checkCode
+	}
 	reply = &types.Reply{
 		Data: map[string]interface{}{
-			"count": count,
-			"list":  parentConvList,
+			"count":   count,
+			"list":    parentConvList,
+			"checked": checkCode,
 		},
 	}
 	redis.Put("newother", key, reply, C.CacheTimeOut)

+ 12 - 6
api/internal/service/network_test.go

@@ -109,8 +109,11 @@ func TestNetWorkList(t *testing.T) {
 func TestAllProject(t *testing.T) {
 	InitConf()
 	res := Network.AllProject(&types.AllprojectReq{
-		EntAccountId: 900824,
-		PositionId:   1205621877,
+		EntId:      221,
+		PositionId: 935,
+		//ClickId:    "30126",
+		//ClickId: "a2c934cc9fda4561864077f2cf7f44ba",
+		//CheckCode: "同甲异业渠道,同甲异业渠道:ffe7b3b526f048f9999b803a4241ce77",
 		//PositionId: 1205591997, //刘苗
 		//PositionId: 1205592003,//刘亚丽
 		//Id:   "009c313ef8e740e59d57432aea777102",
@@ -123,15 +126,18 @@ func TestAllProject(t *testing.T) {
 func TestOwner(t *testing.T) {
 	InitConf()
 	ownerService := &OwnerService{
-		PartyA:      "30604a74c36f47daa532503ac496914c",
-		Heterotophy: "wcj_11111111d,112233445566,112233445566,000cfa77354c49969e4cfddd15dd5b26,000cfa77354c49969e4cfddd15dd5b26,ffe7b3b526f048f9999b803a4241ce77,3a0068dcbf4041aebfdd38f77f553d87,fb180e2267d74081a0e177692df92b42",
-		Agency:      "wcj_11111111c,112233445566,001dfe3364b8480c965f81ab64d76bb4,00172d07d1fd4d90bd95fe5a348a845d",
+		//PartyA: "ffe7b3b526f048f9999b803a4241ce77",
+		Heterotophy: "ffe7b3b526f048f9999b803a4241ce77",
+		//Agency:      "wcj_11111111c,112233445566,001dfe3364b8480c965f81ab64d76bb4,00172d07d1fd4d90bd95fe5a348a845d",
 		//Agency:      "00172d07d1fd4d90bd95fe5a348a845d",
-		PositionId:  935,
+		//Supplier:    "ffe7b3b526f048f9999b803a4241ce77",
 		PageIndex:   1,
 		PageSize:    100,
 		ProjectType: "1",
+		PositionId:  935,
 		EntId:       221,
+		//PositionId:  1205591997,
+		//EntId:       146318,
 		//SourceType:  "2",
 	}
 	data := ownerService.OwnerlList()

+ 1 - 1
api/internal/service/owner.go

@@ -120,7 +120,7 @@ func (t *OwnerService) OwnerlList() *OwnerlListRes {
 		}
 	}
 	// 没有缓存时的处理逻辑
-	if !getFromCache {
+	if true || !getFromCache {
 		dataMap := BuyerList(t.PartyA, t.Intermediary, t.PositionId)
 		if len(*dataMap) == 0 && t.Supplier == "" && t.Heterotophy == "" && t.Agency == "" {
 			return olr

+ 2 - 0
api/internal/types/types.go

@@ -104,6 +104,8 @@ type AllprojectReq struct {
 	Name         string `json:"name,optional"`
 	Type         string `json:"type,optional"`
 	Id           string `json:"id,optional"`
+	CheckCode    string `json:"checkCode,optional"`
+	ClickId      string `json:"clickId,optional"`
 }
 
 type NetWorkListReq struct {

+ 2 - 0
api/networkmanage.api

@@ -97,6 +97,8 @@ type (
 		Name         string `json:"name,optional"`
 		Type         string `json:"type,optional"`
 		Id           string `json:"id,optional"`
+		CheckCode    string `json:"checkCode,optional"`
+		ClickId      string `json:"clickId,optional"`
 	}
 	NetWorkListReq {
 		UserId             string `header:"userId"`