wangchuanjin 9 сар өмнө
parent
commit
ca02087978

+ 3 - 3
api/internal/service/network.go

@@ -993,7 +993,7 @@ func (n *network) Introduce_Supplier(values []string, businessType []string) map
 	repeat := map[string]bool{}
 	whRepeat := map[string]map[string]bool{}
 	buyers := []string{}
-	q := `select winner_id,buyer_id,buyer from information.transaction_info_all where hasAny(winner_id,[` + wh + `])`
+	q := `select winner_id,buyer_id,buyer from information.transaction_info_all where hasAny(winner_id,[` + wh + `]) and project_bidstatus>1`
 	rows, err := ClickhouseConn.Query(context.Background(), q, args...)
 	if err != nil {
 		logx.Error(err)
@@ -1043,7 +1043,7 @@ func (n *network) Introduce_Agency(values []string, businessType []string) map[s
 		return map[string]*projectInfo{}
 	}
 	wh, args := NetworkCom.WhArgs(values)
-	q := `select DISTINCT agency_id,buyer_id,buyer from information.transaction_info_all where agency_id in (` + wh + `)`
+	q := `select DISTINCT agency_id,buyer_id,buyer from information.transaction_info_all where agency_id in (` + wh + `) and project_bidstatus>1`
 	rows, err := ClickhouseConn.Query(context.Background(), q, args...)
 	if err != nil {
 		logx.Error(err)
@@ -1088,7 +1088,7 @@ func (n *network) Introduce_Middleman(values []string, businessType []string) ma
 		return result
 	}
 	wh, args := NetworkCom.WhArgs(values)
-	q := `select DISTINCT project_id,project_money from information.transaction_info_all where project_id in (` + wh + `)`
+	q := `select DISTINCT project_id,project_money from information.transaction_info_all where project_id in (` + wh + `) and project_bidstatus>1`
 	if len(businessType) > 0 {
 		newWh, newArgs := NetworkCom.WhArgs(businessType)
 		q += ` and hasAny(topscopeclass,[` + newWh + `])`

+ 7 - 0
api/internal/service/network_test.go

@@ -179,3 +179,10 @@ func TestDeleteCache(t *testing.T) {
 	InitConf()
 	Network.DeleteCache(935)
 }
+
+func TestIntroduceSupplier(t *testing.T) {
+	InitConf()
+	for k, v := range Network.Introduce_Supplier([]string{"fb180e2267d74081a0e177692df92b42"}, []string{"建筑工程", "机械设备", "信息技术"}) {
+		log.Println(k, fmt.Sprintf("%+v", v))
+	}
+}

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

@@ -698,26 +698,22 @@ func BuyerList(partyA, supplier, heterotophy, intermediary, agency string, posit
 func ProjectHandle(buyerArr []string, area, businessStr string, dataMap *map[string]map[string]interface{}, startIndex, PageSize int64, sourceType string) (*map[string]map[string]interface{}, int64) {
 	projectMap := &map[string]map[string]interface{}{}
 	count := int64(0)
-	sqlStr := "select buyer,buyer_id,groupUniqArray(area) as area,count(1) as ocount,SUM(project_money) as project_money ,MAX(zbtime) as zbtime from transaction_info_all where"
-	countSql := "select count(1) as count from (%s) b "
-	if len(buyerArr) > 0 {
-		buyer, buyerArgs := ConditionHandle(buyerArr)
-		sqlStr += fmt.Sprintf(fmt.Sprintf(" buyer_id in (%s)", buyer), buyerArgs...)
-	}
+	tscSql := `'` + strings.ReplaceAll(businessStr, ",", `','`) + `'`
+	sqlStr := `select buyer,buyer_id,groupUniqArray(area) as area,count(if(hasAny(topscopeclass,[`
+	sqlStr += tscSql + `])=1 and project_bidstatus>1,1,null)) as ocount,SUM(if(hasAny(topscopeclass,[`
+	sqlStr += tscSql + `])=1 and project_bidstatus>1,project_money,0)) as project_money ,MAX(zbtime) as zbtime from transaction_info_all where`
+	buyer, buyerArgs := ConditionHandle(buyerArr)
+	sqlStr += fmt.Sprintf(fmt.Sprintf(" buyer_id in (%s)", buyer), buyerArgs...)
 	if len(area) > 0 && area != "" {
 		areaStr, areaArgs := ConditionHandle(strings.Split(area, ","))
 		sqlStr += fmt.Sprintf(fmt.Sprintf(" area in (%s)", areaStr), areaArgs...)
 	}
-	if len(businessStr) > 0 {
-		business, businessArgs := ConditionHandle(strings.Split(businessStr, ","))
-		sqlStr += fmt.Sprintf(fmt.Sprintf(" and hasAny(topscopeclass,[%s])>0", business), businessArgs...)
-	}
 	sqlStr += " and project_bidstatus>1 GROUP by buyer,buyer_id "
 	if sourceType == "1" {
 		sqlStr += " HAVING ocount>2 "
 	}
 	sqlStr += " order by zbtime desc"
-	countSql = fmt.Sprintf(countSql, sqlStr)
+	countSql := fmt.Sprintf("select count(1) as count from (%s) b ", sqlStr)
 	sqlStr += " limit ?,?"
 	//总数查询
 	rows, err1 := ClickhouseConn.Query(context.TODO(), sqlStr, startIndex, PageSize)