Browse Source

feat:xiugai

wangchuanjin 9 months ago
parent
commit
97cf3e97f1

+ 8 - 8
api/internal/service/network_test.go

@@ -123,10 +123,10 @@ func TestAllProject(t *testing.T) {
 func TestOwner(t *testing.T) {
 	InitConf()
 	ownerService := &OwnerService{
-		//PartyA:      "30604a74c36f47daa532503ac496914c",
-		//Heterotophy: "ffe7b3b526f048f9999b803a4241ce77",
-		//Agency:      "wcj_11111111c,112233445566,001dfe3364b8480c965f81ab64d76bb4,00172d07d1fd4d90bd95fe5a348a845d",
-		Agency:      "00172d07d1fd4d90bd95fe5a348a845d",
+		PartyA:      "30604a74c36f47daa532503ac496914c",
+		Heterotophy: "wcj_11111111d,112233445566,112233445566,000cfa77354c49969e4cfddd15dd5b26,000cfa77354c49969e4cfddd15dd5b26,ffe7b3b526f048f9999b803a4241ce77,3a0068dcbf4041aebfdd38f77f553d87,fb180e2267d74081a0e177692df92b42",
+		Agency:      "wcj_11111111c,112233445566,001dfe3364b8480c965f81ab64d76bb4,00172d07d1fd4d90bd95fe5a348a845d",
+		//Agency:      "00172d07d1fd4d90bd95fe5a348a845d",
 		PositionId:  935,
 		PageIndex:   1,
 		PageSize:    100,
@@ -193,16 +193,16 @@ func TestGetProjectList(t *testing.T) {
 	req := &types.ProjectListReq{
 		PositionId:   935,
 		EntId:        221,
-		PartyA:       "",
+		PartyA:       "30604a74c36f47daa532503ac496914c",
 		Supplier:     "",
-		Heterotophy:  "3a0068dcbf4041aebfdd38f77f553d87",
+		Heterotophy:  "",
 		Intermediary: "",
 		Agency:       "",
 		PageNum:      1,
 		PageSize:     10,
 		BusinessType: "全部",
-		Area:         "广东",
-		Amount:       "2,3,4,5",
+		// Area:         "广东",
+		// Amount:       "2,3,4,5",
 	}
 	resp := GetProjectList(req)
 	log.Println(resp.HasNextPage, resp.Count)

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

@@ -688,13 +688,14 @@ func (t *OwnerService) ProjectHandle(buyerArr []string, businessStr string, moni
 	allArgs = append(allArgs, allArgs...)
 	sqlStr := `select b.buyer as buyer,b.buyer_id as buyer_id,groupUniqArray(b.area) as areaStr,count(if(hasAny(b.topscopeclass,[`
 	sqlStr += whBs + `])=1 and b.project_bidstatus>1,1,null)) as ocount,SUM(if(hasAny(b.topscopeclass,[`
-	sqlStr += whBs + `])=1 and b.project_bidstatus>1,b.project_money,0)) as project_money,MAX(b.zbtime) as zbtime from transaction_info_all a inner join transaction_info_all b on ((`
-	ors := []string{}
+	sqlStr += whBs + `])=1 and b.project_bidstatus>1,b.project_money,0)) as project_money,MAX(b.zbtime) as zbtime from transaction_info_all a inner join transaction_info_all b on`
+	ors1 := []string{}
 	if len(buyerArr) > 0 {
 		wh, args := common.WhArgs(buyerArr)
-		ors = append(ors, `a.buyer_id in (`+wh+`)`)
+		ors1 = append(ors1, `(a.buyer_id in (`+wh+`) and a.project_id=b.project_id)`)
 		allArgs = append(allArgs, args...)
 	}
+	ors2 := []string{}
 	winner_ids := []string{}
 	if t.Supplier != "" {
 		winner_ids = append(winner_ids, strings.Split(t.Supplier, ",")...)
@@ -704,15 +705,18 @@ func (t *OwnerService) ProjectHandle(buyerArr []string, businessStr string, moni
 	}
 	if len(winner_ids) > 0 {
 		wh, args := common.WhArgs(winner_ids)
-		ors = append(ors, `hasAny(a.winner_id,[`+wh+`]`)
+		ors2 = append(ors2, `hasAny(a.winner_id,[`+wh+`])`)
 		allArgs = append(allArgs, args...)
 	}
 	if t.Agency != "" {
 		wh, args := common.WhArgs(strings.Split(t.Agency, ","))
-		ors = append(ors, `a.agency_id in (`+wh+`)`)
+		ors2 = append(ors2, `a.agency_id in (`+wh+`)`)
 		allArgs = append(allArgs, args...)
 	}
-	sqlStr += strings.Join(ors, " or ") + ") and a.buyer_id<>'' and a.buyer_id=b.buyer_id)"
+	if len(ors2) > 0 {
+		ors1 = append(ors1, "(("+strings.Join(ors2, " or ")+") and a.buyer_id<>'' and a.buyer_id=b.buyer_id)")
+	}
+	sqlStr += " (" + strings.Join(ors1, " or ") + ")"
 	wheres := []string{}
 	if len(monitorBuyers) > 0 {
 		wh, args := common.WhArgs(monitorBuyers)

+ 14 - 6
api/internal/service/plistService.go

@@ -161,18 +161,19 @@ func getQuerySql(req *types.ProjectListReq, plist []string, businessStr string)
 	countSql = "select count(1) from information.transaction_info_all a "
 	findSql = "select b.project_id as project_id,b.project_name as project_name,b.business_type as business_type,b.buyer as buyer,b.buyer_id as buyer_id,b.area as area,b.city as city,b.district as district,b.zbtime as zbtime,b.endtime as endtime,b.project_money as project_money,b.info_id as info_id,b.information_id as information_id,b.info_ids as info_ids from information.transaction_info_all a "
 	allArgs = []interface{}{}
-	ors := []string{}
+	ors1 := []string{}
 	// 左侧选中的业主id
 	if req.PartyA != "" {
 		wh, args := common.WhArgs(strings.Split(req.PartyA, ","))
-		ors = append(ors, "a.buyer_id in ("+wh+")")
+		ors1 = append(ors1, "a.buyer_id in ("+wh+")")
 		allArgs = append(allArgs, args...)
 	}
 	if len(plist) > 0 {
 		wh, args := common.WhArgs(plist)
-		ors = append(ors, "a.project_id in ("+wh+")")
+		ors1 = append(ors1, "a.project_id in ("+wh+")")
 		allArgs = append(allArgs, args...)
 	}
+	ors2 := []string{}
 	winner_ids := []string{}
 	if req.Supplier != "" {
 		winner_ids = append(winner_ids, strings.Split(req.Supplier, ",")...)
@@ -182,14 +183,21 @@ func getQuerySql(req *types.ProjectListReq, plist []string, businessStr string)
 	}
 	if len(winner_ids) > 0 {
 		wh, args := common.WhArgs(winner_ids)
-		ors = append(ors, "hasAny(a.winner_id,["+wh+"])")
+		ors2 = append(ors2, "hasAny(a.winner_id,["+wh+"])")
 		allArgs = append(allArgs, args...)
 	}
 	if req.Agency != "" {
 		wh, args := common.WhArgs(strings.Split(req.Agency, ","))
-		ors = append(ors, "a.agency_id in ("+wh+")")
+		ors2 = append(ors2, "a.agency_id in ("+wh+")")
 		allArgs = append(allArgs, args...)
 	}
+	ors := []string{}
+	if len(ors1) > 0 {
+		ors = append(ors, "("+strings.Join(ors1, " or ")+") and a.project_id=b.project_id")
+	}
+	if len(ors2) > 0 {
+		ors = append(ors, "("+strings.Join(ors2, " or ")+") and a.buyer_id<>'' and a.buyer_id=b.buyer_id")
+	}
 	querys := []string{}
 	//业务类型
 	if businessStr != "" {
@@ -230,7 +238,7 @@ func getQuerySql(req *types.ProjectListReq, plist []string, businessStr string)
 		}
 	}
 	//过滤掉已中标的招标项目数据
-	sqlAppend := "inner join information.transaction_info_all b on((" + strings.Join(ors, " or ") + ") and a.buyer_id<>'' and a.buyer_id=b.buyer_id) where b.project_bidstatus>1 and " + strings.Join(querys, " and ")
+	sqlAppend := "inner join information.transaction_info_all b on(" + strings.Join(ors, " or ") + ") where b.project_bidstatus>1 and " + strings.Join(querys, " and ")
 	countSql += sqlAppend
 	findSql += fmt.Sprintf(sqlAppend+" order by b.zbtime desc limit %d,%d", (req.PageNum-1)*req.PageSize, req.PageSize)
 	return