|
@@ -1,1062 +1,1051 @@
|
|
|
-package front
|
|
|
-
|
|
|
-import (
|
|
|
- "encoding/base64"
|
|
|
- "errors"
|
|
|
- "fmt"
|
|
|
- "jfw/config"
|
|
|
- "jfw/jyutil"
|
|
|
- public "jfw/public"
|
|
|
- "jfw/wx"
|
|
|
- "log"
|
|
|
- . "mongodb"
|
|
|
- "net/url"
|
|
|
- "qfw/util"
|
|
|
- "qfw/util/elastic"
|
|
|
- "qfw/util/jy"
|
|
|
- "qfw/util/redis"
|
|
|
- rpc "qfw/util/rpc"
|
|
|
- "strings"
|
|
|
- "time"
|
|
|
-
|
|
|
- "github.com/SKatiyar/qr"
|
|
|
-
|
|
|
- "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:"/follow/ajaxReq"` //关注项目ajax请求
|
|
|
- list xweb.Mapper `xweb:"/follow/list"` //我关注的项目
|
|
|
- add xweb.Mapper `xweb:"/follow/add"` //添加关注项目
|
|
|
- addsave xweb.Mapper `xweb:"/follow/addsave"`
|
|
|
- set xweb.Mapper `xweb:"/follow/set/(\\w+)/([^.]*)"`
|
|
|
- notice xweb.Mapper `xweb:"/follow/notice/([^.]+)/([^.]*)"` //项目公告
|
|
|
- allNotice xweb.Mapper `xweb:"/follow/allNotice"` //项目公告/(.*)
|
|
|
- visited xweb.Mapper `xweb:"/follow/notice/visited"`
|
|
|
- photo xweb.Mapper `xweb:"/follow/photo/(.*)"`
|
|
|
- fwsave xweb.Mapper `xweb:"/follow/fwsave"`
|
|
|
- mylist xweb.Mapper `xweb:"/follow/mylist"`
|
|
|
- checkFPStatus xweb.Mapper `xweb:"/follow/checkFPStatus"`
|
|
|
- checkCStatus xweb.Mapper `xweb:"/follow/checkCStatus"`
|
|
|
- shareFW xweb.Mapper `xweb:"/follow/shareFW/([^.]*)"`
|
|
|
- pcAllNotice xweb.Mapper `xweb:"/front/pcAllNotice"`
|
|
|
- pcEntAllNotice xweb.Mapper `xweb:"/front/pcEntAllNotice"`
|
|
|
- //分享拉新领取超级订阅
|
|
|
- followGift xweb.Mapper `xweb:"/front/followGift/(.*)"`
|
|
|
-}
|
|
|
-
|
|
|
-var followLimit int
|
|
|
-
|
|
|
-func init() {
|
|
|
- xweb.AddAction(&Follow{})
|
|
|
- followLimit = util.IntAllDef(config.Sysconfig["followProject"], 10)
|
|
|
-}
|
|
|
-
|
|
|
-//
|
|
|
-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
|
|
|
-}
|
|
|
-
|
|
|
-//
|
|
|
-func (m *Follow) CheckCStatus() error {
|
|
|
- defer util.Catch()
|
|
|
- pname := m.GetString("pcname")
|
|
|
- pcode := m.GetString("pccode")
|
|
|
- userId, _ := m.GetSession("userId").(string)
|
|
|
- openId, _ := m.GetSession("s_m_openid").(string)
|
|
|
- flag := false
|
|
|
- followid := ""
|
|
|
- if userId != "" {
|
|
|
- flag, followid = MFollow(userId, pname, pcode, "", openId)
|
|
|
- }
|
|
|
- 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,
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-//关注列表关注
|
|
|
-func (m *Follow) Fwsave() {
|
|
|
- defer util.Catch()
|
|
|
- userId := m.GetSession("userId").(string)
|
|
|
- openid := m.GetSession("s_m_openid").(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["s_openid"] = openid
|
|
|
- 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),
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-//分享关注项目
|
|
|
-func (m *Follow) ShareFW(tp string) error {
|
|
|
- defer util.Catch()
|
|
|
- tpm := strings.Split(tp, "__")
|
|
|
- id := util.DecodeArticleId2ByCheck(tpm[0])[0]
|
|
|
- projectname := tpm[1]
|
|
|
- openid := tpm[2]
|
|
|
- m.T["signature"] = wx.SignJSSDK(m.Site() + m.Url())
|
|
|
- mynickname, _ := m.Session().Get("s_nickname").(string)
|
|
|
- myavatar, _ := m.Session().Get("s_avatar").(string)
|
|
|
- m.T["nickname"] = mynickname
|
|
|
- m.T["avatar"] = myavatar
|
|
|
- userId := m.GetSession("userId")
|
|
|
- if userId != "" && userId != nil {
|
|
|
- m.T["userId"] = userId.(string)
|
|
|
- }
|
|
|
- projectcode := ""
|
|
|
- m.T["projectname"] = projectname
|
|
|
- m.T["projectcode"] = projectcode
|
|
|
- m.T["fg"] = "F"
|
|
|
- fields := `"_id","title","comeintime","projectcode","projectname","bidopentime","projectcode","area","toptype","subtype","type","href","publishtime","area"`
|
|
|
- data := elastic.GetByIdField("bidding", "bidding", id, fields)
|
|
|
- bidopentime := (*data)["bidopentime"]
|
|
|
- if bidopentime != nil && 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 && 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 && 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()
|
|
|
- }
|
|
|
- mySelf := make(bson.M)
|
|
|
- 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["l_publishtime"] = (*data)["publishtime"]
|
|
|
- if len(projectname) > 0 || len(projectcode) > 0 {
|
|
|
- res, _ := public.FollowPush(&rpc.FollowPush{
|
|
|
- ProjectName: projectname,
|
|
|
- ProjectCode: projectcode,
|
|
|
- InfoId: id,
|
|
|
- FollowId: "",
|
|
|
- UserId: "",
|
|
|
- Flag: 1,
|
|
|
- })
|
|
|
- if len(res) > 0 || len(mySelf) > 0 {
|
|
|
- m.T["fg"] = "T"
|
|
|
- m.T["data"] = res
|
|
|
- m.T["id"] = id
|
|
|
- m.T["mySelf"] = mySelf
|
|
|
- m.T["openid"] = openid
|
|
|
- }
|
|
|
- }
|
|
|
- return m.Render("/weixin/follow/shareset.html", &m.T)
|
|
|
-}
|
|
|
-
|
|
|
-//
|
|
|
-func (m *Follow) PcAllNotice() error {
|
|
|
- defer util.Catch()
|
|
|
- id := util.DecodeArticleId2ByCheck(m.GetString("id"))[0]
|
|
|
- projectname := m.GetString("projectname")
|
|
|
- projectcode := m.GetString("projectcode")
|
|
|
- //log.Println(projectname, "id:", id)
|
|
|
- data := map[string]interface{}{}
|
|
|
- if len(projectname) > 0 || len(projectcode) > 0 {
|
|
|
- res, _ := public.FollowPush(&rpc.FollowPush{
|
|
|
- ProjectName: projectname,
|
|
|
- ProjectCode: projectcode,
|
|
|
- InfoId: id,
|
|
|
- FollowId: "",
|
|
|
- UserId: "",
|
|
|
- Flag: 1,
|
|
|
- })
|
|
|
- if len(res) > 0 {
|
|
|
- for _, v := range res {
|
|
|
- (*v)["s_eid"] = util.EncodeArticleId2ByCheck((*v)["s_id"].(string))
|
|
|
- }
|
|
|
- data["res"] = res
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- m.ServeJson(map[string]interface{}{
|
|
|
- "data": data,
|
|
|
- })
|
|
|
- return nil
|
|
|
-}
|
|
|
-
|
|
|
-//中标企业公告列表
|
|
|
-func (m *Follow) PcEntAllNotice() error {
|
|
|
- defer util.Catch()
|
|
|
- entname := m.GetString("entname")
|
|
|
- data := map[string]interface{}{}
|
|
|
- if entname != "" {
|
|
|
- entname_a := strings.Split(entname, ",")
|
|
|
- for _, v := range entname_a {
|
|
|
- if v != "" {
|
|
|
- fields := `"_id","projectname","bidamount","title","publishtime","subtype","toptype","href"`
|
|
|
- res := elastic.GetPage("bidding", "bidding", `{"TERM_s_winner":"`+v+`"}`, `{"publishtime":-1}`, fields, 0, 100)
|
|
|
- if len(*res) != 0 && res != nil && *res != nil {
|
|
|
- for _, v := range *res {
|
|
|
- v["_id"] = util.EncodeArticleId2ByCheck(BsonIdToSId(v["_id"]))
|
|
|
- }
|
|
|
- data[v] = res
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- m.ServeJson(map[string]interface{}{
|
|
|
- "data": data,
|
|
|
- })
|
|
|
- return nil
|
|
|
-}
|
|
|
-
|
|
|
-//未关注项目
|
|
|
-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)
|
|
|
- openid := m.GetSession("s_m_openid").(string)
|
|
|
- if userid != "" && openid != "" {
|
|
|
- _, followid = MFollow(userid, projectname, projectcode, "", openid)
|
|
|
- }
|
|
|
- //已关注
|
|
|
- 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": userid,
|
|
|
- }, 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.Render("_error.html")
|
|
|
- }
|
|
|
- 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"]
|
|
|
- }
|
|
|
- }
|
|
|
- m.T["relationinfo"] = (*data)["a_relationinfo"]
|
|
|
- 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
|
|
|
- //log.Println("id:", id)
|
|
|
- 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 || len(mySelf) > 0 {
|
|
|
- for _, v := range res {
|
|
|
- (*v)["s_eid"] = util.EncodeArticleId2ByCheck((*v)["s_id"].(string))
|
|
|
- }
|
|
|
- m.T["data"] = res
|
|
|
- }
|
|
|
- }
|
|
|
- m.T["id"] = util.EncodeArticleId2ByCheck(id)
|
|
|
- m.T["mySelf"] = mySelf
|
|
|
- m.T["source"] = 1
|
|
|
- }
|
|
|
- myopenid, _ := m.Session().Get("s_m_openid").(string)
|
|
|
- m.T["openid"] = se.EncodeString(myopenid)
|
|
|
- mynickname, _ := m.Session().Get("s_nickname").(string)
|
|
|
- myavatar, _ := m.Session().Get("s_avatar").(string)
|
|
|
- m.T["nickname"] = mynickname
|
|
|
- m.T["avatar"] = myavatar
|
|
|
- m.T["signature"] = wx.SignJSSDK(m.Site() + m.Url())
|
|
|
- return m.Render("/weixin/follow/set.html", &m.T)
|
|
|
-}
|
|
|
-
|
|
|
-//关注项目相关的ajax请求
|
|
|
-func (m *Follow) AjaxReq() {
|
|
|
- defer util.Catch()
|
|
|
- userId := m.GetSession("userId").(string)
|
|
|
- openid := m.GetSession("s_m_openid").(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_openid": openid,
|
|
|
- "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),
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-//我关注的项目
|
|
|
-func (m *Follow) List() error {
|
|
|
- defer util.Catch()
|
|
|
- myopenid, _ := m.Session().Get("s_m_openid").(string)
|
|
|
- userId := util.ObjToString(m.Session().Get("userId"))
|
|
|
- if userId == "" {
|
|
|
- log.Println("查询我关注的项目出错,userid为空")
|
|
|
- return errors.New("查询我关注的项目出错,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}`, false, -1, -1)
|
|
|
- m.T["flag"] = false
|
|
|
- if ok && datas != nil && len(*datas) > 0 {
|
|
|
- for _, v := range *datas {
|
|
|
- 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 {
|
|
|
- m.T["flag"] = true
|
|
|
- }
|
|
|
- }
|
|
|
- m.T["openid"] = se.EncodeString(myopenid)
|
|
|
- mynickname, _ := m.Session().Get("s_nickname").(string)
|
|
|
- myavatar, _ := m.Session().Get("s_avatar").(string)
|
|
|
- m.T["nickname"] = mynickname
|
|
|
- m.T["avatar"] = myavatar
|
|
|
- m.T["signature"] = wx.SignJSSDK(m.Site() + m.Url())
|
|
|
- m.T["followLimit"] = followLimit
|
|
|
- return m.Render("/weixin/follow/list.html", &m.T)
|
|
|
-}
|
|
|
-
|
|
|
-//添加关注项目
|
|
|
-func (m *Follow) Add() error {
|
|
|
- myopenid, _ := m.Session().Get("s_m_openid").(string)
|
|
|
- m.T["openid"] = se.EncodeString(myopenid)
|
|
|
- m.T["signature"] = wx.SignJSSDK(m.Site() + m.Url())
|
|
|
- mynickname, _ := m.Session().Get("s_nickname").(string)
|
|
|
- myavatar, _ := m.Session().Get("s_avatar").(string)
|
|
|
- m.T["nickname"] = mynickname
|
|
|
- m.T["avatar"] = myavatar
|
|
|
- return m.Render("/weixin/follow/add.html", &m.T)
|
|
|
-}
|
|
|
-
|
|
|
-//手动添加关注项目
|
|
|
-func (m *Follow) Addsave() error {
|
|
|
- defer util.Catch()
|
|
|
- var status = "n"
|
|
|
- var id string
|
|
|
- userId := m.GetSession("userId").(string)
|
|
|
- openid := m.GetSession("s_m_openid").(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_openid": openid,
|
|
|
- "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 && util.Int64All(bidopentime) != 0 {
|
|
|
- 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
|
|
|
-}
|
|
|
-func (m *Follow) Set(tp, id string) error {
|
|
|
- defer util.Catch()
|
|
|
- isDel := false
|
|
|
- id = util.DecodeArticleId2ByCheck(id)[0]
|
|
|
- userid := util.ObjToString(m.GetSession("userId"))
|
|
|
- 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,"s_userid":1}`
|
|
|
- _id, _ := primitive.ObjectIDFromHex(id)
|
|
|
- data, ok := mongodb.FindOneByField("follow_project", map[string]interface{}{
|
|
|
- "_id": _id,
|
|
|
- }, 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.Render("_error.html")
|
|
|
- }
|
|
|
- sid, _ := (*data)["s_id"].(string)
|
|
|
- projectname, _ := (*data)["s_projectname"].(string)
|
|
|
- projectcode, _ := (*data)["s_projectcode"].(string)
|
|
|
- if util.ObjToString((*data)["s_userid"]) != userid {
|
|
|
- return m.Redirect(fmt.Sprintf("/follow/photo/%s__%s__%s", util.EncodeArticleId2ByCheck(sid), projectname, projectcode))
|
|
|
- }
|
|
|
- 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()
|
|
|
- }
|
|
|
- }
|
|
|
- m.T["projectname"] = projectname
|
|
|
- m.T["projectcode"] = projectcode
|
|
|
- myopenid, _ := m.Session().Get("s_m_openid").(string)
|
|
|
- m.T["openid"] = se.EncodeString(myopenid)
|
|
|
- mynickname, _ := m.Session().Get("s_nickname").(string)
|
|
|
- myavatar, _ := m.Session().Get("s_avatar").(string)
|
|
|
- m.T["nickname"] = mynickname
|
|
|
- m.T["avatar"] = myavatar
|
|
|
- m.T["signature"] = wx.SignJSSDK(m.Site() + m.Url())
|
|
|
- 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}`
|
|
|
- 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
|
|
|
-}
|
|
|
-func (m *Follow) Notice(id, followId string) error {
|
|
|
- defer util.Catch()
|
|
|
- query := map[string]interface{}{
|
|
|
- "_id": StringTOBsonId(id),
|
|
|
- "s_userid": util.ObjToString(m.GetSession("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("/article/content/" + util.ObjToString(firstMap["s_id"]) + ".html?advertcode=" + m.GetString("advertcode"))
|
|
|
- }
|
|
|
- (*data)["a_relationinfo"] = relationinfo
|
|
|
- }
|
|
|
- m.T["data"] = data
|
|
|
- }
|
|
|
- m.T["id"] = util.EncodeArticleId2ByCheck(id)
|
|
|
- m.T["openid"] = se.EncodeString(util.ObjToString(m.GetSession("s_m_openid")))
|
|
|
- mynickname, _ := m.Session().Get("s_nickname").(string)
|
|
|
- myavatar, _ := m.Session().Get("s_avatar").(string)
|
|
|
- m.T["nickname"] = mynickname
|
|
|
- m.T["avatar"] = myavatar
|
|
|
- m.T["signature"] = wx.SignJSSDK(m.Site() + m.Url())
|
|
|
- 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
|
|
|
-}
|
|
|
-
|
|
|
-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
|
|
|
-}
|
|
|
-
|
|
|
-//删除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)
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-//拉新获取超级订阅
|
|
|
-func (this *Follow) FollowGift(shareid string) error {
|
|
|
- defer util.Catch()
|
|
|
- client := this.Header("User-Agent")
|
|
|
- bm := mobileReg.MatchString(client)
|
|
|
- checkIsSubscribeFlag := true
|
|
|
- openid, _ := this.Session().Get("s_m_openid").(string)
|
|
|
- nickname, _ := this.Session().Get("s_nickname").(string)
|
|
|
- redisName := util.ObjToString(config.Sysconfig["shareRedisName"])
|
|
|
- headImg := ""
|
|
|
- qrstr := ""
|
|
|
- infos := ""
|
|
|
- if !strings.Contains(shareid, "shareId_") {
|
|
|
- rdata, ok := mongodb.FindOneByField("user", map[string]interface{}{"s_m_openid": shareid, "i_appid": 2}, `{"_id":1}`)
|
|
|
- if rdata != nil && ok && len(*rdata) > 0 {
|
|
|
- uid := BsonIdToSId((*rdata)["_id"])
|
|
|
- infos = redis.GetStr(redisName, fmt.Sprintf("SF_%s", uid))
|
|
|
- }
|
|
|
- }
|
|
|
- if shareUserid := redis.GetStr(redisName, shareid); shareUserid == "" && infos == "" {
|
|
|
- return this.Render("/_error.html")
|
|
|
- } else {
|
|
|
- if infos == "" {
|
|
|
- infos = redis.GetStr(redisName, fmt.Sprintf("SF_%s", shareUserid))
|
|
|
- }
|
|
|
- if infos != "" {
|
|
|
- nickname = strings.Split(infos, "#@#@")[1]
|
|
|
- headImg = strings.Split(infos, "#@#@")[2]
|
|
|
- link := fmt.Sprintf("%s/front/followGift/%s", util.ObjToString(config.Sysconfig["webdomain"]), strings.Split(infos, "#@#@")[3])
|
|
|
- r, _ := qr.Encode(link, qr.M)
|
|
|
- pngdat := r.PNG()
|
|
|
- qrstr = base64.StdEncoding.EncodeToString(pngdat)
|
|
|
- shareid = strings.Split(infos, "#@#@")[3]
|
|
|
- if jy.IsPhone(nickname) {
|
|
|
- nickname = string(nickname[0:3]) + "****" + string(nickname[len(nickname)-4:])
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if bm {
|
|
|
- if openid == "" {
|
|
|
- if this.Session().Get("s_m_openid") == nil {
|
|
|
- if this.GetString("state") == "wx" {
|
|
|
- //微信跳回来的
|
|
|
- code := this.GetString("code")
|
|
|
- if code != "" {
|
|
|
- openid = jyutil.Getopenid(code)
|
|
|
- log.Println("qwe:", openid)
|
|
|
- if openid != "" {
|
|
|
- isSubscribe := true
|
|
|
- if !checkIsSubscribeFlag {
|
|
|
- checkIsSubscribeFlag = true
|
|
|
- isSubscribe = CheckUserIsSubscribe(openid)
|
|
|
- }
|
|
|
- if isSubscribe {
|
|
|
- FindUserAndCreateSess(openid, this.Session(), "wx", false)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- if public.CheckWxBrowser(this.Request) {
|
|
|
- //所有参数都不再使用,跳到微信验证用户
|
|
|
- return this.Redirect(fmt.Sprintf(config.Wxoauth, url.QueryEscape(this.Site()+this.Url()), "wx"), 302)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- this.T["shareid"] = shareid
|
|
|
- this.T["share_nickname"] = nickname
|
|
|
- this.T["share_headImg"] = headImg
|
|
|
- this.T["openid"] = se.EncodeString(openid)
|
|
|
- this.T["share_qr"] = qrstr
|
|
|
- mynickname, _ := this.Session().Get("s_nickname").(string)
|
|
|
- myavatar, _ := this.Session().Get("s_avatar").(string)
|
|
|
- this.T["nickname"] = mynickname
|
|
|
- this.T["avatar"] = myavatar
|
|
|
- this.T["signature"] = wx.SignJSSDK(this.Site() + this.Url())
|
|
|
- return this.Render("/frontRouter/wx/share/sess/b-share.html", &this.T)
|
|
|
- } else {
|
|
|
- this.T["shareid"] = shareid
|
|
|
- this.T["share_nickname"] = nickname
|
|
|
- this.T["share_headImg"] = headImg
|
|
|
- this.T["signature"] = wx.SignJSSDK(this.Site() + this.Url())
|
|
|
- this.T["isWeixin"] = public.CheckWxBrowser(this.Request)
|
|
|
- this.T["share_qr"] = qrstr
|
|
|
- return this.Render("/frontRouter/pc/share/sess/share-f.html", &this.T)
|
|
|
- }
|
|
|
-}
|
|
|
+package front
|
|
|
+
|
|
|
+import (
|
|
|
+ "encoding/base64"
|
|
|
+ "errors"
|
|
|
+ "fmt"
|
|
|
+ "jfw/config"
|
|
|
+ "jfw/jyutil"
|
|
|
+ "jfw/public"
|
|
|
+ "jfw/wx"
|
|
|
+ . "mongodb"
|
|
|
+ "net/url"
|
|
|
+ "qfw/util"
|
|
|
+ "qfw/util/elastic"
|
|
|
+ "qfw/util/jy"
|
|
|
+ "qfw/util/redis"
|
|
|
+ "qfw/util/rpc"
|
|
|
+ "strings"
|
|
|
+ "time"
|
|
|
+
|
|
|
+ "github.com/SKatiyar/qr"
|
|
|
+
|
|
|
+ "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:"/follow/ajaxReq"` //关注项目ajax请求
|
|
|
+ list xweb.Mapper `xweb:"/follow/list"` //我关注的项目
|
|
|
+ add xweb.Mapper `xweb:"/follow/add"` //添加关注项目
|
|
|
+ addsave xweb.Mapper `xweb:"/follow/addsave"`
|
|
|
+ set xweb.Mapper `xweb:"/follow/set/(\\w+)/([^.]*)"`
|
|
|
+ notice xweb.Mapper `xweb:"/follow/notice/([^.]+)/([^.]*)"` //项目公告
|
|
|
+ allNotice xweb.Mapper `xweb:"/follow/allNotice"` //项目公告/(.*)
|
|
|
+ visited xweb.Mapper `xweb:"/follow/notice/visited"`
|
|
|
+ photo xweb.Mapper `xweb:"/follow/photo/(.*)"`
|
|
|
+ fwsave xweb.Mapper `xweb:"/follow/fwsave"`
|
|
|
+ mylist xweb.Mapper `xweb:"/follow/mylist"`
|
|
|
+ checkFPStatus xweb.Mapper `xweb:"/follow/checkFPStatus"`
|
|
|
+ checkCStatus xweb.Mapper `xweb:"/follow/checkCStatus"`
|
|
|
+ shareFW xweb.Mapper `xweb:"/follow/shareFW/([^.]*)"`
|
|
|
+ pcAllNotice xweb.Mapper `xweb:"/front/pcAllNotice"`
|
|
|
+ pcEntAllNotice xweb.Mapper `xweb:"/front/pcEntAllNotice"`
|
|
|
+ //分享拉新领取超级订阅
|
|
|
+ followGift xweb.Mapper `xweb:"/front/followGift/(.*)"`
|
|
|
+}
|
|
|
+
|
|
|
+var followLimit int
|
|
|
+
|
|
|
+func init() {
|
|
|
+ xweb.AddAction(&Follow{})
|
|
|
+ followLimit = util.IntAllDef(config.Sysconfig["followProject"], 10)
|
|
|
+}
|
|
|
+
|
|
|
+//
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+//
|
|
|
+func (m *Follow) CheckCStatus() error {
|
|
|
+ defer util.Catch()
|
|
|
+ pname := m.GetString("pcname")
|
|
|
+ pcode := m.GetString("pccode")
|
|
|
+ userId, _ := m.GetSession("userId").(string)
|
|
|
+ openId, _ := m.GetSession("s_m_openid").(string)
|
|
|
+ flag := false
|
|
|
+ followid := ""
|
|
|
+ if userId != "" {
|
|
|
+ flag, followid = MFollow(userId, pname, pcode, "", openId)
|
|
|
+ }
|
|
|
+ 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,
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+//关注列表关注
|
|
|
+func (m *Follow) Fwsave() {
|
|
|
+ defer util.Catch()
|
|
|
+ userId := m.GetSession("userId").(string)
|
|
|
+ openid := m.GetSession("s_m_openid").(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["s_openid"] = openid
|
|
|
+ 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),
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+//分享关注项目
|
|
|
+func (m *Follow) ShareFW(tp string) error {
|
|
|
+ defer util.Catch()
|
|
|
+ tpm := strings.Split(tp, "__")
|
|
|
+ id := util.DecodeArticleId2ByCheck(tpm[0])[0]
|
|
|
+ projectname := tpm[1]
|
|
|
+ openid := tpm[2]
|
|
|
+ m.T["signature"] = wx.SignJSSDK(m.Site() + m.Url())
|
|
|
+ mynickname, _ := m.Session().Get("s_nickname").(string)
|
|
|
+ myavatar, _ := m.Session().Get("s_avatar").(string)
|
|
|
+ m.T["nickname"] = mynickname
|
|
|
+ m.T["avatar"] = myavatar
|
|
|
+ userId := m.GetSession("userId")
|
|
|
+ if userId != "" && userId != nil {
|
|
|
+ m.T["userId"] = userId.(string)
|
|
|
+ }
|
|
|
+ projectcode := ""
|
|
|
+ m.T["projectname"] = projectname
|
|
|
+ m.T["projectcode"] = projectcode
|
|
|
+ m.T["fg"] = "F"
|
|
|
+ fields := `"_id","title","comeintime","projectcode","projectname","bidopentime","projectcode","area","toptype","subtype","type","href","publishtime","area"`
|
|
|
+ data := elastic.GetByIdField("bidding", "bidding", id, fields)
|
|
|
+ bidopentime := (*data)["bidopentime"]
|
|
|
+ if bidopentime != nil && 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 && 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 && 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()
|
|
|
+ }
|
|
|
+ mySelf := make(bson.M)
|
|
|
+ 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["l_publishtime"] = (*data)["publishtime"]
|
|
|
+ if len(projectname) > 0 {
|
|
|
+ res, _ := public.FollowPush(&rpc.FollowPush{
|
|
|
+ ProjectName: projectname,
|
|
|
+ ProjectCode: projectcode,
|
|
|
+ InfoId: id,
|
|
|
+ FollowId: "",
|
|
|
+ UserId: "",
|
|
|
+ Flag: 1,
|
|
|
+ })
|
|
|
+ if len(res) > 0 || len(mySelf) > 0 {
|
|
|
+ m.T["fg"] = "T"
|
|
|
+ m.T["data"] = res
|
|
|
+ m.T["id"] = id
|
|
|
+ m.T["mySelf"] = mySelf
|
|
|
+ m.T["openid"] = openid
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return m.Render("/weixin/follow/shareset.html", &m.T)
|
|
|
+}
|
|
|
+
|
|
|
+//
|
|
|
+func (m *Follow) PcAllNotice() error {
|
|
|
+ defer util.Catch()
|
|
|
+ id := util.DecodeArticleId2ByCheck(m.GetString("id"))[0]
|
|
|
+ projectname := m.GetString("projectname")
|
|
|
+ projectcode := m.GetString("projectcode")
|
|
|
+ data := map[string]interface{}{}
|
|
|
+ if len(projectname) > 0 || len(projectcode) > 0 {
|
|
|
+ res, _ := public.FollowPush(&rpc.FollowPush{
|
|
|
+ ProjectName: projectname,
|
|
|
+ ProjectCode: projectcode,
|
|
|
+ InfoId: id,
|
|
|
+ FollowId: "",
|
|
|
+ UserId: "",
|
|
|
+ Flag: 1,
|
|
|
+ })
|
|
|
+ if len(res) > 0 {
|
|
|
+ for _, v := range res {
|
|
|
+ (*v)["s_eid"] = util.EncodeArticleId2ByCheck((*v)["s_id"].(string))
|
|
|
+ }
|
|
|
+ data["res"] = res
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ m.ServeJson(map[string]interface{}{
|
|
|
+ "data": data,
|
|
|
+ })
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+//中标企业公告列表
|
|
|
+func (m *Follow) PcEntAllNotice() error {
|
|
|
+ defer util.Catch()
|
|
|
+ entname := m.GetString("entname")
|
|
|
+ data := map[string]interface{}{}
|
|
|
+ if entname != "" {
|
|
|
+ entname_a := strings.Split(entname, ",")
|
|
|
+ for _, v := range entname_a {
|
|
|
+ if v != "" {
|
|
|
+ fields := `"_id","projectname","bidamount","title","publishtime","subtype","toptype","href"`
|
|
|
+ res := elastic.GetPage("bidding", "bidding", `{"TERM_s_winner":"`+v+`"}`, `{"publishtime":-1}`, fields, 0, 100)
|
|
|
+ if len(*res) != 0 && res != nil && *res != nil {
|
|
|
+ for _, v := range *res {
|
|
|
+ v["_id"] = util.EncodeArticleId2ByCheck(BsonIdToSId(v["_id"]))
|
|
|
+ }
|
|
|
+ data[v] = res
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ m.ServeJson(map[string]interface{}{
|
|
|
+ "data": data,
|
|
|
+ })
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+//未关注项目
|
|
|
+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)
|
|
|
+ openid := m.GetSession("s_m_openid").(string)
|
|
|
+ if userid != "" && openid != "" {
|
|
|
+ _, followid = MFollow(userid, projectname, projectcode, "", openid)
|
|
|
+ }
|
|
|
+ //已关注
|
|
|
+ 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": userid,
|
|
|
+ }, 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.Render("_error.html")
|
|
|
+ }
|
|
|
+ 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"]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ m.T["relationinfo"] = (*data)["a_relationinfo"]
|
|
|
+ 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 || len(mySelf) > 0 {
|
|
|
+ for _, v := range res {
|
|
|
+ (*v)["s_eid"] = util.EncodeArticleId2ByCheck((*v)["s_id"].(string))
|
|
|
+ }
|
|
|
+ m.T["data"] = res
|
|
|
+ }
|
|
|
+ }
|
|
|
+ m.T["id"] = util.EncodeArticleId2ByCheck(id)
|
|
|
+ m.T["mySelf"] = mySelf
|
|
|
+ m.T["source"] = 1
|
|
|
+ }
|
|
|
+ myopenid, _ := m.Session().Get("s_m_openid").(string)
|
|
|
+ m.T["openid"] = se.EncodeString(myopenid)
|
|
|
+ mynickname, _ := m.Session().Get("s_nickname").(string)
|
|
|
+ myavatar, _ := m.Session().Get("s_avatar").(string)
|
|
|
+ m.T["nickname"] = mynickname
|
|
|
+ m.T["avatar"] = myavatar
|
|
|
+ m.T["signature"] = wx.SignJSSDK(m.Site() + m.Url())
|
|
|
+ return m.Render("/weixin/follow/set.html", &m.T)
|
|
|
+}
|
|
|
+
|
|
|
+//关注项目相关的ajax请求
|
|
|
+func (m *Follow) AjaxReq() {
|
|
|
+ defer util.Catch()
|
|
|
+ userId := m.GetSession("userId").(string)
|
|
|
+ openid := m.GetSession("s_m_openid").(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_openid": openid,
|
|
|
+ "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),
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+//我关注的项目
|
|
|
+func (m *Follow) List() error {
|
|
|
+ defer util.Catch()
|
|
|
+ myopenid, _ := m.Session().Get("s_m_openid").(string)
|
|
|
+ userId := util.ObjToString(m.Session().Get("userId"))
|
|
|
+ if userId == "" {
|
|
|
+ return errors.New("查询我关注的项目出错,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}`, false, -1, -1)
|
|
|
+ m.T["flag"] = false
|
|
|
+ if ok && datas != nil && len(*datas) > 0 {
|
|
|
+ for _, v := range *datas {
|
|
|
+ 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 {
|
|
|
+ m.T["flag"] = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ m.T["openid"] = se.EncodeString(myopenid)
|
|
|
+ mynickname, _ := m.Session().Get("s_nickname").(string)
|
|
|
+ myavatar, _ := m.Session().Get("s_avatar").(string)
|
|
|
+ m.T["nickname"] = mynickname
|
|
|
+ m.T["avatar"] = myavatar
|
|
|
+ m.T["signature"] = wx.SignJSSDK(m.Site() + m.Url())
|
|
|
+ m.T["followLimit"] = followLimit
|
|
|
+ return m.Render("/weixin/follow/list.html", &m.T)
|
|
|
+}
|
|
|
+
|
|
|
+//添加关注项目
|
|
|
+func (m *Follow) Add() error {
|
|
|
+ myopenid, _ := m.Session().Get("s_m_openid").(string)
|
|
|
+ m.T["openid"] = se.EncodeString(myopenid)
|
|
|
+ m.T["signature"] = wx.SignJSSDK(m.Site() + m.Url())
|
|
|
+ mynickname, _ := m.Session().Get("s_nickname").(string)
|
|
|
+ myavatar, _ := m.Session().Get("s_avatar").(string)
|
|
|
+ m.T["nickname"] = mynickname
|
|
|
+ m.T["avatar"] = myavatar
|
|
|
+ return m.Render("/weixin/follow/add.html", &m.T)
|
|
|
+}
|
|
|
+
|
|
|
+//手动添加关注项目
|
|
|
+func (m *Follow) Addsave() error {
|
|
|
+ defer util.Catch()
|
|
|
+ var status = "n"
|
|
|
+ var id string
|
|
|
+ userId := m.GetSession("userId").(string)
|
|
|
+ openid := m.GetSession("s_m_openid").(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_openid": openid,
|
|
|
+ "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 && util.Int64All(bidopentime) != 0 {
|
|
|
+ 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
|
|
|
+}
|
|
|
+func (m *Follow) Set(tp, id string) error {
|
|
|
+ defer util.Catch()
|
|
|
+ isDel := false
|
|
|
+ id = util.DecodeArticleId2ByCheck(id)[0]
|
|
|
+ userid := util.ObjToString(m.GetSession("userId"))
|
|
|
+ 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,"s_userid":1}`
|
|
|
+ _id, _ := primitive.ObjectIDFromHex(id)
|
|
|
+ data, ok := mongodb.FindOneByField("follow_project", map[string]interface{}{
|
|
|
+ "_id": _id,
|
|
|
+ }, 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.Render("_error.html")
|
|
|
+ }
|
|
|
+ sid, _ := (*data)["s_id"].(string)
|
|
|
+ projectname, _ := (*data)["s_projectname"].(string)
|
|
|
+ projectcode, _ := (*data)["s_projectcode"].(string)
|
|
|
+ if util.ObjToString((*data)["s_userid"]) != userid {
|
|
|
+ return m.Redirect(fmt.Sprintf("/follow/photo/%s__%s__%s", util.EncodeArticleId2ByCheck(sid), projectname, projectcode))
|
|
|
+ }
|
|
|
+ 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()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ m.T["projectname"] = projectname
|
|
|
+ m.T["projectcode"] = projectcode
|
|
|
+ myopenid, _ := m.Session().Get("s_m_openid").(string)
|
|
|
+ m.T["openid"] = se.EncodeString(myopenid)
|
|
|
+ mynickname, _ := m.Session().Get("s_nickname").(string)
|
|
|
+ myavatar, _ := m.Session().Get("s_avatar").(string)
|
|
|
+ m.T["nickname"] = mynickname
|
|
|
+ m.T["avatar"] = myavatar
|
|
|
+ m.T["signature"] = wx.SignJSSDK(m.Site() + m.Url())
|
|
|
+ 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}`
|
|
|
+ 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
|
|
|
+}
|
|
|
+func (m *Follow) Notice(id, followId string) error {
|
|
|
+ defer util.Catch()
|
|
|
+ query := map[string]interface{}{
|
|
|
+ "_id": StringTOBsonId(id),
|
|
|
+ "s_userid": util.ObjToString(m.GetSession("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("/article/content/" + util.ObjToString(firstMap["s_id"]) + ".html?advertcode=" + m.GetString("advertcode"))
|
|
|
+ }
|
|
|
+ (*data)["a_relationinfo"] = relationinfo
|
|
|
+ }
|
|
|
+ m.T["data"] = data
|
|
|
+ }
|
|
|
+ m.T["id"] = util.EncodeArticleId2ByCheck(id)
|
|
|
+ m.T["openid"] = se.EncodeString(util.ObjToString(m.GetSession("s_m_openid")))
|
|
|
+ mynickname, _ := m.Session().Get("s_nickname").(string)
|
|
|
+ myavatar, _ := m.Session().Get("s_avatar").(string)
|
|
|
+ m.T["nickname"] = mynickname
|
|
|
+ m.T["avatar"] = myavatar
|
|
|
+ m.T["signature"] = wx.SignJSSDK(m.Site() + m.Url())
|
|
|
+ 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
|
|
|
+}
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+//删除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)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//拉新获取超级订阅
|
|
|
+func (this *Follow) FollowGift(shareid string) error {
|
|
|
+ defer util.Catch()
|
|
|
+ client := this.Header("User-Agent")
|
|
|
+ bm := mobileReg.MatchString(client)
|
|
|
+ openid, _ := this.Session().Get("s_m_openid").(string)
|
|
|
+ nickname, _ := this.Session().Get("s_nickname").(string)
|
|
|
+ redisName := util.ObjToString(config.Sysconfig["shareRedisName"])
|
|
|
+ headImg := ""
|
|
|
+ qrstr := ""
|
|
|
+ infos := ""
|
|
|
+ if !strings.Contains(shareid, "shareId_") {
|
|
|
+ rdata, ok := mongodb.FindOneByField("user", map[string]interface{}{"s_m_openid": shareid, "i_appid": 2}, `{"_id":1}`)
|
|
|
+ if rdata != nil && ok && len(*rdata) > 0 {
|
|
|
+ uid := BsonIdToSId((*rdata)["_id"])
|
|
|
+ infos = redis.GetStr(redisName, fmt.Sprintf("SF_%s", uid))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if shareUserid := redis.GetStr(redisName, shareid); shareUserid == "" && infos == "" {
|
|
|
+ return this.Render("/_error.html")
|
|
|
+ } else {
|
|
|
+ if infos == "" {
|
|
|
+ infos = redis.GetStr(redisName, fmt.Sprintf("SF_%s", shareUserid))
|
|
|
+ }
|
|
|
+ if infos != "" {
|
|
|
+ nickname = strings.Split(infos, "#@#@")[1]
|
|
|
+ headImg = strings.Split(infos, "#@#@")[2]
|
|
|
+ link := fmt.Sprintf("%s/front/followGift/%s", util.ObjToString(config.Sysconfig["webdomain"]), strings.Split(infos, "#@#@")[3])
|
|
|
+ r, _ := qr.Encode(link, qr.M)
|
|
|
+ pngdat := r.PNG()
|
|
|
+ qrstr = base64.StdEncoding.EncodeToString(pngdat)
|
|
|
+ shareid = strings.Split(infos, "#@#@")[3]
|
|
|
+ if jy.IsPhone(nickname) {
|
|
|
+ nickname = string(nickname[0:3]) + "****" + string(nickname[len(nickname)-4:])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if bm {
|
|
|
+ if openid == "" {
|
|
|
+ if this.Session().Get("s_m_openid") == nil {
|
|
|
+ if this.GetString("state") == "wx" {
|
|
|
+ //微信跳回来的
|
|
|
+ code := this.GetString("code")
|
|
|
+ if code != "" {
|
|
|
+ openid = jyutil.Getopenid(code)
|
|
|
+ if openid != "" {
|
|
|
+ if CheckUserIsSubscribe(openid) {
|
|
|
+ FindUserAndCreateSess(openid, this.Session(), "wx", false)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if public.CheckWxBrowser(this.Request) {
|
|
|
+ //所有参数都不再使用,跳到微信验证用户
|
|
|
+ return this.Redirect(fmt.Sprintf(config.Wxoauth, url.QueryEscape(this.Site()+this.Url()), "wx"), 302)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.T["shareid"] = shareid
|
|
|
+ this.T["share_nickname"] = nickname
|
|
|
+ this.T["share_headImg"] = headImg
|
|
|
+ this.T["openid"] = se.EncodeString(openid)
|
|
|
+ this.T["share_qr"] = qrstr
|
|
|
+ mynickname, _ := this.Session().Get("s_nickname").(string)
|
|
|
+ myavatar, _ := this.Session().Get("s_avatar").(string)
|
|
|
+ this.T["nickname"] = mynickname
|
|
|
+ this.T["avatar"] = myavatar
|
|
|
+ this.T["signature"] = wx.SignJSSDK(this.Site() + this.Url())
|
|
|
+ return this.Render("/frontRouter/wx/share/sess/b-share.html", &this.T)
|
|
|
+ } else {
|
|
|
+ this.T["shareid"] = shareid
|
|
|
+ this.T["share_nickname"] = nickname
|
|
|
+ this.T["share_headImg"] = headImg
|
|
|
+ this.T["signature"] = wx.SignJSSDK(this.Site() + this.Url())
|
|
|
+ this.T["isWeixin"] = public.CheckWxBrowser(this.Request)
|
|
|
+ this.T["share_qr"] = qrstr
|
|
|
+ return this.Render("/frontRouter/pc/share/sess/share-f.html", &this.T)
|
|
|
+ }
|
|
|
+}
|