Pārlūkot izejas kodu

feat:平台访问调整

wangshan 1 gadu atpakaļ
vecāks
revīzija
db937630eb

+ 15 - 0
src/jfw/active/active.go

@@ -2,6 +2,7 @@ package active
 
 import (
 	"app.yhyue.com/moapp/jypkg/public"
+	"regexp"
 
 	util "app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/encrypt"
@@ -49,6 +50,7 @@ type Active struct {
 
 var mongodb = public.MQFW
 var se = encrypt.SimpleEncrypt{Key: "topnet2015topnet2015"}
+var mobileReg = regexp.MustCompile("(?i)(Android|Mobile|Phone)")
 
 func init() {
 	//添加模块解析
@@ -59,6 +61,19 @@ func init() {
 func (a *Active) TransitRoute(key string) error {
 	redirectUrl := "/"
 	if key != "" {
+		//P477  临时需求 紧急发版 后续优化
+		//是否是移动端
+		bm := mobileReg.MatchString(a.Header("User-Agent"))
+		switch key {
+		case "day01": //PC
+			if bm { //如果是移动端 访问移动端
+				return a.Redirect("/active/transit/day03")
+			}
+		case "day03": //WX
+			if !bm { //如果电脑端 访问电脑端
+				return a.Redirect("/active/transit/day01")
+			}
+		}
 		shortUrls := public.Mysql.SelectBySql(`SELECT * FROM short_url WHERE mold = 1 AND code = ?`, key)
 		if shortUrls != nil && len(*shortUrls) > 0 {
 			shortUrl := (*shortUrls)[0]

+ 16 - 13
src/jfw/modules/publicapply/src/bidcollection/entity/entity.go

@@ -28,7 +28,7 @@ import (
 const (
 	query          = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","subtype","s_winner","buyertel","winnertel","buyerclass","filetext"],"from":0,"size":%d}`
 	mongodb_fields = `{"_id":1,"area":1,"publishtime":1,"s_subscopeclass":1,"subtype":1,"title":1,"toptype":1,"type":1, "buyerclass":1,"budget":1,"bidamount":1,"winnertel":1,"s_winner":1,"buyertel":1,"attach_text":1}`
-	querys         = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","title","detail","area","city","publishtime","projectname","buyer","buyerclass","s_winner","bidamount","subtype","toptype","projectcode","buyertel","budget","bidopentime","agency","projectscope","winnerperson","winnertel","filetext","spidercode","site"],"from":0,"size":%d}}`
+	querys         = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","title","detail","area","city","publishtime","projectname","buyer","buyerclass","s_winner","bidamount","subtype","toptype","projectcode","buyertel","budget","bidopentime","agency","projectscope","winnerperson","winnertel","filetext","spidercode","site"],"from":0,"size":%d}`
 )
 
 var (
@@ -36,7 +36,7 @@ var (
 	insertCollKey2 = []string{"userid", "bid", "labelid", "buyerclass", "buyerinfo", "winnerinfo", "createdate"}
 )
 
-//招标信息是否被收藏 并返回标签
+// 招标信息是否被收藏 并返回标签
 func IsCollByBidsBackInfo(bids, userid string) map[string]interface{} {
 	res := map[string]interface{}{
 		"iscoll": false,
@@ -75,7 +75,7 @@ func IsCollByBidsBackInfo(bids, userid string) map[string]interface{} {
 	return res
 }
 
-//招标信息是否被收藏
+// 招标信息是否被收藏
 func IsCollByBids(bids, userid string) []string {
 	res := []string{}
 	collBidMap := map[string]bool{}
@@ -125,7 +125,7 @@ func IsCollByBids(bids, userid string) []string {
 	return res
 }
 
-//获取用户标签
+// 获取用户标签
 type LabelByUser struct {
 	Lid    string `json:"lid"`
 	Lname  string `json:"lanme"`
@@ -162,7 +162,7 @@ type BidAction struct {
 	Binfo   []BidInfo `json:"binfo"`
 }
 
-//招标信息 bid&userid 唯一
+// 招标信息 bid&userid 唯一
 type BidInfo struct {
 	Bid        string `json:"bid"`        //招标信息id 加密后
 	Buyerclass string `json:"buyerclass"` //采购单位类型
@@ -173,7 +173,7 @@ type BidInfo struct {
 	Labelid    string `json:"labelid"`    //标签ids
 }
 
-//收藏招标信息(批量收藏)|取消收藏(批量取消)
+// 收藏招标信息(批量收藏)|取消收藏(批量取消)
 func BidCollOrRemByIds(bidAction BidAction, session *httpsession.Session) map[string]interface{} {
 	var i = 0
 	ok, msg := true, ""
@@ -244,7 +244,7 @@ func BidCollOrRemByIds(bidAction BidAction, session *httpsession.Session) map[st
 	return m
 }
 
-//添加或绑定标签|删除标签
+// 添加或绑定标签|删除标签
 type LabelInfo struct {
 	Lids    string    `json:"lids"`    //标签ids
 	Lname   string    `json:"lname"`   //标签名称
@@ -252,7 +252,7 @@ type LabelInfo struct {
 	Laction string    `json:"laction"` //用户行为:S添加或绑定标签;D删除标签
 }
 
-//新增标签(并使用)|删除标签 RV0=
+// 新增标签(并使用)|删除标签 RV0=
 func LabelAction(labInfo *LabelInfo, session *httpsession.Session) map[string]interface{} {
 	userid := qu.ObjToString(session.Get("userId"))
 	ibool, ok, msg := true, true, ""
@@ -434,7 +434,7 @@ func GetCollList(c *util.CollList, session *httpsession.Session) map[string]inte
 	return rdata
 }
 
-//是否是付费用户 -bool: true:是 fasle:不是
+// 是否是付费用户 -bool: true:是 fasle:不是
 func Power(session *httpsession.Session) (bool, map[string]interface{}) {
 	isVip, isMember, isEnt, privatedata := false, false, false, false
 	vipstatus := 0
@@ -484,7 +484,7 @@ type InfoList struct {
 	Spidercode      string      `json:"spidercode"`
 }
 
-//根据id取内容
+// 根据id取内容
 func GetInfoById(Mgo_bidding mg.MongodbSim, bidding, bidding_back string, idlist []map[string]interface{}) []*InfoList {
 	var array []*InfoList
 	if len(idlist) == 0 {
@@ -502,6 +502,7 @@ func GetInfoById(Mgo_bidding mg.MongodbSim, bidding, bidding_back string, idlist
 	infos := map[string]map[string]interface{}{}
 	// log.Println("es_ids:", len(es_ids))
 	if len(es_ids) > 0 {
+		log.Println("collection es-bidding query:", fmt.Sprintf(querys, strings.Join(es_ids, `","`), len(es_ids)))
 		list := elastic.Get("bidding", "bidding", fmt.Sprintf(querys, strings.Join(es_ids, `","`), len(es_ids)))
 		if list != nil {
 			for _, v := range *list {
@@ -565,7 +566,7 @@ func GetInfoById(Mgo_bidding mg.MongodbSim, bidding, bidding_back string, idlist
 	return array
 }
 
-//列表单条信息格式化
+// 列表单条信息格式化
 func InfoFormat(p string, info *map[string]interface{}) *InfoList {
 	area := qu.ObjToString((*info)["area"])
 	if area == "A" {
@@ -679,7 +680,7 @@ func getwinnertel(company interface{}) string {
 	return ""
 }
 
-//新增标签
+// 新增标签
 func AddLab(name, userid string) map[string]interface{} {
 	m := map[string]interface{}{
 		"labid": "",
@@ -776,8 +777,10 @@ func UpdateCollListRedis(typ, userid string, list []string) bool {
 }
 
 /*
-    isColl int:	收藏条数的状态 (是否超过100条 超过:2 没超过:1)
+	isColl int:	收藏条数的状态 (是否超过100条 超过:2 没超过:1)
+
 return
+
 	[]string:收藏的id
 */
 func GetCollRedis(userid string, isColl int) []string {