1拼多多接口上传及相关功能(不含部分功能) 2拼多多选品
This commit is contained in:
1 parent
ff42506091
commit
07b912e9eb
37 files changed
+21117
-206
No files matched your search
@@ -0,0 +1,317 @@
|
||||
using AllBase;
|
||||
using AllBase.Model.Param.ToolsManage;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Work;
|
||||
using Work.Api;
|
||||
|
||||
namespace Work.Business.ProductMappingBLL
|
||||
{
|
||||
public class MappingVDianCacheBLL
|
||||
{
|
||||
public static List<Tuple<string, int, int,string>> GetFakeCacheVDianTitle(string productTitle, ref string mappingFrom, string tid = "")
|
||||
{
|
||||
return GetFakeCacheVDianTitleSub(productTitle, ref mappingFrom, tid);
|
||||
}
|
||||
public static void GetFakeCacheQueueVDianTitle(List<ProductMappingImportParam> prod, ref string mappingFrom, string tid = "")
|
||||
{
|
||||
GetFakeCacheVDianQueueTitleSub(prod, ref mappingFrom, tid);
|
||||
}
|
||||
|
||||
public static List<Tuple<string, int, int,string>> GetFakeCacheVDianFissionTitle(string productTitle, ref string mappingFrom, string tid = "")
|
||||
{
|
||||
return GetFakeCacheVDianTitleSub(productTitle, ref mappingFrom, tid, "get_cache_fission_title");
|
||||
}
|
||||
|
||||
public static List<Tuple<string, int, int,string>> GetFakeCacheVDianFissionTitleList(string productTitle, ref string mappingFrom)
|
||||
{
|
||||
var result = new List<Tuple<string, int, int,string>>();
|
||||
|
||||
if (string.IsNullOrEmpty(productTitle) || productTitle.Length <= 14)
|
||||
return result;
|
||||
|
||||
var title0_14 = productTitle.Substring(0, 14);
|
||||
var title0_7 = productTitle.Substring(0, 7);
|
||||
var title7_7 = productTitle.Substring(7, 7);
|
||||
var title0_5 = productTitle.Substring(0, 5);
|
||||
var title4_5 = productTitle.Substring(4, 5);
|
||||
var title8_5 = productTitle.Substring(8, 5);
|
||||
var title0_3 = productTitle.Substring(0, 3);
|
||||
var title3_3 = productTitle.Substring(3, 3);
|
||||
var title6_3 = productTitle.Substring(6, 3);
|
||||
var title9_3 = productTitle.Substring(9, 3);
|
||||
var title12_3 = productTitle.Substring(12, 3);
|
||||
string[] titleArr = new string[] { title0_14, title0_7, title7_7, title0_5, title4_5, title8_5, title0_3, title3_3, title6_3, title9_3, title12_3 };
|
||||
|
||||
var html = "";
|
||||
string url = BaseClass.BuildObjString("data_change&act=get_cache_fission_title_list");
|
||||
string data = "&data=";
|
||||
foreach (var t in titleArr)
|
||||
{
|
||||
var md5id = Md5Base.GetMd5(t).Substring(8, 16);
|
||||
data += md5id + "," + Math.Abs(BaseClass.GetLong(md5id)) % 1024 + ";";
|
||||
}
|
||||
data += "&" + UserLogin.GetSignaturex();
|
||||
// 根据商品标题查找缓存
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html))
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
|
||||
// 读取缓存成功
|
||||
if (!string.IsNullOrEmpty(html) && !html.ToLower().Contains("error"))
|
||||
{
|
||||
mappingFrom = "微店";
|
||||
var contents = BaseRegex.GetMatchRegex(html, "\"content\":\"([\\s\\S]+?)\"");
|
||||
|
||||
foreach (System.Text.RegularExpressions.Match m in contents)
|
||||
{
|
||||
var content = m.Groups[1]?.ToString();
|
||||
if (content == null)
|
||||
content = "";
|
||||
try
|
||||
{
|
||||
var tupleItems = content.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (var tupleItem in tupleItems)
|
||||
{
|
||||
var items = tupleItem.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (items.Length >= 2 && items[0].Length > 5)
|
||||
{
|
||||
try
|
||||
{
|
||||
var item1 = items[0];
|
||||
var item2 = items[1];
|
||||
var item3 = items.Length >= 3 ? items[2] : items[1];
|
||||
var item4 = items.Length >= 4 ? items[3] : "";
|
||||
result.Add(new Tuple<string, int, int,string>(item1, Convert.ToInt32(item2), Convert.ToInt32(item3),item4));
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据商品标题寻找微店商品缓存
|
||||
/// </summary>
|
||||
/// <param name="prod">导入商品</param>
|
||||
/// <param name="mappingFrom"></param>
|
||||
/// <param name="isVDian"></param>
|
||||
/// <returns></returns>
|
||||
public static List<Tuple<string, int, int,string>> GetFakeCacheVDianTitleSub(string productTitle, ref string mappingFrom, string tid = "", string act = "get_cache_title")
|
||||
{
|
||||
var result = new List<Tuple<string, int, int,string>>();
|
||||
var html = "";
|
||||
|
||||
if (string.IsNullOrEmpty(productTitle))
|
||||
return result;
|
||||
|
||||
string url = BaseClass.BuildObjString("data_change&act=" + act);
|
||||
string data = "";
|
||||
// 根据商品标题查找缓存
|
||||
if (string.IsNullOrEmpty(html) || html.ToLower().Contains("error"))
|
||||
{
|
||||
if (tid == "")
|
||||
tid = Md5Base.GetMd5(productTitle).Substring(8, 16);
|
||||
long suffix = Math.Abs(BaseClass.GetLong(tid)) % 1024;
|
||||
data = "&tid=" + tid
|
||||
+ "&suffix=" + suffix
|
||||
+ "&" + UserLogin.GetSignaturex();
|
||||
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html))
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
}
|
||||
// 读取缓存成功
|
||||
if (!string.IsNullOrEmpty(html) && !html.ToLower().Contains("error"))
|
||||
{
|
||||
mappingFrom = "微店";
|
||||
string content = BaseRegex.GetMatchRegexString(html, "\"content\":\"([\\s\\S]+?)(])\"");
|
||||
if (content != null)
|
||||
{
|
||||
content = content.Replace("\\", "") + "]";
|
||||
}
|
||||
else
|
||||
{
|
||||
content = BaseRegex.GetMatchRegexString(html, "\"content\":\"([\\s\\S]+?)\"");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var tupleItems = content.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (var tupleItem in tupleItems)
|
||||
{
|
||||
var items = tupleItem.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (items.Length >= 2 && items[0].Length > 5)
|
||||
{
|
||||
try
|
||||
{
|
||||
var item1 = items[0];
|
||||
var item2 = items[1];
|
||||
var item3 = items.Length >= 3 ? items[2] : items[1];
|
||||
var item4 = items.Length >= 4? items[3] : "";
|
||||
result.Add(new Tuple<string, int, int,string>(item1, Convert.ToInt32(item2), Convert.ToInt32(item3),item4));
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void GetFakeCacheVDianQueueTitleSub(List<ProductMappingImportParam> prods, ref string mappingFrom, string tid = "", string act = "get_cache_title")
|
||||
{
|
||||
//var result = new List<Tuple<string, int, int, string>>();
|
||||
var html = "";
|
||||
string url = BaseClass.BuildObjString("data_change&act=get_cache_title_list");
|
||||
string temp = "";
|
||||
for (int i = 0; i < prods.Count; i++)
|
||||
{
|
||||
var prod = prods[i];
|
||||
|
||||
// 根据商品标题查找缓存
|
||||
if (string.IsNullOrEmpty(html) || html.ToLower().Contains("error"))
|
||||
{
|
||||
|
||||
tid = Md5Base.GetMd5(prod.ProductTitle).Substring(8, 16);
|
||||
long suffix = Math.Abs(BaseClass.GetLong(tid)) % 1024;
|
||||
if (!string.IsNullOrEmpty(temp))
|
||||
temp += ";";
|
||||
temp += suffix + "," + tid;
|
||||
}
|
||||
}
|
||||
string data = "&tids=" + temp+ "&" + UserLogin.GetSignaturex();
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html))
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
// 读取缓存成功
|
||||
if (!string.IsNullOrEmpty(html) && !html.ToLower().Contains("error"))
|
||||
{
|
||||
var m = BaseRegex.GetMatchRegex(ref html, @"\{([^\]]+?)\}");
|
||||
for (int i = 0; i < m.Count; i++)
|
||||
{
|
||||
var result = new List<Tuple<string, int, int, string>>();
|
||||
var proStr = m[i].Groups[0].Value;
|
||||
mappingFrom = "微店";
|
||||
string title =GetHtml.UrlDecode(BaseRegex.GetStringJson(ref proStr, @"title"));
|
||||
var prod = prods.Find(s => title.Contains(s.ProductTitle));
|
||||
if (prod == null) continue;
|
||||
string content = BaseRegex.GetMatchRegexString(proStr, "\"content\":\"([\\s\\S]+?)\"");
|
||||
if (content != null)
|
||||
{
|
||||
content = content.Replace("\\", "") ;
|
||||
}
|
||||
else
|
||||
{
|
||||
content = BaseRegex.GetMatchRegexString(proStr, "\"content\":\"([\\s\\S]+?)\"");
|
||||
}
|
||||
try
|
||||
{
|
||||
var tupleItems = content.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (var tupleItem in tupleItems)
|
||||
{
|
||||
var items = tupleItem.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (items.Length >= 2 && items[0].Length > 5)
|
||||
{
|
||||
try
|
||||
{
|
||||
var item1 = items[0];
|
||||
var item2 = items[1];
|
||||
var item3 = items.Length >= 3 ? items[2] : items[1];
|
||||
var item4 = items.Length >= 4 ? items[3] : "";
|
||||
result.Add(new Tuple<string, int, int, string>(item1, Convert.ToInt32(item2), Convert.ToInt32(item3), item4));
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
UploadPinduoduoMain.goodCacheContent[long.Parse(prod.ProductId)] = result;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < prods.Count; i++)
|
||||
{
|
||||
var prod = prods[i];
|
||||
if (!UploadPinduoduoMain.goodCacheContent.ContainsKey(long.Parse(prod.ProductId)))
|
||||
{
|
||||
var result = new List<Tuple<string, int, int, string>>();
|
||||
UploadPinduoduoMain.goodCacheContent[long.Parse(prod.ProductId)] = result;
|
||||
}
|
||||
//UploadPinduoduoMain.goodCacheContent.Add(long.Parse(prod.ProductId), null);
|
||||
if(UploadPinduoduoMain.goodCacheContent[long.Parse(prod.ProductId)]== null)
|
||||
{
|
||||
var result = new List<Tuple<string, int, int, string>>();
|
||||
UploadPinduoduoMain.goodCacheContent[long.Parse(prod.ProductId)]=result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string SaveFakeCacheVDianTitle(List<Tuple<string, int, int,string>> MappingResult, string productTitle, string mappingFrom, bool isAdd = true)
|
||||
{
|
||||
var content = "";
|
||||
foreach (var item in MappingResult)
|
||||
{
|
||||
content += item.Item1 + "," + item.Item2 + "," + item.Item3 + "," + item.Item4 + ";";
|
||||
}
|
||||
|
||||
string url = BaseClass.BuildObjString("data_change&act=add_cache_title");
|
||||
//if (!isAdd)
|
||||
// url = BaseClass.BuildObjString("data_change&act=update");
|
||||
content = content.Length > 0 ? content.Trim(';') + ";" : content;
|
||||
var tid = Md5Base.GetMd5(productTitle).Substring(8, 16);
|
||||
var suffix = Math.Abs(BaseClass.GetLong(tid)) % 1024;
|
||||
string data = "&tid=" + tid
|
||||
+ "&suffix=" + suffix
|
||||
+ "&content=" + content
|
||||
+ "&title=" + HttpUtility.UrlEncode(productTitle, Encoding.UTF8)
|
||||
+ "&" + UserLogin.GetSignaturex();
|
||||
string result = GetHtml.PostUtf8(url, data);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static string SaveFakeCacheVDianFissionTitle(List<Tuple<string, int, int,string>> MappingResult, string productFissionTitle, string mappingFrom, bool isAdd = true)
|
||||
{
|
||||
var content = "";
|
||||
foreach (var item in MappingResult)
|
||||
{
|
||||
content += item.Item1 + "," + item.Item2 + "," + item.Item3 + "," + item.Item4 + ";";
|
||||
}
|
||||
content = content.Length > 0 ? content.Trim(';') + ";" : content;
|
||||
string url = BaseClass.BuildObjString("data_change&act=add_cache_fission_title");
|
||||
|
||||
var tid = Md5Base.GetMd5(productFissionTitle).Substring(8, 16);
|
||||
var suffix = Math.Abs(BaseClass.GetLong(tid)) % 1024;
|
||||
string data = "&tid=" + tid
|
||||
+ "&suffix=" + suffix
|
||||
+ "&content=" + content
|
||||
+ "&title=" + HttpUtility.UrlEncode(productFissionTitle, Encoding.UTF8)
|
||||
+ "&" + UserLogin.GetSignaturex();
|
||||
string result = GetHtml.PostUtf8(url, data);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user