|
@@ -7,7 +7,6 @@ import (
|
|
|
"math"
|
|
|
"sort"
|
|
|
"strings"
|
|
|
- "sync"
|
|
|
"time"
|
|
|
|
|
|
. "app.yhyue.com/moapp/jybase/common"
|
|
@@ -74,6 +73,33 @@ type firstpartyNetwork struct {
|
|
|
CompanyName string
|
|
|
Name string
|
|
|
}
|
|
|
+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 {
|
|
@@ -83,6 +109,9 @@ func (n *network) AddOrUpdate(in *types.AddOrUpdateReq) *types.Reply {
|
|
|
if in.Type != "middleman" && in.Company_id == "" {
|
|
|
return reply
|
|
|
}
|
|
|
+ if in.Company_name == "" {
|
|
|
+ in.Company_name = "未填写"
|
|
|
+ }
|
|
|
nowFormat := NowFormat(Date_Full_Layout)
|
|
|
var saveIntroduce = func(tx *sql.Tx, cid int64, isUpdate bool) bool {
|
|
|
if in.Type != "middleman" {
|
|
@@ -255,62 +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
|
|
|
+ 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: "甲方",
|
|
@@ -334,50 +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"])
|
|
|
- if company_name == "" {
|
|
|
- company_name = "未填写"
|
|
|
+ case 2:
|
|
|
+ if aio.Supplier[v.Company_id] != nil {
|
|
|
+ ntc.Count = aio.Supplier[v.Company_id].ProjectCount
|
|
|
}
|
|
|
- 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 3:
|
|
|
+ if aio.Adiffb[v.Company_id] != nil {
|
|
|
+ ntc.Count = aio.Adiffb[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 4:
|
|
|
+ if v.Relate_project_id != "" {
|
|
|
+ for _, v := range strings.Split(v.Relate_project_id, ",") {
|
|
|
+ if aio.Middleman[v] != nil {
|
|
|
+ ntc.Count++
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- lock.Lock()
|
|
|
- count += ntc.Count
|
|
|
- list[itype-1].Count += ntc.Count
|
|
|
- list[itype-1].Children = append(list[itype-1].Children, ntc)
|
|
|
- lock.Unlock()
|
|
|
- }(vt)
|
|
|
+ case 5:
|
|
|
+ if aio.Agency[v.Company_id] != nil {
|
|
|
+ ntc.Count = aio.Agency[v.Company_id].ProjectCount
|
|
|
+ }
|
|
|
+ }
|
|
|
+ count += ntc.Count
|
|
|
+ list[v.Itype-1].Count += ntc.Count
|
|
|
+ list[v.Itype-1].Children = append(list[v.Itype-1].Children, ntc)
|
|
|
}
|
|
|
- wait.Wait()
|
|
|
}
|
|
|
convList := []map[string]interface{}{}
|
|
|
for _, v := range list {
|
|
@@ -393,25 +404,53 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
|
|
|
} else {
|
|
|
pm["SZ_LEAF"] = 1
|
|
|
}
|
|
|
- ID := ""
|
|
|
- pType := ""
|
|
|
sort.Sort(v)
|
|
|
+ id := ""
|
|
|
+ pType := ""
|
|
|
for _, vv := range v.Children {
|
|
|
- if ID != "" {
|
|
|
- ID += ","
|
|
|
- }
|
|
|
- if pType != "" {
|
|
|
- pType += ","
|
|
|
- }
|
|
|
tempId := vv.CompanyId
|
|
|
if vv.Type == "middleman" {
|
|
|
tempId = fmt.Sprint(vv.Id)
|
|
|
}
|
|
|
- ID += tempId
|
|
|
- pType += vv.Type
|
|
|
+ myChildIds, myChildTypes := "", ""
|
|
|
+ if in.Id == "" && v.Name == "甲方" {
|
|
|
+ for _, vvv := range firstpartyChild[vv.CompanyId] {
|
|
|
+ if id != "" {
|
|
|
+ id += ","
|
|
|
+ }
|
|
|
+ id += vvv.CompanyId
|
|
|
+ if pType != "" {
|
|
|
+ pType += ","
|
|
|
+ }
|
|
|
+ pType += vv.Type
|
|
|
+ if myChildIds != "" {
|
|
|
+ myChildIds += ","
|
|
|
+ }
|
|
|
+ myChildIds += vvv.CompanyId
|
|
|
+ if myChildTypes != "" {
|
|
|
+ myChildTypes += ","
|
|
|
+ }
|
|
|
+ myChildTypes += vv.Type
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if id != "" {
|
|
|
+ id += ","
|
|
|
+ }
|
|
|
+ id += tempId
|
|
|
+ if pType != "" {
|
|
|
+ pType += ","
|
|
|
+ }
|
|
|
+ pType += vv.Type
|
|
|
+ }
|
|
|
+ if myChildIds == "" {
|
|
|
+ myChildIds = tempId
|
|
|
+ }
|
|
|
+ if myChildTypes == "" {
|
|
|
+ myChildTypes = vv.Type
|
|
|
+ }
|
|
|
cm := map[string]interface{}{
|
|
|
"NAME": vv.CompanyName,
|
|
|
- "ID": tempId,
|
|
|
+ "ID": myChildIds,
|
|
|
"SZ_PID0": v.Name,
|
|
|
"SZ_PID1": v.Name + ":" + tempId,
|
|
|
"CODE": v.Name + ":" + tempId,
|
|
@@ -419,11 +458,12 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
|
|
|
"DATACOUNT": vv.Count,
|
|
|
"SZ_LEVEL": 1,
|
|
|
"SZ_LEAF": 1,
|
|
|
- "TYPE": vv.Type,
|
|
|
+ "TYPE": myChildTypes,
|
|
|
+ "MYID": tempId,
|
|
|
}
|
|
|
convList = append(convList, cm)
|
|
|
}
|
|
|
- pm["ID"] = ID
|
|
|
+ pm["ID"] = id
|
|
|
pm["TYPE"] = pType
|
|
|
convList = append(convList, pm)
|
|
|
}
|
|
@@ -438,19 +478,25 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
|
|
|
|
|
|
//人脉库-列表
|
|
|
func (n *network) List(in *types.NetWorkListReq) *types.Reply {
|
|
|
- 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=?`
|
|
|
- args := []interface{}{in.PositionId}
|
|
|
+ if in.Page_size <= 0 {
|
|
|
+ in.Page_size = 10
|
|
|
+ }
|
|
|
+ if in.Current_page <= 0 {
|
|
|
+ in.Current_page = 1
|
|
|
+ }
|
|
|
+ logx.Info(fmt.Sprintf("%+v", in))
|
|
|
+ args := []interface{}{in.PositionId, in.PositionId, in.PositionId}
|
|
|
+ sqlAppend1 := ""
|
|
|
if in.Type != "" {
|
|
|
- q += ` and a.itype=?`
|
|
|
+ sqlAppend1 += ` and a.itype=?`
|
|
|
args = append(args, n.TypeStrConvert(in.Type))
|
|
|
}
|
|
|
if in.Starttime != "" {
|
|
|
- q += ` and a.create_time>=?`
|
|
|
+ sqlAppend1 += ` and a.create_time>=?`
|
|
|
args = append(args, in.Starttime+" 00:00:00")
|
|
|
}
|
|
|
if in.Endtime != "" {
|
|
|
- q += ` and a.create_time<=?`
|
|
|
+ sqlAppend1 += ` and a.create_time<=?`
|
|
|
if in.Starttime == in.Endtime {
|
|
|
in.Endtime += " 23:59:59"
|
|
|
} else {
|
|
@@ -459,104 +505,88 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
|
|
|
args = append(args, in.Endtime)
|
|
|
}
|
|
|
if in.Name != "" {
|
|
|
- q += ` and a.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`
|
|
|
- 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"]))
|
|
|
- }
|
|
|
+ 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=?`+sqlAppend1, args...)
|
|
|
+ sqlAppend2 = ` limit ?,?`
|
|
|
+ args = append(args, start, end)
|
|
|
}
|
|
|
//
|
|
|
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
|
|
|
}
|
|
@@ -565,25 +595,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 {
|
|
@@ -606,28 +637,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 company_name == "" {
|
|
|
- company_name = "未填写"
|
|
|
- }
|
|
|
- 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,
|
|
|
})
|
|
@@ -649,29 +676,22 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
|
|
|
if in.Order_amount != 0 {
|
|
|
sort.Sort(csList)
|
|
|
}
|
|
|
- length := int64(len(csList.List))
|
|
|
- if in.Page_size <= 0 {
|
|
|
- in.Page_size = 10
|
|
|
- }
|
|
|
- total_page := int64(math.Ceil(float64(length) / float64(in.Page_size)))
|
|
|
finalList := []*map[string]interface{}{}
|
|
|
- if length > 0 {
|
|
|
- if in.Current_page <= 0 {
|
|
|
- in.Current_page = 1
|
|
|
- }
|
|
|
- if in.Current_page > total_page {
|
|
|
- in.Current_page = total_page
|
|
|
- }
|
|
|
- start := (in.Current_page - 1) * in.Page_size
|
|
|
- end := start + in.Page_size
|
|
|
- if end > length {
|
|
|
- end = length
|
|
|
+ if !dbPaging {
|
|
|
+ count = int64(len(csList.List))
|
|
|
+ if count > 0 && start < count {
|
|
|
+ if end > count {
|
|
|
+ end = count
|
|
|
+ }
|
|
|
+ finalList = csList.List[start:end]
|
|
|
}
|
|
|
- finalList = csList.List[start:end]
|
|
|
+ } else {
|
|
|
+ finalList = csList.List
|
|
|
}
|
|
|
+ total_page := int64(math.Ceil(float64(count) / float64(in.Page_size)))
|
|
|
return &types.Reply{
|
|
|
Data: map[string]interface{}{
|
|
|
- "count": length,
|
|
|
+ "count": count,
|
|
|
"total_page": total_page,
|
|
|
"firstparty_count": firstparty_count,
|
|
|
"supplier_count": supplier_count,
|
|
@@ -710,6 +730,9 @@ func (n *network) FirstpartyNetwork(name string, values []string) map[string][]*
|
|
|
logx.Error(err)
|
|
|
continue
|
|
|
}
|
|
|
+ if company_id == "" || company_name == "" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
result[a_id] = append(result[a_id], &firstpartyNetwork{
|
|
|
CompanyId: company_id,
|
|
|
CompanyName: company_name,
|
|
@@ -720,7 +743,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 {
|
|
@@ -729,9 +752,13 @@ func (n *network) Introduce_Firstparty(fpn map[string][]*firstpartyNetwork, entM
|
|
|
values = append(values, vv.CompanyId)
|
|
|
}
|
|
|
}
|
|
|
+ result := map[string]*projectInfo{}
|
|
|
+ if len(values) == 0 {
|
|
|
+ return result
|
|
|
+ }
|
|
|
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...)
|
|
@@ -765,7 +792,6 @@ func (n *network) Introduce_Firstparty(fpn map[string][]*firstpartyNetwork, entM
|
|
|
if err := rows.Err(); err != nil {
|
|
|
logx.Error(err)
|
|
|
}
|
|
|
- result := map[string]*projectInfo{}
|
|
|
for k, v := range fpn {
|
|
|
if result[k] == nil {
|
|
|
result[k] = &projectInfo{}
|
|
@@ -786,120 +812,117 @@ 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 {
|
|
|
- vm := map[string]*projectInfo{}
|
|
|
- for _, v := range values {
|
|
|
- vm[v] = &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{}
|
|
|
}
|
|
|
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),groupUniqArray(b.project_id) 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 += ` and hasAny(b.property_form,[` + newWh + `])`
|
|
|
- args = append(args, newArgs...)
|
|
|
- }
|
|
|
- q += `) group by a.winner_id`
|
|
|
+ vbs := map[string][]*idName{}
|
|
|
+ repeat := map[string]bool{}
|
|
|
+ whRepeat := map[string]map[string]bool{}
|
|
|
+ buyers := []string{}
|
|
|
+ q := `select winner_id,buyer_id,buyer from information.transaction_info where hasAny(winner_id,[` + wh + `])`
|
|
|
rows, err := ClickhouseConn.Query(context.Background(), q, args...)
|
|
|
if err != nil {
|
|
|
logx.Error(err)
|
|
|
- return nil
|
|
|
- }
|
|
|
- for rows.Next() {
|
|
|
- var (
|
|
|
- winner_id []string
|
|
|
- buyer_count uint64
|
|
|
- project_count uint64
|
|
|
- project_amount decimal.Decimal
|
|
|
- buyers []string
|
|
|
- project_id []string
|
|
|
- )
|
|
|
- if err := rows.Scan(&winner_id, &buyer_count, &project_count, &project_amount, &buyers, &project_id); err != nil {
|
|
|
- logx.Error(err)
|
|
|
- continue
|
|
|
- }
|
|
|
- for _, v := range winner_id {
|
|
|
- if vm[v] == nil {
|
|
|
+ } else {
|
|
|
+ for rows.Next() {
|
|
|
+ var (
|
|
|
+ winner_id []string
|
|
|
+ buyer_id string
|
|
|
+ buyer string
|
|
|
+ )
|
|
|
+ if err := rows.Scan(&winner_id, &buyer_id, &buyer); err != nil {
|
|
|
+ logx.Error(err)
|
|
|
continue
|
|
|
}
|
|
|
- vm[v].BuyerCount += int64(buyer_count)
|
|
|
- vm[v].ProjectCount += int64(project_count)
|
|
|
- pf, _ := project_amount.Float64()
|
|
|
- vm[v].ProjectAmount += pf
|
|
|
- vm[v].ExportId = project_id
|
|
|
- for _, v := range buyers {
|
|
|
- if entMonitor[v] {
|
|
|
- vm[v].MonitorCount++
|
|
|
+ if buyer_id == "" || buyer == "" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if !repeat[buyer_id] {
|
|
|
+ repeat[buyer_id] = true
|
|
|
+ buyers = append(buyers, buyer_id)
|
|
|
+ }
|
|
|
+ for _, v := range winner_id {
|
|
|
+ if whRepeat[v] != nil && whRepeat[v][buyer_id] {
|
|
|
+ continue
|
|
|
}
|
|
|
+ if whRepeat[v] == nil {
|
|
|
+ whRepeat[v] = map[string]bool{}
|
|
|
+ }
|
|
|
+ whRepeat[v][buyer_id] = true
|
|
|
+ vbs[v] = append(vbs[v], &idName{
|
|
|
+ Id: buyer_id,
|
|
|
+ Name: buyer,
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
+ rows.Close()
|
|
|
+ if err := rows.Err(); err != nil {
|
|
|
+ logx.Error(err)
|
|
|
+ }
|
|
|
}
|
|
|
- rows.Close()
|
|
|
- if err := rows.Err(); err != nil {
|
|
|
- logx.Error(err)
|
|
|
- }
|
|
|
- return vm
|
|
|
+ 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 {
|
|
|
- vm := map[string]*projectInfo{}
|
|
|
- for _, v := range values {
|
|
|
- vm[v] = &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{}
|
|
|
}
|
|
|
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),groupUniqArray(b.project_id) 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 += ` and hasAny(b.property_form,[` + newWh + `])`
|
|
|
- args = append(args, newArgs...)
|
|
|
- }
|
|
|
- q += `) group by a.agency_id`
|
|
|
+ q := `select DISTINCT agency_id,buyer_id,buyer from information.transaction_info where agency_id in (` + wh + `)`
|
|
|
rows, err := ClickhouseConn.Query(context.Background(), q, args...)
|
|
|
if err != nil {
|
|
|
logx.Error(err)
|
|
|
return nil
|
|
|
}
|
|
|
+ vbs := map[string][]*idName{}
|
|
|
+ buyers := []string{}
|
|
|
+ repeat := map[string]bool{}
|
|
|
for rows.Next() {
|
|
|
var (
|
|
|
- agency_id string
|
|
|
- buyer_count uint64
|
|
|
- project_count uint64
|
|
|
- project_amount decimal.Decimal
|
|
|
- buyers []string
|
|
|
- project_id []string
|
|
|
+ agency_id string
|
|
|
+ buyer_id string
|
|
|
+ buyer string
|
|
|
)
|
|
|
- if err := rows.Scan(&agency_id, &buyer_count, &project_count, &project_amount, &buyers, &project_id); err != nil {
|
|
|
+ if err := rows.Scan(&agency_id, &buyer_id, &buyer); err != nil {
|
|
|
logx.Error(err)
|
|
|
continue
|
|
|
}
|
|
|
- if vm[agency_id] == nil {
|
|
|
+ if buyer_id == "" || buyer == "" {
|
|
|
continue
|
|
|
}
|
|
|
- vm[agency_id].BuyerCount += int64(buyer_count)
|
|
|
- vm[agency_id].ProjectCount += int64(project_count)
|
|
|
- pf, _ := project_amount.Float64()
|
|
|
- vm[agency_id].ProjectAmount += pf
|
|
|
- vm[agency_id].ExportId = project_id
|
|
|
- for _, v := range buyers {
|
|
|
- if entMonitor[v] {
|
|
|
- vm[agency_id].MonitorCount++
|
|
|
- }
|
|
|
+ vbs[agency_id] = append(vbs[agency_id], &idName{
|
|
|
+ Id: buyer_id,
|
|
|
+ Name: buyer,
|
|
|
+ })
|
|
|
+ if !repeat[buyer_id] {
|
|
|
+ repeat[buyer_id] = true
|
|
|
+ buyers = append(buyers, buyer_id)
|
|
|
}
|
|
|
}
|
|
|
rows.Close()
|
|
|
if err := rows.Err(); err != nil {
|
|
|
logx.Error(err)
|
|
|
}
|
|
|
- return vm
|
|
|
+ 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 {
|
|
|
- vm := map[string]*projectInfo{}
|
|
|
- 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...)
|
|
|
+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, 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
|
|
@@ -914,7 +937,7 @@ func (n *network) Introduce_Middleman(values []string, entMonitor map[string]boo
|
|
|
continue
|
|
|
}
|
|
|
pf, _ := project_money.Float64()
|
|
|
- vm[project_id] = &projectInfo{
|
|
|
+ result[project_id] = &projectInfo{
|
|
|
ProjectAmount: pf,
|
|
|
}
|
|
|
}
|
|
@@ -922,7 +945,7 @@ func (n *network) Introduce_Middleman(values []string, entMonitor map[string]boo
|
|
|
if err := rows.Err(); err != nil {
|
|
|
logx.Error(err)
|
|
|
}
|
|
|
- return vm
|
|
|
+ return result
|
|
|
}
|
|
|
|
|
|
//
|
|
@@ -988,3 +1011,132 @@ func (n *network) GetQyxyId(ids []string) map[string]string {
|
|
|
}
|
|
|
return m
|
|
|
}
|
|
|
+
|
|
|
+//
|
|
|
+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 len(probusfors) > 0 {
|
|
|
+ newWh, newArgs := NetworkCom.WhArgs(probusfors)
|
|
|
+ q += ` and hasAny(property_form,[` + newWh + `])`
|
|
|
+ args = append(args, newArgs...)
|
|
|
+ }
|
|
|
+ q += ` group by buyer_id`
|
|
|
+ rows, err := ClickhouseConn.Query(context.Background(), q, args...)
|
|
|
+ if err != nil {
|
|
|
+ logx.Error(err)
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ for rows.Next() {
|
|
|
+ var (
|
|
|
+ buyer_id string
|
|
|
+ project_count uint64
|
|
|
+ project_amount decimal.Decimal
|
|
|
+ project_id []string
|
|
|
+ )
|
|
|
+ if err := rows.Scan(&buyer_id, &project_count, &project_amount, &project_id); err != nil {
|
|
|
+ logx.Error(err)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ pf, _ := project_amount.Float64()
|
|
|
+ vm[buyer_id] = &projectInfo{
|
|
|
+ ProjectCount: int64(project_count),
|
|
|
+ ExportId: project_id,
|
|
|
+ ProjectAmount: pf,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ rows.Close()
|
|
|
+ if err := rows.Err(); err != nil {
|
|
|
+ logx.Error(err)
|
|
|
+ }
|
|
|
+ return vm
|
|
|
+}
|
|
|
+
|
|
|
+//
|
|
|
+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{
|
|
|
+ BuyerCount: int64(len(v)),
|
|
|
+ }
|
|
|
+ re := map[string]bool{}
|
|
|
+ for _, vv := range v {
|
|
|
+ if pis[vv.Id] != nil {
|
|
|
+ pi.ProjectCount += pis[vv.Id].ProjectCount
|
|
|
+ pi.ProjectAmount += pis[vv.Id].ProjectAmount
|
|
|
+ for _, vvv := range pis[vv.Id].ExportId {
|
|
|
+ if re[vvv] {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ pi.ExportId = append(pi.ExportId, vvv)
|
|
|
+ re[vvv] = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if entMonitor[vv.Name] {
|
|
|
+ pi.MonitorCount++
|
|
|
+ }
|
|
|
+ }
|
|
|
+ vm[k] = pi
|
|
|
+ }
|
|
|
+ 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
|
|
|
+}
|