111 lines
3.6 KiB
C#
111 lines
3.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using AllBase;
|
|
|
|
namespace Work.Api
|
|
{
|
|
public class GetProductDetail
|
|
{
|
|
public ShopChatBase Shop;
|
|
public string Html = "";
|
|
public string Name;
|
|
public GetProductDetail(ShopChatBase shop, string name)
|
|
{
|
|
Shop = shop;
|
|
}
|
|
|
|
public ProductDetailBase Get(long pid)
|
|
{
|
|
try
|
|
{
|
|
PinduoduoApiGetProduct api = new PinduoduoApiGetProduct(Shop);
|
|
Html = api.GetProduct(pid);
|
|
if (string.IsNullOrEmpty(Html) || !Html.Contains("\"goods_id\""))
|
|
{
|
|
System.Threading.Thread.Sleep(1000 + Randomx.GetId(1000));
|
|
Html = api.GetProduct(pid);
|
|
}
|
|
if (string.IsNullOrEmpty(Html) || !Html.Contains("\"goods_id\""))
|
|
{
|
|
LogSave.Add(Name, "商品不存在:" + pid);
|
|
return null;
|
|
}
|
|
Html = Html.Replace("\"shelf_life\":null", "\"shelf_life\":0");
|
|
Html = Html.Replace("\"start_production_date\":null", "\"start_production_date\":0");
|
|
Html = Html.Replace("\"end_production_date\":null", "\"end_production_date\":0");
|
|
ProductDetailBasex tp = JsonHelper.DeserializeJsonToObject<ProductDetailBasex>(Html);
|
|
return tp.goods_detail_get_response;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
LogSave.Add(Name, "构建数据错误:" + e.Message);
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
public class ProductDetailBasex
|
|
{
|
|
public ProductDetailBase goods_detail_get_response;
|
|
}
|
|
|
|
public class ProductDetailBase
|
|
{
|
|
public long goods_id;
|
|
public int buy_limit;
|
|
//public string mai_jia_zi_ti;
|
|
public List<string> carousel_gallery_list = new List<string>();
|
|
public int cat_id;
|
|
public long cost_template_id;
|
|
public int shelf_life;
|
|
public int start_production_date;
|
|
public int end_production_date;
|
|
//public int paper_net_weight;
|
|
//public int paper_length;
|
|
//public int paper_width;
|
|
//public int paper_plies_num;
|
|
public int country_id;
|
|
public int customer_num;
|
|
public int goods_type;
|
|
public string goods_name;
|
|
public string tiny_name;
|
|
public string goods_desc;
|
|
public string warehouse;
|
|
public int is_customs;
|
|
public string customs;
|
|
public int market_price;
|
|
public int is_pre_sale;
|
|
public int pre_sale_time;
|
|
public int shipment_limit_second;
|
|
public int order_limit;
|
|
public int is_refundable;
|
|
public int? second_hand;
|
|
public int is_folt;
|
|
public string warm_tips;
|
|
public string outer_goods_id;
|
|
public int fabricx;
|
|
public int fabric_contentx;
|
|
//public int fabric_id;
|
|
//public int fabric_content_id;
|
|
public int mall_id;
|
|
public List<string> list_desc = new List<string>();
|
|
public List<GoodsPropertyListBase> goods_property_list = new List<GoodsPropertyListBase>();
|
|
public string thumb_url;
|
|
public string image_url;
|
|
public string hd_thumb_url;
|
|
public List<string> galleries;
|
|
public List<SkuDetailBase> sku_list;
|
|
public List<string> detail_gallery_list;
|
|
}
|
|
|
|
public class GoodsPropertyListBase
|
|
{
|
|
public long ref_pid;
|
|
public long template_pid;
|
|
public string vvalue;
|
|
public string vid;
|
|
public string punit;
|
|
}
|
|
|
|
}
|