|
@@ -196,27 +196,68 @@ func GetWinnerData(scopeClass string, bid string) []AggStruct {
|
|
|
args := []interface{}{bid, bid}
|
|
|
wh, newArgs := common.WhArgs(strings.Split(scopeClass, ","))
|
|
|
args = append(args, newArgs...)
|
|
|
- rows, err1 := T.ClickhouseConn.Query(context.TODO(), `select winner as name,winner_id as id,sum(1) as sum,sum(project_money) as project_money,max(zbtime) as zbtime from information.transaction_info_all ARRAY JOIN winner_id,winner
|
|
|
- WHERE buyer_id IN (SELECT buyer_id from information.transaction_info_all WHERE has(winner_id,?) and buyer_id<>'') and winner_id<>? AND hasAny(topscopeclass,[`+wh+`])=0 group by winner,winner_id`, args...)
|
|
|
+ rows, err1 := T.ClickhouseConn.Query(context.TODO(), `select distinct winner as name,winner_id as id from information.transaction_info_all ARRAY JOIN winner_id,winner
|
|
|
+ WHERE buyer_id IN (SELECT buyer_id from information.transaction_info_all WHERE has(winner_id,?) and buyer_id<>'') and winner_id<>? AND hasAny(topscopeclass,[`+wh+`])=0`, args...)
|
|
|
if err1 != nil {
|
|
|
logx.Error(err1)
|
|
|
return ass
|
|
|
}
|
|
|
+ winnerIds := []string{}
|
|
|
for rows.Next() {
|
|
|
as := AggStruct{}
|
|
|
if err := rows.ScanStruct(&as); err != nil {
|
|
|
logx.Error(err)
|
|
|
continue
|
|
|
}
|
|
|
+ winnerIds = append(winnerIds, as.Id)
|
|
|
ass = append(ass, as)
|
|
|
}
|
|
|
rows.Close()
|
|
|
if err := rows.Err(); err != nil {
|
|
|
logx.Error(err)
|
|
|
}
|
|
|
+ hz := GetWinnerDataHz(bid, winnerIds)
|
|
|
+ for _, v := range ass {
|
|
|
+ if _, ok := hz[v.Id]; !ok {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ v.ProjectMoney = hz[v.Id].ProjectMoney
|
|
|
+ v.Sum = hz[v.Id].Sum
|
|
|
+ v.Zbtime = hz[v.Id].Zbtime
|
|
|
+ }
|
|
|
return ass
|
|
|
}
|
|
|
|
|
|
+//
|
|
|
+func GetWinnerDataHz(buyerId string, winnerIds []string) map[string]AggStruct {
|
|
|
+ res := map[string]AggStruct{}
|
|
|
+ if len(winnerIds) == 0 {
|
|
|
+ return res
|
|
|
+ }
|
|
|
+ args := []interface{}{buyerId}
|
|
|
+ wh, newArgs := common.WhArgs(winnerIds)
|
|
|
+ args = append(args, newArgs...)
|
|
|
+ rows, err1 := T.ClickhouseConn.Query(context.TODO(), `select winner_id as id,sum(1) as sum,sum(project_money) as project_money,max(zbtime) as zbtime from information.transaction_info_all ARRAY JOIN winner_id
|
|
|
+ WHERE winner_id in(`+wh+`) and buyer_id=? group by winner_id`, args...)
|
|
|
+ if err1 != nil {
|
|
|
+ logx.Error(err1)
|
|
|
+ return res
|
|
|
+ }
|
|
|
+ for rows.Next() {
|
|
|
+ as := AggStruct{}
|
|
|
+ if err := rows.ScanStruct(&as); err != nil {
|
|
|
+ logx.Error(err)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ res[as.Id] = as
|
|
|
+ }
|
|
|
+ rows.Close()
|
|
|
+ if err := rows.Err(); err != nil {
|
|
|
+ logx.Error(err)
|
|
|
+ }
|
|
|
+ return res
|
|
|
+}
|
|
|
+
|
|
|
//代理机构
|
|
|
func GetAgencyData(bid string) []AggStruct {
|
|
|
ass := []AggStruct{}
|