部分功能优化

This commit is contained in:
wule committed 2026-02-11 18:05:45 +08:00
1 parent 60ed59fc05
commit 5eea769672
10 files changed
+443 -96

No files matched your search

@@ -1766,6 +1766,26 @@ namespace TemuKJD.WXForms.ProductForms
}
#endregion
#region 保存缓存盗链图片
if (isChangeImgDic)
{
var url = BaseClass.BuildObjString("product/mdy_pdd_product");
var data = "";
Invoke(new Action(() =>
{
data = UserLogin.GetSignaturex();
data += "&spu_id=" + dbProd.spu_id;
data += "&wx_img_map_json=" + JsonHelper.SerializeObject(wxImgMapDic);
}));
var html = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
html = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
html = GetHtml.PostUtf8(url, data);
isChangeImgDic = false;
}
#endregion
#region 识别类目
if (cell != null)
{
@@ -2326,6 +2346,26 @@ namespace TemuKJD.WXForms.ProductForms
}
#endregion
#region 保存缓存盗链图片
if (isChangeImgDic)
{
var url = BaseClass.BuildObjString("product/mdy_pdd_product");
var data = "";
Invoke(new Action(() =>
{
data = UserLogin.GetSignaturex();
data += "&spu_id=" + dbProd.spu_id;
data += "&wx_img_map_json=" + JsonHelper.SerializeObject(wxImgMapDic);
}));
var html = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
html = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
html = GetHtml.PostUtf8(url, data);
isChangeImgDic = false;
}
#endregion
#region 匹配产品属性
//真丝、蚕丝、香云纱、羊绒、羊毛、羊羔毛、羽绒、皮草
upProdParam.product.info.param = new List<propParam>(); // 商品属性值
@@ -2714,6 +2754,26 @@ namespace TemuKJD.WXForms.ProductForms
}
#endregion
#region 保存缓存盗链图片
if (isChangeImgDic)
{
var url = BaseClass.BuildObjString("product/mdy_pdd_product");
var data = "";
Invoke(new Action(() =>
{
data = UserLogin.GetSignaturex();
data += "&spu_id=" + dbProd.spu_id;
data += "&wx_img_map_json=" + JsonHelper.SerializeObject(wxImgMapDic);
}));
var html = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
html = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
html = GetHtml.PostUtf8(url, data);
isChangeImgDic = false;
}
#endregion
#region sku信息
upProdParam.product.productSkus = new List<productSkuParam>();
int skuIndex = 0;
@@ -2941,7 +3001,7 @@ namespace TemuKJD.WXForms.ProductForms
}));
}
#region 草稿保存成功,保存缓存盗链图片
#region 保存缓存盗链图片
if (isChangeImgDic)
{
var url = BaseClass.BuildObjString("product/mdy_pdd_product");
@@ -2957,6 +3017,7 @@ namespace TemuKJD.WXForms.ProductForms
html = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
html = GetHtml.PostUtf8(url, data);
isChangeImgDic = false;
}
#endregion
@@ -3286,17 +3347,36 @@ namespace TemuKJD.WXForms.ProductForms
private void btnRandomAdd_Click(object sender, EventArgs e)
{
btnRandomAdd.Enabled = false;
pbSelectProd.Visible = true;
Task.Run(() =>
{
Thread.Sleep(5000);
Invoke(new Action(() =>
{
btnRandomAdd.Enabled = true;
}));
});
int addCount = txtAddCount.Text.Trim().ParseToInt();
Task.Run(() =>
{
List<KJDDBProduct> prodLst = new List<KJDDBProduct>();
int index = 0;
while (addCount > 0)
{
index++;
int prodCount = 0;
// 如果产品数量在0到50之间,说明数据库商品数量不足,无需再重复筛选,直接随机打乱
if (prodLst.Count == 0 || prodLst.Count == Math.Min(50, addCount))
{
prodLst = GetRandomProductList(out prodCount, 1, Math.Min(50, addCount));
if (index > 1 && prodCount > 0)
{
prodLst = GetRandomProductList(out prodCount, 1, Math.Min(50, addCount), true, prodCount);
}
else
{
prodLst = GetRandomProductList(out prodCount, 1, Math.Min(50, addCount));
}
Thread.Sleep(Randomx.GetId(50, 100));
}
else
@@ -3329,10 +3409,15 @@ namespace TemuKJD.WXForms.ProductForms
}
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_db_prod_upload_list", this.lstTemuDBProductSelect);
}
Invoke(new Action(() =>
{
pbSelectProd.Visible = false;
}));
});
}
public List<KJDDBProduct> GetRandomProductList(out int totalCount, int page = 1, int pageSize = 50)
public List<KJDDBProduct> GetRandomProductList(out int totalCount, int page = 1, int pageSize = 50, bool isNotCount = false, int totalProdCount = 0)
{
var lstShopId = dgvShop.Rows.Cast<DataGridViewRow>().Where(row
=> row.Cells["colSelect"]?.Value.ParseToBool() == true).Select(r => r.Cells["colShopId"]?.Value.ToString()).ToList();
@@ -3348,6 +3433,11 @@ namespace TemuKJD.WXForms.ProductForms
data = UserLogin.GetSignaturex() +
"&page=" + 1 +
"&page_size=" + pageSize;
if (isNotCount)
{
data += "&is_not_count=" + true;
data += "&prod_count=" + totalProdCount;
}
data += "&in_ext_codes=" + txtExtCodeFilter.Text;
data += "&in_spu_ids=" + txtIdFilter.Text;
data += "&in_groups=" + cmbGroupFilter.Text;