|
@@ -1,10 +1,8 @@
|
|
|
package report
|
|
|
|
|
|
import (
|
|
|
- "encoding/json"
|
|
|
"fmt"
|
|
|
qutil "qfw/util"
|
|
|
- "qfw/util/jy"
|
|
|
"sort"
|
|
|
"strings"
|
|
|
"time"
|
|
@@ -157,75 +155,68 @@ func (r *Report) Detail() {
|
|
|
subscribe["area"] = map[string][]string{}
|
|
|
subscribe["industry"] = []string{}
|
|
|
result["subscribe"] = subscribe
|
|
|
- userdata, ok := util.MQFW.FindById("user", userId, `{"s_m_openid":1,"a_m_openid":1,"s_phone":1,"a_mergeorder":1}`)
|
|
|
- if ok {
|
|
|
- _, dateSection := getDateSection(start, end)
|
|
|
- s_m_openid, _ := (*userdata)["s_m_openid"].(string)
|
|
|
- a_m_openid, _ := (*userdata)["a_m_openid"].(string)
|
|
|
- s_phone, _ := (*userdata)["s_phone"].(string)
|
|
|
- a_mergeorder, _ := (*userdata)["a_mergeorder"].([]interface{})
|
|
|
- openid := jy.GetOldOpenid(s_m_openid, a_m_openid, s_phone, a_mergeorder)
|
|
|
- //关注项目
|
|
|
- res, _ := util.MQFW.Find("jy_pushproject", map[string]interface{}{
|
|
|
- "id": map[string]interface{}{
|
|
|
- "$in": dateSection,
|
|
|
- },
|
|
|
- "openid": openid,
|
|
|
- }, nil, `{"pcode":1,"pname":1,"info":1}`, false, -1, 100)
|
|
|
- follow_project := *res
|
|
|
- if follow_project != nil {
|
|
|
- indexMap := map[string]int{}
|
|
|
- projects := []map[string]interface{}{}
|
|
|
- for _, v := range follow_project {
|
|
|
- projectname := qutil.ObjToString(v["pname"])
|
|
|
- if projectname == "" {
|
|
|
- projectname = qutil.ObjToString(v["pcode"])
|
|
|
- }
|
|
|
- index, ok := indexMap[projectname]
|
|
|
- //合并
|
|
|
- if ok {
|
|
|
- infos, _ := projects[index]["infos"].([]map[string]interface{})
|
|
|
- infos = append(infos, formatInfo(qutil.ObjToString(v["info"]))...)
|
|
|
- projects[index]["infos"] = infos
|
|
|
- } else {
|
|
|
- projects = append(projects, map[string]interface{}{
|
|
|
- "projectname": projectname,
|
|
|
- "infos": formatInfo(qutil.ObjToString(v["info"])),
|
|
|
- })
|
|
|
- indexMap[projectname] = len(projects) - 1
|
|
|
- }
|
|
|
+ //关注项目
|
|
|
+ res, _ := util.MQFW.Find("jy_pushproject", map[string]interface{}{
|
|
|
+ "date": map[string]interface{}{
|
|
|
+ "$gte": start,
|
|
|
+ "$lt": end + 86400,
|
|
|
+ },
|
|
|
+ "userid": userId,
|
|
|
+ }, nil, `{"pcode":1,"pname":1,"info":1}`, false, -1, 100)
|
|
|
+ follow_project := *res
|
|
|
+ if follow_project != nil {
|
|
|
+ indexMap := map[string]int{}
|
|
|
+ projects := []map[string]interface{}{}
|
|
|
+ for _, v := range follow_project {
|
|
|
+ projectname := qutil.ObjToString(v["pname"])
|
|
|
+ if projectname == "" {
|
|
|
+ projectname = qutil.ObjToString(v["pcode"])
|
|
|
+ }
|
|
|
+ index, ok := indexMap[projectname]
|
|
|
+ //合并
|
|
|
+ if ok {
|
|
|
+ infos, _ := projects[index]["infos"].([]map[string]interface{})
|
|
|
+ infos = append(infos, formatInfo(v["info"])...)
|
|
|
+ projects[index]["infos"] = infos
|
|
|
+ } else {
|
|
|
+ projects = append(projects, map[string]interface{}{
|
|
|
+ "projectname": projectname,
|
|
|
+ "infos": formatInfo(v["info"]),
|
|
|
+ })
|
|
|
+ indexMap[projectname] = len(projects) - 1
|
|
|
}
|
|
|
- result["projects"] = projects
|
|
|
}
|
|
|
- //关注企业
|
|
|
- res_ent, _ := util.MQFW.Find("jy_pushent", map[string]interface{}{
|
|
|
- "id": map[string]interface{}{
|
|
|
- "$in": dateSection,
|
|
|
- },
|
|
|
- "openid": openid,
|
|
|
- }, nil, `{"entname":1,"info":1}`, false, -1, 100)
|
|
|
- follow_ent := *res_ent
|
|
|
- if follow_ent != nil {
|
|
|
- indexMap := map[string]int{}
|
|
|
- ents := []map[string]interface{}{}
|
|
|
- for _, v := range follow_ent {
|
|
|
- entname := qutil.ObjToString(v["entname"])
|
|
|
- index, ok := indexMap[entname]
|
|
|
- //合并
|
|
|
- if ok {
|
|
|
- infos, _ := ents[index]["infos"].([]map[string]interface{})
|
|
|
- infos = append(infos, formatInfo(qutil.ObjToString(v["info"]))...)
|
|
|
- ents[index]["infos"] = infos
|
|
|
- } else {
|
|
|
- ents = append(ents, map[string]interface{}{
|
|
|
- "entname": entname,
|
|
|
- "infos": formatInfo(qutil.ObjToString(v["info"])),
|
|
|
- })
|
|
|
- indexMap[entname] = len(ents) - 1
|
|
|
- }
|
|
|
+ result["projects"] = projects
|
|
|
+ }
|
|
|
+ //关注企业
|
|
|
+ res_ent, _ := util.MQFW.Find("jy_pushent", map[string]interface{}{
|
|
|
+ "date": map[string]interface{}{
|
|
|
+ "$gte": start,
|
|
|
+ "$lt": end + 86400,
|
|
|
+ },
|
|
|
+ "userid": userId,
|
|
|
+ }, nil, `{"entname":1,"info":1}`, false, -1, 100)
|
|
|
+ follow_ent := *res_ent
|
|
|
+ if follow_ent != nil {
|
|
|
+ indexMap := map[string]int{}
|
|
|
+ ents := []map[string]interface{}{}
|
|
|
+ for _, v := range follow_ent {
|
|
|
+ entname := qutil.ObjToString(v["entname"])
|
|
|
+ index, ok := indexMap[entname]
|
|
|
+ //合并
|
|
|
+ if ok {
|
|
|
+ infos, _ := ents[index]["infos"].([]map[string]interface{})
|
|
|
+ infos = append(infos, formatInfo(v["info"])...)
|
|
|
+ ents[index]["infos"] = infos
|
|
|
+ } else {
|
|
|
+ ents = append(ents, map[string]interface{}{
|
|
|
+ "entname": entname,
|
|
|
+ "infos": formatInfo(v["info"]),
|
|
|
+ })
|
|
|
+ indexMap[entname] = len(ents) - 1
|
|
|
}
|
|
|
- result["ents"] = ents
|
|
|
}
|
|
|
+ result["ents"] = ents
|
|
|
}
|
|
|
go util.MQFW.Update("pushspace_statistic", map[string]interface{}{
|
|
|
"userid": userId,
|
|
@@ -326,11 +317,11 @@ func formatCity(area, city map[string]interface{}) AreaCitySorts {
|
|
|
}
|
|
|
|
|
|
//
|
|
|
-func formatInfo(text string) []map[string]interface{} {
|
|
|
- var relationinfo []map[string]interface{}
|
|
|
- json.Unmarshal([]byte(text), &relationinfo)
|
|
|
+func formatInfo(ri interface{}) []map[string]interface{} {
|
|
|
+ relationinfo, _ := ri.([]interface{})
|
|
|
infos := []map[string]interface{}{}
|
|
|
- for _, v := range relationinfo {
|
|
|
+ for _, vv := range relationinfo {
|
|
|
+ v, _ := vv.(map[string]interface{})
|
|
|
infotype, _ := v["s_subtype"].(string)
|
|
|
if infotype == "" {
|
|
|
infotype, _ = v["s_toptype"].(string)
|
|
@@ -354,19 +345,6 @@ func formatInfo(text string) []map[string]interface{} {
|
|
|
return infos
|
|
|
}
|
|
|
|
|
|
-func getDateSection(start, end int64) (string, []string) {
|
|
|
- array := []string{}
|
|
|
- s := time.Unix(start, 0)
|
|
|
- e := time.Unix(end, 0)
|
|
|
- for {
|
|
|
- if s.After(e) {
|
|
|
- break
|
|
|
- }
|
|
|
- array = append(array, qutil.FormatDate(&s, qutil.Date_Short_Layout))
|
|
|
- s = s.AddDate(0, 0, 1)
|
|
|
- }
|
|
|
- return `'` + strings.Join(array, `','`) + `'`, array
|
|
|
-}
|
|
|
func (r *Report) Tip() {
|
|
|
userId, _ := r.GetSession("userId").(string)
|
|
|
unread := util.MQFW.Count("pushspace_statistic", map[string]interface{}{
|