|
@@ -6,6 +6,7 @@ import (
|
|
|
"db"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
+ "jfw/modules/common/src/qfw/util/jy"
|
|
|
"log"
|
|
|
qutil "qfw/util"
|
|
|
dfa "qfw/util/dfa"
|
|
@@ -22,7 +23,7 @@ import (
|
|
|
const (
|
|
|
INDEX = "forecast"
|
|
|
TYPE = "forecast"
|
|
|
- bidSearch_sort = `{"publishtime":-1}`
|
|
|
+ bidSearch_sort = `{"yucetime":-1}`
|
|
|
findfields = `"title"`
|
|
|
|
|
|
view_maxPageNum = 20
|
|
@@ -35,21 +36,75 @@ func (this *Analysis) ForPContent() {
|
|
|
defer qutil.Catch()
|
|
|
userId, _ := this.GetSession("userId").(string)
|
|
|
rData, errMsg := func() (interface{}, error) {
|
|
|
- id := this.GetString("id") //项目预测id
|
|
|
- // keys := this.GetString("keys") //关键词
|
|
|
- if id == "" { //}|| keys == "" {
|
|
|
+ id := this.GetString("id") //项目预测id
|
|
|
+ keys := this.GetString("keys") //关键词
|
|
|
+ if id == "" || keys == "" {
|
|
|
return -1, nil
|
|
|
}
|
|
|
id = util.DecodeId(id)
|
|
|
- data := elastic.GetById(INDEX, TYPE, id)
|
|
|
- if len(*data) > 0 {
|
|
|
- res := ForecastInfo{}
|
|
|
- res.Buyer = qutil.ObjToString((*data)[0]["buyer"])
|
|
|
- res.Createtime = qutil.Int64All((*data)[0]["yucetime"])
|
|
|
- // res.Purchasing = (*data)[0]["results"].([]string)
|
|
|
- res.Title = qutil.ObjToString((*data)[0]["title"])
|
|
|
- res.Jyhref = qutil.ObjToString((*data)[0]["jyhref"])
|
|
|
- return res, nil
|
|
|
+ data, ok := db.Mgo_Ent.FindById(C_FPContent, id, nil)
|
|
|
+ if ok && data != nil && (*data)["results"] != nil {
|
|
|
+ yucetime := (*data)["yucetime"]
|
|
|
+ (*data)["yucetime"] = qutil.FormatDateWithObj(&yucetime, "2006/01/02")
|
|
|
+ results := qutil.ObjArrToMapArr((*data)["results"].([]interface{}))
|
|
|
+ resultsArr := []map[string]interface{}{}
|
|
|
+ resultsMap := map[string]interface{}{}
|
|
|
+ if len(results) > 0 {
|
|
|
+ for _, rv := range results {
|
|
|
+ if rv["p_projects"] == nil {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ p_projects := qutil.ObjArrToMapArr(rv["p_projects"].([]interface{}))
|
|
|
+ for _, pv := range p_projects {
|
|
|
+ if pv["p_id"] == nil || pv["p_purchasing"] == nil {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ pv_key := qutil.ObjToString(pv["p_purchasing"])
|
|
|
+ for _, kv := range strings.Split(keys, "、") {
|
|
|
+ if strings.Contains(pv_key, kv) {
|
|
|
+ if resultsMap[pv["p_id"].(string)] != nil {
|
|
|
+ rmp := qutil.ObjToMap(resultsMap[pv["p_id"].(string)])
|
|
|
+ if qutil.ObjToString((*rmp)["p_purchasing"]) == pv_key {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ pv_key = qutil.ObjToString((*rmp)["p_purchasing"]) + "、" + pv["p_purchasing"].(string)
|
|
|
+ if pv["p_person"] == nil && (*rmp)["p_purchasing"] != nil {
|
|
|
+ pv["p_person"] = (*rmp)["p_person"]
|
|
|
+ }
|
|
|
+ if pv["p_phone"] == nil && (*rmp)["p_phone"] != nil {
|
|
|
+ pv["p_phone"] = (*rmp)["p_phone"]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resultsMap[pv["p_id"].(string)] = map[string]interface{}{
|
|
|
+ "p_purchasing": pv_key,
|
|
|
+ "p_phone": pv["p_phone"],
|
|
|
+ "p_person": pv["p_person"],
|
|
|
+ "p_id": util.EncodeId(pv["p_id"].(string)),
|
|
|
+ "p_orther": pv["p_orther"],
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if resultsMap != nil {
|
|
|
+ for _, rmv := range resultsMap {
|
|
|
+ resultsArr = append(resultsArr, *qutil.ObjToMap(rmv))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ power := []int{}
|
|
|
+ powerMap := jy.GetBigVipUserBaseMsg(userId, db.Mysql, db.Mgo).PowerMap
|
|
|
+ for k, _ := range powerMap {
|
|
|
+ power = append(power, k)
|
|
|
+ }
|
|
|
+ (*data)["power"] = power
|
|
|
+ (*data)["results"] = []map[string]interface{}{}
|
|
|
+ if len(resultsArr) > 0 {
|
|
|
+ (*data)["results"] = resultsArr
|
|
|
+ }
|
|
|
+ delete(*data, "_id")
|
|
|
+ delete(*data, "infoid")
|
|
|
+ return *data, nil
|
|
|
}
|
|
|
return 0, nil
|
|
|
}()
|
|
@@ -59,6 +114,35 @@ func (this *Analysis) ForPContent() {
|
|
|
this.ServeJson(NewResult(rData, errMsg))
|
|
|
}
|
|
|
|
|
|
+//预测详情页
|
|
|
+// func (this *Analysis) ForPContent() {
|
|
|
+// defer qutil.Catch()
|
|
|
+// userId, _ := this.GetSession("userId").(string)
|
|
|
+// rData, errMsg := func() (interface{}, error) {
|
|
|
+// id := this.GetString("id") //项目预测id
|
|
|
+// // keys := this.GetString("keys") //关键词
|
|
|
+// if id == "" { //}|| keys == "" {
|
|
|
+// return -1, nil
|
|
|
+// }
|
|
|
+// id = util.DecodeId(id)
|
|
|
+// data := elastic.GetById(INDEX, TYPE, id)
|
|
|
+// if len(*data) > 0 {
|
|
|
+// res := ForecastInfo{}
|
|
|
+// res.Buyer = qutil.ObjToString((*data)[0]["buyer"])
|
|
|
+// res.Createtime = qutil.Int64All((*data)[0]["yucetime"])
|
|
|
+// // res.Purchasing = (*data)[0]["results"].([]string)
|
|
|
+// res.Title = qutil.ObjToString((*data)[0]["title"])
|
|
|
+// res.Jyhref = qutil.ObjToString((*data)[0]["jyhref"])
|
|
|
+// return res, nil
|
|
|
+// }
|
|
|
+// return 0, nil
|
|
|
+// }()
|
|
|
+// if errMsg != nil {
|
|
|
+// log.Printf("%s 获取此预测项目信息出错-%s", userId, errMsg)
|
|
|
+// }
|
|
|
+// this.ServeJson(NewResult(rData, errMsg))
|
|
|
+// }
|
|
|
+
|
|
|
//list
|
|
|
func (this *Analysis) ForPList() {
|
|
|
defer qutil.Catch()
|
|
@@ -387,7 +471,7 @@ func GetMemberForecastSql(scd *util.ViewCondition) string {
|
|
|
}
|
|
|
|
|
|
qstr := fmt.Sprintf(query, strings.Join(musts, ","), strings.Join(bools, ","), boolsNum)
|
|
|
- // log.Println("------qstr", qstr)
|
|
|
+ log.Println("------qstr", qstr)
|
|
|
return qstr
|
|
|
}
|
|
|
|