|
@@ -1,915 +1,915 @@
|
|
|
package front
|
|
|
|
|
|
import (
|
|
|
- "database/sql"
|
|
|
- "errors"
|
|
|
- "fmt"
|
|
|
- "io"
|
|
|
- utils "jy/src/jfw/modules/app/src/app/jyutil"
|
|
|
- "jy/src/jfw/modules/app/src/jfw/config"
|
|
|
- "net/http"
|
|
|
- "regexp"
|
|
|
- "strconv"
|
|
|
- "strings"
|
|
|
- "sync"
|
|
|
- "time"
|
|
|
-
|
|
|
- "github.com/gogf/gf/v2/util/gconv"
|
|
|
-
|
|
|
- "app.yhyue.com/moapp/jybase/date"
|
|
|
- "app.yhyue.com/moapp/jybase/encrypt"
|
|
|
-
|
|
|
- //"math/rand"
|
|
|
- . "jy/src/jfw/modules/app/src/app/jyutil"
|
|
|
- "log"
|
|
|
-
|
|
|
- util "app.yhyue.com/moapp/jybase/common"
|
|
|
- elastic "app.yhyue.com/moapp/jybase/es"
|
|
|
- "app.yhyue.com/moapp/jybase/go-xweb/xweb"
|
|
|
- "app.yhyue.com/moapp/jybase/redis"
|
|
|
- "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
|
|
|
- "app.yhyue.com/moapp/jypkg/public"
|
|
|
+ "database/sql"
|
|
|
+ "errors"
|
|
|
+ "fmt"
|
|
|
+ "io"
|
|
|
+ utils "jy/src/jfw/modules/app/src/app/jyutil"
|
|
|
+ "jy/src/jfw/modules/app/src/jfw/config"
|
|
|
+ "net/http"
|
|
|
+ "regexp"
|
|
|
+ "strconv"
|
|
|
+ "strings"
|
|
|
+ "sync"
|
|
|
+ "time"
|
|
|
+
|
|
|
+ "github.com/gogf/gf/v2/util/gconv"
|
|
|
+
|
|
|
+ "app.yhyue.com/moapp/jybase/date"
|
|
|
+ "app.yhyue.com/moapp/jybase/encrypt"
|
|
|
+
|
|
|
+ //"math/rand"
|
|
|
+ . "jy/src/jfw/modules/app/src/app/jyutil"
|
|
|
+ "log"
|
|
|
+
|
|
|
+ util "app.yhyue.com/moapp/jybase/common"
|
|
|
+ elastic "app.yhyue.com/moapp/jybase/es"
|
|
|
+ "app.yhyue.com/moapp/jybase/go-xweb/xweb"
|
|
|
+ "app.yhyue.com/moapp/jybase/redis"
|
|
|
+ "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
|
|
|
+ "app.yhyue.com/moapp/jypkg/public"
|
|
|
)
|
|
|
|
|
|
type Short struct {
|
|
|
- *xweb.Action
|
|
|
- //article xweb.Mapper `xweb:"/jyapp/article/(\\w+)/(.*).html"` //([pm])
|
|
|
- article xweb.Mapper `xweb:"/jyapp/(article|nologin)/(\\w+)/(.*).html"` //([pm])
|
|
|
- replication xweb.Mapper `xweb:"/jyapp/shorturl/replication"` //用户复制操作记录入库
|
|
|
- whiteList xweb.Mapper `xweb:"/jyapp/initialize/whiteList"` //白名单初始化
|
|
|
- transitRoute xweb.Mapper `xweb:"/jyapp/transit/(.*)"` //中转路由
|
|
|
- clearCache xweb.Mapper `xweb:"/jyapp/free/clearCache"` //清楚缓存
|
|
|
+ *xweb.Action
|
|
|
+ //article xweb.Mapper `xweb:"/jyapp/article/(\\w+)/(.*).html"` //([pm])
|
|
|
+ article xweb.Mapper `xweb:"/jyapp/(article|nologin)/(\\w+)/(.*).html"` //([pm])
|
|
|
+ replication xweb.Mapper `xweb:"/jyapp/shorturl/replication"` //用户复制操作记录入库
|
|
|
+ whiteList xweb.Mapper `xweb:"/jyapp/initialize/whiteList"` //白名单初始化
|
|
|
+ transitRoute xweb.Mapper `xweb:"/jyapp/transit/(.*)"` //中转路由
|
|
|
+ clearCache xweb.Mapper `xweb:"/jyapp/free/clearCache"` //清楚缓存
|
|
|
}
|
|
|
|
|
|
func init() {
|
|
|
- xweb.AddAction(&Short{})
|
|
|
- if config.Seoconfig["hotArea"] != nil {
|
|
|
- utils.HotArea = config.Seoconfig["hotArea"].(string)
|
|
|
- }
|
|
|
+ xweb.AddAction(&Short{})
|
|
|
+ if config.Seoconfig["hotArea"] != nil {
|
|
|
+ utils.HotArea = config.Seoconfig["hotArea"].(string)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
var DateFullLayout = "2006-01-02 15:04:05"
|
|
|
var suffix_msgt = "_SX"
|
|
|
var TypeCodeMap = map[string]string{
|
|
|
- "拟建": "拟建项目",
|
|
|
- "采购意向": "采购意向",
|
|
|
- "预告": "招标预告",
|
|
|
- "预审": "资格预审",
|
|
|
- "预审结果": "资格预审结果",
|
|
|
- "论证意见": "论证意见",
|
|
|
- "需求公示": "需求公示",
|
|
|
- "招标": "公开招标",
|
|
|
- "邀标": "邀请招标",
|
|
|
- "询价": "询价采购",
|
|
|
- "竞谈": "竞争性谈判",
|
|
|
- "单一": "单一来源采购",
|
|
|
- "竞价": "竞价公告",
|
|
|
- "变更": "变更公告",
|
|
|
- "中标": "中标公示",
|
|
|
- "成交": "成交公告",
|
|
|
- "废标": "废标公告",
|
|
|
- "流标": "流标公告",
|
|
|
- "合同": "合同公告信息",
|
|
|
- "验收": "验收公告信息",
|
|
|
- "违规": "违规信息",
|
|
|
+ "拟建": "拟建项目",
|
|
|
+ "采购意向": "采购意向",
|
|
|
+ "预告": "招标预告",
|
|
|
+ "预审": "资格预审",
|
|
|
+ "预审结果": "资格预审结果",
|
|
|
+ "论证意见": "论证意见",
|
|
|
+ "需求公示": "需求公示",
|
|
|
+ "招标": "公开招标",
|
|
|
+ "邀标": "邀请招标",
|
|
|
+ "询价": "询价采购",
|
|
|
+ "竞谈": "竞争性谈判",
|
|
|
+ "单一": "单一来源采购",
|
|
|
+ "竞价": "竞价公告",
|
|
|
+ "变更": "变更公告",
|
|
|
+ "中标": "中标公示",
|
|
|
+ "成交": "成交公告",
|
|
|
+ "废标": "废标公告",
|
|
|
+ "流标": "流标公告",
|
|
|
+ "合同": "合同公告信息",
|
|
|
+ "验收": "验收公告信息",
|
|
|
+ "违规": "违规信息",
|
|
|
}
|
|
|
var (
|
|
|
- redisLimitation = "limitation"
|
|
|
- cacheIndex = []byte{}
|
|
|
- cacheLock = sync.Mutex{}
|
|
|
+ redisLimitation = "limitation"
|
|
|
+ cacheIndex = []byte{}
|
|
|
+ cacheLock = sync.Mutex{}
|
|
|
)
|
|
|
|
|
|
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,
|
|
|
- })
|
|
|
+ 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
|
|
|
+ ipInitAuthentication := s.GetString("ipInitAuthentication")
|
|
|
+ if ipInitAuthentication == config.Sysconfig["ipInitAuthentication"] {
|
|
|
+ config.IpInit()
|
|
|
+ log.Println("初始化ipInit配置")
|
|
|
+ }
|
|
|
+ return nil
|
|
|
}
|
|
|
|
|
|
func (s *Short) Article(contentType, stype, id string) error {
|
|
|
- //先判断是否有session
|
|
|
- sess := s.Session().GetMultiple()
|
|
|
- userId := util.ObjToString(sess["userId"])
|
|
|
- //userId, _ := s.GetSession("userId").(string)
|
|
|
- //if userId == "" {
|
|
|
- // return s.Redirect("/jyapp/free/swordfish/about", 302)
|
|
|
- //}
|
|
|
- //disWord := s.GetString("disWord")
|
|
|
- userPower := jy.GetBigVipUserBaseMsg(s.Session(), *config.Middleground)
|
|
|
- var (
|
|
|
- belongUserId, email string
|
|
|
- isEntnicheNew, isOldVip, isVip, isMember, isEntniche, isEntService bool
|
|
|
- )
|
|
|
- //userId = "637dcf3ff143ed326e9e1589"
|
|
|
- //登录用户 权限
|
|
|
- if userId != "" && strings.Contains(s.Request.RequestURI, "article") {
|
|
|
- //mobileHtmlKey := "jy_mobile_index_app"
|
|
|
- var loginPageInfo = func() (body []byte) {
|
|
|
- // 获取页面内容
|
|
|
- mobileUrl := fmt.Sprintf("%s%s", config.Sysconfig["webdomain"].(string), "/jy_mobile/index.html")
|
|
|
- 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", "app")
|
|
|
- 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
|
|
|
- }
|
|
|
- s.T["isVip"] = isVip
|
|
|
- s.T["member_status"] = userPower.Status
|
|
|
- s.T["email"] = email
|
|
|
- s.T["isEntniche"] = isEntniche
|
|
|
- s.T["isMember"] = isMember
|
|
|
- s.T["isEntService"] = isEntService
|
|
|
- s.T["isEntnicheNew"] = isEntnicheNew
|
|
|
- surl := s.GetString("url")
|
|
|
- kds := s.GetString("keywords")
|
|
|
- industry := s.GetString("industry")
|
|
|
- var sid string
|
|
|
- sid_openid := encrypt.CommonDecodeArticle(stype, id)
|
|
|
- if len(sid_openid) == 0 {
|
|
|
- return s.Redirect("/jyapp/free/swordfish/about", 302)
|
|
|
- } else {
|
|
|
- sid = sid_openid[0]
|
|
|
- }
|
|
|
-
|
|
|
- s.T["keywords"] = kds
|
|
|
- var obj map[string]interface{}
|
|
|
- var canRead bool
|
|
|
- ips := strings.Split(util.GetIp(s.Request), ",")
|
|
|
- var ipTrue bool
|
|
|
- if len(ips) > 0 {
|
|
|
- ipTrue = config.IpList.Match(ips[0])
|
|
|
- }
|
|
|
- log.Printf("三级页userid:%s ips %v", userId, ips)
|
|
|
- obj = wxvisitD(sid, userId, (isVip && isOldVip) || isEntniche || isMember)
|
|
|
- if len(obj) > 0 {
|
|
|
- //if userId == "" && !ipTrue {
|
|
|
- // if util.ObjToString(obj["subtype"]) == "采购意向" || util.ObjToString(obj["subtype"]) == "拟建" {
|
|
|
- // rUrl := "/jyapp/free/login"
|
|
|
- // if util.ObjToString(obj["subtype"]) == "拟建" {
|
|
|
- // rUrl = fmt.Sprintf("%s?DisUrl=%s", rUrl, s.Request.URL)
|
|
|
- // }
|
|
|
- // return s.Redirect(rUrl)
|
|
|
- // }
|
|
|
- //}
|
|
|
- if userId != "" {
|
|
|
- if ((isVip && isOldVip) || isMember || isEntniche) || //老版本vip、大会员、商机管理
|
|
|
- ((isVip && !isOldVip) && (!(util.ObjToString(obj["subtype"]) == "拟建" || util.ObjToString(obj["subtype"]) == "采购意向"))) { //新超级订阅非采购意向”和“拟建项目”
|
|
|
- canRead = true
|
|
|
- } else {
|
|
|
- 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, "采购意向") {
|
|
|
- canRead = false
|
|
|
- } else {
|
|
|
- if resVal := redis.GetStr(redisLimitation, watchKey); resVal != "" {
|
|
|
- sidss := strings.Split(resVal, "_")
|
|
|
- canReadNotice := config.Sysconfig["canReadNotice"]
|
|
|
- if len(sidss) < util.IntAll(canReadNotice) {
|
|
|
- canRead = true
|
|
|
- sidss = append(sidss, sid)
|
|
|
- arrs := RemoveDuplicatesAndEmpty(sidss)
|
|
|
- newVal := strings.Join(arrs, "_")
|
|
|
- redis.Put(redisLimitation, watchKey, newVal, jy.GetExpire())
|
|
|
- } else {
|
|
|
- canRead = false
|
|
|
- for _, v := range sidss {
|
|
|
- if sid == v {
|
|
|
- canRead = true
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- redis.Put(redisLimitation, watchKey, sid, jy.GetExpire())
|
|
|
- canRead = true
|
|
|
- }
|
|
|
- //检验是否留资
|
|
|
- ok := CNode(userId)
|
|
|
- if ok {
|
|
|
- canRead = true
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- //未登录顶部导航
|
|
|
- s.T["hotArea"] = utils.HotAreas
|
|
|
- s.T["areaList"] = utils.AreaInfo
|
|
|
- s.T["infoTypeList"], _ = utils.GetInfoType()
|
|
|
- }
|
|
|
- //超前项目推送处理
|
|
|
- s.T["canRead"] = canRead
|
|
|
- if stype == "advancedProject" {
|
|
|
- newCanRead := false
|
|
|
- //判断此用户是否有打开的权限
|
|
|
- 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
|
|
|
- }
|
|
|
- if newCanRead || canRead {
|
|
|
- obj = wxvisitD(sid, userId, true)
|
|
|
- canRead = true
|
|
|
- }
|
|
|
- s.T["canRead"] = canRead
|
|
|
- }
|
|
|
- // 未登录但是在白名单可以看 不遮挡
|
|
|
- if userId == "" && ipTrue {
|
|
|
- canRead = true
|
|
|
- }
|
|
|
- if canRead || (userId == "" && !ipTrue && util.ObjToString(obj["subtype"]) != "拟建" && util.ObjToString(obj["subtype"]) != "采购意向") {
|
|
|
- if belongUserId != "" && belongUserId != userId && util.ObjToString(obj["subtype"]) != "拟建" && userId != "" { //分享开打的
|
|
|
- article_id := encrypt.CommonDecodeArticle(stype, id)[0]
|
|
|
- key := fmt.Sprintf("integral_article_%s_%s_%s", article_id, belongUserId, 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, belongUserId, jy.Jyapp_node1, nil)
|
|
|
- if err != nil {
|
|
|
- log.Println("nsq队列写入失败-->", jy.Jyweb_article_open, belongUserId)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //获取打赏文案
|
|
|
- //util.ReadConfig(&config.Sysconfig)
|
|
|
- if obj["entidlist"] != nil { //大会员中标企业跳转至画像
|
|
|
- entIdArr, winnerMap := []string{}, map[string]interface{}{}
|
|
|
- eidList, _ := obj["entidlist"].([]interface{})
|
|
|
- swinnerArr := strings.Split(util.ObjToString(obj["s_winner"]), ",")
|
|
|
- //先查询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 util.Int64All(obj["buyerhint"]) == 2 {
|
|
|
- obj["buyerperson"] = ""
|
|
|
- obj["buyertel"] = ""
|
|
|
- }
|
|
|
- //免费用户正文手机号替换
|
|
|
- if obj["site"] == "剑鱼信息发布平台" && !isMember && userId != "" {
|
|
|
- //采购电话中标单位电话置空
|
|
|
- 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 !canRead && util.ObjToString(obj["subtype"]) == "拟建" && !(userId == "" && ipTrue) { //登录拟建&采购不展示遮罩 只打码
|
|
|
- // otherFilter(obj, userId != "")
|
|
|
- // //s.T["canRead"] = true
|
|
|
- //} else
|
|
|
- if userId == "" && !ipTrue {
|
|
|
- obj = Filter(obj)
|
|
|
- obj["description"] = fmt.Sprintf("%s,%s。", obj["title"], baseInfo(obj))
|
|
|
- s.T["canRead"] = true
|
|
|
- }
|
|
|
- if obj["l_publishtime"] != nil {
|
|
|
- obj["publishtimeShorDate"] = time.Unix(util.Int64All(obj["l_publishtime"]), 0).Format(date.Date_Short_Layout)
|
|
|
- }
|
|
|
- //P385 查看原文
|
|
|
- href, _ := obj["href"].(string)
|
|
|
- obj["originalShow"] = false
|
|
|
- if href != "" {
|
|
|
- obj["originalShow"] = true
|
|
|
- delete(obj, "href")
|
|
|
- }
|
|
|
- } else {
|
|
|
- if obj["l_publishtime"] != nil {
|
|
|
- obj["publishtimeShorDate"] = time.Unix(util.Int64All(obj["l_publishtime"]), 0).Format(date.Date_Short_Layout)
|
|
|
- }
|
|
|
- obj = map[string]interface{}{
|
|
|
- "title": obj["title"],
|
|
|
- "_id": obj["_id"],
|
|
|
- "subtype": obj["subtype"],
|
|
|
- "hasSession": false,
|
|
|
- "originalShow": false,
|
|
|
- "l_publishtime": obj["l_publishtime"],
|
|
|
- "publishtimeShorDate": obj["publishtimeShorDate"],
|
|
|
- "area": obj["area"],
|
|
|
- "buyerclass": obj["buyerclass"],
|
|
|
- }
|
|
|
- }
|
|
|
- if userId == "" && ipTrue {
|
|
|
- s.T["canRead"] = true
|
|
|
- }
|
|
|
- if userId != "" {
|
|
|
- s.T["userId"] = se.Encode2Hex(userId) //加密用户userid
|
|
|
- obj["hasSession"] = true
|
|
|
- }
|
|
|
- s.T["forceShareFlag"] = public.CheckUserNeedForceShare(userId, public.ShareType_detail, config.Sysconfig)
|
|
|
- s.T["rewardText"], s.T["advertText"] = getRewardText()
|
|
|
- s.T["advertImg"] = config.Sysconfig["advertImg"]
|
|
|
- s.T["advertName"] = config.Sysconfig["advertName"]
|
|
|
- s.T["advertUrl"] = config.Sysconfig["advertUrl"]
|
|
|
- obj["industry"] = industry
|
|
|
- obj["keywords"] = KeyWordHandle(obj)
|
|
|
- obj["description"] = DescriptionHandle(stype, obj)
|
|
|
-
|
|
|
- if userId == "" {
|
|
|
- var currentLocation []Navigation
|
|
|
- if typeVal := util.ObjToString(obj["toptype"]); typeVal != "" {
|
|
|
- if val := getSeoLocation(typeVal); val != nil {
|
|
|
- currentLocation = append(currentLocation, *val)
|
|
|
- }
|
|
|
- }
|
|
|
- if title := util.ObjToString(obj["title"]); title != "" {
|
|
|
- currentLocation = append(currentLocation, Navigation{
|
|
|
- Name: title,
|
|
|
- })
|
|
|
- }
|
|
|
- s.T["currentLocation"] = currentLocation
|
|
|
- }
|
|
|
- s.T["obj"] = obj
|
|
|
- s.T["isIosExam"], s.T["isIosExamPhone"], _, _ = IosExamInfo(s.Action, false, false)
|
|
|
- content, err := s.Render4Cache("/weixin/wxinfocontent.html", &s.T)
|
|
|
- if err != nil {
|
|
|
- log.Println("模板数据写入失败:", err.Error())
|
|
|
- }
|
|
|
- return s.SetBody(content)
|
|
|
- }
|
|
|
- if surl != "" {
|
|
|
- return s.Redirect(surl)
|
|
|
- }
|
|
|
- return s.Redirect("/jyapp/free/mob/err")
|
|
|
+ //先判断是否有session
|
|
|
+ sess := s.Session().GetMultiple()
|
|
|
+ userId := util.ObjToString(sess["userId"])
|
|
|
+ //userId, _ := s.GetSession("userId").(string)
|
|
|
+ //if userId == "" {
|
|
|
+ // return s.Redirect("/jyapp/free/swordfish/about", 302)
|
|
|
+ //}
|
|
|
+ //disWord := s.GetString("disWord")
|
|
|
+ userPower := jy.GetBigVipUserBaseMsg(s.Session(), *config.Middleground)
|
|
|
+ var (
|
|
|
+ belongUserId, email string
|
|
|
+ isEntnicheNew, isOldVip, isVip, isMember, isEntniche, isEntService bool
|
|
|
+ )
|
|
|
+ //userId = "637dcf3ff143ed326e9e1589"
|
|
|
+ //登录用户 权限
|
|
|
+ if userId != "" { //&& strings.Contains(s.Request.RequestURI, "article")
|
|
|
+ //mobileHtmlKey := "jy_mobile_index_app"
|
|
|
+ var loginPageInfo = func() (body []byte) {
|
|
|
+ // 获取页面内容
|
|
|
+ mobileUrl := fmt.Sprintf("%s%s", config.Sysconfig["webdomain"].(string), "/jy_mobile/index.html")
|
|
|
+ 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", "app")
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ s.T["isVip"] = isVip
|
|
|
+ s.T["member_status"] = userPower.Status
|
|
|
+ s.T["email"] = email
|
|
|
+ s.T["isEntniche"] = isEntniche
|
|
|
+ s.T["isMember"] = isMember
|
|
|
+ s.T["isEntService"] = isEntService
|
|
|
+ s.T["isEntnicheNew"] = isEntnicheNew
|
|
|
+ surl := s.GetString("url")
|
|
|
+ kds := s.GetString("keywords")
|
|
|
+ industry := s.GetString("industry")
|
|
|
+ var sid string
|
|
|
+ sid_openid := encrypt.CommonDecodeArticle(stype, id)
|
|
|
+ if len(sid_openid) == 0 {
|
|
|
+ return s.Redirect("/jyapp/free/swordfish/about", 302)
|
|
|
+ } else {
|
|
|
+ sid = sid_openid[0]
|
|
|
+ }
|
|
|
+
|
|
|
+ s.T["keywords"] = kds
|
|
|
+ var obj map[string]interface{}
|
|
|
+ var canRead bool
|
|
|
+ ips := strings.Split(util.GetIp(s.Request), ",")
|
|
|
+ var ipTrue bool
|
|
|
+ if len(ips) > 0 {
|
|
|
+ ipTrue = config.IpList.Match(ips[0])
|
|
|
+ }
|
|
|
+ log.Printf("三级页userid:%s ips %v", userId, ips)
|
|
|
+ obj = wxvisitD(sid, userId, (isVip && isOldVip) || isEntniche || isMember)
|
|
|
+ if len(obj) > 0 {
|
|
|
+ //if userId == "" && !ipTrue {
|
|
|
+ // if util.ObjToString(obj["subtype"]) == "采购意向" || util.ObjToString(obj["subtype"]) == "拟建" {
|
|
|
+ // rUrl := "/jyapp/free/login"
|
|
|
+ // if util.ObjToString(obj["subtype"]) == "拟建" {
|
|
|
+ // rUrl = fmt.Sprintf("%s?DisUrl=%s", rUrl, s.Request.URL)
|
|
|
+ // }
|
|
|
+ // return s.Redirect(rUrl)
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ if userId != "" {
|
|
|
+ if ((isVip && isOldVip) || isMember || isEntniche) || //老版本vip、大会员、商机管理
|
|
|
+ ((isVip && !isOldVip) && (!(util.ObjToString(obj["subtype"]) == "拟建" || util.ObjToString(obj["subtype"]) == "采购意向"))) { //新超级订阅非采购意向”和“拟建项目”
|
|
|
+ canRead = true
|
|
|
+ } else {
|
|
|
+ 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, "采购意向") {
|
|
|
+ canRead = false
|
|
|
+ } else {
|
|
|
+ if resVal := redis.GetStr(redisLimitation, watchKey); resVal != "" {
|
|
|
+ sidss := strings.Split(resVal, "_")
|
|
|
+ canReadNotice := config.Sysconfig["canReadNotice"]
|
|
|
+ if len(sidss) < util.IntAll(canReadNotice) {
|
|
|
+ canRead = true
|
|
|
+ sidss = append(sidss, sid)
|
|
|
+ arrs := RemoveDuplicatesAndEmpty(sidss)
|
|
|
+ newVal := strings.Join(arrs, "_")
|
|
|
+ redis.Put(redisLimitation, watchKey, newVal, jy.GetExpire())
|
|
|
+ } else {
|
|
|
+ canRead = false
|
|
|
+ for _, v := range sidss {
|
|
|
+ if sid == v {
|
|
|
+ canRead = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ redis.Put(redisLimitation, watchKey, sid, jy.GetExpire())
|
|
|
+ canRead = true
|
|
|
+ }
|
|
|
+ //检验是否留资
|
|
|
+ ok := CNode(userId)
|
|
|
+ if ok {
|
|
|
+ canRead = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //未登录顶部导航
|
|
|
+ s.T["hotArea"] = utils.HotAreas
|
|
|
+ s.T["areaList"] = utils.AreaInfo
|
|
|
+ s.T["infoTypeList"], _ = utils.GetInfoType()
|
|
|
+ }
|
|
|
+ //超前项目推送处理
|
|
|
+ s.T["canRead"] = canRead
|
|
|
+ if stype == "advancedProject" {
|
|
|
+ newCanRead := false
|
|
|
+ //判断此用户是否有打开的权限
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ if newCanRead || canRead {
|
|
|
+ obj = wxvisitD(sid, userId, true)
|
|
|
+ canRead = true
|
|
|
+ }
|
|
|
+ s.T["canRead"] = canRead
|
|
|
+ }
|
|
|
+ // 未登录但是在白名单可以看 不遮挡
|
|
|
+ if userId == "" && ipTrue {
|
|
|
+ canRead = true
|
|
|
+ }
|
|
|
+ if canRead || (userId == "" && !ipTrue && util.ObjToString(obj["subtype"]) != "拟建" && util.ObjToString(obj["subtype"]) != "采购意向") {
|
|
|
+ if belongUserId != "" && belongUserId != userId && util.ObjToString(obj["subtype"]) != "拟建" && userId != "" { //分享开打的
|
|
|
+ article_id := encrypt.CommonDecodeArticle(stype, id)[0]
|
|
|
+ key := fmt.Sprintf("integral_article_%s_%s_%s", article_id, belongUserId, 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, belongUserId, jy.Jyapp_node1, nil)
|
|
|
+ if err != nil {
|
|
|
+ log.Println("nsq队列写入失败-->", jy.Jyweb_article_open, belongUserId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //获取打赏文案
|
|
|
+ //util.ReadConfig(&config.Sysconfig)
|
|
|
+ if obj["entidlist"] != nil { //大会员中标企业跳转至画像
|
|
|
+ entIdArr, winnerMap := []string{}, map[string]interface{}{}
|
|
|
+ eidList, _ := obj["entidlist"].([]interface{})
|
|
|
+ swinnerArr := strings.Split(util.ObjToString(obj["s_winner"]), ",")
|
|
|
+ //先查询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 util.Int64All(obj["buyerhint"]) == 2 {
|
|
|
+ obj["buyerperson"] = ""
|
|
|
+ obj["buyertel"] = ""
|
|
|
+ }
|
|
|
+ //免费用户正文手机号替换
|
|
|
+ if obj["site"] == "剑鱼信息发布平台" && !isMember && userId != "" {
|
|
|
+ //采购电话中标单位电话置空
|
|
|
+ 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 !canRead && util.ObjToString(obj["subtype"]) == "拟建" && !(userId == "" && ipTrue) { //登录拟建&采购不展示遮罩 只打码
|
|
|
+ // otherFilter(obj, userId != "")
|
|
|
+ // //s.T["canRead"] = true
|
|
|
+ //} else
|
|
|
+ if userId == "" && !ipTrue {
|
|
|
+ obj = Filter(obj)
|
|
|
+ obj["description"] = fmt.Sprintf("%s,%s。", obj["title"], baseInfo(obj))
|
|
|
+ s.T["canRead"] = true
|
|
|
+ }
|
|
|
+ if obj["l_publishtime"] != nil {
|
|
|
+ obj["publishtimeShorDate"] = time.Unix(util.Int64All(obj["l_publishtime"]), 0).Format(date.Date_Short_Layout)
|
|
|
+ }
|
|
|
+ //P385 查看原文
|
|
|
+ href, _ := obj["href"].(string)
|
|
|
+ obj["originalShow"] = false
|
|
|
+ if href != "" {
|
|
|
+ obj["originalShow"] = true
|
|
|
+ delete(obj, "href")
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if obj["l_publishtime"] != nil {
|
|
|
+ obj["publishtimeShorDate"] = time.Unix(util.Int64All(obj["l_publishtime"]), 0).Format(date.Date_Short_Layout)
|
|
|
+ }
|
|
|
+ obj = map[string]interface{}{
|
|
|
+ "title": obj["title"],
|
|
|
+ "_id": obj["_id"],
|
|
|
+ "subtype": obj["subtype"],
|
|
|
+ "hasSession": false,
|
|
|
+ "originalShow": false,
|
|
|
+ "l_publishtime": obj["l_publishtime"],
|
|
|
+ "publishtimeShorDate": obj["publishtimeShorDate"],
|
|
|
+ "area": obj["area"],
|
|
|
+ "buyerclass": obj["buyerclass"],
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if userId == "" && ipTrue {
|
|
|
+ s.T["canRead"] = true
|
|
|
+ }
|
|
|
+ if userId != "" {
|
|
|
+ s.T["userId"] = se.Encode2Hex(userId) //加密用户userid
|
|
|
+ obj["hasSession"] = true
|
|
|
+ }
|
|
|
+ s.T["forceShareFlag"] = public.CheckUserNeedForceShare(userId, public.ShareType_detail, config.Sysconfig)
|
|
|
+ s.T["rewardText"], s.T["advertText"] = getRewardText()
|
|
|
+ s.T["advertImg"] = config.Sysconfig["advertImg"]
|
|
|
+ s.T["advertName"] = config.Sysconfig["advertName"]
|
|
|
+ s.T["advertUrl"] = config.Sysconfig["advertUrl"]
|
|
|
+ obj["industry"] = industry
|
|
|
+ obj["keywords"] = KeyWordHandle(obj)
|
|
|
+ obj["description"] = DescriptionHandle(stype, obj)
|
|
|
+
|
|
|
+ if userId == "" {
|
|
|
+ var currentLocation []Navigation
|
|
|
+ if typeVal := util.ObjToString(obj["toptype"]); typeVal != "" {
|
|
|
+ if val := getSeoLocation(typeVal); val != nil {
|
|
|
+ currentLocation = append(currentLocation, *val)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if title := util.ObjToString(obj["title"]); title != "" {
|
|
|
+ currentLocation = append(currentLocation, Navigation{
|
|
|
+ Name: title,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ s.T["currentLocation"] = currentLocation
|
|
|
+ }
|
|
|
+ s.T["obj"] = obj
|
|
|
+ s.T["isIosExam"], s.T["isIosExamPhone"], _, _ = IosExamInfo(s.Action, false, false)
|
|
|
+ content, err := s.Render4Cache("/weixin/wxinfocontent.html", &s.T)
|
|
|
+ if err != nil {
|
|
|
+ log.Println("模板数据写入失败:", err.Error())
|
|
|
+ }
|
|
|
+ return s.SetBody(content)
|
|
|
+ }
|
|
|
+ if surl != "" {
|
|
|
+ return s.Redirect(surl)
|
|
|
+ }
|
|
|
+ return s.Redirect("/jyapp/free/mob/err")
|
|
|
}
|
|
|
|
|
|
var typeUrlMap = map[string]string{
|
|
|
- "预告": "/list/stype/ZBYG.html",
|
|
|
- "招标": "/list/stype/ZBGG.html",
|
|
|
- "结果": "/list/stype/ZBJG.html",
|
|
|
- "其它": "/list/stype/ZBXYXX.html",
|
|
|
+ "预告": "/list/stype/ZBYG.html",
|
|
|
+ "招标": "/list/stype/ZBGG.html",
|
|
|
+ "结果": "/list/stype/ZBJG.html",
|
|
|
+ "其它": "/list/stype/ZBXYXX.html",
|
|
|
}
|
|
|
|
|
|
func getSeoLocation(name string) *Navigation {
|
|
|
- var url string
|
|
|
+ var url string
|
|
|
|
|
|
- if url = typeUrlMap[name]; url != "" {
|
|
|
- return &Navigation{
|
|
|
- Name: name,
|
|
|
- Url: url,
|
|
|
- }
|
|
|
- }
|
|
|
+ if url = typeUrlMap[name]; url != "" {
|
|
|
+ return &Navigation{
|
|
|
+ Name: name,
|
|
|
+ Url: url,
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- switch name {
|
|
|
+ switch name {
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- return nil
|
|
|
+ return nil
|
|
|
}
|
|
|
|
|
|
// 未登录用户进行数据过滤
|
|
|
func Filter(obj map[string]interface{}) map[string]interface{} {
|
|
|
- detail := fmt.Sprint(obj["detail"])
|
|
|
- //mosaicText := fmt.Sprintf(`<span class="noLoginMosaic">%s</span>`, util.ObjToString(config.Sysconfig["detailMosaic"]))
|
|
|
- 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"]))
|
|
|
- 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
|
|
|
+ detail := fmt.Sprint(obj["detail"])
|
|
|
+ //mosaicText := fmt.Sprintf(`<span class="noLoginMosaic">%s</span>`, util.ObjToString(config.Sysconfig["detailMosaic"]))
|
|
|
+ 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"]))
|
|
|
+ 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
|
|
|
+ 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
|
|
|
}
|
|
|
|
|
|
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
|
|
|
+ reg, err := regexp.Compile(rule)
|
|
|
+ if reg == nil || err != nil {
|
|
|
+ return "", errors.New("正则MustCompile错误:" + err.Error())
|
|
|
+ }
|
|
|
+ return reg.ReplaceAllString(str, replace), nil
|
|
|
}
|
|
|
|
|
|
// 分段匹配数字打码
|
|
|
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 ""
|
|
|
+ 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 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 := utils.Compatible.Select(userId, `{"s_phone":1,"s_m_phone":1,"s_myemail":1,"s_company":1,"o_jy":1,"o_vipjy":1}`); userinfo != nil && ok && 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
|
|
|
+ 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 := utils.Compatible.Select(userId, `{"s_phone":1,"s_m_phone":1,"s_myemail":1,"s_company":1,"o_jy":1,"o_vipjy":1}`); userinfo != nil && ok && 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 GetbelongUserId(disWord, userId string) (belongUserId string) {
|
|
|
- if disWord != "" {
|
|
|
- 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]
|
|
|
- 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)
|
|
|
- }
|
|
|
- return true
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return
|
|
|
+ if disWord != "" {
|
|
|
+ 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]
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
func TimeProcessing(hour interface{}, duration int) time.Time {
|
|
|
- todayZero, _ := time.ParseInLocation("2006-01-02 15:04:05", fmt.Sprint(hour), time.Local)
|
|
|
- mm, _ := time.ParseDuration(fmt.Sprint(duration) + "m")
|
|
|
- t := todayZero.Add(mm)
|
|
|
- return t
|
|
|
+ todayZero, _ := time.ParseInLocation("2006-01-02 15:04:05", fmt.Sprint(hour), time.Local)
|
|
|
+ mm, _ := time.ParseDuration(fmt.Sprint(duration) + "m")
|
|
|
+ t := todayZero.Add(mm)
|
|
|
+ return t
|
|
|
}
|
|
|
|
|
|
// 三级页复制操作记录
|
|
|
func (s *Short) Replication() {
|
|
|
- mongodb.Save("copyaction", map[string]interface{}{
|
|
|
- "userid": s.GetSession("userId").(string),
|
|
|
- "createtime": time.Now().Unix(),
|
|
|
- "url": s.Request.Referer(),
|
|
|
- "client": s.Header("User-Agent"),
|
|
|
- })
|
|
|
+ mongodb.Save("copyaction", map[string]interface{}{
|
|
|
+ "userid": s.GetSession("userId").(string),
|
|
|
+ "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
|
|
|
+ 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 ""
|
|
|
+ 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 UserPermission(userId string) (isVip, isOldVip, isEntniche bool, i_member_status int, email string) {
|
|
|
- var phone string
|
|
|
- data := utils.Compatible.Select(userId, `{"i_vip_status":1,"i_member_status":1,"s_myemail":1,"s_phone":1,"s_m_phone":1,"l_vip_starttime":1}`)
|
|
|
- if data != nil && len(*data) > 0 {
|
|
|
- i_vip_status := util.IntAll((*data)["i_vip_status"])
|
|
|
- if i_vip_status > 0 {
|
|
|
- isVip = true
|
|
|
- if util.Int64All((*data)["l_vip_starttime"]) < util.Int64All(config.Sysconfig["contextOldVipLimit"]) {
|
|
|
- isOldVip = true
|
|
|
- }
|
|
|
- }
|
|
|
- i_member_status = util.IntAllDef((*data)["i_member_status"], 0)
|
|
|
- email = util.ObjToStringDef((*data)["s_myemail"], "")
|
|
|
- if s_phone, _ := (*data)["s_phone"].(string); s_phone != "" {
|
|
|
- phone = s_phone
|
|
|
- } else if s_m_phone, _ := (*data)["s_m_phone"].(string); s_m_phone != "" {
|
|
|
- phone = s_m_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
|
|
|
- return
|
|
|
+ var phone string
|
|
|
+ data := utils.Compatible.Select(userId, `{"i_vip_status":1,"i_member_status":1,"s_myemail":1,"s_phone":1,"s_m_phone":1,"l_vip_starttime":1}`)
|
|
|
+ if data != nil && len(*data) > 0 {
|
|
|
+ i_vip_status := util.IntAll((*data)["i_vip_status"])
|
|
|
+ if i_vip_status > 0 {
|
|
|
+ isVip = true
|
|
|
+ if util.Int64All((*data)["l_vip_starttime"]) < util.Int64All(config.Sysconfig["contextOldVipLimit"]) {
|
|
|
+ isOldVip = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ i_member_status = util.IntAllDef((*data)["i_member_status"], 0)
|
|
|
+ email = util.ObjToStringDef((*data)["s_myemail"], "")
|
|
|
+ if s_phone, _ := (*data)["s_phone"].(string); s_phone != "" {
|
|
|
+ phone = s_phone
|
|
|
+ } else if s_m_phone, _ := (*data)["s_m_phone"].(string); s_m_phone != "" {
|
|
|
+ phone = s_m_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
|
|
|
+ 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
|
|
|
+ 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
|
|
|
+ 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
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
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
|
|
|
+ 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 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, util.InterfaceToStr(obj["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
|
|
|
+ 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, util.InterfaceToStr(obj["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 := ""
|
|
|
- pushTime := time.Unix(util.Int64All(obj["l_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"])
|
|
|
- publishtime := util.Int64All(obj["l_publishtime"])
|
|
|
- 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
|
|
|
+ description := ""
|
|
|
+ pushTime := time.Unix(util.Int64All(obj["l_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"])
|
|
|
+ publishtime := util.Int64All(obj["l_publishtime"])
|
|
|
+ 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
|
|
|
}
|
|
|
|
|
|
// TransitRoute 中转路由
|
|
|
func (s *Short) TransitRoute(key string) error {
|
|
|
- redirectUrl := "/"
|
|
|
- if key != "" {
|
|
|
- shortUrls := public.Mysql.SelectBySql(`SELECT * FROM short_url WHERE mold = 1 AND code = ?`, key)
|
|
|
- if shortUrls != nil && len(*shortUrls) > 0 {
|
|
|
- shortUrl := (*shortUrls)[0]
|
|
|
- //登录用户跳转地址
|
|
|
- if util.ObjToString(shortUrl["url"]) != "" {
|
|
|
- redirectUrl = util.ObjToString(shortUrl["url"])
|
|
|
- }
|
|
|
- //未登录用户跳转地址
|
|
|
- if util.ObjToString(shortUrl["href"]) != "" && util.ObjToString(s.GetSession("userId")) == "" {
|
|
|
- redirectUrl = util.ObjToString(shortUrl["href"])
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return s.Redirect(redirectUrl)
|
|
|
+ redirectUrl := "/"
|
|
|
+ if key != "" {
|
|
|
+ shortUrls := public.Mysql.SelectBySql(`SELECT * FROM short_url WHERE mold = 1 AND code = ?`, key)
|
|
|
+ if shortUrls != nil && len(*shortUrls) > 0 {
|
|
|
+ shortUrl := (*shortUrls)[0]
|
|
|
+ //登录用户跳转地址
|
|
|
+ if util.ObjToString(shortUrl["url"]) != "" {
|
|
|
+ redirectUrl = util.ObjToString(shortUrl["url"])
|
|
|
+ }
|
|
|
+ //未登录用户跳转地址
|
|
|
+ if util.ObjToString(shortUrl["href"]) != "" && util.ObjToString(s.GetSession("userId")) == "" {
|
|
|
+ redirectUrl = util.ObjToString(shortUrl["href"])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return s.Redirect(redirectUrl)
|
|
|
}
|