佣金上货逻辑调整
This commit is contained in:
1 parent
381332b7c8
commit
8f5debb85c
5 files changed
+458
-114
No files matched your search
@@ -777,6 +777,8 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
}));
|
||||
foreach (JObject prod in prodObjs["productList"])
|
||||
{
|
||||
string StatusStr = "";
|
||||
int rowIndex = 0;
|
||||
var pStr = JsonHelper.SerializeObject(prod);
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
@@ -787,7 +789,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
{
|
||||
|
||||
}
|
||||
string StatusStr = "其他";
|
||||
StatusStr = "其他";
|
||||
if (prod["status"].ParseToInt() == 5)
|
||||
StatusStr = "在售";
|
||||
if (prod["status"].ParseToInt() == 11)
|
||||
@@ -805,7 +807,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
var Limit2 = BaseRegex.GetStringJson(ref pStr, "secondLevelLabelName").ParseToString().Length > 0 ? "\r\n低风险规则上架" : "";
|
||||
StatusStr += Limit1 + Limit2;
|
||||
|
||||
var rowIndex = this.dgvSelectProduct.Rows.Add(
|
||||
rowIndex = this.dgvSelectProduct.Rows.Add(
|
||||
false,
|
||||
"",
|
||||
shop.ShopId,
|
||||
@@ -820,6 +822,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
"", // 替换图地址
|
||||
null, // 替换图
|
||||
prod["title"].ParseToString(), // 用户端显示商品原名
|
||||
"", // 推广短链
|
||||
(prod["recommendCategory"].IsJTokenNullOrEmpty() || prod["recommendCategory"]["categoryNames"].IsJTokenNullOrEmpty()) ?
|
||||
"" : string.Join(" >> ", prod["recommendCategory"]["categoryNames"].Select(s => s.ParseToString())), // 类目名称
|
||||
prod["spuCode"].ParseToString(),
|
||||
@@ -847,6 +850,37 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
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;
|
||||
}));
|
||||
|
||||
if (StatusStr.ParseToString().StartsWith("在售") && chkSearchPromotionLink.Checked == true)
|
||||
{
|
||||
Task.Run(() => { });
|
||||
var PromotionRst = WXPreSale.GetPromotionLink(shop, prod["productId"].ParseToString(), page);
|
||||
Thread.Sleep(Randomx.GetId(50, 150));
|
||||
if (PromotionRst.ParseToString().Contains("\"code\":0"))
|
||||
{
|
||||
var shareUrl = BaseRegex.GetStringJson(ref PromotionRst, "shareUrl");
|
||||
var shortLink = BaseRegex.GetStringJson(ref PromotionRst, "shortLink");
|
||||
if (!string.IsNullOrEmpty(shareUrl))
|
||||
{
|
||||
Invoke(new Action(() => {
|
||||
dgvSelectProduct.Rows[rowIndex].Cells["colPromotionLink"].Value = shareUrl;
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
Invoke(new Action(() => {
|
||||
dgvSelectProduct.Rows[rowIndex].Cells["colPromotionLink"].Value = "链接获取失败";
|
||||
}));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var errMsg = BaseRegex.GetStringJsonByRegs(ref PromotionRst, PromotionRst, "errMsg", "errorMsg", "err_msg", "error_msg", "errormsg");
|
||||
Invoke(new Action(() => {
|
||||
dgvSelectProduct.Rows[rowIndex].Cells["colPromotionLink"].Value = errMsg;
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -1592,6 +1626,177 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void chkSearchPromotionLink_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.dgvSelectProduct.Columns["colPromotionLink"].Visible = chkSearchPromotionLink.Checked;
|
||||
}
|
||||
|
||||
private void btnSetPrice_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (txtPrice.Text.ParseToDecimal().IsNullOrZero())
|
||||
{
|
||||
BaseMsgForm.ShowError("请输入批量设置金额!");
|
||||
return;
|
||||
}
|
||||
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(() =>
|
||||
{
|
||||
SetProdDown(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 SetProdPrice(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.DownProd(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
|
||||
@@ -1694,5 +1899,19 @@ 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 GetPromotionLink(ShopLoginInfo shop, string prodId, int pageId)
|
||||
{
|
||||
string url = "https://store.weixin.qq.com/shop-faas/mmecnodematerial/product?token=&lang=zh_CN&productId=" + prodId;
|
||||
string referer = "https://store.weixin.qq.com/shop/goods/list?currentPage=" + pageId;
|
||||
var result = WXHttpResponseBLL.WeiXinGetResponse(shop, url, referer);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user