Browse Source

转链

master
huangjiajun 8 months ago
parent
commit
28267e58e4
3 changed files with 66 additions and 30 deletions
  1. +62
    -25
      chain_transfer/svc/svc_turnchain.go
  2. +3
    -0
      md/url.go
  3. +1
    -5
      taobao/convert_url.go

+ 62
- 25
chain_transfer/svc/svc_turnchain.go View File

@@ -17,6 +17,7 @@ import (
"errors"
"fmt"
"github.com/jinzhu/copier"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
"math/rand"
"regexp"
@@ -485,20 +486,47 @@ func TikTokUrl(eg *xorm.Engine, dbName string, gid, activityId string) string {
}
return url
}
func CheckTaobaoWordGetTkl(eg *xorm.Engine, dbName string, s string, args map[string]string) (string, string) {
func CheckTaobaoWordGetTkl(eg *xorm.Engine, dbName string, s string, args map[string]string) (string, string, string) {
taobaoSdk, _ := taobao.NewTaobaoSDK(eg, dbName, args["platfrom"], zhios_third_party_utils.StrToInt(args["acc_taobao_share_id"]), args["union_id"])
if taobaoSdk == nil {
return "", ""
return "", "", ""
}
urls, _ := taobaoSdk.WnConvertUrlSC(s, "2", taobaoSdk.SelfPromoIdWeb, args["acc_taobao_share_id"])
if urls == nil {
return "", ""
if strings.Contains(s, "taobao.com") || strings.Contains(s, "tmall.com") {
bizSceneId := ""
url := strings.ReplaceAll(s, "?", "&") + "&"
split := strings.Split(url, "&id=")
if len(split) == 2 {
split1 := strings.Split(split[1], "&")
if len(split1) > 0 {
goodsId := split1[0]
if php2go.IsNumeric(goodsId) {
bizSceneId = "2"
}
}
}
s1 := s
itemInfo, err := taobaoSdk.ItemDetailByLink(s1, bizSceneId)
if itemInfo == nil || err != nil {
return "", "", ""
}
return "", zhios_third_party_utils.AnyToString(itemInfo.ItemID), ""
}
// 查无数据
if urls.TaoBaoWord == "" {
return "", ""

urls, _ := taobaoSdk.WnConvertUrlSC(s, "2", taobaoSdk.CloudPromoIdWeb, args["acc_taobao_share_id"])
if urls != nil {
if urls.IsDown == "2" {
return "", "", ""
}
taokou := &md.TaobaoWord{
Text: urls.Tkl,
Code: urls.ShortTkl,
}
urls.TaoBaoWord = WordDeal(eg, args["master_id"], taokou)
}
if urls != nil {
return urls.TaoBaoWord, urls.ItemId, urls.IsDown
}
return urls.TaoBaoWord, urls.ItemId
return "", "", ""
}

// 淘口令
@@ -787,19 +815,22 @@ func FindTaobaoWord(eg *xorm.Engine, officialEg *xorm.Engine, tmp map[string]str
split1 := regexp.MustCompile("[a-zA-Z0-9]{6,15} [a-zA-Z0-9]{6,15}").FindAllString(reqCount, -1)

if len(split1) > 0 || strings.Contains(reqCount, "tb.cn") {
tkl, ItemId := CheckTaobaoWordGetTkl(eg, dbName, reqCount, goodsParam)
if tkl != "" {
return md.PVD_TB, ItemId, tkl, ""
tkl, ItemId, isDown := CheckTaobaoWordGetTkl(eg, dbName, reqCount, goodsParam)
pvds := md.PVD_TB
if isDown == "1" {
pvds = ""
}
return pvds, ItemId, tkl, ""
}
//判断是不是有淘宝链接
if strings.Count(reqCount, "€") >= 1 || strings.Contains(reqCount, "tb.cn") {

ItemId := CheckTaobaoWordGetId(eg, dbName, reqCount, goodsParam)
if ItemId != "" {
return md.PVD_TB, ItemId, "", ""
tkl, ItemId, isDown := CheckTaobaoWordGetTkl(eg, dbName, reqCount, goodsParam)
pvds := md.PVD_TB
if isDown == "1" {
pvds = ""
}
return pvds, ItemId, tkl, ""
}
//split_letter := regexp.MustCompile("[a-zA-Z]{8,15}").FindAllString(reqCount, -1)
if split != nil && ((zhios_third_party_utils.IsChineseChar(reqCount) && strings.Contains(reqCount, "http")) || strings.Contains(reqCount, "http") == false) {
@@ -812,10 +843,12 @@ func FindTaobaoWord(eg *xorm.Engine, officialEg *xorm.Engine, tmp map[string]str
}

if is_tkl == 1 {
taobaoWord := CheckTaobaoWordGetId(eg, dbName, reqCount, goodsParam)
if taobaoWord != "" {
return md.PVD_TB, taobaoWord, tklWord, ""
tkl, ItemId, isDown := CheckTaobaoWordGetTkl(eg, dbName, reqCount, goodsParam)
pvds := md.PVD_TB
if isDown == "1" {
pvds = ""
}
return pvds, ItemId, tkl, ""
}
}
if strings.Contains(reqCount, "http") == false {
@@ -838,16 +871,20 @@ func FindTaobaoWord(eg *xorm.Engine, officialEg *xorm.Engine, tmp map[string]str
}
}
if strings.Contains(strings.ToLower(reqCount), "taobao.com") || strings.Contains(strings.ToLower(reqCount), "tmall.com") {
taobaoWord := CheckTaobao(eg, officialEg, dbName, reqCount, goodsParam)
if taobaoWord != nil {
return md.PVD_TB, taobaoWord.ItemId, "", ""
tkl, ItemId, isDown := CheckTaobaoWordGetTkl(eg, dbName, reqCount, goodsParam)
pvds := md.PVD_TB
if isDown == "1" {
pvds = ""
}
return pvds, ItemId, tkl, ""
}
if strings.Contains(reqCount, "s.click.Taobao") {
taobaoWord := CheckTaobao(eg, officialEg, dbName, reqCount, goodsParam)
if taobaoWord != nil {
return md.PVD_TB, taobaoWord.ItemId, "", ""
tkl, ItemId, isDown := CheckTaobaoWordGetTkl(eg, dbName, reqCount, goodsParam)
pvds := md.PVD_TB
if isDown == "1" {
pvds = ""
}
return pvds, ItemId, tkl, ""
}
return
}


+ 3
- 0
md/url.go View File

@@ -8,6 +8,9 @@ type ExtraData struct {

// 转链后链接
type ConvertedUrls struct {
StopStr string `json:"stop_str"`
IsStop string `json:"is_stop"`
IsDown string `json:"is_down"`
Tkl string `json:"tkl"`
ShortTkl string `json:"short_tkl"`
ItemId string `json:"item_id"`


+ 1
- 5
taobao/convert_url.go View File

@@ -274,12 +274,8 @@ func (t *TB) WnConvertUrlSC(itemId, types, pid, externalId string) (*md.Converte
if strings.Contains(string(resp), "该商品已下架") {
isDown = "1"
}
if isDown == "1" {
tkl = ""
shortTkl = ""
itemId = ""
}
return &md.ConvertedUrls{
IsDown: isDown,
Tkl: tkl,
ShortTkl: shortTkl,
ItemId: itemId,


Loading…
Cancel
Save