|
@@ -1,15 +1,24 @@
|
|
|
package common
|
|
|
|
|
|
import (
|
|
|
+ qutil "app.yhyue.com/moapp/jybase/common"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
+ "leadGeneration/public"
|
|
|
"leadGeneration/util"
|
|
|
"log"
|
|
|
+ "regexp"
|
|
|
+ "strings"
|
|
|
+ "time"
|
|
|
)
|
|
|
|
|
|
func (mae *MarketAnalysisEntity) AdvancedProject() map[string]interface{} {
|
|
|
finalSql := fmt.Sprintf(mae.GetCommonQuerySqlWithAggs(), projectsNumber, mae.Size, projectsSort)
|
|
|
log.Println("定制化分析报告sql查询:", finalSql)
|
|
|
+ mae.Types = 2
|
|
|
+ mae.FormatParam.SubType = []string{"拟建", "采购意向"}
|
|
|
+ mae.Size = 2
|
|
|
+ mae.FormatParam.STime = time.Now().AddDate(0, -3, 0).Unix()
|
|
|
res, _, data := util.GetAggs("bidding", "bidding", finalSql)
|
|
|
if res == nil || len(res) == 0 || data == nil || len(data) == 0 {
|
|
|
return nil
|
|
@@ -28,13 +37,86 @@ func (mae *MarketAnalysisEntity) AdvancedProject() map[string]interface{} {
|
|
|
}
|
|
|
redisData := make(map[string]interface{})
|
|
|
for _, v := range thisRow.ProjectsNumber.Buckets {
|
|
|
+ if v.DocCount == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
redisData[v.Key] = v.DocCount
|
|
|
}
|
|
|
+ if len(redisData) == 0 {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
resData := make([]map[string]interface{}, len(data))
|
|
|
for i, v := range data {
|
|
|
if json.Unmarshal(*v.Source, &resData[i]) != nil {
|
|
|
continue
|
|
|
}
|
|
|
}
|
|
|
+ log.Println("AdvancedProject redis data :", resData)
|
|
|
return nil
|
|
|
}
|
|
|
+
|
|
|
+func KeyWordFormat(userid, keyWords string) string {
|
|
|
+ var (
|
|
|
+ arryMap []map[string]interface{}
|
|
|
+ key string
|
|
|
+ )
|
|
|
+ if keyWords != "" {
|
|
|
+ var aItems []map[string]interface{}
|
|
|
+ for _, v := range strings.Split(keyWords, ",") {
|
|
|
+ arryMap = append(arryMap, map[string]interface{}{"from": 1, "appendkey": nil, "key": processKeyword(v), "notkey": nil, "updatetime": time.Now().Unix()})
|
|
|
+ }
|
|
|
+ item := map[string]interface{}{
|
|
|
+ "a_key": arryMap,
|
|
|
+ "s_item": "未分类",
|
|
|
+ "updatetime": time.Now().Unix(),
|
|
|
+ }
|
|
|
+ aItems = append(aItems, item)
|
|
|
+ dataType, _ := json.Marshal(aItems)
|
|
|
+ key = string(dataType)
|
|
|
+ } else {
|
|
|
+ data, ok := public.MQFW.FindById("user", userid, `{"o_jy":1,"o_vipjy":1,"o_member_jy":1,"i_vip_status":1,"i_member_status":1,"s_phone":1,"s_m_phone":1}`)
|
|
|
+ if ok && data != nil && len(*data) > 0 {
|
|
|
+ oJy, _ := (*data)["o_jy"].(map[string]interface{}) //免费用户关键词
|
|
|
+ vipJy, _ := (*data)["o_vipjy"].(map[string]interface{}) //超级订阅关键词
|
|
|
+ memberJy, _ := (*data)["o_member_jy"].(map[string]interface{}) //大会员关键词
|
|
|
+ var aItems []interface{}
|
|
|
+ if qutil.IntAll((*data)["i_member_status"]) > 0 {
|
|
|
+ aItems, _ = memberJy["a_items"].([]interface{})
|
|
|
+ } else if qutil.IntAll((*data)["i_vip_status"]) > 0 {
|
|
|
+ aItems, _ = vipJy["a_items"].([]interface{})
|
|
|
+ } else {
|
|
|
+ if oJy["a_key"] != nil && len(oJy["a_key"].([]interface{})) > 0 {
|
|
|
+ a_key, _ := oJy["a_key"].([]interface{})
|
|
|
+ for _, v := range a_key {
|
|
|
+ v1, _ := v.(map[string]interface{})
|
|
|
+ arryMap = append(arryMap, map[string]interface{}{"from": 1, "appendkey": nil, "key": processKeyword(qutil.InterfaceToStr(v1["key"])), "notkey": nil, "updatetime": time.Now().Unix()})
|
|
|
+ }
|
|
|
+ item := map[string]interface{}{
|
|
|
+ "a_key": arryMap,
|
|
|
+ "s_item": "未分类",
|
|
|
+ "updatetime": time.Now().Unix(),
|
|
|
+ }
|
|
|
+ aItems = append(aItems, item)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(aItems) > 0 {
|
|
|
+ dataType, _ := json.Marshal(aItems)
|
|
|
+ key = string(dataType)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return key
|
|
|
+}
|
|
|
+
|
|
|
+// 处理订阅的关键词
|
|
|
+func processKeyword(keyword string) []string {
|
|
|
+ keywordReg := regexp.MustCompile("([\\s\u3000\u2003\u00a0+,,])+")
|
|
|
+ spaceReg := regexp.MustCompile("\\s+")
|
|
|
+ keyword = keywordReg.ReplaceAllString(keyword, " ")
|
|
|
+ keyword = spaceReg.ReplaceAllString(keyword, " ")
|
|
|
+ keyword = strings.Trim(keyword, " ")
|
|
|
+ if keyword == "" {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return strings.Split(keyword, " ")
|
|
|
+}
|