|
@@ -24,26 +24,25 @@ const (
|
|
|
)
|
|
|
|
|
|
type OwnerService struct {
|
|
|
- PartyA string
|
|
|
- Supplier string
|
|
|
- Heterotophy string
|
|
|
- Intermediary string
|
|
|
- Agency string
|
|
|
- SearchEntName string
|
|
|
- SourceType string
|
|
|
- ProcessingStatus string
|
|
|
- Area string
|
|
|
- PositionId int64
|
|
|
- PageIndex int64
|
|
|
- PageSize int64
|
|
|
- BuyerId string
|
|
|
- BuyerName string
|
|
|
- WinnerId string
|
|
|
- WinnerName string
|
|
|
- CooperateType string
|
|
|
- EntAccountId int64
|
|
|
- ProjectType string
|
|
|
- Type string
|
|
|
+ PartyA string
|
|
|
+ Supplier string
|
|
|
+ Heterotophy string
|
|
|
+ Intermediary string
|
|
|
+ Agency string
|
|
|
+ SearchEntName string
|
|
|
+ SourceType string
|
|
|
+ Area string
|
|
|
+ PositionId int64
|
|
|
+ PageIndex int64
|
|
|
+ PageSize int64
|
|
|
+ BuyerId string
|
|
|
+ BuyerName string
|
|
|
+ WinnerId string
|
|
|
+ WinnerName string
|
|
|
+ CooperateType string
|
|
|
+ EntAccountId int64
|
|
|
+ ProjectType string
|
|
|
+ Type string
|
|
|
}
|
|
|
|
|
|
type BuyerProject struct {
|
|
@@ -81,6 +80,16 @@ func (t *OwnerService) OwnerlList() map[string]interface{} {
|
|
|
startTime := time.Now().Unix()
|
|
|
dataMap := &map[string]map[string]interface{}{}
|
|
|
projectMap := &map[string]map[string]interface{}{}
|
|
|
+ businessStr := FindBusiness(t.EntAccountId)
|
|
|
+ returnData, connectionsNumber, highSuccessNumber, monitorNumber := []BuyerProject{}, int64(0), int64(0), int64(0)
|
|
|
+ if businessStr == "" {
|
|
|
+ return map[string]interface{}{
|
|
|
+ "connectionsNumber": connectionsNumber,
|
|
|
+ "highSuccessNumber": highSuccessNumber,
|
|
|
+ "monitorNumber": monitorNumber,
|
|
|
+ "list": returnData,
|
|
|
+ }
|
|
|
+ }
|
|
|
if 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 {
|
|
@@ -91,8 +100,6 @@ func (t *OwnerService) OwnerlList() map[string]interface{} {
|
|
|
"list": []BuyerProject{},
|
|
|
}
|
|
|
}
|
|
|
- //处理状态初始化
|
|
|
- ProcessingStatusInit(t.PositionId, dataMap, t.ProcessingStatus)
|
|
|
//监控状态处理
|
|
|
//MonitorStatusInit(t.PositionId, dataMap, t.SourceType)
|
|
|
//项目数量查询
|
|
@@ -101,20 +108,7 @@ func (t *OwnerService) OwnerlList() map[string]interface{} {
|
|
|
buyerArr = append(buyerArr, fmt.Sprintf(`"%s"`, gconv.String(value["buyerName"])))
|
|
|
}
|
|
|
//项目数量处理
|
|
|
- projectMap, _, dataMap = ProjectHandle(buyerArr, t.EntAccountId, t.SearchEntName, t.Area, t.ProjectType, dataMap)
|
|
|
- } else if t.SearchEntName != "" {
|
|
|
- //1 只看转介绍成功率高2只看已监控的
|
|
|
- //先查找采购单位数据
|
|
|
- projectMap, dataMap, _ = ProjectHandle([]string{}, t.EntAccountId, t.SearchEntName, t.Area, t.ProjectType, dataMap)
|
|
|
- a7 := time.Now().Unix()
|
|
|
- fmt.Println("es用时", a7-startTime)
|
|
|
- ProcessingStatusInit(t.PositionId, dataMap, t.ProcessingStatus)
|
|
|
- a8 := time.Now().Unix()
|
|
|
- fmt.Println("状态用时", a8-a7)
|
|
|
- //监控状态处理
|
|
|
- /*MonitorStatusInit(t.PositionId, dataMap, t.SourceType)*/
|
|
|
- a9 := time.Now().Unix()
|
|
|
- fmt.Println("监控用时", a9-a8)
|
|
|
+ projectMap, _, dataMap = ProjectHandle(buyerArr, t.EntAccountId, t.SearchEntName, t.Area, businessStr, dataMap)
|
|
|
}
|
|
|
|
|
|
endTime := time.Now().Unix()
|
|
@@ -124,7 +118,7 @@ func (t *OwnerService) OwnerlList() map[string]interface{} {
|
|
|
}
|
|
|
//采购单位和项目合并
|
|
|
a1 := time.Now().Unix()
|
|
|
- returnData, connectionsNumber, highSuccessNumber, monitorNumber := BuyerProjectMerge(dataMap, projectMap, t.SourceType)
|
|
|
+ returnData, connectionsNumber, highSuccessNumber, monitorNumber = BuyerProjectMerge(dataMap, projectMap, t.SourceType)
|
|
|
a2 := time.Now().Unix()
|
|
|
fmt.Println("组合数据", a2-a1)
|
|
|
//数组排序
|
|
@@ -546,11 +540,6 @@ func BuyerProjectMerge(dataMap, projectMap *map[string]map[string]interface{}, s
|
|
|
if count >= 2 {
|
|
|
highSuccessNumber++
|
|
|
}
|
|
|
- /*if sourceType == "1" {
|
|
|
- if count < 2 {
|
|
|
- continue
|
|
|
- }
|
|
|
- }*/
|
|
|
returnData = append(returnData, BuyerProject{
|
|
|
BuyerId: buyerId,
|
|
|
BuyerName: buyerName,
|
|
@@ -560,12 +549,10 @@ func BuyerProjectMerge(dataMap, projectMap *map[string]map[string]interface{}, s
|
|
|
EstimatedAmount: money,
|
|
|
Connections: []map[string]interface{}{},
|
|
|
},
|
|
|
- Area: gconv.String(projectMap["area"]),
|
|
|
- Zbtime: zbtime,
|
|
|
- IsIgnore: gconv.Bool(buyerMap["isIgnore"]),
|
|
|
- IsMonitor: gconv.Bool(buyerMap["isMonitor"]),
|
|
|
- IsCreateCustomer: gconv.Bool(buyerMap["isCreateCustomer"]),
|
|
|
- CId: gconv.String(buyerMap["cId"]),
|
|
|
+ Area: gconv.String(projectMap["area"]),
|
|
|
+ Zbtime: zbtime,
|
|
|
+ IsMonitor: gconv.Bool(buyerMap["isMonitor"]),
|
|
|
+ CId: gconv.String(buyerMap["cId"]),
|
|
|
})
|
|
|
} else {
|
|
|
/*if sourceType == "1" {
|
|
@@ -582,12 +569,10 @@ func BuyerProjectMerge(dataMap, projectMap *map[string]map[string]interface{}, s
|
|
|
EstimatedAmount: 0,
|
|
|
Connections: []map[string]interface{}{},
|
|
|
},
|
|
|
- Area: "",
|
|
|
- Zbtime: 0,
|
|
|
- IsIgnore: gconv.Bool(buyerMap["isIgnore"]),
|
|
|
- IsMonitor: gconv.Bool(buyerMap["isMonitor"]),
|
|
|
- IsCreateCustomer: gconv.Bool(buyerMap["isCreateCustomer"]),
|
|
|
- CId: gconv.String(buyerMap["cId"]),
|
|
|
+ Area: "",
|
|
|
+ Zbtime: 0,
|
|
|
+ IsMonitor: gconv.Bool(buyerMap["isMonitor"]),
|
|
|
+ CId: gconv.String(buyerMap["cId"]),
|
|
|
})
|
|
|
|
|
|
}
|
|
@@ -772,31 +757,21 @@ func BuyerList(partyA, supplier, heterotophy, intermediary, agency string, posit
|
|
|
}
|
|
|
|
|
|
// 项目数量查询
|
|
|
-func ProjectHandle(buyerArr []string, entAccountId int64, entName, area, projectType string, dataMap *map[string]map[string]interface{}) (*map[string]map[string]interface{}, *map[string]map[string]interface{}, *map[string]map[string]interface{}) {
|
|
|
+func ProjectHandle(buyerArr []string, entAccountId int64, entName, area, businessStr string, dataMap *map[string]map[string]interface{}) (*map[string]map[string]interface{}, *map[string]map[string]interface{}, *map[string]map[string]interface{}) {
|
|
|
projectMap := &map[string]map[string]interface{}{}
|
|
|
returnMap := &map[string]map[string]interface{}{}
|
|
|
sql := ""
|
|
|
sqlStr := ""
|
|
|
- propertyFormStr := ""
|
|
|
- if projectType == "1" {
|
|
|
- propertyForm := ""
|
|
|
- m1 := CrmMysql.FindOne("config_tenant", map[string]interface{}{"account_id": entAccountId}, "probusfor", "")
|
|
|
- if m1 != nil && len(*m1) > 0 {
|
|
|
- propertyForm = common.ObjToString((*m1)["probusfor"])
|
|
|
- if propertyForm != "" {
|
|
|
- propertyFormStr = fmt.Sprintf(`,{"match":{"property_form":"%s"}}`, propertyForm)
|
|
|
- }
|
|
|
-
|
|
|
+ propertyFormStr := `,{"match":{"property_form":[`
|
|
|
+ for k, v := range strings.Split(businessStr, ",") {
|
|
|
+ if k > 0 {
|
|
|
+ propertyFormStr += `,`
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
- if entName != "" {
|
|
|
- sql = `{"query":{"bool":{"must_not":[{"term":{"project_bidstatus":1}}],"must":[{"multi_match":{"query":"%s","type":"phrase","fields":["buyer.mbuyer"]}}%s%s]}},"aggs":{"buyer_count":{"terms":{"field":"buyer","size":500,"order":{"zbtime_count":"desc"}},"aggs":{"area_count":{"terms":{"field":"area"}},"buyer_id":{"terms":{"field":"buyer_id"}},"money_count":{"sum":{"field":"project_money"}},"zbtime_count":{"max":{"field":"zbtime"}}}}},"size":0}`
|
|
|
- sqlStr = fmt.Sprintf(sql, entName, common.If(area != "", fmt.Sprintf(`,{"term":{"area":"%s"}}`, area), ""), common.If(projectType == "1", propertyFormStr, ""))
|
|
|
- } else {
|
|
|
- sql = `{"query":{"bool":{"must_not":[{"term":{"project_bidstatus":1}}],"must":[{"terms":{"buyer":[%s]}}%s%s]}},"aggs":{"buyer_count":{"terms":{"field":"buyer","size":500,"order":{"zbtime_count":"desc"}},"aggs":{"area_count":{"terms":{"field":"area"}},"buyer_id":{"terms":{"field":"buyer_id"}},"money_count":{"sum":{"field":"project_money"}},"zbtime_count":{"max":{"field":"zbtime"}}}}},"size":0}`
|
|
|
- sqlStr = fmt.Sprintf(sql, strings.Join(buyerArr, ","), common.If(area != "", fmt.Sprintf(`,{"term":{"area":"%s"}}`, area), ""), common.If(projectType == "1", propertyFormStr, ""))
|
|
|
+ propertyFormStr += `"` + v + `"`
|
|
|
}
|
|
|
+ propertyFormStr += `]}}`
|
|
|
+ sql = `{"query":{"bool":{"must_not":[{"term":{"project_bidstatus":1}}],"must":[{"multi_match":{"query":"%s","type":"phrase","fields":["buyer.mbuyer"]}}%s%s]}},"aggs":{"buyer_count":{"terms":{"field":"buyer","size":500,"order":{"zbtime_count":"desc"}},"aggs":{"area_count":{"terms":{"field":"area"}},"buyer_id":{"terms":{"field":"buyer_id"}},"money_count":{"sum":{"field":"project_money"}},"zbtime_count":{"max":{"field":"zbtime"}}}}},"size":0}`
|
|
|
+ sqlStr = fmt.Sprintf(sql, entName, common.If(area != "", fmt.Sprintf(`,{"term":{"area":"%s"}}`, area), ""), propertyFormStr)
|
|
|
startTime := time.Now().Unix()
|
|
|
data, _, _ := elastic.GetAggs(INDEX_1, INDEX_1, sqlStr)
|
|
|
endTime := time.Now().Unix()
|
|
@@ -842,7 +817,7 @@ func ProjectHandle(buyerArr []string, entAccountId int64, entName, area, project
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- if projectType == "1" || area != "" {
|
|
|
+ if area != "" {
|
|
|
if entName == "" {
|
|
|
for buyerId, v := range *dataMap {
|
|
|
buyerName := gconv.String(v["buyerName"])
|
|
@@ -1084,3 +1059,33 @@ func (t *OwnerService) OwnerCooperate() []map[string]interface{} {
|
|
|
}
|
|
|
return returData
|
|
|
}
|
|
|
+
|
|
|
+// 物业业务类型查询
|
|
|
+func FindBusiness(entUserId int64) string {
|
|
|
+ //先查询他的上级
|
|
|
+ entList := JianyuMysql.SelectBySql("select b.phone from entniche_user a INNER JOIN entniche_info b on a.id=? and a.ent_id =b.id ", entUserId)
|
|
|
+ if entList == nil || len(*entList) == 0 {
|
|
|
+ return ""
|
|
|
+ }
|
|
|
+ //获取手机号
|
|
|
+ phone := gconv.String((*entList)[0]["phone"])
|
|
|
+ datas, _ := Mgo.Find("user", map[string]interface{}{
|
|
|
+ "i_appid": 2,
|
|
|
+ "$or": []map[string]interface{}{
|
|
|
+ {"s_phone": phone},
|
|
|
+ {"s_m_phone": phone},
|
|
|
+ },
|
|
|
+ }, `{"s_phone":-1}`, `{"s_phone":1,"s_m_phone":1}`, false, 0, 1)
|
|
|
+ if datas != nil || len(*datas) == 0 {
|
|
|
+ return ""
|
|
|
+ }
|
|
|
+ //
|
|
|
+ if _, ok := (*datas)[0]["identity_info"]; !ok {
|
|
|
+ return ""
|
|
|
+ }
|
|
|
+ identity_info := gconv.Map((*datas)[0]["identity_info"])
|
|
|
+ if _, ok := identity_info["ent_businessType"]; !ok {
|
|
|
+ return ""
|
|
|
+ }
|
|
|
+ return gconv.String(identity_info["ent_businessType"])
|
|
|
+}
|