|
@@ -0,0 +1,280 @@
|
|
|
+package transfer
|
|
|
+
|
|
|
+import (
|
|
|
+ "app.yhyue.com/moapp/jybase/go-xweb/httpsession"
|
|
|
+ "app.yhyue.com/moapp/jybase/go-xweb/xweb"
|
|
|
+ "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
|
|
|
+ "app.yhyue.com/moapp/jypkg/public"
|
|
|
+ "encoding/hex"
|
|
|
+ "fmt"
|
|
|
+ "jy/src/jfw/modules/publicapply/src/config"
|
|
|
+ "log"
|
|
|
+ "net/url"
|
|
|
+ "regexp"
|
|
|
+ "strings"
|
|
|
+)
|
|
|
+
|
|
|
+func init() {
|
|
|
+ xweb.AddAction(&Transfer{})
|
|
|
+}
|
|
|
+
|
|
|
+type Transfer struct {
|
|
|
+ *xweb.Action
|
|
|
+ transfer xweb.Mapper `xweb:"/transfer"`
|
|
|
+}
|
|
|
+
|
|
|
+func (this *Transfer) Transfer() error {
|
|
|
+ newUrl := func() string {
|
|
|
+ urlStr := this.GetString("url")
|
|
|
+ if urlStr == "" {
|
|
|
+ return ""
|
|
|
+ }
|
|
|
+ /*urlStr, _ = url.QueryUnescape(urlStr)*/
|
|
|
+ urlByte, _ := hex.DecodeString(urlStr)
|
|
|
+ urlStr = string(urlByte)
|
|
|
+ isWX := public.CheckWxBrowser(this.Request)
|
|
|
+ repType := "pc"
|
|
|
+ if isWX {
|
|
|
+ repType = "wx"
|
|
|
+ } else {
|
|
|
+ var mobileReg = regexp.MustCompile("(?i)(Android|Mobile|Phone)")
|
|
|
+ log.Println("11111", this.Request.UserAgent())
|
|
|
+ isApp := mobileReg.MatchString(this.Request.UserAgent())
|
|
|
+ if isApp {
|
|
|
+ repType = "app"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return UrlHandle(urlStr, repType, this.Session())
|
|
|
+ }()
|
|
|
+ if newUrl != "" {
|
|
|
+ log.Println("最近地址", newUrl)
|
|
|
+ return this.Redirect(newUrl)
|
|
|
+ }
|
|
|
+ return this.WriteBytes([]byte("请求异常"))
|
|
|
+}
|
|
|
+
|
|
|
+// 标讯
|
|
|
+var PCWXArticle = "/article/content/%s"
|
|
|
+var APPArticle = "/jyapp/article/content/%s"
|
|
|
+
|
|
|
+// 项目
|
|
|
+var PCProject = "/swordfish/page_big_pc/pro_follow_detail?sid=%s"
|
|
|
+var APPProject = "/jyapp/big/page/pro_follow_detail?sid=%s"
|
|
|
+var WXProject = "/big/wx/page/pro_follow_detail?sid=%s"
|
|
|
+var APPEntProject = "/jyapp/big/page/client_follow_detail?sid=%s&from=client"
|
|
|
+var WXEntProject = "/big/wx/page/client_follow_detail?sid=%s&from=client"
|
|
|
+
|
|
|
+// 拟在建项目
|
|
|
+var PCLandingPage = "/succbi/nzj/app/nzj.app/nzj_detail_0.spg?pid=%s"
|
|
|
+var AppLandingPage = "/jyapp/big/page/landingPage"
|
|
|
+var WXLandingPage = "/big/wx/page/landingPage"
|
|
|
+
|
|
|
+// 采购单位画像
|
|
|
+var PCBuyPortrait = "/swordfish/page_big_pc/unit_portrayal/%s"
|
|
|
+var APPBuyPortrait = "/jyapp/big/page/unit_portrayal?entName=%s"
|
|
|
+var WXBuyPortrait = "/big/wx/page/unit_portrayal?entName=%s"
|
|
|
+var PCEntBuyPortrait = "/entpc/unit_portrayal/%s"
|
|
|
+var APPEntBuyPortrait = "/jyapp/big/page/client_portrayal?type=replace&entName=%s"
|
|
|
+var WXEntBuyPortrait = "/big/wx/page/client_portrayal?entName=%s"
|
|
|
+
|
|
|
+// 企业画像
|
|
|
+var PCEntPortrait = "/swordfish/page_big_pc/ent_portrait/%s"
|
|
|
+var PCVipEntPortrait = "/swordfish/page_big_pc/svip/ent_ser_portrait/%s"
|
|
|
+var APPEntPortrait = "/jyapp/big/page/ent_portrait?eId=%s"
|
|
|
+var WXEntPortrait = "/weixin/frontPage/collection/sess/ent_portrait?eId=%s"
|
|
|
+
|
|
|
+func UrlHandle(urlStr string, repType string, u *httpsession.Session) string {
|
|
|
+ newUrl := ""
|
|
|
+ lastPath, queryMap := QueryHadle(urlStr)
|
|
|
+ if strings.Contains(urlStr, "/jyapp/article/content") {
|
|
|
+ //移动端地址
|
|
|
+ if repType == "app" {
|
|
|
+ newUrl = fmt.Sprintf(APPArticle, lastPath)
|
|
|
+ } else if repType == "wx" {
|
|
|
+ newUrl = fmt.Sprintf(PCWXArticle, lastPath)
|
|
|
+ } else {
|
|
|
+ newUrl = fmt.Sprintf(PCWXArticle, lastPath)
|
|
|
+ }
|
|
|
+ return newUrl
|
|
|
+ }
|
|
|
+ if strings.Contains(urlStr, "/article/content") {
|
|
|
+ //可能是pc或者微信地址
|
|
|
+ if repType == "app" {
|
|
|
+ newUrl = fmt.Sprintf(APPArticle, lastPath)
|
|
|
+ } else if repType == "wx" {
|
|
|
+ newUrl = fmt.Sprintf(PCWXArticle, lastPath)
|
|
|
+ } else {
|
|
|
+ newUrl = fmt.Sprintf(PCWXArticle, lastPath)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if strings.Contains(urlStr, "/pro_follow_detail") {
|
|
|
+ //移动端项目详情页
|
|
|
+ if repType == "app" {
|
|
|
+ newUrl = fmt.Sprintf(APPProject, url.QueryEscape(strings.Join(queryMap["sid"], "")))
|
|
|
+ } else if repType == "wx" {
|
|
|
+ newUrl = fmt.Sprintf(WXProject, url.QueryEscape(strings.Join(queryMap["sid"], "")))
|
|
|
+ } else {
|
|
|
+ newUrl = fmt.Sprintf(PCProject, url.QueryEscape(strings.Join(queryMap["sid"], "")))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if strings.Contains(urlStr, "/client_follow_detail") {
|
|
|
+ //商机管理项目详情页
|
|
|
+ if repType == "app" {
|
|
|
+ newUrl = fmt.Sprintf(APPEntProject, url.QueryEscape(strings.Join(queryMap["sid"], "")))
|
|
|
+ } else if repType == "wx" {
|
|
|
+ newUrl = fmt.Sprintf(WXEntProject, url.QueryEscape(strings.Join(queryMap["sid"], "")))
|
|
|
+ } else {
|
|
|
+ newUrl = fmt.Sprintf(PCProject, url.QueryEscape(strings.Join(queryMap["sid"], "")))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if strings.Contains(urlStr, "/succbi/nzj/app/nzj.app") {
|
|
|
+ //pc拟在建项目
|
|
|
+ if repType == "app" {
|
|
|
+ newUrl = AppLandingPage
|
|
|
+ } else if repType == "wx" {
|
|
|
+ newUrl = WXLandingPage
|
|
|
+ } else {
|
|
|
+ newUrl = fmt.Sprintf(PCLandingPage, url.QueryEscape(strings.Join(queryMap["pid"], "")))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if strings.Contains(urlStr, "/swordfish/page_big_pc/svip/ent_ser_portrait") || strings.Contains(urlStr, "/swordfish/page_big_pc/ent_portrait") {
|
|
|
+ //pc企业画像
|
|
|
+ Big := jy.GetBigVipUserBaseMsg(u, *config.Middleground)
|
|
|
+ if repType == "app" {
|
|
|
+ newUrl = fmt.Sprintf(APPEntPortrait, lastPath)
|
|
|
+ } else if repType == "wx" {
|
|
|
+ newUrl = fmt.Sprintf(WXEntPortrait, lastPath)
|
|
|
+ } else {
|
|
|
+ if Big.Status > 0 {
|
|
|
+ newUrl = fmt.Sprintf(PCEntPortrait, lastPath)
|
|
|
+ } else if Big.VipStatus > 0 {
|
|
|
+ newUrl = fmt.Sprintf(PCVipEntPortrait, lastPath)
|
|
|
+ } else {
|
|
|
+ newUrl = fmt.Sprintf(PCEntPortrait, lastPath)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if strings.Contains(urlStr, "/jyapp/big/page/ent_portrait") {
|
|
|
+ //移动端企业画像
|
|
|
+ //权限获取
|
|
|
+ Big := jy.GetBigVipUserBaseMsg(u, *config.Middleground)
|
|
|
+ if repType == "app" {
|
|
|
+ newUrl = fmt.Sprintf(APPEntPortrait, url.QueryEscape(strings.Join(queryMap["eId"], "")))
|
|
|
+ } else if repType == "wx" {
|
|
|
+ newUrl = fmt.Sprintf(WXEntPortrait, url.QueryEscape(strings.Join(queryMap["eId"], "")))
|
|
|
+ } else {
|
|
|
+ if Big.Status > 0 {
|
|
|
+ newUrl = fmt.Sprintf(PCEntPortrait, url.QueryEscape((strings.Join(queryMap["eId"], ""))))
|
|
|
+ } else if Big.VipStatus > 0 {
|
|
|
+ newUrl = fmt.Sprintf(PCVipEntPortrait, url.QueryEscape(strings.Join(queryMap["eId"], "")))
|
|
|
+ } else {
|
|
|
+ newUrl = fmt.Sprintf(PCEntPortrait, url.QueryEscape(strings.Join(queryMap["eId"], "")))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if strings.Contains(urlStr, "/weixin/frontPage/collection/sess/ent_portrait") {
|
|
|
+ //微信端企业画像
|
|
|
+ Big := jy.GetBigVipUserBaseMsg(u, *config.Middleground)
|
|
|
+ if repType == "app" {
|
|
|
+ newUrl = fmt.Sprintf(APPEntPortrait, url.QueryEscape(strings.Join(queryMap["eId"], "")))
|
|
|
+ } else if repType == "wx" {
|
|
|
+ newUrl = fmt.Sprintf(WXEntPortrait, url.QueryEscape(strings.Join(queryMap["eId"], "")))
|
|
|
+ } else {
|
|
|
+ if Big.Status > 0 {
|
|
|
+ newUrl = fmt.Sprintf(PCEntPortrait, url.QueryEscape(strings.Join(queryMap["eId"], "")))
|
|
|
+ } else if Big.VipStatus > 0 {
|
|
|
+ newUrl = fmt.Sprintf(PCVipEntPortrait, url.QueryEscape(strings.Join(queryMap["eId"], "")))
|
|
|
+ } else {
|
|
|
+ newUrl = fmt.Sprintf(PCEntPortrait, url.QueryEscape(strings.Join(queryMap["eId"], "")))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if strings.Contains(urlStr, "/swordfish/page_big_pc/unit_portrayal") {
|
|
|
+ //pc采购单位画像
|
|
|
+ lastPath, queryMap = NameQueryHadle(urlStr)
|
|
|
+ if repType == "app" {
|
|
|
+ newUrl = fmt.Sprintf(APPBuyPortrait, lastPath)
|
|
|
+ } else if repType == "wx" {
|
|
|
+ newUrl = fmt.Sprintf(WXBuyPortrait, lastPath)
|
|
|
+ } else {
|
|
|
+ newUrl = fmt.Sprintf(PCBuyPortrait, lastPath)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if strings.Contains(urlStr, "/jyapp/big/page/unit_portrayal") {
|
|
|
+ //移动端采购单位画像
|
|
|
+ if repType == "app" {
|
|
|
+ newUrl = fmt.Sprintf(APPBuyPortrait, url.QueryEscape(strings.Join(queryMap["entName"], "")))
|
|
|
+ } else if repType == "wx" {
|
|
|
+ newUrl = fmt.Sprintf(WXBuyPortrait, url.QueryEscape(strings.Join(queryMap["entName"], "")))
|
|
|
+ } else {
|
|
|
+ newUrl = fmt.Sprintf(PCBuyPortrait, url.QueryEscape(strings.Join(queryMap["entName"], "")))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if strings.Contains(urlStr, "/big/wx/page/unit_portrayal") {
|
|
|
+ //微信端采购单位画像
|
|
|
+ if repType == "app" {
|
|
|
+ newUrl = fmt.Sprintf(APPBuyPortrait, url.QueryEscape(strings.Join(queryMap["entName"], "")))
|
|
|
+ } else if repType == "wx" {
|
|
|
+ newUrl = fmt.Sprintf(WXBuyPortrait, url.QueryEscape(strings.Join(queryMap["entName"], "")))
|
|
|
+ } else {
|
|
|
+ newUrl = fmt.Sprintf(PCBuyPortrait, url.QueryEscape(strings.Join(queryMap["entName"], "")))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if strings.Contains(urlStr, "/entpc/unit_portrayal") {
|
|
|
+ //商机管理pc采购单位画像
|
|
|
+ lastPath, queryMap = NameQueryHadle(urlStr)
|
|
|
+ if repType == "app" {
|
|
|
+ newUrl = fmt.Sprintf(APPEntBuyPortrait, lastPath)
|
|
|
+ } else if repType == "wx" {
|
|
|
+ newUrl = fmt.Sprintf(WXEntBuyPortrait, lastPath)
|
|
|
+ } else {
|
|
|
+ newUrl = fmt.Sprintf(PCEntBuyPortrait, lastPath)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if strings.Contains(urlStr, "/jyapp/big/page/client_portrayal") {
|
|
|
+ //商机管理移动端采购单位画像
|
|
|
+ if repType == "app" {
|
|
|
+ newUrl = fmt.Sprintf(APPEntBuyPortrait, url.QueryEscape(strings.Join(queryMap["entName"], "")))
|
|
|
+ } else if repType == "wx" {
|
|
|
+ newUrl = fmt.Sprintf(WXEntBuyPortrait, url.QueryEscape(strings.Join(queryMap["entName"], "")))
|
|
|
+ } else {
|
|
|
+ newUrl = fmt.Sprintf(PCEntBuyPortrait, url.QueryEscape(strings.Join(queryMap["entName"], "")))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if strings.Contains(urlStr, "/big/wx/page/client_portrayal") {
|
|
|
+ //商机管理微信端采购单位画像
|
|
|
+ if repType == "app" {
|
|
|
+ newUrl = fmt.Sprintf(APPEntBuyPortrait, url.QueryEscape(strings.Join(queryMap["entName"], "")))
|
|
|
+ } else if repType == "wx" {
|
|
|
+ newUrl = fmt.Sprintf(WXEntBuyPortrait, url.QueryEscape(strings.Join(queryMap["entName"], "")))
|
|
|
+ } else {
|
|
|
+ newUrl = fmt.Sprintf(PCEntBuyPortrait, url.QueryEscape(strings.Join(queryMap["entName"], "")))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return newUrl
|
|
|
+}
|
|
|
+func QueryHadle(urlStr string) (string, url.Values) {
|
|
|
+ u, err := url.Parse(urlStr)
|
|
|
+ if err != nil {
|
|
|
+ return "", nil
|
|
|
+ }
|
|
|
+ pathArr := []string{}
|
|
|
+ if u.RawPath == "" {
|
|
|
+ pathArr = strings.Split(u.Path, "/")
|
|
|
+ } else {
|
|
|
+ pathArr = strings.Split(u.RawPath, "/")
|
|
|
+ }
|
|
|
+ m, _ := url.ParseQuery(u.RawQuery)
|
|
|
+ return pathArr[len(pathArr)-1], m
|
|
|
+}
|
|
|
+func NameQueryHadle(urlStr string) (string, url.Values) {
|
|
|
+ urlStr, _ = url.QueryUnescape(urlStr)
|
|
|
+ u, err := url.Parse(urlStr)
|
|
|
+ if err != nil {
|
|
|
+ return "", nil
|
|
|
+ }
|
|
|
+ pathArr := strings.Split(u.Path, "/")
|
|
|
+ m, _ := url.ParseQuery(u.RawQuery)
|
|
|
+ return pathArr[len(pathArr)-1], m
|
|
|
+}
|