添加商品改价回滚功能,优化图书上传

This commit is contained in:
wule_5900x committed 2026-06-28 21:05:32 +08:00
1 parent 8f5debb85c
commit 5467acadc0
7 files changed
+460 -124

No files matched your search

+1 -1
View File
@@ -27,7 +27,7 @@ namespace AllBase
/// <summary> /// <summary>
/// 版本ID /// 版本ID
/// </summary> /// </summary>
public static int VersionCount = 1192; public static int VersionCount = 1195;
public static string MainPath = "29wx"; public static string MainPath = "29wx";
//public static string MainPath = "29wx"; //public static string MainPath = "29wx";
//public static string MainPath = "29pdd"; //public static string MainPath = "29pdd";
@@ -8,7 +8,7 @@
<IISExpressWindowsAuthentication /> <IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode /> <IISExpressUseClassicPipelineMode />
<UseGlobalApplicationHostFile /> <UseGlobalApplicationHostFile />
<LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig> <LastActiveSolutionConfig>Release|Any CPU</LastActiveSolutionConfig>
<ProjectView>ShowAllFiles</ProjectView> <ProjectView>ShowAllFiles</ProjectView>
</PropertyGroup> </PropertyGroup>
<ProjectExtensions> <ProjectExtensions>
@@ -54,6 +54,7 @@ namespace TemuKJD.WXForms.OrderForms
{ {
var error = BaseRegex.GetStringJsonByRegs(ref getProdOnSaleRst, getProdOnSaleRst, "err_msg", "error_msg", "errMsg", "errorMsg", "msg"); var error = BaseRegex.GetStringJsonByRegs(ref getProdOnSaleRst, getProdOnSaleRst, "err_msg", "error_msg", "errMsg", "errorMsg", "msg");
BaseMsgForm.ShowInfo("改价失败" + error); BaseMsgForm.ShowInfo("改价失败" + error);
return;
} }
prodObj = JsonHelper.JObjectParse(getProdOnSaleRst)["productList"].FirstOrDefault() as JObject; prodObj = JsonHelper.JObjectParse(getProdOnSaleRst)["productList"].FirstOrDefault() as JObject;
if (prodObj != null) if (prodObj != null)
@@ -3163,10 +3163,10 @@ namespace TemuKJD.WXForms.ProductForms
foreach (var wxEditCategoryParam in wxEditPropParam.categorys) foreach (var wxEditCategoryParam in wxEditPropParam.categorys)
{ {
// 修改书名 // 修改书名
//if (wxEditPropParam.categorys.FirstOrDefault().name == "书名" && wxEditCategoryParam == wxEditPropParam.categorys.LastOrDefault()) if (wxEditPropParam.categorys.FirstOrDefault().name == "书名" && wxEditCategoryParam == wxEditPropParam.categorys.LastOrDefault())
//{ {
// wxEditCategoryParam.name = prodTitle; wxEditCategoryParam.name = prodTitle;
//} }
var wxCategoryParam = new categoryPropParam() var wxCategoryParam = new categoryPropParam()
{ {
catType = wxEditCategoryParam.catType, catType = wxEditCategoryParam.catType,
@@ -3320,14 +3320,15 @@ namespace TemuKJD.WXForms.ProductForms
if (upProdParam.product.info.category.FirstOrDefault()?.name == "图书" || prodInfo.detail.cats.FirstOrDefault() == "书籍/杂志/报纸") if (upProdParam.product.info.category.FirstOrDefault()?.name == "图书" || prodInfo.detail.cats.FirstOrDefault() == "书籍/杂志/报纸")
{ {
// 修改书名 作者 // 修改书名 作者
//if (attr.name == "书名" /*&& dbProd.product_get_type_text == "微信小店"*/) if (attr.name == "书名" /*&& dbProd.product_get_type_text == "微信小店"*/)
//{ {
// attrValue = prodTitle; attrValue = prodTitle;
//} }
//if (attr.name == "作者" && attrValue == "无") if (attr.name == "作者" && attrValue == "无")
//{ {
// attrValue = new List<string>() { "赵老师", "钱老师", "孙老师", "李老师", "周老师", "吴老师", "郑老师", "王老师", "张老师", "孙老师", "刘老师" }.OrderBy(x => Guid.NewGuid()).FirstOrDefault(); attrValue = new List<string>() { "赵老师", "钱老师", "孙老师", "李老师", "周老师", "吴老师", "郑老师", "王老师", "张老师", "孙老师", "刘老师" }.OrderBy(x => Guid.NewGuid()).FirstOrDefault();
//} attrValue = "无";
}
if (attrValue.IsNullOrEmpty() && attr.type == "integer_unit" && (propInfo.values.FirstOrDefault()?.value).IsNumber()) if (attrValue.IsNullOrEmpty() && attr.type == "integer_unit" && (propInfo.values.FirstOrDefault()?.value).IsNumber())
{ {
@@ -3603,7 +3604,10 @@ namespace TemuKJD.WXForms.ProductForms
if (attr.name == "出版社名称") if (attr.name == "出版社名称")
attrValue = new List<string>() { "技术出版社", "文化出版社", "美术出版社" }[Randomx.GetId(3)]; attrValue = new List<string>() { "技术出版社", "文化出版社", "美术出版社" }[Randomx.GetId(3)];
if (attr.name == "作者") if (attr.name == "作者")
{
attrValue = new List<string>() { "赵老师", "钱老师", "孙老师", "李老师", "周老师", "吴老师", "郑老师", "王老师", "张老师", "孙老师", "刘老师" }.OrderBy(x => Guid.NewGuid()).FirstOrDefault(); attrValue = new List<string>() { "赵老师", "钱老师", "孙老师", "李老师", "周老师", "吴老师", "郑老师", "王老师", "张老师", "孙老师", "刘老师" }.OrderBy(x => Guid.NewGuid()).FirstOrDefault();
attrValue = "无";
}
if (attr.name == "包装") if (attr.name == "包装")
attrValue = "平装"; attrValue = "平装";
if (attr.name == "出版时间") if (attr.name == "出版时间")
@@ -3723,6 +3727,19 @@ namespace TemuKJD.WXForms.ProductForms
wxPropParam.categorys.Add(wxCategoryParam1); wxPropParam.categorys.Add(wxCategoryParam1);
wxPropParam.categorys.Add(wxCategoryParam2); wxPropParam.categorys.Add(wxCategoryParam2);
} }
if (upProdParam.product.info.category.FirstOrDefault()?.name == "图书" || prodInfo.detail.cats.FirstOrDefault() == "书籍/杂志/报纸")
{
foreach (var param in upProdParam.product.info.param.ToList())
{
if (param.categorys.FirstOrDefault()?.name == "作者" && param.categorys.LastOrDefault()?.name == "无")
{
param.categorys.LastOrDefault().name = upProdParam.product.info.param.FirstOrDefault(p => p.categorys.FirstOrDefault()?.name == "出版社名称")?.categorys?.LastOrDefault()?.name;
if (param.categorys.LastOrDefault().name.IsNullOrEmpty())
param.categorys.LastOrDefault().name = "无";
break;
}
}
}
#endregion #endregion
#region sku规格属性 #region sku规格属性
@@ -4160,7 +4177,7 @@ namespace TemuKJD.WXForms.ProductForms
} }
} }
// 微信店采直接复制 // 微信店采直接复制
else if (dbProd.product_get_type_text == "微信店采") //&& upProdParam.product.info.category.FirstOrDefault()?.name != "图书") else if (dbProd.product_get_type_text == "微信店采" && upProdParam.product.info.category.FirstOrDefault()?.name != "图书")
{ {
upProdParam.product.info.qualificationList.Clear(); upProdParam.product.info.qualificationList.Clear();
if (wxEditProdInfo.product?.info?.qualificationList?.Count > 0) if (wxEditProdInfo.product?.info?.qualificationList?.Count > 0)
@@ -4198,9 +4215,10 @@ namespace TemuKJD.WXForms.ProductForms
} }
string publisher = "出版社名称:" + new List<string>() { "技术出版社", "文化出版社", "美术出版社" }[Randomx.GetId(3)]; string publisher = "出版社名称:" + new List<string>() { "技术出版社", "文化出版社", "美术出版社" }[Randomx.GetId(3)];
string isbn = "ISBN:"; //string isbn = "ISBN:";
string bookName = "书名:"; string isbn = "ISBN/CN刊号:";
//string bookName = "图书名称:"; //string bookName = "书名:";
string bookName = "图书名称:";
string bookPrice = "定价:" + upProdParam.product.productSkus.Max(s => s.productSkuInfo.salePrice) * 0.01; string bookPrice = "定价:" + upProdParam.product.productSkus.Max(s => s.productSkuInfo.salePrice) * 0.01;
string author = "作者:王老师"; string author = "作者:王老师";
string publishTime = "出版时间:" + DateTime.Now.AddMonths(-3).ToString("yyyy年MM月dd日"); string publishTime = "出版时间:" + DateTime.Now.AddMonths(-3).ToString("yyyy年MM月dd日");
@@ -4212,10 +4230,20 @@ namespace TemuKJD.WXForms.ProductForms
if (propParam.categorys[0].name.Contains("出版社名称")) if (propParam.categorys[0].name.Contains("出版社名称"))
publisher = "出版社名称:" + propParam.categorys[1].name; publisher = "出版社名称:" + propParam.categorys[1].name;
else if (propParam.categorys[0].name.Contains("ISBN版号/CN刊号")) else if (propParam.categorys[0].name.Contains("ISBN版号/CN刊号"))
isbn = "ISBN:" + propParam.categorys[1].name; {
//isbn = "ISBN:" + propParam.categorys[1].name;
isbn = "ISBN/CN刊号:" + propParam.categorys[1].name;
if (propParam.categorys[1].name.Length == 13)
{
var isbnStr = propParam.categorys[1].name;
isbn = "ISBN/CN刊号:" + isbnStr[0] + isbnStr[1] + isbnStr[2] + "-" + isbnStr[3] + "-" + isbnStr[4] + isbnStr[5] + isbnStr[6] + isbnStr[7] + "-" + isbnStr[8] + isbnStr[9] + isbnStr[10] + isbnStr[11] + "-" + isbnStr[12];
}
}
else if (propParam.categorys[0].name.Contains("书名")) else if (propParam.categorys[0].name.Contains("书名"))
//bookName = "图书名称:" + propParam.categorys[1].name; {
bookName = "书名:" + propParam.categorys[1].name; //bookName = "书名:" + propParam.categorys[1].name;
bookName = "图书名称:" + propParam.categorys[1].name;
}
else if (propParam.categorys[0].name.Contains("定价")) else if (propParam.categorys[0].name.Contains("定价"))
{ {
//bookPrice = "定价:" + propParam.categorys[1].name; //bookPrice = "定价:" + propParam.categorys[1].name;
@@ -4240,17 +4268,58 @@ namespace TemuKJD.WXForms.ProductForms
edition + "\r\n" + "\r\n" + edition + "\r\n" + "\r\n" +
binding; binding;
var bookImg = new Bitmap(800, 800); int imgW = 800; int imgH = 800; int textImgH = 0;
string getImgError;
var img_url = upProdParam.product.info.headImg[0];
if (!img_url.Contains("wst.wxapp.tc.qq.com") && !img_url.Contains("mmecimage.cn"))
img_url = img_url.Replace("https://", "http://");
var imageMain = GetHtml.GetUrlImg(img_url, out getImgError);
if (imageMain == null)
imageMain = new Bitmap(800, 800);
using (Bitmap bitmap = new Bitmap(1, 1)) // 尺寸不重要,只是为了使用Graphics对象
using (Graphics g = Graphics.FromImage(bitmap)) // 获取Graphics对象
{
// 定义字体
Font font = new Font("微软雅黑", 16, FontStyle.Regular);
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
// 定义要测量的字符串
string text = bookStr;
// 测量字符串大小
SizeF size = g.MeasureString(text, font, imgW - 120);
// 输出高度信息
//Console.WriteLine("Text Height: " + size.Height);
textImgH = size.Height.ParseToInt() + 180;
}
//var bookImg = new Bitmap(imgW, imgH);
//using (Graphics g = Graphics.FromImage(bookImg))
//{
// g.Clear(Color.White);
// //Font font = new Font("宋体", 15, FontStyle.Bold);
// //Font font = new Font("微软雅黑", 15, FontStyle.Regular);
// Font font = new Font("微软雅黑", 16, FontStyle.Regular);
// //Font font = new Font("宋体", 17, FontStyle.Bold);
// Brush textBrush = Brushes.Black;
// g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
// RectangleF rectF = new RectangleF(60, 80, imgW - 120, imgH - 180);
// g.DrawString(bookStr, font, textBrush, rectF);
//}
// 绘制一张带主图的商品详情页
var bookImg = new Bitmap(imgW, imgH + textImgH);
using (Graphics g = Graphics.FromImage(bookImg)) using (Graphics g = Graphics.FromImage(bookImg))
{ {
g.Clear(Color.White); g.Clear(Color.FromArgb(248, 239, 244));
g.DrawImage(imageMain, new Rectangle(0, 0, imgW, imgH), 0, 0, imageMain.Width, imageMain.Height, GraphicsUnit.Pixel);
//Font font = new Font("宋体", 15, FontStyle.Bold); //Font font = new Font("宋体", 15, FontStyle.Bold);
Font font = new Font("微软雅黑", 15, FontStyle.Regular); //Font font = new Font("微软雅黑", 15, FontStyle.Regular);
//Font font = new Font("微软雅黑", 16, FontStyle.Regular); Font font = new Font("微软雅黑", 18, FontStyle.Regular);
//Font font = new Font("宋体", 17, FontStyle.Bold); //Font font = new Font("宋体", 17, FontStyle.Bold);
Brush textBrush = Brushes.Black; Brush textBrush = Brushes.Black;
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
RectangleF rectF = new RectangleF(80, 80, 800 - 80, 800 - 80); RectangleF rectF = new RectangleF(60, imgH + 80, imgW - 120, textImgH - 180);
g.DrawString(bookStr, font, textBrush, rectF); g.DrawString(bookStr, font, textBrush, rectF);
} }
@@ -4260,6 +4329,44 @@ namespace TemuKJD.WXForms.ProductForms
return locationStr; return locationStr;
var location = BaseRegex.GetStringJson(ref locationStr, "Location"); var location = BaseRegex.GetStringJson(ref locationStr, "Location");
upProdParam.product.info.qualificationList.Add(new qualificationParam() { qualificationId = "1111485", qualificationUrl = new List<string>() { location }, }); upProdParam.product.info.qualificationList.Add(new qualificationParam() { qualificationId = "1111485", qualificationUrl = new List<string>() { location }, });
#region 将资质图作为主图的最后一张。
using (MemoryStream memoryStream = new MemoryStream())
{
bookImg.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] imageBytes = memoryStream.ToArray();
var imgBase64 = Convert.ToBase64String(imageBytes);
var urlImg = BaseClass.BuildPDDObjString("product/wx_api_upload_image");
var upDate = UserLogin.GetSignaturex();
upDate += "&token=" + token.accessToken;
//upDate += "&is_file=true";
//if (needAddRandomBlock || wantAddRandomBlock)
// upDate += "&random_code=true";
upDate += "&img_url=" + location;
upDate += "&img_base64=" + imgBase64;
var sTime = DateTime.Now;
var apiUpImgFileRst = GetHtml.PostUtf8(urlImg, upDate);
if (cell != null)
{
Invoke(new Action(() =>
{
cell.Value = "正在上传资质图文件 " + (DateTime.Now - sTime).TotalMilliseconds.ParseToInt();
}));
}
for (int i = 0; i < 5 && apiUpImgFileRst.Contains("access_token expired"); i++)
{
token.mdyTime = DateTime.Now.AddDays(-100);
token = new WxApiBLL().GetRandomWxToken();
apiUpImgFileRst = GetHtml.PostUtf8(urlImg, upDate);
}
var upImgUrl = BaseRegex.GetStringJson(ref apiUpImgFileRst, "img_url");
upProdParam.product.info.headImg = upProdParam.product.info.headImg.Take(8).ToList();
upProdParam.product.info.headImg.Add(upImgUrl);
}
#endregion
} }
#endregion #endregion
+84 -70
View File
@@ -32,15 +32,16 @@ namespace TemuKJD.WXForms.ProductForms
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle16 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle17 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle18 = new System.Windows.Forms.DataGridViewCellStyle();
this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.ucGroupBoxEx3 = new TemuKJD.UserComponent.UcGroupBoxEx(this.components); this.ucGroupBoxEx3 = new TemuKJD.UserComponent.UcGroupBoxEx(this.components);
this.btnBatchRealDel = new DevComponents.DotNetBar.PanelEx(); this.btnBatchRealDel = new DevComponents.DotNetBar.PanelEx();
@@ -124,6 +125,8 @@ namespace TemuKJD.WXForms.ProductForms
this.pbLoading = new System.Windows.Forms.PictureBox(); this.pbLoading = new System.Windows.Forms.PictureBox();
this.chkTestNoAuditUpload = new TemuKJD.UserComponent.UcCheckBox(this.components); this.chkTestNoAuditUpload = new TemuKJD.UserComponent.UcCheckBox(this.components);
this.dgvSelectProduct = new TemuKJD.UserComponent.DataGridViewEx(); this.dgvSelectProduct = new TemuKJD.UserComponent.DataGridViewEx();
this.splitContainer4 = new System.Windows.Forms.SplitContainer();
this.statusBar = new TemuKJD.UserControls.StatusBarUserControl();
this.colCheck = new System.Windows.Forms.DataGridViewCheckBoxColumn(); this.colCheck = new System.Windows.Forms.DataGridViewCheckBoxColumn();
this.colSelectId = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.colSelectId = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colSupplierId = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.colSupplierId = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -141,6 +144,7 @@ namespace TemuKJD.WXForms.ProductForms
this.colPromotionLink = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.colPromotionLink = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colProductCat = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.colProductCat = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colExtCode = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.colExtCode = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colSkuMultiPrice = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colPrice = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.colPrice = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colSoldNum = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.colSoldNum = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colMsg = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.colMsg = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -150,8 +154,6 @@ namespace TemuKJD.WXForms.ProductForms
this.ColDelete = new System.Windows.Forms.DataGridViewLinkColumn(); this.ColDelete = new System.Windows.Forms.DataGridViewLinkColumn();
this.colAddTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.colAddTime = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colOpResult = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.colOpResult = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.splitContainer4 = new System.Windows.Forms.SplitContainer();
this.statusBar = new TemuKJD.UserControls.StatusBarUserControl();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout();
@@ -491,7 +493,8 @@ namespace TemuKJD.WXForms.ProductForms
this.btnRestorePrice.StyleMouseOver.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255))))); this.btnRestorePrice.StyleMouseOver.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
this.btnRestorePrice.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255))))); this.btnRestorePrice.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
this.btnRestorePrice.TabIndex = 854; this.btnRestorePrice.TabIndex = 854;
this.btnRestorePrice.Text = "批量设置价格"; this.btnRestorePrice.Text = "批量还原价格";
this.btnRestorePrice.Click += new System.EventHandler(this.btnRestorePrice_Click);
// //
// label7 // label7
// //
@@ -1322,19 +1325,19 @@ namespace TemuKJD.WXForms.ProductForms
// //
this.dgvShop.AllowUserToAddRows = false; this.dgvShop.AllowUserToAddRows = false;
this.dgvShop.AllowUserToDeleteRows = false; this.dgvShop.AllowUserToDeleteRows = false;
dataGridViewCellStyle10.BackColor = System.Drawing.Color.WhiteSmoke; dataGridViewCellStyle1.BackColor = System.Drawing.Color.WhiteSmoke;
this.dgvShop.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle10; this.dgvShop.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
this.dgvShop.AutoRowNumber = true; this.dgvShop.AutoRowNumber = true;
this.dgvShop.BackgroundColor = System.Drawing.Color.White; this.dgvShop.BackgroundColor = System.Drawing.Color.White;
this.dgvShop.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255))))); this.dgvShop.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle11.BackColor = System.Drawing.SystemColors.Control; dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle11.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle11.ForeColor = System.Drawing.SystemColors.WindowText; dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle11.SelectionBackColor = System.Drawing.SystemColors.Highlight; dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle11.SelectionForeColor = System.Drawing.SystemColors.HighlightText; dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle11.WrapMode = System.Windows.Forms.DataGridViewTriState.False; dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dgvShop.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle11; this.dgvShop.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2;
this.dgvShop.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvShop.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvShop.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.dgvShop.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.colSelect, this.colSelect,
@@ -1503,19 +1506,19 @@ namespace TemuKJD.WXForms.ProductForms
// //
this.dgvSelectProduct.AllowUserToAddRows = false; this.dgvSelectProduct.AllowUserToAddRows = false;
this.dgvSelectProduct.AllowUserToDeleteRows = false; this.dgvSelectProduct.AllowUserToDeleteRows = false;
dataGridViewCellStyle12.BackColor = System.Drawing.Color.WhiteSmoke; dataGridViewCellStyle3.BackColor = System.Drawing.Color.WhiteSmoke;
this.dgvSelectProduct.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle12; this.dgvSelectProduct.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3;
this.dgvSelectProduct.AutoRowNumber = true; this.dgvSelectProduct.AutoRowNumber = true;
this.dgvSelectProduct.BackgroundColor = System.Drawing.Color.White; this.dgvSelectProduct.BackgroundColor = System.Drawing.Color.White;
this.dgvSelectProduct.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255))))); this.dgvSelectProduct.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
dataGridViewCellStyle13.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle13.BackColor = System.Drawing.SystemColors.Control; dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle13.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle13.ForeColor = System.Drawing.SystemColors.WindowText; dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle13.SelectionBackColor = System.Drawing.SystemColors.Highlight; dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle13.SelectionForeColor = System.Drawing.SystemColors.HighlightText; dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle13.WrapMode = System.Windows.Forms.DataGridViewTriState.False; dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dgvSelectProduct.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle13; this.dgvSelectProduct.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4;
this.dgvSelectProduct.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvSelectProduct.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvSelectProduct.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.dgvSelectProduct.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.colCheck, this.colCheck,
@@ -1535,6 +1538,7 @@ namespace TemuKJD.WXForms.ProductForms
this.colPromotionLink, this.colPromotionLink,
this.colProductCat, this.colProductCat,
this.colExtCode, this.colExtCode,
this.colSkuMultiPrice,
this.colPrice, this.colPrice,
this.colSoldNum, this.colSoldNum,
this.colMsg, this.colMsg,
@@ -1554,6 +1558,31 @@ namespace TemuKJD.WXForms.ProductForms
this.dgvSelectProduct.TabIndex = 187; this.dgvSelectProduct.TabIndex = 187;
this.dgvSelectProduct.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvSelectProduct_CellContentClick); this.dgvSelectProduct.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvSelectProduct_CellContentClick);
// //
// splitContainer4
//
this.splitContainer4.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer4.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
this.splitContainer4.Location = new System.Drawing.Point(0, 0);
this.splitContainer4.Name = "splitContainer4";
//
// splitContainer4.Panel1
//
this.splitContainer4.Panel1.Controls.Add(this.statusBar);
this.splitContainer4.Size = new System.Drawing.Size(1346, 26);
this.splitContainer4.SplitterDistance = 1165;
this.splitContainer4.TabIndex = 3;
//
// statusBar
//
this.statusBar.BackColor = System.Drawing.Color.White;
this.statusBar.Dock = System.Windows.Forms.DockStyle.Fill;
this.statusBar.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.statusBar.Location = new System.Drawing.Point(0, 0);
this.statusBar.Margin = new System.Windows.Forms.Padding(0);
this.statusBar.Name = "statusBar";
this.statusBar.Size = new System.Drawing.Size(1165, 26);
this.statusBar.TabIndex = 2;
//
// colCheck // colCheck
// //
this.colCheck.Frozen = true; this.colCheck.Frozen = true;
@@ -1580,8 +1609,8 @@ namespace TemuKJD.WXForms.ProductForms
// //
// colSupplierName // colSupplierName
// //
dataGridViewCellStyle14.WrapMode = System.Windows.Forms.DataGridViewTriState.True; dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.colSupplierName.DefaultCellStyle = dataGridViewCellStyle14; this.colSupplierName.DefaultCellStyle = dataGridViewCellStyle5;
this.colSupplierName.Frozen = true; this.colSupplierName.Frozen = true;
this.colSupplierName.HeaderText = "店铺名称"; this.colSupplierName.HeaderText = "店铺名称";
this.colSupplierName.Name = "colSupplierName"; this.colSupplierName.Name = "colSupplierName";
@@ -1669,8 +1698,8 @@ namespace TemuKJD.WXForms.ProductForms
// //
// colProductName // colProductName
// //
dataGridViewCellStyle15.WrapMode = System.Windows.Forms.DataGridViewTriState.True; dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.colProductName.DefaultCellStyle = dataGridViewCellStyle15; this.colProductName.DefaultCellStyle = dataGridViewCellStyle6;
this.colProductName.HeaderText = "商品标题"; this.colProductName.HeaderText = "商品标题";
this.colProductName.Name = "colProductName"; this.colProductName.Name = "colProductName";
this.colProductName.ReadOnly = true; this.colProductName.ReadOnly = true;
@@ -1685,8 +1714,8 @@ namespace TemuKJD.WXForms.ProductForms
// //
// colProductCat // colProductCat
// //
dataGridViewCellStyle16.WrapMode = System.Windows.Forms.DataGridViewTriState.True; dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.colProductCat.DefaultCellStyle = dataGridViewCellStyle16; this.colProductCat.DefaultCellStyle = dataGridViewCellStyle7;
this.colProductCat.HeaderText = "商品类目"; this.colProductCat.HeaderText = "商品类目";
this.colProductCat.Name = "colProductCat"; this.colProductCat.Name = "colProductCat";
this.colProductCat.ReadOnly = true; this.colProductCat.ReadOnly = true;
@@ -1699,8 +1728,17 @@ namespace TemuKJD.WXForms.ProductForms
this.colExtCode.ReadOnly = true; this.colExtCode.ReadOnly = true;
this.colExtCode.Width = 145; this.colExtCode.Width = 145;
// //
// colSkuMultiPrice
//
this.colSkuMultiPrice.HeaderText = "sku价格序列";
this.colSkuMultiPrice.Name = "colSkuMultiPrice";
this.colSkuMultiPrice.ReadOnly = true;
this.colSkuMultiPrice.Visible = false;
//
// colPrice // colPrice
// //
dataGridViewCellStyle8.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.colPrice.DefaultCellStyle = dataGridViewCellStyle8;
this.colPrice.HeaderText = "价格"; this.colPrice.HeaderText = "价格";
this.colPrice.Name = "colPrice"; this.colPrice.Name = "colPrice";
this.colPrice.ReadOnly = true; this.colPrice.ReadOnly = true;
@@ -1715,8 +1753,8 @@ namespace TemuKJD.WXForms.ProductForms
// //
// colMsg // colMsg
// //
dataGridViewCellStyle17.WrapMode = System.Windows.Forms.DataGridViewTriState.True; dataGridViewCellStyle9.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.colMsg.DefaultCellStyle = dataGridViewCellStyle17; this.colMsg.DefaultCellStyle = dataGridViewCellStyle9;
this.colMsg.HeaderText = "状态"; this.colMsg.HeaderText = "状态";
this.colMsg.Name = "colMsg"; this.colMsg.Name = "colMsg";
this.colMsg.ReadOnly = true; this.colMsg.ReadOnly = true;
@@ -1754,8 +1792,8 @@ namespace TemuKJD.WXForms.ProductForms
// //
// colAddTime // colAddTime
// //
dataGridViewCellStyle18.WrapMode = System.Windows.Forms.DataGridViewTriState.True; dataGridViewCellStyle10.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.colAddTime.DefaultCellStyle = dataGridViewCellStyle18; this.colAddTime.DefaultCellStyle = dataGridViewCellStyle10;
this.colAddTime.HeaderText = "上架时间"; this.colAddTime.HeaderText = "上架时间";
this.colAddTime.Name = "colAddTime"; this.colAddTime.Name = "colAddTime";
this.colAddTime.ReadOnly = true; this.colAddTime.ReadOnly = true;
@@ -1768,31 +1806,6 @@ namespace TemuKJD.WXForms.ProductForms
this.colOpResult.ReadOnly = true; this.colOpResult.ReadOnly = true;
this.colOpResult.Width = 240; this.colOpResult.Width = 240;
// //
// splitContainer4
//
this.splitContainer4.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer4.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
this.splitContainer4.Location = new System.Drawing.Point(0, 0);
this.splitContainer4.Name = "splitContainer4";
//
// splitContainer4.Panel1
//
this.splitContainer4.Panel1.Controls.Add(this.statusBar);
this.splitContainer4.Size = new System.Drawing.Size(1346, 26);
this.splitContainer4.SplitterDistance = 1165;
this.splitContainer4.TabIndex = 3;
//
// statusBar
//
this.statusBar.BackColor = System.Drawing.Color.White;
this.statusBar.Dock = System.Windows.Forms.DockStyle.Fill;
this.statusBar.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.statusBar.Location = new System.Drawing.Point(0, 0);
this.statusBar.Margin = new System.Windows.Forms.Padding(0);
this.statusBar.Name = "statusBar";
this.statusBar.Size = new System.Drawing.Size(1165, 26);
this.statusBar.TabIndex = 2;
//
// WXProdPreSaleForm // WXProdPreSaleForm
// //
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
@@ -1921,6 +1934,10 @@ namespace TemuKJD.WXForms.ProductForms
private UserComponent.UcCheckBox chkNotDownCount; private UserComponent.UcCheckBox chkNotDownCount;
private System.Windows.Forms.Label label6; private System.Windows.Forms.Label label6;
private UserComponent.UcCheckBox chkSearchPromotionLink; private UserComponent.UcCheckBox chkSearchPromotionLink;
private System.Windows.Forms.TextBox txtPrice;
private DevComponents.DotNetBar.PanelEx btnSetPrice;
private DevComponents.DotNetBar.PanelEx btnRestorePrice;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.DataGridViewCheckBoxColumn colCheck; private System.Windows.Forms.DataGridViewCheckBoxColumn colCheck;
private System.Windows.Forms.DataGridViewTextBoxColumn colSelectId; private System.Windows.Forms.DataGridViewTextBoxColumn colSelectId;
private System.Windows.Forms.DataGridViewTextBoxColumn colSupplierId; private System.Windows.Forms.DataGridViewTextBoxColumn colSupplierId;
@@ -1938,6 +1955,7 @@ namespace TemuKJD.WXForms.ProductForms
private System.Windows.Forms.DataGridViewTextBoxColumn colPromotionLink; private System.Windows.Forms.DataGridViewTextBoxColumn colPromotionLink;
private System.Windows.Forms.DataGridViewTextBoxColumn colProductCat; private System.Windows.Forms.DataGridViewTextBoxColumn colProductCat;
private System.Windows.Forms.DataGridViewTextBoxColumn colExtCode; private System.Windows.Forms.DataGridViewTextBoxColumn colExtCode;
private System.Windows.Forms.DataGridViewTextBoxColumn colSkuMultiPrice;
private System.Windows.Forms.DataGridViewTextBoxColumn colPrice; private System.Windows.Forms.DataGridViewTextBoxColumn colPrice;
private System.Windows.Forms.DataGridViewTextBoxColumn colSoldNum; private System.Windows.Forms.DataGridViewTextBoxColumn colSoldNum;
private System.Windows.Forms.DataGridViewTextBoxColumn colMsg; private System.Windows.Forms.DataGridViewTextBoxColumn colMsg;
@@ -1947,9 +1965,5 @@ namespace TemuKJD.WXForms.ProductForms
private System.Windows.Forms.DataGridViewLinkColumn ColDelete; private System.Windows.Forms.DataGridViewLinkColumn ColDelete;
private System.Windows.Forms.DataGridViewTextBoxColumn colAddTime; private System.Windows.Forms.DataGridViewTextBoxColumn colAddTime;
private System.Windows.Forms.DataGridViewTextBoxColumn colOpResult; private System.Windows.Forms.DataGridViewTextBoxColumn colOpResult;
private System.Windows.Forms.TextBox txtPrice;
private DevComponents.DotNetBar.PanelEx btnSetPrice;
private DevComponents.DotNetBar.PanelEx btnRestorePrice;
private System.Windows.Forms.Label label7;
} }
} }
+239 -28
View File
@@ -92,6 +92,10 @@ namespace TemuKJD.WXForms.ProductForms
if (wxUploadRule == null) if (wxUploadRule == null)
wxUploadRule = new WXUploadRule(); wxUploadRule = new WXUploadRule();
dicProductBasePrice = NaiBa.Util.Helper.ConfigHelper.LoadConfig<Dictionary<string,string>>("wx_product_base_price");
if (dicProductBasePrice == null)
dicProductBasePrice = new Dictionary<string, string>();
this.txtPreDays.TextChanged -= txtPreDays_TextChanged; this.txtPreDays.TextChanged -= txtPreDays_TextChanged;
this.chkPreSale.CheckedChanged -= chkPreSale_CheckedChanged; this.chkPreSale.CheckedChanged -= chkPreSale_CheckedChanged;
this.chkNoPreSale.CheckedChanged -= chkNoPreSale_CheckedChanged; this.chkNoPreSale.CheckedChanged -= chkNoPreSale_CheckedChanged;
@@ -782,8 +786,8 @@ namespace TemuKJD.WXForms.ProductForms
var pStr = JsonHelper.SerializeObject(prod); var pStr = JsonHelper.SerializeObject(prod);
Invoke(new Action(() => Invoke(new Action(() =>
{ {
decimal? price = null; decimal? minPrice = prod["skuList"]?.Min(sk => sk["price"].ParseToDecimal() / 100);
try { price = prod["skuList"]?[0]["price"].ParseToDecimal() / 100; } catch { } decimal? maxPrice = prod["skuList"]?.Max(sk => sk["price"].ParseToDecimal() / 100);
var prodId = prod["productId"].ParseToString(); var prodId = prod["productId"].ParseToString();
if (dgvSelectProduct.Rows.Cast<DataGridViewRow>().Any(r => r.Cells["colDraftId"].ParseToString() == prodId)) if (dgvSelectProduct.Rows.Cast<DataGridViewRow>().Any(r => r.Cells["colDraftId"].ParseToString() == prodId))
{ {
@@ -826,8 +830,9 @@ namespace TemuKJD.WXForms.ProductForms
(prod["recommendCategory"].IsJTokenNullOrEmpty() || prod["recommendCategory"]["categoryNames"].IsJTokenNullOrEmpty()) ? (prod["recommendCategory"].IsJTokenNullOrEmpty() || prod["recommendCategory"]["categoryNames"].IsJTokenNullOrEmpty()) ?
"" : string.Join(" >> ", prod["recommendCategory"]["categoryNames"].Select(s => s.ParseToString())), // 类目名称 "" : string.Join(" >> ", prod["recommendCategory"]["categoryNames"].Select(s => s.ParseToString())), // 类目名称
prod["spuCode"].ParseToString(), prod["spuCode"].ParseToString(),
//price, prod["skuList"].ParseToString(),
prod["price"].ParseToDecimal() * 0.01m, //prod["price"].ParseToDecimal() * 0.01m,
"" + minPrice + " - " + maxPrice,
prod["soldNum"].ParseToInt(), prod["soldNum"].ParseToInt(),
StatusStr, StatusStr,
prod["presaleTag"].ParseToInt() == 1 ? "[预售]" : "", prod["presaleTag"].ParseToInt() == 1 ? "[预售]" : "",
@@ -1661,7 +1666,7 @@ namespace TemuKJD.WXForms.ProductForms
cancellationTokenSource = new CancellationTokenSource(); cancellationTokenSource = new CancellationTokenSource();
Task.Run(() => Task.Run(() =>
{ {
SetProdDown(rowLst); ChangeProdPrice(rowLst);
Invoke(new Action(() => Invoke(new Action(() =>
{ {
if (cancellationTokenSource.IsCancellationRequested) if (cancellationTokenSource.IsCancellationRequested)
@@ -1682,7 +1687,8 @@ namespace TemuKJD.WXForms.ProductForms
} }
void SetProdPrice(List<DataGridViewRow> rowLst) Dictionary<string, string> dicProductBasePrice = new Dictionary<string, string>();
void ChangeProdPrice(List<DataGridViewRow> rowLst)
{ {
Invoke(new Action(() => Invoke(new Action(() =>
{ {
@@ -1740,11 +1746,20 @@ namespace TemuKJD.WXForms.ProductForms
foreach (var row in rowLstTmp) foreach (var row in rowLstTmp)
{ {
var prodId = row.Cells["colDraftId"].Value.ParseToString(); var prodId = row.Cells["colDraftId"].Value.ParseToString();
prodIdLst.Add(prodId); var skuPricesStr = row.Cells["colSkuMultiPrice"].Value.ParseToString();
var newPrice = txtPrice.Text.ParseToDecimal();
if (dicProductBasePrice.ContainsKey(prodId))
{
Invoke(new Action(() =>
{
row.Cells["colOpResult"].Value = "商品改价未还原,跳过";
}));
continue;
} }
var downProdRst = WXPreSale.DownProd(shop, string.Join(",", prodIdLst)); var downProdRst = changePrice(shop, prodId, skuPricesStr, (newPrice * 100).ParseToInt());
Thread.Sleep(Randomx.GetId(1000, 1500)); Thread.Sleep(Randomx.GetId(200, 500));
if (!downProdRst.Contains("\"code\":0")) if (!downProdRst.Contains("\"code\":0"))
{ {
if (downProdRst.Contains("biz magic invalid")) if (downProdRst.Contains("biz magic invalid"))
@@ -1754,12 +1769,12 @@ namespace TemuKJD.WXForms.ProductForms
{ {
Invoke(new Action(() => Invoke(new Action(() =>
{ {
foreach (var row in rowLstTmp) foreach (var r in rowLstTmp)
{ {
row.Cells["colOpResult"].Value = "店铺掉线"; r.Cells["colOpResult"].Value = "店铺掉线";
} }
})); }));
continue; break;
} }
} }
@@ -1769,31 +1784,227 @@ namespace TemuKJD.WXForms.ProductForms
Invoke(new Action(() => Invoke(new Action(() =>
{ {
foreach (var row in rowLstTmp) row.Cells["colOpResult"].Value = "修改价格失败" + errmsg;
{
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;
}
})); }));
} }
// 改价成功
else
{
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;
}));
}
}
}
}
if (downProdRst.Contains("\"code\":0")) /// <summary>
/// 修改成指定价格或者还原缓存的原来价格
/// </summary>
/// <param name="shop"></param>
/// <param name="spuId"></param>
/// <param name="skuPrices"></param>
/// <param name="newPrice">新价格 单位分</param>
/// <param name="isRestore">是否是还原价格</param>
/// <returns></returns>
private string changePrice(ShopLoginInfo shop, string spuId, string skuPrices, int newPrice, bool isRestore = false)
{
try
{
var skuListObj = JArray.Parse(skuPrices);
JObject changePriceObj = new JObject();
JArray skuArr = new JArray();
foreach (var sku in skuListObj)
{
JObject obj = new JObject();
obj["spuId"] = spuId;
obj["skuId"] = sku["skuId"];
if (isRestore)
obj["salePrice"] = sku["price"].ParseToInt();
else
obj["salePrice"] = newPrice;
skuArr.Add(obj);
}
changePriceObj["skuList"] = skuArr;
changePriceObj["uploadSource"] = 6;
// string body = @"{""skuList"":[{""spuId"":" + spuId + @",""skuId"":""" + skuId + @""",""salePrice"":" + newPrice + @"}],""uploadSource"":6}";
var rst = OrderForms.WXOrderList.EditPrice(shop, changePriceObj);
if (rst.Contains("\"code\":0"))
{
return rst;
}
else
{
return rst;
}
}
catch (Exception ex)
{
return ex.Message;
}
}
private void btnRestorePrice_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(() =>
{
RestoreProdPrice(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 RestoreProdPrice(List<DataGridViewRow> rowLst)
{ {
Invoke(new Action(() => Invoke(new Action(() =>
{ {
foreach (var row in rowLstTmp) 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)
{ {
row.Cells["colOpResult"].Value = "修改价格成功"; 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();
if (!dicProductBasePrice.ContainsKey(prodId))
{
Invoke(new Action(() =>
{
row.Cells["colOpResult"].Value = "未找到价格修改记录,无法还原,跳过";
}));
continue;
}
var skuPricesStr = dicProductBasePrice[prodId];
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"))
{
WXShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false);
if (shop.LoginStatus != "登录成功")
{
Invoke(new Action(() =>
{
foreach (var r in rowLstTmp)
{
r.Cells["colOpResult"].Value = "店铺掉线";
}
}));
break;
}
}
var errmsg = BaseRegex.GetStringJson(ref downProdRst, "msg");
if (string.IsNullOrWhiteSpace(errmsg))
errmsg = downProdRst;
Invoke(new Action(() =>
{
row.Cells["colOpResult"].Value = "还原失败" + errmsg;
}));
}
// 还原价格成功
else
{
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);
}));
}
} }
} }
} }
@@ -204,6 +204,9 @@
<metadata name="colExtCode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="colExtCode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="colSkuMultiPrice.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colPrice.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="colPrice.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>