产品库手动更新sku下架情况
This commit is contained in:
1 parent
1b2b6bb553
commit
30efe8fccb
25 files changed
+2214
-490
No files matched your search
@@ -514,6 +514,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
}
|
||||
|
||||
|
||||
Task tskPreSale = null;
|
||||
private void btnSetPreSale_Click(object sender, EventArgs e)
|
||||
{
|
||||
var rowLst = dgvSelectProduct.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colCheck"].Value.ParseToBool() == true).ToList();
|
||||
@@ -579,9 +580,9 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
this.btnSetPreSale.Enabled = false;
|
||||
cancellationTokenSource = new CancellationTokenSource();
|
||||
dgvSelectProduct.Columns["colCouponNum"].Visible = false;
|
||||
Task.Run(() =>
|
||||
tskPreSale = Task.Run(() =>
|
||||
{
|
||||
SetProdCoupon(rowLst);
|
||||
SetProdCoupon(rowLst.Select(r => r.Cells["colDraftId"].Value.ParseToString()).Distinct().ToList());
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
this.statusBar.lblTaskStatus.Text = "商品设置完毕";
|
||||
@@ -592,18 +593,19 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
}, cancellationTokenSource.Token);
|
||||
}
|
||||
|
||||
void SetProdCoupon(List<DataGridViewRow> rowLst)
|
||||
void SetProdCoupon(List<string> prodIdLst)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
this.pbLoading.Visible = true;
|
||||
this.statusBar.lblTaskStatus.Text = "正在设置" + "...".Substring(0, DateTime.Now.Second % 4);
|
||||
this.statusBar.pgbTaskProgress.Maximum = rowLst.Count;
|
||||
this.statusBar.pgbTaskProgress.Maximum = prodIdLst.Count;
|
||||
this.statusBar.UpdateProgressBar(0);
|
||||
}));
|
||||
|
||||
foreach (var row in rowLst)
|
||||
|
||||
foreach (var prodId in prodIdLst)
|
||||
{
|
||||
var row = dgvSelectProduct.Rows.Cast<DataGridViewRow>().FirstOrDefault(r => r.Cells["colDraftId"].Value.ParseToString() == prodId);
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
this.statusBar.lblTaskStatus.Text = "正在设置" + "...".Substring(0, DateTime.Now.Second % 4);
|
||||
@@ -614,7 +616,6 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
if (cancellationTokenSource.IsCancellationRequested)
|
||||
break;
|
||||
|
||||
var prodId = row.Cells["colDraftId"].Value.ParseToString();
|
||||
var shopId = row.Cells["colSupplierId"].Value.ParseToString();
|
||||
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ShopId == shopId);
|
||||
if (shop == null)
|
||||
@@ -634,7 +635,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
continue;
|
||||
}
|
||||
WXCouponParamBase wxCouponParam = new WXCouponParamBase();
|
||||
Thread.Sleep(Randomx.GetId(300, 800));
|
||||
Thread.Sleep(Randomx.GetId(200, 500));
|
||||
//wxCouponParam.check = true;
|
||||
wxCouponParam.coupon.couponInfo.name = prodId;
|
||||
wxCouponParam.coupon.couponInfo.discountInfo.discountCondition.productIds.Add(prodId.ParseToLong());
|
||||
@@ -675,6 +676,44 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
wxCouponParam.coupon.couponInfo.discountInfo.discountNum = discountNum.ToString("0.##");
|
||||
}
|
||||
|
||||
Thread.Sleep(Randomx.GetId(200, 500));
|
||||
if (chkSkipSet.Checked)
|
||||
{
|
||||
var searchCouponRst = WxCoupon.WxSearchCoupon(shop, prodId);
|
||||
if (searchCouponRst.Contains("biz magic invalid"))
|
||||
{
|
||||
WXShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false);
|
||||
}
|
||||
if (!searchCouponRst.Contains("\"success\":true") && !searchCouponRst.Contains("\"code\":0"))
|
||||
{
|
||||
var errmsg = BaseRegex.GetStringJson(ref searchCouponRst, "msg");
|
||||
if (string.IsNullOrWhiteSpace(errmsg))
|
||||
errmsg = searchCouponRst;
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
row.Cells["colOpResult"].Value = errmsg;
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (searchCouponRst.Contains("\"code\":0"))
|
||||
{
|
||||
var totalNum = BaseRegex.GetStringJson(ref searchCouponRst, "totalNum");
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
row.Cells["colCouponNum"].Value = totalNum;
|
||||
}));
|
||||
if (totalNum.ParseToInt() > 0)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
row.Cells["colOpResult"].Value = "商品已设置专属优惠券,跳过";
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var addCouponRst = WxCoupon.WxSetCoupon(shop, wxCouponParam);
|
||||
Thread.Sleep(Randomx.GetId(50, 100));
|
||||
@@ -706,7 +745,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
}
|
||||
|
||||
private void btnStop_Click(object sender, EventArgs e)
|
||||
{
|
||||
{
|
||||
if (this.cancellationTokenSource != null)
|
||||
this.cancellationTokenSource.Cancel();
|
||||
}
|
||||
@@ -794,12 +833,12 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
try
|
||||
{
|
||||
var prodObjs = JsonHelper.JObjectParse(getProdOnSaleRst);
|
||||
if (page == 1)
|
||||
if (page == 1 || 1 == 1)
|
||||
{
|
||||
var totalNum = prodObjs["totalNum"].ParseToInt();
|
||||
totalPage = Math.Ceiling(1m * totalNum / pageSize).ParseToInt();
|
||||
nextKey = prodObjs["nextKey"].ParseToString();
|
||||
}
|
||||
nextKey = prodObjs["nextKey"].ParseToString();
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
this.pbLoading.Visible = true;
|
||||
@@ -1350,7 +1389,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
row.Cells["colOpResult"].Value = "商品无优惠券,跳过";
|
||||
row.Cells["colOpResult"].Value = "商品无专属优惠券,跳过";
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user