|
@@ -239,12 +239,12 @@ func (n *network) Associate(in *types.AssociateReq) (reply *types.Reply) {
|
|
|
}
|
|
|
pageSize := 10
|
|
|
if in.Type == "adiffb" {
|
|
|
- probusfors := NetworkCom.GetMyProbusfor(in.EntAccountId)
|
|
|
- if len(probusfors) > 0 {
|
|
|
+ businessType := strings.Split(FindBusiness(in.EntId, in.MgoUserId), ",")
|
|
|
+ if len(businessType) > 0 {
|
|
|
args := []interface{}{in.EntName}
|
|
|
- wh, newArgs := NetworkCom.WhArgs(probusfors)
|
|
|
+ wh, newArgs := NetworkCom.WhArgs(businessType)
|
|
|
args = append(args, newArgs...)
|
|
|
- q := `select DISTINCT winner_id,winner from information.transaction_info where buyer_id in (select buyer_id from information.transaction_info where has(winner, ?) and buyer_id<>'') and hasAny(property_form,[` + wh + `])=0 ORDER BY project_id`
|
|
|
+ q := `select DISTINCT winner_id,winner from information.transaction_info where buyer_id in (select buyer_id from information.transaction_info where has(winner, ?) and buyer_id<>'') and hasAny(topscopeclass,[` + wh + `])=0 ORDER BY project_id`
|
|
|
rows, err := ClickhouseConn.Query(context.Background(), q, args...)
|
|
|
if err != nil {
|
|
|
logx.Error(err)
|
|
@@ -322,7 +322,7 @@ func (n *network) Associate(in *types.AssociateReq) (reply *types.Reply) {
|
|
|
//人脉库-全部人脉项目
|
|
|
func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
|
|
|
reply = &types.Reply{}
|
|
|
- probusfors := NetworkCom.GetMyProbusfor(in.EntAccountId)
|
|
|
+ businessType := strings.Split(FindBusiness(in.EntId, in.MgoUserId), ",")
|
|
|
var count int64
|
|
|
var list []*networkTree
|
|
|
firstpartyChild := map[string][]*firstpartyNetwork{}
|
|
@@ -330,7 +330,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
|
|
|
if in.Type == "firstparty" {
|
|
|
fpn := n.FirstpartyNetwork(in.Name, []string{in.Id})
|
|
|
if fpn[in.Id] != nil {
|
|
|
- firstparty := n.Introduce_Firstparty(fpn, map[string]bool{}, probusfors)
|
|
|
+ firstparty := n.Introduce_Firstparty(fpn, map[string]bool{}, businessType)
|
|
|
nameIndex := map[string]int{}
|
|
|
for _, v := range fpn[in.Id] {
|
|
|
if _, ok := nameIndex[v.Name]; !ok {
|
|
@@ -360,7 +360,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
|
|
|
sqlAppend1 += ` and a.company_name like ?`
|
|
|
args = append(args, "%"+in.Name+"%")
|
|
|
}
|
|
|
- aio := n.AllIntroduceOwner(sqlAppend1, "", args, true, probusfors, map[string]bool{})
|
|
|
+ aio := n.AllIntroduceOwner(sqlAppend1, "", args, true, businessType, map[string]bool{})
|
|
|
firstpartyChild = aio.FirstpartyNetwork
|
|
|
list = []*networkTree{
|
|
|
&networkTree{
|
|
@@ -567,6 +567,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
|
|
|
|
|
|
//人脉库-列表
|
|
|
func (n *network) List(in *types.NetWorkListReq) *types.Reply {
|
|
|
+ in.Project_matchme = 1
|
|
|
if in.Page_size <= 0 {
|
|
|
in.Page_size = 10
|
|
|
}
|
|
@@ -636,16 +637,16 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
|
|
|
//
|
|
|
list := []*map[string]interface{}{}
|
|
|
isTjProject := true
|
|
|
- probusfors := []string{}
|
|
|
+ businessType := []string{}
|
|
|
if in.Project_matchme == 1 {
|
|
|
- probusfors = NetworkCom.GetMyProbusfor(in.EntAccountId)
|
|
|
- if len(probusfors) == 0 {
|
|
|
+ businessType = strings.Split(FindBusiness(in.EntId, in.MgoUserId), ",")
|
|
|
+ if len(businessType) == 0 {
|
|
|
isTjProject = false
|
|
|
}
|
|
|
}
|
|
|
if isTjProject {
|
|
|
entMonitor := NetworkCom.EntMonitor(in.UserId)
|
|
|
- aio := n.AllIntroduceOwner(sqlAppend1, sqlAppend2, args, isTjProject, probusfors, entMonitor)
|
|
|
+ aio := n.AllIntroduceOwner(sqlAppend1, sqlAppend2, args, isTjProject, businessType, entMonitor)
|
|
|
for _, v := range aio.Networks {
|
|
|
itype := ""
|
|
|
buyer_count, project_count, expect_amount, monitor_count := int64(0), int64(0), float64(0), int64(0)
|
|
@@ -888,7 +889,7 @@ func (n *network) FirstpartyNetwork(name string, values []string) map[string][]*
|
|
|
}
|
|
|
|
|
|
//
|
|
|
-func (n *network) Introduce_Firstparty(fpn map[string][]*firstpartyNetwork, entMonitor map[string]bool, probusfors []string) map[string]*projectInfo {
|
|
|
+func (n *network) Introduce_Firstparty(fpn map[string][]*firstpartyNetwork, entMonitor map[string]bool, businessType []string) map[string]*projectInfo {
|
|
|
values := []string{}
|
|
|
vm := map[string]*projectInfo{}
|
|
|
for _, v := range fpn {
|
|
@@ -903,9 +904,9 @@ func (n *network) Introduce_Firstparty(fpn map[string][]*firstpartyNetwork, entM
|
|
|
}
|
|
|
wh, args := NetworkCom.WhArgs(values)
|
|
|
q := `select buyer_id,count(project_id) AS project_count,sum(project_money) AS project_amount,groupUniqArray(project_id) from information.transaction_info where buyer_id in (` + wh + `)`
|
|
|
- if len(probusfors) > 0 {
|
|
|
- newWh, newArgs := NetworkCom.WhArgs(probusfors)
|
|
|
- q += ` and hasAny(property_form,[` + newWh + `])`
|
|
|
+ if len(businessType) > 0 {
|
|
|
+ newWh, newArgs := NetworkCom.WhArgs(businessType)
|
|
|
+ q += ` and hasAny(topscopeclass,[` + newWh + `])`
|
|
|
args = append(args, newArgs...)
|
|
|
}
|
|
|
q += ` and project_bidstatus>1 group by buyer_id`
|
|
@@ -958,7 +959,7 @@ func (n *network) Introduce_Firstparty(fpn map[string][]*firstpartyNetwork, entM
|
|
|
}
|
|
|
|
|
|
//
|
|
|
-func (n *network) Introduce_Supplier(values []string, entMonitor map[string]bool, probusfors []string) map[string]*projectInfo {
|
|
|
+func (n *network) Introduce_Supplier(values []string, entMonitor map[string]bool, businessType []string) map[string]*projectInfo {
|
|
|
if len(values) == 0 {
|
|
|
return map[string]*projectInfo{}
|
|
|
}
|
|
@@ -1008,11 +1009,11 @@ func (n *network) Introduce_Supplier(values []string, entMonitor map[string]bool
|
|
|
logx.Error(err)
|
|
|
}
|
|
|
}
|
|
|
- return n.MakeProjectInfo(buyers, vbs, probusfors, entMonitor)
|
|
|
+ return n.MakeProjectInfo(buyers, vbs, businessType, entMonitor)
|
|
|
}
|
|
|
|
|
|
//
|
|
|
-func (n *network) Introduce_Agency(values []string, entMonitor map[string]bool, probusfors []string) map[string]*projectInfo {
|
|
|
+func (n *network) Introduce_Agency(values []string, entMonitor map[string]bool, businessType []string) map[string]*projectInfo {
|
|
|
if len(values) == 0 {
|
|
|
return map[string]*projectInfo{}
|
|
|
}
|
|
@@ -1052,20 +1053,20 @@ func (n *network) Introduce_Agency(values []string, entMonitor map[string]bool,
|
|
|
if err := rows.Err(); err != nil {
|
|
|
logx.Error(err)
|
|
|
}
|
|
|
- return n.MakeProjectInfo(buyers, vbs, probusfors, entMonitor)
|
|
|
+ return n.MakeProjectInfo(buyers, vbs, businessType, entMonitor)
|
|
|
}
|
|
|
|
|
|
//
|
|
|
-func (n *network) Introduce_Middleman(values []string, entMonitor map[string]bool, probusfors []string) map[string]*projectInfo {
|
|
|
+func (n *network) Introduce_Middleman(values []string, entMonitor map[string]bool, businessType []string) map[string]*projectInfo {
|
|
|
result := map[string]*projectInfo{}
|
|
|
if len(values) == 0 {
|
|
|
return result
|
|
|
}
|
|
|
wh, args := NetworkCom.WhArgs(values)
|
|
|
q := `select DISTINCT project_id,project_money from information.transaction_info where project_id in (` + wh + `) and project_bidstatus>1`
|
|
|
- if len(probusfors) > 0 {
|
|
|
- newWh, newArgs := NetworkCom.WhArgs(probusfors)
|
|
|
- q += ` and hasAny(property_form,[` + newWh + `])`
|
|
|
+ if len(businessType) > 0 {
|
|
|
+ newWh, newArgs := NetworkCom.WhArgs(businessType)
|
|
|
+ q += ` and hasAny(topscopeclass,[` + newWh + `])`
|
|
|
args = append(args, newArgs...)
|
|
|
}
|
|
|
rows, err := ClickhouseConn.Query(context.Background(), q, args...)
|
|
@@ -1162,16 +1163,16 @@ func (n *network) GetQyxyId(ids []string) map[string]string {
|
|
|
}
|
|
|
|
|
|
//
|
|
|
-func (n *network) BuyerProjectInfo(ids []string, probusfors []string) map[string]*projectInfo {
|
|
|
+func (n *network) BuyerProjectInfo(ids []string, businessType []string) map[string]*projectInfo {
|
|
|
vm := map[string]*projectInfo{}
|
|
|
if len(ids) == 0 {
|
|
|
return vm
|
|
|
}
|
|
|
wh, args := NetworkCom.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 where buyer_id in (` + wh + `) and project_bidstatus>1`
|
|
|
- if len(probusfors) > 0 {
|
|
|
- newWh, newArgs := NetworkCom.WhArgs(probusfors)
|
|
|
- q += ` and hasAny(property_form,[` + newWh + `])`
|
|
|
+ if len(businessType) > 0 {
|
|
|
+ newWh, newArgs := NetworkCom.WhArgs(businessType)
|
|
|
+ q += ` and hasAny(topscopeclass,[` + newWh + `])`
|
|
|
args = append(args, newArgs...)
|
|
|
}
|
|
|
q += ` group by buyer_id`
|
|
@@ -1206,8 +1207,8 @@ func (n *network) BuyerProjectInfo(ids []string, probusfors []string) map[string
|
|
|
}
|
|
|
|
|
|
//
|
|
|
-func (n *network) MakeProjectInfo(buyers []string, vbs map[string][]*idName, probusfors []string, entMonitor map[string]bool) map[string]*projectInfo {
|
|
|
- pis := n.BuyerProjectInfo(buyers, probusfors)
|
|
|
+func (n *network) MakeProjectInfo(buyers []string, vbs map[string][]*idName, businessType []string, entMonitor map[string]bool) map[string]*projectInfo {
|
|
|
+ pis := n.BuyerProjectInfo(buyers, businessType)
|
|
|
vm := map[string]*projectInfo{}
|
|
|
for k, v := range vbs {
|
|
|
pi := &projectInfo{
|
|
@@ -1236,7 +1237,7 @@ func (n *network) MakeProjectInfo(buyers []string, vbs map[string][]*idName, pro
|
|
|
}
|
|
|
|
|
|
//
|
|
|
-func (n *network) AllIntroduceOwner(sqlAppend1, sqlAppend2 string, args []interface{}, isTjProject bool, probusfors []string, entMonitor map[string]bool) *introduceOwnerProject {
|
|
|
+func (n *network) AllIntroduceOwner(sqlAppend1, sqlAppend2 string, args []interface{}, isTjProject bool, businessType []string, entMonitor map[string]bool) *introduceOwnerProject {
|
|
|
q := `select a.id,a.company_id,a.company_name,a.qyxy_id,a.itype,a.contact_person as person,a.contact_phone as phone,count(DISTINCT if(b.itype=1,b.relate_id,null)) as buyer_count,count(DISTINCT if(b.itype=2,b.relate_id,null)) as project_count,GROUP_CONCAT(IF(b.itype=1,b.relate_id,NULL)) AS relate_buyer_id,GROUP_CONCAT(IF(b.itype=1,b.relate_name,NULL)) AS relate_buyer_name,GROUP_CONCAT(IF(b.itype=2,b.relate_id,NULL)) AS relate_project_id,a.create_time from crm.connection a
|
|
|
left join crm.connection_introduce b on (a.position_id=? and b.position_id=? and a.id=b.connection_id) where a.position_id=?` + sqlAppend1 + ` GROUP BY a.id order by a.create_time desc` + sqlAppend2
|
|
|
listTemp := CrmMysql.SelectBySql(q, args...)
|
|
@@ -1285,11 +1286,11 @@ func (n *network) AllIntroduceOwner(sqlAppend1, sqlAppend2 string, args []interf
|
|
|
}
|
|
|
if isTjProject {
|
|
|
iop.FirstpartyNetwork = n.FirstpartyNetwork("", firstparty_array)
|
|
|
- iop.Firstparty = n.Introduce_Firstparty(iop.FirstpartyNetwork, entMonitor, probusfors)
|
|
|
- iop.Supplier = n.Introduce_Supplier(supplier_array, entMonitor, probusfors)
|
|
|
- iop.Adiffb = n.Introduce_Supplier(adiffb_array, entMonitor, probusfors)
|
|
|
- iop.Agency = n.Introduce_Agency(agency_array, entMonitor, probusfors)
|
|
|
- iop.Middleman = n.Introduce_Middleman(middleman_project_array, entMonitor, probusfors)
|
|
|
+ iop.Firstparty = n.Introduce_Firstparty(iop.FirstpartyNetwork, entMonitor, businessType)
|
|
|
+ iop.Supplier = n.Introduce_Supplier(supplier_array, entMonitor, businessType)
|
|
|
+ iop.Adiffb = n.Introduce_Supplier(adiffb_array, entMonitor, businessType)
|
|
|
+ iop.Agency = n.Introduce_Agency(agency_array, entMonitor, businessType)
|
|
|
+ iop.Middleman = n.Introduce_Middleman(middleman_project_array, entMonitor, businessType)
|
|
|
}
|
|
|
return iop
|
|
|
}
|