123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248 |
- package front
- import (
- "database/sql"
- "errors"
- "fmt"
- "github.com/gogf/gf/v2/util/gconv"
- "jy/src/jfw/config"
- "jy/src/jfw/wx"
- "log"
- "math/rand"
- "net/url"
- "strconv"
- "jy/src/jfw/jyutil"
- "app.yhyue.com/moapp/jypkg/public"
- util "app.yhyue.com/moapp/jybase/common"
- "app.yhyue.com/moapp/jybase/date"
- . "app.yhyue.com/moapp/jybase/mongodb"
- elastic "app.yhyue.com/moapp/jybase/es"
- "app.yhyue.com/moapp/jybase/fsw"
- "regexp"
- "strings"
- "time"
- "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]) 无需登录
- }
- var mobileReg = regexp.MustCompile("(?i)(Android|Mobile|Phone)")
- var DateFullLayout = "2006-01-02 15:04:05"
- var Map_stype = map[string]bool{
- "content": true,
- "entservice": true,
- "bdprivate": true,
- "mailprivate": true,
- "bdcontent": true,
- "indexcontent": true,
- "advancedProject": true,
- }
- var TypeCodeMap = map[string]string{
- "拟建": "拟建项目",
- "采购意向": "采购意向",
- "预告": "招标预告",
- "预审": "资格预审",
- "预审结果": "资格预审结果",
- "论证意见": "论证意见",
- "需求公示": "需求公示",
- "招标": "公开招标",
- "邀标": "邀请招标",
- "询价": "询价采购",
- "竞谈": "竞争性谈判",
- "单一": "单一来源采购",
- "竞价": "竞价公告",
- "变更": "变更公告",
- "中标": "中标公示",
- "成交": "成交公告",
- "废标": "废标公告",
- "流标": "流标公告",
- "合同": "合同公告信息",
- "验收": "验收公告信息",
- "违规": "违规信息",
- }
- var seoAgentReg = regexp.MustCompile("Baiduspider|360Spider|bingbot|Googlebot")
- func (s *Short) Article(stype, id string) error {
- userId, _ := s.GetSession("userId").(string)
- if (stype == "content" || stype == "indexcontent") && userId == "" {
- if seoAgentReg.MatchString(s.UserAgent()) {
- sids := encrypt.CommonDecodeArticle(stype, id)
- return s.NologinCommon("", stype, id, sids[0])
- } else {
- return s.Redirect("/notin/page")
- }
- }
- return s.LoginCommon(userId, stype, id)
- }
- func (s *Short) LoginCommon(userId, stype, id string) error {
- client := s.Header("User-Agent")
- bm := mobileReg.MatchString(client)
- //电脑端 剑鱼快照页面访问
- if stype == "content" && !bm {
- //工作桌面内嵌 快照页
- //老地址(地址不包含aside)且非工作桌面地址
- if !strings.Contains(s.Request.URL.String(), "aside") && !strings.Contains(s.Request.URL.String(), "page_workDesktop") {
- paramSuffix := ".html?aside=0"
- replaceStr := ".html"
- if strings.Contains(s.Request.URL.String(), "?") {
- replaceStr = ".html?"
- paramSuffix = ".html?aside=0&"
- }
- return s.Redirect(fmt.Sprintf("%s%s%s", config.Sysconfig["workDesktopUrl"].(string), config.Sysconfig["webdomain"].(string), url.QueryEscape(strings.Replace(s.Request.URL.String(), replaceStr, paramSuffix, 1))))
- }
- }
- //先判断是否有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] {
- s.Redirect("/not/nottype", 302)
- return nil
- } else if stype == "content" || stype == "bdcontent" || stype == "advancedProject" {
- if userId == "" {
- 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)
- }
- }
- }
- } else if public.CheckWxBrowser(s.Request) {
- //所有参数都不再使用,跳到微信验证用户
- return s.Redirect(fmt.Sprintf(config.Wxoauth, url.QueryEscape(s.Site()+s.Url()), "wx"), 302)
- }
- }
- if disWord != "" {
- from_userid = disWordNil(disWord, userId)
- }
- if userId == "" { //} && !regclient.MatchString(client) { //没有用户session //搜索引擎让过
- s.Session().Set("referer", s.Request.RequestURI)
- if bm { //是否是移动端访问
- s.Redirect(aboutUrl, 302)
- } else {
- if stype == "bdcontent" {
- var retMap = make(map[string]interface{})
- stype = "content"
- _id := encrypt.CommonDecodeArticle(stype, id)[0]
- _, _, _, obj := pcVRT(_id, "", stype, true)
- if obj != nil && len(obj) > 0 {
- retMap["_id"] = 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("/notin/page", 302)
- }
- }
- return nil
- }
- if stype == "bdcontent" {
- stype = "content"
- }
- } else if stype == "entservice" { //大客户数据快照展示
- //se := util.SimpleEncrypt{"entservice"}
- sid := encrypt.SE3.DecodeString(id)
- if len(sid) == 0 || (len(sid) > 0 && sid == "") {
- s.Redirect("/notin/page", 302)
- return nil
- }
- catchKey := fmt.Sprintf("jypcdetail_%s_%s_%s", userId, stype, sid)
- if res := redis.Get("newother", 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 := s.Session().Get("s_m_openid")
- po, bo, wo, obj := pcVRT(sid, industry, stype, 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("newother", catchKey, string(content), 60*20)
- return s.SetBody(content)
- }
- } else {
- return s.SetBody([]byte(res.(string)))
- }
- }
- ssOpenid := s.Session().Get("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 = 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}`)
- }
- entid := util.Int64All(s.GetSession("entId"))
- userPower := jy.GetBigVipUserBaseMsg(s.Session(), *config.Middleground)
- var (
- isEntnicheNew bool = userPower.EntIsNew //新版超级订阅
- isOldVip bool = false //新购超级订阅不能查看拟建项目详情页
- isVip bool = userPower.VipStatus > 0 //超级订阅
- isMember bool = userPower.Status > 0 //大会员
- isEntniche bool = userPower.EntnicheStatus > 0 //商机管理
- privatedata bool = userPower.PrivateGD //广东移动DICT 用户
- isEntService bool = userPower.Data.Ent.PowerSource > 0 && userPower.Data.Entniche.IsEntPower > 0 //商机管理服务
- )
- if res != nil && len(*res) > 0 {
- if isVip && util.Int64All((*res)["l_vip_starttime"]) < util.Int64All(config.Sysconfig["contextOldVipLimit"]) {
- isOldVip = true
- }
- }
- entId := util.IntAll(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:
- s.Redirect(aboutUrl, 302)
- return nil
- default:
- shareopenid, sid = SwiDef(sid_openid)
- }
- s.T["keywords"] = kds
- if shareopenid != "" {
- s.T["shareopenid"] = shareopenid
- }
- myopenid, _ := s.Session().Get("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)
- 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)
- 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 stype == "advancedProject" {
- newCanRead := false
- //判断此用户是否有打开的权限
- newUserId := s.GetSession("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
- }
- if newCanRead || canRead {
- obj = wxvisitD(sid, userId, myopenid, stype, true)
- canRead = true
- }
- 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
- }
- }
- s.T["advertcode"] = s.GetString("advertcode")
- } else {
- obj = map[string]interface{}{
- "title": obj["title"],
- "_id": obj["_id"],
- "subtype": obj["subtype"],
- }
- }
- //纠错随机回复
- 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)
- }
- if surl != "" {
- return s.Redirect(surl)
- }
- } else {
- sids := encrypt.CommonDecodeArticle(stype, id)
- if len(sids) == 0 || (len(sids) > 0 && sids[0] == "") {
- s.Redirect("/notin/page", 302)
- return nil
- }
- sid := sids[0]
- //免费用户浏览三级页判断留资与浏览次数
- indust := s.GetString("industry")
- if userId != "" && stype == "indexcontent" { //已登录用户直接跳转至正常三级页
- return s.Redirect(fmt.Sprintf("/article/content/%s.html", encrypt.CommonEncodeArticle("content", sid)))
- }
- 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)
- 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(objc, 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 stype == "advancedProject" {
- canRead := false
- //判断此用户是否有打开的权限
- newUserId := s.GetSession("base_user_id")
- pushData := public.BaseMysql.FindOne("leadproject_push", map[string]interface{}{"user_id": newUserId, "info_id": sid}, "id", "")
- //访问次数加1
- if pushData == nil {
- canRead = 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"])
- canRead = true
- }
- if canRead || node {
- _, _, _, obj = pcVRT(sid, indust, stype, true)
- canRead = true
- node = canRead
- }
- s.T["canRead"] = canRead
- }
- 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
- }
- }
- } else {
- obj = map[string]interface{}{
- "title": obj["title"],
- "_id": obj["_id"],
- "subtype": obj["subtype"],
- "stypeadd": obj["stypeadd"],
- }
- }
- 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()
- return s.Render("/pc/biddetail_rec.html", &s.T)
- }
- }
- return nil
- }
- func CNode(userId string) bool {
- if hasRetainedCapital(userId, "jyarticle_see3_plus") {
- 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("other", 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("other", watchKey, newVal, jy.GetExpire())
- return true
- } else {
- for _, v := range sidss {
- if sid == v {
- return true
- }
- }
- return false
- }
- }
- } else {
- redis.Put("other", 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 = 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"] = ""
- }
- if !b {
- href, _ := obj["href"].(string)
- href = strings.Replace(href, "\n", "", -1)
- if href != "" && !strings.HasPrefix(href, "http") {
- href = "http://" + href
- }
- obj["url"] = href
- }
- //大会员中标企业跳转至画像
- if obj["entidlist"] != nil {
- if s_winner := util.ObjToString(obj["s_winner"]); s_winner != "" {
- entIdArr, winnerMap := []string{}, 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","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"]))
- }
- }
- }
- } else {
- for k, v := range eidList {
- vstr := util.ObjToString(v)
- if vstr == "-" {
- continue
- }
- winnerMap[swinnerArr[k]] = encrypt.EncodeArticleId2ByCheck(vstr)
- }
- }
- obj["entId"] = entIdArr
- obj["winnerMap"] = winnerMap
- }
- }
- //移动端需要处理--剑鱼币
- 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("other", key) == 1 {
- redis.SetExpire("other", 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)
- 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("other", "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
- }
- data := config.Sysconfig["webdomain"].(string) + "/article/content/" + 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 := 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, source string) bool {
- if count, err := mongodb.CountByErr("saleLeads", map[string]interface{}{"userid": uid, "source": 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 := util.ObjToString(config.Sysconfig["detailMosaicTxt"])
- for k, _ := range obj {
- needMosaic, _ := config.Sysconfig["needMosaic"].(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
- return obj
- }
- // 未登录用户进行数据过滤 name 配置文件
- func SearchFilter(obj map[string]interface{}) map[string]interface{} {
- //detail := fmt.Sprint(obj["detail"])
- mosaicText := util.ObjToString(config.Sysconfig["detailMosaicTxt"])
- for k, _ := range obj {
- needMosaic, _ := config.Sysconfig["searchMosaic"].(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
- return obj
- }
- func (s *Short) NologinArticle(stype, id string) error {
- userId := util.ObjToString(s.GetSession("userId"))
- sids := encrypt.CommonDecodeArticle(stype, id)
- if len(sids) == 0 || (len(sids) > 0 && sids[0] == "") {
- s.Redirect("/notin/page", 302)
- return nil
- }
- if userId != "" { //已登录用户直接跳转至正常三级页
- return s.LoginCommon(userId, stype, id)
- }
- return s.NologinCommon(userId, stype, id, sids[0])
- }
- func (s *Short) NologinCommon(userId, stype, id, sid string) error {
- tg := &Tags{}
- catchKey := fmt.Sprintf("jypcdetail_nologin_%s_%s", stype, sid)
- if res := redis.Get("newother", 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")
- s.DisableHttpCache()
- po, bo, wo, obj := pcVRT(sid, industry, stype, false || false || false)
- 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
- }
- FieldProcessing(obj, "", industry, id, "", userId, stype, false)
- obj["urlpath"] = s.Uri()
- obj["industry"] = industry
- if userId == "" {
- obj["winnerTitle"] = obj["winner"]
- obj["buyerTitle"] = obj["buyer"]
- obj["projectnameTitle"] = obj["projectname"]
- obj["projectcodeTitle"] = obj["projectcode"]
- log.Println(time.Now().UnixNano())
- obj = Filter(obj)
- //obj["description"] = fmt.Sprintf("%s,%s。", obj["title"], baseInfo(obj))
- }
- if obj["publishtime"] != nil {
- obj["publishtimeShorDate"] = time.Unix(util.Int64All(obj["publishtime"]), 0).Format(date.Date_Short_Layout)
- }
- 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)
- content, _ := s.Render4Cache("/pc/tags/detail.html", &s.T)
- redis.Put("newother", catchKey, string(content), 60*2)
- return s.SetBody(content)
- }
- } else {
- return s.SetBody([]byte(res.(string)))
- }
- return nil
- }
- /*
- 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, title)
- }
- 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, title)
- }
- 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
- }
|