|
@@ -1,822 +1,912 @@
|
|
|
package front
|
|
|
|
|
|
import (
|
|
|
- "jfw/config"
|
|
|
- "jfw/public"
|
|
|
- "log"
|
|
|
- . "mongodb"
|
|
|
- "qfw/util"
|
|
|
- "qfw/util/elastic"
|
|
|
- "qfw/util/redis"
|
|
|
- "qfw/util/rpc"
|
|
|
- "strings"
|
|
|
- "time"
|
|
|
-
|
|
|
- "github.com/go-xweb/xweb"
|
|
|
- "go.mongodb.org/mongo-driver/bson"
|
|
|
- "go.mongodb.org/mongo-driver/bson/primitive"
|
|
|
+ "app/jyutil"
|
|
|
+ "fmt"
|
|
|
+ "jfw/config"
|
|
|
+ "jfw/public"
|
|
|
+ "log"
|
|
|
+ . "mongodb"
|
|
|
+ "qfw/util"
|
|
|
+ "qfw/util/elastic"
|
|
|
+ "qfw/util/redis"
|
|
|
+ "qfw/util/rpc"
|
|
|
+ "strings"
|
|
|
+ "sync"
|
|
|
+ "time"
|
|
|
+
|
|
|
+ "github.com/pkg/errors"
|
|
|
+
|
|
|
+ "github.com/go-xweb/xweb"
|
|
|
+ "go.mongodb.org/mongo-driver/bson"
|
|
|
+ "go.mongodb.org/mongo-driver/bson/primitive"
|
|
|
)
|
|
|
|
|
|
type Follow struct {
|
|
|
- *xweb.Action
|
|
|
- ajaxReq xweb.Mapper `xweb:"/jyapp/follow/ajaxReq"` //关注项目ajax请求
|
|
|
- list xweb.Mapper `xweb:"/jyapp/follow/list"` //我关注的项目
|
|
|
- getList xweb.Mapper `xweb:"/jyapp/follow/getList"` //我关注的项目
|
|
|
- add xweb.Mapper `xweb:"/jyapp/follow/add"` //添加关注项目
|
|
|
- addsave xweb.Mapper `xweb:"/jyapp/follow/addsave"`
|
|
|
- set xweb.Mapper `xweb:"/jyapp/follow/set/(\\w+)/([^.]*)"`
|
|
|
- notice xweb.Mapper `xweb:"/jyapp/follow/notice/([^.]+)/([^.]*)"` //项目公告
|
|
|
- allNotice xweb.Mapper `xweb:"/jyapp/follow/allNotice"` //项目公告/(.*)
|
|
|
- visited xweb.Mapper `xweb:"/jyapp/follow/notice/visited"`
|
|
|
- photo xweb.Mapper `xweb:"/jyapp/follow/photo/(.*)"`
|
|
|
- fwsave xweb.Mapper `xweb:"/jyapp/follow/fwsave"`
|
|
|
- mylist xweb.Mapper `xweb:"/jyapp/follow/mylist"`
|
|
|
- checkFPStatus xweb.Mapper `xweb:"/jyapp/follow/checkFPStatus"`
|
|
|
- checkCStatus xweb.Mapper `xweb:"/jyapp/follow/checkCStatus"`
|
|
|
+ *xweb.Action
|
|
|
+ newList xweb.Mapper `xweb:"/jyapp/follow/list"` //我关注的项目--项目关注表合并 临时调整
|
|
|
+ detail xweb.Mapper `xweb:"/jyapp/follow/set/(\\w+)/([^.]*)"`
|
|
|
+ ajaxReq xweb.Mapper `xweb:"/jyapp/follow/ajaxReq"` //关注项目ajax请求
|
|
|
+ getList xweb.Mapper `xweb:"/jyapp/follow/getList"` //我关注的项目
|
|
|
+ add xweb.Mapper `xweb:"/jyapp/follow/add"` //添加关注项目
|
|
|
+ addsave xweb.Mapper `xweb:"/jyapp/follow/addsave"`
|
|
|
+ notice xweb.Mapper `xweb:"/jyapp/follow/notice/([^.]+)/([^.]*)"` //项目公告
|
|
|
+ allNotice xweb.Mapper `xweb:"/jyapp/follow/allNotice"` //项目公告/(.*)
|
|
|
+ visited xweb.Mapper `xweb:"/jyapp/follow/notice/visited"`
|
|
|
+ photo xweb.Mapper `xweb:"/jyapp/follow/photo/(.*)"`
|
|
|
+ fwsave xweb.Mapper `xweb:"/jyapp/follow/fwsave"`
|
|
|
+ mylist xweb.Mapper `xweb:"/jyapp/follow/mylist"`
|
|
|
+ checkFPStatus xweb.Mapper `xweb:"/jyapp/follow/checkFPStatus"`
|
|
|
+ checkCStatus xweb.Mapper `xweb:"/jyapp/follow/checkCStatus"`
|
|
|
+ //list xweb.Mapper `xweb:"/jyapp/follow/list"` //我关注的项目
|
|
|
+ //set xweb.Mapper `xweb:"/jyapp/follow/set/(\\w+)/([^.]*)"`
|
|
|
}
|
|
|
|
|
|
var followLimit int
|
|
|
|
|
|
func init() {
|
|
|
- xweb.AddAction(&Follow{})
|
|
|
- followLimit = util.IntAllDef(config.Sysconfig["followProject"], 10)
|
|
|
+ xweb.AddAction(&Follow{})
|
|
|
+ followLimit = util.IntAllDef(config.Sysconfig["followProject"], 10)
|
|
|
+}
|
|
|
+
|
|
|
+//原关注项目详情页 到大会员项目关注列表页 此处涉及到项目推送
|
|
|
+func (m *Follow) Detail(tp, id string) error {
|
|
|
+ log.Println(tp, "--", id)
|
|
|
+ return m.Redirect("/jyapp/big/page/pro_follow_list")
|
|
|
}
|
|
|
|
|
|
+//非大会员用户访问关注项目-->访问大会员的项目管理路由
|
|
|
+func (m *Follow) NewList() error {
|
|
|
+ return m.Redirect("/jyapp/big/page/pro_follow_list")
|
|
|
+}
|
|
|
+
|
|
|
+//
|
|
|
func (m *Follow) CheckFPStatus() error {
|
|
|
- defer util.Catch()
|
|
|
- s_id := util.DecodeArticleId2ByCheck(m.GetString("s_id"))[0]
|
|
|
- follows, _ := mongodb.FindById("follow_project", s_id, `{"_id":1}`)
|
|
|
- flag := "f"
|
|
|
- if follows != nil && *follows != nil && len(*follows) > 0 {
|
|
|
- flag = "t"
|
|
|
- }
|
|
|
- m.ServeJson(map[string]interface{}{
|
|
|
- "flag": flag,
|
|
|
- })
|
|
|
- return nil
|
|
|
+ defer util.Catch()
|
|
|
+ s_id := util.DecodeArticleId2ByCheck(m.GetString("s_id"))[0]
|
|
|
+ userId, _ := m.GetSession("userId").(string)
|
|
|
+ follows := public.BaseMysql.FindOne("follow_project_monitor", map[string]interface{}{"s_userid": userId, "s_id": s_id}, "_id", "")
|
|
|
+ flag := "f"
|
|
|
+ if follows != nil && *follows != nil && len(*follows) > 0 {
|
|
|
+ flag = "t"
|
|
|
+ }
|
|
|
+ m.ServeJson(map[string]interface{}{
|
|
|
+ "flag": flag,
|
|
|
+ })
|
|
|
+ return nil
|
|
|
}
|
|
|
|
|
|
func (m *Follow) CheckCStatus() error {
|
|
|
- defer util.Catch()
|
|
|
- pname := m.GetString("pcname")
|
|
|
- pcode := m.GetString("pccode")
|
|
|
- userId, _ := m.GetSession("userId").(string)
|
|
|
- flag := false
|
|
|
- followid := ""
|
|
|
- if userId != "" {
|
|
|
- flag, followid = MFollow(userId, pname, pcode, "")
|
|
|
- }
|
|
|
- m.ServeJson(map[string]interface{}{
|
|
|
- "flag": flag,
|
|
|
- "followid": followid,
|
|
|
- })
|
|
|
- return nil
|
|
|
+ defer util.Catch()
|
|
|
+ flag := false
|
|
|
+ followid := ""
|
|
|
+ if m.GetString("s_id") != "" {
|
|
|
+ sid := util.DecodeArticleId2ByCheck(m.GetString("s_id"))[0]
|
|
|
+
|
|
|
+ userId, _ := m.GetSession("userId").(string)
|
|
|
+ if userId != "" {
|
|
|
+ flag, followid = MFollow(userId, sid)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ m.ServeJson(map[string]interface{}{
|
|
|
+ "flag": flag,
|
|
|
+ "followid": followid,
|
|
|
+ })
|
|
|
+ return nil
|
|
|
}
|
|
|
|
|
|
//
|
|
|
func (m *Follow) Mylist() {
|
|
|
- defer util.Catch()
|
|
|
- id := m.GetString("id")
|
|
|
- id = util.DecodeArticleId2ByCheck(id)[0]
|
|
|
- var flag = "F"
|
|
|
- res, ok := mongodb.FindById("follow_project", id, `{"title":1}`)
|
|
|
- if ok && res != nil && len(*res) > 0 {
|
|
|
- flag = "T"
|
|
|
- }
|
|
|
- m.ServeJson(map[string]interface{}{
|
|
|
- "flag": flag,
|
|
|
- })
|
|
|
+ defer util.Catch()
|
|
|
+ id := m.GetString("id")
|
|
|
+ id = util.DecodeArticleId2ByCheck(id)[0]
|
|
|
+ var flag = "F"
|
|
|
+ res := public.BaseMysql.FindOne("follow_project_monitor", map[string]interface{}{"id": id}, "", "")
|
|
|
+ if res != nil && len(*res) > 0 {
|
|
|
+ flag = "T"
|
|
|
+ }
|
|
|
+ m.ServeJson(map[string]interface{}{
|
|
|
+ "flag": flag,
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
//关注列表关注
|
|
|
func (m *Follow) Fwsave() {
|
|
|
- defer util.Catch()
|
|
|
- userId := m.GetSession("userId").(string)
|
|
|
- var status = "n"
|
|
|
- var followId string
|
|
|
- s_id := util.DecodeArticleId2ByCheck(m.GetString("id"))[0]
|
|
|
- if mongodb.Count("follow_project", `{"s_userid":"`+userId+`"}`) >= followLimit {
|
|
|
- status = "m"
|
|
|
- } else if mongodb.Count("follow_project", `{"s_userid":"`+userId+`","s_id":"`+s_id+`"}`) > 0 {
|
|
|
- status = "e"
|
|
|
- } else {
|
|
|
- data := make(map[string]interface{})
|
|
|
- if remind, _ := m.GetInteger("remind"); remind == 1 {
|
|
|
- data["i_remind"] = 1
|
|
|
- } else {
|
|
|
- data["i_remind"] = 0
|
|
|
- }
|
|
|
- if bidopentime, err := m.GetInt("bidopentime"); err == nil {
|
|
|
- data["l_bidopentime"] = bidopentime
|
|
|
- }
|
|
|
- if remindtime, err := m.GetInt("remindtime"); err == nil {
|
|
|
- data["l_remindtime"] = remindtime
|
|
|
- }
|
|
|
- projectname := m.GetString("projectname")
|
|
|
- data["s_projectname"] = projectname
|
|
|
- data["s_userid"] = userId
|
|
|
- data["l_createtime"] = time.Now().Unix()
|
|
|
- data["s_title"] = projectname
|
|
|
- data["s_id"] = s_id
|
|
|
- data["i_source"] = 3
|
|
|
- data["toptype"] = "招标"
|
|
|
- fields := `"title","comeintime","bidopentime","projectcode","type","href","publishtime","area","subtype","toptype","industry","s_subscopeclass"`
|
|
|
- res := elastic.GetByIdField("bidding", "bidding", s_id, fields)
|
|
|
- if res != nil {
|
|
|
- projectcode, _ := (*res)["projectcode"].(string)
|
|
|
- data["s_projectcode"] = projectcode
|
|
|
- data["s_title"] = (*res)["title"]
|
|
|
- data["s_type"] = (*res)["type"]
|
|
|
- data["l_publishtime"] = (*res)["publishtime"]
|
|
|
- data["s_area"] = (*res)["area"]
|
|
|
- data["s_url"] = (*res)["href"]
|
|
|
- data["s_province"] = (*res)["area"]
|
|
|
- data["l_comeintime"] = (*res)["comeintime"]
|
|
|
- if data["l_bidopentime"] == "" {
|
|
|
- data["l_bidopentime"] = (*res)["bidopentime"]
|
|
|
- }
|
|
|
- mySelf := make(bson.M)
|
|
|
- mySelf["s_projectname"] = projectname
|
|
|
- mySelf["s_title"] = (*res)["title"]
|
|
|
- mySelf["s_projectcode"] = projectcode
|
|
|
- mySelf["s_url"] = (*res)["href"]
|
|
|
- mySelf["s_type"] = (*res)["type"]
|
|
|
- mySelf["s_subtype"] = (*res)["subtype"]
|
|
|
- mySelf["s_toptype"] = (*res)["toptype"]
|
|
|
- mySelf["s_province"] = (*res)["area"]
|
|
|
- mySelf["s_id"] = s_id
|
|
|
- mySelf["s_eid"] = util.EncodeArticleId2ByCheck(s_id)
|
|
|
- mySelf["l_publishtime"] = (*res)["publishtime"]
|
|
|
- if (*res)["industry"] == nil && (*res)["s_subscopeclass"] != nil {
|
|
|
- ind := strings.Split(util.ObjToString((*res)["s_subscopeclass"]), ",")[0]
|
|
|
- data["s_industry"] = strings.Split(ind, "_")[0]
|
|
|
- mySelf["s_industry"] = strings.Split(ind, "_")[0]
|
|
|
- } else {
|
|
|
- data["s_industry"] = (*res)["industry"]
|
|
|
- mySelf["s_industry"] = (*res)["industry"]
|
|
|
- }
|
|
|
- data["a_relationinfo"] = []map[string]interface{}{mySelf}
|
|
|
- if followId = mongodb.Save("follow_project", data); len(followId) > 0 {
|
|
|
- status = "y"
|
|
|
- go public.FollowPush(&rpc.FollowPush{
|
|
|
- ProjectName: projectname,
|
|
|
- ProjectCode: projectcode,
|
|
|
- InfoId: s_id,
|
|
|
- FollowId: followId,
|
|
|
- UserId: userId,
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- m.ServeJson(map[string]interface{}{
|
|
|
- "status": status,
|
|
|
- "followId": util.EncodeArticleId2ByCheck(followId),
|
|
|
- "infoId": util.EncodeArticleId2ByCheck(s_id),
|
|
|
- })
|
|
|
+ defer util.Catch()
|
|
|
+ userId := m.GetSession("userId").(string)
|
|
|
+ var status = "n"
|
|
|
+ var followId string
|
|
|
+ s_id := util.DecodeArticleId2ByCheck(m.GetString("id"))[0]
|
|
|
+ if public.BaseMysql.Count("follow_project_monitor", map[string]interface{}{"s_userid": userId}) >= util.Int64All(followLimit) {
|
|
|
+ status = "m"
|
|
|
+ } else if public.BaseMysql.Count("follow_project_monitor", map[string]interface{}{"s_userid": userId, "s_id": s_id}) > 0 {
|
|
|
+ status = "e"
|
|
|
+ } else {
|
|
|
+ data := make(map[string]interface{})
|
|
|
+ if remind, _ := m.GetInteger("remind"); remind == 1 {
|
|
|
+ data["i_remind"] = 1
|
|
|
+ } else {
|
|
|
+ data["i_remind"] = 0
|
|
|
+ }
|
|
|
+ if bidopentime, err := m.GetInt("bidopentime"); err == nil {
|
|
|
+ data["l_bidopentime"] = bidopentime
|
|
|
+ }
|
|
|
+ if remindtime, err := m.GetInt("remindtime"); err == nil {
|
|
|
+ data["l_remindtime"] = remindtime
|
|
|
+ }
|
|
|
+ projectname := m.GetString("projectname")
|
|
|
+ //data["s_projectname"] = projectname
|
|
|
+ data["s_userid"] = userId
|
|
|
+ data["l_createtime"] = time.Now().Unix()
|
|
|
+ data["s_title"] = projectname
|
|
|
+ data["s_id"] = s_id
|
|
|
+ //data["i_source"] = 3
|
|
|
+ //data["toptype"] = "招标"
|
|
|
+ fields := `"title","comeintime","bidopentime","projectcode","type","href","publishtime","area","subtype","toptype","industry","s_subscopeclass"`
|
|
|
+ res := elastic.GetByIdField("bidding", "bidding", s_id, fields)
|
|
|
+ if res != nil {
|
|
|
+ // projectUserKey = []string{"s_id", "s_userid", "i_remind", "l_createtime", "l_lastpushtime", "a_visited", "info_source", "s_title", "i_apppushunread", "l_bidopentime", "l_remindtime", "old_id"}
|
|
|
+ data["s_title"] = (*res)["title"]
|
|
|
+ //data["l_publishtime"] = (*res)["publishtime"]
|
|
|
+ data["l_comeintime"] = (*res)["comeintime"]
|
|
|
+ if data["l_bidopentime"] == "" {
|
|
|
+ data["l_bidopentime"] = (*res)["bidopentime"]
|
|
|
+ }
|
|
|
+
|
|
|
+ projectcode, _ := (*res)["projectcode"].(string)
|
|
|
+ if id := public.BaseMysql.Insert("follow_project_monitor", data); id > 0 {
|
|
|
+ followId = util.InterfaceToStr(id)
|
|
|
+ status = "y"
|
|
|
+ go public.FollowPush(&rpc.FollowPush{
|
|
|
+ ProjectName: projectname,
|
|
|
+ ProjectCode: projectcode,
|
|
|
+ InfoId: s_id,
|
|
|
+ FollowId: followId,
|
|
|
+ UserId: userId,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ m.ServeJson(map[string]interface{}{
|
|
|
+ "status": status,
|
|
|
+ "followId": util.EncodeArticleId2ByCheck(followId),
|
|
|
+ "infoId": util.EncodeArticleId2ByCheck(s_id),
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
//未关注项目
|
|
|
func (m *Follow) Photo(tp string) error {
|
|
|
- defer util.Catch()
|
|
|
- followid := ""
|
|
|
- tpm := strings.Split(tp, "__")
|
|
|
- projectname := tpm[1]
|
|
|
- projectcode := tpm[2]
|
|
|
- userId, _ := m.GetSession("userId").(string)
|
|
|
- if userId != "" {
|
|
|
- _, followid = MFollow(userId, projectname, projectcode, "")
|
|
|
- }
|
|
|
- //已关注
|
|
|
- if followid != "" {
|
|
|
- id := util.DecodeArticleId2ByCheck(followid)[0]
|
|
|
- fields := `{"s_id":1,"i_source":1,"s_projectname":1,"s_projectcode":1,"s_url":1,"i_remind":1,"s_type":1,"l_bidopentime":1,"l_remindtime":1,"a_relationinfo":1,"a_visited":1,"l_lastpushtime":1,"a_lastpushids":1}`
|
|
|
- _id, _ := primitive.ObjectIDFromHex(id)
|
|
|
- data, ok := mongodb.FindOneByField("follow_project", map[string]interface{}{
|
|
|
- "_id": _id,
|
|
|
- "s_userid": m.GetSession("userId").(string),
|
|
|
- }, fields)
|
|
|
- m.T["isDel"] = false
|
|
|
- if ok && (data == nil || len(*data) == 0) {
|
|
|
- data, ok = mongodb.FindOneByField("follow_project_back", `{"s_followid":"`+id+`"}`, fields)
|
|
|
- m.T["isDel"] = true
|
|
|
- }
|
|
|
- if !ok || data == nil || len(*data) == 0 {
|
|
|
- return m.Redirect("/jyapp/free/mob/err")
|
|
|
- }
|
|
|
- sid, _ := (*data)["s_id"].(string)
|
|
|
- m.T["_id"] = followid
|
|
|
- m.T["sid"] = util.EncodeArticleId2ByCheck(sid)
|
|
|
- m.T["source"] = (*data)["i_source"]
|
|
|
- m.T["projectname"] = (*data)["s_projectname"]
|
|
|
- m.T["projectcode"] = (*data)["s_projectcode"]
|
|
|
- m.T["url"] = (*data)["s_url"]
|
|
|
- m.T["remind"] = (*data)["i_remind"]
|
|
|
- m.T["type"] = (*data)["s_type"]
|
|
|
- if sid != "" {
|
|
|
- info := elastic.GetByIdField("bidding", "bidding", sid, `"type","subtype","toptype"`)
|
|
|
- info_ok := info != nil && len(*info) != 0
|
|
|
- if info_ok {
|
|
|
- m.T["subtype"] = (*info)["subtype"]
|
|
|
- m.T["toptype"] = (*info)["toptype"]
|
|
|
- m.T["type"] = (*data)["type"]
|
|
|
- }
|
|
|
- }
|
|
|
- res := util.ObjArrToMapArr((*data)["a_relationinfo"].([]interface{}))
|
|
|
- if len(res) > 0 {
|
|
|
- for _, v := range res {
|
|
|
- v["s_id"] = ""
|
|
|
- }
|
|
|
- m.T["relationinfo"] = res
|
|
|
- }
|
|
|
- m.T["a_visited"] = (*data)["a_visited"]
|
|
|
- m.T["l_lastpushtime"] = (*data)["l_lastpushtime"]
|
|
|
- m.T["a_lastpushids"] = (*data)["a_lastpushids"]
|
|
|
- l_bidopentime := (*data)["l_bidopentime"]
|
|
|
- if l_bidopentime != nil && l_bidopentime != "" && util.Int64All(l_bidopentime) != 0 {
|
|
|
- m.T["bidopentime"] = util.FormatDateWithObj(&l_bidopentime, "2006年01月02日 15时") + " " + convertWeekday(time.Unix(util.Int64All(l_bidopentime), 0).Weekday().String())
|
|
|
- m.T["l_bidopentime"] = l_bidopentime
|
|
|
- }
|
|
|
- if l_remindtime := (*data)["l_remindtime"]; l_remindtime != nil && l_remindtime != "" && util.Int64All(l_remindtime) != 0 {
|
|
|
- m.T["remindtime"] = util.FormatDateWithObj(&l_remindtime, "2006年01月02日 15时") + " " + convertWeekday(time.Unix(util.Int64All(l_remindtime), 0).Weekday().String())
|
|
|
- m.T["l_remindtime"] = l_remindtime
|
|
|
- } else if l_bidopentime != nil && l_bidopentime != "" && util.Int64All(l_bidopentime) != 0 {
|
|
|
- date := time.Unix(util.Int64All(l_bidopentime), 0).AddDate(0, 0, -1)
|
|
|
- m.T["remindtime"] = util.FormatDate(&date, "2006年01月02日 15时") + " " + convertWeekday(date.Weekday().String())
|
|
|
- m.T["l_remindtime"] = date.Unix()
|
|
|
- }
|
|
|
- } else { //未关注
|
|
|
- id := util.DecodeArticleId2ByCheck(tpm[0])[0]
|
|
|
- m.T["projectname"] = projectname
|
|
|
- m.T["projectcode"] = projectcode
|
|
|
- fields := `"_id","title","comeintime","projectcode","projectname","bidopentime","projectcode","area","toptype","subtype","type","href","publishtime","area","industry","s_subscopeclass"`
|
|
|
- data := elastic.GetByIdField("bidding", "bidding", id, fields)
|
|
|
- mySelf := make(bson.M)
|
|
|
- if data != nil && len(*data) > 0 {
|
|
|
- mySelf["s_projectname"] = projectname
|
|
|
- mySelf["s_title"] = (*data)["title"]
|
|
|
- mySelf["type"] = (*data)["type"]
|
|
|
- mySelf["subtype"] = (*data)["subtype"]
|
|
|
- mySelf["toptype"] = (*data)["toptype"]
|
|
|
- mySelf["area"] = (*data)["area"]
|
|
|
- mySelf["s_projectcode"] = projectcode
|
|
|
- mySelf["s_url"] = (*data)["href"]
|
|
|
- mySelf["s_id"] = "" //id
|
|
|
- mySelf["s_eid"] = util.EncodeArticleId2ByCheck(id)
|
|
|
- mySelf["l_publishtime"] = (*data)["publishtime"]
|
|
|
- if (*data)["industry"] == nil && (*data)["s_subscopeclass"] != nil {
|
|
|
- ind := strings.Split(util.ObjToString((*data)["s_subscopeclass"]), ",")[0]
|
|
|
- (*data)["industry"] = strings.Split(ind, "_")[0]
|
|
|
- mySelf["s_industry"] = strings.Split(ind, "_")[0]
|
|
|
- }
|
|
|
- ////////////////////////
|
|
|
- bidopentime := (*data)["bidopentime"]
|
|
|
- if bidopentime != nil && bidopentime != "" && util.Int64All(bidopentime) != 0 {
|
|
|
- m.T["bidopentime"] = util.FormatDateWithObj(&bidopentime, "2006年01月02日 15时") + " " + convertWeekday(time.Unix(util.Int64All(bidopentime), 0).Weekday().String())
|
|
|
- m.T["l_bidopentime"] = bidopentime
|
|
|
- }
|
|
|
- if remindtime := (*data)["remindtime"]; remindtime != nil && remindtime != "" && util.Int64All(remindtime) != 0 {
|
|
|
- m.T["remindtime"] = util.FormatDateWithObj(&remindtime, "2006年01月02日 15时") + " " + convertWeekday(time.Unix(util.Int64All(remindtime), 0).Weekday().String())
|
|
|
- m.T["l_remindtime"] = remindtime
|
|
|
- } else if bidopentime != nil && bidopentime != "" && util.Int64All(bidopentime) != 0 {
|
|
|
- date := time.Unix(util.Int64All(bidopentime), 0).AddDate(0, 0, -1)
|
|
|
- m.T["remindtime"] = util.FormatDate(&date, "2006年01月02日 15时") + " " + convertWeekday(date.Weekday().String())
|
|
|
- m.T["l_remindtime"] = date.Unix()
|
|
|
- }
|
|
|
- m.T["type"] = (*data)["type"]
|
|
|
- m.T["subtype"] = (*data)["subtype"]
|
|
|
- m.T["toptype"] = (*data)["toptype"]
|
|
|
- m.T["a_lastpushids"] = (*data)["a_lastpushids"]
|
|
|
- }
|
|
|
- if len(projectname) > 0 || len(projectcode) > 0 {
|
|
|
- res, _ := public.FollowPush(&rpc.FollowPush{
|
|
|
- ProjectName: projectname,
|
|
|
- ProjectCode: projectcode,
|
|
|
- InfoId: id,
|
|
|
- FollowId: "",
|
|
|
- UserId: m.GetSession("userId").(string),
|
|
|
- Flag: 1,
|
|
|
- })
|
|
|
- if len(res) > 0 {
|
|
|
- for _, v := range res {
|
|
|
- (*v)["s_eid"] = util.EncodeArticleId2ByCheck((*v)["s_id"].(string))
|
|
|
- (*v)["s_id"] = ""
|
|
|
- }
|
|
|
- m.T["data"] = res
|
|
|
- }
|
|
|
- }
|
|
|
- m.T["id"] = util.EncodeArticleId2ByCheck(id)
|
|
|
- m.T["mySelf"] = mySelf
|
|
|
- m.T["source"] = 1
|
|
|
- }
|
|
|
- return m.Render("/weixin/follow/set.html", &m.T)
|
|
|
+ defer util.Catch()
|
|
|
+ followid := ""
|
|
|
+ tpm := strings.Split(tp, "__")
|
|
|
+ projectname := tpm[1]
|
|
|
+ projectcode := tpm[2]
|
|
|
+ userId, _ := m.GetSession("userId").(string)
|
|
|
+ if userId != "" {
|
|
|
+ _, followid = MFollow(userId, tp)
|
|
|
+ }
|
|
|
+ //已关注
|
|
|
+ if followid != "" {
|
|
|
+ id := util.DecodeArticleId2ByCheck(followid)[0]
|
|
|
+ fields := `{"s_id":1,"i_source":1,"s_projectname":1,"s_projectcode":1,"s_url":1,"i_remind":1,"s_type":1,"l_bidopentime":1,"l_remindtime":1,"a_relationinfo":1,"a_visited":1,"l_lastpushtime":1,"a_lastpushids":1}`
|
|
|
+ _id, _ := primitive.ObjectIDFromHex(id)
|
|
|
+ data, ok := mongodb.FindOneByField("follow_project", map[string]interface{}{
|
|
|
+ "_id": _id,
|
|
|
+ "s_userid": m.GetSession("userId").(string),
|
|
|
+ }, fields)
|
|
|
+ m.T["isDel"] = false
|
|
|
+ if ok && (data == nil || len(*data) == 0) {
|
|
|
+ data, ok = mongodb.FindOneByField("follow_project_back", `{"s_followid":"`+id+`"}`, fields)
|
|
|
+ m.T["isDel"] = true
|
|
|
+ }
|
|
|
+ if !ok || data == nil || len(*data) == 0 {
|
|
|
+ return m.Redirect("/jyapp/free/mob/err")
|
|
|
+ }
|
|
|
+ sid, _ := (*data)["s_id"].(string)
|
|
|
+ m.T["_id"] = followid
|
|
|
+ m.T["sid"] = util.EncodeArticleId2ByCheck(sid)
|
|
|
+ m.T["source"] = (*data)["i_source"]
|
|
|
+ m.T["projectname"] = (*data)["s_projectname"]
|
|
|
+ m.T["projectcode"] = (*data)["s_projectcode"]
|
|
|
+ m.T["url"] = (*data)["s_url"]
|
|
|
+ m.T["remind"] = (*data)["i_remind"]
|
|
|
+ m.T["type"] = (*data)["s_type"]
|
|
|
+ if sid != "" {
|
|
|
+ info := elastic.GetByIdField("bidding", "bidding", sid, `"type","subtype","toptype"`)
|
|
|
+ info_ok := info != nil && len(*info) != 0
|
|
|
+ if info_ok {
|
|
|
+ m.T["subtype"] = (*info)["subtype"]
|
|
|
+ m.T["toptype"] = (*info)["toptype"]
|
|
|
+ m.T["type"] = (*data)["type"]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ res := util.ObjArrToMapArr((*data)["a_relationinfo"].([]interface{}))
|
|
|
+ if len(res) > 0 {
|
|
|
+ for _, v := range res {
|
|
|
+ v["s_id"] = ""
|
|
|
+ }
|
|
|
+ m.T["relationinfo"] = res
|
|
|
+ }
|
|
|
+ m.T["a_visited"] = (*data)["a_visited"]
|
|
|
+ m.T["l_lastpushtime"] = (*data)["l_lastpushtime"]
|
|
|
+ m.T["a_lastpushids"] = (*data)["a_lastpushids"]
|
|
|
+ l_bidopentime := (*data)["l_bidopentime"]
|
|
|
+ if l_bidopentime != nil && l_bidopentime != "" && util.Int64All(l_bidopentime) != 0 {
|
|
|
+ m.T["bidopentime"] = util.FormatDateWithObj(&l_bidopentime, "2006年01月02日 15时") + " " + convertWeekday(time.Unix(util.Int64All(l_bidopentime), 0).Weekday().String())
|
|
|
+ m.T["l_bidopentime"] = l_bidopentime
|
|
|
+ }
|
|
|
+ if l_remindtime := (*data)["l_remindtime"]; l_remindtime != nil && l_remindtime != "" && util.Int64All(l_remindtime) != 0 {
|
|
|
+ m.T["remindtime"] = util.FormatDateWithObj(&l_remindtime, "2006年01月02日 15时") + " " + convertWeekday(time.Unix(util.Int64All(l_remindtime), 0).Weekday().String())
|
|
|
+ m.T["l_remindtime"] = l_remindtime
|
|
|
+ } else if l_bidopentime != nil && l_bidopentime != "" && util.Int64All(l_bidopentime) != 0 {
|
|
|
+ date := time.Unix(util.Int64All(l_bidopentime), 0).AddDate(0, 0, -1)
|
|
|
+ m.T["remindtime"] = util.FormatDate(&date, "2006年01月02日 15时") + " " + convertWeekday(date.Weekday().String())
|
|
|
+ m.T["l_remindtime"] = date.Unix()
|
|
|
+ }
|
|
|
+ } else { //未关注
|
|
|
+ id := util.DecodeArticleId2ByCheck(tpm[0])[0]
|
|
|
+ m.T["projectname"] = projectname
|
|
|
+ m.T["projectcode"] = projectcode
|
|
|
+ fields := `"_id","title","comeintime","projectcode","projectname","bidopentime","projectcode","area","toptype","subtype","type","href","publishtime","area","industry","s_subscopeclass"`
|
|
|
+ data := elastic.GetByIdField("bidding", "bidding", id, fields)
|
|
|
+ mySelf := make(bson.M)
|
|
|
+ if data != nil && len(*data) > 0 {
|
|
|
+ mySelf["s_projectname"] = projectname
|
|
|
+ mySelf["s_title"] = (*data)["title"]
|
|
|
+ mySelf["type"] = (*data)["type"]
|
|
|
+ mySelf["subtype"] = (*data)["subtype"]
|
|
|
+ mySelf["toptype"] = (*data)["toptype"]
|
|
|
+ mySelf["area"] = (*data)["area"]
|
|
|
+ mySelf["s_projectcode"] = projectcode
|
|
|
+ mySelf["s_url"] = (*data)["href"]
|
|
|
+ mySelf["s_id"] = "" //id
|
|
|
+ mySelf["s_eid"] = util.EncodeArticleId2ByCheck(id)
|
|
|
+ mySelf["l_publishtime"] = (*data)["publishtime"]
|
|
|
+ if (*data)["industry"] == nil && (*data)["s_subscopeclass"] != nil {
|
|
|
+ ind := strings.Split(util.ObjToString((*data)["s_subscopeclass"]), ",")[0]
|
|
|
+ (*data)["industry"] = strings.Split(ind, "_")[0]
|
|
|
+ mySelf["s_industry"] = strings.Split(ind, "_")[0]
|
|
|
+ }
|
|
|
+ ////////////////////////
|
|
|
+ bidopentime := (*data)["bidopentime"]
|
|
|
+ if bidopentime != nil && bidopentime != "" && util.Int64All(bidopentime) != 0 {
|
|
|
+ m.T["bidopentime"] = util.FormatDateWithObj(&bidopentime, "2006年01月02日 15时") + " " + convertWeekday(time.Unix(util.Int64All(bidopentime), 0).Weekday().String())
|
|
|
+ m.T["l_bidopentime"] = bidopentime
|
|
|
+ }
|
|
|
+ if remindtime := (*data)["remindtime"]; remindtime != nil && remindtime != "" && util.Int64All(remindtime) != 0 {
|
|
|
+ m.T["remindtime"] = util.FormatDateWithObj(&remindtime, "2006年01月02日 15时") + " " + convertWeekday(time.Unix(util.Int64All(remindtime), 0).Weekday().String())
|
|
|
+ m.T["l_remindtime"] = remindtime
|
|
|
+ } else if bidopentime != nil && bidopentime != "" && util.Int64All(bidopentime) != 0 {
|
|
|
+ date := time.Unix(util.Int64All(bidopentime), 0).AddDate(0, 0, -1)
|
|
|
+ m.T["remindtime"] = util.FormatDate(&date, "2006年01月02日 15时") + " " + convertWeekday(date.Weekday().String())
|
|
|
+ m.T["l_remindtime"] = date.Unix()
|
|
|
+ }
|
|
|
+ m.T["type"] = (*data)["type"]
|
|
|
+ m.T["subtype"] = (*data)["subtype"]
|
|
|
+ m.T["toptype"] = (*data)["toptype"]
|
|
|
+ m.T["a_lastpushids"] = (*data)["a_lastpushids"]
|
|
|
+ }
|
|
|
+ if len(projectname) > 0 || len(projectcode) > 0 {
|
|
|
+ res, _ := public.FollowPush(&rpc.FollowPush{
|
|
|
+ ProjectName: projectname,
|
|
|
+ ProjectCode: projectcode,
|
|
|
+ InfoId: id,
|
|
|
+ FollowId: "",
|
|
|
+ UserId: m.GetSession("userId").(string),
|
|
|
+ Flag: 1,
|
|
|
+ })
|
|
|
+ if len(res) > 0 {
|
|
|
+ for _, v := range res {
|
|
|
+ (*v)["s_eid"] = util.EncodeArticleId2ByCheck((*v)["s_id"].(string))
|
|
|
+ (*v)["s_id"] = ""
|
|
|
+ }
|
|
|
+ m.T["data"] = res
|
|
|
+ }
|
|
|
+ }
|
|
|
+ m.T["id"] = util.EncodeArticleId2ByCheck(id)
|
|
|
+ m.T["mySelf"] = mySelf
|
|
|
+ m.T["source"] = 1
|
|
|
+ }
|
|
|
+ return m.Render("/weixin/follow/set.html", &m.T)
|
|
|
}
|
|
|
|
|
|
//关注项目相关的ajax请求
|
|
|
func (m *Follow) AjaxReq() {
|
|
|
- defer util.Catch()
|
|
|
- userId := m.GetSession("userId").(string)
|
|
|
- var status = "n"
|
|
|
- reqType := m.GetString("reqType")
|
|
|
- var followId string
|
|
|
- if reqType == "follow" { //快照页面关注
|
|
|
- s_id := util.DecodeArticleId2ByCheck(m.GetString("id"))[0]
|
|
|
- if mongodb.Count("follow_project", `{"s_userid":"`+userId+`"}`) >= followLimit {
|
|
|
- status = "m"
|
|
|
- } else if mongodb.Count("follow_project", `{"s_userid":"`+userId+`","s_id":"`+s_id+`"}`) > 0 {
|
|
|
- status = "e"
|
|
|
- } else {
|
|
|
- publishtime, _ := m.GetInt("publishtime")
|
|
|
- projectname := m.GetString("projectname")
|
|
|
- projectcode := m.GetString("projectcode")
|
|
|
- url := m.GetString("url")
|
|
|
- title := m.GetString("title")
|
|
|
- area := m.GetString("area")
|
|
|
- subtype := m.GetString("subtype")
|
|
|
- toptype := m.GetString("toptype")
|
|
|
- s_type := m.GetString("type")
|
|
|
- s_industry := m.GetString("industry")
|
|
|
- if projectname != "" || projectcode != "" {
|
|
|
- data := map[string]interface{}{
|
|
|
- "s_userid": userId,
|
|
|
- "s_id": s_id,
|
|
|
- "s_url": url,
|
|
|
- "s_title": title,
|
|
|
- "l_createtime": time.Now().Unix(),
|
|
|
- "i_remind": 0,
|
|
|
- "l_publishtime": publishtime,
|
|
|
- "i_source": 1,
|
|
|
- "s_province": area,
|
|
|
- "s_area": area,
|
|
|
- "s_type": s_type,
|
|
|
- "s_industry": s_industry,
|
|
|
- "toptype": "招标",
|
|
|
- }
|
|
|
- if comeintime, err := m.GetInt("comeintime"); err == nil {
|
|
|
- data["l_comeintime"] = comeintime
|
|
|
- }
|
|
|
- if s_type := m.GetString("type"); s_type != "" {
|
|
|
- data["s_type"] = s_type
|
|
|
- }
|
|
|
- if projectname != "" {
|
|
|
- data["s_projectname"] = projectname
|
|
|
- } else {
|
|
|
- data["s_projectname"] = title
|
|
|
- }
|
|
|
- if projectcode != "" {
|
|
|
- data["s_projectcode"] = projectcode
|
|
|
- }
|
|
|
- if bidopentime, err := m.GetInt("bidopentime"); err == nil && bidopentime > 0 {
|
|
|
- data["l_bidopentime"] = bidopentime
|
|
|
- }
|
|
|
- //
|
|
|
- mySelf := make(bson.M)
|
|
|
- mySelf["s_projectcode"] = projectcode
|
|
|
- mySelf["s_projectname"] = projectname
|
|
|
- mySelf["s_title"] = title
|
|
|
- mySelf["s_url"] = url
|
|
|
- mySelf["s_id"] = s_id
|
|
|
- mySelf["s_eid"] = util.EncodeArticleId2ByCheck(s_id)
|
|
|
- mySelf["l_publishtime"] = publishtime
|
|
|
- mySelf["s_province"] = area
|
|
|
- mySelf["s_subtype"] = subtype
|
|
|
- mySelf["s_toptype"] = toptype
|
|
|
- mySelf["s_type"] = s_type
|
|
|
- mySelf["s_industry"] = s_industry
|
|
|
- //
|
|
|
- data["a_relationinfo"] = []map[string]interface{}{mySelf}
|
|
|
- if followId = mongodb.Save("follow_project", data); len(followId) > 0 {
|
|
|
- status = "y"
|
|
|
- go public.FollowPush(&rpc.FollowPush{
|
|
|
- ProjectName: projectname,
|
|
|
- ProjectCode: projectcode,
|
|
|
- InfoId: s_id,
|
|
|
- FollowId: followId,
|
|
|
- UserId: userId,
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else if reqType == "cancel" { //取消关注
|
|
|
- if data, ok := mongodb.FindOne("follow_project", `{"s_userid":"`+userId+`","_id":"`+util.DecodeArticleId2ByCheck(m.GetString("id"))[0]+`"}`); ok && data != nil {
|
|
|
- (*data)["s_followid"] = BsonIdToSId((*data)["_id"])
|
|
|
- delete(*data, "_id")
|
|
|
- (*data)["i_status"] = 1
|
|
|
- mongodb.Save("follow_project_back", data)
|
|
|
- if mongodb.Del("follow_project", `{"s_userid":"`+(*data)["s_userid"].(string)+`","_id":"`+util.DecodeArticleId2ByCheck(m.GetString("id"))[0]+`"}`) {
|
|
|
- status = "y"
|
|
|
- go delRelRedis((*data)["s_userid"], (*data)["a_relationinfo"])
|
|
|
- }
|
|
|
- }
|
|
|
- } else if reqType == "followset" {
|
|
|
- id := util.DecodeArticleId2ByCheck(m.GetString("id"))[0]
|
|
|
- _id, _ := primitive.ObjectIDFromHex(id)
|
|
|
- if mongodb.Count("follow_project", map[string]interface{}{"_id": _id, "s_userid": userId}) == 1 {
|
|
|
- data := make(map[string]interface{})
|
|
|
- data["l_updatetime"] = time.Now().Unix()
|
|
|
- if remind, _ := m.GetInteger("remind"); remind == 1 {
|
|
|
- data["i_remind"] = 1
|
|
|
- } else {
|
|
|
- data["i_remind"] = 0
|
|
|
- }
|
|
|
- if bidopentime, err := m.GetInt("bidopentime"); err == nil {
|
|
|
- data["l_bidopentime"] = bidopentime
|
|
|
- }
|
|
|
- if remindtime, err := m.GetInt("remindtime"); err == nil {
|
|
|
- data["l_remindtime"] = remindtime
|
|
|
- }
|
|
|
- if mongodb.Update("follow_project", `{"_id":"`+id+`"}`, map[string]interface{}{"$set": data}, false, false) {
|
|
|
- status = "y"
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- m.ServeJson(map[string]interface{}{
|
|
|
- "status": status,
|
|
|
- "followId": util.EncodeArticleId2ByCheck(followId),
|
|
|
- })
|
|
|
+ defer util.Catch()
|
|
|
+ userId := m.GetSession("userId").(string)
|
|
|
+ var status = "n"
|
|
|
+ reqType := m.GetString("reqType")
|
|
|
+ var followId string
|
|
|
+ if reqType == "follow" { //快照页面关注
|
|
|
+ s_id := util.DecodeArticleId2ByCheck(m.GetString("id"))[0]
|
|
|
+ query := map[string]interface{}{
|
|
|
+ "s_userid": userId,
|
|
|
+ }
|
|
|
+ if public.BaseMysql.Count("follow_project_monitor", query) >= util.Int64All(followLimit) {
|
|
|
+ status = "m"
|
|
|
+ } else if public.BaseMysql.Count("follow_project_monitor", map[string]interface{}{"s_userid": userId, "s_id": s_id}) > 0 {
|
|
|
+ status = "e"
|
|
|
+ } else {
|
|
|
+ //publishtime, _ := m.GetInt("publishtime")
|
|
|
+ projectname := m.GetString("projectname")
|
|
|
+ projectcode := m.GetString("projectcode")
|
|
|
+ //url := m.GetString("url")
|
|
|
+ title := m.GetString("title")
|
|
|
+ //area := m.GetString("area")
|
|
|
+ //subtype := m.GetString("subtype")
|
|
|
+ //toptype := m.GetString("toptype")
|
|
|
+ //s_type := m.GetString("type")
|
|
|
+ //s_industry := m.GetString("industry")
|
|
|
+ if projectname != "" || projectcode != "" {
|
|
|
+ data := map[string]interface{}{
|
|
|
+ "s_userid": userId,
|
|
|
+ "s_id": s_id,
|
|
|
+ //"s_url": url,
|
|
|
+ "s_title": title,
|
|
|
+ "l_createtime": time.Now().Unix(),
|
|
|
+ "i_remind": 0,
|
|
|
+ //"l_publishtime": publishtime,
|
|
|
+ //"i_source": 1,
|
|
|
+ //"s_province": area,
|
|
|
+ //"s_area": area,
|
|
|
+ //"s_type": s_type,
|
|
|
+ //"s_industry": s_industry,
|
|
|
+ //"toptype": "招标",
|
|
|
+ }
|
|
|
+ /*if comeintime, err := m.GetInt("comeintime"); err == nil {
|
|
|
+ data["l_comeintime"] = comeintime
|
|
|
+ }
|
|
|
+ if s_type := m.GetString("type"); s_type != "" {
|
|
|
+ data["s_type"] = s_type
|
|
|
+ }
|
|
|
+ if projectname != "" {
|
|
|
+ data["s_projectname"] = projectname
|
|
|
+ } else {
|
|
|
+ data["s_projectname"] = title
|
|
|
+ }
|
|
|
+ if projectcode != "" {
|
|
|
+ data["s_projectcode"] = projectcode
|
|
|
+ }*/
|
|
|
+ if bidopentime, err := m.GetInt("bidopentime"); err == nil && bidopentime > 0 {
|
|
|
+ data["l_bidopentime"] = bidopentime
|
|
|
+ }
|
|
|
+
|
|
|
+ if followId = util.InterfaceToStr(public.BaseMysql.Insert("follow_project_monitor", data)); len(followId) > 0 {
|
|
|
+ status = "y"
|
|
|
+ go public.FollowPush(&rpc.FollowPush{
|
|
|
+ ProjectName: projectname,
|
|
|
+ ProjectCode: projectcode,
|
|
|
+ InfoId: s_id,
|
|
|
+ FollowId: followId,
|
|
|
+ UserId: userId,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if reqType == "cancel" { //取消关注
|
|
|
+ query := map[string]interface{}{
|
|
|
+ "s_userid": userId,
|
|
|
+ "id": util.DecodeArticleId2ByCheck(m.GetString("_id"))[0],
|
|
|
+ }
|
|
|
+ if data := public.BaseMysql.FindOne("follow_project_monitor", query, "", ""); data != nil {
|
|
|
+ (*data)["s_followid"] = util.InterfaceToStr((*data)["id"])
|
|
|
+ delete(*data, "id")
|
|
|
+ (*data)["i_status"] = 1
|
|
|
+ mongodb.Save("follow_project_monitor_back", data)
|
|
|
+ if public.BaseMysql.Delete("follow_project_monitor", query) {
|
|
|
+ status = "y"
|
|
|
+ go delRelRedis((*data)["s_userid"], []interface{}{(*data)["s_id"]})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if reqType == "followset" {
|
|
|
+ id := util.DecodeArticleId2ByCheck(m.GetString("id"))[0]
|
|
|
+ if public.BaseMysql.Count("follow_project_monitor", map[string]interface{}{"id": id, "s_userid": userId}) == 1 {
|
|
|
+
|
|
|
+ data := make(map[string]interface{})
|
|
|
+ data["l_updatetime"] = time.Now().Unix()
|
|
|
+ if remind, _ := m.GetInteger("remind"); remind == 1 {
|
|
|
+ data["i_remind"] = 1
|
|
|
+ } else {
|
|
|
+ data["i_remind"] = 0
|
|
|
+ }
|
|
|
+ if bidopentime, err := m.GetInt("bidopentime"); err == nil {
|
|
|
+ data["l_bidopentime"] = bidopentime
|
|
|
+ }
|
|
|
+ if remindtime, err := m.GetInt("remindtime"); err == nil {
|
|
|
+ data["l_remindtime"] = remindtime
|
|
|
+ }
|
|
|
+ if public.BaseMysql.Update("follow_project_monitor", map[string]interface{}{"id": id}, data) {
|
|
|
+ status = "y"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ m.ServeJson(map[string]interface{}{
|
|
|
+ "status": status,
|
|
|
+ "followId": util.EncodeArticleId2ByCheck(followId),
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
//我关注的项目
|
|
|
func (m *Follow) List() error {
|
|
|
- m.T["followLimit"] = followLimit
|
|
|
- return m.Render("/weixin/follow/list.html", &m.T)
|
|
|
+ m.T["followLimit"] = followLimit
|
|
|
+ return m.Render("/weixin/follow/list.html", &m.T)
|
|
|
}
|
|
|
func (m *Follow) GetList() {
|
|
|
- userId := util.ObjToString(m.Session().Get("userId"))
|
|
|
- if userId == "" {
|
|
|
- log.Println("查询我关注的项目出错,userid为空")
|
|
|
- }
|
|
|
- datas, ok := mongodb.Find("follow_project", `{"s_userid":"`+userId+`"}`, `{"l_lastpushtime":-1,"l_createtime":-1}`, `{"s_projectname":1,"s_projectcode":1,"i_remind":1,"l_lastpushtime":1,"l_createtime":1,"s_industry":1,"s_area":1,i_apppushunread":1}`, false, -1, -1)
|
|
|
- flag := false
|
|
|
- if ok && datas != nil && len(*datas) > 0 {
|
|
|
- for _, v := range *datas {
|
|
|
- v["followid"] = BsonIdToSId(v["_id"])
|
|
|
- v["_id"] = util.EncodeArticleId2ByCheck(BsonIdToSId(v["_id"]))
|
|
|
- if v["l_lastpushtime"] == "" || v["l_lastpushtime"] == nil {
|
|
|
- v["l_lastpushtime"] = v["l_createtime"]
|
|
|
- }
|
|
|
- }
|
|
|
- m.T["datas"] = datas
|
|
|
- if len(*datas) >= followLimit {
|
|
|
- flag = true
|
|
|
- }
|
|
|
- }
|
|
|
- m.ServeJson(map[string]interface{}{
|
|
|
- "flag": flag,
|
|
|
- "list": datas,
|
|
|
- })
|
|
|
+ userId := util.ObjToString(m.Session().Get("userId"))
|
|
|
+ if userId == "" {
|
|
|
+ log.Println("查询我关注的项目出错,userid为空")
|
|
|
+ }
|
|
|
+ log.Println(userId, "---", util.IntAll(config.Sysconfig["followProject"]))
|
|
|
+ datas := public.BaseMysql.SelectBySql(`SELECT * FROM follow_project_monitor WHERE s_userid =? ORDER BY l_lastpushtime,l_createtime DESC LIMIT 0,?`, userId, util.IntAll(config.Sysconfig["followProject"]))
|
|
|
+ log.Println("datas:", datas)
|
|
|
+ //datas, ok := mongodb.Find("follow_project", `{"s_userid":"`+userId+`"}`, `{"l_lastpushtime":-1,"l_createtime":-1}`, `{"s_projectname":1,"s_projectcode":1,"i_remind":1,"l_lastpushtime":1,"l_createtime":1,"s_industry":1,"s_area":1,i_apppushunread":1}`, false, -1, -1)
|
|
|
+ flag := false
|
|
|
+ var followData []map[string]interface{}
|
|
|
+ if datas != nil && len(*datas) > 0 {
|
|
|
+ sidArr := []string{}
|
|
|
+ followSetting := map[string]map[string]interface{}{}
|
|
|
+ for _, followOne := range *datas {
|
|
|
+ sid := util.ObjToString(followOne["s_id"])
|
|
|
+ if followOne["l_lastpushtime"] != nil && util.ObjToString(followOne["l_lastpushtime"]) != "" {
|
|
|
+ followOne["l_createtime"] = followOne["l_lastpushtime"]
|
|
|
+ } else if followOne["l_lastpushtime"] == nil {
|
|
|
+ followOne["l_lastpushtime"] = followOne["l_createtime"]
|
|
|
+ }
|
|
|
+ sidArr = append(sidArr, sid)
|
|
|
+ followSetting[sid] = followOne
|
|
|
+ }
|
|
|
+
|
|
|
+ projectInfos := []map[string]interface{}{}
|
|
|
+ pool := make(chan bool, 10)
|
|
|
+ wait := &sync.WaitGroup{}
|
|
|
+ var lock sync.Mutex
|
|
|
+ for _, v := range SplitArray(sidArr, 50) {
|
|
|
+ pool <- true
|
|
|
+ wait.Add(1)
|
|
|
+ go func(arr []string) error {
|
|
|
+ defer func() {
|
|
|
+ wait.Done()
|
|
|
+ <-pool
|
|
|
+ }()
|
|
|
+ //es查询
|
|
|
+ projectInfos_, err := getProjectsBySid(arr)
|
|
|
+ lock.Lock()
|
|
|
+ projectInfos = append(projectInfos, projectInfos_...)
|
|
|
+ lock.Unlock()
|
|
|
+ if err != nil {
|
|
|
+ err = errors.New("项目信息查询异常")
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+ }(v)
|
|
|
+ }
|
|
|
+ wait.Wait()
|
|
|
+
|
|
|
+ for _, projectinfo := range projectInfos { //补充设置信息
|
|
|
+ for _, k := range util.ObjArrToStringArr(projectinfo["ids"].([]interface{})) {
|
|
|
+ if info, ok := followSetting[k]; ok {
|
|
|
+ info["s_area"] = projectinfo["area"]
|
|
|
+ info["s_buyerclass"] = projectinfo["buyerclass"]
|
|
|
+ info["s_budget"] = util.Float64All(projectinfo["budget"])
|
|
|
+ info["s_title"] = projectinfo["projectname"]
|
|
|
+ info["s_projectname"] = projectinfo["projectname"]
|
|
|
+ info["toptype"] = projectinfo["bidstatus"]
|
|
|
+ info["s_projectcode"] = projectinfo["projectcode"]
|
|
|
+ if projectinfo["topscopeclass"] != nil && len(projectinfo["topscopeclass"].([]interface{})) > 0 {
|
|
|
+ topscopeclass, _ := projectinfo["topscopeclass"].([]interface{})
|
|
|
+ info["s_industry"] = topscopeclass[0]
|
|
|
+ }
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, sid := range sidArr {
|
|
|
+ thisRow := followSetting[sid]
|
|
|
+ fid := util.InterfaceToStr(thisRow["id"])
|
|
|
+ thisRow["id"] = fid
|
|
|
+ if thisRow["s_title"] == nil {
|
|
|
+ log.Println("异常数据:", sid, fid)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ delete(thisRow, "s_id")
|
|
|
+ followData = append(followData, thisRow)
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range followData {
|
|
|
+ v["followid"] = util.InterfaceToStr(v["id"])
|
|
|
+ v["_id"] = util.EncodeArticleId2ByCheck(util.InterfaceToStr(v["id"]))
|
|
|
+ if v["l_lastpushtime"] == "" || v["l_lastpushtime"] == nil {
|
|
|
+ v["l_lastpushtime"] = v["l_createtime"]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ m.T["datas"] = followData
|
|
|
+ if len(*datas) >= followLimit {
|
|
|
+ flag = true
|
|
|
+ }
|
|
|
+ m.ServeJson(map[string]interface{}{
|
|
|
+ "flag": flag,
|
|
|
+ "list": followData,
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
//添加关注项目
|
|
|
func (m *Follow) Add() error {
|
|
|
- return m.Render("/weixin/follow/add.html")
|
|
|
+ return m.Render("/weixin/follow/add.html")
|
|
|
}
|
|
|
|
|
|
//手动添加关注项目
|
|
|
func (m *Follow) Addsave() error {
|
|
|
- defer util.Catch()
|
|
|
- var status = "n"
|
|
|
- var id string
|
|
|
- userId := m.GetSession("userId").(string)
|
|
|
- if mongodb.Count("follow_project", `{"s_userid":"`+userId+`"}`) >= followLimit {
|
|
|
- status = "m"
|
|
|
- } else {
|
|
|
- if projectname := m.GetString("projectname"); projectname != "" {
|
|
|
- data := map[string]interface{}{
|
|
|
- "s_userid": userId,
|
|
|
- "s_projectname": projectname,
|
|
|
- "l_createtime": time.Now().Unix(),
|
|
|
- "i_remind": 0,
|
|
|
- "s_title": projectname,
|
|
|
- "i_source": 2,
|
|
|
- "toptype": "招标",
|
|
|
- }
|
|
|
- //匹配
|
|
|
- r := elastic.GetPage("bidding", "bidding", `{"TERM_projectname":"`+projectname+`"}`, `{"comeintime":-1}`, `"_id","title","comeintime","bidopentime","projectcode","type","href","publishtime","subtype","toptype","area","industry","s_subscopeclass"`, -1, -1)
|
|
|
- var matchingFlag = r != nil && len(*r) != 0
|
|
|
- var projectcode, sid string
|
|
|
- if matchingFlag {
|
|
|
- d := (*r)[0]
|
|
|
- sid = d["_id"].(string) //(d["_id"].(bson.ObjectId)).Hex()
|
|
|
- data["s_id"] = sid
|
|
|
- data["l_comeintime"] = d["comeintime"]
|
|
|
- publishtime := d["publishtime"]
|
|
|
- data["l_publishtime"] = publishtime
|
|
|
- data["s_title"] = d["title"]
|
|
|
- data["s_area"] = d["area"]
|
|
|
- data["s_province"] = d["area"]
|
|
|
- if bidopentime := d["bidopentime"]; bidopentime != nil {
|
|
|
- data["l_bidopentime"] = bidopentime
|
|
|
- }
|
|
|
- if d["projectcode"] != nil {
|
|
|
- projectcode = d["projectcode"].(string)
|
|
|
- data["s_projectcode"] = projectcode
|
|
|
- }
|
|
|
- if s_type := d["type"]; s_type != nil {
|
|
|
- data["s_type"] = s_type
|
|
|
- }
|
|
|
- url := d["href"].(string)
|
|
|
- data["s_url"] = url
|
|
|
- //
|
|
|
- mySelf := make(bson.M)
|
|
|
- mySelf["s_type"] = util.ObjToString(d["type"])
|
|
|
- mySelf["s_toptype"] = util.ObjToString(d["toptype"])
|
|
|
- mySelf["s_subtype"] = util.ObjToString(d["subtype"])
|
|
|
- mySelf["s_province"] = util.ObjToString(d["area"])
|
|
|
- mySelf["s_projectname"] = projectname
|
|
|
- mySelf["s_title"] = d["title"]
|
|
|
- mySelf["s_projectcode"] = projectcode
|
|
|
- mySelf["s_url"] = url
|
|
|
- mySelf["s_id"] = sid
|
|
|
- mySelf["s_eid"] = util.EncodeArticleId2ByCheck(sid)
|
|
|
- mySelf["l_publishtime"] = publishtime
|
|
|
- if d["industry"] == nil && d["s_subscopeclass"] != nil {
|
|
|
- ind := strings.Split(util.ObjToString(d["s_subscopeclass"]), ",")[0]
|
|
|
- data["s_industry"] = strings.Split(ind, "_")[0]
|
|
|
- mySelf["s_industry"] = strings.Split(ind, "_")[0]
|
|
|
- } else {
|
|
|
- data["s_industry"] = d["industry"]
|
|
|
- mySelf["s_industry"] = d["industry"]
|
|
|
- }
|
|
|
- data["a_relationinfo"] = []map[string]interface{}{mySelf}
|
|
|
- }
|
|
|
- if id = mongodb.Save("follow_project", data); len(id) > 0 {
|
|
|
- status = "y"
|
|
|
- go public.FollowPush(&rpc.FollowPush{
|
|
|
- ProjectName: projectname,
|
|
|
- ProjectCode: projectcode,
|
|
|
- InfoId: sid,
|
|
|
- FollowId: id,
|
|
|
- UserId: userId,
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- m.ServeJson(map[string]interface{}{
|
|
|
- "status": status,
|
|
|
- "id": util.EncodeArticleId2ByCheck(id),
|
|
|
- })
|
|
|
- return nil
|
|
|
+ defer util.Catch()
|
|
|
+ var status = "n"
|
|
|
+ var id string
|
|
|
+ userId := m.GetSession("userId").(string)
|
|
|
+ query := map[string]interface{}{
|
|
|
+ "s_userid": userId,
|
|
|
+ }
|
|
|
+ if public.BaseMysql.Count("follow_project_monitor", query) >= util.Int64All(followLimit) {
|
|
|
+ status = "m"
|
|
|
+ } else {
|
|
|
+ // "s_id": sid, //信息id
|
|
|
+ // "s_userid": this.UserId, //用户id
|
|
|
+ // "i_remind": 0, //开标提醒
|
|
|
+ // "l_createtime": nowTimeStamp, //关注时间
|
|
|
+ // "l_lastpushtime": nowTimeStamp, //关注时间
|
|
|
+ // "a_visited": "", //浏览记录
|
|
|
+ if projectname := m.GetString("projectname"); projectname != "" {
|
|
|
+ data := map[string]interface{}{
|
|
|
+ "s_userid": userId,
|
|
|
+ "l_createtime": time.Now().Unix(),
|
|
|
+ "i_remind": 0,
|
|
|
+ "s_title": projectname,
|
|
|
+ "a_visited": "",
|
|
|
+ }
|
|
|
+ //匹配
|
|
|
+ r := elastic.GetPage("bidding", "bidding", `{"TERM_projectname":"`+projectname+`"}`, `{"comeintime":-1}`, `"_id","title","comeintime","bidopentime","projectcode","type","href","publishtime","subtype","toptype","area","industry","s_subscopeclass"`, -1, -1)
|
|
|
+ var matchingFlag = r != nil && len(*r) != 0
|
|
|
+ var projectcode, sid string
|
|
|
+ if matchingFlag {
|
|
|
+ d := (*r)[0]
|
|
|
+ sid = d["_id"].(string) //(d["_id"].(bson.ObjectId)).Hex()
|
|
|
+ data["s_id"] = sid
|
|
|
+ publishtime := d["publishtime"]
|
|
|
+ data["l_lastpushtime"] = publishtime
|
|
|
+ data["s_title"] = d["title"]
|
|
|
+ if bidopentime := d["bidopentime"]; bidopentime != nil {
|
|
|
+ data["l_bidopentime"] = bidopentime
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if public.BaseMysql.Insert("follow_project_monitor", data) > 0 {
|
|
|
+ status = "y"
|
|
|
+ go public.FollowPush(&rpc.FollowPush{
|
|
|
+ ProjectName: projectname,
|
|
|
+ ProjectCode: projectcode,
|
|
|
+ InfoId: sid,
|
|
|
+ FollowId: id,
|
|
|
+ UserId: userId,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ m.ServeJson(map[string]interface{}{
|
|
|
+ "status": status,
|
|
|
+ "id": util.EncodeArticleId2ByCheck(id),
|
|
|
+ })
|
|
|
+ return nil
|
|
|
}
|
|
|
+
|
|
|
+//
|
|
|
+func (m *Front) NewFollowDetail() error {
|
|
|
+ return m.Render("/weixin/follow/detail.html")
|
|
|
+}
|
|
|
+
|
|
|
+//
|
|
|
func (m *Follow) Set(tp, id string) error {
|
|
|
- defer util.Catch()
|
|
|
- isDel := false
|
|
|
- id = util.DecodeArticleId2ByCheck(id)[0]
|
|
|
- fields := `{"s_id":1,"i_source":1,"s_projectname":1,"s_projectcode":1,"s_url":1,"i_remind":1,"s_type":1,"l_bidopentime":1,"l_remindtime":1,"a_relationinfo":1,"a_visited":1,"l_lastpushtime":1,"a_lastpushids":1}`
|
|
|
- _id, _ := primitive.ObjectIDFromHex(id)
|
|
|
- data, ok := mongodb.FindOneByField("follow_project", map[string]interface{}{
|
|
|
- "_id": _id,
|
|
|
- "s_userid": m.GetSession("userId").(string),
|
|
|
- }, fields)
|
|
|
- if ok && (data == nil || len(*data) == 0) {
|
|
|
- data, ok = mongodb.FindOneByField("follow_project_back", `{"s_followid":"`+id+`"}`, fields)
|
|
|
- isDel = true
|
|
|
- }
|
|
|
- if !ok || data == nil || len(*data) == 0 {
|
|
|
- return m.Redirect("/jyapp/free/mob/err")
|
|
|
- }
|
|
|
- sid, _ := (*data)["s_id"].(string)
|
|
|
- projectname, _ := (*data)["s_projectname"].(string)
|
|
|
- projectcode, _ := (*data)["s_projectcode"].(string)
|
|
|
- if isDel {
|
|
|
- fields := `"_id","title","comeintime","projectcode","projectname","bidopentime","projectcode","area","toptype","subtype","type","href","publishtime","area"`
|
|
|
- data := elastic.GetByIdField("bidding", "bidding", sid, fields)
|
|
|
- mySelf := make(bson.M)
|
|
|
- if data != nil && len(*data) > 0 {
|
|
|
- mySelf["s_projectname"] = projectname
|
|
|
- mySelf["s_title"] = (*data)["title"]
|
|
|
- mySelf["type"] = (*data)["type"]
|
|
|
- mySelf["subtype"] = (*data)["subtype"]
|
|
|
- mySelf["toptype"] = (*data)["toptype"]
|
|
|
- mySelf["area"] = (*data)["area"]
|
|
|
- mySelf["s_projectcode"] = projectcode
|
|
|
- mySelf["s_url"] = (*data)["href"]
|
|
|
- mySelf["s_id"] = "" //sid
|
|
|
- mySelf["s_eid"] = util.EncodeArticleId2ByCheck(sid)
|
|
|
- mySelf["l_publishtime"] = (*data)["publishtime"]
|
|
|
- ////////////////////////
|
|
|
- bidopentime := (*data)["bidopentime"]
|
|
|
- if bidopentime != nil && bidopentime != "" && util.Int64All(bidopentime) != 0 {
|
|
|
- m.T["bidopentime"] = util.FormatDateWithObj(&bidopentime, "2006年01月02日 15时") + " " + convertWeekday(time.Unix(util.Int64All(bidopentime), 0).Weekday().String())
|
|
|
- m.T["l_bidopentime"] = bidopentime
|
|
|
- }
|
|
|
- if remindtime := (*data)["remindtime"]; remindtime != nil && remindtime != "" && util.Int64All(remindtime) != 0 {
|
|
|
- m.T["remindtime"] = util.FormatDateWithObj(&remindtime, "2006年01月02日 15时") + " " + convertWeekday(time.Unix(util.Int64All(remindtime), 0).Weekday().String())
|
|
|
- m.T["l_remindtime"] = remindtime
|
|
|
- } else if bidopentime != nil && bidopentime != "" && util.Int64All(bidopentime) != 0 {
|
|
|
- date := time.Unix(util.Int64All(bidopentime), 0).AddDate(0, 0, -1)
|
|
|
- m.T["remindtime"] = util.FormatDate(&date, "2006年01月02日 15时") + " " + convertWeekday(date.Weekday().String())
|
|
|
- m.T["l_remindtime"] = date.Unix()
|
|
|
- }
|
|
|
- m.T["type"] = (*data)["type"]
|
|
|
- m.T["subtype"] = (*data)["subtype"]
|
|
|
- m.T["toptype"] = (*data)["toptype"]
|
|
|
- m.T["a_lastpushids"] = (*data)["a_lastpushids"]
|
|
|
- }
|
|
|
- if len(projectname) > 0 || len(projectcode) > 0 {
|
|
|
- res, _ := public.FollowPush(&rpc.FollowPush{
|
|
|
- ProjectName: projectname,
|
|
|
- ProjectCode: projectcode,
|
|
|
- InfoId: sid,
|
|
|
- FollowId: "",
|
|
|
- UserId: m.GetSession("userId").(string),
|
|
|
- Flag: 1,
|
|
|
- })
|
|
|
- if len(res) > 0 || len(mySelf) > 0 {
|
|
|
- for _, v := range res {
|
|
|
- (*v)["s_eid"] = util.EncodeArticleId2ByCheck((*v)["s_id"].(string))
|
|
|
- (*v)["s_id"] = ""
|
|
|
- }
|
|
|
- m.T["data"] = res
|
|
|
- }
|
|
|
- }
|
|
|
- m.T["id"] = util.EncodeArticleId2ByCheck(sid)
|
|
|
- m.T["mySelf"] = mySelf
|
|
|
- } else {
|
|
|
- m.T["_id"] = util.EncodeArticleId2ByCheck(id)
|
|
|
- m.T["sid"] = util.EncodeArticleId2ByCheck(sid)
|
|
|
- m.T["source"] = (*data)["i_source"]
|
|
|
- m.T["url"] = (*data)["s_url"]
|
|
|
- m.T["remind"] = (*data)["i_remind"]
|
|
|
- m.T["type"] = (*data)["s_type"]
|
|
|
- if sid != "" {
|
|
|
- info := elastic.GetByIdField("bidding", "bidding", sid, `"type","subtype","toptype"`)
|
|
|
- info_ok := info != nil && len(*info) != 0
|
|
|
- if info_ok {
|
|
|
- m.T["subtype"] = (*info)["subtype"]
|
|
|
- m.T["toptype"] = (*info)["toptype"]
|
|
|
- m.T["type"] = (*data)["type"]
|
|
|
- }
|
|
|
- }
|
|
|
- rela := (*data)["a_relationinfo"]
|
|
|
- var res []map[string]interface{}
|
|
|
- if rela != nil {
|
|
|
- res = util.ObjArrToMapArr((*data)["a_relationinfo"].([]interface{}))
|
|
|
- }
|
|
|
- if len(res) > 0 {
|
|
|
- for _, v := range res {
|
|
|
- v["s_id"] = ""
|
|
|
- }
|
|
|
- m.T["relationinfo"] = res
|
|
|
- }
|
|
|
- m.T["a_visited"] = (*data)["a_visited"]
|
|
|
- m.T["l_lastpushtime"] = (*data)["l_lastpushtime"]
|
|
|
- m.T["a_lastpushids"] = (*data)["a_lastpushids"]
|
|
|
- l_bidopentime := (*data)["l_bidopentime"]
|
|
|
- if l_bidopentime != nil && l_bidopentime != "" && util.Int64All(l_bidopentime) != 0 {
|
|
|
- m.T["bidopentime"] = util.FormatDateWithObj(&l_bidopentime, "2006年01月02日 15时") + " " + convertWeekday(time.Unix(util.Int64All(l_bidopentime), 0).Weekday().String())
|
|
|
- m.T["l_bidopentime"] = l_bidopentime
|
|
|
- }
|
|
|
- if l_remindtime := (*data)["l_remindtime"]; l_remindtime != nil && l_remindtime != "" && util.Int64All(l_remindtime) != 0 {
|
|
|
- m.T["remindtime"] = util.FormatDateWithObj(&l_remindtime, "2006年01月02日 15时") + " " + convertWeekday(time.Unix(util.Int64All(l_remindtime), 0).Weekday().String())
|
|
|
- m.T["l_remindtime"] = l_remindtime
|
|
|
- } else if l_bidopentime != nil && l_bidopentime != "" && util.Int64All(l_bidopentime) != 0 {
|
|
|
- date := time.Unix(util.Int64All(l_bidopentime), 0).AddDate(0, 0, -1)
|
|
|
- m.T["remindtime"] = util.FormatDate(&date, "2006年01月02日 15时") + " " + convertWeekday(date.Weekday().String())
|
|
|
- m.T["l_remindtime"] = date.Unix()
|
|
|
- }
|
|
|
- //
|
|
|
- mongodb.UpdateById("follow_project", id, map[string]interface{}{
|
|
|
- "$set": map[string]interface{}{
|
|
|
- "i_apppushunread": 0,
|
|
|
- },
|
|
|
- })
|
|
|
- }
|
|
|
- m.T["projectname"] = projectname
|
|
|
- m.T["projectcode"] = projectcode
|
|
|
- return m.Render("/weixin/follow/set.html", &m.T)
|
|
|
+ defer util.Catch()
|
|
|
+ //isDel := false
|
|
|
+ var isDel bool
|
|
|
+ id = util.DecodeArticleId2ByCheck(id)[0]
|
|
|
+ //fields := `{"s_id":1,"i_source":1,"s_projectname":1,"s_projectcode":1,"s_url":1,"i_remind":1,"s_type":1,"l_bidopentime":1,"l_remindtime":1,"a_relationinfo":1,"a_visited":1,"l_lastpushtime":1,"a_lastpushids":1}`
|
|
|
+ //_id, _ := primitive.ObjectIDFromHex(id)
|
|
|
+ data := public.BaseMysql.FindOne("follow_project_monitor", map[string]interface{}{
|
|
|
+ "id": id,
|
|
|
+ "s_userid": m.GetSession("userId").(string),
|
|
|
+ }, "", "")
|
|
|
+ if data == nil || len(*data) == 0 {
|
|
|
+ data, _ = mongodb.FindOneByField("follow_project_monitor_back", `{"s_followid":"`+id+`"}`, "")
|
|
|
+ isDel = true
|
|
|
+ }
|
|
|
+ if data == nil || len(*data) == 0 {
|
|
|
+ return m.Redirect("/jyapp/free/mob/err")
|
|
|
+ }
|
|
|
+ m.T["isDel"] = isDel
|
|
|
+ sid, _ := (*data)["s_id"].(string)
|
|
|
+
|
|
|
+ list := elastic.Get("projectset", "projectset", `{"query": {"bool": {"must": [{"match": {"list.infoid": "`+sid+`"}}]}},"_source":["list","projectcode","projectname","bidopentime","area","city","agency","buyer","buyerperson","buyertel","bidstatus"],"from": 0,"size": 1}`)
|
|
|
+ if len(*list) == 0 {
|
|
|
+ return m.Redirect("/jyapp/free/mob/err")
|
|
|
+ }
|
|
|
+ projectInfo := (*list)[0]
|
|
|
+ projectIds, _ := projectInfo["list"].([]interface{})
|
|
|
+ //if !ok {
|
|
|
+ // return m.Redirect("/jyapp/free/mob/err")
|
|
|
+ //}
|
|
|
+ thisList := []map[string]interface{}{}
|
|
|
+ projectname, _ := projectInfo["projectname"].(string)
|
|
|
+ projectcode, _ := projectInfo["projectcode"].(string)
|
|
|
+
|
|
|
+ if sid != "" {
|
|
|
+ r := elastic.GetPage("bidding", "bidding", `{"TERM_projectname":"`+projectname+`"}`, `{"comeintime":-1}`, `"_id","title","comeintime","bidopentime","projectcode","type","href","publishtime","subtype","toptype","area","industry","s_subscopeclass"`, -1, -1)
|
|
|
+ if r != nil && len(*r) != 0 {
|
|
|
+ d := (*r)[0]
|
|
|
+ m.T["url"] = d["href"].(string)
|
|
|
+ if s_type := d["type"]; s_type != nil {
|
|
|
+ m.T["type"] = d["type"]
|
|
|
+ m.T["subtype"] = d["subtype"]
|
|
|
+ m.T["toptype"] = d["toptype"]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, d := range util.ObjArrToMapArr(projectIds) {
|
|
|
+ if len(thisList) >= 50 {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ mySelf := make(map[string]interface{})
|
|
|
+ mySelf["s_type"] = util.ObjToString(d["type"])
|
|
|
+ mySelf["s_toptype"] = util.ObjToString(d["toptype"])
|
|
|
+ mySelf["s_subtype"] = util.ObjToString(d["subtype"])
|
|
|
+ mySelf["s_province"] = util.ObjToString(d["area"])
|
|
|
+ mySelf["s_projectname"] = projectname
|
|
|
+ mySelf["s_title"] = d["title"]
|
|
|
+ mySelf["s_projectcode"] = projectcode
|
|
|
+ mySelf["s_url"] = d["href"].(string)
|
|
|
+ mySelf["s_id"] = ""
|
|
|
+ mySelf["s_eid"] = util.EncodeArticleId2ByCheck(sid)
|
|
|
+ mySelf["l_publishtime"] = d["publishtime"]
|
|
|
+ if projectInfo["industry"] == nil && projectInfo["s_subscopeclass"] != nil {
|
|
|
+ ind := strings.Split(util.ObjToString(projectInfo["s_subscopeclass"]), ",")[0]
|
|
|
+ mySelf["s_industry"] = strings.Split(ind, "_")[0]
|
|
|
+ } else {
|
|
|
+ mySelf["s_industry"] = projectInfo["industry"]
|
|
|
+ }
|
|
|
+ thisList = append(thisList, mySelf)
|
|
|
+ }
|
|
|
+ jyutil.SortData(&thisList, "l_publishtime", true)
|
|
|
+ m.T["relationinfo"] = thisList
|
|
|
+
|
|
|
+ m.T["_id"] = util.EncodeArticleId2ByCheck(id)
|
|
|
+ m.T["sid"] = util.EncodeArticleId2ByCheck(sid)
|
|
|
+ //m.T["a_lastpushids"] = (*data)["ids"]
|
|
|
+ l_bidopentime := (*data)["l_bidopentime"]
|
|
|
+ if l_bidopentime != nil && l_bidopentime != "" && util.Int64All(l_bidopentime) != 0 {
|
|
|
+ m.T["bidopentime"] = util.FormatDateWithObj(&l_bidopentime, "2006年01月02日 15时") + " " + convertWeekday(time.Unix(util.Int64All(l_bidopentime), 0).Weekday().String())
|
|
|
+ m.T["l_bidopentime"] = l_bidopentime
|
|
|
+ }
|
|
|
+ if l_remindtime := (*data)["l_remindtime"]; l_remindtime != nil && l_remindtime != "" && util.Int64All(l_remindtime) != 0 {
|
|
|
+ m.T["remindtime"] = util.FormatDateWithObj(&l_remindtime, "2006年01月02日 15时") + " " + convertWeekday(time.Unix(util.Int64All(l_remindtime), 0).Weekday().String())
|
|
|
+ m.T["l_remindtime"] = l_remindtime
|
|
|
+ } else if l_bidopentime != nil && l_bidopentime != "" && util.Int64All(l_bidopentime) != 0 {
|
|
|
+ date := time.Unix(util.Int64All(l_bidopentime), 0).AddDate(0, 0, -1)
|
|
|
+ m.T["remindtime"] = util.FormatDate(&date, "2006年01月02日 15时") + " " + convertWeekday(date.Weekday().String())
|
|
|
+ m.T["l_remindtime"] = date.Unix()
|
|
|
+ }
|
|
|
+ if !isDel {
|
|
|
+ public.BaseMysql.Update("follow_project_monitor", map[string]interface{}{"id": id}, map[string]interface{}{
|
|
|
+ "i_apppushunread": 0,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ m.T["a_visited"] = (*data)["a_visited"]
|
|
|
+ m.T["remind"] = (*data)["i_remind"]
|
|
|
+ m.T["l_lastpushtime"] = (*data)["l_lastpushtime"]
|
|
|
+ m.T["projectname"] = projectname
|
|
|
+ m.T["projectcode"] = projectcode
|
|
|
+ return m.Render("/weixin/follow/set.html", &m.T)
|
|
|
}
|
|
|
func (m *Follow) AllNotice() error {
|
|
|
- defer util.Catch()
|
|
|
- id := util.DecodeArticleId2ByCheck(m.GetString("id"))[0]
|
|
|
- var relationinfo []interface{}
|
|
|
- fields := `{"_id":-1,"s_title":1,"s_projectcode":1,"s_projectname":1,"s_url":1,"s_id":1,"l_publishtime":1,"a_relationinfo":1,"a_visited":1,"s_id":1}`
|
|
|
- data, ok := mongodb.FindById("follow_project", id, fields)
|
|
|
- if ok && (data == nil || len(*data) == 0) { //以取消关注
|
|
|
- data, ok = mongodb.FindOneByField("follow_project_back", `{"s_followid":"`+id+`"}`, fields)
|
|
|
- }
|
|
|
- if ok && data != nil {
|
|
|
- if a_relationinfo := (*data)["a_relationinfo"]; a_relationinfo != nil {
|
|
|
- relationinfo = a_relationinfo.([]interface{})
|
|
|
- //排序
|
|
|
- for x := range relationinfo {
|
|
|
- for y := 0; y < len(relationinfo)-x-1; y++ {
|
|
|
- dt1 := util.Int64All(relationinfo[y].(map[string]interface{})["l_publishtime"])
|
|
|
- dt2 := util.Int64All(relationinfo[y+1].(map[string]interface{})["l_publishtime"])
|
|
|
- if dt1 > 0 && dt2 > 0 && dt1 < dt2 {
|
|
|
- temp := relationinfo[y]
|
|
|
- relationinfo[y] = relationinfo[y+1]
|
|
|
- relationinfo[y+1] = temp
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- (*data)["a_relationinfo"] = relationinfo
|
|
|
- }
|
|
|
- m.ServeJson(map[string]interface{}{
|
|
|
- "data": data,
|
|
|
- })
|
|
|
- return nil
|
|
|
+ defer util.Catch()
|
|
|
+ id := util.DecodeArticleId2ByCheck(m.GetString("id"))[0]
|
|
|
+ var relationinfo []interface{}
|
|
|
+ data := public.BaseMysql.FindOne("follow_project_monitor", map[string]interface{}{
|
|
|
+ "id": id,
|
|
|
+ "s_userid": m.GetSession("userId").(string),
|
|
|
+ }, "", "")
|
|
|
+ if data == nil || len(*data) == 0 {
|
|
|
+ data, _ = mongodb.FindOneByField("follow_project_monitor_back", `{"s_followid":"`+id+`"}`, "")
|
|
|
+ }
|
|
|
+ sid, _ := (*data)["s_id"].(string)
|
|
|
+ if data != nil && len(*data) > 0 {
|
|
|
+ thisList := []map[string]interface{}{}
|
|
|
+ list := elastic.Get("projectset", "projectset", `{"query": {"bool": {"must": [{"match": {"list.infoid": "`+sid+`"}}]}},"_source":["list","projectcode","projectname","bidopentime","area","city","agency","buyer","buyerperson","buyertel","bidstatus"],"from": 0,"size": 1}`)
|
|
|
+ projectInfo := (*list)[0]
|
|
|
+ relationinfo, _ = projectInfo["list"].([]interface{})
|
|
|
+ if relationinfo != nil {
|
|
|
+
|
|
|
+ for _, d := range util.ObjArrToMapArr(relationinfo) {
|
|
|
+ mySelf := make(map[string]interface{})
|
|
|
+ mySelf["s_type"] = util.ObjToString(d["type"])
|
|
|
+ mySelf["s_toptype"] = util.ObjToString(d["toptype"])
|
|
|
+ mySelf["s_subtype"] = util.ObjToString(d["subtype"])
|
|
|
+ mySelf["s_province"] = util.ObjToString(d["area"])
|
|
|
+ mySelf["s_projectname"] = util.ObjToString(d["projectname"])
|
|
|
+ mySelf["s_title"] = d["title"]
|
|
|
+ mySelf["s_projectcode"] = util.ObjToString(d["projectcode"])
|
|
|
+ mySelf["s_url"] = d["href"].(string)
|
|
|
+ mySelf["s_id"] = ""
|
|
|
+ mySelf["s_eid"] = util.EncodeArticleId2ByCheck(sid)
|
|
|
+ mySelf["l_publishtime"] = d["publishtime"]
|
|
|
+ if projectInfo["industry"] == nil && projectInfo["s_subscopeclass"] != nil {
|
|
|
+ ind := strings.Split(util.ObjToString(projectInfo["s_subscopeclass"]), ",")[0]
|
|
|
+ mySelf["s_industry"] = strings.Split(ind, "_")[0]
|
|
|
+ } else {
|
|
|
+ mySelf["s_industry"] = projectInfo["industry"]
|
|
|
+ }
|
|
|
+ thisList = append(thisList, mySelf)
|
|
|
+ }
|
|
|
+ jyutil.SortData(&thisList, "l_publishtime", true)
|
|
|
+ //relationinfo = a_relationinfo.([]interface{})
|
|
|
+ //排序
|
|
|
+ //for x := range relationinfo {
|
|
|
+ // for y := 0; y < len(relationinfo)-x-1; y++ {
|
|
|
+ // dt1 := util.Int64All(relationinfo[y].(map[string]interface{})["l_publishtime"])
|
|
|
+ // dt2 := util.Int64All(relationinfo[y+1].(map[string]interface{})["l_publishtime"])
|
|
|
+ // if dt1 > 0 && dt2 > 0 && dt1 < dt2 {
|
|
|
+ // temp := relationinfo[y]
|
|
|
+ // relationinfo[y] = relationinfo[y+1]
|
|
|
+ // relationinfo[y+1] = temp
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ }
|
|
|
+ (*data)["a_relationinfo"] = thisList
|
|
|
+ }
|
|
|
+ m.ServeJson(map[string]interface{}{
|
|
|
+ "data": data,
|
|
|
+ })
|
|
|
+ return nil
|
|
|
}
|
|
|
func (m *Follow) Notice(id, followId string) error {
|
|
|
- defer util.Catch()
|
|
|
- go mongodb.UpdateById("follow_project", followId, map[string]interface{}{
|
|
|
- "$set": map[string]interface{}{
|
|
|
- "i_apppushunread": 0,
|
|
|
- },
|
|
|
- })
|
|
|
- userid, _ := m.GetSession("userId").(string)
|
|
|
- var query map[string]interface{}
|
|
|
- if len(id) == 19 {
|
|
|
- query = map[string]interface{}{
|
|
|
- "l_date": util.Int64All(id) / 1000000000,
|
|
|
- "s_userid": userid,
|
|
|
- "s_followid": followId,
|
|
|
- }
|
|
|
- } else {
|
|
|
- query = map[string]interface{}{
|
|
|
- "_id": StringTOBsonId(id),
|
|
|
- "s_userid": userid,
|
|
|
- }
|
|
|
- }
|
|
|
- data, ok := public.MQFW.FindOneByField("jy_pushproject", query, `{"s_followid":-1,"s_title":1,"s_projectcode":1,"s_projectname":1,"a_relationinfo":1,"a_visited":1}`)
|
|
|
- if ok && data != nil && len(*data) > 0 {
|
|
|
- if a_relationinfo := (*data)["a_relationinfo"]; a_relationinfo != nil {
|
|
|
- relationinfo := a_relationinfo.([]interface{})
|
|
|
- for x := range relationinfo {
|
|
|
- s_id, _ := relationinfo[x].(map[string]interface{})["s_id"].(string)
|
|
|
- relationinfo[x].(map[string]interface{})["s_id"] = util.EncodeArticleId2ByCheck(s_id)
|
|
|
- for y := 0; y < len(relationinfo)-x-1; y++ {
|
|
|
- dt1 := util.Int64All(relationinfo[y].(map[string]interface{})["l_publishtime"])
|
|
|
- dt2 := util.Int64All(relationinfo[y+1].(map[string]interface{})["l_publishtime"])
|
|
|
- if dt1 > 0 && dt2 > 0 && dt1 < dt2 {
|
|
|
- temp := relationinfo[y]
|
|
|
- relationinfo[y] = relationinfo[y+1]
|
|
|
- relationinfo[y+1] = temp
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if len(relationinfo) == 1 {
|
|
|
- firstMap, _ := relationinfo[0].(map[string]interface{})
|
|
|
- go public.MQFW.UpdateById("jy_pushproject", id, map[string]interface{}{
|
|
|
- "$addToSet": map[string]interface{}{"a_visited": firstMap["s_id"]},
|
|
|
- })
|
|
|
- return m.Redirect("/jyapp/article/content/" + util.ObjToString(firstMap["s_id"]) + ".html")
|
|
|
- }
|
|
|
- (*data)["a_relationinfo"] = relationinfo
|
|
|
- }
|
|
|
- m.T["data"] = data
|
|
|
- }
|
|
|
- m.T["id"] = util.EncodeArticleId2ByCheck(id)
|
|
|
- return m.Render("/weixin/follow/notice.html", &m.T)
|
|
|
+ defer util.Catch()
|
|
|
+ go mongodb.UpdateById("follow_project", followId, map[string]interface{}{
|
|
|
+ "$set": map[string]interface{}{
|
|
|
+ "i_apppushunread": 0,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ userid, _ := m.GetSession("userId").(string)
|
|
|
+ var query map[string]interface{}
|
|
|
+ if len(id) == 19 {
|
|
|
+ query = map[string]interface{}{
|
|
|
+ "l_date": util.Int64All(id) / 1000000000,
|
|
|
+ "s_userid": userid,
|
|
|
+ "s_followid": followId,
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ query = map[string]interface{}{
|
|
|
+ "_id": StringTOBsonId(id),
|
|
|
+ "s_userid": userid,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ data, ok := public.MQFW.FindOneByField("jy_pushproject", query, `{"s_followid":-1,"s_title":1,"s_projectcode":1,"s_projectname":1,"a_relationinfo":1,"a_visited":1}`)
|
|
|
+ if ok && data != nil && len(*data) > 0 {
|
|
|
+ if a_relationinfo := (*data)["a_relationinfo"]; a_relationinfo != nil {
|
|
|
+ relationinfo := a_relationinfo.([]interface{})
|
|
|
+ for x := range relationinfo {
|
|
|
+ s_id, _ := relationinfo[x].(map[string]interface{})["s_id"].(string)
|
|
|
+ relationinfo[x].(map[string]interface{})["s_id"] = util.EncodeArticleId2ByCheck(s_id)
|
|
|
+ for y := 0; y < len(relationinfo)-x-1; y++ {
|
|
|
+ dt1 := util.Int64All(relationinfo[y].(map[string]interface{})["l_publishtime"])
|
|
|
+ dt2 := util.Int64All(relationinfo[y+1].(map[string]interface{})["l_publishtime"])
|
|
|
+ if dt1 > 0 && dt2 > 0 && dt1 < dt2 {
|
|
|
+ temp := relationinfo[y]
|
|
|
+ relationinfo[y] = relationinfo[y+1]
|
|
|
+ relationinfo[y+1] = temp
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(relationinfo) == 1 {
|
|
|
+ firstMap, _ := relationinfo[0].(map[string]interface{})
|
|
|
+ go public.MQFW.UpdateById("jy_pushproject", id, map[string]interface{}{
|
|
|
+ "$addToSet": map[string]interface{}{"a_visited": firstMap["s_id"]},
|
|
|
+ })
|
|
|
+ return m.Redirect("/jyapp/article/content/" + util.ObjToString(firstMap["s_id"]) + ".html")
|
|
|
+ }
|
|
|
+ (*data)["a_relationinfo"] = relationinfo
|
|
|
+ }
|
|
|
+ m.T["data"] = data
|
|
|
+ }
|
|
|
+ m.T["id"] = util.EncodeArticleId2ByCheck(id)
|
|
|
+ return m.Render("/weixin/follow/notice.html", &m.T)
|
|
|
}
|
|
|
func (m *Follow) Visited() error {
|
|
|
- defer util.Catch()
|
|
|
- d_id := util.DecodeArticleId2ByCheck(m.GetString("id"))[0]
|
|
|
- if d_id == "" {
|
|
|
- return nil
|
|
|
- }
|
|
|
- reqType, _ := m.GetInteger("type")
|
|
|
- sid := m.GetString("sid")
|
|
|
- if reqType == 1 {
|
|
|
- mongodb.UpdateById("follow_project", d_id, map[string]interface{}{
|
|
|
- "$addToSet": map[string]interface{}{"a_visited": sid},
|
|
|
- })
|
|
|
- } else if reqType == 2 {
|
|
|
- mongodb.UpdateById("jy_pushproject", d_id, map[string]interface{}{
|
|
|
- "$addToSet": map[string]interface{}{"a_visited": sid},
|
|
|
- })
|
|
|
- }
|
|
|
- return nil
|
|
|
+ defer util.Catch()
|
|
|
+ d_id := util.DecodeArticleId2ByCheck(m.GetString("id"))[0]
|
|
|
+ if d_id == "" {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ reqType, _ := m.GetInteger("type")
|
|
|
+ sid := m.GetString("sid")
|
|
|
+ if reqType == 1 {
|
|
|
+ public.BaseMysql.Update("follow_project_monitor", map[string]interface{}{"s_id": sid}, map[string]interface{}{
|
|
|
+ "$addToSet": map[string]interface{}{"a_visited": sid},
|
|
|
+ })
|
|
|
+ } else if reqType == 2 {
|
|
|
+ mongodb.UpdateById("jy_pushproject", d_id, map[string]interface{}{
|
|
|
+ "$addToSet": map[string]interface{}{"a_visited": sid},
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return nil
|
|
|
}
|
|
|
func convertWeekday(weekday string) string {
|
|
|
- if weekday == "Sunday" {
|
|
|
- weekday = "日"
|
|
|
- } else if weekday == "Monday" {
|
|
|
- weekday = "一"
|
|
|
- } else if weekday == "Tuesday" {
|
|
|
- weekday = "二"
|
|
|
- } else if weekday == "Wednesday" {
|
|
|
- weekday = "三"
|
|
|
- } else if weekday == "Thursday" {
|
|
|
- weekday = "四"
|
|
|
- } else if weekday == "Friday" {
|
|
|
- weekday = "五"
|
|
|
- } else if weekday == "Saturday" {
|
|
|
- weekday = "六"
|
|
|
- }
|
|
|
- return "周" + weekday
|
|
|
+ if weekday == "Sunday" {
|
|
|
+ weekday = "日"
|
|
|
+ } else if weekday == "Monday" {
|
|
|
+ weekday = "一"
|
|
|
+ } else if weekday == "Tuesday" {
|
|
|
+ weekday = "二"
|
|
|
+ } else if weekday == "Wednesday" {
|
|
|
+ weekday = "三"
|
|
|
+ } else if weekday == "Thursday" {
|
|
|
+ weekday = "四"
|
|
|
+ } else if weekday == "Friday" {
|
|
|
+ weekday = "五"
|
|
|
+ } else if weekday == "Saturday" {
|
|
|
+ weekday = "六"
|
|
|
+ }
|
|
|
+ return "周" + weekday
|
|
|
}
|
|
|
|
|
|
//删除redis相关数据
|
|
|
func delRelRedis(userid interface{}, relationinfo interface{}) {
|
|
|
- defer util.Catch()
|
|
|
- uid, _ := userid.(string)
|
|
|
- if uid == "" || relationinfo == nil {
|
|
|
- return
|
|
|
- }
|
|
|
- array, _ := relationinfo.([]interface{})
|
|
|
- for _, v := range util.ObjArrToMapArr(array) {
|
|
|
- sid, _ := v["s_id"].(string)
|
|
|
- redis.Del("push", "push_"+uid+"_"+sid)
|
|
|
- }
|
|
|
+ defer util.Catch()
|
|
|
+ uid, _ := userid.(string)
|
|
|
+ if uid == "" || relationinfo == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ array, _ := relationinfo.([]interface{})
|
|
|
+ for _, v := range util.ObjArrToMapArr(array) {
|
|
|
+ sid, _ := v["s_id"].(string)
|
|
|
+ redis.Del("push", "push_"+uid+"_"+sid)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// SplitArray 分割数组
|
|
|
+func SplitArray(arr []string, num int64) [][]string {
|
|
|
+
|
|
|
+ max := int64(len(arr))
|
|
|
+ //判断数组大小是否小于等于指定分割大小的值,是则把原数组放入二维数组返回
|
|
|
+ if max <= num {
|
|
|
+ return [][]string{arr}
|
|
|
+ }
|
|
|
+ //获取应该数组分割为多少份
|
|
|
+ var quantity int64
|
|
|
+ if max%num == 0 {
|
|
|
+ quantity = max / num
|
|
|
+ } else {
|
|
|
+ quantity = (max / num) + 1
|
|
|
+ }
|
|
|
+ //声明分割好的二维数组
|
|
|
+ var segments = make([][]string, 0)
|
|
|
+ //声明分割数组的截止下标
|
|
|
+ var start, end, i int64
|
|
|
+ for i = 1; i <= quantity; i++ {
|
|
|
+ end = i * num
|
|
|
+ if i != quantity {
|
|
|
+ segments = append(segments, arr[start:end])
|
|
|
+ } else {
|
|
|
+ segments = append(segments, arr[start:])
|
|
|
+ }
|
|
|
+ start = i * num
|
|
|
+ }
|
|
|
+ return segments
|
|
|
+}
|
|
|
+
|
|
|
+//根据多个信息id查询对应的项目信息
|
|
|
+func getProjectsBySid(sids []string) ([]map[string]interface{}, error) {
|
|
|
+ sidStr := strings.Join(sids, `","`)
|
|
|
+ list := elastic.Get("projectset", "projectset", `{"query": {"bool": {"must": [{"terms": {"list.infoid": ["`+sidStr+`"]}}]}},"_source":["projectname","topscopeclass","_id","area","buyerclass","budget","ids","bidstatus","projectcode"],"from": 0,"size": `+fmt.Sprint(len(sids))+`}`)
|
|
|
+ if len(*list) == 0 {
|
|
|
+ return nil, errors.New("获取项目信息查询出错")
|
|
|
+ }
|
|
|
+ return *list, nil
|
|
|
}
|