From 28267e58e4ad19bc6027c12daffc4c4313cb9592 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Tue, 2 Apr 2024 14:55:42 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AC=E9=93=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chain_transfer/svc/svc_turnchain.go | 87 ++++++++++++++++++++--------- md/url.go | 3 + taobao/convert_url.go | 6 +- 3 files changed, 66 insertions(+), 30 deletions(-) diff --git a/chain_transfer/svc/svc_turnchain.go b/chain_transfer/svc/svc_turnchain.go index 6b0745d..469c198 100644 --- a/chain_transfer/svc/svc_turnchain.go +++ b/chain_transfer/svc/svc_turnchain.go @@ -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 } diff --git a/md/url.go b/md/url.go index a6f5524..1f89265 100644 --- a/md/url.go +++ b/md/url.go @@ -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"` diff --git a/taobao/convert_url.go b/taobao/convert_url.go index 23abf5d..81696c2 100644 --- a/taobao/convert_url.go +++ b/taobao/convert_url.go @@ -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,