Jianghan 1 jaar geleden
bovenliggende
commit
677c1a74b4

+ 7 - 6
api/internal/logic/coophistorylistlogic.go

@@ -2,11 +2,9 @@ package logic
 
 import (
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/service"
-	"context"
-	"log"
-
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
+	"context"
 
 	"github.com/zeromicro/go-zero/core/logx"
 )
@@ -27,14 +25,17 @@ func NewCoopHistoryListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *C
 
 func (l *CoopHistoryListLogic) CoopHistoryList(req *types.CoopHistoryReq) (resp *types.Reply, err error) {
 	resp = &types.Reply{}
-	result := service.GetPrList(req)
-	log.Println(result)
+	result, size1, size2, size3, size4 := service.GetPrList(req)
 	if result == nil {
 		resp.Error_code = -1
 		resp.Error_msg = "查询异常"
 	} else {
 		resp.Data = map[string]interface{}{
-			"list": result,
+			"list":  result,
+			"size1": size1,
+			"size2": size2,
+			"size3": size3,
+			"size4": size4,
 		}
 	}
 

+ 10 - 6
api/internal/service/CoopHistoryService.go

@@ -44,11 +44,11 @@ type ProjectTmp struct {
 	PropertyForm []string `ch:"property_form"`
 }
 
-func GetPrList(req *types.CoopHistoryReq) (result []*ResultData) {
+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
+		return nil, 0, 0, 0, 0
 	}
 	propertyForm := ""
 	m1 := T.CrmMysql.FindOne("config_tenant", map[string]interface{}{"account_id": req.EntAccountId}, "probusfor", "")
@@ -59,7 +59,8 @@ func GetPrList(req *types.CoopHistoryReq) (result []*ResultData) {
 	// 1、同甲异业数据/ 3、招标代理机构渠道
 	if req.ChannelType == "0" || req.ChannelType == "1" || req.ChannelType == "3" {
 		r1, r2 := GetData(propertyForm, pTmp.BuyerId)
-		if req.ChannelType != "3" && r1 != nil && len(r1) > 0 {
+		if (req.ChannelType == "0" || req.ChannelType == "1") && r1 != nil && len(r1) > 0 {
+			size_1 = int64(len(r1))
 			for _, m := range r1 {
 				near, zbtime := LastTimeCoop(pTmp.BuyerId, common.ObjToString(m["name"]), "adiffb")
 				tmp := ResultData{
@@ -73,7 +74,8 @@ func GetPrList(req *types.CoopHistoryReq) (result []*ResultData) {
 				result = append(result, &tmp)
 			}
 		}
-		if req.ChannelType != "2" && r2 != nil && len(r2) > 0 {
+		if req.ChannelType == "0" || req.ChannelType == "3" && r2 != nil && len(r2) > 0 {
+			size_3 = int64(len(r2))
 			for _, m := range r2 {
 				near, zbtime := LastTimeCoop(pTmp.BuyerId, common.ObjToString(m["name"]), "agency")
 				tmp := ResultData{
@@ -92,9 +94,10 @@ func GetPrList(req *types.CoopHistoryReq) (result []*ResultData) {
 		if req.ChannelType == "0" || req.ChannelType == "4" {
 			// 中间人可介绍业主
 			var r3 []map[string]interface{}
-			r3 = FindMiddleman([]string{pTmp.BuyerId}, 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))
 					tmp := ResultData{
 						SourceType:   "middleman",
 						EntName:      common.ObjToString(m["b_name"]),
@@ -108,8 +111,9 @@ func GetPrList(req *types.CoopHistoryReq) (result []*ResultData) {
 		if req.ChannelType == "0" || req.ChannelType == "2" {
 			// 关联单位
 			var r4 []map[string]interface{}
-			r4 = Findfirstparty([]string{pTmp.BuyerId}, 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 {
 					tmp := ResultData{
 						SourceType:   "sup_sub",

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

@@ -2,7 +2,6 @@ package service
 
 import (
 	"app.yhyue.com/moapp/jybase/common"
-	P "app.yhyue.com/moapp/jybase/mapping"
 	"app.yhyue.com/moapp/jypkg/ent/util"
 	T "bp.jydev.jianyu360.cn/CRM/application/api/common"
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
@@ -147,38 +146,24 @@ func getQuerySql(req *types.ProjectListReq, isPage bool, buyerArr []string) (cou
 	var regionArr = []string{}
 	if req.Area != "" || req.City != "" || req.District != "" {
 		//城市
-		city := []string{}
-		for _, v := range strings.Split(req.City, ",") {
-			if P.BidCodeMapping.City[v] != "" {
-				city = append(city, fmt.Sprint(P.BidCodeMapping.City[v]))
-			}
-		}
-		if len(city) > 0 {
-			regionArr = append(regionArr, fmt.Sprintf(" a.city in (%s) ", strings.Join(city, ",")))
+		if req.City != "" {
+			regionArr = append(regionArr, fmt.Sprintf(" a.city in ('%s') ", req.City))
 		}
 		//区域
-		area := []string{}
-		for _, v := range strings.Split(req.Area, ",") {
-			if P.BidCodeMapping.Area[v] != "" {
-				area = append(area, fmt.Sprint(P.BidCodeMapping.Area[v]))
-			}
-		}
-		if len(area) > 0 {
-			regionArr = append(regionArr, fmt.Sprintf(" a.area in (%s) ", strings.Join(area, ",")))
+		if req.Area != "" {
+			regionArr = append(regionArr, fmt.Sprintf(" a.area in ('%s') ", req.Area))
 		}
 		//区域
 		district := []string{}
 		if req.District != "" {
 			for _, v := range strings.Split(req.District, ",") {
-				cityName := strings.Split(v, "_")[0]
+				//cityName := strings.Split(v, "_")[0]
 				districtName := strings.Split(v, "_")[1]
-				if P.BidCodeMapping.District[cityName][districtName] != "" {
-					district = append(district, fmt.Sprint(P.BidCodeMapping.District[cityName][districtName]))
-				}
+				district = append(district, districtName)
 			}
 		}
 		if len(district) > 0 {
-			regionArr = append(regionArr, fmt.Sprintf(" a.district in (%s) ", strings.Join(district, ",")))
+			regionArr = append(regionArr, fmt.Sprintf(" a.district in ('%s') ", strings.Join(district, ",")))
 		}
 		if len(regionArr) > 0 {
 			querys = append(querys, fmt.Sprintf("(%s)", strings.Join(regionArr, "or")))