diff --git a/AllBase/GetHtml.cs b/AllBase/GetHtml.cs
index d420ec4..4982ca2 100644
--- a/AllBase/GetHtml.cs
+++ b/AllBase/GetHtml.cs
@@ -1250,13 +1250,89 @@ Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrom
}
}
- ///
- /// post 数据
- ///
- ///
- ///
- ///
- public static string PostUtf8(string url, byte[] byteData)
+ public static async Task PostUtf8Async(string url, string postData, string contentType = "", int? timeOut = null)
+ {
+
+ bool isError = false;
+ string[] l = UserAgent.Split('\n');
+ reTry:
+ try
+ {
+ string codeType = "utf-8";
+ HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
+ request.UserAgent = l[new Random(Guid.NewGuid().GetHashCode()).Next(l.Length)].Trim();
+ byte[] byteData = Encoding.GetEncoding(codeType).GetBytes(postData);
+ request.Method = "POST";
+ request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
+ request.Timeout = BaseClass.TimeOut * 1000;
+ request.ReadWriteTimeout = BaseClass.TimeOut * 1000;
+ if (timeOut != null)
+ {
+ request.Timeout = timeOut.Value * 1000;
+ request.ReadWriteTimeout = timeOut.Value * 1000;
+ }
+ request.Proxy = null;
+ request.ContentType = "application/x-www-form-urlencoded; charset=" + codeType;
+ //if(BaseClass.SaLevel > 0)
+ {
+ //260306 采用GZip/deflate压缩
+ //request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate, br, zstd");
+ request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
+ }
+ if (url.StartsWith("https://openapi.jinritemai.com/"))
+ {
+ request.Headers.Add("X-USE-BOE", "1");
+ request.Headers.Add("Origin-From", "djt_prod");
+ request.Headers.Add("djt_prod", "boe_time_sku");
+ }
+ if (!string.IsNullOrEmpty(contentType))
+ {
+ request.ContentType = contentType;
+ }
+ request.ContentLength = byteData.Length;
+ request.Referer = url;
+ request.CookieContainer = new CookieContainer();
+ request.AllowAutoRedirect = false;
+ using (Stream requestStream = await request.GetRequestStreamAsync())
+ {
+ requestStream.Write(byteData, 0, byteData.Length);
+ }
+ HttpWebResponse response = (HttpWebResponse) await request.GetResponseAsync();
+
+ Stream receiveStream = response.GetResponseStream();
+ StreamReader readStream = new StreamReader(receiveStream, Encoding.GetEncoding(codeType));
+
+ //if (BaseClass.SaLevel == 0)
+ //{
+ // return readStream.ReadToEnd().Trim();
+ //}
+ //else
+ {
+ //260306 超管采用GZip/deflate压缩
+ //Thread.Sleep(50);
+ return GetProxyHtml.ReadResponse(response);
+ }
+ }
+ catch (Exception e)
+ {
+ LogSave.Add(e.ToString());
+ //if (!isError)
+ //{
+ // isError = true;
+ // goto reTry;
+ //}
+ Thread.Sleep(50);
+ return "";
+ }
+
+ }
+ ///
+ /// post 数据
+ ///
+ ///
+ ///
+ ///
+ public static string PostUtf8(string url, byte[] byteData)
{
WebClientx webClient = new WebClientx();
try
diff --git a/TEMUKJD/PDDForms/ProductSelectForms/CloudGoodsForm.cs b/TEMUKJD/PDDForms/ProductSelectForms/CloudGoodsForm.cs
index 0a3fde8..6eb5b2d 100644
--- a/TEMUKJD/PDDForms/ProductSelectForms/CloudGoodsForm.cs
+++ b/TEMUKJD/PDDForms/ProductSelectForms/CloudGoodsForm.cs
@@ -49,13 +49,21 @@ namespace TemuKJD.PDDForms.ProductSelectForms
ucSplitPage1.PageChange += UcSplitPage1_PageChange;
InitCategory();
InitBindingDataGridView();
- txt_title.Text = "连衣裙";
+
+
num_minsold.Value = 0;
num_maxsold.Value = 999;
num_minprice.Value = 0;
num_maxprice.Value = 999;
+
cb_Platform.SelectedIndex = 0;
ucSplitPage1.TotalCount = 0;
+
+
+ if (EnvironmentHelper.IsDevelopment)
+ {
+ txt_title.Text = "连衣裙";
+ }
}
@@ -301,33 +309,48 @@ namespace TemuKJD.PDDForms.ProductSelectForms
{
btnSearch_Click(obj, null);
}
- private void btnSearch_Click(object sender, EventArgs e)
+ private async void btnSearch_Click(object sender, EventArgs e)
{
- GoodsSearchRequest search = new GoodsSearchRequest();
-
- search.Platform = cb_Platform.SelectedIndex == 1 ? PlatformType.PDD : cb_Platform.SelectedIndex == 2 ? PlatformType.WX : PlatformType.None;
- search.Title = txt_title.Text;
- search.MinSoldQuantity = (int)num_minsold.Value;
- search.MaxSoldQuantity = (int)num_maxsold.Value;
- search.MinPrice = (long)num_minprice.Value * 100;
- search.MaxPrice = (long)num_maxprice.Value * 100;
- if (cmbCatSelect1.SelectedItem is PddCatInfo cat1)
+ try
{
- search.CatId1 = (int)(cat1.cat_id);
- search.CatId1 = search.CatId1 == 0 ? null : search.CatId1;
+ this.pbLoading.Visible = true;
+ btnSearch.Enabled = false;
+
+ GoodsSearchRequest search = new GoodsSearchRequest();
+
+ search.Platform = cb_Platform.SelectedIndex == 1 ? PlatformType.PDD : cb_Platform.SelectedIndex == 2 ? PlatformType.WX : PlatformType.None;
+ search.Title = txt_title.Text;
+ search.MinSoldQuantity = (int)num_minsold.Value;
+ search.MaxSoldQuantity = (int)num_maxsold.Value;
+ search.MinPrice = (long)num_minprice.Value * 100;
+ search.MaxPrice = (long)num_maxprice.Value * 100;
+ if (cmbCatSelect1.SelectedItem is PddCatInfo cat1)
+ {
+ search.CatId1 = (int)(cat1.cat_id);
+ search.CatId1 = search.CatId1 == 0 ? null : search.CatId1;
+ }
+ if (cmbCatSelect2.SelectedItem is PddCatInfo cat2)
+ search.CatId2 = (int)(cat2.cat_id);
+ if (cmbCatSelect3.SelectedItem is PddCatInfo cat3)
+ search.CatId3 = (int)(cat3.cat_id);
+ if (cmbCatSelect4.SelectedItem is PddCatInfo cat4)
+ search.CatId4 = (int)(cat4.cat_id);
+ search.PageIndex = ucSplitPage1.CurrentPage;
+ search.PageSize = ucSplitPage1.PageSize;
+
+
+
+ GetGoods(search);
+ }
+ catch (Exception ex)
+ {
+ BaseMsgForm.ShowError($"查询失败:{ex.Message}");
+ }
+ finally
+ {
+ this.pbLoading.Visible = false;
+ btnSearch.Enabled = true;
}
- if (cmbCatSelect2.SelectedItem is PddCatInfo cat2)
- search.CatId2 = (int)(cat2.cat_id);
- if (cmbCatSelect3.SelectedItem is PddCatInfo cat3)
- search.CatId3 = (int)(cat3.cat_id);
- if (cmbCatSelect4.SelectedItem is PddCatInfo cat4)
- search.CatId4 = (int)(cat4.cat_id);
- search.PageIndex = ucSplitPage1.CurrentPage;
- search.PageSize = ucSplitPage1.PageSize;
-
-
-
- GetGoods(search);
}
@@ -346,24 +369,20 @@ namespace TemuKJD.PDDForms.ProductSelectForms
}
- public void GetGoods(GoodsSearchRequest request)
+ public async void GetGoods(GoodsSearchRequest request)
{
- this.pbLoading.Visible = true;
dataList.Clear();
- Task.Run(() =>
+ PageData ret = await CloudGoodsService.GetGoods(request);
+ Invoke(new Action(() =>
{
- PageData ret = CloudGoodsService.GetGoods(request);
- Invoke(new Action(() =>
- {
- ret.List.ForEach(a => dataList.Add(a));
- ucSplitPage1.TotalPage = Math.Max(1, ret.TotalPages);
- ucSplitPage1.TotalCount = ret.Total;
- this.pbLoading.Visible = false;
- // 异步加载商品缩略图(Column1 绑定 ThumbUrl)
- ShowDgvImg();
- }));
- });
+ ret.List.ForEach(a => dataList.Add(a));
+ ucSplitPage1.TotalPage = Math.Max(1, ret.TotalPages);
+ ucSplitPage1.TotalCount = ret.Total;
+ this.pbLoading.Visible = false;
+ // 异步加载商品缩略图(Column1 绑定 ThumbUrl)
+ ShowDgvImg();
+ }));
}
@@ -377,32 +396,43 @@ namespace TemuKJD.PDDForms.ProductSelectForms
///
private void bt_importUploadList_Click(object sender, EventArgs e)
{
+ int succ = 0;
+ int err = 0;
foreach (var item in dataList)
{
- if (item.IsSelected == false) continue;
- string catName = "";
- if (item.CatId4.HasValue)
+ try
{
- catName = GlobalConfig.PddCatList.FirstOrDefault(a => a.cat_id == item.CatId4)?.cat_name ?? "";
+ if (item.IsSelected == false) continue;
+ string catName = "";
+ if (item.CatId4.HasValue)
+ {
+ catName = GlobalConfig.PddCatList.FirstOrDefault(a => a.cat_id == item.CatId4)?.cat_name ?? "";
+ }
+ else if (item.CatId3.HasValue)
+ {
+ catName = GlobalConfig.PddCatList.FirstOrDefault(a => a.cat_id == item.CatId3)?.cat_name ?? "";
+ }
+ else if (item.CatId2.HasValue)
+ {
+ catName = GlobalConfig.PddCatList.FirstOrDefault(a => a.cat_id == item.CatId2)?.cat_name ?? "";
+ }
+ WXDBProdUploadForm.Instance.lstTemuDBProductSelect.Add(new TemuDBProductSelect
+ {
+ out_product_Id = item.GoodsId.ToString(),
+ spu_id = item.GoodsId.ToString(),
+ main_img = item.ThumbUrl,
+ product_name = item.Title,
+ cat_name = catName,
+ });
+ succ++;
}
- else if (item.CatId3.HasValue)
+ catch
{
- catName = GlobalConfig.PddCatList.FirstOrDefault(a => a.cat_id == item.CatId3)?.cat_name ?? "";
+ err++;
}
- else if (item.CatId2.HasValue)
- {
- catName = GlobalConfig.PddCatList.FirstOrDefault(a => a.cat_id == item.CatId2)?.cat_name ?? "";
- }
- WXDBProdUploadForm.Instance.lstTemuDBProductSelect.Add(new TemuDBProductSelect
- {
- out_product_Id = item.GoodsId.ToString(),
- spu_id = item.GoodsId.ToString(),
- main_img = item.ThumbUrl,
- product_name = item.Title,
- cat_name = catName,
- });
}
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_db_prod_upload_list", WXDBProdUploadForm.Instance.lstTemuDBProductSelect);
+ BaseMsgForm.ShowInfo($"导入完成!{succ} 成功 {err} 失败");
}
}
diff --git a/TEMUKJD/WXForms/ProductForms/WXProductForm.Designer.cs b/TEMUKJD/WXForms/ProductForms/WXProductForm.Designer.cs
index 665ae77..ab71ece 100644
--- a/TEMUKJD/WXForms/ProductForms/WXProductForm.Designer.cs
+++ b/TEMUKJD/WXForms/ProductForms/WXProductForm.Designer.cs
@@ -29,7 +29,7 @@
private void InitializeComponent()
{
System.Windows.Forms.TreeNode treeNode1 = new System.Windows.Forms.TreeNode("选品上传");
- System.Windows.Forms.TreeNode treeNode2 = new System.Windows.Forms.TreeNode("云仓数据");
+ System.Windows.Forms.TreeNode treeNode2 = new System.Windows.Forms.TreeNode("云端数据");
System.Windows.Forms.TreeNode treeNode3 = new System.Windows.Forms.TreeNode("我的商品库");
System.Windows.Forms.TreeNode treeNode4 = new System.Windows.Forms.TreeNode("商品预售/下架");
System.Windows.Forms.TreeNode treeNode5 = new System.Windows.Forms.TreeNode("云仓退货地址");
@@ -149,8 +149,8 @@
this.tv.Name = "tv";
treeNode1.Name = "选品上传";
treeNode1.Text = "选品上传";
- treeNode2.Name = "云仓数据";
- treeNode2.Text = "云仓数据";
+ treeNode2.Name = "云端数据";
+ treeNode2.Text = "云端数据";
treeNode3.Name = "我的商品库";
treeNode3.Text = "我的商品库";
treeNode4.Name = "商品预售/下架";
diff --git a/TEMUKJD/WXForms/ProductForms/WXProductForm.cs b/TEMUKJD/WXForms/ProductForms/WXProductForm.cs
index 84ba5c4..76b93ea 100644
--- a/TEMUKJD/WXForms/ProductForms/WXProductForm.cs
+++ b/TEMUKJD/WXForms/ProductForms/WXProductForm.cs
@@ -98,7 +98,7 @@ namespace TemuKJD.WXForms.ProductForms
case "选品上传":
SetForm(userSelectDbProductForm.Value);
break;
- case "云仓数据":
+ case "云端数据":
SetForm(cloudgoodsForm.Value);
break;
case "我的商品库":
diff --git a/Work/Services/CloudGoodsService.cs b/Work/Services/CloudGoodsService.cs
index 4120915..8079bd6 100644
--- a/Work/Services/CloudGoodsService.cs
+++ b/Work/Services/CloudGoodsService.cs
@@ -15,10 +15,10 @@ namespace Work.Services
public class CloudGoodsService
{
private const string ServerUrl = "http://119.45.4.202:14312";
- public static PageData GetGoods(GoodsSearchRequest request)
+ public static async Task> GetGoods(GoodsSearchRequest request)
{
string data = JsonHelper.SerializeObject(request);
- var html = GetHtml.PostUtf8(ServerUrl + "/Goods/SearchGoods", data, "application/json");
+ var html = await GetHtml.PostUtf8Async(ServerUrl + "/Goods/SearchGoods", data, "application/json");
var ret = JsonConvert.DeserializeObject>>(html);
if (ret.Code != 200)