调整价格接口优化

This commit is contained in:
wule committed 2026-06-28 21:35:56 +08:00
1 parent 5467acadc0
commit 93a55ff343
1 file changed
+41 -17
@@ -1743,7 +1743,10 @@ namespace TemuKJD.WXForms.ProductForms
} }
List<string> prodIdLst = new List<string>(); List<string> prodIdLst = new List<string>();
ConcurrentList<Task> tList = new ConcurrentList<Task>();
foreach (var row in rowLstTmp) foreach (var row in rowLstTmp)
{
var t = Task.Run(() =>
{ {
var prodId = row.Cells["colDraftId"].Value.ParseToString(); var prodId = row.Cells["colDraftId"].Value.ParseToString();
var skuPricesStr = row.Cells["colSkuMultiPrice"].Value.ParseToString(); var skuPricesStr = row.Cells["colSkuMultiPrice"].Value.ParseToString();
@@ -1755,7 +1758,7 @@ namespace TemuKJD.WXForms.ProductForms
{ {
row.Cells["colOpResult"].Value = "商品改价未还原,跳过"; row.Cells["colOpResult"].Value = "商品改价未还原,跳过";
})); }));
continue; return;
} }
var downProdRst = changePrice(shop, prodId, skuPricesStr, (newPrice * 100).ParseToInt()); var downProdRst = changePrice(shop, prodId, skuPricesStr, (newPrice * 100).ParseToInt());
@@ -1769,19 +1772,15 @@ namespace TemuKJD.WXForms.ProductForms
{ {
Invoke(new Action(() => Invoke(new Action(() =>
{ {
foreach (var r in rowLstTmp) row.Cells["colOpResult"].Value = "店铺掉线";
{
r.Cells["colOpResult"].Value = "店铺掉线";
}
})); }));
break; return;
} }
} }
var errmsg = BaseRegex.GetStringJson(ref downProdRst, "msg"); var errmsg = BaseRegex.GetStringJson(ref downProdRst, "msg");
if (string.IsNullOrWhiteSpace(errmsg)) if (string.IsNullOrWhiteSpace(errmsg))
errmsg = downProdRst; errmsg = downProdRst;
Invoke(new Action(() => Invoke(new Action(() =>
{ {
row.Cells["colOpResult"].Value = "修改价格失败" + errmsg; row.Cells["colOpResult"].Value = "修改价格失败" + errmsg;
@@ -1790,14 +1789,26 @@ namespace TemuKJD.WXForms.ProductForms
// 改价成功 // 改价成功
else else
{ {
dicProductBasePrice[prodId] = skuPricesStr;
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_product_base_price", dicProductBasePrice);
Invoke(new Action(() => Invoke(new Action(() =>
{ {
dicProductBasePrice[prodId] = skuPricesStr;
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_product_base_price", dicProductBasePrice);
row.Cells["colOpResult"].Value = "修改价格成功"; row.Cells["colOpResult"].Value = "修改价格成功";
row.Cells["colPrice"].Value = newPrice; row.Cells["colPrice"].Value = newPrice;
})); }));
} }
});
tList.Add(t);
while(tList.Count > 20)
{
Thread.Sleep(200);
tList.RemoveAll(ta => ta.IsFaulted || ta.IsCanceled || ta.IsCompleted);
}
}
while (tList.Count > 0)
{
Thread.Sleep(200);
tList.RemoveAll(ta => ta.IsFaulted || ta.IsCanceled || ta.IsCompleted);
} }
} }
} }
@@ -1949,8 +1960,11 @@ namespace TemuKJD.WXForms.ProductForms
continue; continue;
} }
ConcurrentList<Task> tList = new ConcurrentList<Task>();
List<string> prodIdLst = new List<string>(); List<string> prodIdLst = new List<string>();
foreach (var row in rowLstTmp) foreach (var row in rowLstTmp)
{
var t = Task.Run(() =>
{ {
var prodId = row.Cells["colDraftId"].Value.ParseToString(); var prodId = row.Cells["colDraftId"].Value.ParseToString();
@@ -1960,7 +1974,7 @@ namespace TemuKJD.WXForms.ProductForms
{ {
row.Cells["colOpResult"].Value = "未找到价格修改记录,无法还原,跳过"; row.Cells["colOpResult"].Value = "未找到价格修改记录,无法还原,跳过";
})); }));
continue; return;
} }
var skuPricesStr = dicProductBasePrice[prodId]; var skuPricesStr = dicProductBasePrice[prodId];
@@ -1975,12 +1989,9 @@ namespace TemuKJD.WXForms.ProductForms
{ {
Invoke(new Action(() => Invoke(new Action(() =>
{ {
foreach (var r in rowLstTmp) row.Cells["colOpResult"].Value = "店铺掉线";
{
r.Cells["colOpResult"].Value = "店铺掉线";
}
})); }));
break; return;
} }
} }
@@ -1996,15 +2007,28 @@ namespace TemuKJD.WXForms.ProductForms
// 还原价格成功 // 还原价格成功
else else
{ {
dicProductBasePrice.Remove(prodId);
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_product_base_price", dicProductBasePrice);
Invoke(new Action(() => Invoke(new Action(() =>
{ {
dicProductBasePrice.Remove(prodId);
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_product_base_price", dicProductBasePrice);
row.Cells["colOpResult"].Value = "还原价格成功"; row.Cells["colOpResult"].Value = "还原价格成功";
var skuListObj = JArray.Parse(skuPricesStr); var skuListObj = JArray.Parse(skuPricesStr);
row.Cells["colPrice"].Value = skuListObj.Min(sk => sk["price"].ParseToInt() * 0.01m) + " - " + skuListObj.Max(sk => sk["price"].ParseToInt() * 0.01m); row.Cells["colPrice"].Value = skuListObj.Min(sk => sk["price"].ParseToInt() * 0.01m) + " - " + skuListObj.Max(sk => sk["price"].ParseToInt() * 0.01m);
})); }));
} }
});
tList.Add(t);
while (tList.Count > 20)
{
Thread.Sleep(200);
tList.RemoveAll(ta => ta.IsFaulted || ta.IsCanceled || ta.IsCompleted);
}
}
while (tList.Count > 0)
{
Thread.Sleep(200);
tList.RemoveAll(ta => ta.IsFaulted || ta.IsCanceled || ta.IsCompleted);
} }
} }
} }