微信商品上传货号extcode优化 产品数据库查询逻辑优化

This commit is contained in:
wule committed 2026-09-08 16:59:22 +08:00
1 parent 4fdcc94a91
commit 5ade769d7d
5 files changed
+131 -11

No files matched your search

@@ -1,5 +1,6 @@
using AllBase;
using AllBase.Helper;
using AllBase.Model.Data;
using AllBase.Model.Param;
using AllBase.Model.Result;
using AllBase.Model.Result._1688;
@@ -173,14 +174,25 @@ namespace TemuKJD.PDDForms.ProductSelectForms
lstTemuDbProduct.Clear();
dgvDbProduct.Columns["colViewUv"].Visible = false;
}
if (cancellationTokenSource!= null)
cancellationTokenSource.Cancel();
cancellationTokenSource = new CancellationTokenSource();
Task.Run(() =>
{
{
var cancelToken = cancellationTokenSource.Token;
int pageCount;
int pageSize = 100;
decimal seconds;
Invoke(new Action(() => { pageSize = this.ucSplitPage1.PageSize; }));
var list = GetProductList(out pageCount, out seconds, page, pageSize);
if (cancelToken.IsCancellationRequested)
return;
// 测试获取爆款数据
//var list = GetHotProductList(out pageCount, out seconds, page, pageSize);
// 测试获取商品最后几笔订单的外采价格
//var outAmountList = GetProductLatestOutAmountList(string.Join(",", list.Select(l => l.ext_code.IsNullOrEmpty() ? WXDBProdUploadForm.GetNewExtCode(l.spu_id) : l.ext_code)));
lstTemuDbProduct.AddRange(list);
this.ucSplitPage1.TotalPage = pageCount;
@@ -199,6 +211,9 @@ namespace TemuKJD.PDDForms.ProductSelectForms
}));
foreach (var prod in lstTemuDbProduct.Reverse().ToList())
{
if (cancelToken.IsCancellationRequested)
return;
string catName = (prod.cat_name ?? prod.cat_id);
if (prod.wx_cat_leaf != null)
{
@@ -286,6 +301,9 @@ namespace TemuKJD.PDDForms.ProductSelectForms
}));
}
if (cancelToken.IsCancellationRequested)
return;
Invoke(new Action(() =>
{
ShowDgvImg();
@@ -295,7 +313,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
this.statusBar.lblTaskStatus.Text += ",耗时:" + seconds;
#endif
}));
});
}, cancellationTokenSource.Token);
}
Bitmap defaultBitmap = null;
@@ -443,6 +461,49 @@ namespace TemuKJD.PDDForms.ProductSelectForms
}
}
public List<ProductLatestOutAmountInfo> GetProductLatestOutAmountList(string outProductIds)
{
List<ProductLatestOutAmountInfo> list = new List<ProductLatestOutAmountInfo>();
var url = BaseClass.BuildWXObjString("product/wx_get_product_latest_buy_amount_list");
var data = "";
Invoke(new Action(() =>
{
data = "&out_product_ids=" + outProductIds;
data += "&latest_cnt=10";
}));
data += "&sign=" + BaseClass.GetMd5(DateTime.Now.ToString("yyyyMMddHHmm") + "wxxd").ToLower();
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"))
{
Invoke(new Action(() =>
{
BaseMsgForm.ShowError("获取商品列表失败,请重试!" + BaseRegex.GetStringJson(ref html, "msg"));
}));
return list;
}
var seconds = BaseRegex.GetDecimalJson(ref html, "seconds");
var jArr = JObject.Parse(html)["data"];
if (jArr.Count() == 0)
return list;
var sProd = JsonHelper.SerializeObject(jArr);
try
{
list = JsonHelper.DeserializeJsonToList<ProductLatestOutAmountInfo>(sProd);
return list;
}
catch (Exception ex)
{
return new List<ProductLatestOutAmountInfo>();
}
}
public List<KJDDBProduct> GetProductList(out int pageCount, out decimal seconds, int page = 1, int pageSize = 200)
{
List<KJDDBProduct> list = new List<KJDDBProduct>();