删除草稿箱,回收站等的商品
This commit is contained in:
1 parent
b2c152889a
commit
a131da66c1
3 files changed
+397
-59
No files matched your search
@@ -793,6 +793,12 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
onSaleStatusCode = 5;
|
||||
else if (OnSaleStatus == "下架")
|
||||
onSaleStatusCode = 11;
|
||||
else if (OnSaleStatus == "审核待处理")
|
||||
onSaleStatusCode = 3;
|
||||
else if (OnSaleStatus == "草稿箱")
|
||||
onSaleStatusCode = 1;
|
||||
else if (OnSaleStatus == "回收站")
|
||||
onSaleStatusCode = 6;
|
||||
|
||||
if (string.IsNullOrEmpty(PreType))
|
||||
getProdOnSaleRst = WXPreSale.scanProductPreview(shop, page, nextKey, pageSize, onSaleStatusCode);
|
||||
@@ -844,7 +850,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
decimal? price = null;
|
||||
try { price = prod["skuList"][0]["price"].ParseToDecimal() / 100; } catch { }
|
||||
try { price = prod["skuList"]?[0]["price"].ParseToDecimal() / 100; } catch { }
|
||||
var prodId = prod["productId"].ParseToString();
|
||||
if (dgvSelectProduct.Rows.Cast<DataGridViewRow>().Any(r => r.Cells["colDraftId"].ParseToString() == prodId))
|
||||
{
|
||||
@@ -855,6 +861,18 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
StatusStr = "在售";
|
||||
if (prod["status"].ParseToInt() == 11)
|
||||
StatusStr = "下架";
|
||||
if (prod["status"].ParseToInt() == 0)
|
||||
{
|
||||
StatusStr = "草稿箱";
|
||||
if (prod["editStatus"].ParseToInt() == 3)
|
||||
StatusStr = "审核待处理";
|
||||
}
|
||||
if (prod["status"].ParseToInt() == 6)
|
||||
StatusStr = "回收站";
|
||||
var Limit1 = pStr.Contains("同款/高度相似商品") ? "\r\n上架相似品" : "";
|
||||
//var Limit2 = BaseRegex.GetStringJson(ref pStr, "secondLevelLabelName").ParseToString().Length > 0 ? "\r\n命中低风险规则上架" : "";
|
||||
var Limit2 = BaseRegex.GetStringJson(ref pStr, "secondLevelLabelName").ParseToString().Length > 0 ? "\r\n低风险规则上架" : "";
|
||||
StatusStr += Limit1 + Limit2;
|
||||
|
||||
var rowIndex = this.dgvSelectProduct.Rows.Add(
|
||||
false,
|
||||
@@ -886,7 +904,16 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
"");
|
||||
|
||||
dgvSelectProduct.Rows[rowIndex].Height = 60;
|
||||
dgvSelectProduct.Rows[rowIndex].Cells["colMsg"].Style.ForeColor = dgvSelectProduct.Rows[rowIndex].Cells["colMsg"].Value.ParseToString().Contains("在售") ? Color.Blue : Color.Red;
|
||||
Color color = Color.Red;
|
||||
if (dgvSelectProduct.Rows[rowIndex].Cells["colMsg"].Value.ParseToString() == "在售")
|
||||
color = Color.Blue;
|
||||
if (dgvSelectProduct.Rows[rowIndex].Cells["colMsg"].Value.ParseToString() == "下架")
|
||||
color = Color.Purple;
|
||||
if (dgvSelectProduct.Rows[rowIndex].Cells["colMsg"].Value.ParseToString() == "草稿箱")
|
||||
color = Color.DarkOrange;
|
||||
if (dgvSelectProduct.Rows[rowIndex].Cells["colMsg"].Value.ParseToString() == "回收站")
|
||||
color = Color.Gray;
|
||||
dgvSelectProduct.Rows[rowIndex].Cells["colMsg"].Style.ForeColor = color;
|
||||
dgvSelectProduct.Rows[rowIndex].Cells["colPreSale"].Style.ForeColor = dgvSelectProduct.Rows[rowIndex].Cells["colPreSale"].Value.ParseToString().Contains("预售") ? Color.Green : Color.Blue;
|
||||
}));
|
||||
}
|
||||
@@ -1094,6 +1121,14 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
BaseMsgForm.ShowError("请勾选需要操作的商品!");
|
||||
return;
|
||||
}
|
||||
if (rowLst.Any(r => r.Cells["colMsg"].Value.ParseToString().Contains("在售") == false))
|
||||
{
|
||||
BaseMsgForm.ShowError("只能勾选在售商品!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (BaseMsgForm.ShowConfirm("确认要下架商品吗?下架后如需上架需要消耗审核次数!").DialogResult != DialogResult.OK)
|
||||
return;
|
||||
|
||||
this.pbLoading.Visible = true;
|
||||
this.btnSetPreSale.Enabled = false;
|
||||
@@ -1250,6 +1285,28 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
}
|
||||
}
|
||||
|
||||
private void btnSelectLimit1_Click(object sender, EventArgs e)
|
||||
{
|
||||
foreach (DataGridViewRow row in dgvSelectProduct.Rows)
|
||||
{
|
||||
if (row.Cells["colMsg"].Value.ParseToString().Contains("上架相似品"))
|
||||
row.Cells["colCheck"].Value = true;
|
||||
else
|
||||
row.Cells["colCheck"].Value = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void btnSelectLimit2_Click(object sender, EventArgs e)
|
||||
{
|
||||
foreach (DataGridViewRow row in dgvSelectProduct.Rows)
|
||||
{
|
||||
if (row.Cells["colMsg"].Value.ParseToString().Contains("低风险规则上架"))
|
||||
row.Cells["colCheck"].Value = true;
|
||||
else
|
||||
row.Cells["colCheck"].Value = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void cmbOnSaleStatus_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
@@ -1269,6 +1326,9 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
return;
|
||||
}
|
||||
|
||||
if (BaseMsgForm.ShowConfirm("确认要删除商品吗?删除后如需上架需要消耗审核次数!").DialogResult != DialogResult.OK)
|
||||
return;
|
||||
|
||||
this.pbLoading.Visible = true;
|
||||
this.btnSetPreSale.Enabled = false;
|
||||
if (cancellationTokenSource != null && !cancellationTokenSource.IsCancellationRequested)
|
||||
@@ -1412,6 +1472,167 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void btnBatchRealDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
var rowLst = dgvSelectProduct.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colCheck"].Value.ParseToBool() == true).ToList();
|
||||
if (rowLst.Count <= 0)
|
||||
{
|
||||
BaseMsgForm.ShowError("请勾选需要操作的商品!");
|
||||
return;
|
||||
}
|
||||
if (rowLst.Any(r => r.Cells["colMsg"].Value.ParseToString().Contains("回收站") == false))
|
||||
{
|
||||
BaseMsgForm.ShowError("只能勾选回收站商品!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (BaseMsgForm.ShowConfirm("确认要彻底删除商品吗?彻底删除后将无法再找回该商品!").DialogResult != DialogResult.OK)
|
||||
return;
|
||||
|
||||
this.pbLoading.Visible = true;
|
||||
this.btnSetPreSale.Enabled = false;
|
||||
if (cancellationTokenSource != null && !cancellationTokenSource.IsCancellationRequested)
|
||||
cancellationTokenSource.Cancel();
|
||||
cancellationTokenSource = new CancellationTokenSource();
|
||||
Task.Run(() =>
|
||||
{
|
||||
SetProdRealDel(rowLst);
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
if (cancellationTokenSource.IsCancellationRequested)
|
||||
{
|
||||
this.statusBar.lblTaskStatus.Text = "商品删除中断";
|
||||
BaseMsgForm.ShowInfo("商品删除中断");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.statusBar.lblTaskStatus.Text = "商品删除完毕";
|
||||
BaseMsgForm.ShowInfo("商品删除完毕");
|
||||
}
|
||||
|
||||
this.pbLoading.Visible = false;
|
||||
this.btnSetPreSale.Enabled = true;
|
||||
}));
|
||||
}, cancellationTokenSource.Token);
|
||||
|
||||
}
|
||||
|
||||
void SetProdRealDel(List<DataGridViewRow> rowLst)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
this.pbLoading.Visible = true;
|
||||
this.statusBar.lblTaskStatus.Text = "正在彻底删除" + "...".Substring(0, DateTime.Now.Second % 4);
|
||||
this.statusBar.pgbTaskProgress.Maximum = dgvSelectProduct.Rows.Count;
|
||||
this.statusBar.UpdateProgressBar(0);
|
||||
}));
|
||||
|
||||
while (rowLst.Count > 0)
|
||||
{
|
||||
if (cancellationTokenSource.IsCancellationRequested)
|
||||
break;
|
||||
|
||||
var r0 = rowLst.FirstOrDefault();
|
||||
var shopId = r0.Cells["colSupplierId"].Value.ParseToString();
|
||||
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ShopId == shopId);
|
||||
var rowLstTmp = rowLst.Where(r => r.Cells["colSupplierId"].Value.ParseToString() == shopId).Take(50).ToList();
|
||||
|
||||
foreach (var r in rowLstTmp)
|
||||
{
|
||||
rowLst.Remove(r);
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
this.statusBar.lblTaskStatus.Text = "正在彻底删除" + "...".Substring(0, DateTime.Now.Second % 4);
|
||||
this.statusBar.UpdateProgressBar(this.statusBar.pgbTaskProgress.Value + 1);
|
||||
r.Cells["colOpResult"].Value = "";
|
||||
}));
|
||||
}
|
||||
if (shop == null)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
foreach (var r in rowLstTmp)
|
||||
{
|
||||
r.Cells["colOpResult"].Value = "店铺不存在";
|
||||
}
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
if (shop.LoginStatus != "登录成功")
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
foreach (var r in rowLstTmp)
|
||||
{
|
||||
r.Cells["colOpResult"].Value = "店铺掉线";
|
||||
}
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
|
||||
List<string> prodIdLst = new List<string>();
|
||||
foreach (var row in rowLstTmp)
|
||||
{
|
||||
var prodId = row.Cells["colDraftId"].Value.ParseToString();
|
||||
prodIdLst.Add(prodId);
|
||||
}
|
||||
|
||||
var downProdRst = WXPreSale.RealDelProd(shop, string.Join(",", prodIdLst));
|
||||
Thread.Sleep(Randomx.GetId(1000, 1500));
|
||||
if (!downProdRst.Contains("\"code\":0"))
|
||||
{
|
||||
if (downProdRst.Contains("biz magic invalid"))
|
||||
{
|
||||
WXShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false);
|
||||
if (shop.LoginStatus != "登录成功")
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
foreach (var row in rowLstTmp)
|
||||
{
|
||||
row.Cells["colOpResult"].Value = "店铺掉线";
|
||||
}
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
var errmsg = BaseRegex.GetStringJson(ref downProdRst, "msg");
|
||||
if (string.IsNullOrWhiteSpace(errmsg))
|
||||
errmsg = downProdRst;
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
foreach (var row in rowLstTmp)
|
||||
{
|
||||
if (downProdRst.Contains("\"code\":108002"))
|
||||
{
|
||||
var prodId = row.Cells["colDraftId"].Value.ParseToString();
|
||||
if (downProdRst.Contains(prodId))
|
||||
row.Cells["colOpResult"].Value = "彻底删除失败,请检查商品是否已删除";
|
||||
else
|
||||
row.Cells["colOpResult"].Value = "彻底删除成功";
|
||||
}
|
||||
else
|
||||
row.Cells["colOpResult"].Value = errmsg;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
if (downProdRst.Contains("\"code\":0"))
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
foreach (var row in rowLstTmp)
|
||||
{
|
||||
row.Cells["colOpResult"].Value = "彻底删除成功";
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class WXPreSale
|
||||
@@ -1421,7 +1642,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
/// </summary>
|
||||
/// <param name="status">-1 全部 5 在售 11 下架</param>
|
||||
/// <returns></returns>
|
||||
public static string searchProduct(ShopLoginInfo shop, int pageNum, int? presaleType = null, int pageSize = 50, int? sortType = null, int status=5)
|
||||
public static string searchProduct(ShopLoginInfo shop, int pageNum, int? presaleType = null, int pageSize = 50, int? sortType = null, int status = 5)
|
||||
{
|
||||
//https://store.weixin.qq.com/shop-faas/mmchannelstradeproductcore/cgi/goods/searchProduct?token=&lang=zh_CN&pageSize=20&productStatus[]=-1&productSource=[1,16,32]&searchSource=1&useNew=true&pageNum=44&status[]=5&presaleType[]=1
|
||||
string url = "https://store.weixin.qq.com/shop-faas/mmchannelstradeproductcore/cgi/goods/searchProduct?token=&lang=zh_CN&" +
|
||||
@@ -1437,9 +1658,9 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -1 全部 5 在售 11 下架
|
||||
/// -1全部 5在售 11下架 1草稿箱 3审核待处理 6回收站
|
||||
/// </summary>
|
||||
/// <param name="saleStatus">-1 全部 5 在售 11 下架</param>
|
||||
/// <param name="saleStatus">-1 全部 5在售 11下架 1草稿箱 3审核待处理 6回收站</param>
|
||||
/// <returns></returns>
|
||||
public static string scanProductPreview(ShopLoginInfo shop, int page, string nextKey = "", int pageSize = 50, int saleStatus = 5)
|
||||
{
|
||||
@@ -1449,8 +1670,22 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
referer = "https://store.weixin.qq.com/shop/goods/list?currentTab=PRODUCT_STATUS_ON¤tPage=" + page;
|
||||
//string body = @"{""pageSize"":20,""productStatus"":[-1],""productSource"":""[1,16,32]"",""searchSource"":1,""useNew"":true,""pageNum"":1,""status"":[5]}";
|
||||
//string body = @"{""pageSize"":20,""productStatus"":[-1],""productSource"":""[1,16,32]"",""searchSource"":1,""useNew"":true,""pageNum"":2,""status"":[5],""nextKey"":""ChwItc+24YajAhCD14bMBhjqLiDoDCgAMITXhswGEhwIy8im34ajAhCa74XMBhiaXyDeBygAMJrvhcwGGAEgeiiIEw==""}";
|
||||
string body = @"{""pageSize"":" + pageSize + @",""productStatus"":[-1],""productSource"":""[1,16,32]"",""searchSource"":1,""useNew"":true,""pageNum"":" + page +
|
||||
@",""status"":[" + saleStatus + @"],""nextKey"":""" + nextKey + @"""}";
|
||||
|
||||
//string body = @"{""pageSize"":" + pageSize + @",""productStatus"":[-1],""productSource"":""[1,16,32]"",""searchSource"":1,""useNew"":true,""pageNum"":" + page + @",""status"":[" + saleStatus + @"],""nextKey"":""" + nextKey + @"""}";
|
||||
JObject bodyObj = new JObject();
|
||||
bodyObj["pageSize"] = pageSize;
|
||||
bodyObj["productStatus"] = new JArray() { -1 };
|
||||
bodyObj["productSource"] = "[1,16,32]";
|
||||
bodyObj["searchSource"] = 1;
|
||||
bodyObj["useNew"] = true;
|
||||
bodyObj["pageNum"] = page;
|
||||
bodyObj["status"] = new JArray() { saleStatus };
|
||||
if(!string.IsNullOrEmpty(nextKey))
|
||||
{
|
||||
bodyObj["nextKey"] = nextKey;
|
||||
}
|
||||
string body = JsonHelper.SerializeObject(bodyObj);
|
||||
|
||||
var result = WXHttpResponseBLL.WeiXinPostResponse(shop, url, body, referer);
|
||||
return result;
|
||||
}
|
||||
@@ -1472,7 +1707,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 下架商品
|
||||
/// 删除商品
|
||||
/// </summary>
|
||||
/// <param name="shop"></param>
|
||||
/// <param name="prodId"></param>
|
||||
@@ -1485,5 +1720,20 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
var result = WXHttpResponseBLL.WeiXinPostResponse(shop, url, body, referer);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 彻底删除商品
|
||||
/// </summary>
|
||||
/// <param name="shop"></param>
|
||||
/// <param name="prodId"></param>
|
||||
/// <returns></returns>
|
||||
public static string RealDelProd(ShopLoginInfo shop, string prodIds)
|
||||
{
|
||||
string url = "https://store.weixin.qq.com/shop-faas/mmecnodeproductlist/cgi/goods/batchRealDel?token=&lang=zh_CN";
|
||||
string referer = "https://store.weixin.qq.com/shop/goods/list?currentTab=PRODUCT_RECYCLE_BIN";
|
||||
string body = @"{""ids"":[" + prodIds + @"],""uploadSource"":6}";
|
||||
var result = WXHttpResponseBLL.WeiXinPostResponse(shop, url, body, referer);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user