|
@@ -7,7 +7,6 @@ import (
|
|
|
"math"
|
|
|
"sort"
|
|
|
"strings"
|
|
|
- "sync"
|
|
|
"time"
|
|
|
|
|
|
. "app.yhyue.com/moapp/jybase/common"
|
|
@@ -78,6 +77,29 @@ type idName struct {
|
|
|
Id string
|
|
|
Name string
|
|
|
}
|
|
|
+type introduceOwnerProject struct {
|
|
|
+ Networks []*myNetwork
|
|
|
+ FirstpartyNetwork map[string][]*firstpartyNetwork
|
|
|
+ Firstparty map[string]*projectInfo
|
|
|
+ Supplier map[string]*projectInfo
|
|
|
+ Adiffb map[string]*projectInfo
|
|
|
+ Agency map[string]*projectInfo
|
|
|
+ Middleman map[string]*projectInfo
|
|
|
+}
|
|
|
+type myNetwork struct {
|
|
|
+ Id int64
|
|
|
+ Company_id string
|
|
|
+ Company_name string
|
|
|
+ Qyxy_id string
|
|
|
+ Itype int64
|
|
|
+ Person string
|
|
|
+ Phone string
|
|
|
+ Buyer_count int64
|
|
|
+ Project_count int64
|
|
|
+ Relate_buyer_id string
|
|
|
+ Relate_project_id string
|
|
|
+ Create_time string
|
|
|
+}
|
|
|
|
|
|
//人脉库-添加/修改人脉
|
|
|
func (n *network) AddOrUpdate(in *types.AddOrUpdateReq) *types.Reply {
|
|
@@ -262,63 +284,47 @@ func (n *network) Associate(in *types.AssociateReq) (reply *types.Reply) {
|
|
|
|
|
|
//人脉库-全部人脉项目
|
|
|
func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
|
|
|
- pool := make(chan bool, 5)
|
|
|
- wait := &sync.WaitGroup{}
|
|
|
- lock := &sync.Mutex{}
|
|
|
reply = &types.Reply{}
|
|
|
- wh, newArgs := NetworkCom.WhArgs(NetworkCom.GetMyProbusfor(in.EntAccountId))
|
|
|
+ probusfors := NetworkCom.GetMyProbusfor(in.EntAccountId)
|
|
|
var count int64
|
|
|
var list []*networkTree
|
|
|
- firstpartyIds := []string{}
|
|
|
+ firstpartyChild := map[string][]*firstpartyNetwork{}
|
|
|
if in.Id != "" {
|
|
|
if in.Type == "firstparty" {
|
|
|
- result := n.FirstpartyNetwork(in.Name, []string{in.Id})
|
|
|
- if result[in.Id] != nil {
|
|
|
+ fpn := n.FirstpartyNetwork(in.Name, []string{in.Id})
|
|
|
+ if fpn[in.Id] != nil {
|
|
|
+ firstparty := n.Introduce_Firstparty(fpn, map[string]bool{}, probusfors)
|
|
|
nameIndex := map[string]int{}
|
|
|
- for _, v := range result[in.Id] {
|
|
|
+ for _, v := range fpn[in.Id] {
|
|
|
if _, ok := nameIndex[v.Name]; !ok {
|
|
|
nameIndex[v.Name] = len(list)
|
|
|
list = append(list, &networkTree{
|
|
|
Name: v.Name,
|
|
|
})
|
|
|
}
|
|
|
- pool <- true
|
|
|
- wait.Add(1)
|
|
|
- go func(cIndex int, cId, cName string) {
|
|
|
- defer func() {
|
|
|
- <-pool
|
|
|
- wait.Done()
|
|
|
- }()
|
|
|
- ntc := &networkTreeChild{
|
|
|
- CompanyName: cName,
|
|
|
- CompanyId: cId,
|
|
|
- Type: "firstparty",
|
|
|
- }
|
|
|
- if wh != "" {
|
|
|
- thisArgs := []interface{}{ntc.CompanyId}
|
|
|
- thisArgs = append(thisArgs, newArgs...)
|
|
|
- ntc.Count = NetworkCom.Count(`select count(1) from information.transaction_info where buyer_id=? and hasAny(property_form,[`+wh+`])`, thisArgs...)
|
|
|
- }
|
|
|
- lock.Lock()
|
|
|
- count++
|
|
|
- list[cIndex].Count += ntc.Count
|
|
|
- list[cIndex].Children = append(list[cIndex].Children, ntc)
|
|
|
- lock.Unlock()
|
|
|
- }(nameIndex[v.Name], v.CompanyId, v.CompanyName)
|
|
|
+ ntc := &networkTreeChild{
|
|
|
+ CompanyName: v.CompanyName,
|
|
|
+ CompanyId: v.CompanyId,
|
|
|
+ Type: "firstparty",
|
|
|
+ }
|
|
|
+ if firstparty[v.CompanyId] != nil {
|
|
|
+ ntc.Count = firstparty[v.CompanyId].ProjectCount
|
|
|
+ }
|
|
|
+ count++
|
|
|
+ list[nameIndex[v.Name]].Count += ntc.Count
|
|
|
+ list[nameIndex[v.Name]].Children = append(list[nameIndex[v.Name]].Children, ntc)
|
|
|
}
|
|
|
- wait.Wait()
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- q := `SELECT a.id,a.company_id,a.company_name,a.itype,a.create_time,COUNT(b.id) AS ipc FROM crm.connection a
|
|
|
- LEFT JOIN crm.connection_introduce b ON (b.position_id=? AND b.itype=2 AND a.id=b.connection_id) WHERE a.position_id=?`
|
|
|
- args := []interface{}{in.PositionId, in.PositionId}
|
|
|
+ args := []interface{}{in.PositionId, in.PositionId, in.PositionId}
|
|
|
+ sqlAppend1 := ""
|
|
|
if in.Name != "" {
|
|
|
- q += ` and company_name like ?`
|
|
|
+ sqlAppend1 += ` and a.company_name like ?`
|
|
|
args = append(args, "%"+in.Name+"%")
|
|
|
}
|
|
|
- q += ` GROUP BY a.id ORDER BY a.create_time DESC`
|
|
|
- datas := CrmMysql.SelectBySql(q, args...)
|
|
|
+ aio := n.AllIntroduceOwner(sqlAppend1, "", args, true, probusfors, map[string]bool{})
|
|
|
+ firstpartyChild = aio.FirstpartyNetwork
|
|
|
list = []*networkTree{
|
|
|
&networkTree{
|
|
|
Name: "甲方",
|
|
@@ -342,54 +348,47 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
|
|
|
},
|
|
|
}
|
|
|
//
|
|
|
- for _, vt := range *datas {
|
|
|
- pool <- true
|
|
|
- wait.Add(1)
|
|
|
- go func(v map[string]interface{}) {
|
|
|
- defer func() {
|
|
|
- <-pool
|
|
|
- wait.Done()
|
|
|
- }()
|
|
|
- itype := IntAll(v["itype"])
|
|
|
- if itype <= 0 || itype > len(list) {
|
|
|
- return
|
|
|
+ for _, v := range aio.Networks {
|
|
|
+ if v.Itype <= 0 || v.Itype > int64(len(list)) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ ntc := &networkTreeChild{
|
|
|
+ Id: v.Id,
|
|
|
+ CompanyName: v.Company_name,
|
|
|
+ CompanyId: v.Company_id,
|
|
|
+ Type: n.TypeIntConvert(v.Itype),
|
|
|
+ CreateTime: v.Create_time,
|
|
|
+ }
|
|
|
+ switch v.Itype {
|
|
|
+ case 1:
|
|
|
+ if aio.Firstparty[v.Company_id] != nil {
|
|
|
+ ntc.Count = aio.Firstparty[v.Company_id].ProjectCount
|
|
|
}
|
|
|
- company_name := ObjToString(v["company_name"])
|
|
|
- ntc := &networkTreeChild{
|
|
|
- Id: Int64All(v["id"]),
|
|
|
- CompanyName: company_name,
|
|
|
- CompanyId: ObjToString(v["company_id"]),
|
|
|
- Type: n.TypeIntConvert(Int64All(v["itype"])),
|
|
|
- CreateTime: ObjToString(v["create_time"]),
|
|
|
+ case 2:
|
|
|
+ if aio.Supplier[v.Company_id] != nil {
|
|
|
+ ntc.Count = aio.Supplier[v.Company_id].ProjectCount
|
|
|
}
|
|
|
- if wh != "" {
|
|
|
- thisArgs := []interface{}{ntc.CompanyId}
|
|
|
- thisArgs = append(thisArgs, newArgs...)
|
|
|
- if itype == 1 {
|
|
|
- ntc.Count = NetworkCom.Count(`select count(1) from information.transaction_info where buyer_id=? and hasAny(property_form,[`+wh+`])`, thisArgs...)
|
|
|
- } else if itype == 2 || itype == 3 {
|
|
|
- ntc.Count = NetworkCom.Count(`select count(1) from information.transaction_info where has(winner_id,?) and hasAny(property_form,[`+wh+`])`, thisArgs...)
|
|
|
- } else if itype == 4 {
|
|
|
- ntc.Count = Int64All(v["ipc"])
|
|
|
- } else if itype == 5 {
|
|
|
- ntc.Count = NetworkCom.Count(`select count(1) from information.transaction_info where agency_id=? and hasAny(property_form,[`+wh+`])`, thisArgs...)
|
|
|
+ case 3:
|
|
|
+ if aio.Adiffb[v.Company_id] != nil {
|
|
|
+ ntc.Count = aio.Adiffb[v.Company_id].ProjectCount
|
|
|
+ }
|
|
|
+ case 4:
|
|
|
+ if v.Relate_project_id != "" {
|
|
|
+ for _, v := range strings.Split(v.Relate_project_id, ",") {
|
|
|
+ if aio.Middleman[v] != nil {
|
|
|
+ ntc.Count++
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- lock.Lock()
|
|
|
- if itype == 1 {
|
|
|
- firstpartyIds = append(firstpartyIds, ntc.CompanyId)
|
|
|
+ case 5:
|
|
|
+ if aio.Agency[v.Company_id] != nil {
|
|
|
+ ntc.Count = aio.Agency[v.Company_id].ProjectCount
|
|
|
}
|
|
|
- count += ntc.Count
|
|
|
- list[itype-1].Count += ntc.Count
|
|
|
- list[itype-1].Children = append(list[itype-1].Children, ntc)
|
|
|
- lock.Unlock()
|
|
|
- }(vt)
|
|
|
+ }
|
|
|
+ count += ntc.Count
|
|
|
+ list[v.Itype-1].Count += ntc.Count
|
|
|
+ list[v.Itype-1].Children = append(list[v.Itype-1].Children, ntc)
|
|
|
}
|
|
|
- wait.Wait()
|
|
|
- }
|
|
|
- firstpartyChild := map[string][]*firstpartyNetwork{}
|
|
|
- if len(firstpartyIds) > 0 {
|
|
|
- firstpartyChild = n.FirstpartyNetwork("", firstpartyIds)
|
|
|
}
|
|
|
convList := []map[string]interface{}{}
|
|
|
for _, v := range list {
|
|
@@ -485,18 +484,18 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
|
|
|
if in.Current_page <= 0 {
|
|
|
in.Current_page = 1
|
|
|
}
|
|
|
- args := []interface{}{in.PositionId}
|
|
|
- sqlAppend := ""
|
|
|
+ args := []interface{}{in.PositionId, in.PositionId, in.PositionId}
|
|
|
+ sqlAppend1 := ""
|
|
|
if in.Type != "" {
|
|
|
- sqlAppend += ` and a.itype=?`
|
|
|
+ sqlAppend1 += ` and a.itype=?`
|
|
|
args = append(args, n.TypeStrConvert(in.Type))
|
|
|
}
|
|
|
if in.Starttime != "" {
|
|
|
- sqlAppend += ` and a.create_time>=?`
|
|
|
+ sqlAppend1 += ` and a.create_time>=?`
|
|
|
args = append(args, in.Starttime+" 00:00:00")
|
|
|
}
|
|
|
if in.Endtime != "" {
|
|
|
- sqlAppend += ` and a.create_time<=?`
|
|
|
+ sqlAppend1 += ` and a.create_time<=?`
|
|
|
if in.Starttime == in.Endtime {
|
|
|
in.Endtime += " 23:59:59"
|
|
|
} else {
|
|
@@ -505,114 +504,88 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
|
|
|
args = append(args, in.Endtime)
|
|
|
}
|
|
|
if in.Name != "" {
|
|
|
- sqlAppend += ` and a.company_name like ?`
|
|
|
+ sqlAppend1 += ` and a.company_name like ?`
|
|
|
args = append(args, "%"+in.Name+"%")
|
|
|
}
|
|
|
- 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=2,b.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=?` + sqlAppend + ` GROUP BY a.id order by a.create_time desc`
|
|
|
var count int64
|
|
|
start := (in.Current_page - 1) * in.Page_size
|
|
|
end := start + in.Page_size
|
|
|
dbPaging := in.Buyercount_start == 0 && in.Buyercount_end == 0 && in.Monitor == 0 && in.Monitorcount_start == 0 && in.Monitorcount_end == 0 && in.Project_matchme == 0 && in.Order_amount == 0
|
|
|
+ sqlAppend2 := ""
|
|
|
if dbPaging {
|
|
|
- count = CrmMysql.CountBySql(`select count(1) as count from crm.connection a where a.position_id=?`+sqlAppend, args...)
|
|
|
- q += ` limit ?,?`
|
|
|
+ count = CrmMysql.CountBySql(`select count(1) as count from crm.connection a where a.position_id=?`+sqlAppend1, args...)
|
|
|
+ sqlAppend2 = ` limit ?,?`
|
|
|
args = append(args, start, end)
|
|
|
}
|
|
|
- listTemp := CrmMysql.SelectBySql(q, args...)
|
|
|
- firstparty_array, supplier_array, adiffb_array, agency_array, middleman_project_array := []string{}, []string{}, []string{}, []string{}, []string{}
|
|
|
- for _, v := range *listTemp {
|
|
|
- switch Int64All(v["itype"]) {
|
|
|
- case 1:
|
|
|
- firstparty_array = append(firstparty_array, ObjToString(v["company_id"]))
|
|
|
- case 2:
|
|
|
- supplier_array = append(supplier_array, ObjToString(v["company_id"]))
|
|
|
- case 3:
|
|
|
- adiffb_array = append(adiffb_array, ObjToString(v["company_id"]))
|
|
|
- case 4:
|
|
|
- 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:
|
|
|
- agency_array = append(agency_array, ObjToString(v["company_id"]))
|
|
|
- }
|
|
|
- }
|
|
|
//
|
|
|
firstparty_count, supplier_count, adiffb_count, middleman_count, agency_count := 0, 0, 0, 0, 0
|
|
|
list := []*map[string]interface{}{}
|
|
|
- isGoNextSetp := true
|
|
|
+ isTjProject := true
|
|
|
probusfors := []string{}
|
|
|
if in.Project_matchme == 1 {
|
|
|
probusfors = NetworkCom.GetMyProbusfor(in.EntAccountId)
|
|
|
if len(probusfors) == 0 {
|
|
|
- isGoNextSetp = false
|
|
|
+ isTjProject = false
|
|
|
}
|
|
|
}
|
|
|
- if isGoNextSetp {
|
|
|
+ if isTjProject {
|
|
|
entMonitor := NetworkCom.EntMonitor(in.UserId)
|
|
|
- fpn := n.FirstpartyNetwork("", firstparty_array)
|
|
|
- firstparty_project := n.Introduce_Firstparty(fpn, 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 {
|
|
|
+ aio := n.AllIntroduceOwner(sqlAppend1, sqlAppend2, args, isTjProject, probusfors, entMonitor)
|
|
|
+ for _, v := range aio.Networks {
|
|
|
itype := ""
|
|
|
buyer_count, project_count, expect_amount, monitor_count := int64(0), int64(0), float64(0), int64(0)
|
|
|
- company_id := ObjToString(v["company_id"])
|
|
|
export_id := []string{}
|
|
|
jump_type, jump_id := "", ""
|
|
|
- switch Int64All(v["itype"]) {
|
|
|
+ switch v.Itype {
|
|
|
case 1:
|
|
|
itype = "甲方"
|
|
|
jump_type = "firstparty"
|
|
|
- for _, vv := range fpn[company_id] {
|
|
|
+ for _, vv := range aio.FirstpartyNetwork[v.Company_id] {
|
|
|
if jump_id != "" {
|
|
|
jump_id += ","
|
|
|
}
|
|
|
jump_id += vv.CompanyId
|
|
|
}
|
|
|
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
|
|
|
- export_id = firstparty_project[company_id].ExportId
|
|
|
+ if aio.Firstparty[v.Company_id] != nil {
|
|
|
+ buyer_count = aio.Firstparty[v.Company_id].BuyerCount
|
|
|
+ project_count = aio.Firstparty[v.Company_id].ProjectCount
|
|
|
+ expect_amount = aio.Firstparty[v.Company_id].ProjectAmount
|
|
|
+ monitor_count = aio.Firstparty[v.Company_id].MonitorCount
|
|
|
+ export_id = aio.Firstparty[v.Company_id].ExportId
|
|
|
}
|
|
|
case 2:
|
|
|
itype = "供应商"
|
|
|
jump_type = "supplier"
|
|
|
- jump_id = company_id
|
|
|
+ jump_id = v.Company_id
|
|
|
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
|
|
|
- export_id = supplier_project[company_id].ExportId
|
|
|
+ if aio.Supplier[v.Company_id] != nil {
|
|
|
+ buyer_count = aio.Supplier[v.Company_id].BuyerCount
|
|
|
+ project_count = aio.Supplier[v.Company_id].ProjectCount
|
|
|
+ expect_amount = aio.Supplier[v.Company_id].ProjectAmount
|
|
|
+ monitor_count = aio.Supplier[v.Company_id].MonitorCount
|
|
|
+ export_id = aio.Supplier[v.Company_id].ExportId
|
|
|
}
|
|
|
case 3:
|
|
|
itype = "同甲异业渠道"
|
|
|
jump_type = "adiffb"
|
|
|
- jump_id = company_id
|
|
|
+ jump_id = v.Company_id
|
|
|
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
|
|
|
- export_id = adiffb_project[company_id].ExportId
|
|
|
+ if aio.Adiffb[v.Company_id] != nil {
|
|
|
+ buyer_count = aio.Adiffb[v.Company_id].BuyerCount
|
|
|
+ project_count = aio.Adiffb[v.Company_id].ProjectCount
|
|
|
+ expect_amount = aio.Adiffb[v.Company_id].ProjectAmount
|
|
|
+ monitor_count = aio.Adiffb[v.Company_id].MonitorCount
|
|
|
+ export_id = aio.Adiffb[v.Company_id].ExportId
|
|
|
}
|
|
|
case 4:
|
|
|
itype = "中间人"
|
|
|
jump_type = "middleman"
|
|
|
- jump_id = fmt.Sprint(Int64All(v["id"]))
|
|
|
+ jump_id = fmt.Sprint(v.Id)
|
|
|
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, ",") {
|
|
|
+ buyer_count = v.Buyer_count
|
|
|
+ if v.Relate_buyer_id != "" {
|
|
|
+ for _, v := range strings.Split(v.Relate_buyer_id, ",") {
|
|
|
if v == "" {
|
|
|
continue
|
|
|
}
|
|
@@ -621,25 +594,26 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if relate_project_id := ObjToString(v["relate_project_id"]); relate_project_id != "" {
|
|
|
- export_id = strings.Split(relate_project_id, ",")
|
|
|
+ if v.Relate_project_id != "" {
|
|
|
+ export_id = strings.Split(v.Relate_project_id, ",")
|
|
|
for _, v := range export_id {
|
|
|
- if middleman_project[v] != nil {
|
|
|
- expect_amount += middleman_project[v].ProjectAmount
|
|
|
+ if aio.Middleman[v] != nil {
|
|
|
+ project_count++
|
|
|
+ expect_amount += aio.Middleman[v].ProjectAmount
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
case 5:
|
|
|
itype = "招标代理机构"
|
|
|
jump_type = "agency"
|
|
|
- jump_id = company_id
|
|
|
+ jump_id = v.Company_id
|
|
|
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
|
|
|
- export_id = agency_project[company_id].ExportId
|
|
|
+ if aio.Agency[v.Company_id] != nil {
|
|
|
+ buyer_count = aio.Agency[v.Company_id].BuyerCount
|
|
|
+ project_count = aio.Agency[v.Company_id].ProjectCount
|
|
|
+ expect_amount = aio.Agency[v.Company_id].ProjectAmount
|
|
|
+ monitor_count = aio.Agency[v.Company_id].MonitorCount
|
|
|
+ export_id = aio.Agency[v.Company_id].ExportId
|
|
|
}
|
|
|
}
|
|
|
if buyer_count < in.Buyercount_start {
|
|
@@ -662,25 +636,24 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
|
|
|
export_url = "/subscribepay/network/projectExport?export_id=" + encrypt.SE.EncodeStringByCheck(strings.Join(export_id, ","))
|
|
|
}
|
|
|
url := ""
|
|
|
- company_name, _ := v["company_name"].(string)
|
|
|
- if qyxy_id := ObjToString(v["qyxy_id"]); qyxy_id != "" && (jump_type == "supplier" || jump_type == "adiffb") {
|
|
|
- url = "/swordfish/page_big_pc/ent_portrait/" + encrypt.EncodeArticleId2ByCheck(qyxy_id)
|
|
|
- } else if jump_type == "firstparty" && company_name != "" {
|
|
|
- url = "/swordfish/page_big_pc/unit_portrayal/" + company_name
|
|
|
+ if v.Qyxy_id != "" && (jump_type == "supplier" || jump_type == "adiffb") {
|
|
|
+ url = "/swordfish/page_big_pc/ent_portrait/" + encrypt.EncodeArticleId2ByCheck(v.Qyxy_id)
|
|
|
+ } else if jump_type == "firstparty" && v.Company_name != "" {
|
|
|
+ url = "/swordfish/page_big_pc/unit_portrayal/" + v.Company_name
|
|
|
}
|
|
|
list = append(list, &map[string]interface{}{
|
|
|
- "company_id": company_id,
|
|
|
- "company_name": company_name,
|
|
|
+ "company_id": v.Company_id,
|
|
|
+ "company_name": v.Company_name,
|
|
|
"type": itype,
|
|
|
"jump_type": jump_type,
|
|
|
"jump_id": jump_id,
|
|
|
- "person": v["person"],
|
|
|
- "phone": v["phone"],
|
|
|
+ "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"],
|
|
|
+ "create_time": v.Create_time,
|
|
|
"export_url": export_url,
|
|
|
"url": url,
|
|
|
})
|
|
@@ -769,7 +742,7 @@ func (n *network) FirstpartyNetwork(name string, values []string) map[string][]*
|
|
|
}
|
|
|
|
|
|
//
|
|
|
-func (n *network) Introduce_Firstparty(fpn map[string][]*firstpartyNetwork, entMonitor map[string]bool, matchme int64, probusfors []string) map[string]*projectInfo {
|
|
|
+func (n *network) Introduce_Firstparty(fpn map[string][]*firstpartyNetwork, entMonitor map[string]bool, probusfors []string) map[string]*projectInfo {
|
|
|
values := []string{}
|
|
|
vm := map[string]*projectInfo{}
|
|
|
for _, v := range fpn {
|
|
@@ -784,7 +757,7 @@ 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 matchme == 1 {
|
|
|
+ if len(probusfors) > 0 {
|
|
|
newWh, newArgs := NetworkCom.WhArgs(probusfors)
|
|
|
q += ` and hasAny(property_form,[` + newWh + `])`
|
|
|
args = append(args, newArgs...)
|
|
@@ -838,7 +811,7 @@ func (n *network) Introduce_Firstparty(fpn map[string][]*firstpartyNetwork, entM
|
|
|
}
|
|
|
|
|
|
//
|
|
|
-func (n *network) Introduce_Supplier(values []string, entMonitor map[string]bool, matchme int64, probusfors []string) map[string]*projectInfo {
|
|
|
+func (n *network) Introduce_Supplier(values []string, entMonitor map[string]bool, probusfors []string) map[string]*projectInfo {
|
|
|
if len(values) == 0 {
|
|
|
return map[string]*projectInfo{}
|
|
|
}
|
|
@@ -888,11 +861,11 @@ func (n *network) Introduce_Supplier(values []string, entMonitor map[string]bool
|
|
|
logx.Error(err)
|
|
|
}
|
|
|
}
|
|
|
- return n.MakeProjectInfo(buyers, vbs, matchme, probusfors, entMonitor)
|
|
|
+ return n.MakeProjectInfo(buyers, vbs, probusfors, entMonitor)
|
|
|
}
|
|
|
|
|
|
//
|
|
|
-func (n *network) Introduce_Agency(values []string, entMonitor map[string]bool, matchme int64, probusfors []string) map[string]*projectInfo {
|
|
|
+func (n *network) Introduce_Agency(values []string, entMonitor map[string]bool, probusfors []string) map[string]*projectInfo {
|
|
|
if len(values) == 0 {
|
|
|
return map[string]*projectInfo{}
|
|
|
}
|
|
@@ -932,17 +905,23 @@ 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, matchme, probusfors, entMonitor)
|
|
|
+ return n.MakeProjectInfo(buyers, vbs, probusfors, entMonitor)
|
|
|
}
|
|
|
|
|
|
//
|
|
|
-func (n *network) Introduce_Middleman(values []string, entMonitor map[string]bool, matchme int64, probusfors []string) map[string]*projectInfo {
|
|
|
+func (n *network) Introduce_Middleman(values []string, entMonitor map[string]bool, probusfors []string) map[string]*projectInfo {
|
|
|
result := map[string]*projectInfo{}
|
|
|
if len(values) == 0 {
|
|
|
return result
|
|
|
}
|
|
|
- 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...)
|
|
|
+ wh, args := NetworkCom.WhArgs(values)
|
|
|
+ q := `select DISTINCT project_id,project_money from information.transaction_info where project_id in (` + wh + `)`
|
|
|
+ if len(probusfors) > 0 {
|
|
|
+ newWh, newArgs := NetworkCom.WhArgs(probusfors)
|
|
|
+ q += ` and hasAny(property_form,[` + newWh + `])`
|
|
|
+ args = append(args, newArgs...)
|
|
|
+ }
|
|
|
+ rows, err := ClickhouseConn.Query(context.Background(), q, args...)
|
|
|
if err != nil {
|
|
|
logx.Error(err)
|
|
|
return nil
|
|
@@ -1033,11 +1012,11 @@ func (n *network) GetQyxyId(ids []string) map[string]string {
|
|
|
}
|
|
|
|
|
|
//
|
|
|
-func (n *network) BuyerProjectInfo(ids []string, matchme int64, probusfors []string) map[string]*projectInfo {
|
|
|
+func (n *network) BuyerProjectInfo(ids []string, probusfors []string) map[string]*projectInfo {
|
|
|
vm := map[string]*projectInfo{}
|
|
|
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 + `)`
|
|
|
- if matchme == 1 {
|
|
|
+ if len(probusfors) > 0 {
|
|
|
newWh, newArgs := NetworkCom.WhArgs(probusfors)
|
|
|
q += ` and hasAny(property_form,[` + newWh + `])`
|
|
|
args = append(args, newArgs...)
|
|
@@ -1074,8 +1053,8 @@ func (n *network) BuyerProjectInfo(ids []string, matchme int64, probusfors []str
|
|
|
}
|
|
|
|
|
|
//
|
|
|
-func (n *network) MakeProjectInfo(buyers []string, vbs map[string][]*idName, matchme int64, probusfors []string, entMonitor map[string]bool) map[string]*projectInfo {
|
|
|
- pis := n.BuyerProjectInfo(buyers, matchme, probusfors)
|
|
|
+func (n *network) MakeProjectInfo(buyers []string, vbs map[string][]*idName, probusfors []string, entMonitor map[string]bool) map[string]*projectInfo {
|
|
|
+ pis := n.BuyerProjectInfo(buyers, probusfors)
|
|
|
vm := map[string]*projectInfo{}
|
|
|
for k, v := range vbs {
|
|
|
pi := &projectInfo{
|
|
@@ -1102,3 +1081,61 @@ func (n *network) MakeProjectInfo(buyers []string, vbs map[string][]*idName, mat
|
|
|
}
|
|
|
return vm
|
|
|
}
|
|
|
+
|
|
|
+//
|
|
|
+func (n *network) AllIntroduceOwner(sqlAppend1, sqlAppend2 string, args []interface{}, isTjProject bool, probusfors []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=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...)
|
|
|
+ firstparty_array, supplier_array, adiffb_array, agency_array, middleman_project_array := []string{}, []string{}, []string{}, []string{}, []string{}
|
|
|
+ myNetworks := []*myNetwork{}
|
|
|
+ for _, v := range *listTemp {
|
|
|
+ myNetwork := &myNetwork{
|
|
|
+ Id: Int64All(v["id"]),
|
|
|
+ Company_id: ObjToString(v["company_id"]),
|
|
|
+ Company_name: ObjToString(v["company_name"]),
|
|
|
+ Qyxy_id: ObjToString(v["qyxy_id"]),
|
|
|
+ Itype: Int64All(v["itype"]),
|
|
|
+ Person: ObjToString(v["person"]),
|
|
|
+ Phone: ObjToString(v["phone"]),
|
|
|
+ Buyer_count: Int64All(v["buyer_count"]),
|
|
|
+ Project_count: Int64All(v["project_count"]),
|
|
|
+ Relate_buyer_id: ObjToString(v["relate_buyer_id"]),
|
|
|
+ Relate_project_id: ObjToString(v["relate_project_id"]),
|
|
|
+ Create_time: ObjToString(v["create_time"]),
|
|
|
+ }
|
|
|
+ switch myNetwork.Itype {
|
|
|
+ case 1:
|
|
|
+ firstparty_array = append(firstparty_array, myNetwork.Company_id)
|
|
|
+ case 2:
|
|
|
+ supplier_array = append(supplier_array, myNetwork.Company_id)
|
|
|
+ case 3:
|
|
|
+ adiffb_array = append(adiffb_array, myNetwork.Company_id)
|
|
|
+ case 4:
|
|
|
+ if myNetwork.Relate_project_id != "" {
|
|
|
+ middleman_project_array = append(middleman_project_array, strings.Split(myNetwork.Relate_project_id, ",")...)
|
|
|
+ }
|
|
|
+ case 5:
|
|
|
+ agency_array = append(agency_array, myNetwork.Company_id)
|
|
|
+ }
|
|
|
+ myNetworks = append(myNetworks, myNetwork)
|
|
|
+ }
|
|
|
+ iop := &introduceOwnerProject{
|
|
|
+ Networks: myNetworks,
|
|
|
+ FirstpartyNetwork: map[string][]*firstpartyNetwork{},
|
|
|
+ Firstparty: map[string]*projectInfo{},
|
|
|
+ Supplier: map[string]*projectInfo{},
|
|
|
+ Adiffb: map[string]*projectInfo{},
|
|
|
+ Agency: map[string]*projectInfo{},
|
|
|
+ Middleman: map[string]*projectInfo{},
|
|
|
+ }
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+ return iop
|
|
|
+}
|