|
@@ -2,8 +2,14 @@ package front
|
|
|
|
|
|
import (
|
|
|
"database/sql"
|
|
|
+ "errors"
|
|
|
"fmt"
|
|
|
+<<<<<<< HEAD
|
|
|
"jy/src/jfw/modules/app/src/jfw/config"
|
|
|
+=======
|
|
|
+ "jfw/config"
|
|
|
+ "qfw/util/fsw"
|
|
|
+>>>>>>> master
|
|
|
"regexp"
|
|
|
"strconv"
|
|
|
"strings"
|
|
@@ -41,34 +47,52 @@ var suffix_msgt = "_SX"
|
|
|
func (s *Short) Article(stype, id string) error {
|
|
|
//先判断是否有session
|
|
|
userId, _ := s.GetSession("userId").(string)
|
|
|
-
|
|
|
- if userId == "" {
|
|
|
- return s.Redirect("/jyapp/free/swordfish/about", 302)
|
|
|
- }
|
|
|
+ log.Printf("三级页userid:%s", userId)
|
|
|
+ //if userId == "" {
|
|
|
+ // return s.Redirect("/jyapp/free/swordfish/about", 302)
|
|
|
+ //}
|
|
|
disWord := s.GetString("disWord")
|
|
|
+<<<<<<< HEAD
|
|
|
belongUserId := GetbelongUserId(disWord, userId)
|
|
|
b, _ := redis.Exists("sso", "req_"+userId)
|
|
|
if b {
|
|
|
return s.Redirect("/jyapp/free/mob/err")
|
|
|
}
|
|
|
userPower := jy.GetBigVipUserBaseMsg( s.Session(), *config.Middleground)
|
|
|
+=======
|
|
|
+>>>>>>> master
|
|
|
var (
|
|
|
- isEntnicheNew bool = userPower.EntIsNew //新版超级订阅
|
|
|
- isOldVip bool = false //新购超级订阅不能查看拟建项目详情页
|
|
|
- isVip bool = userPower.VipStatus > 0 //超级订阅
|
|
|
- isMember bool = userPower.Status > 0 //大会员
|
|
|
- isEntniche bool = userPower.EntnicheStatus > 0 //商机管理
|
|
|
- email string = userPower.Email //用户邮箱
|
|
|
- isEntService bool = userPower.IsEntService //商机管理服务
|
|
|
+ belongUserId, email string
|
|
|
+
|
|
|
+ isEntnicheNew, isOldVip, isVip, isMember, isEntniche, isEntService bool
|
|
|
)
|
|
|
- _, isOldVip, _, _, _ = UserPermission(userId)
|
|
|
- entId := util.IntAll(s.GetSession("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
|
|
|
+ userPower := new(jy.BigVipBaseMsg)
|
|
|
+ //userId = "637dcf3ff143ed326e9e1589"
|
|
|
+ //登录用户 权限
|
|
|
+ if userId != "" {
|
|
|
+ belongUserId = GetbelongUserId(disWord, userId)
|
|
|
+ b, _ := redis.Exists("sso", "req_"+userId)
|
|
|
+ if b {
|
|
|
+ return s.Redirect("/jyapp/free/mob/err")
|
|
|
+ }
|
|
|
+ userPower = jy.GetBigVipUserBaseMsg(userId, public.Mysql, public.MQFW)
|
|
|
+
|
|
|
+ isEntnicheNew = userPower.EntIsNew //新版超级订阅
|
|
|
+ isOldVip = false //新购超级订阅不能查看拟建项目详情页
|
|
|
+ isVip = userPower.VipStatus > 0 //超级订阅
|
|
|
+ isMember = userPower.Status > 0 //大会员
|
|
|
+ isEntniche = userPower.EntnicheStatus > 0 //商机管理
|
|
|
+ email = userPower.Email //用户邮箱
|
|
|
+ isEntService = userPower.IsEntService //商机管理服务
|
|
|
+ _, isOldVip, _, _, _ = UserPermission(userId)
|
|
|
+ entId := util.IntAll(s.GetSession("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
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
s.T["isVip"] = isVip
|
|
@@ -93,70 +117,79 @@ func (s *Short) Article(stype, id string) error {
|
|
|
var obj map[string]interface{}
|
|
|
var canRead bool
|
|
|
obj = wxvisitD(sid, userId, (isVip && isOldVip) || isEntniche || isMember)
|
|
|
-
|
|
|
- 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("other", 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("other", watchKey, newVal, jy.GetExpire())
|
|
|
- } else {
|
|
|
+ if len(obj) > 0 {
|
|
|
+ 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
|
|
|
- for _, v := range sidss {
|
|
|
- if sid == v {
|
|
|
+ } else {
|
|
|
+ if resVal := redis.GetStr("other", watchKey); resVal != "" {
|
|
|
+ sidss := strings.Split(resVal, "_")
|
|
|
+ canReadNotice := config.Sysconfig["canReadNotice"]
|
|
|
+ if len(sidss) < util.IntAll(canReadNotice) {
|
|
|
canRead = true
|
|
|
- break
|
|
|
+ sidss = append(sidss, sid)
|
|
|
+ arrs := RemoveDuplicatesAndEmpty(sidss)
|
|
|
+ newVal := strings.Join(arrs, "_")
|
|
|
+ redis.Put("other", watchKey, newVal, jy.GetExpire())
|
|
|
+ } else {
|
|
|
+ canRead = false
|
|
|
+ for _, v := range sidss {
|
|
|
+ if sid == v {
|
|
|
+ canRead = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ } else {
|
|
|
+ redis.Put("other", watchKey, sid, jy.GetExpire())
|
|
|
+ canRead = true
|
|
|
+ }
|
|
|
+ //检验是否留资
|
|
|
+ ok := CNode(userId)
|
|
|
+ if ok {
|
|
|
+ canRead = true
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //超前项目推送处理
|
|
|
+ s.T["canRead"] = canRead
|
|
|
+ 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 {
|
|
|
- redis.Put("other", watchKey, sid, jy.GetExpire())
|
|
|
- canRead = true
|
|
|
+ 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
|
|
|
}
|
|
|
- //检验是否留资
|
|
|
- ok := CNode(userId)
|
|
|
- if ok {
|
|
|
+ if newCanRead || canRead {
|
|
|
+ obj = wxvisitD(sid, userId, true)
|
|
|
canRead = true
|
|
|
}
|
|
|
+ s.T["canRead"] = canRead
|
|
|
}
|
|
|
- }
|
|
|
- //超前项目推送处理
|
|
|
- s.T["canRead"] = canRead
|
|
|
- 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, true)
|
|
|
+ if userId == "" {
|
|
|
canRead = true
|
|
|
+ s.T["canRead"] = canRead
|
|
|
}
|
|
|
- s.T["canRead"] = canRead
|
|
|
- }
|
|
|
-
|
|
|
- if len(obj) > 0 {
|
|
|
if canRead {
|
|
|
+<<<<<<< HEAD
|
|
|
if belongUserId != "" && belongUserId != userId && util.ObjToString(obj["subtype"]) != "拟建" { //分享开打的
|
|
|
article_id := encrypt.CommonDecodeArticle(stype, id)[0]
|
|
|
+=======
|
|
|
+ if belongUserId != "" && belongUserId != userId && util.ObjToString(obj["subtype"]) != "拟建" && userId != "" { //分享开打的
|
|
|
+ article_id := util.CommonDecodeArticle(stype, id)[0]
|
|
|
+>>>>>>> master
|
|
|
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)
|
|
@@ -197,15 +230,13 @@ func (s *Short) Article(stype, id string) error {
|
|
|
obj["entId"] = entIdArr
|
|
|
obj["winnerMap"] = winnerMap
|
|
|
}
|
|
|
- s.T["userId"] = se.Encode2Hex(userId) //加密用户userid
|
|
|
-
|
|
|
//判断是否公开联系人信息
|
|
|
if util.Int64All(obj["buyerhint"]) == 2 {
|
|
|
obj["buyerperson"] = ""
|
|
|
obj["buyertel"] = ""
|
|
|
}
|
|
|
//免费用户正文手机号替换
|
|
|
- if obj["site"] == "剑鱼信息发布平台" && isMember {
|
|
|
+ if obj["site"] == "剑鱼信息发布平台" && !isMember && userId != "" {
|
|
|
//采购电话中标单位电话置空
|
|
|
if util.InterfaceToStr(obj["buyertel"]) != "" {
|
|
|
obj["buyertel"] = "freeView"
|
|
@@ -233,6 +264,9 @@ func (s *Short) Article(stype, id string) error {
|
|
|
obj["detail"] = strings.ReplaceAll(strings.ReplaceAll(detail3, `<span class="freeView">点击查看</span><span class="freeView">点击查看</span>`, `<span class="freeView">点击查看</span>`), "*********", code)
|
|
|
}
|
|
|
}
|
|
|
+ if userId == "" {
|
|
|
+ obj = Filter(obj)
|
|
|
+ }
|
|
|
} else {
|
|
|
obj = map[string]interface{}{
|
|
|
"title": obj["title"],
|
|
@@ -240,16 +274,27 @@ func (s *Short) Article(stype, id string) error {
|
|
|
"subtype": obj["subtype"],
|
|
|
}
|
|
|
}
|
|
|
+ if userId != "" {
|
|
|
+ s.T["userId"] = se.Encode2Hex(userId) //加密用户userid
|
|
|
+ }
|
|
|
+ s.T["forceShareFlag"] = public.CheckUserNeedForceShare(userId, public.ShareType_detail)
|
|
|
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
|
|
|
+<<<<<<< HEAD
|
|
|
obj["ucbsId"] = encrypt.EncodeArticleId2ByCheck("ucbs#" + userId + "#" + id)
|
|
|
s.T["obj"] = obj
|
|
|
s.T["forceShareFlag"] = public.CheckUserNeedForceShare(userId, public.ShareType_detail, config.Sysconfig)
|
|
|
+=======
|
|
|
+ s.T["obj"] = obj
|
|
|
+>>>>>>> master
|
|
|
s.T["isIosExam"], s.T["isIosExamPhone"], _, _ = IosExamInfo(s.Action, false, false)
|
|
|
- content, _ := s.Render4Cache("/weixin/wxinfocontent.html", &s.T)
|
|
|
+ content, err := s.Render4Cache("/weixin/wxinfocontent.html", &s.T)
|
|
|
+ if err != nil {
|
|
|
+ log.Println("模板数据写入失败:", err.Error())
|
|
|
+ }
|
|
|
return s.SetBody(content)
|
|
|
}
|
|
|
if surl != "" {
|
|
@@ -258,6 +303,124 @@ func (s *Short) Article(stype, id string) error {
|
|
|
return s.Redirect("/jyapp/free/mob/err")
|
|
|
}
|
|
|
|
|
|
+func NoLoginArticle(stype, sid string) map[string]interface{} {
|
|
|
+ obj := make(map[string]interface{})
|
|
|
+ catchKey := fmt.Sprintf("jypcdetail_nologin_app_%s_%s", stype, sid)
|
|
|
+ //if res := redis.Get("other", catchKey); res != nil && res != "" {
|
|
|
+ // if data := util.ObjToMap(res); data != nil {
|
|
|
+ // obj = *data
|
|
|
+ // return obj
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ obj = wxvisitD(sid, "", false)
|
|
|
+ if len(obj) > 0 {
|
|
|
+ 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, util.EncodeArticleId2ByCheck(util.ObjToString((*rData)[0]["_id"])))
|
|
|
+ winnerMap[v] = util.EncodeArticleId2ByCheck(util.ObjToString((*rData)[0]["_id"]))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for k, v := range eidList {
|
|
|
+ vstr := util.ObjToString(v)
|
|
|
+ if vstr == "-" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ winnerMap[swinnerArr[k]] = util.EncodeArticleId2ByCheck(vstr)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ obj["entId"] = entIdArr
|
|
|
+ obj["winnerMap"] = winnerMap
|
|
|
+ }
|
|
|
+ //判断是否公开联系人信息
|
|
|
+ if util.Int64All(obj["buyerhint"]) == 2 {
|
|
|
+ obj["buyerperson"] = ""
|
|
|
+ obj["buyertel"] = ""
|
|
|
+ }
|
|
|
+
|
|
|
+ obj["winnerTitle"] = obj["winner"]
|
|
|
+ obj["buyerTitle"] = obj["buyer"]
|
|
|
+ obj["projectnameTitle"] = obj["projectname"]
|
|
|
+ obj["projectcodeTitle"] = obj["projectcode"]
|
|
|
+ obj = Filter(obj)
|
|
|
+ redis.Put("other", catchKey, obj, 60*60*2)
|
|
|
+ }
|
|
|
+ fmt.Println("11111", obj)
|
|
|
+ return obj
|
|
|
+}
|
|
|
+
|
|
|
+// 未登录用户进行数据过滤
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+// 分段匹配数字打码
|
|
|
+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 CNode(userId string) bool {
|
|
|
if hasRetainedCapital(userId, "jyarticle_see3_plus") {
|
|
|
return true
|