|
@@ -79,7 +79,15 @@ func (t *OwnerService) OwnerlList() map[string]interface{} {
|
|
|
dataMap := &map[string]map[string]interface{}{}
|
|
|
projectMap := &map[string]map[string]interface{}{}
|
|
|
if t.PartyA != "" || t.Supplier != "" || t.Heterotophy != "" || t.Intermediary != "" || t.Agency != "" {
|
|
|
- dataMap = BuyerList(t.PartyA, t.Supplier, t.Heterotophy, t.Intermediary, t.Agency)
|
|
|
+ dataMap = BuyerList(t.PartyA, t.Supplier, t.Heterotophy, t.Intermediary, t.Agency, t.PositionId)
|
|
|
+ if len(*dataMap) == 0 {
|
|
|
+ return map[string]interface{}{
|
|
|
+ "connectionsNumber": 0,
|
|
|
+ "highSuccessNumber": 0,
|
|
|
+ "monitorNumber": 0,
|
|
|
+ "list": []BuyerProject{},
|
|
|
+ }
|
|
|
+ }
|
|
|
//处理状态初始化
|
|
|
if t.ProcessingStatus != "" {
|
|
|
ProcessingStatusInit(t.PositionId, dataMap, t.ProcessingStatus)
|
|
@@ -202,6 +210,9 @@ func ConnectionsHandle(buyerArr []string, positionId int64, isAll bool) []map[st
|
|
|
|
|
|
// 供应商处理
|
|
|
func Findwinner(buyerArr []string, returnData []map[string]interface{}) []map[string]interface{} {
|
|
|
+ if len(buyerArr) == 0 {
|
|
|
+ return returnData
|
|
|
+ }
|
|
|
//供应商 采购单位 供应商 招标代理机构 采购单位 招标代理机构 需要计算合作次数
|
|
|
winnerSql := fmt.Sprintf(`select
|
|
|
DISTINCT
|
|
@@ -358,6 +369,9 @@ func Findwinner(buyerArr []string, returnData []map[string]interface{}) []map[st
|
|
|
|
|
|
// 中间人查询
|
|
|
func FindMiddleman(buyerArr []string, positionId int64, returnData []map[string]interface{}) []map[string]interface{} {
|
|
|
+ if len(buyerArr) == 0 {
|
|
|
+ return returnData
|
|
|
+ }
|
|
|
//中间人 作为可介绍业主 企业名称
|
|
|
companyArr := CrmMysql.SelectBySql(
|
|
|
fmt.Sprintf("select DISTINCT b.company_id,b.company_name,a.relate_id,a.relate_name,b.contact_person from connection_introduce a INNER JOIN connection b on a.position_id=%d and a.connection_id=b.id and a.relate_Id in (%s) and a.itype =1 and b.itype=4 and b.status=1 ", positionId, strings.Join(buyerArr, ",")))
|
|
@@ -382,6 +396,9 @@ func FindMiddleman(buyerArr []string, positionId int64, returnData []map[string]
|
|
|
|
|
|
// 企业之间关系查询
|
|
|
func Findfirstparty(buyerArr []string, returnData []map[string]interface{}) []map[string]interface{} {
|
|
|
+ if len(buyerArr) == 0 {
|
|
|
+ return returnData
|
|
|
+ }
|
|
|
buyerSql := fmt.Sprintf(`select DISTINCT
|
|
|
a.a_id as a_id,
|
|
|
a.b_id as b_id,
|
|
@@ -504,8 +521,11 @@ func BuyerProjectMerge(dataMap, projectMap *map[string]map[string]interface{}, s
|
|
|
EstimatedAmount: money,
|
|
|
Connections: []map[string]interface{}{},
|
|
|
},
|
|
|
- Area: gconv.String(projectMap["area"]),
|
|
|
- Zbtime: zbtime,
|
|
|
+ Area: gconv.String(projectMap["area"]),
|
|
|
+ Zbtime: zbtime,
|
|
|
+ IsIgnore: gconv.Bool(buyerMap["isIgnore"]),
|
|
|
+ IsMonitor: gconv.Bool(buyerMap["isMonitor"]),
|
|
|
+ IsCreateCustomer: gconv.Bool(buyerMap["isCreateCustomer"]),
|
|
|
})
|
|
|
} else {
|
|
|
if count > 2 {
|
|
@@ -519,8 +539,11 @@ func BuyerProjectMerge(dataMap, projectMap *map[string]map[string]interface{}, s
|
|
|
EstimatedAmount: money,
|
|
|
Connections: []map[string]interface{}{},
|
|
|
},
|
|
|
- Area: gconv.String(projectMap["area"]),
|
|
|
- Zbtime: zbtime,
|
|
|
+ Area: gconv.String(projectMap["area"]),
|
|
|
+ Zbtime: zbtime,
|
|
|
+ IsIgnore: gconv.Bool(buyerMap["isIgnore"]),
|
|
|
+ IsMonitor: gconv.Bool(buyerMap["isMonitor"]),
|
|
|
+ IsCreateCustomer: gconv.Bool(buyerMap["isCreateCustomer"]),
|
|
|
})
|
|
|
}
|
|
|
} else {
|
|
@@ -532,8 +555,11 @@ func BuyerProjectMerge(dataMap, projectMap *map[string]map[string]interface{}, s
|
|
|
EstimatedAmount: 0,
|
|
|
Connections: []map[string]interface{}{},
|
|
|
},
|
|
|
- Area: "",
|
|
|
- Zbtime: 0,
|
|
|
+ Area: "",
|
|
|
+ Zbtime: 0,
|
|
|
+ IsIgnore: false,
|
|
|
+ IsMonitor: false,
|
|
|
+ IsCreateCustomer: false,
|
|
|
})
|
|
|
}
|
|
|
connectionsNumber++
|
|
@@ -628,18 +654,17 @@ func ProcessingStatusInit(positionId int64, dataMap *map[string]map[string]inter
|
|
|
}
|
|
|
|
|
|
// 采购单位查询
|
|
|
-func BuyerList(partyA, supplier, heterotophy, intermediary, agency string) *map[string]map[string]interface{} {
|
|
|
+func BuyerList(partyA, supplier, heterotophy, intermediary, agency string, positionId int64) *map[string]map[string]interface{} {
|
|
|
dataMap := &map[string]map[string]interface{}{}
|
|
|
//甲方
|
|
|
if partyA != "" {
|
|
|
+ intermediaryArr := []string{}
|
|
|
for _, v := range strings.Split(partyA, ",") {
|
|
|
- intermediaryArr := strings.Split(v, "_")
|
|
|
- if len(intermediaryArr) == 2 {
|
|
|
- (*dataMap)[intermediaryArr[0]] = map[string]interface{}{
|
|
|
- "buyerName": intermediaryArr[1],
|
|
|
- }
|
|
|
- }
|
|
|
+ intermediaryArr = append(intermediaryArr, fmt.Sprintf("'%s'", v))
|
|
|
+
|
|
|
}
|
|
|
+ partyASql := fmt.Sprintf(`select id as buyer_id,company_name as buyer from ent_info where id in (%s)`, strings.Join(intermediaryArr, ","))
|
|
|
+ FindHandle(partyASql, dataMap)
|
|
|
}
|
|
|
//供应商 //同甲异业
|
|
|
if supplier != "" || heterotophy != "" {
|
|
@@ -655,11 +680,14 @@ func BuyerList(partyA, supplier, heterotophy, intermediary, agency string) *map[
|
|
|
}
|
|
|
//中间人
|
|
|
if intermediary != "" {
|
|
|
- for _, v := range strings.Split(intermediary, ",") {
|
|
|
- intermediaryArr := strings.Split(v, "_")
|
|
|
- if len(intermediaryArr) == 2 {
|
|
|
- (*dataMap)[intermediaryArr[0]] = map[string]interface{}{
|
|
|
- "buyerName": intermediaryArr[1],
|
|
|
+ intermediarySql := fmt.Sprintf(`select b.relate_id as relate_id,b.relate_name as relate_name from crm.connection a inner join crm.connection_introduce b on (a.position_id=%s and find_in_set(company_id,"")and a.id=b.connection_id and b.itype=1)`, gconv.String(positionId), intermediary)
|
|
|
+ intermediaryArr := CrmMysql.SelectBySql(intermediarySql)
|
|
|
+ if intermediaryArr != nil && len(*intermediaryArr) > 0 {
|
|
|
+ for _, m := range *intermediaryArr {
|
|
|
+ buyerId := gconv.String(m["relate_id"])
|
|
|
+ buyerName := gconv.String(m["relate_name"])
|
|
|
+ (*dataMap)[buyerId] = map[string]interface{}{
|
|
|
+ "buyerName": buyerName,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -766,8 +794,10 @@ func FindHandle(sqlStr string, dataMap *map[string]map[string]interface{}) {
|
|
|
for rows.Next() {
|
|
|
data := Recommend{}
|
|
|
rows.ScanStruct(&data)
|
|
|
- (*dataMap)[data.buyerId] = map[string]interface{}{
|
|
|
- "buyerName": data.buyer,
|
|
|
+ if data.buyerId != "" {
|
|
|
+ (*dataMap)[data.buyerId] = map[string]interface{}{
|
|
|
+ "buyerName": data.buyer,
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return
|
|
@@ -975,7 +1005,7 @@ func (t *OwnerService) CandidateChannel() []*ResultData {
|
|
|
returnData := []*ResultData{}
|
|
|
dataMap := &map[string]map[string]interface{}{}
|
|
|
if t.PartyA != "" || t.Supplier != "" || t.Heterotophy != "" || t.Intermediary != "" || t.Agency != "" {
|
|
|
- dataMap = BuyerList(t.PartyA, t.Supplier, t.Heterotophy, t.Intermediary, t.Agency)
|
|
|
+ dataMap = BuyerList(t.PartyA, t.Supplier, t.Heterotophy, t.Intermediary, t.Agency, t.PositionId)
|
|
|
}
|
|
|
if len(*dataMap) > 0 && dataMap != nil {
|
|
|
propertyForm := ""
|
|
@@ -1013,32 +1043,36 @@ func (t *OwnerService) CandidateChannel() []*ResultData {
|
|
|
returnData = append(returnData, &tmp)
|
|
|
}
|
|
|
}
|
|
|
- r3 := GetData1(t.PositionId, buyerId)
|
|
|
+
|
|
|
+ // 中间人可介绍业主
|
|
|
+ var r3 []map[string]interface{}
|
|
|
+ r3 = FindMiddleman([]string{buyerId}, t.PositionId, r3)
|
|
|
if r3 != nil && len(r3) > 0 {
|
|
|
for _, m := range r3 {
|
|
|
tmp := ResultData{
|
|
|
- SourceType: "middleman",
|
|
|
- EntName: common.ObjToString(m["name"]),
|
|
|
- ProjectNum: common.IntAll(m["coop_size"]),
|
|
|
- TotalAmount: common.Float64All(m["coop_amount"]),
|
|
|
+ SourceType: "middleman",
|
|
|
+ EntName: common.ObjToString(m["b_name"]),
|
|
|
+ EntPerson: common.ObjToString(m["personName"]),
|
|
|
+ Relationship: "业主的关系人",
|
|
|
}
|
|
|
returnData = append(returnData, &tmp)
|
|
|
}
|
|
|
}
|
|
|
- r4 := GetData2(buyerId)
|
|
|
+ // 关联单位
|
|
|
+ var r4 []map[string]interface{}
|
|
|
+ r4 = Findfirstparty([]string{buyerId}, r4)
|
|
|
if r4 != nil && len(r4) > 0 {
|
|
|
- for _, m := range r4 {
|
|
|
+ for _, m := range r3 {
|
|
|
tmp := ResultData{
|
|
|
- SourceType: "sup_sub",
|
|
|
- EntName: common.ObjToString(m["name"]),
|
|
|
- ProjectNum: common.IntAll(m["coop_size"]),
|
|
|
- TotalAmount: common.Float64All(m["coop_amount"]),
|
|
|
+ SourceType: "sup_sub",
|
|
|
+ EntName: common.ObjToString(m["b_name"]),
|
|
|
+ EntPerson: common.ObjToString(m["personName"]),
|
|
|
+ Relationship: common.ObjToString(m["relationship"]),
|
|
|
}
|
|
|
returnData = append(returnData, &tmp)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
return returnData
|
|
|
}
|