|
@@ -35,9 +35,10 @@ type networkTreeChild struct {
|
|
Type int `json:"type"`
|
|
Type int `json:"type"`
|
|
}
|
|
}
|
|
type projectInfo struct {
|
|
type projectInfo struct {
|
|
- BuyerCount int
|
|
|
|
- ProjectCount int
|
|
|
|
|
|
+ BuyerCount int64
|
|
|
|
+ ProjectCount int64
|
|
ProjectAmount float64
|
|
ProjectAmount float64
|
|
|
|
+ MonitorCount int64
|
|
}
|
|
}
|
|
type firstpartyNetwork struct {
|
|
type firstpartyNetwork struct {
|
|
CompanyId string
|
|
CompanyId string
|
|
@@ -323,7 +324,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
|
|
|
|
|
|
//人脉库-列表
|
|
//人脉库-列表
|
|
func (n *network) List(in *types.NetWorkListReq) *types.Reply {
|
|
func (n *network) List(in *types.NetWorkListReq) *types.Reply {
|
|
- q := `select a.company_id,a.company_name,a.itype,a.contact_person as person,a.contact_phone as phone,count(if(b.itype=1,1,null)) as buyer_count,count(if(b.itype=2,1,null)) as project_count,GROUP_CONCAT(b.relate_id) as relate_id,a.create_time from crm.connection a
|
|
|
|
|
|
+ q := `select a.company_id,a.company_name,a.itype,a.contact_person as person,a.contact_phone as phone,count(if(b.itype=1,1,null)) as buyer_count,count(if(b.itype=2,1,null)) as project_count,GROUP_CONCAT(IF(b.itype=1,relate_id,NULL)) AS relate_buyer_id,GROUP_CONCAT(IF(b.itype=2,relate_id,NULL)) AS relate_project_id,a.create_time from crm.connection a
|
|
left join crm.connection_introduce b on (a.id=b.connection_id) where a.position_id=?`
|
|
left join crm.connection_introduce b on (a.id=b.connection_id) where a.position_id=?`
|
|
args := []interface{}{in.PositionId}
|
|
args := []interface{}{in.PositionId}
|
|
if in.Type != "" {
|
|
if in.Type != "" {
|
|
@@ -344,7 +345,7 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
|
|
}
|
|
}
|
|
q += ` GROUP BY a.id order by a.create_time desc`
|
|
q += ` GROUP BY a.id order by a.create_time desc`
|
|
listTemp := CrmMysql.SelectBySql(q, args...)
|
|
listTemp := CrmMysql.SelectBySql(q, args...)
|
|
- firstparty_array, supplier_array, adiffb_array, agency_array, middleman_array := []string{}, []string{}, []string{}, []string{}, []string{}
|
|
|
|
|
|
+ firstparty_array, supplier_array, adiffb_array, agency_array, middleman_project_array := []string{}, []string{}, []string{}, []string{}, []string{}
|
|
for _, v := range *listTemp {
|
|
for _, v := range *listTemp {
|
|
switch Int64All(v["itype"]) {
|
|
switch Int64All(v["itype"]) {
|
|
case 1:
|
|
case 1:
|
|
@@ -354,8 +355,8 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
|
|
case 3:
|
|
case 3:
|
|
adiffb_array = append(adiffb_array, ObjToString(v["company_id"]))
|
|
adiffb_array = append(adiffb_array, ObjToString(v["company_id"]))
|
|
case 4:
|
|
case 4:
|
|
- if relate_id := ObjToString(v["relate_id"]); relate_id != "" {
|
|
|
|
- middleman_array = append(middleman_array, strings.Split(relate_id, ",")...)
|
|
|
|
|
|
+ if relate_project_id := ObjToString(v["relate_project_id"]); relate_project_id != "" {
|
|
|
|
+ middleman_project_array = append(middleman_project_array, strings.Split(relate_project_id, ",")...)
|
|
}
|
|
}
|
|
case 5:
|
|
case 5:
|
|
agency_array = append(agency_array, ObjToString(v["company_id"]))
|
|
agency_array = append(agency_array, ObjToString(v["company_id"]))
|
|
@@ -364,82 +365,122 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
|
|
//
|
|
//
|
|
firstparty_count, supplier_count, adiffb_count, middleman_count, agency_count := 0, 0, 0, 0, 0
|
|
firstparty_count, supplier_count, adiffb_count, middleman_count, agency_count := 0, 0, 0, 0, 0
|
|
list := []*map[string]interface{}{}
|
|
list := []*map[string]interface{}{}
|
|
- firstparty_project := n.Introduce_Firstparty(n.FirstpartyNetwork("", firstparty_array))
|
|
|
|
- supplier_project := n.Introduce_Supplier(supplier_array)
|
|
|
|
- adiffb_project := n.Introduce_Supplier(adiffb_array)
|
|
|
|
- agency_project := n.Introduce_Agency(agency_array)
|
|
|
|
- middleman_project := n.Introduce_Middleman(middleman_array)
|
|
|
|
- for _, v := range *listTemp {
|
|
|
|
- itype := ""
|
|
|
|
- buyer_count, project_count, expect_amount := 0, 0, float64(0)
|
|
|
|
- company_id := ObjToString(v["company_id"])
|
|
|
|
- switch Int64All(v["itype"]) {
|
|
|
|
- case 1:
|
|
|
|
- itype = "甲方"
|
|
|
|
- firstparty_count++
|
|
|
|
- if firstparty_project[company_id] != nil {
|
|
|
|
- buyer_count = firstparty_project[company_id].BuyerCount
|
|
|
|
- project_count = firstparty_project[company_id].ProjectCount
|
|
|
|
- expect_amount = firstparty_project[company_id].ProjectAmount
|
|
|
|
- }
|
|
|
|
- case 2:
|
|
|
|
- itype = "供应商"
|
|
|
|
- supplier_count++
|
|
|
|
- if supplier_project[company_id] != nil {
|
|
|
|
- buyer_count = supplier_project[company_id].BuyerCount
|
|
|
|
- project_count = supplier_project[company_id].ProjectCount
|
|
|
|
- expect_amount = supplier_project[company_id].ProjectAmount
|
|
|
|
- }
|
|
|
|
- case 3:
|
|
|
|
- itype = "同甲异业渠道"
|
|
|
|
- adiffb_count++
|
|
|
|
- if adiffb_project[company_id] != nil {
|
|
|
|
- buyer_count = adiffb_project[company_id].BuyerCount
|
|
|
|
- project_count = adiffb_project[company_id].ProjectCount
|
|
|
|
- expect_amount = adiffb_project[company_id].ProjectAmount
|
|
|
|
- }
|
|
|
|
- case 4:
|
|
|
|
- itype = "中间人"
|
|
|
|
- middleman_count++
|
|
|
|
- buyer_count = IntAll(v["buyer_count"])
|
|
|
|
- project_count = IntAll(v["project_count"])
|
|
|
|
- if relate_id := ObjToString(v["relate_id"]); relate_id != "" {
|
|
|
|
- for _, v := range strings.Split(relate_id, ",") {
|
|
|
|
- if middleman_project[v] != nil {
|
|
|
|
- expect_amount += middleman_project[v].ProjectAmount
|
|
|
|
|
|
+ isGoNextSetp := true
|
|
|
|
+ probusfors := []string{}
|
|
|
|
+ if in.Project_matchme == 1 {
|
|
|
|
+ probusfors = NetworkCom.GetMyProbusfor(in.EntAccountId)
|
|
|
|
+ if len(probusfors) == 0 {
|
|
|
|
+ isGoNextSetp = false
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if isGoNextSetp {
|
|
|
|
+ entMonitor := n.EntMonitor(in.PositionId)
|
|
|
|
+ firstparty_project := n.Introduce_Firstparty(n.FirstpartyNetwork("", firstparty_array), entMonitor, in.Project_matchme, probusfors)
|
|
|
|
+ supplier_project := n.Introduce_Supplier(supplier_array, entMonitor, in.Project_matchme, probusfors)
|
|
|
|
+ adiffb_project := n.Introduce_Supplier(adiffb_array, entMonitor, in.Project_matchme, probusfors)
|
|
|
|
+ agency_project := n.Introduce_Agency(agency_array, entMonitor, in.Project_matchme, probusfors)
|
|
|
|
+ middleman_project := n.Introduce_Middleman(middleman_project_array, entMonitor, in.Project_matchme, probusfors)
|
|
|
|
+ for _, v := range *listTemp {
|
|
|
|
+ itype := ""
|
|
|
|
+ buyer_count, project_count, expect_amount, monitor_count := int64(0), int64(0), float64(0), int64(0)
|
|
|
|
+ company_id := ObjToString(v["company_id"])
|
|
|
|
+ switch Int64All(v["itype"]) {
|
|
|
|
+ case 1:
|
|
|
|
+ itype = "甲方"
|
|
|
|
+ firstparty_count++
|
|
|
|
+ if firstparty_project[company_id] != nil {
|
|
|
|
+ buyer_count = firstparty_project[company_id].BuyerCount
|
|
|
|
+ project_count = firstparty_project[company_id].ProjectCount
|
|
|
|
+ expect_amount = firstparty_project[company_id].ProjectAmount
|
|
|
|
+ monitor_count = firstparty_project[company_id].MonitorCount
|
|
|
|
+ }
|
|
|
|
+ case 2:
|
|
|
|
+ itype = "供应商"
|
|
|
|
+ supplier_count++
|
|
|
|
+ if supplier_project[company_id] != nil {
|
|
|
|
+ buyer_count = supplier_project[company_id].BuyerCount
|
|
|
|
+ project_count = supplier_project[company_id].ProjectCount
|
|
|
|
+ expect_amount = supplier_project[company_id].ProjectAmount
|
|
|
|
+ monitor_count = supplier_project[company_id].MonitorCount
|
|
|
|
+ }
|
|
|
|
+ case 3:
|
|
|
|
+ itype = "同甲异业渠道"
|
|
|
|
+ adiffb_count++
|
|
|
|
+ if adiffb_project[company_id] != nil {
|
|
|
|
+ buyer_count = adiffb_project[company_id].BuyerCount
|
|
|
|
+ project_count = adiffb_project[company_id].ProjectCount
|
|
|
|
+ expect_amount = adiffb_project[company_id].ProjectAmount
|
|
|
|
+ monitor_count = adiffb_project[company_id].MonitorCount
|
|
|
|
+ }
|
|
|
|
+ case 4:
|
|
|
|
+ itype = "中间人"
|
|
|
|
+ middleman_count++
|
|
|
|
+ buyer_count = Int64All(v["buyer_count"])
|
|
|
|
+ project_count = Int64All(v["project_count"])
|
|
|
|
+ if relate_buyer_id := ObjToString(v["relate_buyer_id"]); relate_buyer_id != "" {
|
|
|
|
+ for _, v := range strings.Split(relate_buyer_id, ",") {
|
|
|
|
+ if v == "" {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ if entMonitor[v] {
|
|
|
|
+ monitor_count++
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if relate_project_id := ObjToString(v["relate_project_id"]); relate_project_id != "" {
|
|
|
|
+ for _, v := range strings.Split(relate_project_id, ",") {
|
|
|
|
+ if middleman_project[v] != nil {
|
|
|
|
+ expect_amount += middleman_project[v].ProjectAmount
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if middleman_project[company_id] != nil {
|
|
|
|
+ expect_amount = middleman_project[company_id].ProjectAmount
|
|
|
|
+ }
|
|
|
|
+ case 5:
|
|
|
|
+ itype = "招标代理机构"
|
|
|
|
+ agency_count++
|
|
|
|
+ if agency_project[company_id] != nil {
|
|
|
|
+ buyer_count = agency_project[company_id].BuyerCount
|
|
|
|
+ project_count = agency_project[company_id].ProjectCount
|
|
|
|
+ expect_amount = agency_project[company_id].ProjectAmount
|
|
|
|
+ monitor_count = agency_project[company_id].MonitorCount
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- if middleman_project[company_id] != nil {
|
|
|
|
- expect_amount = middleman_project[company_id].ProjectAmount
|
|
|
|
- }
|
|
|
|
- case 5:
|
|
|
|
- itype = "招标代理机构"
|
|
|
|
- agency_count++
|
|
|
|
- if agency_project[company_id] != nil {
|
|
|
|
- buyer_count = agency_project[company_id].BuyerCount
|
|
|
|
- project_count = agency_project[company_id].ProjectCount
|
|
|
|
- expect_amount = agency_project[company_id].ProjectAmount
|
|
|
|
|
|
+ if buyer_count < in.Buyercount_start {
|
|
|
|
+ continue
|
|
|
|
+ } else if buyer_count > in.Buyercount_end {
|
|
|
|
+ continue
|
|
|
|
+ } else if in.Monitor == 1 && monitor_count <= 0 {
|
|
|
|
+ continue
|
|
|
|
+ } else if in.Monitor == -1 && monitor_count > 0 {
|
|
|
|
+ continue
|
|
|
|
+ } else if monitor_count < in.Monitorcount_start {
|
|
|
|
+ continue
|
|
|
|
+ } else if monitor_count > in.Monitorcount_end {
|
|
|
|
+ continue
|
|
|
|
+ } else if in.Project_matchme == 1 && project_count == 0 {
|
|
|
|
+ continue
|
|
}
|
|
}
|
|
|
|
+ list = append(list, &map[string]interface{}{
|
|
|
|
+ "company_id": company_id,
|
|
|
|
+ "company_name": v["company_name"],
|
|
|
|
+ "type": itype,
|
|
|
|
+ "person": v["person"],
|
|
|
|
+ "phone": v["phone"],
|
|
|
|
+ "buyer_count": buyer_count,
|
|
|
|
+ "monitor_count": 0,
|
|
|
|
+ "expect_amount": RetainDecimal(expect_amount/10000, 2),
|
|
|
|
+ "project_count": project_count,
|
|
|
|
+ "create_time": v["create_time"],
|
|
|
|
+ })
|
|
}
|
|
}
|
|
- list = append(list, &map[string]interface{}{
|
|
|
|
- "company_id": company_id,
|
|
|
|
- "company_name": v["company_name"],
|
|
|
|
- "type": itype,
|
|
|
|
- "person": v["person"],
|
|
|
|
- "phone": v["phone"],
|
|
|
|
- "buyer_count": buyer_count,
|
|
|
|
- "monitor_count": 0,
|
|
|
|
- "expect_amount": RetainDecimal(expect_amount/10000, 2),
|
|
|
|
- "project_count": project_count,
|
|
|
|
- "create_time": v["create_time"],
|
|
|
|
- })
|
|
|
|
}
|
|
}
|
|
csList := &ComSortList{
|
|
csList := &ComSortList{
|
|
SortKeys: []*ComSortKey{
|
|
SortKeys: []*ComSortKey{
|
|
&ComSortKey{
|
|
&ComSortKey{
|
|
Keys: []string{"expect_amount"},
|
|
Keys: []string{"expect_amount"},
|
|
- Order: -1,
|
|
|
|
|
|
+ Order: 1,
|
|
Type: "float",
|
|
Type: "float",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
@@ -519,7 +560,7 @@ func (n *network) FirstpartyNetwork(name string, values []string) map[string][]*
|
|
}
|
|
}
|
|
|
|
|
|
//
|
|
//
|
|
-func (n *network) Introduce_Firstparty(fpn map[string][]*firstpartyNetwork) map[string]*projectInfo {
|
|
|
|
|
|
+func (n *network) Introduce_Firstparty(fpn map[string][]*firstpartyNetwork, entMonitor map[string]bool, matchme int64, probusfors []string) map[string]*projectInfo {
|
|
values := []string{}
|
|
values := []string{}
|
|
vm := map[string]*projectInfo{}
|
|
vm := map[string]*projectInfo{}
|
|
for _, v := range fpn {
|
|
for _, v := range fpn {
|
|
@@ -529,7 +570,14 @@ func (n *network) Introduce_Firstparty(fpn map[string][]*firstpartyNetwork) map[
|
|
}
|
|
}
|
|
}
|
|
}
|
|
wh, args := NetworkCom.WhArgs(values)
|
|
wh, args := NetworkCom.WhArgs(values)
|
|
- rows, err := ClickhouseConn.Query(context.Background(), `select buyer_id,count(project_id) AS project_count,sum(project_money) AS project_amount from information.transaction_info where buyer_id in (`+wh+`) group by buyer_id`, args...)
|
|
|
|
|
|
+ q := `select buyer_id,count(project_id) AS project_count,sum(project_money) AS project_amount from information.transaction_info where buyer_id in (` + wh + `)`
|
|
|
|
+ if matchme == 1 {
|
|
|
|
+ newWh, newArgs := NetworkCom.WhArgs(probusfors)
|
|
|
|
+ q += ` hasAny(property_form,[` + newWh + `])`
|
|
|
|
+ args = append(args, newArgs...)
|
|
|
|
+ }
|
|
|
|
+ q += ` group by buyer_id`
|
|
|
|
+ rows, err := ClickhouseConn.Query(context.Background(), q, args...)
|
|
if err != nil {
|
|
if err != nil {
|
|
logx.Error(err)
|
|
logx.Error(err)
|
|
return nil
|
|
return nil
|
|
@@ -547,7 +595,7 @@ func (n *network) Introduce_Firstparty(fpn map[string][]*firstpartyNetwork) map[
|
|
if vm[buyer_id] == nil {
|
|
if vm[buyer_id] == nil {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- vm[buyer_id].ProjectCount += int(project_count)
|
|
|
|
|
|
+ vm[buyer_id].ProjectCount += int64(project_count)
|
|
pf, _ := project_amount.Float64()
|
|
pf, _ := project_amount.Float64()
|
|
vm[buyer_id].ProjectAmount += pf
|
|
vm[buyer_id].ProjectAmount += pf
|
|
}
|
|
}
|
|
@@ -560,8 +608,11 @@ func (n *network) Introduce_Firstparty(fpn map[string][]*firstpartyNetwork) map[
|
|
if result[k] == nil {
|
|
if result[k] == nil {
|
|
result[k] = &projectInfo{}
|
|
result[k] = &projectInfo{}
|
|
}
|
|
}
|
|
- result[k].BuyerCount = len(v)
|
|
|
|
|
|
+ result[k].BuyerCount = int64(len(v))
|
|
for _, vv := range v {
|
|
for _, vv := range v {
|
|
|
|
+ if entMonitor[vv.CompanyName] {
|
|
|
|
+ result[k].MonitorCount++
|
|
|
|
+ }
|
|
if vm[vv.CompanyId] == nil {
|
|
if vm[vv.CompanyId] == nil {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
@@ -573,15 +624,21 @@ func (n *network) Introduce_Firstparty(fpn map[string][]*firstpartyNetwork) map[
|
|
}
|
|
}
|
|
|
|
|
|
//
|
|
//
|
|
-func (n *network) Introduce_Supplier(values []string) map[string]*projectInfo {
|
|
|
|
|
|
+func (n *network) Introduce_Supplier(values []string, entMonitor map[string]bool, matchme int64, probusfors []string) map[string]*projectInfo {
|
|
vm := map[string]*projectInfo{}
|
|
vm := map[string]*projectInfo{}
|
|
for _, v := range values {
|
|
for _, v := range values {
|
|
vm[v] = &projectInfo{}
|
|
vm[v] = &projectInfo{}
|
|
}
|
|
}
|
|
- wh, newArgs := NetworkCom.WhArgs(values)
|
|
|
|
- rows, err := ClickhouseConn.Query(context.Background(), `select a.winner_id,count(a.buyer_id) AS buyer_count,count(b.project_id) AS project_count,sum(b.project_money) AS project_amount from information.transaction_info a
|
|
|
|
- inner join information.transaction_info b on (hasAny(a.winner_id,[`+wh+`]) and a.buyer_id<>'' and a.buyer_id=b.buyer_id)
|
|
|
|
- group by a.winner_id`, newArgs...)
|
|
|
|
|
|
+ wh, args := NetworkCom.WhArgs(values)
|
|
|
|
+ q := `select a.winner_id,count(DISTINCT b.buyer_id) AS buyer_count,count(DISTINCT b.project_id) AS project_count,sum(b.project_money) AS project_amount,groupUniqArray(b.buyer) from information.transaction_info a
|
|
|
|
+ inner join information.transaction_info b on (hasAny(a.winner_id,[` + wh + `]) and a.buyer_id<>'' and a.buyer_id=b.buyer_id`
|
|
|
|
+ if matchme == 1 {
|
|
|
|
+ newWh, newArgs := NetworkCom.WhArgs(probusfors)
|
|
|
|
+ q += ` hasAny(b.property_form,[` + newWh + `])`
|
|
|
|
+ args = append(args, newArgs...)
|
|
|
|
+ }
|
|
|
|
+ q += `) group by a.winner_id`
|
|
|
|
+ rows, err := ClickhouseConn.Query(context.Background(), q, args...)
|
|
if err != nil {
|
|
if err != nil {
|
|
logx.Error(err)
|
|
logx.Error(err)
|
|
return nil
|
|
return nil
|
|
@@ -592,8 +649,9 @@ func (n *network) Introduce_Supplier(values []string) map[string]*projectInfo {
|
|
buyer_count uint64
|
|
buyer_count uint64
|
|
project_count uint64
|
|
project_count uint64
|
|
project_amount decimal.Decimal
|
|
project_amount decimal.Decimal
|
|
|
|
+ buyers []string
|
|
)
|
|
)
|
|
- if err := rows.Scan(&winner_id, &buyer_count, &project_count, &project_amount); err != nil {
|
|
|
|
|
|
+ if err := rows.Scan(&winner_id, &buyer_count, &project_count, &project_amount, &buyers); err != nil {
|
|
logx.Error(err)
|
|
logx.Error(err)
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
@@ -601,10 +659,15 @@ func (n *network) Introduce_Supplier(values []string) map[string]*projectInfo {
|
|
if vm[v] == nil {
|
|
if vm[v] == nil {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- vm[v].BuyerCount += int(buyer_count)
|
|
|
|
- vm[v].ProjectCount += int(project_count)
|
|
|
|
|
|
+ vm[v].BuyerCount += int64(buyer_count)
|
|
|
|
+ vm[v].ProjectCount += int64(project_count)
|
|
pf, _ := project_amount.Float64()
|
|
pf, _ := project_amount.Float64()
|
|
vm[v].ProjectAmount += pf
|
|
vm[v].ProjectAmount += pf
|
|
|
|
+ for _, v := range buyers {
|
|
|
|
+ if entMonitor[v] {
|
|
|
|
+ vm[v].MonitorCount++
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
rows.Close()
|
|
rows.Close()
|
|
@@ -615,15 +678,21 @@ func (n *network) Introduce_Supplier(values []string) map[string]*projectInfo {
|
|
}
|
|
}
|
|
|
|
|
|
//
|
|
//
|
|
-func (n *network) Introduce_Agency(values []string) map[string]*projectInfo {
|
|
|
|
|
|
+func (n *network) Introduce_Agency(values []string, entMonitor map[string]bool, matchme int64, probusfors []string) map[string]*projectInfo {
|
|
vm := map[string]*projectInfo{}
|
|
vm := map[string]*projectInfo{}
|
|
for _, v := range values {
|
|
for _, v := range values {
|
|
vm[v] = &projectInfo{}
|
|
vm[v] = &projectInfo{}
|
|
}
|
|
}
|
|
- wh, newArgs := NetworkCom.WhArgs(values)
|
|
|
|
- rows, err := ClickhouseConn.Query(context.Background(), `select a.agency_id,count(a.buyer_id) AS buyer_count,count(b.project_id) AS project_count,sum(b.project_money) AS project_amount from information.transaction_info a
|
|
|
|
- inner join information.transaction_info b on (a.agency_id in (`+wh+`) and a.buyer_id<>'' and a.buyer_id=b.buyer_id)
|
|
|
|
- group by a.agency_id`, newArgs...)
|
|
|
|
|
|
+ wh, args := NetworkCom.WhArgs(values)
|
|
|
|
+ q := `select a.agency_id,count(DISTINCT b.buyer_id) AS buyer_count,count(DISTINCT b.project_id) AS project_count,sum(b.project_money) AS project_amount,groupUniqArray(b.buyer) from information.transaction_info a
|
|
|
|
+ inner join information.transaction_info b on (a.agency_id in (` + wh + `) and a.buyer_id<>'' and a.buyer_id=b.buyer_id`
|
|
|
|
+ if matchme == 1 {
|
|
|
|
+ newWh, newArgs := NetworkCom.WhArgs(probusfors)
|
|
|
|
+ q += ` hasAny(b.property_form,[` + newWh + `])`
|
|
|
|
+ args = append(args, newArgs...)
|
|
|
|
+ }
|
|
|
|
+ q += `) group by a.agency_id`
|
|
|
|
+ rows, err := ClickhouseConn.Query(context.Background(), q, args...)
|
|
if err != nil {
|
|
if err != nil {
|
|
logx.Error(err)
|
|
logx.Error(err)
|
|
return nil
|
|
return nil
|
|
@@ -634,18 +703,24 @@ func (n *network) Introduce_Agency(values []string) map[string]*projectInfo {
|
|
buyer_count uint64
|
|
buyer_count uint64
|
|
project_count uint64
|
|
project_count uint64
|
|
project_amount decimal.Decimal
|
|
project_amount decimal.Decimal
|
|
|
|
+ buyers []string
|
|
)
|
|
)
|
|
- if err := rows.Scan(&agency_id, &buyer_count, &project_count, &project_amount); err != nil {
|
|
|
|
|
|
+ if err := rows.Scan(&agency_id, &buyer_count, &project_count, &project_amount, &buyers); err != nil {
|
|
logx.Error(err)
|
|
logx.Error(err)
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
if vm[agency_id] == nil {
|
|
if vm[agency_id] == nil {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- vm[agency_id].BuyerCount += int(buyer_count)
|
|
|
|
- vm[agency_id].ProjectCount += int(project_count)
|
|
|
|
|
|
+ vm[agency_id].BuyerCount += int64(buyer_count)
|
|
|
|
+ vm[agency_id].ProjectCount += int64(project_count)
|
|
pf, _ := project_amount.Float64()
|
|
pf, _ := project_amount.Float64()
|
|
vm[agency_id].ProjectAmount += pf
|
|
vm[agency_id].ProjectAmount += pf
|
|
|
|
+ for _, v := range buyers {
|
|
|
|
+ if entMonitor[v] {
|
|
|
|
+ vm[agency_id].MonitorCount++
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
rows.Close()
|
|
rows.Close()
|
|
if err := rows.Err(); err != nil {
|
|
if err := rows.Err(); err != nil {
|
|
@@ -655,7 +730,7 @@ func (n *network) Introduce_Agency(values []string) map[string]*projectInfo {
|
|
}
|
|
}
|
|
|
|
|
|
//
|
|
//
|
|
-func (n *network) Introduce_Middleman(values []string) map[string]*projectInfo {
|
|
|
|
|
|
+func (n *network) Introduce_Middleman(values []string, entMonitor map[string]bool, matchme int64, probusfors []string) map[string]*projectInfo {
|
|
vm := map[string]*projectInfo{}
|
|
vm := map[string]*projectInfo{}
|
|
wh, newArgs := NetworkCom.WhArgs(values)
|
|
wh, newArgs := NetworkCom.WhArgs(values)
|
|
rows, err := ClickhouseConn.Query(context.Background(), `select project_id,project_money from information.transaction_info where project_id in (`+wh+`)`, newArgs...)
|
|
rows, err := ClickhouseConn.Query(context.Background(), `select project_id,project_money from information.transaction_info where project_id in (`+wh+`)`, newArgs...)
|
|
@@ -684,6 +759,18 @@ func (n *network) Introduce_Middleman(values []string) map[string]*projectInfo {
|
|
return vm
|
|
return vm
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+//
|
|
|
|
+func (n *network) EntMonitor(positionId int64) map[string]bool {
|
|
|
|
+ m := map[string]bool{}
|
|
|
|
+ list := CrmMysql.SelectBySql(`select * from base_service.follow_ent_monitor where s_userid=?`, positionId)
|
|
|
|
+ for _, v := range *list {
|
|
|
|
+ if entName := ObjToString(v["s_entname"]); entName != "" {
|
|
|
|
+ m[entName] = true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return m
|
|
|
|
+}
|
|
|
|
+
|
|
//
|
|
//
|
|
func (n *network) TypeConvert(itype string) int {
|
|
func (n *network) TypeConvert(itype string) int {
|
|
//firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 agency:招标代理机构
|
|
//firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 agency:招标代理机构
|