Jianghan 1 ano atrás
pai
commit
0efd36895e
1 arquivos alterados com 11 adições e 7 exclusões
  1. 11 7
      api/internal/service/CoopHistoryService.go

+ 11 - 7
api/internal/service/CoopHistoryService.go

@@ -34,6 +34,7 @@ type ResultData struct {
 	SupEnt       string  `json:"SupEnt"`       // 上级
 	NextEnt      string  `json:"NextEnt"`      // 下级
 	Relationship string  `json:"Relationship"` // 关系
+	BuyerId      string  `json:"BuyerId"`
 }
 
 type ProjectTmp struct {
@@ -44,13 +45,12 @@ type ProjectTmp struct {
 	PropertyForm []string `ch:"property_form"`
 }
 
-func GetPrList(req *types.CoopHistoryReq) (result []*ResultData, size_1, size_2, size_3, size_4 int64, bid string) {
+func GetPrList(req *types.CoopHistoryReq) (result []*ResultData, size_1, size_2, size_3, size_4 int64) {
 	pTmp := ProjectTmp{}
 	err := T.ClickhouseConn.QueryRow(context.TODO(), sql_2_0, req.Pid).ScanStruct(&pTmp)
 	if err != nil {
-		return nil, 0, 0, 0, 0, ""
+		return nil, 0, 0, 0, 0
 	}
-	bid = pTmp.BuyerId
 	propertyForm := ""
 	m1 := T.CrmMysql.FindOne("config_tenant", map[string]interface{}{"account_id": req.EntAccountId}, "probusfor", "")
 	if m1 != nil && len(*m1) > 0 {
@@ -63,7 +63,7 @@ func GetPrList(req *types.CoopHistoryReq) (result []*ResultData, size_1, size_2,
 		if (req.ChannelType == "0" || req.ChannelType == "1") && r1 != nil && len(r1) > 0 {
 			size_1 = int64(len(r1))
 			for _, m := range r1 {
-				near, zbtime := LastTimeCoop(bid, common.ObjToString(m["name"]), "adiffb")
+				near, zbtime := LastTimeCoop(pTmp.BuyerId, common.ObjToString(m["name"]), "adiffb")
 				tmp := ResultData{
 					SourceType:  "adiffb",
 					EntName:     common.ObjToString(m["name"]),
@@ -71,6 +71,7 @@ func GetPrList(req *types.CoopHistoryReq) (result []*ResultData, size_1, size_2,
 					TotalAmount: common.Float64All(m["coop_amount"]),
 					RecentTime:  zbtime,
 					NearlyYears: near,
+					BuyerId:     pTmp.BuyerId,
 				}
 				result = append(result, &tmp)
 			}
@@ -78,7 +79,7 @@ func GetPrList(req *types.CoopHistoryReq) (result []*ResultData, size_1, size_2,
 		if req.ChannelType == "0" || req.ChannelType == "3" && r2 != nil && len(r2) > 0 {
 			size_3 = int64(len(r2))
 			for _, m := range r2 {
-				near, zbtime := LastTimeCoop(bid, common.ObjToString(m["name"]), "agency")
+				near, zbtime := LastTimeCoop(pTmp.BuyerId, common.ObjToString(m["name"]), "agency")
 				tmp := ResultData{
 					SourceType:  "agency",
 					EntName:     common.ObjToString(m["name"]),
@@ -86,6 +87,7 @@ func GetPrList(req *types.CoopHistoryReq) (result []*ResultData, size_1, size_2,
 					TotalAmount: common.Float64All(m["coop_amount"]),
 					RecentTime:  zbtime,
 					NearlyYears: near,
+					BuyerId:     pTmp.BuyerId,
 				}
 				result = append(result, &tmp)
 			}
@@ -95,7 +97,7 @@ func GetPrList(req *types.CoopHistoryReq) (result []*ResultData, size_1, size_2,
 		if req.ChannelType == "0" || req.ChannelType == "4" {
 			// 中间人可介绍业主
 			var r3 []map[string]interface{}
-			r3 = FindMiddleman([]string{fmt.Sprintf("'%s'", bid)}, req.PositionId, r3)
+			r3 = FindMiddleman([]string{fmt.Sprintf("'%s'", pTmp.BuyerId)}, req.PositionId, r3)
 			if r3 != nil && len(r3) > 0 {
 				for _, m := range r3 {
 					size_4 = int64(len(r3))
@@ -104,6 +106,7 @@ func GetPrList(req *types.CoopHistoryReq) (result []*ResultData, size_1, size_2,
 						EntName:      common.ObjToString(m["b_name"]),
 						EntPerson:    common.ObjToString(m["personName"]),
 						Relationship: "业主的关系人",
+						BuyerId:      pTmp.BuyerId,
 					}
 					result = append(result, &tmp)
 				}
@@ -112,7 +115,7 @@ func GetPrList(req *types.CoopHistoryReq) (result []*ResultData, size_1, size_2,
 		if req.ChannelType == "0" || req.ChannelType == "2" {
 			// 关联单位
 			var r4 []map[string]interface{}
-			r4 = Findfirstparty([]string{fmt.Sprintf("'%s'", bid)}, r4)
+			r4 = Findfirstparty([]string{fmt.Sprintf("'%s'", pTmp.BuyerId)}, r4)
 			if r4 != nil && len(r4) > 0 {
 				size_2 = int64(len(r4))
 				for _, m := range r4 {
@@ -121,6 +124,7 @@ func GetPrList(req *types.CoopHistoryReq) (result []*ResultData, size_1, size_2,
 						EntName:      common.ObjToString(m["b_name"]),
 						EntPerson:    common.ObjToString(m["personName"]),
 						Relationship: common.ObjToString(m["relationship"]),
+						BuyerId:      pTmp.BuyerId,
 					}
 					result = append(result, &tmp)
 				}