temu客户端程序

This commit is contained in:
wule committed 2025-06-29 19:38:31 +08:00
commit 4aaf264e89
694 files changed
+263780

No files matched your search

+309
View File
@@ -0,0 +1,309 @@
using System;
using System.Collections.Generic;
using System.Threading;
using AllBase;
using Work.CollectClass;
namespace Work.Api
{
public class MobileDetail
{
public string Name;
public long Pid;
public long FromId = 0;
public string FromShopName = "";
public int FromSiteId = 0;
public string message_alert = string.Empty;
public MobileDetail(string name, long pid)
{
Name = name;
Pid = pid;
}
public ProductCollectBase Get()
{
if (TaobaoMobileCollect.ProductTemp.ContainsKey(Pid))
return TaobaoMobileCollect.ProductTemp[Pid];
var p = new ProductCollectBase();
string url = "http://apiv4.yangkeduo.com/v5/goods/" + Pid + "?timeout=1500&pdduid=0";
string html = GetPostTaobaoHtml.GetUrl(url, "http://apiv4.yangkeduo.com", true, "");
Thread.Sleep(3000);
if (CollectKeywordByTaobao.SaveCollect && !string.IsNullOrEmpty(html) && html.Contains("远程服务器返回错误"))
{
Thread.Sleep(6000);
html = GetHtml.ByUsa(true, url);
}
if (string.IsNullOrEmpty(html) || html.Contains("远程服务器返回错误"))
{
Thread.Sleep(5000);
TaobaoProductBase t = new TaobaoProductBase();
t.FromType = "拼多多";
t.FromId = Pid;
PinduoduoProductCollect pp = new PinduoduoProductCollect(Name, t);
pp.NoAdd = true;
pp.Get();
p = pp.pb;
return p;
}
if (string.IsNullOrEmpty(html) || html.Contains("\"success\":false"))
{
LogSave.Add(Name, "商品不存在:" + Pid);
return p;
}
if (html.Contains("远程服务器返回错误"))
{
LogSave.Add(Name, "IP临时被封请切换电脑IP:" + Pid);
return p;
}
if (BaseRegex.GetIntJson(ref html, "is_onsale") == 0)
{
LogSave.Add(Name, "商品已下架:" + Pid);
return p;
}
MobileDetailBase tp = JsonHelper.DeserializeJsonToObject<MobileDetailBase>(html);
p.name = tp.goods_name;
for (int i = 0; i < tp.gallery.Count; i++)
{
if (tp.gallery[i].type == 1)
p.Images.Add(tp.gallery[i].url);
else
p.content += "<img src=\"" + tp.gallery[i].url + "\" height=\"" + tp.gallery[i].height + "\" width=\"" + tp.gallery[i].width + "\" />";
}
if (tp.sku.Count > 0 && tp.sku[0].specs.Count == 1)
{
var spe = tp.sku[0].specs[0];
PropBase prop = new PropBase();
prop.name = spe.spec_key;
for (int i = 0; i < tp.sku.Count; i++)
{
PropValueBase pvb = new PropValueBase();
pvb.name = tp.sku[i].specs[0].spec_value;
pvb.id = tp.sku[i].spec;
pvb.name_pinduoduo = pvb.name;
pvb.image = tp.sku[i].thumb_url;
pvb.image_from_url = pvb.image;
prop.Values.Add(pvb);
SkuMapBase sku = new SkuMapBase();
sku.name = tp.sku[i].specs[0].spec_key + ":" + tp.sku[i].specs[0].spec_value;
sku.before_price = tp.sku[i].normal_price / 100m;
sku.price = tp.sku[i].group_price / 100m;
sku.number = tp.sku[i].is_onsale == 0 ? 0 : tp.sku[i].quantity;
sku.sale_count = tp.sku[i].sold_quantity;
sku.id = tp.sku[i].sku_id;
sku.pinduoduo_image = tp.sku[i].thumb_url;
sku.prop_image = tp.sku[i].thumb_url;
p.SkuMaps.Add(sku);
}
p.Props.Add(prop);
}
if (tp.sku.Count > 0 && tp.sku[0].specs.Count == 2)
{
for (int i = 0; i < tp.sku[0].specs.Count; i++)
{
PropBase prop = new PropBase();
prop.name = tp.sku[0].specs[i].spec_key;
p.Props.Add(prop);
for (int j = 0; j < tp.sku.Count; j++)
{
if (prop.Values.Exists(po => po.name == tp.sku[j].specs[i].spec_value))
continue;
PropValueBase pv = new PropValueBase();
pv.name = tp.sku[j].specs[i].spec_value;
pv.image = tp.sku[j].thumb_url;
pv.name_pinduoduo = pv.name;
pv.id = tp.sku[j].spec.Split(',')[i];
prop.Values.Add(pv);
}
}
for (int i = 0; i < tp.sku.Count; i++)
{
SkuMapBase sku = new SkuMapBase();
sku.name = tp.sku[i].specs[0].spec_key + ":" + tp.sku[i].specs[0].spec_value + ";" + tp.sku[i].specs[1].spec_key + ":" + tp.sku[i].specs[1].spec_value;
sku.before_price = tp.sku[i].normal_price / 100m;
sku.price = tp.sku[i].group_price / 100m;
sku.number = tp.sku[i].is_onsale == 0 ? 0 : tp.sku[i].quantity;
sku.sale_count = tp.sku[i].sold_quantity;
sku.id = tp.sku[i].sku_id;
sku.pinduoduo_image = tp.sku[i].thumb_url;
sku.prop_image = tp.sku[i].thumb_url;
sku.spec_pinduoduo = tp.sku[i].spec;
p.SkuMaps.Add(sku);
}
}
p.id = Pid;
p.cat1 = tp.cat_id_1;
p.cat2 = tp.cat_id_2;
p.cat3 = tp.cat_id_3;
p.cat4 = tp.cat_id == tp.cat_id_3 ? 0 : tp.cat_id;
p.cat_id = tp.cat_id;
p.from = "拼多多";
p.from_site_id = 2;
p.mall_id = tp.mall_id;
var f = new FromTitleToCat();
p.main_cid = f.GetMainCatId(p.cat1);
p.main_cat_name = f.MainCatName;
p.name_share = tp.share_desc;
p.content_pinduoduo = tp.goods_desc;
p.hd_thumb_url_pinduoduo = tp.hd_thumb_url;
p.thumb_url_pinduoduo = tp.thumb_url;
p.image = tp.image_url;
p.cost_template_id_pinduoduo = tp.cost_template_id;
p.saleCount = tp.sales;
p.from_id = FromId;
p.from_shop_name = FromShopName;
if (p.saleCount > 0 )
{
//url = BaseClass.BigDataApiUrl + "?obj=product/product";
//string json = JsonHelper.SerializeObject(p);
//string data = "&act=update&site_id=2&shop_name=" + GetHtml.UrlEncodeUtf8(p.from_shop_name) + "&json=" + GetHtml.UrlEncodeUtf8(json);
//html = GetHtml.PostUtf8(url, UserLogin.GetSignaturex() + data);
}
try
{
if (TaobaoMobileCollect.ProductTemp.Count > 1000)
{
TaobaoMobileCollect.ProductTemp.Clear();
}
TaobaoMobileCollect.ProductTemp.Add(Pid,p);
}
catch
{
}
return p;
}
public TaobaoProductBase ProductToTaobao(ProductCollectBase p)
{
TaobaoProductBase t = new TaobaoProductBase();
t.GoodsId = p.id;
t.Cat1 = p.cat1;
t.Cat2 = p.cat2;
t.Cat3 = p.cat3;
t.Cat4 = p.cat4;
t.CatId = p.cat_id;
t.FromId = p.from_id;
t.FromType = p.from;
t.MailId = p.mall_id;
t.MainCatId = p.main_cid;
t.MainCatName = p.main_cat_name;
t.Price = p.price;
t.SaleCount = p.saleCount;
t.Titlte = p.name;
return t;
}
}
public class MobileDetailBase
{
public string goods_sn = "";
public string goods_name = "";
public string goods_desc = "";
public string thumb_url = "";
public string hd_thumb_url = "";
public string country = "";
public string warehouse = "";
public string image_url = "";
public string share_desc = "";
public string skip_goods = "";
public long goods_id = 0;
public int cat_id = 0;
public int mall_id = 0;
public int market_price = 0;
public int goods_type = 0;
public int is_refundable = 0;
public int quick_refund = 0;
public int is_pre_sale = 0;
public int pre_sale_time = 0;
public int rv_image = 0;
public int rv = 0;
public int gpv = 0;
public int shipment_limit_second = 0;
public int sales = 0;
public int is_mall_rec = 0;
public int min_on_sale_group_price = 0;
public int max_on_sale_group_price = 0;
public int min_on_sale_normal_price = 0;
public int max_on_sale_normal_price = 0;
public int min_group_price = 0;
public int max_group_price = 0;
public int max_normal_price = 0;
public int min_normal_price = 0;
public int old_min_on_sale_group_price = 0;
public int old_max_on_sale_group_price = 0;
public int old_min_group_price = 0;
public int old_max_group_price = 0;
public int tag = 0;
public int cost_template_id = 0;
public int show_rec = 0;
public int app_new = 0;
public int is_home_delivery = 0;
public int second_hand = 0;
public int is_mall_dsr = 0;
public int created_at = 0;
public int quantity = 0;
public int cat_id_1 = 0;
public int cat_id_2 = 0;
public int cat_id_3 = 0;
public List<MobileDetailgalleryBase> gallery = new List<MobileDetailgalleryBase>();
public List<MobileDetailskuBase> sku = new List<MobileDetailskuBase>();
}
public class MobileDetailgalleryBase
{
public long id = 0;
public long goods_id = 0;
public int width = 0;
public int height = 0;
public int priority = 0;
public int type = 0;
public string url = "";
}
/// <summary>
/// sku
/// </summary>
public class MobileDetailskuBase
{
public long sku_id = 0;
public long goods_id = 0;
public string thumb_url = "";
public int quantity = 0;
public int limit_quantity = 0;
public int sold_quantity = 0;
public int init_quantity = 0;
public int is_onsale = 0;
public string spec = "";
public string outer_id = "";
public int normal_price = 0;
public int group_price = 0;
public int old_group_price = 0;
/// <summary>
/// 未使用
/// </summary>
public int price = 0;
/// <summary>
/// 未使用
/// </summary>
public int market_price = 0;
public List<MobileDetailspecsBase> specs = new List<MobileDetailspecsBase>();
}
/// <summary>
/// 属性
/// </summary>
public class MobileDetailspecsBase
{
/// <summary>
/// 属性名
/// </summary>
public string spec_key = "";
/// <summary>
/// 属性值
/// </summary>
public string spec_value = "";
}
}