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