12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667 |
- package front
- import (
- "context"
- "database/sql"
- "errors"
- "fmt"
- "github.com/gogf/gf/v2/frame/g"
- "io"
- "jy/src/jfw/config"
- "jy/src/jfw/wx"
- "log"
- "math/rand"
- "net/http"
- "net/url"
- "strconv"
- "sync"
- "github.com/gogf/gf/v2/util/gconv"
- "jy/src/jfw/jyutil"
- "app.yhyue.com/moapp/jypkg/public"
- util "app.yhyue.com/moapp/jybase/common"
- "app.yhyue.com/moapp/jybase/date"
- mg "app.yhyue.com/moapp/jybase/mongodb"
- "regexp"
- "strings"
- "time"
- elastic "app.yhyue.com/moapp/jybase/es"
- "app.yhyue.com/moapp/jybase/encrypt"
- "app.yhyue.com/moapp/jybase/go-xweb/xweb"
- "app.yhyue.com/moapp/jybase/redis"
- "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
- "github.com/SKatiyar/qr"
- "go.mongodb.org/mongo-driver/bson"
- )
- type Short struct {
- *xweb.Action
- article xweb.Mapper `xweb:"/article/(\\w+)/(.*).html"` //([pm])
- qr xweb.Mapper `xweb:"/biddetail/(\\w+)/qr/(.+)"`
- replication xweb.Mapper `xweb:"/front/shorturl/replication"` //用户复制操作记录入库
- nologinArticle xweb.Mapper `xweb:"/nologin/(\\w+)/(.*).html"` //([pm]) 无需登录
- whiteList xweb.Mapper `xweb:"/initialize/whiteList"` //白名单初始化
- clearCache xweb.Mapper `xweb:"/front/free/clearCache"` //清楚缓存
- notFindPage xweb.Mapper `xweb:"/front/notFind"` //清楚缓存
- }
- var (
- mobileReg = regexp.MustCompile("(?i)(Android|Mobile|Phone)")
- DateFullLayout = "2006-01-02 15:04:05"
- Map_stype = map[string]bool{
- "content": true,
- "entservice": true,
- "bdprivate": true,
- "mailprivate": true,
- "bdcontent": true,
- "indexcontent": true,
- "advancedProject": true,
- }
- //seoAgentReg = regexp.MustCompile("Baiduspider|360Spider|bingbot|Googlebot")
- detailNeedMosaic map[string]interface{}
- TypeCodeMap = map[string]string{
- "拟建": "拟建项目",
- "采购意向": "采购意向",
- "预告": "招标预告",
- "预审": "资格预审",
- "预审结果": "资格预审结果",
- "论证意见": "论证意见",
- "需求公示": "需求公示",
- "招标": "公开招标",
- "邀标": "邀请招标",
- "询价": "询价采购",
- "竞谈": "竞争性谈判",
- "单一": "单一来源采购",
- "竞价": "竞价公告",
- "变更": "变更公告",
- "中标": "中标公示",
- "成交": "成交公告",
- "废标": "废标公告",
- "流标": "流标公告",
- "合同": "合同公告信息",
- "验收": "验收公告信息",
- "违规": "违规信息",
- }
- PageTypeCheck = map[string]bool{
- "content": false,
- "entservice": false,
- "bdprivate": true,
- "mailprivate": false,
- "bdcontent": false,
- "indexcontent": true, //老首页 seo入口 供爬虫使用
- "advancedProject": false,
- }
- cacheIndex = []byte{}
- cacheLock = sync.Mutex{}
- )
- func (s *Short) NotFindPage() error {
- return s.Render("/pc/tags/404.html")
- }
- func (s *Short) ClearCache() {
- defer util.Catch()
- cacheLock.Lock()
- defer cacheLock.Unlock()
- log.Println("before cacheIndex:", string(cacheIndex))
- var (
- data = string(cacheIndex)
- )
- if len(cacheIndex) > 0 {
- cacheIndex = []byte{}
- }
- log.Println("after cacheIndex:", string(cacheIndex))
- s.ServeJson(map[string]interface{}{
- "state": len(cacheIndex),
- "index": data,
- })
- }
- func (s *Short) WhiteList() error {
- ipInitAuthentication := s.GetString("ipInitAuthentication")
- if ipInitAuthentication == config.Sysconfig["ipInitAuthentication"] {
- config.IpInit()
- log.Println("初始化ipInit配置")
- }
- return nil
- }
- func (s *Short) Article(stype, id string) error {
- //是否是移动端
- bm := mobileReg.MatchString(s.Header("User-Agent"))
- //是否是微信浏览器
- isWxB := public.CheckWxBrowser(s.Request)
- //userId, _ := s.GetSession("userId").(string)
- sess := s.Session().GetMultiple()
- //未登录用户是否访问的微信浏览器
- userId, _ := sess["userId"].(string)
- if strings.Contains(id, "/") {
- id = url.QueryEscape(id)
- }
- if userId == "" {
- if IsWxBrowserContent[stype] {
- if s.GetString("state") == "wx" {
- //微信跳回来的
- if code := s.GetString("code"); code != "" {
- if openid := jyutil.Getopenid(code); openid != "" {
- if CheckUserIsSubscribe(openid) {
- FindUserAndCreateSess(openid, s.Session(), "wx", false, true)
- //生session后 重新获取一下
- //userId, _ = s.GetSession("userId").(string)
- sess = s.Session().GetMultiple()
- experienceBinding := util.Int64All(sess["experience_binding"])
- userId, _ = sess["userId"].(string)
- //新关注微信公众号用户是否绑定手机号
- phone, ok := sess["phone"].(string)
- if ok && phone == "" && experienceBinding != 1 { //微信用户 体验绑定手机号
- //注册时间
- regTime := util.Int64All(s.GetSession("registedate"))
- //新用户时间
- accountMergeOnline, _ := config.Sysconfig["accountMergeOnline"].(string)
- if accountMergeOnline != "" && regTime > 0 {
- reg := time.Unix(regTime, 0)
- onLineTime, _ := time.ParseInLocation(date.Date_Full_Layout, accountMergeOnline, time.Local)
- //如果未绑定手机号,老用户不用强制绑定;新用户需要绑定手机号
- if onLineTime.Before(reg) {
- return s.Redirect("/swordfish/frontPage/userMerge/sess/bind?from=detail")
- }
- }
- }
- } else if !bm { //未关注用户 pc端到关注页面
- log.Println("PC微信端浏览器 未关注用户 访问地址----")
- s.Request.Header.Del("Referer")
- return s.Redirect("/swordfish/frontPage/user/free/redirect-wx")
- } //未关注用户 移动端下面处理
- }
- }
- } else if isWxB {
- //所有参数都不再使用,跳到微信验证用户
- return s.Redirect(fmt.Sprintf(config.Wxoauth, url.QueryEscape(s.Site()+s.Url()), "wx"), 302)
- }
- }
- }
- //PC端未登录用户程序走此逻辑 WX端走原来逻辑
- if !bm && (stype == "content" || stype == "indexcontent" || stype == "mailprivate") && userId == "" {
- sids := encrypt.CommonDecodeArticle(stype, id)
- if len(sids) == 0 || (len(sids) > 0 && sids[0] == "") {
- return s.Redirect(getErrPageUrl(bm, DecodeErr), 302)
- }
- //2024.11.26 增加新标讯未登录 /article/content 302 到seo/nologin/content
- if mgoId := sids[0]; stype == "content" && mgoId != "" {
- if bid := mg.StringTOBsonId(mgoId); bid.Timestamp().Unix() > 1732550400 {
- return s.Redirect(fmt.Sprintf("/nologin/content/%s.html", id), 302)
- }
- }
- return s.NologinCommon("", stype, id, sids[0], bm)
- }
- return s.LoginCommon(sess, stype, id, bm)
- }
- const (
- DecodeErr = iota + 1
- QueryErr
- UndefinedType
- )
- func getErrPageUrl(isMobile bool, t int) string {
- if isMobile {
- return fmt.Sprintf("/jyapp/notFind?t=%d", t)
- }
- return fmt.Sprintf("/front/notFind?t=%d", t)
- }
- func (s *Short) LoginCommon(sess map[string]interface{}, stype, id string, bm bool) error {
- userId, _ := sess["userId"].(string)
- log.Println(stype, "----stype:---", id, "---userId---:", userId, "----", bm)
- //电脑端 剑鱼快照页面访问
- if !bm {
- //工作桌面内嵌 快照页
- //老地址(地址不包含aside)且非工作桌面地址
- if !strings.Contains(s.Request.URL.String(), "aside") && !strings.Contains(s.Request.URL.String(), "page_workDesktop") {
- tg := &Tags{} //415 第二版 添加右侧推荐 工作台外登录 不在重定向跳转
- s.T["newBidInfoList"] = tg.GetNewBidInfo()
- s.T["industryInfoList"] = tg.GetConsult()
- s.T["hotLabelList"] = tg.GetHotLabel(30)
- }
- if inWorkDesktop, _ := s.GetInt("inWorkDesktop"); inWorkDesktop == 1 && !strings.Contains(s.Request.URL.String(), "page_workDesktop") {
- return s.Redirect(fmt.Sprintf("%s%s%s", config.Sysconfig["workDesktopUrl"].(string), config.Sysconfig["webdomain"].(string), url.QueryEscape(strings.Replace(s.Request.URL.String(), "inWorkDesktop=1", "inWorkDesktop=0", 1))))
- }
- //P406登录用户标讯详情页改版
- if userId != "" {
- sids := encrypt.CommonDecodeArticle(stype, id)
- if len(sids) == 0 || (len(sids) > 0 && sids[0] == "") {
- s.Redirect(getErrPageUrl(bm, DecodeErr), 302)
- return nil
- }
- s.T["title"], s.T["keywords"], s.T["description"] = GetTDK(stype, sids[0])
- return s.Render("/pc/detail/biddetail_login.html", &s.T)
- }
- } else if userId != "" { //移动端登录
- //mobileHtmlKey := "jy_mobile_index_wx"
- var loginPageInfo = func() (body []byte) {
- // 获取页面内容
- mobileUrl := fmt.Sprintf("%s%s", config.Sysconfig["webdomain"].(string), "/jy_mobile/index.html")
- log.Println("article --- mobileUrl :", mobileUrl)
- req, err := http.NewRequest("GET", mobileUrl, nil)
- if err != nil {
- log.Println(s.ResponseWriter, "Failed to fetch page", http.StatusInternalServerError)
- return
- }
- req.Header.Set("mobile_index", "wx")
- req.Header.Set("X-Forwarded-For", util.GetIp(s.Request))
- client := &http.Client{}
- // 使用 Do 方法处理请求
- resp, err := client.Do(req)
- if err != nil {
- log.Println(s.ResponseWriter, "Failed to create client", http.StatusInternalServerError)
- return
- }
- defer resp.Body.Close()
- body, err = io.ReadAll(resp.Body)
- if err != nil {
- log.Println(s.ResponseWriter, "Failed to read response body", http.StatusInternalServerError)
- return
- }
- //err = redis.PutBytes(redisLimitation, mobileHtmlKey, &body, 3*24*60*60)
- //if err != nil {
- // log.Println("mobile html redis cache err :", err.Error())
- //}
- return
- }
- // 将页面内容返回给前端
- s.ResponseWriter.Header().Set("Content-Type", "text/html; charset=utf-8")
- cacheLock.Lock()
- if len(cacheIndex) == 0 {
- cacheIndex = loginPageInfo()
- }
- cacheLock.Unlock()
- s.ResponseWriter.Write(cacheIndex)
- return nil
- }
- //getsession := s.Session().GetMultiple()
- //先判断是否有session
- source := s.GetString("source")
- disWord := s.GetString("disWord")
- aboutUrl := "/swordfish/about"
- //是否已经检查过,默认是检查过-true,分享过来的是未检查过-false
- // checkIsSubscribeFlag := true
- // if source == "app_infocontentshare" || source == "wx_infocontentshare" {
- // checkIsSubscribeFlag = false
- // }
- from_userid := ""
- if source != "" {
- aboutUrl += "?source=" + source
- if strings.Contains(source, "wx_infocontentshare") {
- decodeArr := encrypt.DecodeArticleId2ByCheck(id)
- if len(decodeArr) > 1 {
- from_userid = se.Encode2Hex(GetUserId(decodeArr[1])) //加密用户userid
- }
- } else if strings.Contains(source, "app_infocontentshare") {
- if from := s.GetString("from"); from != "" {
- from_userid = from
- }
- }
- aboutUrl += "&from=" + from_userid
- }
- if !Map_stype[stype] {
- return s.Redirect(getErrPageUrl(bm, UndefinedType), 302)
- } else if stype == "content" || stype == "bdcontent" || stype == "advancedProject" {
- if userId == "" { //} && !regclient.MatchString(client) { //没有用户session //搜索引擎让过
- s.Session().Set("referer", s.Request.RequestURI)
- if bm { //是否是移动端访问
- s.Redirect(aboutUrl, 302)
- return nil
- } else {
- if stype == "bdcontent" {
- var retMap = make(map[string]interface{})
- stype = "content"
- sids := encrypt.CommonDecodeArticle(stype, id)
- if len(sids) == 0 || (len(sids) > 0 && sids[0] == "") {
- return s.Redirect(getErrPageUrl(bm, DecodeErr), 302)
- }
- _, _, _, obj := pcVRT(sids[0], "", stype, true, true)
- if obj != nil && len(obj) > 0 {
- retMap["_id"] = url.QueryEscape(id)
- retMap["title"], _ = obj["title"].(string)
- retMap["area"], _ = obj["area"].(string)
- retMap["subtype"], _ = obj["subtype"].(string)
- retMap["subscopeclass"], _ = obj["s_subscopeclass"].(string)
- retMap["publishtime"] = util.IntAll(obj["publishtime"])
- retMap["keywords"] = KeyWordHandle(obj)
- retMap["description"] = DescriptionHandle(stype, obj)
- }
- s.T["shareid"] = config.Seoconfig["baiduSEM-p"].(string)
- s.T["logid"] = config.Seoconfig["baiduSEM-p"].(string)
- s.T["obj"] = retMap
- s.Render("/pc/biddetail_bd.html", &s.T)
- } else {
- s.Redirect(getErrPageUrl(bm, UndefinedType), 302)
- }
- }
- return nil
- } else if disWord != "" {
- from_userid = disWordNil(disWord, userId)
- }
- if stype == "bdcontent" {
- stype = "content"
- }
- } else if stype == "entservice" { //大客户数据快照展示
- //se := util.SimpleEncrypt{"entservice"}
- sid := encrypt.SE3.DecodeString(id)
- log.Println("----sid:---", sid)
- if len(sid) == 0 || (len(sid) > 0 && sid == "") { //未登录用户没有权限访问---userId == "" || 未登录可以访问来自陈 11.29
- return s.Redirect(getErrPageUrl(bm, DecodeErr), 302)
- }
- catchKey := fmt.Sprintf("jypcdetail_%s_%s_%s", userId, stype, sid)
- if res := redis.Get(redisLimitation, catchKey); res == nil || res == "" {
- industry := s.GetString("industry")
- var shareid = s.GetString("id")
- if len(shareid) == 0 {
- shareid = "10"
- }
- s.T["logid"] = config.Seoconfig["jysskzy"].(string)
- s.T["shareid"] = se.EncodeString(shareid)
- s.T["keywords"] = s.GetString("kds")
- ssOpenid := sess["s_m_openid"]
- po, bo, wo, obj := pcVRT(sid, industry, stype, true, true)
- if obj != nil && len(obj) > 0 {
- if len(po) > 0 {
- s.T["projectOther"] = po
- }
- if len(bo) > 0 {
- s.T["buyerOther"] = bo
- }
- if len(wo) > 0 {
- s.T["winnerOther"] = wo
- }
- obj["urlpath"] = s.Uri()
- obj["industry"] = industry
- if ssOpenid != nil {
- obj["ucbsId"] = encrypt.EncodeArticleId2ByCheck("ucbs#" + ssOpenid.(string) + "#" + id)
- }
- //if false && isbid(obj["subtype"]) {
- // //bidding表有数据就有,没有不再查此中标企业得其他信息--需求来自数据和质量
- // obj["winner_enttel"] = "" //getwinnertel(obj["winner"])
- //}
- //判断时间 //如果是seo页面超过时间访问的进入首页
- comeinTime := time.Unix(util.Int64All(obj["comeintime"]), 0)
- if stype == "indexcontent" {
- if count := public.MQFW.Count("seobidding", map[string]interface{}{"bid": sid}); count <= 0 && comeinTime.Before(time.Now().Add(time.Duration(-util.IntAll(config.Sysconfig["seoBeforeTimeHour"]))*time.Hour)) {
- return s.Redirect("/")
- }
- }
- FieldProcessing(obj, ssOpenid, industry, id, from_userid, userId, stype, false)
- if obj["projectname"] != nil {
- s.SetSession("projectname", obj["projectname"])
- }
- if obj["entidlist"] != nil { //大会员中标企业跳转至画像
- s_winner := util.ObjToString(obj["s_winner"])
- idObjs, _ := obj["entidlist"].([]interface{})
- winnerIdArr := []string{}
- for _, v := range strings.Split(s_winner, ",") {
- if v == "-" || !isInStringArr(util.ObjArrToStringArr(idObjs), v) {
- continue
- }
- winnerIdArr = append(winnerIdArr, encrypt.EncodeArticleId2ByCheck(v))
- obj["entIds"] = winnerIdArr
- }
- }
- if obj["publishtime"] != nil {
- obj["publishtimeShorDate"] = time.Unix(util.Int64All(obj["publishtime"]), 0).Format(date.Date_Short_Layout)
- }
- s.T["url"] = s.Uri()
- obj["keywords"] = KeyWordHandle(obj)
- obj["description"] = DescriptionHandle(stype, obj)
- s.T["obj"] = obj
- content, _ := s.Render4Cache("/pc/biddetail_rec.html", &s.T)
- redis.Put(redisLimitation, catchKey, string(content), 60*20)
- return s.SetBody(content)
- } else {
- return s.Redirect(getErrPageUrl(bm, QueryErr), 302)
- }
- } else {
- return s.SetBody([]byte(res.(string)))
- }
- }
- ssOpenid := sess["s_m_openid"]
- var (
- res *map[string]interface{}
- ok bool
- )
- if userId == "" && ssOpenid != nil {
- res, ok = mongodb.FindOneByField("user", bson.M{"s_m_openid": ssOpenid, "s_unionid": bson.M{"$ne": ssOpenid}}, `{"i_vip_status":1,"i_member_status":1,"s_m_phone":1,"s_phone":1,"l_vip_starttime":1}`)
- if ok {
- userId = mg.BsonIdToSId((*res)["_id"])
- }
- } else if userId != "" {
- //判断用户是否是vip
- res = jyutil.Compatible.Select(userId, `{"i_vip_status":1,"i_member_status":1,"s_m_phone":1,"s_phone":1,"l_vip_starttime":1}`)
- }
- userPower := jy.GetBigVipUserBaseMsg(s.Session(), *config.Middleground)
- var (
- isEntnicheNew = userPower.EntIsNew //新版超级订阅
- isOldVip = false //新购超级订阅不能查看拟建项目详情页
- isVip = userPower.VipStatus > 0 //超级订阅
- isMember = userPower.Status > 0 //大会员
- isEntniche = userPower.EntnicheStatus > 0 //商机管理
- privatedata = userPower.PrivateGD //广东移动DICT 用户
- isEntService = userPower.Data.Ent.PowerSource > 0 && userPower.Data.Entniche.IsEntPower > 0 //商机管理服务
- newCanRead = false
- )
- if res != nil && len(*res) > 0 {
- if isVip && util.Int64All((*res)["l_vip_starttime"]) < util.Int64All(config.Sysconfig["contextOldVipLimit"]) {
- isOldVip = true
- }
- }
- //entid := util.Int64All(s.GetSession("entId"))
- entId := util.IntAll(sess["entId"])
- if entId > 0 && userPower.EntInfo[entId] != nil {
- isEntniche = userPower.EntInfo[entId].Status == 1 && userPower.EntInfo[entId].IsPower
- isEntnicheNew = userPower.EntInfo[entId].IsNew && isEntniche
- if isEntService = userPower.EntInfo[entId].IsService && userPower.EntInfo[entId].IsPower; isEntService {
- isEntnicheNew = false
- isEntniche = false
- }
- }
- if !isEntniche && privatedata {
- isEntniche = true
- }
- s.T["isVip"] = isVip
- s.T["isMember"] = isMember
- s.T["isEntniche"] = isEntniche
- s.T["isEntnicheNew"] = isEntnicheNew
- s.T["isEntService"] = isEntService
- if bm {
- //判断有没有取关,取关的话,跳转到关于剑鱼标讯页面
- if ssOpenid != nil && ssOpenid != "" {
- isSubscribe := CheckUserIsSubscribe(ssOpenid.(string))
- if !isSubscribe {
- return s.Redirect(aboutUrl, 302)
- }
- //之前sessionkeep.go中没有放userId,造成关注有问题
- if userId == "" {
- FindUserAndCreateSess(ssOpenid.(string), s.Session(), "wx", false, true)
- }
- }
- surl := s.GetString("url")
- kds := s.GetString("keywords")
- industry := s.GetString("industry")
- var shareopenid, sid string
- sid_openid := encrypt.CommonDecodeArticle(stype, id)
- switch len(sid_openid) {
- case 0:
- return s.Redirect(getErrPageUrl(bm, DecodeErr), 302)
- default:
- shareopenid, sid = SwiDef(sid_openid)
- }
- if stype == "advancedProject" {
- //判断此用户是否有打开的权限
- //newUserId := s.GetSession("base_user_id")
- newUserId := sess["base_user_id"]
- pushData := public.BaseMysql.FindOne("leadproject_push", map[string]interface{}{"user_id": newUserId, "info_id": sid}, "id", "")
- //访问次数加1
- if pushData == nil {
- newCanRead = false
- } else {
- public.BaseMysql.UpdateOrDeleteBySql("UPDATE leadproject_push SET visit_count=visit_count+1 ,lastvisit_time=? WHERE id = ?", time.Now().Format("2006-01-02 15:04:05"), (*pushData)["id"])
- newCanRead = true
- }
- }
- s.T["keywords"] = kds
- if shareopenid != "" {
- s.T["shareopenid"] = shareopenid
- }
- myopenid, _ := sess["s_m_openid"].(string)
- if myopenid == "" {
- myopenid = shareopenid
- s.T["openid"] = myopenid //"-1"
- } else {
- s.T["openid"] = se.EncodeString(myopenid) //"-1"
- }
- //mynickname, _ := s.GetSession("s_nickname").(string)
- //myavatar, _ := s.GetSession("s_avatar").(string)
- mynickname := util.ObjToString(sess["s_nickname"])
- myavatar := util.ObjToString(sess["s_avatar"])
- s.T["nickname"] = mynickname
- s.T["avatar"] = myavatar
- s.T["signature"] = wx.SignJSSDK(s.Site() + s.Url())
- obj := wxvisitD(sid, userId, myopenid, stype, (isVip && isOldVip) || isMember || isEntniche || newCanRead)
- canRead := false
- if ((isVip && isOldVip) || isMember || isEntniche) || //老版本vip、大会员、商机管理
- ((isVip && !isOldVip) && (!(util.ObjToString(obj["subtype"]) == "拟建" || util.ObjToString(obj["subtype"]) == "采购意向"))) || //新超级订阅非采购意向”和“拟建项目”
- stype == "mailprivate" || stype == "indexcontent" || stype == "bdprivate" { //邮箱推送
- canRead = true
- } else {
- canRead = SeeDetailLimit(obj, userId, sid)
- }
- if newCanRead {
- canRead = newCanRead
- s.T["canRead"] = canRead
- }
- if len(obj) > 0 {
- if canRead {
- FieldProcessing(obj, ssOpenid, industry, id, from_userid, userId, stype, true)
- //免费用户正文手机号替换
- if obj["site"] == "剑鱼信息发布平台" && !isMember {
- //采购电话中标单位电话置空
- if util.InterfaceToStr(obj["buyertel"]) != "" {
- obj["buyertel"] = "freeView"
- }
- if util.InterfaceToStr(obj["winnertel"]) != "" {
- obj["winnertel"] = "freeView"
- }
- //正文电话 手机号 邮箱处理
- if detail, _ := obj["detail"].(string); detail != "" {
- //手机号
- re1 := regexp.MustCompile("1[345789]{1}\\d{9}")
- detail1 := re1.ReplaceAllString(detail, `<span class="freeView">点击查看</span>`)
- code := util.InterfaceToStr(obj["projectcode"])
- if code != "" {
- detail1 = strings.ReplaceAll(detail1, code, "*********")
- }
- //座机
- re2 := regexp.MustCompile("((0\\d{2,3})-)(\\d{7,8})(-(\\d{3,}))?")
- detail2 := re2.ReplaceAllString(detail1, `<span class="freeView">点击查看</span>`)
- re4 := regexp.MustCompile("((400)-)(\\d{3,4}-)(\\d{3,})")
- detail4 := re4.ReplaceAllString(detail2, `<span class="freeView">点击查看</span>`)
- //邮箱
- re3 := regexp.MustCompile("([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)")
- detail3 := re3.ReplaceAllString(detail4, `<span class="freeView">点击查看</span>`)
- obj["detail"] = strings.ReplaceAll(strings.ReplaceAll(detail3, `<span class="freeView">点击查看</span><span class="freeView">点击查看</span>`, `<span class="freeView">点击查看</span>`), "*********", code)
- }
- }
- if obj["entidlist"] != nil { //大会员中标企业跳转至画像
- s_winner := util.ObjToString(obj["s_winner"])
- idObjs, _ := obj["entidlist"].([]interface{})
- winnerIdArr := []string{}
- for _, v := range strings.Split(s_winner, ",") {
- if v == "-" || !isInStringArr(util.ObjArrToStringArr(idObjs), v) {
- continue
- }
- winnerIdArr = append(winnerIdArr, encrypt.EncodeArticleId2ByCheck(v))
- obj["entIds"] = winnerIdArr
- }
- }
- //原 拟建类型可以进入,进行打码操作,后根据需求改成遮罩
- if !canRead { //登录拟建&采购不展示遮罩 只打码
- //canRead = true
- //打码显示引导
- otherFilter(obj, userId != "")
- }
- s.T["advertcode"] = s.GetString("advertcode")
- } else {
- obj = map[string]interface{}{
- "title": obj["title"],
- "_id": obj["_id"],
- "subtype": obj["subtype"],
- "originalShow": false,
- }
- }
- //纠错随机回复
- recoveryRight, _ := config.Sysconfig["recoveryRight"].([]interface{})
- recVal := rand.New(rand.NewSource(time.Now().UnixNano())).Intn(len(recoveryRight))
- s.T["recVal"] = util.ObjToString(recoveryRight[recVal])
- s.T["advertImg"] = config.Sysconfig["advertImg"]
- s.T["advertName"] = config.Sysconfig["advertName"]
- s.T["advertUrl"] = config.Sysconfig["advertUrl"]
- s.T["canRead"] = canRead
- obj["industry"] = industry
- obj["keywords"] = KeyWordHandle(obj)
- obj["description"] = DescriptionHandle(stype, obj)
- s.T["obj"] = obj
- //获取打赏文案
- s.T["rewardText"], s.T["advertText"] = getRewardText()
- content, _ := s.Render4Cache("/weixin/wxinfocontent_rec.html", &s.T)
- return s.SetBody(content)
- } else if surl == "" {
- return s.Redirect(getErrPageUrl(bm, QueryErr), 302)
- } else {
- return s.Redirect(surl)
- }
- } else {
- sids := encrypt.CommonDecodeArticle(stype, id)
- if len(sids) == 0 || (len(sids) > 0 && sids[0] == "") {
- return s.Redirect(getErrPageUrl(bm, DecodeErr), 302)
- }
- sid := sids[0]
- //免费用户浏览三级页判断留资与浏览次数
- //indust := s.GetString("industry")
- if userId != "" && stype == "indexcontent" { //已登录用户直接跳转至正常三级页
- return s.Redirect(fmt.Sprintf("/article/content/%s.html", encrypt.EncodeArticleId2ByCheck(sid)))
- }
- if stype == "advancedProject" {
- //判断此用户是否有打开的权限
- //newUserId := s.GetSession("base_user_id")
- newUserId := sess["base_user_id"]
- pushData := public.BaseMysql.FindOne("leadproject_push", map[string]interface{}{"user_id": newUserId, "info_id": sid}, "id", "")
- //访问次数加1
- if pushData == nil {
- newCanRead = false
- } else {
- public.BaseMysql.UpdateOrDeleteBySql("UPDATE leadproject_push SET visit_count=visit_count+1 ,lastvisit_time=? WHERE id = ?", time.Now().Format("2006-01-02 15:04:05"), (*pushData)["id"])
- newCanRead = true
- }
- }
- var detailKey = func() string {
- if (isVip && isOldVip) || isMember || isEntniche || newCanRead || stype == "mailprivate" || stype == "indexcontent" || stype == "bdprivate" {
- return "pay" //可以看全部
- } else if isVip && !isOldVip {
- return "new_vip_pay" //新版超级订阅不能看 采购意向
- } else if SeeDetailLimit(nil, userId, sid) {
- return "saleLeads_free" //未留资 三篇非采购意向信息;留资后同pay
- } else {
- return "free" //已经免费查看三篇招标信息,且未留资。任何信息都不能看 有遮罩
- }
- }()
- catchKey := fmt.Sprintf("jypcdetail_%s_%s_%s", detailKey, stype, sid)
- if res := redis.Get(redisLimitation, catchKey); res == nil || res == "" {
- redisTimeOut := util.If((isVip && isOldVip) || isMember || isEntniche || newCanRead, detailRedisByPayTimeOut, detailRedisByFreeTimeOut).(int)
- industry := s.GetString("industry")
- var shareid = s.GetString("id")
- if len(shareid) == 0 {
- shareid = "10"
- }
- s.T["logid"] = config.Seoconfig["jysskzy"].(string)
- s.T["shareid"] = se.EncodeString(shareid)
- s.T["keywords"] = s.GetString("kds")
- s.DisableHttpCache()
- po, bo, wo, obj := pcVRT(sid, industry, stype, isVip || isMember || isEntniche || newCanRead, true)
- if obj != nil && len(obj) > 0 {
- var node bool
- if ((isVip && isOldVip) || isMember || isEntniche) || //老版本vip、大会员、商机管理 白名单
- ((isVip && !isOldVip) && (!(util.ObjToString(obj["subtype"]) == "拟建" || util.ObjToString(obj["subtype"]) == "采购意向"))) || //新超级订阅非采购意向”和“拟建项目”
- stype == "mailprivate" || stype == "indexcontent" || stype == "bdprivate" { //邮箱推送
- node = true
- } else {
- //_, _, _, objc := pcVRT(sid, indust, stype, isVip || isMember || isEntniche)
- node = SeeDetailLimit(obj, userId, sid)
- }
- if obj["publishtime"] != nil {
- obj["publishtimeShorDate"] = time.Unix(util.Int64All(obj["publishtime"]), 0).Format(date.Date_Short_Layout)
- }
- s.T["canRead"] = node
- if newCanRead {
- s.T["canRead"] = newCanRead
- node = newCanRead
- }
- if node {
- if len(po) > 0 {
- s.T["projectOther"] = po
- }
- if len(bo) > 0 {
- s.T["buyerOther"] = bo
- }
- if len(wo) > 0 {
- s.T["winnerOther"] = wo
- }
- //判断时间 //如果是seo页面超过时间访问的进入首页
- comeinTime := time.Unix(util.Int64All(obj["comeintime"]), 0)
- if stype == "indexcontent" {
- if count := public.MQFW.Count("seobidding", map[string]interface{}{"bid": sid}); count <= 0 && comeinTime.Before(time.Now().Add(time.Duration(-util.IntAll(config.Sysconfig["seoBeforeTimeHour"]))*time.Hour)) {
- return s.Redirect("/")
- }
- }
- FieldProcessing(obj, ssOpenid, industry, id, from_userid, userId, stype, false)
- //免费用户正文手机号替换
- if obj["site"] == "剑鱼信息发布平台" && !isMember {
- //采购电话中标单位电话置空
- if util.InterfaceToStr(obj["buyertel"]) != "" {
- obj["buyertel"] = "freeView"
- }
- if util.InterfaceToStr(obj["winnertel"]) != "" {
- obj["winnertel"] = "freeView"
- }
- //正文电话 手机号 邮箱处理
- if detail, _ := obj["detail"].(string); detail != "" {
- //手机号
- re1 := regexp.MustCompile("1[345789]{1}\\d{9}")
- detail1 := re1.ReplaceAllString(detail, `<span class="freeView">点击查看</span>`)
- code := util.InterfaceToStr(obj["projectcode"])
- if code != "" {
- detail1 = strings.ReplaceAll(detail1, code, "*********")
- }
- //座机
- re2 := regexp.MustCompile("((0\\d{2,3})-)(\\d{7,8})(-(\\d{3,}))?")
- detail2 := re2.ReplaceAllString(detail1, `<span class="freeView">点击查看</span>`)
- re4 := regexp.MustCompile("((400)-)(\\d{3,4}-)(\\d{3,})")
- detail4 := re4.ReplaceAllString(detail2, `<span class="freeView">点击查看</span>`)
- //邮箱
- re3 := regexp.MustCompile("([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)")
- detail3 := re3.ReplaceAllString(detail4, `<span class="freeView">点击查看</span>`)
- obj["detail"] = strings.ReplaceAll(strings.ReplaceAll(detail3, `<span class="freeView">点击查看</span><span class="freeView">点击查看</span>`, `<span class="freeView">点击查看</span>`), "*********", code)
- }
- }
- if obj["projectname"] != nil {
- s.SetSession("projectname", obj["projectname"])
- }
- if obj["entidlist"] != nil { //大会员中标企业跳转至画像
- s_winner := util.ObjToString(obj["s_winner"])
- idObjs, _ := obj["entidlist"].([]interface{})
- winnerIdArr := []string{}
- for _, v := range strings.Split(s_winner, ",") {
- if v == "-" || !isInStringArr(util.ObjArrToStringArr(idObjs), v) {
- continue
- }
- winnerIdArr = append(winnerIdArr, encrypt.EncodeArticleId2ByCheck(v))
- obj["entIds"] = winnerIdArr
- }
- }
- if !node {
- //打码遮罩
- //s.T["canRead"] = true
- otherFilter(obj, userId != "")
- }
- } else {
- obj = map[string]interface{}{
- "title": obj["title"],
- "_id": obj["_id"],
- "subtype": obj["subtype"],
- "stypeadd": obj["stypeadd"],
- "originalShow": false,
- }
- }
- obj["urlpath"] = s.Uri()
- obj["industry"] = industry
- if ssOpenid != nil {
- obj["ucbsId"] = encrypt.EncodeArticleId2ByCheck("ucbs#" + ssOpenid.(string) + "#" + id)
- }
- obj["keywords"] = KeyWordHandle(obj)
- obj["description"] = DescriptionHandle(stype, obj)
- s.T["obj"] = obj
- s.T["url"] = s.Uri()
- content, _ := s.Render4Cache("/pc/biddetail_rec.html", &s.T)
- redis.Put(redisLimitation, catchKey, string(content), redisTimeOut)
- return s.SetBody(content)
- //return s.Render("/pc/biddetail_rec.html", &s.T)
- } else {
- return s.Redirect(getErrPageUrl(bm, QueryErr), 302)
- }
- } else {
- return s.SetBody([]byte(res.(string)))
- }
- }
- return nil
- }
- func CNode(userId string) bool {
- if hasRetainedCapital(userId, []string{"jyarticle_see3_plus", "jyarticle_see3_plus_pc", "jyarticle_see3_plus_wx", "jyarticle_see3_plus_app", "pc_article_member_freeuse", "app_article_member_freeuse", "app_article_member_freeuse", "wx_article_member_freeuse", "h5_article_member_freeuse"}) {
- return true
- }
- rM := map[string]interface{}{}
- rdata, ok := mongodb.Find("saleLeads", map[string]interface{}{
- "userid": userId,
- }, `{"createtime":-1}`, nil, false, 0, 10)
- if rdata != nil && len(*rdata) > 0 && ok {
- for _, v := range *rdata {
- for kk, vv := range v {
- if vv == nil {
- continue
- }
- if rM[kk] != nil {
- continue
- }
- rM[kk] = vv
- }
- }
- delete(rM, "_id")
- delete(rM, "userid")
- delete(rM, "createtime")
- delete(rM, "client")
- }
- if userinfo := jyutil.Compatible.Select(userId, `{"s_phone":1,"s_m_phone":1,"s_myemail":1,"s_company":1,"o_jy":1,"o_vipjy":1}`); userinfo != nil && len(*userinfo) > 0 {
- s_phone := util.ObjToString((*userinfo)["s_phone"])
- phone := util.If(s_phone == "", util.ObjToString((*userinfo)["s_m_phone"]), s_phone)
- if rM["phone"] == nil || rM["phone"] == "" {
- rM["phone"] = phone
- }
- if rM["company"] == nil || rM["company"] == "" {
- rM["company"] = util.ObjToString((*userinfo)["s_company"])
- }
- }
- if rM["name"] != nil && rM["name"] != "" && rM["phone"] != nil && rM["phone"] != "" && rM["company"] != nil && rM["company"] != "" && rM["position"] != nil && rM["position"] != "" && rM["companyType"] != "" {
- if rM["position"] != "总裁" && rM["position"] != "总经理" && (rM["branch"] == nil || rM["branch"] == "") {
- return false
- }
- return true
- }
- return false
- }
- // 查看公告详情次数限制
- func SeeDetailLimit(obj map[string]interface{}, userId, sid string) bool {
- watchKey := fmt.Sprintf("article_count_%d_%s_%d_%s", time.Now().Year(), time.Now().Month(), time.Now().Day(), userId)
- subTypeStr, _ := obj["subtype"].(string)
- if strings.Contains(subTypeStr, "拟建") || strings.Contains(subTypeStr, "采购意向") {
- return false
- } else {
- //检验是否留资
- if CNode(userId) {
- return true
- }
- if seeRes := redis.Get(redisLimitation, watchKey); seeRes != nil && seeRes != "" {
- if resVal, _ := seeRes.(string); resVal != "" {
- sidss := strings.Split(resVal, "_")
- canRead := config.Sysconfig["canReadNotice"]
- if len(sidss) < util.IntAll(canRead) {
- sidss = append(sidss, sid)
- arrs := RemoveDuplicatesAndEmpty(sidss)
- newVal := strings.Join(arrs, "_")
- redis.Put(redisLimitation, watchKey, newVal, jy.GetExpire())
- return true
- } else {
- for _, v := range sidss {
- if sid == v {
- return true
- }
- }
- return false
- }
- }
- } else {
- redis.Put(redisLimitation, watchKey, sid, jy.GetExpire())
- return true
- }
- }
- return false
- }
- func SwiDef(sid_openid []string) (string, string) {
- var shareopenid, sid string
- if len(sid_openid) > 1 {
- sid = sid_openid[0]
- shareopenid = sid_openid[1]
- } else {
- sid = sid_openid[0]
- }
- return shareopenid, sid
- }
- // user 权限获取
- func UserPermission(userId string, ssOpenid interface{}) (bool, bool, bool) {
- var (
- res *map[string]interface{}
- isVip, isMember, isEntniche, privatedata bool
- )
- if userId == "" && ssOpenid != nil {
- res, _ = mongodb.FindOneByField("user", bson.M{"s_m_openid": ssOpenid, "s_unionid": bson.M{"$ne": ssOpenid}}, `{"i_vip_status":1,"i_member_status":1,"s_m_phone":1,"s_phone":1}`)
- userId = mg.BsonIdToSId((*res)["_id"])
- } else {
- //判断用户是否是vip
- res = jyutil.Compatible.Select(userId, `{"i_vip_status":1,"i_member_status":1,"s_m_phone":1,"s_phone":1}`)
- }
- isVip = util.IntAll((*res)["i_vip_status"]) == 1 || util.IntAll((*res)["i_vip_status"]) == 2
- isMember = util.IntAll((*res)["i_member_status"]) > 0
- if phone, _ := util.If(util.ObjToString((*res)["s_phone"]) != "", util.ObjToString((*res)["s_phone"]), util.ObjToString((*res)["s_m_phone"])).(string); phone != "" {
- isEntniche = public.Mysql.CountBySql(`SELECT count(1) from entniche_user a INNER JOIN entniche_info b on (a.phone=? and a.power=1 and a.ent_id=b.id and b.status>0)`, phone) > 0
- privatedata = public.Mysql.CountBySql(`select count(1) from privatedata where phone = ?`, phone) > 0
- }
- if !isEntniche && privatedata {
- isEntniche = true
- }
- return isVip, isMember, isEntniche
- }
- // pc 移动共用字段处理
- func FieldProcessing(obj map[string]interface{}, ssOpenid interface{}, industry, id, from_userid, userId, stype string, b bool) {
- obj["industry"] = industry
- if ssOpenid != nil {
- obj["ucbsId"] = encrypt.EncodeArticleId2ByCheck("ucbs#" + ssOpenid.(string) + "#" + id)
- }
- //判断是否公开联系人信息
- if util.Int64All(obj["buyerhint"]) == 2 {
- obj["buyerperson"] = ""
- obj["buyertel"] = ""
- }
- href, _ := obj["href"].(string)
- if !b {
- href = strings.Replace(href, "\n", "", -1)
- if href != "" && !strings.HasPrefix(href, "http") {
- href = "http://" + href
- }
- obj["url"] = href
- obj["buyerSeoId"] = EsSeoId(false, util.InterfaceToStr(obj["buyer"]))
- }
- //P385 查看原文
- obj["originalShow"] = false
- if href != "" && userId != "" {
- obj["originalShow"] = true
- }
- //大会员中标企业跳转至画像
- if obj["entidlist"] != nil {
- if s_winner := util.ObjToString(obj["s_winner"]); s_winner != "" {
- entIdArr, winnerMap, winnerSeoMap := []string{}, map[string]interface{}{}, map[string]interface{}{}
- swinnerArr := strings.Split(s_winner, ",")
- eidList, _ := obj["entidlist"].([]interface{})
- //先查询entlist 如果长度和s_winner不一致 根据企业名称查询id
- if len(eidList) != len(swinnerArr) {
- for _, v := range swinnerArr {
- winnerMap[v] = ""
- //临时更改为企业名称查询企业id
- rData := elastic.Get("qyxy", "qyxy", fmt.Sprintf(`{"query":{"bool":{"should":[{"term":{"company_name":"%s"}},{"term":{"hname":"%s"}}],"minimum_should_match":1}},"_source":["name","_id","nseo_id","capital","company_phone"],"size":1}`, v, v))
- if rData != nil && len(*rData) == 1 {
- if entId := util.ObjToString((*rData)[0]["_id"]); entId != "" {
- entIdArr = append(entIdArr, encrypt.EncodeArticleId2ByCheck(util.ObjToString((*rData)[0]["_id"])))
- winnerMap[v] = encrypt.EncodeArticleId2ByCheck(util.ObjToString((*rData)[0]["_id"]))
- if !b {
- winnerSeoMap[v] = (*rData)[0]["nseo_id"]
- }
- }
- }
- }
- } else {
- for k, v := range eidList {
- vstr := util.ObjToString(v)
- if vstr == "-" || vstr == "" {
- continue
- }
- winnerMap[swinnerArr[k]] = encrypt.EncodeArticleId2ByCheck(vstr)
- if !b {
- winnerSeoMap[swinnerArr[k]] = EsSeoId(true, vstr)
- }
- }
- }
- obj["entId"] = entIdArr
- obj["winnerMap"] = winnerMap
- obj["winnerSeoMap"] = winnerSeoMap
- }
- }
- //移动端需要处理--剑鱼币
- if b && from_userid != "" && se.Decode4Hex(from_userid) != "" && se.Decode4Hex(from_userid) != userId && util.ObjToString(obj["subtype"]) != "拟建" { //分享开打的
- article_id := encrypt.CommonDecodeArticle(stype, id)[0]
- key := fmt.Sprintf("integral_article_%s_%s_%s", article_id, from_userid, userId)
- if redis.Incr(redisLimitation, key) == 1 {
- redis.SetExpire(redisLimitation, key, 60*60*24)
- err := jy.Publish(public.Mgo_Log, config.Sysconfig["nsq"].(string), config.Sysconfig["nsq_topic"].(string), jy.Jyweb_article_open, se.Decode4Hex(from_userid), jy.Jywx_node1, nil)
- if err != nil {
- log.Println("nsq队列写入失败-->", jy.Jyweb_article_open, se.Decode4Hex(from_userid))
- }
- }
- }
- }
- // disWord 为空时处理
- func disWordNil(disWord, userId string) string {
- var from_userid string
- redisDis := redis.GetStr(redisLimitation, "DIS_"+disWord[1:])
- if redisDis != "" {
- suffix := disWord[len(disWord)-3:]
- //公告三级页处理
- if suffix == suffix_msgt {
- effectiveTimeStr := strings.Split(redisDis, "##")[3]
- effectiveTime, _ := strconv.ParseInt(effectiveTimeStr, 10, 64)
- //是否计算佣金
- if time.Now().Unix() <= effectiveTime {
- belongUserId := strings.Split(redisDis, "##")[1]
- //if (belongUserId != userId) {
- public.Mysql.ExecTx("口号使用", func(tx *sql.Tx) bool {
- //口号是否使用过
- wordInfo := public.Mysql.Find("dis_word", map[string]interface{}{"userId": userId, "password": disWord}, "id", "", 0, 0)
- if len(*wordInfo) == 0 {
- //新增口号使用
- start_time := time.Now().Format(DateFullLayout)
- termValidityInt, _ := strconv.Atoi(fmt.Sprint(config.Sysconfig["termValidity"]))
- stop_time := TimeProcessing(time.Now().Format(DateFullLayout), termValidityInt).Format(DateFullLayout)
- insert := map[string]interface{}{
- "password": disWord,
- "userId": userId,
- "belong_userid": belongUserId,
- "start_time": start_time,
- "stop_time": stop_time,
- }
- insert_1 := public.Mysql.InsertByTx(tx, "dis_word", insert) //口号使用表
- log.Println("插入口号使用表", insert_1)
- from_userid = se.Encode2Hex(belongUserId)
- }
- return true
- })
- }
- //}
- }
- }
- return from_userid
- }
- // 检查用户是否关注
- func CheckUserIsSubscribe(openid string) bool {
- user, ok := mongodb.FindOneByField("user", map[string]interface{}{
- "i_appid": 2,
- "s_m_openid": openid,
- "s_unionid": map[string]interface{}{"$ne": openid},
- }, `{"i_ispush":1}`)
- if ok && user != nil {
- if (*user)["_id"] == nil || util.IntAllDef((*user)["i_ispush"], 1) == 0 {
- return false
- } else {
- return true
- }
- }
- return false
- }
- func (s *Short) Qr(t, id string) error {
- w := s.ResponseWriter
- w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
- w.Header().Set("Pragma", "no-cache")
- w.Header().Set("Expires", "0")
- w.Header().Set("Content-Type", "image/png")
- kds := s.GetString("kds")
- industry := s.GetString("industry")
- param := "?scan_source=pc"
- if t == "force" {
- param += "&ispcforceshare=1"
- }
- if kds != "" {
- param += "&keywords=" + kds
- }
- if industry != "" {
- param += "&industry=" + industry
- }
- ///article/bdprivate/BXXXX 详情页
- if strings.Contains(s.Refer(), "bdprivate") {
- bdprivateId := encrypt.EncodeArticleId2ByCheck(encrypt.CommonDecodeArticle("bdprivate", id)[0])
- if bdprivateId != "" {
- id = bdprivateId
- }
- }
- data := config.Sysconfig["webdomain"].(string) + "/article/content/" + url.QueryEscape(id) + ".html" + param
- r, _ := qr.Encode(data, qr.M)
- pngdat := r.PNG()
- _, err := w.Write(pngdat)
- return err
- }
- func (s *Short) Replication() {
- userId, OK := s.GetSession("userId").(string)
- if OK && userId != "" {
- mongodb.Save("copyaction", map[string]interface{}{
- "userid": userId,
- "createtime": time.Now().Unix(),
- "url": s.Request.Referer(),
- "client": s.Header("User-Agent"),
- })
- }
- }
- func isbid(typ interface{}) bool {
- if typ != nil {
- subtype := util.ObjToString(typ)
- if subtype == "中标" || subtype == "合同" || subtype == "成交" {
- return true
- }
- }
- return false
- }
- // 中标企业库
- func getwinnertel(company interface{}) string {
- if company != nil {
- data, _ := public.Mgo_Ent.FindOne("winner_enterprise", map[string]interface{}{
- "company_name": util.ObjToString(company),
- })
- if (*data)["company_phone"] != nil {
- return util.ObjToString((*data)["company_phone"])
- }
- }
- return ""
- }
- func GetUserId(openid string) string {
- data, ok := public.MQFW.FindOne("user", map[string]interface{}{"s_m_openid": openid})
- if data != nil && len(*data) > 0 && ok {
- userid := mg.BsonIdToSId((*data)["_id"])
- return userid
- }
- return ""
- }
- func RemoveDuplicatesAndEmpty(a []string) (ret []string) {
- a_len := len(a)
- for i := 0; i < a_len; i++ {
- if (i > 0 && a[i-1] == a[i]) || len(a[i]) == 0 {
- continue
- }
- ret = append(ret, a[i])
- }
- return
- }
- // 该节点是否留资
- func hasRetainedCapital(uid string, source []string) bool {
- if count, err := mongodb.CountByErr("saleLeads", map[string]interface{}{"userid": uid, "source": map[string]interface{}{"$in": source}}); err != nil || count > 0 {
- return true
- }
- return false
- }
- func isInStringArr(arr []string, key string) bool {
- for _, v := range arr {
- if v == key {
- return true
- }
- }
- return false
- }
- func ReplaceStringByRegex(str, rule, replace string) (string, error) {
- reg, err := regexp.Compile(rule)
- if reg == nil || err != nil {
- return "", errors.New("正则MustCompile错误:" + err.Error())
- }
- return reg.ReplaceAllString(str, replace), nil
- }
- // 未登录用户进行数据过滤 name 配置文件
- func Filter(obj map[string]interface{}) map[string]interface{} {
- detail := fmt.Sprint(obj["detail"])
- mosaicText := fmt.Sprintf(`<span style="color:#2ABED1;">%s</span>`, util.ObjToString(config.Sysconfig["detailMosaic"]))
- detailText := fmt.Sprintf(`<span class="noLoginMosaic" style="color: #2ABED1;">%s</span>`, util.ObjToString(config.Sysconfig["detailMosaic"]))
- //for k, _ := range obj {
- // if ok, _ := detailNeedMosaic[k].(bool); ok {
- // if util.ObjToString(obj[k]) != "" {
- // detail = strings.ReplaceAll(detail, util.ObjToString(obj[k]), detailText)
- // }
- // //中标企业信息
- // if k == "winnerMap" && obj[k] != nil {
- // winnerNewMap := map[string]interface{}{}
- // winnerMap := util.ObjToMap(obj[k])
- // for _, wv := range *winnerMap {
- // winnerNewMap[mosaicText] = wv
- // }
- // obj[k] = winnerNewMap
- // } else {
- // obj[k] = mosaicText
- // }
- // }
- //}
- //
- if detailNeedMosaic == nil {
- detailNeedMosaic, _ = config.Sysconfig["detailNeedMosaic"].(map[string]interface{})
- }
- for dk, dv := range detailNeedMosaic {
- if !dv.(bool) {
- continue
- }
- if obj["package"] != nil {
- pk := util.ObjToMap(obj["package"])
- for _, pv := range *pk {
- if pv != nil {
- if page := util.ObjToMap(pv); page != nil {
- if (*page)[dk] != nil {
- (*page)[dk] = mosaicText
- }
- delete(*page, "text")
- }
- }
- }
- }
- //if util.ObjToString(obj[dk]) != "" {
- // detail = strings.ReplaceAll(detail, util.ObjToString(obj[dk]), detailText)
- //}
- if util.InterfaceToStr(obj[dk]) != "" {
- value, b := obj[dk].(float64)
- if b {
- replaceStr := fmt.Sprintf("%v", int64(value))
- detail = strings.ReplaceAll(detail, replaceStr, detailText)
- } else {
- detail = strings.ReplaceAll(detail, util.InterfaceToStr(obj[dk]), detailText)
- }
- }
- //中标企业信息
- if dk == "winnerMap" {
- winnerNewMap := map[string]interface{}{}
- if obj[dk] != nil {
- winnerMap := util.ObjToMap(obj[dk])
- for _, wv := range *winnerMap {
- winnerNewMap[mosaicText] = wv
- }
- }
- obj[dk] = winnerNewMap
- } else {
- obj[dk] = mosaicText
- }
- }
- obj["detail"] = detail
- return obj
- }
- // 拟建采购意向用户进行数据过滤 name 配置文件
- func otherFilter(obj map[string]interface{}, isLogin bool) map[string]interface{} {
- txt := util.If(isLogin, "解锁会员查看", "登陆后解锁会员查看").(string)
- detail := fmt.Sprint(obj["detail"])
- mosaicText := fmt.Sprintf(`<span class="highlight-text otherMosaic">%s</span>`, txt)
- detailText := fmt.Sprintf(`<span class="highlight-text otherMosaic">%s</span>`, txt)
- var (
- projectinfo map[string]interface{}
- )
- var otherMosaic map[string]interface{}
- if obj["subtype"] == "拟建" {
- otherMosaic, _ = config.Sysconfig["planBuildMosaic"].(map[string]interface{})
- projectinfo, _ = obj["projectinfo"].(map[string]interface{}) //1.项目信息打码处理
- } else if obj["subtype"] == "采购意向" {
- otherMosaic, _ = config.Sysconfig["purchaseMosaic"].(map[string]interface{})
- procurementlist, _ := obj["procurementlist"].([]interface{})
- for _, vs := range procurementlist { //1.采购意向清单数据集打码处理
- vsMap, _ := vs.(map[string]interface{})
- for _, vsq := range vsMap {
- if vs1, ok := vsq.(string); ok && vs1 != "" {
- detail = strings.ReplaceAll(detail, util.InterfaceToStr(vsq), detailText)
- }
- }
- }
- delete(obj, "procurementlist")
- }
- for dk, dv := range otherMosaic {
- if !dv.(bool) {
- continue
- }
- if vs, ok := projectinfo[dk]; ok && vs != nil && vs != "" {
- detail = strings.ReplaceAll(detail, util.InterfaceToStr(vs), detailText)
- projectinfo[dk] = mosaicText
- }
- if vs, ok := obj[dk]; ok && vs != nil && vs != "" {
- value, b := obj[dk].(float64)
- if b {
- replaceStr := fmt.Sprintf("%v", int64(value))
- detail = strings.ReplaceAll(detail, replaceStr, detailText)
- } else {
- detail = strings.ReplaceAll(detail, util.InterfaceToStr(obj[dk]), detailText)
- }
- }
- obj[dk] = mosaicText
- }
- if obj["subtype"] == "拟建" {
- for k := range projectinfo {
- if _, ok := otherMosaic[k]; !ok {
- delete(projectinfo, k)
- }
- }
- obj["projectinfo"] = projectinfo
- }
- obj["detail"] = detail
- return obj
- }
- // 未登录用户进行数据过滤 name 配置文件
- func SearchFilter(obj map[string]interface{}) map[string]interface{} {
- //detail := fmt.Sprint(obj["detail"])
- //mosaicText := fmt.Sprintf(`<span style="cursor:pointer;">%s</span>`, util.ObjToString(config.Sysconfig["detailMosaic"]))
- //for k, _ := range obj {
- // needMosaic, _ := config.Sysconfig["detailNeedMosaic"].(map[string]interface{})
- // if ok, _ := needMosaic[k].(bool); ok {
- // //if util.ObjToString(obj[k]) != "" {
- // // detail = strings.ReplaceAll(detail, util.ObjToString(obj[k]), mosaicText)
- // // //敏感词过滤
- // //}
- // if k == "winnerMap" {
- // winnerMap, _ := obj[k].(map[string]interface{})
- // mosaicMap := map[string]interface{}{}
- // for i := 0; i < len(winnerMap); i++ {
- // mosaicMap[mosaicText] = mosaicText
- // }
- // obj["winnerMap"] = mosaicMap
- // } else {
- // obj[k] = mosaicText
- // }
- //
- // }
- //}
- //数字打码
- //detail = RegDetail(detail)
- //detail = fsw.Repl(detail)
- //obj["detail"] = detail
- if detailNeedMosaic == nil {
- detailNeedMosaic, _ = config.Sysconfig["detailNeedMosaic"].(map[string]interface{})
- }
- for dk, dv := range detailNeedMosaic {
- if !dv.(bool) {
- continue
- }
- //中标企业信息
- if dk == "winnerMap" {
- winnerNewMap := map[string]interface{}{}
- if obj[dk] != nil {
- winnerMap := util.ObjToMap(obj[dk])
- for _, wv := range *winnerMap {
- winnerNewMap[util.ObjToString(config.Sysconfig["detailMosaic"])] = wv
- }
- }
- obj[dk] = winnerNewMap
- } else {
- obj[dk] = util.ObjToString(config.Sysconfig["detailMosaic"])
- }
- }
- return obj
- }
- func (s *Short) NologinArticle(stype, id string) error {
- sess := s.Session().GetMultiple()
- userId := util.ObjToString(sess["userId"])
- sids := encrypt.CommonDecodeArticle(stype, id)
- bm := mobileReg.MatchString(s.Header("User-Agent"))
- if len(sids) == 0 || (len(sids) > 0 && sids[0] == "") {
- return s.Redirect(getErrPageUrl(bm, DecodeErr), 302)
- }
- if detailNeedMosaic == nil {
- detailNeedMosaic, _ = config.Sysconfig["detailNeedMosaic"].(map[string]interface{})
- }
- if userId != "" { //已登录用户直接跳转至正常三级页
- return s.LoginCommon(sess, stype, id, bm) //是否是移动端
- }
- return s.NologinCommon(userId, stype, id, sids[0], bm)
- }
- func (s *Short) NologinCommon(userId, stype, id, sid string, isMobile bool) error {
- tg := &Tags{}
- var ipTrue bool
- ips := strings.Split(util.GetIp(s.Request), ",")
- if len(ips) > 0 {
- ipTrue = config.IpList.Match(ips[0])
- }
- catchKey := fmt.Sprintf("jypcdetail_nologin_%s_%s_%v", stype, sid, ipTrue)
- if res := redis.Get(redisLimitation, catchKey); res == nil || res == "" {
- industry := s.GetString("industry")
- var shareid = s.GetString("id")
- if len(shareid) == 0 {
- shareid = "10"
- }
- s.T["canRead"] = true
- s.T["logid"] = config.Seoconfig["jysskzy"].(string)
- s.T["shareid"] = se.EncodeString(shareid)
- //s.T["keywords"] = s.GetString("kds")
- s.DisableHttpCache()
- po, bo, wo, obj := pcVRT(sid, industry, stype, false, false)
- if obj != nil && len(obj) > 0 {
- //阳光采购 网站的数据 未登录不能访问
- if util.InterfaceToStr(obj["infoattribute"]) == "zc_cgxx" { //&& util.IntAll(obj["is_yg_new"]) == 1
- return s.Redirect("/", 301)
- }
- // p397 未登录不能查看拟建项目
- if !ipTrue && (obj["subtype"] == "采购意向" || obj["subtype"] == "拟建") { //未登录拟建 采购意向 遮罩
- obj = map[string]interface{}{
- "winnerTitle": obj["winner"],
- "buyerTitle": obj["buyer"],
- "projectnameTitle": obj["projectname"],
- "projectcodeTitle": obj["projectcode"],
- "title": obj["title"],
- "_id": obj["_id"],
- "subtype": obj["subtype"],
- "stypeadd": obj["stypeadd"],
- "originalShow": false,
- }
- s.T["canRead"] = false
- } else {
- FieldProcessing(obj, "", industry, id, "", userId, stype, false)
- if userId == "" {
- obj["winnerTitle"] = obj["winner"]
- obj["buyerTitle"] = obj["buyer"]
- obj["projectnameTitle"] = obj["projectname"]
- obj["projectcodeTitle"] = obj["projectcode"]
- if !ipTrue { //非白名单用户
- obj = Filter(obj)
- }
- //obj["description"] = fmt.Sprintf("%s,%s。", obj["title"], baseInfo(obj))
- }
- obj["agency"] = ""
- if obj["publishtime"] != nil {
- obj["publishtimeShorDate"] = time.Unix(util.Int64All(obj["publishtime"]), 0).Format(date.Date_Short_Layout)
- }
- }
- if len(po) > 0 {
- s.T["projectOther"] = po
- }
- if len(bo) > 0 {
- s.T["buyerOther"] = bo
- }
- if len(wo) > 0 {
- s.T["winnerOther"] = wo
- }
- obj["urlpath"] = s.Uri()
- obj["industry"] = industry
- obj["keywords"] = KeyWordHandle(obj)
- obj["description"] = DescriptionHandle("nologin", obj)
- s.T["obj"] = obj
- s.T["url"] = s.Uri()
- s.T["newBidInfoList"] = tg.GetNewBidInfo()
- s.T["industryInfoList"] = tg.GetConsult()
- s.T["hotLabelList"] = tg.GetHotLabel(30)
- s.T["simpleTemplateData"] = map[string]interface{}{
- "obj": obj,
- }
- content, _ := s.Render4Cache("/pc/tags/detail.html", &s.T)
- redis.Put(redisLimitation, catchKey, string(content), 60*2)
- return s.SetBody(content)
- } else {
- return s.Redirect(getErrPageUrl(isMobile, QueryErr), 302)
- }
- } else {
- return s.SetBody([]byte(res.(string)))
- }
- }
- /*
- TDK description
- */
- func baseInfo(obj map[string]interface{}) string {
- info := ""
- info += "省份:"
- //{{if eq .T.obj.area "A"}}全国{{else}}{{.T.obj.area}}{{end}}
- if area := util.ObjToString(obj["area"]); area == "A" {
- info += "全国"
- } else {
- info += area
- }
- info += ",城市:" + util.ObjToString(obj["city"])
- info += ",招标代理机构:" + util.ObjToString(obj["agency"])
- info += ",项目名称:" + util.ObjToString(obj["projectname"])
- info += ",采购单位:" + util.ObjToString(obj["buyer"])
- info += ",采购联系人:" + util.ObjToString(obj["buyerperson"])
- info += ",采购电话:" + util.ObjToString(obj["buyertel"])
- if obj["package"] == nil {
- info += ",项目预算(元):" + util.ObjToString(obj["budget"])
- }
- if util.ObjToString(obj["subtype"]) == "单一" && util.ObjToString(obj["package"]) == "" {
- info += ",拟定单一来源采购供应商:" + util.ObjToString(obj["winner"])
- }
- subtype := util.ObjToString(obj["subtype"])
- if subtype == "中标" || subtype == "成交" || subtype == "合同" {
- if obj["winnerMap"] != nil {
- info += ",中标单位:"
- i := 0
- for k := range *util.ObjToMap(obj["winnerMap"]) {
- i++
- info += k
- if i != len(*util.ObjToMap(obj["winnerMap"])) {
- info += "、"
- }
- }
- }
- if obj["bidamount"] != nil {
- info += ",中标金额(元):" + util.ObjToString(obj["bidamount"])
- }
- if obj["bidamount"] != nil {
- info += ",联系方式:" + util.ObjToString(obj["bidamount"])
- }
- }
- return info
- }
- // 分段匹配数字打码
- func RegDetail(html string) string {
- mosaicText := util.ObjToString(config.Sysconfig["detailMosaicTxt"])
- reg := regexp.MustCompile("<[^<>]{1,1000}>") //分段正则
- s := reg.FindAllStringIndex(html, -1) //全文匹配分段
- if len(s) > 0 { //走分段替换
- arr := []string{}
- index := 0
- for _, v := range s {
- if len(v) == 2 {
- // log.Println(html[index:v[0]])
- txt, _ := ReplaceStringByRegex(html[index:v[0]], "[0-9]+", mosaicText)
- arr = append(arr, txt) //替换
- arr = append(arr, html[v[0]:v[1]])
- index = v[1]
- }
- }
- return strings.Join(arr, "")
- }
- return ""
- }
- func KeyWordHandle(obj map[string]interface{}) string {
- keywordArr := []string{}
- owner := util.InterfaceToStr(obj["owner"])
- buyer := util.InterfaceToStr(obj["buyer"])
- if buyer == "" {
- buyer = owner
- }
- if buyer != "" && buyer != config.Sysconfig["detailMosaicTxt"] {
- keywordArr = append(keywordArr, buyer)
- }
- if util.InterfaceToStr(obj["s_winner"]) != "" && util.InterfaceToStr(obj["s_winner"]) != config.Sysconfig["detailMosaicTxt"] {
- keywordArr = append(keywordArr, util.InterfaceToStr(obj["s_winner"]))
- }
- if obj["purchasinglist"] != nil && obj["purchasinglist"] != "" {
- i := 0
- for _, v := range gconv.SliceMap(obj["purchasinglist"]) {
- if i == 5 {
- break
- }
- if util.InterfaceToStr(v["itemname"]) != "" && util.InterfaceToStr(obj["s_winner"]) != config.Sysconfig["detailMosaicTxt"] {
- keywordArr = append(keywordArr, util.InterfaceToStr(v["itemname"]))
- i++
- }
- }
- }
- if util.InterfaceToStr(obj["subtype"]) != "" && util.InterfaceToStr(obj["subtype"]) != "其它" {
- keywordArr = append(keywordArr, TypeCodeMap[util.InterfaceToStr(obj["subtype"])])
- }
- if util.InterfaceToStr(obj["area"]) != "" {
- keywordArr = append(keywordArr, util.InterfaceToStr(obj["area"])+"招标")
- }
- if util.InterfaceToStr(obj["city"]) != "" {
- keywordArr = append(keywordArr, util.InterfaceToStr(obj["city"])+"招标")
- }
- keywordArr = append(keywordArr, "剑鱼标讯")
- keyword := strings.Join(keywordArr, ",")
- return keyword
- }
- func DescriptionHandle(stype string, obj map[string]interface{}) string {
- description := ""
- publishtime := util.Int64All(obj["l_publishtime"])
- if publishtime == 0 {
- publishtime = util.Int64All(obj["publishtime"])
- }
- pushTime := time.Unix(publishtime, 0)
- title := util.InterfaceToStr(obj["title"])
- owner := util.InterfaceToStr(obj["owner"])
- buyer := util.InterfaceToStr(obj["buyer"])
- if buyer == "" {
- buyer = owner
- }
- s_winner := util.InterfaceToStr(obj["s_winner"])
- area := util.InterfaceToStr(obj["area"])
- city := util.InterfaceToStr(obj["city"])
- if stype == "bdprivate" {
- //bdprivate
- //{项目标题},采购单位:{采购单位名称},成交供应商:{中标企业名称},公告日期:{公告日期}。
- descriptionArr := []string{}
- if title != "" {
- descriptionArr = append(descriptionArr, strLimitRune(title, g.Cfg().MustGet(context.TODO(), "seo.description.titleLimit", 48).Int()))
- }
- if buyer != "" {
- descriptionArr = append(descriptionArr, fmt.Sprintf("采购单位:%s", buyer))
- }
- if s_winner != "" {
- descriptionArr = append(descriptionArr, fmt.Sprintf("成交供应商:%s", s_winner))
- }
- if publishtime != 0 {
- descriptionArr = append(descriptionArr, fmt.Sprintf("公告日期:%s", pushTime.Format("2006年01月02日")))
- }
- descriptionArr = append(descriptionArr, "查看该项目信息详情请访问剑鱼标讯官网。")
- description = strings.Join(descriptionArr, ",")
- } else {
- //descriptionStr = "%s,项目所属地区是%s%s,项目采购单位是%s,项目发布时间是%s"
- descriptionArr := []string{}
- if title != "" {
- descriptionArr = append(descriptionArr, strLimitRune(title, g.Cfg().MustGet(context.TODO(), "seo.description.titleLimit", 48).Int()))
- }
- if area != "" || city != "" {
- descriptionArr = append(descriptionArr, fmt.Sprintf("项目所属地区是%s%s", area, city))
- }
- if buyer != "" {
- descriptionArr = append(descriptionArr, fmt.Sprintf("项目采购单位是%s", buyer))
- }
- if publishtime != 0 {
- descriptionArr = append(descriptionArr, fmt.Sprintf("项目发布时间是%s", pushTime.Format("2006年01月02日")))
- }
- descriptionArr = append(descriptionArr, "查看该项目信息详情请访问剑鱼标讯官网。")
- description = strings.Join(descriptionArr, ",")
- }
- return description
- }
- func strLimitRune(str string, length int, suffix ...string) string {
- runes := []rune(str)
- if len(runes) < length {
- return str
- }
- suffixStr := "..."
- if len(suffix) > 0 {
- suffixStr = suffix[0]
- }
- return string(runes[0:length]) + suffixStr
- }
- func GetTDK(pageType, sid string) (t, k, d string) {
- tdkCacheKey := fmt.Sprintf("detail_tkd_%s_%s", pageType, sid)
- if tdk := redis.GetStr(redisLimitation, tdkCacheKey); tdk != "" {
- tdks := strings.Split(tdk, "##")
- if len(tdks) == 3 {
- t = tdks[0]
- k = tdks[1]
- d = tdks[2]
- return
- }
- }
- obj, ok := public.Mgo_Bidding.FindById(public.DbConf.Mongodb.Bidding.Collection, sid, nil)
- if ok && (obj == nil || *obj == nil || len(*obj) == 0) {
- obj, ok = public.Mgo_Bidding.FindById(public.DbConf.Mongodb.Bidding.Collection_back, sid, nil)
- }
- if ok && obj != nil && len(*obj) > 2 {
- t = util.InterfaceToStr((*obj)["title"])
- k = KeyWordHandle(*obj)
- d = DescriptionHandle(pageType, *obj)
- } else {
- t = "全国招标信息-招标采购公告大全-剑鱼标讯"
- k = "招标网站,招标信息查询,剑鱼标讯,招标采购信息,招标大数据平台"
- d = "剑鱼标讯是国内专业的招标大数据服务平台,专注于全国招标采购信息的搜索查询、订阅推送和数据定制化服务。提供涵盖拟在建项目、招标预告、招标公告、中标公告、政府采购、企业工商信息等多种信息类型,帮助企业全方位掌握市场动态变化。招投标大数据平台就用剑鱼标讯。"
- }
- redis.Put(redisLimitation, tdkCacheKey, fmt.Sprintf("%s##%s##%s", t, k, d), 24*60*60)
- return
- }
|