|
@@ -1244,11 +1244,29 @@ func (n *network) GetQyxyId(ids []string) map[string]string {
|
|
|
}
|
|
|
return m
|
|
|
}
|
|
|
-
|
|
|
func (n *network) BuyerProjectInfo(ids []string, businessType []string) map[string]*projectInfo {
|
|
|
vm := map[string]*projectInfo{}
|
|
|
+ m := map[string]bool{}
|
|
|
+ newIds := []string{}
|
|
|
+ for _, v := range ids {
|
|
|
+ if m[v] {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ m[v] = true
|
|
|
+ newIds = append(newIds, v)
|
|
|
+ if len(newIds) == C.BuyerBatch {
|
|
|
+ n.BuyerProjectInfoBatch(newIds, businessType, vm)
|
|
|
+ newIds = []string{}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(newIds) > 0 {
|
|
|
+ n.BuyerProjectInfoBatch(newIds, businessType, vm)
|
|
|
+ }
|
|
|
+ return vm
|
|
|
+}
|
|
|
+func (n *network) BuyerProjectInfoBatch(ids []string, businessType []string, vm map[string]*projectInfo) {
|
|
|
if len(ids) == 0 {
|
|
|
- return vm
|
|
|
+ return
|
|
|
}
|
|
|
wh, args := WhArgs(ids)
|
|
|
q := `select buyer_id,count(DISTINCT project_id) AS project_count,sum(project_money) AS project_amount,groupUniqArray(project_id) from information.transaction_info_all where buyer_id in (` + wh + `) and project_bidstatus>1`
|
|
@@ -1261,7 +1279,7 @@ func (n *network) BuyerProjectInfo(ids []string, businessType []string) map[stri
|
|
|
rows, err := ClickhouseConn.Query(context.Background(), q, args...)
|
|
|
if err != nil {
|
|
|
logx.Error(err)
|
|
|
- return nil
|
|
|
+ return
|
|
|
}
|
|
|
for rows.Next() {
|
|
|
var (
|
|
@@ -1275,17 +1293,23 @@ func (n *network) BuyerProjectInfo(ids []string, businessType []string) map[stri
|
|
|
continue
|
|
|
}
|
|
|
pf, _ := project_amount.Float64()
|
|
|
- vm[buyer_id] = &projectInfo{
|
|
|
- ProjectCount: int64(project_count),
|
|
|
- ExportId: project_id,
|
|
|
- ProjectAmount: pf,
|
|
|
+ if vm[buyer_id] == nil {
|
|
|
+ vm[buyer_id] = &projectInfo{
|
|
|
+ ProjectCount: int64(project_count),
|
|
|
+ ExportId: project_id,
|
|
|
+ ProjectAmount: pf,
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ vm[buyer_id].ProjectAmount += pf
|
|
|
+ vm[buyer_id].ProjectCount += int64(project_count)
|
|
|
+ vm[buyer_id].ExportId = append(vm[buyer_id].ExportId, project_id...)
|
|
|
}
|
|
|
}
|
|
|
rows.Close()
|
|
|
if err := rows.Err(); err != nil {
|
|
|
logx.Error(err)
|
|
|
}
|
|
|
- return vm
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
func (n *network) MakeProjectInfo(buyers []string, vbs map[string][]*idName, businessType []string) map[string]*projectInfo {
|