调整价格接口优化
This commit is contained in:
1 parent
5467acadc0
commit
93a55ff343
1 file changed
+111
-87
@@ -1743,62 +1743,73 @@ 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 prodId = row.Cells["colDraftId"].Value.ParseToString();
|
var t = Task.Run(() =>
|
||||||
var skuPricesStr = row.Cells["colSkuMultiPrice"].Value.ParseToString();
|
|
||||||
var newPrice = txtPrice.Text.ParseToDecimal();
|
|
||||||
|
|
||||||
if (dicProductBasePrice.ContainsKey(prodId))
|
|
||||||
{
|
{
|
||||||
Invoke(new Action(() =>
|
var prodId = row.Cells["colDraftId"].Value.ParseToString();
|
||||||
{
|
var skuPricesStr = row.Cells["colSkuMultiPrice"].Value.ParseToString();
|
||||||
row.Cells["colOpResult"].Value = "商品改价未还原,跳过";
|
var newPrice = txtPrice.Text.ParseToDecimal();
|
||||||
}));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var downProdRst = changePrice(shop, prodId, skuPricesStr, (newPrice * 100).ParseToInt());
|
if (dicProductBasePrice.ContainsKey(prodId))
|
||||||
Thread.Sleep(Randomx.GetId(200, 500));
|
|
||||||
if (!downProdRst.Contains("\"code\":0"))
|
|
||||||
{
|
|
||||||
if (downProdRst.Contains("biz magic invalid"))
|
|
||||||
{
|
{
|
||||||
WXShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false);
|
Invoke(new Action(() =>
|
||||||
if (shop.LoginStatus != "登录成功")
|
|
||||||
{
|
{
|
||||||
Invoke(new Action(() =>
|
row.Cells["colOpResult"].Value = "商品改价未还原,跳过";
|
||||||
{
|
}));
|
||||||
foreach (var r in rowLstTmp)
|
return;
|
||||||
{
|
|
||||||
r.Cells["colOpResult"].Value = "店铺掉线";
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var errmsg = BaseRegex.GetStringJson(ref downProdRst, "msg");
|
var downProdRst = changePrice(shop, prodId, skuPricesStr, (newPrice * 100).ParseToInt());
|
||||||
if (string.IsNullOrWhiteSpace(errmsg))
|
Thread.Sleep(Randomx.GetId(200, 500));
|
||||||
errmsg = downProdRst;
|
if (!downProdRst.Contains("\"code\":0"))
|
||||||
|
{
|
||||||
|
if (downProdRst.Contains("biz magic invalid"))
|
||||||
|
{
|
||||||
|
WXShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false);
|
||||||
|
if (shop.LoginStatus != "登录成功")
|
||||||
|
{
|
||||||
|
Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
row.Cells["colOpResult"].Value = "店铺掉线";
|
||||||
|
}));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Invoke(new Action(() =>
|
var errmsg = BaseRegex.GetStringJson(ref downProdRst, "msg");
|
||||||
|
if (string.IsNullOrWhiteSpace(errmsg))
|
||||||
|
errmsg = downProdRst;
|
||||||
|
Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
row.Cells["colOpResult"].Value = "修改价格失败" + errmsg;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
// 改价成功
|
||||||
|
else
|
||||||
{
|
{
|
||||||
row.Cells["colOpResult"].Value = "修改价格失败" + errmsg;
|
Invoke(new Action(() =>
|
||||||
}));
|
{
|
||||||
}
|
dicProductBasePrice[prodId] = skuPricesStr;
|
||||||
// 改价成功
|
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_product_base_price", dicProductBasePrice);
|
||||||
else
|
row.Cells["colOpResult"].Value = "修改价格成功";
|
||||||
|
row.Cells["colPrice"].Value = newPrice;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tList.Add(t);
|
||||||
|
while(tList.Count > 20)
|
||||||
{
|
{
|
||||||
dicProductBasePrice[prodId] = skuPricesStr;
|
Thread.Sleep(200);
|
||||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_product_base_price", dicProductBasePrice);
|
tList.RemoveAll(ta => ta.IsFaulted || ta.IsCanceled || ta.IsCompleted);
|
||||||
Invoke(new Action(() =>
|
|
||||||
{
|
|
||||||
row.Cells["colOpResult"].Value = "修改价格成功";
|
|
||||||
row.Cells["colPrice"].Value = newPrice;
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
while (tList.Count > 0)
|
||||||
|
{
|
||||||
|
Thread.Sleep(200);
|
||||||
|
tList.RemoveAll(ta => ta.IsFaulted || ta.IsCanceled || ta.IsCompleted);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1949,63 +1960,76 @@ 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 prodId = row.Cells["colDraftId"].Value.ParseToString();
|
var t = Task.Run(() =>
|
||||||
|
|
||||||
if (!dicProductBasePrice.ContainsKey(prodId))
|
|
||||||
{
|
{
|
||||||
Invoke(new Action(() =>
|
var prodId = row.Cells["colDraftId"].Value.ParseToString();
|
||||||
{
|
|
||||||
row.Cells["colOpResult"].Value = "未找到价格修改记录,无法还原,跳过";
|
|
||||||
}));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
var skuPricesStr = dicProductBasePrice[prodId];
|
|
||||||
|
|
||||||
var downProdRst = changePrice(shop, prodId, skuPricesStr, -1, true);
|
if (!dicProductBasePrice.ContainsKey(prodId))
|
||||||
Thread.Sleep(Randomx.GetId(200, 500));
|
|
||||||
if (!downProdRst.Contains("\"code\":0"))
|
|
||||||
{
|
|
||||||
if (downProdRst.Contains("biz magic invalid"))
|
|
||||||
{
|
{
|
||||||
WXShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false);
|
Invoke(new Action(() =>
|
||||||
if (shop.LoginStatus != "登录成功")
|
|
||||||
{
|
{
|
||||||
Invoke(new Action(() =>
|
row.Cells["colOpResult"].Value = "未找到价格修改记录,无法还原,跳过";
|
||||||
{
|
}));
|
||||||
foreach (var r in rowLstTmp)
|
return;
|
||||||
{
|
|
||||||
r.Cells["colOpResult"].Value = "店铺掉线";
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
var skuPricesStr = dicProductBasePrice[prodId];
|
||||||
|
|
||||||
var errmsg = BaseRegex.GetStringJson(ref downProdRst, "msg");
|
var downProdRst = changePrice(shop, prodId, skuPricesStr, -1, true);
|
||||||
if (string.IsNullOrWhiteSpace(errmsg))
|
Thread.Sleep(Randomx.GetId(200, 500));
|
||||||
errmsg = downProdRst;
|
if (!downProdRst.Contains("\"code\":0"))
|
||||||
|
|
||||||
Invoke(new Action(() =>
|
|
||||||
{
|
{
|
||||||
row.Cells["colOpResult"].Value = "还原失败" + errmsg;
|
if (downProdRst.Contains("biz magic invalid"))
|
||||||
}));
|
{
|
||||||
}
|
WXShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false);
|
||||||
// 还原价格成功
|
if (shop.LoginStatus != "登录成功")
|
||||||
else
|
{
|
||||||
|
Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
row.Cells["colOpResult"].Value = "店铺掉线";
|
||||||
|
}));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var errmsg = BaseRegex.GetStringJson(ref downProdRst, "msg");
|
||||||
|
if (string.IsNullOrWhiteSpace(errmsg))
|
||||||
|
errmsg = downProdRst;
|
||||||
|
|
||||||
|
Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
row.Cells["colOpResult"].Value = "还原失败" + errmsg;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
// 还原价格成功
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
dicProductBasePrice.Remove(prodId);
|
||||||
|
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_product_base_price", dicProductBasePrice);
|
||||||
|
|
||||||
|
row.Cells["colOpResult"].Value = "还原价格成功";
|
||||||
|
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);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tList.Add(t);
|
||||||
|
while (tList.Count > 20)
|
||||||
{
|
{
|
||||||
dicProductBasePrice.Remove(prodId);
|
Thread.Sleep(200);
|
||||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_product_base_price", dicProductBasePrice);
|
tList.RemoveAll(ta => ta.IsFaulted || ta.IsCanceled || ta.IsCompleted);
|
||||||
Invoke(new Action(() =>
|
|
||||||
{
|
|
||||||
row.Cells["colOpResult"].Value = "还原价格成功";
|
|
||||||
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);
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
while (tList.Count > 0)
|
||||||
|
{
|
||||||
|
Thread.Sleep(200);
|
||||||
|
tList.RemoveAll(ta => ta.IsFaulted || ta.IsCanceled || ta.IsCompleted);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user