|
@@ -0,0 +1,902 @@
|
|
|
|
|
+using dodohold.core;
|
|
|
|
|
+using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
+using System.Diagnostics;
|
|
|
|
|
+using System.Text.RegularExpressions;
|
|
|
|
|
+
|
|
|
|
|
+namespace molilian.core
|
|
|
|
|
+{
|
|
|
|
|
+
|
|
|
|
|
+ public class ParseDeeplinkResust
|
|
|
|
|
+ {
|
|
|
|
|
+ public bool success { get; set; } = false;
|
|
|
|
|
+ public string reason { get; set; } = string.Empty;
|
|
|
|
|
+ public string url { get; set; } = string.Empty;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ public partial class UnionParseCore
|
|
|
|
|
+ {
|
|
|
|
|
+ public static async Task<APIResult> DeeplinkTaobaoParseAsync(string content, int commerceType,
|
|
|
|
|
+ string ip = "", string oaid = "", string riskStrategy = "", int launchScene = 0,
|
|
|
|
|
+ int accountid = 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ bool other_aff = false;
|
|
|
|
|
+ AlimamaPlus alimama = null;
|
|
|
|
|
+ var result = AlimamaPlus.GetFormattedObject(content, ip, oaid);
|
|
|
|
|
+
|
|
|
|
|
+ result.riskStrategy = riskStrategy;
|
|
|
|
|
+ result.launchScene = launchScene;
|
|
|
|
|
+ result.rawContent = content;
|
|
|
|
|
+ result.parse_type = "dp";
|
|
|
|
|
+
|
|
|
|
|
+ Dictionary<string, long> swData = new();
|
|
|
|
|
+ swData.Add("StartNew", 0);
|
|
|
|
|
+ Stopwatch stopwatch = Stopwatch.StartNew();
|
|
|
|
|
+
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ var parseResult = parseTaobaoDeeplinkInput(content);
|
|
|
|
|
+ if (!parseResult.success)
|
|
|
|
|
+ {
|
|
|
|
|
+ result.channel = TkChannelEnum.tb;
|
|
|
|
|
+ result.channel_type = ChannelTypeEnum.tb;
|
|
|
|
|
+ result.link_type = LinkTypeEnum.other_aff;
|
|
|
|
|
+ result.success = false;
|
|
|
|
|
+ result.message = "放弃转链";
|
|
|
|
|
+ result.reason = parseResult.reason;
|
|
|
|
|
+ result.subCode = TkSubCodeEnum.OtherPromo;
|
|
|
|
|
+ result.accountName = string.Empty;
|
|
|
|
|
+ result.content = content;
|
|
|
|
|
+ result.deeplink_url = string.Empty;
|
|
|
|
|
+
|
|
|
|
|
+ _ = TkLogCore.ParseLogAsync(result);
|
|
|
|
|
+ return TaobaoParseOutput(result, swData, new
|
|
|
|
|
+ {
|
|
|
|
|
+ result.success,
|
|
|
|
|
+ result.commercial,
|
|
|
|
|
+ result.message,
|
|
|
|
|
+ result.content,
|
|
|
|
|
+ result.itemName,
|
|
|
|
|
+ other_aff = true,
|
|
|
|
|
+ result.deeplink_url,
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ (bool isTaobaUrl, string shortLinkurl) = AlimamaPlus.IsTaobaoUrl(parseResult.url);
|
|
|
|
|
+ if (!isTaobaUrl)
|
|
|
|
|
+ {
|
|
|
|
|
+ result.success = false;
|
|
|
|
|
+ result.channel = TkChannelEnum.tb;
|
|
|
|
|
+ result.link_type = LinkTypeEnum.unknown;
|
|
|
|
|
+ result.success = false;
|
|
|
|
|
+ result.message = "放弃转链";
|
|
|
|
|
+ result.reason = "无效商品id";
|
|
|
|
|
+
|
|
|
|
|
+ if (!result.success)
|
|
|
|
|
+ {
|
|
|
|
|
+ result.deeplink_url = string.Empty;
|
|
|
|
|
+ }
|
|
|
|
|
+ _ = TkLogCore.ParseLogAsync(result);
|
|
|
|
|
+ return TaobaoParseOutput(result, swData, new
|
|
|
|
|
+ {
|
|
|
|
|
+ result.success,
|
|
|
|
|
+ result.commercial,
|
|
|
|
|
+ result.message,
|
|
|
|
|
+ result.content,
|
|
|
|
|
+ result.itemName,
|
|
|
|
|
+ other_aff,
|
|
|
|
|
+ result.deeplink_url,
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ result.shortLinkurl = shortLinkurl;
|
|
|
|
|
+ result.deeplink_url = string.Empty;
|
|
|
|
|
+ result.content = shortLinkurl;
|
|
|
|
|
+ content = shortLinkurl;
|
|
|
|
|
+
|
|
|
|
|
+ string reason = string.Empty;
|
|
|
|
|
+
|
|
|
|
|
+ var config = TkConfigCore.Get();
|
|
|
|
|
+ var arr = config.tk_whitelist_regular.Split('\n')
|
|
|
|
|
+ .Where(line => !string.IsNullOrWhiteSpace(line))
|
|
|
|
|
+ .ToList();
|
|
|
|
|
+
|
|
|
|
|
+ var arr2 = config.tk_blacklist_regular.Split('\n')
|
|
|
|
|
+ .Where(line => !string.IsNullOrWhiteSpace(line))
|
|
|
|
|
+ .ToList();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ var arr3 = config.multi_token_regular.Split('\n')
|
|
|
|
|
+ .Where(line => !string.IsNullOrWhiteSpace(line))
|
|
|
|
|
+ .ToList();
|
|
|
|
|
+
|
|
|
|
|
+ bool is_tao_url = !string.IsNullOrEmpty(result.shortLinkurl);
|
|
|
|
|
+ bool is_tao_token = AlimamaPlus.MatchRegexes(content, arr);
|
|
|
|
|
+ bool is_other = AlimamaPlus.MatchOtherInfo(content, arr2);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //============================== 放弃转链-初步筛选1 ==============================
|
|
|
|
|
+ if (!is_tao_url && !is_tao_token || is_other)
|
|
|
|
|
+ {
|
|
|
|
|
+ //没有链接都放弃
|
|
|
|
|
+ result.success = false;
|
|
|
|
|
+ result.message = "放弃转链";
|
|
|
|
|
+ result.reason = "初步筛选1";
|
|
|
|
|
+ result.subCode = TkSubCodeEnum.Prelim1;
|
|
|
|
|
+ result.itemName = "";
|
|
|
|
|
+ result.deeplink_url = string.Empty;
|
|
|
|
|
+ _ = TkLogCore.ParseLogAsync(result);
|
|
|
|
|
+
|
|
|
|
|
+ return TaobaoParseOutput(result, swData, new
|
|
|
|
|
+ {
|
|
|
|
|
+ result.success,
|
|
|
|
|
+ result.commercial,
|
|
|
|
|
+ result.message,
|
|
|
|
|
+ result.content,
|
|
|
|
|
+ result.itemName,
|
|
|
|
|
+ other_aff,
|
|
|
|
|
+ result.deeplink_url,
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ bool is_multi_token = AlimamaPlus.MatchMultiToken(content, arr3);
|
|
|
|
|
+ //============================== 放弃转链-初步筛选1.5 ==============================
|
|
|
|
|
+ if (is_multi_token)
|
|
|
|
|
+ {
|
|
|
|
|
+ //没有链接都放弃
|
|
|
|
|
+ result.success = false;
|
|
|
|
|
+ result.message = "放弃转链";
|
|
|
|
|
+ result.reason = "初步筛选1.5";
|
|
|
|
|
+ result.subCode = TkSubCodeEnum.Prelim1_5;
|
|
|
|
|
+ result.itemName = "";
|
|
|
|
|
+ result.deeplink_url = string.Empty;
|
|
|
|
|
+ _ = TkLogCore.ParseLogAsync(result);
|
|
|
|
|
+
|
|
|
|
|
+ return TaobaoParseOutput(result, swData, new
|
|
|
|
|
+ {
|
|
|
|
|
+ result.success,
|
|
|
|
|
+ result.commercial,
|
|
|
|
|
+ result.message,
|
|
|
|
|
+ result.content,
|
|
|
|
|
+ result.itemName,
|
|
|
|
|
+ other_aff,
|
|
|
|
|
+ result.deeplink_url,
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //============================== 放弃转链-初步筛选2 ==============================
|
|
|
|
|
+ bool is_aff_link = false;
|
|
|
|
|
+ if (!string.IsNullOrEmpty(result.shortLinkurl)) is_aff_link = AlimamaPlus.IsAffLink(result.shortLinkurl);
|
|
|
|
|
+ if (!is_tao_url && is_tao_token)
|
|
|
|
|
+ {
|
|
|
|
|
+ //淘宝口令
|
|
|
|
|
+ result.success = false;
|
|
|
|
|
+ result.message = "放弃转链";
|
|
|
|
|
+ result.reason = "初步筛选2";
|
|
|
|
|
+ result.subCode = TkSubCodeEnum.Prelim2;
|
|
|
|
|
+ result.itemName = "点击打开淘宝APP";
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (!result.success)
|
|
|
|
|
+ {
|
|
|
|
|
+ result.deeplink_url = string.Empty;
|
|
|
|
|
+ }
|
|
|
|
|
+ _ = TkLogCore.ParseLogAsync(result);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //20241229 特例
|
|
|
|
|
+ //if ("bj".Equals(EndPointCore.CurrentEndPoint))
|
|
|
|
|
+ //{
|
|
|
|
|
+ // string ruleKey = $"tmp_rules2:tb:{DateTime.Now:yyyyMMdd}";
|
|
|
|
|
+ // var count = RedisHelper.Get<int>(ruleKey);
|
|
|
|
|
+ // var now = DateTime.Now;
|
|
|
|
|
+ // if (now > new DateTime(2024, 12, 19) && now <= new DateTime(2024, 12, 22) && now.Hour >= 7 && count < 1000)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // result.deeplink_url = "tbopen://m.taobao.com/tbopen/index.html?source=auto&action=ali.open.nav&module=h5&bootImage=0&afc_route=1&bc_fl_src=growth_dhh_2200803434968_100-1930985-1595034112&dpa_Inid=159503411212096&dpa_material_id=530637422585&dpa_material_type=1&dpa_source_code=12096&force_no_smb=true&h5Url=https%3A%2F%2Fs.m.taobao.com%2Fh5%3Ffrom%3Dcustoms%26g_channelSrp%3Ddhhdpa_1232552832%26dpa_material_type%3D1%26ut_sk%3Dsearch%26spm%3Da2141.mb819t211c7%26sLaunch%3D0%26sKeep%3D1%26sModuleName%3Dsearch%26spm_back_up%3Da2141.mb819t211c7%26bc_fl_src%3Dgrowth_dhh_2200803434968_100-1930985-1595034112%26dpa_Inid%3D159503411212096%26dpa_material_id%3D530637422585%26dpa_material_type%3D1%26dpa_source_code%3D12096%26force_no_smb%3Dtrue%26itemIds%3D530637422585%26slk_actid%3D100000000207%26spm%3D2014.ugdhh.2200803434968.100-1930985-1595034112%26wh_biz%3Dtm&itemIds=530637422585&slk_actid=100000000207&spm=2014.ugdhh.2200803434968.100-1930985-1595034112&wh_biz=tm";
|
|
|
|
|
+ // RedisHelper.IncrBy(ruleKey);
|
|
|
|
|
+ // RedisHelper.Expire(ruleKey, 86400 * 1);
|
|
|
|
|
+ // }
|
|
|
|
|
+ //}
|
|
|
|
|
+
|
|
|
|
|
+ other_aff = true;
|
|
|
|
|
+ return TaobaoParseOutput(result, swData, new
|
|
|
|
|
+ {
|
|
|
|
|
+ result.success,
|
|
|
|
|
+ result.commercial,
|
|
|
|
|
+ result.message,
|
|
|
|
|
+ result.content,
|
|
|
|
|
+ result.itemName,
|
|
|
|
|
+ other_aff,
|
|
|
|
|
+ result.deeplink_url,
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ if ((!is_tao_url && is_tao_token) || is_aff_link)
|
|
|
|
|
+ {
|
|
|
|
|
+ //没有短链接都放弃
|
|
|
|
|
+ result.success = false;
|
|
|
|
|
+ result.message = "放弃转链";
|
|
|
|
|
+ result.reason = "初步筛选2";
|
|
|
|
|
+ result.subCode = TkSubCodeEnum.Prelim2;
|
|
|
|
|
+ result.itemName = "点击打开淘宝APP";
|
|
|
|
|
+
|
|
|
|
|
+ if (!result.success)
|
|
|
|
|
+ {
|
|
|
|
|
+ result.deeplink_url = string.Empty;
|
|
|
|
|
+ }
|
|
|
|
|
+ _ = TkLogCore.ParseLogAsync(result);
|
|
|
|
|
+
|
|
|
|
|
+ //20241229 特例
|
|
|
|
|
+ //if ("bj".Equals(EndPointCore.CurrentEndPoint))
|
|
|
|
|
+ //{
|
|
|
|
|
+ // string ruleKey = $"tmp_rules2:tb:{DateTime.Now:yyyyMMdd}";
|
|
|
|
|
+ // var count = RedisHelper.Get<int>(ruleKey);
|
|
|
|
|
+ // var now = DateTime.Now;
|
|
|
|
|
+ // if (now > new DateTime(2024, 12, 19) && now <= new DateTime(2024, 12, 22) && now.Hour >= 7 && count < 1000)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // result.deeplink_url = "tbopen://m.taobao.com/tbopen/index.html?source=auto&action=ali.open.nav&module=h5&bootImage=0&afc_route=1&bc_fl_src=growth_dhh_2200803434968_100-1930985-1595034112&dpa_Inid=159503411212096&dpa_material_id=530637422585&dpa_material_type=1&dpa_source_code=12096&force_no_smb=true&h5Url=https%3A%2F%2Fs.m.taobao.com%2Fh5%3Ffrom%3Dcustoms%26g_channelSrp%3Ddhhdpa_1232552832%26dpa_material_type%3D1%26ut_sk%3Dsearch%26spm%3Da2141.mb819t211c7%26sLaunch%3D0%26sKeep%3D1%26sModuleName%3Dsearch%26spm_back_up%3Da2141.mb819t211c7%26bc_fl_src%3Dgrowth_dhh_2200803434968_100-1930985-1595034112%26dpa_Inid%3D159503411212096%26dpa_material_id%3D530637422585%26dpa_material_type%3D1%26dpa_source_code%3D12096%26force_no_smb%3Dtrue%26itemIds%3D530637422585%26slk_actid%3D100000000207%26spm%3D2014.ugdhh.2200803434968.100-1930985-1595034112%26wh_biz%3Dtm&itemIds=530637422585&slk_actid=100000000207&spm=2014.ugdhh.2200803434968.100-1930985-1595034112&wh_biz=tm";
|
|
|
|
|
+ // RedisHelper.IncrBy(ruleKey);
|
|
|
|
|
+ // RedisHelper.Expire(ruleKey, 86400 * 1);
|
|
|
|
|
+ // }
|
|
|
|
|
+ //}
|
|
|
|
|
+
|
|
|
|
|
+ other_aff = true;
|
|
|
|
|
+ return TaobaoParseOutput(result, swData, new
|
|
|
|
|
+ {
|
|
|
|
|
+ result.success,
|
|
|
|
|
+ result.commercial,
|
|
|
|
|
+ result.message,
|
|
|
|
|
+ result.content,
|
|
|
|
|
+ result.itemName,
|
|
|
|
|
+ other_aff,
|
|
|
|
|
+ result.deeplink_url,
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //那就初步筛选3 有tb.cn 并且有 or 手淘发现
|
|
|
|
|
+ string pattern = @"^(?!【淘宝】).*https?:\/\/m\.tb\.cn.*(?:手淘发现|手淘搜索)";
|
|
|
|
|
+ bool isMatch = Regex.IsMatch(content, pattern);
|
|
|
|
|
+ if (isMatch)
|
|
|
|
|
+ {
|
|
|
|
|
+ result.success = false;
|
|
|
|
|
+ result.message = "放弃转链";
|
|
|
|
|
+ result.reason = "初步筛选3";
|
|
|
|
|
+ result.subCode = TkSubCodeEnum.Prelim3;
|
|
|
|
|
+ result.itemName = "点击打开淘宝APP";
|
|
|
|
|
+
|
|
|
|
|
+ if (!result.success)
|
|
|
|
|
+ {
|
|
|
|
|
+ result.deeplink_url = string.Empty;
|
|
|
|
|
+ }
|
|
|
|
|
+ _ = TkLogCore.ParseLogAsync(result);
|
|
|
|
|
+
|
|
|
|
|
+ return TaobaoParseOutput(result, swData, new
|
|
|
|
|
+ {
|
|
|
|
|
+ result.success,
|
|
|
|
|
+ result.commercial,
|
|
|
|
|
+ result.message,
|
|
|
|
|
+ result.content,
|
|
|
|
|
+ result.itemName,
|
|
|
|
|
+ other_aff,
|
|
|
|
|
+ result.deeplink_url,
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ //============================== 放弃转链-地区过滤 ==============================
|
|
|
|
|
+
|
|
|
|
|
+ bool is_ignore2 = AlimamaPlus.ShouldIgnoreRequest(ip, oaid, riskStrategy, launchScene, out reason);
|
|
|
|
|
+
|
|
|
|
|
+ if (is_ignore2)
|
|
|
|
|
+ {
|
|
|
|
|
+ result.success = false;
|
|
|
|
|
+ result.message = "放弃转链";
|
|
|
|
|
+ result.itemName = "点击打开淘宝APP";
|
|
|
|
|
+ result.reason = reason;
|
|
|
|
|
+ result.subCode = TkSubCodeEnum.TrafficCtrl;
|
|
|
|
|
+
|
|
|
|
|
+ if (!result.success)
|
|
|
|
|
+ {
|
|
|
|
|
+ result.deeplink_url = string.Empty;
|
|
|
|
|
+ }
|
|
|
|
|
+ _ = TkLogCore.ParseLogAsync(result);
|
|
|
|
|
+ return TaobaoParseOutput(result, swData, new
|
|
|
|
|
+ {
|
|
|
|
|
+ result.success,
|
|
|
|
|
+ result.commercial,
|
|
|
|
|
+ result.message,
|
|
|
|
|
+ result.content,
|
|
|
|
|
+ result.itemName,
|
|
|
|
|
+ other_aff,
|
|
|
|
|
+ result.deeplink_url,
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ (bool isTaobaoUrl, string url) = AlimamaPlus.IsTaobaoUrl(content);
|
|
|
|
|
+
|
|
|
|
|
+ //============================== 放弃转链-没有匹配账号 ==============================
|
|
|
|
|
+ TkPoolDTO? account = accountid > 0 ?
|
|
|
|
|
+ await TkPoolCore.GetOneAsync(accountid) :
|
|
|
|
|
+ await TkPoolCore.GetOneAsync(TkPoolCore.TkAction.parse, isTaobaoUrl, riskStrategy, launchScene, "dp");
|
|
|
|
|
+ if (account == null)
|
|
|
|
|
+ {
|
|
|
|
|
+ result.success = false;
|
|
|
|
|
+ result.message = "放弃转链";
|
|
|
|
|
+ result.reason = "没有匹配账号";
|
|
|
|
|
+ result.subCode = TkSubCodeEnum.Other;
|
|
|
|
|
+ result.itemName = "点击打开淘宝APP";
|
|
|
|
|
+
|
|
|
|
|
+ if (!result.success)
|
|
|
|
|
+ {
|
|
|
|
|
+ result.deeplink_url = string.Empty;
|
|
|
|
|
+ }
|
|
|
|
|
+ _ = TkLogCore.ParseLogAsync(result);
|
|
|
|
|
+ return TaobaoParseOutput(result, swData, new
|
|
|
|
|
+ {
|
|
|
|
|
+ result.success,
|
|
|
|
|
+ result.commercial,
|
|
|
|
|
+ result.message,
|
|
|
|
|
+ result.content,
|
|
|
|
|
+ result.couponAmount,
|
|
|
|
|
+ result.taoToken,
|
|
|
|
|
+ result.shortLinkurl,
|
|
|
|
|
+ other_aff,
|
|
|
|
|
+ result.deeplink_url,
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ result.accountId = account.id;
|
|
|
|
|
+ result.accountName = account.company;
|
|
|
|
|
+
|
|
|
|
|
+ alimama = new AlimamaPlus(account);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ int timeout = alimama._config.rt_max;
|
|
|
|
|
+#if DEBUG
|
|
|
|
|
+ timeout = 10000;
|
|
|
|
|
+#endif
|
|
|
|
|
+ using var cts = new CancellationTokenSource();
|
|
|
|
|
+ cts.CancelAfter(timeout);
|
|
|
|
|
+
|
|
|
|
|
+ var requestTask = Task.Run(() => alimama.UnionParseAsync(ip, oaid, content, commerceType, result, isTaobaoUrl, riskStrategy, launchScene, cts.Token, swData), cts.Token);
|
|
|
|
|
+ var delayTask = Task.Delay(timeout, cts.Token);
|
|
|
|
|
+ var completedTask = await Task.WhenAny(requestTask, delayTask);
|
|
|
|
|
+ if (completedTask == requestTask)
|
|
|
|
|
+ {
|
|
|
|
|
+ result = await requestTask;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ //============================== 放弃转链-请求超时 ==============================
|
|
|
|
|
+ cts.Cancel();
|
|
|
|
|
+ result.success = false;
|
|
|
|
|
+ result.message = "放弃转链";
|
|
|
|
|
+ result.reason = "请求超时";
|
|
|
|
|
+ result.subCode = TkSubCodeEnum.Other;
|
|
|
|
|
+ result.itemName = "点击打开淘宝APP";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ result.accountName = account.company;
|
|
|
|
|
+ //result = await alimama.UnionParse2Async(content, result);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ //============================== 放弃转链-请求超时 ==============================
|
|
|
|
|
+ if (ex.Message.Contains("was canceled"))
|
|
|
|
|
+ {
|
|
|
|
|
+ result.success = false;
|
|
|
|
|
+ result.message = "放弃转链";
|
|
|
|
|
+ result.reason = "请求超时";
|
|
|
|
|
+ result.subCode = TkSubCodeEnum.Other;
|
|
|
|
|
+ result.itemName = "点击打开淘宝APP";
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ //============================== 转链接口异常 ==============================
|
|
|
|
|
+ _ = new LoggerLibrary("unionParse", "tb_error")
|
|
|
|
|
+ .Info(ip, oaid)
|
|
|
|
|
+ .Info(content)
|
|
|
|
|
+ .Info(ex.Message, ex.StackTrace)
|
|
|
|
|
+ .SaveAsync();
|
|
|
|
|
+
|
|
|
|
|
+ NotifyCore.Notify(new NifyMessage
|
|
|
|
|
+ {
|
|
|
|
|
+ message = $"【转链异常TB】\n{content}\n\n{ex.Message}\n{ex.StackTrace}",
|
|
|
|
|
+ priority = NifyMessagePriority.high,
|
|
|
|
|
+ tags = ["red_circle"]
|
|
|
|
|
+ });
|
|
|
|
|
+ result.success = false;
|
|
|
|
|
+ result.subCode = TkSubCodeEnum.Other;
|
|
|
|
|
+ result.message = "转链接口异常";
|
|
|
|
|
+ result.itemName = "点击打开淘宝APP";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!result.success)
|
|
|
|
|
+ {
|
|
|
|
|
+ result.deeplink_url = string.Empty;
|
|
|
|
|
+ }
|
|
|
|
|
+ _ = TkLogCore.ParseLogAsync(result, alimama);
|
|
|
|
|
+
|
|
|
|
|
+ switch (result.reason)
|
|
|
|
|
+ {
|
|
|
|
|
+ case "其他推广链接":
|
|
|
|
|
+ //case "排除淘口令":
|
|
|
|
|
+ case "纯口令 没链接":
|
|
|
|
|
+ other_aff = true;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return TaobaoParseOutput(result, swData, new
|
|
|
|
|
+ {
|
|
|
|
|
+ result.success,
|
|
|
|
|
+ result.commercial,
|
|
|
|
|
+ result.message,
|
|
|
|
|
+ link_type = result.link_type.ToString(),
|
|
|
|
|
+ channel = result?.channel.ToString(),
|
|
|
|
|
+ result.channel_type,
|
|
|
|
|
+ result.itemId,
|
|
|
|
|
+ result.itemName,
|
|
|
|
|
+ result.pic,
|
|
|
|
|
+ result.promotionPrice,
|
|
|
|
|
+ result.couponAmount,
|
|
|
|
|
+ result.couponEffectiveStartTime,
|
|
|
|
|
+ result?.couponEffectiveEndTime,
|
|
|
|
|
+ result.shortLinkurl,
|
|
|
|
|
+ result.deeplink_url,
|
|
|
|
|
+ result.riskStrategy,
|
|
|
|
|
+ result.launchScene,
|
|
|
|
|
+ result.content,
|
|
|
|
|
+ result.taoToken,
|
|
|
|
|
+ other_aff,
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public static async Task<APIResult> DeeplinkJdParseAsync(string content, int commerceType, string ip, string oaid,
|
|
|
|
|
+ string riskStrategy = "", int launchScene = 0,
|
|
|
|
|
+ int accountid = 0, string clickId = "", CancellationToken cancellationToken = default)
|
|
|
|
|
+ {
|
|
|
|
|
+ var config = TkConfigCore.Get();
|
|
|
|
|
+ var result = JdUnionPlus.GetFormattedObject(content, ip, oaid, clickId);
|
|
|
|
|
+
|
|
|
|
|
+ result.rawContent = content;
|
|
|
|
|
+ result.parse_type = "dp";
|
|
|
|
|
+ result.riskStrategy = riskStrategy;
|
|
|
|
|
+ result.launchScene = launchScene;
|
|
|
|
|
+ bool IfExceptional = false;
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ var parseResult = parseJdDeeplinkInput(content);
|
|
|
|
|
+
|
|
|
|
|
+ if (!parseResult.success)
|
|
|
|
|
+ {
|
|
|
|
|
+ result.channel = TkChannelEnum.jd;
|
|
|
|
|
+ result.channel_type = ChannelTypeEnum.jd;
|
|
|
|
|
+ result.link_type = LinkTypeEnum.other_aff;
|
|
|
|
|
+ result.success = false;
|
|
|
|
|
+ result.message = "放弃转链";
|
|
|
|
|
+ result.reason = parseResult.reason;
|
|
|
|
|
+ result.accountName = string.Empty;
|
|
|
|
|
+ result.content = content;
|
|
|
|
|
+ result.deeplink_url = string.Empty;
|
|
|
|
|
+
|
|
|
|
|
+ _ = TkLogCore.ParseLogAsync(result);
|
|
|
|
|
+ return JdParseOutput(result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ result.shortLinkurl = parseResult.url;
|
|
|
|
|
+ result.content = parseResult.url;
|
|
|
|
|
+ result.deeplink_url = string.Empty;
|
|
|
|
|
+ content = parseResult.url;
|
|
|
|
|
+
|
|
|
|
|
+ if (!string.IsNullOrEmpty(config.jd_blacklist_regular))
|
|
|
|
|
+ {
|
|
|
|
|
+ var blacklist = config.jd_blacklist_regular.Split('\n')
|
|
|
|
|
+ .Where(line => !string.IsNullOrWhiteSpace(line))
|
|
|
|
|
+ .ToList();
|
|
|
|
|
+ bool anyMatch = false;
|
|
|
|
|
+ foreach (string pattern in blacklist)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (Regex.IsMatch(content, pattern, RegexOptions.IgnoreCase)) anyMatch = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (anyMatch)
|
|
|
|
|
+ {
|
|
|
|
|
+ result.success = false;
|
|
|
|
|
+ result.deeplink_url = string.Empty;
|
|
|
|
|
+ result.message = "放弃转链";
|
|
|
|
|
+ result.reason = "规则排除";
|
|
|
|
|
+ _ = TkLogCore.ParseLogAsync(result);
|
|
|
|
|
+ return JdParseOutput(result);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ string out_url = null;
|
|
|
|
|
+ string itemId = null;
|
|
|
|
|
+
|
|
|
|
|
+ //============================== 放弃转链-地区过滤 ==============================
|
|
|
|
|
+ if (!TestParseCore.InWhitelist(result.ip, result.oaid) && accountid == 0 && JdUnionPlus.ShouldIgnoreRequest(config, ip, oaid, riskStrategy, launchScene, out string reason))
|
|
|
|
|
+ {
|
|
|
|
|
+ result.link_type = JdUnionPlus.GetLinkType(result.shortLinkurl, out out_url, out itemId);
|
|
|
|
|
+
|
|
|
|
|
+ result.deeplink_url = result.link_type switch
|
|
|
|
|
+ {
|
|
|
|
|
+ LinkTypeEnum.other_aff or
|
|
|
|
|
+ LinkTypeEnum.live or
|
|
|
|
|
+ LinkTypeEnum.video or
|
|
|
|
|
+ LinkTypeEnum.profile or
|
|
|
|
|
+ LinkTypeEnum.goods => JdUnionPlus.GetDefaultStyleDeeplink(result.shortLinkurl),
|
|
|
|
|
+ _ => JdUnionPlus.GetDefaultStyleDeeplink(result.shortLinkurl),
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ result.success = false;
|
|
|
|
|
+ result.message = "放弃转链";
|
|
|
|
|
+ result.reason = reason;
|
|
|
|
|
+
|
|
|
|
|
+ if (!result.success)
|
|
|
|
|
+ {
|
|
|
|
|
+ result.deeplink_url = string.Empty;
|
|
|
|
|
+ }
|
|
|
|
|
+ _ = TkLogCore.ParseLogAsync(result);
|
|
|
|
|
+ return JdParseOutput(result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ result.shortLinkurl = JdUnionPlus.GetLink(content);
|
|
|
|
|
+ result.content = result.shortLinkurl;
|
|
|
|
|
+ result.link_type = JdUnionPlus.GetLinkType(result.shortLinkurl, out out_url, out itemId);
|
|
|
|
|
+
|
|
|
|
|
+ bool is_numeric = result.shortLinkurl.Contains(itemId);
|
|
|
|
|
+
|
|
|
|
|
+ var account = accountid > 0 ? await JdPoolCore.GetOneAsync(accountid, JdPoolCore.JdAction.parse) : await JdPoolCore.GetOneAsync(JdPoolCore.JdAction.parse, riskStrategy, launchScene, is_numeric, "dp");
|
|
|
|
|
+ if (account == null)
|
|
|
|
|
+ {
|
|
|
|
|
+ result.success = false;
|
|
|
|
|
+ result.message = "放弃转链";
|
|
|
|
|
+ result.reason = "没有匹配账号";
|
|
|
|
|
+ result.deeplink_url = result.link_type switch
|
|
|
|
|
+ {
|
|
|
|
|
+ LinkTypeEnum.other_aff or LinkTypeEnum.goods => JdUnionPlus.GetDefaultStyleDeeplink(result.shortLinkurl),
|
|
|
|
|
+ _ => JdUnionPlus.GetDefaultStyleDeeplink(result.shortLinkurl),
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (!result.success)
|
|
|
|
|
+ {
|
|
|
|
|
+ result.deeplink_url = string.Empty;
|
|
|
|
|
+ }
|
|
|
|
|
+ _ = TkLogCore.ParseLogAsync(result);
|
|
|
|
|
+ return JdParseOutput(result);
|
|
|
|
|
+ }
|
|
|
|
|
+ result.accountId = account.id;
|
|
|
|
|
+ result.accountName = account.name;
|
|
|
|
|
+
|
|
|
|
|
+ var plus = new JdUnionPlus(account);
|
|
|
|
|
+
|
|
|
|
|
+ result = await plus.JdParseAsync(content, commerceType, clickId, result, cancellationToken);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (ex.Message.Contains("was canceled"))
|
|
|
|
|
+ {
|
|
|
|
|
+ result.success = false;
|
|
|
|
|
+ result.message = "放弃转链";
|
|
|
|
|
+ result.reason = "请求超时";
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ IfExceptional = true;
|
|
|
|
|
+ _ = new LoggerLibrary("unionParse", "jd_error")
|
|
|
|
|
+ .Info(ip, oaid)
|
|
|
|
|
+ .Info(content)
|
|
|
|
|
+ .Info(ex.Message, ex.StackTrace)
|
|
|
|
|
+ .SaveAsync();
|
|
|
|
|
+ NotifyCore.Notify(new NifyMessage
|
|
|
|
|
+ {
|
|
|
|
|
+ message = $"【转链异常JD】\n{content}\n\n{ex.Message}\n{ex.StackTrace}",
|
|
|
|
|
+ priority = NifyMessagePriority.high,
|
|
|
|
|
+ tags = ["red_circle"]
|
|
|
|
|
+ });
|
|
|
|
|
+ result.success = false;
|
|
|
|
|
+ result.message = "内部错误";
|
|
|
|
|
+ result.reason = "转链接口异常";
|
|
|
|
|
+ }
|
|
|
|
|
+ result.deeplink_url = result.link_type switch
|
|
|
|
|
+ {
|
|
|
|
|
+ LinkTypeEnum.other_aff or LinkTypeEnum.goods => JdUnionPlus.GetDefaultStyleDeeplink(result.shortLinkurl),
|
|
|
|
|
+ _ => JdUnionPlus.GetDefaultStyleDeeplink(result.shortLinkurl),
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!result.success)
|
|
|
|
|
+ {
|
|
|
|
|
+ result.deeplink_url = string.Empty;
|
|
|
|
|
+ }
|
|
|
|
|
+ _ = TkLogCore.ParseLogAsync(result);
|
|
|
|
|
+ return JdParseOutput(result, IfExceptional ? APIResultCodeEnum.NotAcceptable : APIResultCodeEnum.OK);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public static async Task<APIResult> DeeplinkPddParseAsync(string content, int commerceType, string ip, string oaid,
|
|
|
|
|
+ int accountid = 0, CancellationToken cancellationToken = default)
|
|
|
|
|
+ {
|
|
|
|
|
+ var result = PddUnionPlus.GetFormattedObject(content, ip, oaid);
|
|
|
|
|
+ content = content.UrlDecode();
|
|
|
|
|
+ result.rawContent = content;
|
|
|
|
|
+ result.parse_type = "dp";
|
|
|
|
|
+ bool IfExceptional = false;
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ var config = TkConfigCore.Get();
|
|
|
|
|
+
|
|
|
|
|
+ if (!string.IsNullOrEmpty(config.pdd_blacklist_regular))
|
|
|
|
|
+ {
|
|
|
|
|
+ var blacklist = config.pdd_blacklist_regular.Split('\n')
|
|
|
|
|
+ .Where(line => !string.IsNullOrWhiteSpace(line))
|
|
|
|
|
+ .ToList();
|
|
|
|
|
+ bool anyMatch = false;
|
|
|
|
|
+ foreach (string pattern in blacklist)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (Regex.IsMatch(content, pattern, RegexOptions.IgnoreCase)) anyMatch = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (anyMatch)
|
|
|
|
|
+ {
|
|
|
|
|
+ result.success = false;
|
|
|
|
|
+ result.deeplink_url = string.Empty;
|
|
|
|
|
+ result.message = "放弃转链";
|
|
|
|
|
+ result.reason = "规则排除";
|
|
|
|
|
+ _ = TkLogCore.ParseLogAsync(result);
|
|
|
|
|
+ return PddParseOutput(result);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //============================== 放弃转链-地区过滤 ==============================
|
|
|
|
|
+ if (accountid == 0 && PddUnionPlus.ShouldIgnoreRequest(config, ip, oaid, out string reason))
|
|
|
|
|
+ {
|
|
|
|
|
+ result.success = false;
|
|
|
|
|
+ result.message = "放弃转链";
|
|
|
|
|
+ result.reason = reason;
|
|
|
|
|
+ result.deeplink_url = PddUnionPlus.GetDeeplink(result.rawContent);
|
|
|
|
|
+ _ = TkLogCore.ParseLogAsync(result);
|
|
|
|
|
+ return PddParseOutput(result);
|
|
|
|
|
+ }
|
|
|
|
|
+ var account = PddPoolCore.GetOne(PddUnionWorkMode.All, accountid, "dp");
|
|
|
|
|
+ if (account == null)
|
|
|
|
|
+ {
|
|
|
|
|
+ result.success = false;
|
|
|
|
|
+ result.message = "放弃转链";
|
|
|
|
|
+ result.reason = "没有匹配账号";
|
|
|
|
|
+ result.deeplink_url = PddUnionPlus.GetDeeplink(result.rawContent);
|
|
|
|
|
+ _ = TkLogCore.ParseLogAsync(result);
|
|
|
|
|
+ return PddParseOutput(result);
|
|
|
|
|
+ }
|
|
|
|
|
+ result.accountId = account.id;
|
|
|
|
|
+ result.accountName = account.name;
|
|
|
|
|
+
|
|
|
|
|
+ var plus = new PddUnionPlus(account);
|
|
|
|
|
+
|
|
|
|
|
+ result = await plus.PddParseAsync(content, commerceType, result, cancellationToken);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (ex.Message.Contains("was canceled"))
|
|
|
|
|
+ {
|
|
|
|
|
+ result.success = false;
|
|
|
|
|
+ result.message = "放弃转链";
|
|
|
|
|
+ result.reason = "请求超时";
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ IfExceptional = true;
|
|
|
|
|
+ _ = new LoggerLibrary("unionParse", "pdd_error")
|
|
|
|
|
+ .Info(ip, oaid)
|
|
|
|
|
+ .Info(content)
|
|
|
|
|
+ .Info(ex.Message, ex.StackTrace)
|
|
|
|
|
+ .SaveAsync();
|
|
|
|
|
+ NotifyCore.Notify(new NifyMessage
|
|
|
|
|
+ {
|
|
|
|
|
+ message = $"【转链异常PDD】\n{content}\n\n{ex.Message}\n{ex.StackTrace}",
|
|
|
|
|
+ priority = NifyMessagePriority.high,
|
|
|
|
|
+ tags = ["red_circle"]
|
|
|
|
|
+ });
|
|
|
|
|
+ result.success = false;
|
|
|
|
|
+ result.message = "内部错误";
|
|
|
|
|
+ result.reason = "转链接口异常";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ _ = TkLogCore.ParseLogAsync(result);
|
|
|
|
|
+ return PddParseOutput(result, IfExceptional ? APIResultCodeEnum.NotAcceptable : APIResultCodeEnum.OK);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static ParseDeeplinkResust parseJdDeeplinkInput(string content)
|
|
|
|
|
+ {
|
|
|
|
|
+ ParseDeeplinkResust resust = new();
|
|
|
|
|
+ if (!content.StartsWith("openapp.jdmobile://"))
|
|
|
|
|
+ {
|
|
|
|
|
+ resust.success = false;
|
|
|
|
|
+ resust.reason = "不是有效DP";
|
|
|
|
|
+ return resust;
|
|
|
|
|
+ }
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ string param = content.GetContentPart("params=", "");
|
|
|
|
|
+ param = param.UrlDecode();
|
|
|
|
|
+ var root = param.Convert2JsonElement();
|
|
|
|
|
+ string category = root.Read("category", string.Empty);
|
|
|
|
|
+ string sourceType = root.Read("sourceType", string.Empty);
|
|
|
|
|
+ string skuId = root.Read("skuId", string.Empty);
|
|
|
|
|
+ string url = root.Read("url", string.Empty);
|
|
|
|
|
+ string des = root.Read("des", string.Empty);
|
|
|
|
|
+ switch (sourceType)
|
|
|
|
|
+ {
|
|
|
|
|
+ case "Item":
|
|
|
|
|
+ resust.url = $"https://item.jd.com/{skuId}.html";
|
|
|
|
|
+ resust.success = true;
|
|
|
|
|
+ return resust;
|
|
|
|
|
+ }
|
|
|
|
|
+ switch (category)
|
|
|
|
|
+ {
|
|
|
|
|
+ case "jump":
|
|
|
|
|
+ switch (des)
|
|
|
|
|
+ {
|
|
|
|
|
+ case "getCoupon":
|
|
|
|
|
+ case "union":
|
|
|
|
|
+ resust.success = false;
|
|
|
|
|
+ resust.reason = "其他推广链接";
|
|
|
|
|
+ return resust;
|
|
|
|
|
+ case "m":
|
|
|
|
|
+ resust.url = url;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "productDetail":
|
|
|
|
|
+ resust.success = true;
|
|
|
|
|
+ resust.url = $"https://item.jd.com/{skuId}.html";
|
|
|
|
|
+ return resust;
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (string.IsNullOrEmpty(url))
|
|
|
|
|
+ {
|
|
|
|
|
+ resust.success = false;
|
|
|
|
|
+ resust.reason = "未知链接";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ string utm_campaign = resust.url.GetContentPart("utm_campaign=", "&");
|
|
|
|
|
+ string utm_term = resust.url.GetContentPart("utm_term=", "&");
|
|
|
|
|
+ if (url.Contains("union-click.jd.com") || url.Contains("union-activity") ||
|
|
|
|
|
+ !string.IsNullOrEmpty(utm_campaign) || !string.IsNullOrEmpty(utm_term))
|
|
|
|
|
+ {
|
|
|
|
|
+ resust.success = false;
|
|
|
|
|
+ resust.reason = "其他推广链接";
|
|
|
|
|
+ return resust;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ resust.success = true;
|
|
|
|
|
+ return resust;
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ resust.success = false;
|
|
|
|
|
+ resust.reason = "内部错误";
|
|
|
|
|
+ return resust;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static ParseDeeplinkResust parseTaobaoDeeplinkInput(string content)
|
|
|
|
|
+ {
|
|
|
|
|
+ ParseDeeplinkResust resust = new();
|
|
|
|
|
+ if (!content.StartsWith("taobao://") && !content.StartsWith("tbopen://") && !content.StartsWith("tmall://"))
|
|
|
|
|
+ {
|
|
|
|
|
+ resust.success = false;
|
|
|
|
|
+ resust.reason = "不是有效DP";
|
|
|
|
|
+ return resust;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (content.Contains("ali_trackid="))
|
|
|
|
|
+ {
|
|
|
|
|
+ resust.success = false;
|
|
|
|
|
+ resust.reason = "其他推广链接";
|
|
|
|
|
+ return resust;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ string itemid_pattern = "(?:pc_detail\\.itemId\\.\\d+&id=|detail\\.tmall\\.com\\/item\\.htm\\?id=)(\\d+)";
|
|
|
|
|
+
|
|
|
|
|
+ var regex = new Regex(itemid_pattern);
|
|
|
|
|
+ var match = regex.Match(content);
|
|
|
|
|
+ if (match.Success)
|
|
|
|
|
+ {
|
|
|
|
|
+ string itemId = match.Groups[1].Value;
|
|
|
|
|
+ string item_url = $"https://item.taobao.com/item.htm?id={itemId}";
|
|
|
|
|
+
|
|
|
|
|
+ resust.success = true;
|
|
|
|
|
+ resust.url = item_url;
|
|
|
|
|
+ return resust;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ * tbopen://m.taobao.com/tbopen/index.html?action=ali.open.nav&module=h5&source=alimama&bc_fl_src=tunion_vipmedia_sy&h5Url=https%3A%2F%2Fs.click.taobao.com%2Ff8sLf2s
|
|
|
|
|
+ * tbopen://m.taobao.com/tbopen/index.html?h5Url=https%3A%2F%2Fmain.m.taobao.com%2Fsearch%2Findex.html%3Fspm%3Da215s.7406091.topbar.1.560c6770snz1OF%26pageType%3D3%26q%3D%25E6%2598%259F%25E8%25BF%2590%25E5%258D%25A1
|
|
|
|
|
+ *
|
|
|
|
|
+
|
|
|
|
|
+ tbopen://m.taobao.com/tbopen/index.html?h5Url=https%3A%2F%2Fmain.m.taobao.com%2Fsearch%2Findex.html%3Fspm%3Da215s.7406091.topbar.1.560c6770snz1OF%26pageType%3D3%26q%3D%25E9%25A1%25BA%25E6%2597%25BA%25E5%258D%25A1
|
|
|
|
|
+tbopen://m.taobao.com/tbopen/index.html?h5Url=https%3A%2F%2Fku.m.taobao.com%2Fmix.htm%3Fdf_sid%3D215f61a7f2d0d7006883872e0fa2df3d%26_oneId%3DBD00ECC981654638911F62B6CCF30F30C261E65C5A593BD4E4C78E7F0B05AA0B%26kn%3D521909AA62D8712AA77BD65C878A07BF59834B3D18D1D24D2C0E947EC545D6EA%26package_name%3D2%2FYVzIkqDv9cGePpY%2FRKjGIB7bMMF5twBLhjEiOCk9g%26refpid%3Dmm_26632268_153800213_74441300498%26itemid%3D646763119270%26adgroupid%3D74846357352%26catid%3D1801%26adsrc%3D2%26tk%3D1.1_rUEipiu4lQnCUAcGljdHYD4C6l8ikkERn4TzMch3-OXcoJ3I2L9ZMNENrcyuEA6d%26bc_fl_src%3Dtanx_df_74441300498_215f61a7f2d0d7006883872e0fa2df3d_0_646763119270_74846357352_74867406695_0_1_0_2_0_0_2211829026650_0_646763119270_0_0_0_0_1%26mip%3DXmhaREh7ZFVhSH13Xg%26pdiv%3Dqt3%26project_id%3D1%26ali_trackid%3D158_471853809d7b199af8af80e276b7edb9%26bxsign%3DtanTcJ_vnwBjiXMx6dXdbwNtN0NYe4Dxw8jdMFUfthOcBEBDMKekKKeyFJVBC1HN90EhBu4bnt877-6MRM7VMJfXPrwh_1B7nUf6olHer4TLXU%26slk_gid%3Dgid_er_sidebar_0%26tkSid%3D1752753038137_556550289_0.0%26tk_cps_ut%3D12%26e%3DEb2ey4TKM3Zwv7nGTZ2_-rX3DTSVrV-TdPW7X9DGPerTBdT1uMUzpLB4tW1Ia-SYSzILWu-4Ylw1xiku1Ij7RdZ9rtbmhnxUlYC60BGXgC5f6ehAkwDioKUmn1Ujh2ntIbOKDm8SGGXFqv6GieJi2KXc4rofFFSJZ6rS0GtzoCFGKDxAFeCMxblh5_iK7tdUOCg-a4qwrTN2_AL2y2LOy60-b68KW7cRvO7dXGStqJAigOjjYrz2j5MUyWjCKPHVoZD9rN1I0mU8VGta6ZddcKfRgMu9M8FAVWx6XRy23oSLkoMYS_fbzlZlGzzVHt-JtOrywR95lxHccBzKc7kLgBvZbuLTRODDNWlsmyjpbuya2Ddv0ls-v1Y0FiUPJBa3VjcpA4WsRFam6zFndQ3HZaZPpBJnnE487qeUylWc6TSX3cwyLTlAhlg4CzRoOGUPfG2M1DxYVhIM-7XZOBKdtm1-MNutVMsdVL5FrN2D3QFIHauVi2R1R4T_8p273pSzV1XCG8Ub_zp6czCzvmBAnuTHBUPfjEfH31tdnUQbdFwwPrn00QwN2w%26type%3D2%26tkFlag%3D1&bc_fl_src=tanx_df_74441300498_215f61a7f2d0d7006883872e0fa2df3d_0_646763119270_74846357352_74867406695_0_1_0_2_0_0_2211829026650_0_646763119270_0_0_0_0_1&action=ali.open.nav&module=h5&bootImage=0&slk_sid=j9H/IH/fa3kBASQJiigVFV2u_1753450292601&slk_t=1753450293764&slk_gid=gid_er_sidebar_0&afcPromotionOpen=false&ali_trackid=158_471853809d7b199af8af80e276b7edb9&source=slk_dp
|
|
|
|
|
+
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+ string url = content.GetContentPart("h5Url=", "&");
|
|
|
|
|
+ if (string.IsNullOrEmpty(url))
|
|
|
|
|
+ {
|
|
|
|
|
+ url = content.GetContentPart("h5Url=", "");
|
|
|
|
|
+ }
|
|
|
|
|
+ url = url.UrlDecode();
|
|
|
|
|
+
|
|
|
|
|
+ if (string.IsNullOrEmpty(url))
|
|
|
|
|
+ {
|
|
|
|
|
+ resust.success = false;
|
|
|
|
|
+ resust.reason = "未知链接";
|
|
|
|
|
+ return resust;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (url.Contains("s.click.taobao.com"))
|
|
|
|
|
+ {
|
|
|
|
|
+ resust.success = false;
|
|
|
|
|
+ resust.reason = "其他推广链接";
|
|
|
|
|
+ return resust;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ resust.success = false;
|
|
|
|
|
+ resust.reason = "未知链接";
|
|
|
|
|
+ return resust;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static string parseDeeplinkInput(string content)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (content.StartsWith("tbopen://") || content.StartsWith("tmall://"))
|
|
|
|
|
+ {
|
|
|
|
|
+ string url = content.GetContentPart("h5Url=", "&");
|
|
|
|
|
+ if (string.IsNullOrEmpty(url))
|
|
|
|
|
+ {
|
|
|
|
|
+ url = content.GetContentPart("h5Url=", "");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (string.IsNullOrEmpty(url)) return content;
|
|
|
|
|
+ content = url.UrlDecode();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (content.StartsWith("openapp.jdmobile://"))
|
|
|
|
|
+ {
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ string param = content.GetContentPart("params=", "");
|
|
|
|
|
+ param = param.UrlDecode();
|
|
|
|
|
+ var root = param.Convert2JsonElement();
|
|
|
|
|
+ string category = root.Read("category", string.Empty);
|
|
|
|
|
+ string sourceType = root.Read("sourceType", string.Empty);
|
|
|
|
|
+ string skuId = root.Read("skuId", string.Empty);
|
|
|
|
|
+ switch (sourceType)
|
|
|
|
|
+ {
|
|
|
|
|
+ case "Item":
|
|
|
|
|
+ string url_content = $"https://item.jd.com/{skuId}.html";
|
|
|
|
|
+ return url_content;
|
|
|
|
|
+ }
|
|
|
|
|
+ switch (category)
|
|
|
|
|
+ {
|
|
|
|
|
+ case "jump":
|
|
|
|
|
+ string url = root.Read("url", string.Empty);
|
|
|
|
|
+ string url_content = url;
|
|
|
|
|
+ return url_content;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return content;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|