动态随机换图,上传后还原图片和标题功能
This commit is contained in:
1 parent
2a4a3ef744
commit
8135f50686
17 files changed
+2034
-50
No files matched your search
+108
-18
@@ -39,6 +39,11 @@
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DbProductSelectListManageForm));
|
||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||
this.lblCustomImgNum = new System.Windows.Forms.Label();
|
||||
this.btnCustomImg = new DevComponents.DotNetBar.PanelEx();
|
||||
this.label14 = new System.Windows.Forms.Label();
|
||||
this.numSeconds = new System.Windows.Forms.NumericUpDown();
|
||||
this.chkCustomPic = new TemuKJD.UserComponent.UcCheckBox(this.components);
|
||||
this.btnDel = new DevComponents.DotNetBar.PanelEx();
|
||||
this.btnReFission = new TemuKJD.UserControls.ButtonEx();
|
||||
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||
@@ -73,6 +78,7 @@
|
||||
this.chkSkuRandomPrice = new TemuKJD.UserComponent.UcCheckBox(this.components);
|
||||
this.numSkuRandomPrice = new System.Windows.Forms.NumericUpDown();
|
||||
this.label11 = new System.Windows.Forms.Label();
|
||||
this.chkOriginalPriceMarkUp = new TemuKJD.UserComponent.UcCheckBox(this.components);
|
||||
this.pnlEmpty = new DevComponents.DotNetBar.PanelEx();
|
||||
this.btnSearch = new TemuKJD.UserControls.ButtonEx();
|
||||
this.cmbUserNotes = new System.Windows.Forms.ComboBox();
|
||||
@@ -113,11 +119,11 @@
|
||||
this.colOpResult = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.ucSplitPage1 = new TemuKJD.UserControls.UcSplitPage();
|
||||
this.statusBar = new TemuKJD.UserControls.StatusBarUserControl();
|
||||
this.chkOriginalPriceMarkUp = new TemuKJD.UserComponent.UcCheckBox(this.components);
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
||||
this.splitContainer1.Panel1.SuspendLayout();
|
||||
this.splitContainer1.Panel2.SuspendLayout();
|
||||
this.splitContainer1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numSeconds)).BeginInit();
|
||||
this.tableLayoutPanel1.SuspendLayout();
|
||||
this.flowLayoutPanel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numSkuRandomPrice)).BeginInit();
|
||||
@@ -140,6 +146,11 @@
|
||||
//
|
||||
// splitContainer1.Panel1
|
||||
//
|
||||
this.splitContainer1.Panel1.Controls.Add(this.lblCustomImgNum);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.btnCustomImg);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.label14);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.numSeconds);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.chkCustomPic);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.btnDel);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.btnReFission);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.tableLayoutPanel1);
|
||||
@@ -150,9 +161,81 @@
|
||||
//
|
||||
this.splitContainer1.Panel2.Controls.Add(this.splitContainer2);
|
||||
this.splitContainer1.Size = new System.Drawing.Size(1558, 638);
|
||||
this.splitContainer1.SplitterDistance = 70;
|
||||
this.splitContainer1.SplitterDistance = 100;
|
||||
this.splitContainer1.TabIndex = 2;
|
||||
//
|
||||
// lblCustomImgNum
|
||||
//
|
||||
this.lblCustomImgNum.AutoSize = true;
|
||||
this.lblCustomImgNum.Location = new System.Drawing.Point(349, 74);
|
||||
this.lblCustomImgNum.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
|
||||
this.lblCustomImgNum.Name = "lblCustomImgNum";
|
||||
this.lblCustomImgNum.Size = new System.Drawing.Size(95, 17);
|
||||
this.lblCustomImgNum.TabIndex = 484;
|
||||
this.lblCustomImgNum.Text = "自定义图片 0 张";
|
||||
//
|
||||
// btnCustomImg
|
||||
//
|
||||
this.btnCustomImg.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
this.btnCustomImg.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.btnCustomImg.DisabledBackColor = System.Drawing.Color.Empty;
|
||||
this.btnCustomImg.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.btnCustomImg.Location = new System.Drawing.Point(242, 69);
|
||||
this.btnCustomImg.Name = "btnCustomImg";
|
||||
this.btnCustomImg.Size = new System.Drawing.Size(106, 26);
|
||||
this.btnCustomImg.Style.Alignment = System.Drawing.StringAlignment.Center;
|
||||
this.btnCustomImg.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
|
||||
this.btnCustomImg.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
|
||||
this.btnCustomImg.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder;
|
||||
this.btnCustomImg.Style.BorderDashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
|
||||
this.btnCustomImg.Style.BorderSide = DevComponents.DotNetBar.eBorderSide.None;
|
||||
this.btnCustomImg.Style.ForeColor.Color = System.Drawing.Color.White;
|
||||
this.btnCustomImg.Style.GradientAngle = 90;
|
||||
this.btnCustomImg.StyleMouseOver.Alignment = System.Drawing.StringAlignment.Center;
|
||||
this.btnCustomImg.StyleMouseOver.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
|
||||
this.btnCustomImg.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
|
||||
this.btnCustomImg.TabIndex = 483;
|
||||
this.btnCustomImg.Text = "设置自定义图片";
|
||||
this.btnCustomImg.Click += new System.EventHandler(this.btnCustomImg_Click);
|
||||
//
|
||||
// label14
|
||||
//
|
||||
this.label14.AutoSize = true;
|
||||
this.label14.Location = new System.Drawing.Point(183, 74);
|
||||
this.label14.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
|
||||
this.label14.Name = "label14";
|
||||
this.label14.Size = new System.Drawing.Size(56, 17);
|
||||
this.label14.TabIndex = 479;
|
||||
this.label14.Text = "秒后还原";
|
||||
//
|
||||
// numSeconds
|
||||
//
|
||||
this.numSeconds.Location = new System.Drawing.Point(137, 71);
|
||||
this.numSeconds.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3);
|
||||
this.numSeconds.Maximum = new decimal(new int[] {
|
||||
1000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numSeconds.Name = "numSeconds";
|
||||
this.numSeconds.Size = new System.Drawing.Size(44, 23);
|
||||
this.numSeconds.TabIndex = 478;
|
||||
this.numSeconds.Value = new decimal(new int[] {
|
||||
35,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// chkCustomPic
|
||||
//
|
||||
this.chkCustomPic.Location = new System.Drawing.Point(8, 72);
|
||||
this.chkCustomPic.Margin = new System.Windows.Forms.Padding(2, 0, 0, 0);
|
||||
this.chkCustomPic.Name = "chkCustomPic";
|
||||
this.chkCustomPic.Size = new System.Drawing.Size(135, 21);
|
||||
this.chkCustomPic.TabIndex = 477;
|
||||
this.chkCustomPic.Text = "使用自定义图片并在";
|
||||
this.chkCustomPic.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// btnDel
|
||||
//
|
||||
this.btnDel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
@@ -625,6 +708,18 @@
|
||||
this.label11.TabIndex = 471;
|
||||
this.label11.Text = "元";
|
||||
//
|
||||
// chkOriginalPriceMarkUp
|
||||
//
|
||||
this.chkOriginalPriceMarkUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.chkOriginalPriceMarkUp.AutoSize = true;
|
||||
this.chkOriginalPriceMarkUp.Location = new System.Drawing.Point(883, 4);
|
||||
this.chkOriginalPriceMarkUp.Margin = new System.Windows.Forms.Padding(2, 0, 0, 0);
|
||||
this.chkOriginalPriceMarkUp.Name = "chkOriginalPriceMarkUp";
|
||||
this.chkOriginalPriceMarkUp.Size = new System.Drawing.Size(95, 21);
|
||||
this.chkOriginalPriceMarkUp.TabIndex = 469;
|
||||
this.chkOriginalPriceMarkUp.Text = "sku原价加价";
|
||||
this.chkOriginalPriceMarkUp.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// pnlEmpty
|
||||
//
|
||||
this.pnlEmpty.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
|
||||
@@ -785,15 +880,15 @@
|
||||
//
|
||||
this.splitContainer2.Panel2.Controls.Add(this.ucSplitPage1);
|
||||
this.splitContainer2.Panel2.Controls.Add(this.statusBar);
|
||||
this.splitContainer2.Size = new System.Drawing.Size(1558, 564);
|
||||
this.splitContainer2.SplitterDistance = 535;
|
||||
this.splitContainer2.Size = new System.Drawing.Size(1558, 534);
|
||||
this.splitContainer2.SplitterDistance = 505;
|
||||
this.splitContainer2.TabIndex = 0;
|
||||
//
|
||||
// pbLoading
|
||||
//
|
||||
this.pbLoading.Anchor = System.Windows.Forms.AnchorStyles.None;
|
||||
this.pbLoading.Image = global::TemuKJD.Properties.Resources.loading_blue;
|
||||
this.pbLoading.Location = new System.Drawing.Point(754, 242);
|
||||
this.pbLoading.Location = new System.Drawing.Point(754, 227);
|
||||
this.pbLoading.Name = "pbLoading";
|
||||
this.pbLoading.Size = new System.Drawing.Size(50, 50);
|
||||
this.pbLoading.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||||
@@ -850,7 +945,7 @@
|
||||
this.dgvSelectProduct.ReadOnly = true;
|
||||
this.dgvSelectProduct.RowHeadersWidth = 40;
|
||||
this.dgvSelectProduct.RowTemplate.Height = 23;
|
||||
this.dgvSelectProduct.Size = new System.Drawing.Size(1550, 535);
|
||||
this.dgvSelectProduct.Size = new System.Drawing.Size(1550, 505);
|
||||
this.dgvSelectProduct.TabIndex = 189;
|
||||
this.dgvSelectProduct.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvSelectProduct_CellContentClick);
|
||||
this.dgvSelectProduct.Scroll += new System.Windows.Forms.ScrollEventHandler(this.dgvSelectProduct_Scroll);
|
||||
@@ -1088,18 +1183,6 @@
|
||||
this.statusBar.Size = new System.Drawing.Size(1558, 25);
|
||||
this.statusBar.TabIndex = 5;
|
||||
//
|
||||
// chkOriginalPriceMarkUp
|
||||
//
|
||||
this.chkOriginalPriceMarkUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.chkOriginalPriceMarkUp.AutoSize = true;
|
||||
this.chkOriginalPriceMarkUp.Location = new System.Drawing.Point(883, 4);
|
||||
this.chkOriginalPriceMarkUp.Margin = new System.Windows.Forms.Padding(2, 0, 0, 0);
|
||||
this.chkOriginalPriceMarkUp.Name = "chkOriginalPriceMarkUp";
|
||||
this.chkOriginalPriceMarkUp.Size = new System.Drawing.Size(95, 21);
|
||||
this.chkOriginalPriceMarkUp.TabIndex = 469;
|
||||
this.chkOriginalPriceMarkUp.Text = "sku原价加价";
|
||||
this.chkOriginalPriceMarkUp.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// DbProductSelectListManageForm
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
@@ -1114,9 +1197,11 @@
|
||||
this.VisibleChanged += new System.EventHandler(this.DbProductSelectListManageForm_VisibleChanged);
|
||||
this.Controls.SetChildIndex(this.splitContainer1, 0);
|
||||
this.splitContainer1.Panel1.ResumeLayout(false);
|
||||
this.splitContainer1.Panel1.PerformLayout();
|
||||
this.splitContainer1.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
|
||||
this.splitContainer1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.numSeconds)).EndInit();
|
||||
this.tableLayoutPanel1.ResumeLayout(false);
|
||||
this.tableLayoutPanel1.PerformLayout();
|
||||
this.flowLayoutPanel1.ResumeLayout(false);
|
||||
@@ -1210,5 +1295,10 @@
|
||||
private System.Windows.Forms.ComboBox cmbNotes;
|
||||
private DevComponents.DotNetBar.PanelEx btnDel;
|
||||
private UserComponent.UcCheckBox chkOriginalPriceMarkUp;
|
||||
private System.Windows.Forms.Label label14;
|
||||
private System.Windows.Forms.NumericUpDown numSeconds;
|
||||
private UserComponent.UcCheckBox chkCustomPic;
|
||||
private System.Windows.Forms.Label lblCustomImgNum;
|
||||
private DevComponents.DotNetBar.PanelEx btnCustomImg;
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,8 @@ namespace TemuKJD.KJDForms.ProductSelectForms
|
||||
List<TemuDBProductSelect> lstAdminTemuDBProductSelect = new List<TemuDBProductSelect>();
|
||||
List<ShopLoginInfo> shopLst = new List<ShopLoginInfo>();
|
||||
List<TemuDBPriceInfo> lstDbPrice = new List<TemuDBPriceInfo>();
|
||||
List<string> lstCustomImg = new List<string>();
|
||||
Dictionary<string, string> dicCustomImg = new Dictionary<string, string>();
|
||||
|
||||
public DbProductSelectListManageForm()
|
||||
{
|
||||
@@ -489,6 +491,12 @@ namespace TemuKJD.KJDForms.ProductSelectForms
|
||||
|
||||
private void btnAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (chkCustomPic.Checked && lstCustomImg.Count <= 0)
|
||||
{
|
||||
BaseMsgForm.ShowError("请选择自定义图片!");
|
||||
return;
|
||||
}
|
||||
|
||||
var lstProdId = dgvSelectProduct.Rows.Cast<DataGridViewRow>().Where(row
|
||||
=> row.Cells["colSelect"]?.Value.ParseToBool() == true).Select(r => r.Cells["colSelectId"]?.Value.ToString()).ToList();
|
||||
var prodList = this.lstAdminTemuDBProductSelect.Where(p => lstProdId.Contains(p.id.ParseToString())).ToArray();
|
||||
@@ -807,6 +815,22 @@ namespace TemuKJD.KJDForms.ProductSelectForms
|
||||
prodParam.carouselImageI18nReqs = prodInfo.carouselImageI18nVOList;
|
||||
prodParam.carouselImageUrls = prodInfo.carouselImageUrls;
|
||||
|
||||
List<ProductSkuReqsItem> realSkuItems = new List<ProductSkuReqsItem>();
|
||||
List<string> realCarouselImageUrls = new List<string>();
|
||||
realCarouselImageUrls.AddRange(prodInfo.carouselImageUrls);
|
||||
|
||||
if (chkCustomPic.Checked)
|
||||
{
|
||||
for (int i = 0; i < prodParam.carouselImageUrls.Count; i++)
|
||||
{
|
||||
var imgUrlRst = GetCustomImg(shop, prodParam.productDraftId.ParseToString());
|
||||
if (imgUrlRst.Contains("\"success\":false"))
|
||||
return imgUrlRst;
|
||||
prodParam.carouselImageUrls[i] = imgUrlRst;
|
||||
Thread.Sleep(Randomx.GetId(50, 100));
|
||||
}
|
||||
}
|
||||
|
||||
prodParam.goodsAdvantageLabelTypes = prodInfo.goodsAdvantageLabelVOList != null ?
|
||||
prodInfo.goodsAdvantageLabelVOList : new List<object>();
|
||||
prodParam.goodsLayerDecorationCustomizeI18nReqs = prodInfo.goodsLayerDecorationCustomizeI18nVOList;
|
||||
@@ -837,6 +861,11 @@ namespace TemuKJD.KJDForms.ProductSelectForms
|
||||
}
|
||||
prodParam.goodsModelReqs = prodInfo.goodsModelList != null ? prodInfo.goodsModelList : new List<object>();
|
||||
prodParam.materialImgUrl = prodInfo.materialImgUrl;
|
||||
if (chkCustomPic.Checked)
|
||||
{
|
||||
if (prodParam.carouselImageUrls != null && prodParam.carouselImageUrls.Count > 0)
|
||||
prodParam.materialImgUrl = prodParam.carouselImageUrls[0];
|
||||
}
|
||||
prodParam.materialMultiLanguages = prodInfo.productLocalExtAttr.materialMultiLanguages != null ?
|
||||
prodInfo.productLocalExtAttr.materialMultiLanguages : new List<object>();
|
||||
prodParam.personalizationSwitch = prodInfo.productWhExtAttr.personalizationSwitch.ParseToInt();
|
||||
@@ -1203,6 +1232,18 @@ namespace TemuKJD.KJDForms.ProductSelectForms
|
||||
#endregion
|
||||
|
||||
skuItem.thumbUrl = skuInfo.thumbUrl;
|
||||
// 自定义sku图
|
||||
if (chkCustomPic.Checked)
|
||||
{
|
||||
var skuCopy = JsonHelper.DeserializeJsonToObject<ProductSkuReqsItem>(JsonHelper.SerializeObject(skuItem));
|
||||
realSkuItems.Add(skuCopy);
|
||||
|
||||
var imgUrlRst = GetCustomImg(shop, prodParam.productDraftId.ParseToString());
|
||||
if (imgUrlRst.Contains("\"success\":false"))
|
||||
return imgUrlRst;
|
||||
skuItem.thumbUrl = imgUrlRst;
|
||||
Thread.Sleep(Randomx.GetId(50, 100));
|
||||
}
|
||||
|
||||
skcItem.productSkuReqs.Add(skuItem);
|
||||
}
|
||||
@@ -1263,6 +1304,42 @@ namespace TemuKJD.KJDForms.ProductSelectForms
|
||||
{
|
||||
if (!chkUploadProd.Checked)
|
||||
{
|
||||
#region 使用草稿箱模拟上传后改图
|
||||
if (chkCustomPic.Checked)
|
||||
{
|
||||
prodParam.carouselImageUrls = realCarouselImageUrls;
|
||||
prodParam.productSkcReqs[0].productSkuReqs = realSkuItems;
|
||||
var index = prodParam.productName.ParseToString().IndexOf(dbProd.product_name);
|
||||
if (index >= 0)
|
||||
prodParam.productName = prodParam.productName.Substring(index);
|
||||
if (prodParam.carouselImageUrls != null && prodParam.carouselImageUrls.Count > 0)
|
||||
prodParam.materialImgUrl = prodParam.carouselImageUrls[0];
|
||||
Task.Run(() =>
|
||||
{
|
||||
var cell2 = cell;
|
||||
var realprodParam = JsonHelper.DeserializeJsonToObject<TemuProductParam>(JsonHelper.SerializeObject(prodParam));
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
cell2.Value = "正在还原图片";
|
||||
}));
|
||||
Thread.Sleep(numSeconds.Value.ParseToInt() * 1000);
|
||||
|
||||
var rst = SaveDraft(shop, prodParam.productDraftId.ToString(), realprodParam);
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
if (rst.Contains("\"success\":true"))
|
||||
cell2.Value = "还原草稿图片成功";
|
||||
else
|
||||
{
|
||||
var error = BaseRegex.GetStringJson(ref html, "errorMsg");
|
||||
if (string.IsNullOrEmpty(error))
|
||||
error = BaseRegex.GetStringJson(ref html, "error_msg");
|
||||
cell2.Value = "还原草稿图片失败 " + error;
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
return "{\"success\":true,\"status\":\"草稿箱\"," +
|
||||
"\"productDraftId\":\"" + prodParam.productDraftId.ParseToString() + "\"," +
|
||||
"\"errMsg\":\"" + sizeError + "\"}";
|
||||
@@ -1290,6 +1367,49 @@ namespace TemuKJD.KJDForms.ProductSelectForms
|
||||
html = AddProduct(shop, prodParam.productDraftId.ToString(), prodParam);
|
||||
if (html.Contains("\"success\":true"))
|
||||
{
|
||||
if (chkCustomPic.Checked)
|
||||
{
|
||||
prodParam.carouselImageUrls = realCarouselImageUrls;
|
||||
prodParam.productSkcReqs[0].productSkuReqs = realSkuItems;
|
||||
var index = prodParam.productName.ParseToString().IndexOf(dbProd.product_name);
|
||||
if (index >= 0)
|
||||
prodParam.productName = prodParam.productName.Substring(index);
|
||||
if (prodParam.carouselImageUrls != null && prodParam.carouselImageUrls.Count > 0)
|
||||
prodParam.materialImgUrl = prodParam.carouselImageUrls[0];
|
||||
Task.Run(() =>
|
||||
{
|
||||
var cell2 = cell;
|
||||
var realprodParam = JsonHelper.DeserializeJsonToObject<TemuProductParam>(JsonHelper.SerializeObject(prodParam));
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
cell2.Value = "正在还原图片";
|
||||
}));
|
||||
Thread.Sleep(numSeconds.Value.ParseToInt() * 1000);
|
||||
|
||||
var rst = EditProduct(shop, prodParam.productDraftId.ToString(), realprodParam);
|
||||
if (!rst.Contains("\"success\":true"))
|
||||
{
|
||||
Thread.Sleep(5000);
|
||||
rst = EditProduct(shop, prodParam.productDraftId.ToString(), realprodParam);
|
||||
}
|
||||
if (!rst.Contains("\"success\":true"))
|
||||
{
|
||||
rst = EditProduct(shop, prodParam.productDraftId.ToString(), realprodParam);
|
||||
}
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
if (rst.Contains("\"success\":true"))
|
||||
cell2.Value = "还原图片成功";
|
||||
else
|
||||
{
|
||||
var error2 = BaseRegex.GetStringJson(ref html, "errorMsg");
|
||||
if (string.IsNullOrEmpty(error2))
|
||||
error2 = BaseRegex.GetStringJson(ref html, "error_msg");
|
||||
cell2.Value = "还原图片失败 " + error2;
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
return "{\"success\":true,\"status\":\"已上传\"," +
|
||||
"\"productDraftId\":\"" + prodParam.productDraftId.ParseToString() + "\"," +
|
||||
"\"errMsg\":\"" + sizeError + "\"}";
|
||||
@@ -1299,6 +1419,44 @@ namespace TemuKJD.KJDForms.ProductSelectForms
|
||||
var error = BaseRegex.GetStringJson(ref html, "errorMsg");
|
||||
if (string.IsNullOrWhiteSpace(error))
|
||||
error = BaseRegex.GetStringJson(ref html, "error_msg");
|
||||
|
||||
#region 传失败了在草稿箱,使用草稿箱模拟上传后改图
|
||||
if (chkCustomPic.Checked)
|
||||
{
|
||||
prodParam.carouselImageUrls = realCarouselImageUrls;
|
||||
prodParam.productSkcReqs[0].productSkuReqs = realSkuItems;
|
||||
var index = prodParam.productName.ParseToString().IndexOf(dbProd.product_name);
|
||||
if (index >= 0)
|
||||
prodParam.productName = prodParam.productName.Substring(index);
|
||||
if (prodParam.carouselImageUrls != null && prodParam.carouselImageUrls.Count > 0)
|
||||
prodParam.materialImgUrl = prodParam.carouselImageUrls[0];
|
||||
Task.Run(() =>
|
||||
{
|
||||
var cell2 = cell;
|
||||
var realprodParam = JsonHelper.DeserializeJsonToObject<TemuProductParam>(JsonHelper.SerializeObject(prodParam));
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
cell2.Value = "正在还原图片";
|
||||
}));
|
||||
Thread.Sleep(numSeconds.Value.ParseToInt() * 1000);
|
||||
|
||||
var rst = SaveDraft(shop, prodParam.productDraftId.ToString(), realprodParam);
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
if (rst.Contains("\"success\":true"))
|
||||
cell2.Value = "还原草稿图片成功";
|
||||
else
|
||||
{
|
||||
var error2 = BaseRegex.GetStringJson(ref html, "errorMsg");
|
||||
if (string.IsNullOrEmpty(error2))
|
||||
error2 = BaseRegex.GetStringJson(ref html, "error_msg");
|
||||
cell2.Value = "还原草稿图片失败 " + error;
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
// 这里上传草稿一定成功了,所以返回true,但是有错误信息
|
||||
return "{\"success\":true,\"status\":\"草稿箱\"," +
|
||||
"\"productDraftId\":\"" + prodParam.productDraftId.ParseToString() + "\"," +
|
||||
@@ -1307,6 +1465,71 @@ namespace TemuKJD.KJDForms.ProductSelectForms
|
||||
#endregion
|
||||
}
|
||||
|
||||
string GetCustomImg(ShopLoginInfo shop, string productDraftId)
|
||||
{
|
||||
var sImgPath = this.lstCustomImg[Randomx.GetId(lstCustomImg.Count)];
|
||||
if (dicCustomImg.Keys.Contains(sImgPath))
|
||||
return dicCustomImg[sImgPath];
|
||||
|
||||
var md5CheckRst = CheckImgMd5(shop, productDraftId, "", BaseClass.GetFileMd5(sImgPath));
|
||||
if (!md5CheckRst.Contains("\"success\":true"))
|
||||
{
|
||||
var error = BaseRegex.GetStringJson(ref md5CheckRst, "errorMsg");
|
||||
if (string.IsNullOrEmpty(error))
|
||||
error = BaseRegex.GetStringJson(ref md5CheckRst, "error_msg");
|
||||
return "{\"success\":false,\"status\":\"未上传\"," +
|
||||
"\"productDraftId\":\"" + productDraftId + "\"," +
|
||||
"\"errMsg\":\"草稿箱上传失败 " + error + "\"}";
|
||||
}
|
||||
var materialId = BaseRegex.GetStringJson(ref md5CheckRst, "id");
|
||||
if (string.IsNullOrEmpty(materialId))
|
||||
{
|
||||
var imgUpSignRst = GetImgUpSign(shop, productDraftId);
|
||||
string signature = BaseRegex.GetStringJson(ref imgUpSignRst, "signature");
|
||||
if (string.IsNullOrEmpty(signature))
|
||||
{
|
||||
var error = BaseRegex.GetStringJson(ref imgUpSignRst, "errorMsg");
|
||||
if (string.IsNullOrEmpty(error))
|
||||
error = BaseRegex.GetStringJson(ref imgUpSignRst, "error_msg");
|
||||
return "{\"success\":false,\"status\":\"未上传\"," +
|
||||
"\"productDraftId\":\"" + productDraftId + "\"," +
|
||||
"\"errMsg\":\"草稿箱上传失败,获取图片上传signature失败 " + error + "\"}";
|
||||
}
|
||||
var uploadImgRst = UploadImage(shop, productDraftId, sImgPath, signature);
|
||||
var imgUrl = BaseRegex.GetStringJson(ref uploadImgRst, "url");
|
||||
|
||||
if (string.IsNullOrEmpty(signature))
|
||||
{
|
||||
var error = BaseRegex.GetStringJson(ref uploadImgRst, "errorMsg");
|
||||
if (string.IsNullOrEmpty(error))
|
||||
error = BaseRegex.GetStringJson(ref uploadImgRst, "error_msg");
|
||||
return "{\"success\":false,\"status\":\"未上传\"," +
|
||||
"\"productDraftId\":\"" + productDraftId + "\"," +
|
||||
"\"errMsg\":\"草稿箱上传失败,上传图片失败 " + error + "\"}";
|
||||
}
|
||||
|
||||
dicCustomImg[sImgPath] = imgUrl;
|
||||
return imgUrl;
|
||||
}
|
||||
else
|
||||
{
|
||||
var existImgRst = this.GetExistImg(shop, productDraftId, materialId);
|
||||
string imgUrl = BaseRegex.GetStringJson(ref existImgRst, "imgUrl");
|
||||
if (string.IsNullOrEmpty(materialId))
|
||||
{
|
||||
var error = BaseRegex.GetStringJson(ref existImgRst, "errorMsg");
|
||||
if (string.IsNullOrEmpty(error))
|
||||
error = BaseRegex.GetStringJson(ref existImgRst, "error_msg");
|
||||
return "{\"success\":false,\"status\":\"未上传\"," +
|
||||
"\"productDraftId\":\"" + productDraftId + "\"," +
|
||||
"\"errMsg\":\"草稿箱上传失败,获取已存在图片失败 " + error + "\"}";
|
||||
}
|
||||
|
||||
dicCustomImg[sImgPath] = imgUrl;
|
||||
return imgUrl;
|
||||
}
|
||||
}
|
||||
|
||||
private string AddDraft(ShopLoginInfo shop, string catId)
|
||||
{
|
||||
//string url = "https://seller.kuajingmaihuo.com/bg-visage-mms/product/draft/add";
|
||||
@@ -1351,6 +1574,14 @@ namespace TemuKJD.KJDForms.ProductSelectForms
|
||||
return KJDHttpResponse.PostResponse2(shop, url, body, refere);
|
||||
}
|
||||
|
||||
private string EditProduct(ShopLoginInfo shop, string productId, TemuProductParam prodParam)
|
||||
{
|
||||
string url = "https://agentseller.temu.com/visage-agent-seller/product/edit";
|
||||
string body = JsonHelper.SerializeObject(prodParam).Replace("productDraftId", "productId");
|
||||
string refere = "https://agentseller.temu.com/goods/edit?from=productList&productId=" + productId;
|
||||
return KJDHttpResponse.PostResponse2(shop, url, body, refere);
|
||||
}
|
||||
|
||||
private string QueryOrAddSpec(ShopLoginInfo shop, string draftId, string parentSpecId, string specName)
|
||||
{
|
||||
string url = "https://agentseller.temu.com/anniston-agent-seller/sku/spec/byName/queryOrAdd";
|
||||
@@ -1360,6 +1591,72 @@ namespace TemuKJD.KJDForms.ProductSelectForms
|
||||
return KJDHttpResponse.PostResponse2(shop, url, body, refere);
|
||||
}
|
||||
|
||||
private string CheckImgMd5(ShopLoginInfo shop, string draftId, string parentSpecId, string fileMd5)
|
||||
{
|
||||
string url = "https://agentseller.temu.com/phoenix-mms/material/queryByMd5";
|
||||
string body = @"{""materialType"":1,""md5IdList"":[""" + fileMd5 + @"""]}";
|
||||
|
||||
string refere = "https://agentseller.temu.com/goods/edit?productDraftId=" + draftId + "&from=menu&st_time="
|
||||
+ BaseClass.DateTimeToTimestampSeconds(DateTime.Now);
|
||||
return KJDHttpResponse.PostResponse2(shop, url, body, refere);
|
||||
|
||||
//https://img.kwcdn.com/product/fancy/8dc012c8-fa6d-4625-b2bb-efd32f44f889.jpg
|
||||
//"materialName":"8dc012c8-fa6d-4625-b2bb-efd32f44f889"
|
||||
}
|
||||
|
||||
private string GetExistImg(ShopLoginInfo shop, string draftId, string materialId)
|
||||
{
|
||||
string url = "https://agentseller.temu.com/phoenix-mms/material/pageQuery";
|
||||
string body = @"{""pageInfo"":{""pageNo"":1,""pageSize"":50},""uploadStatusList"":[3],
|
||||
""materialIdList"":[" + materialId + @"],""folderId"":0,""minMaterialHeight"":800,""minMaterialWidth"":800,""maxMaterialSize"":2097152,
|
||||
""proportion"":""1:1"",""proportionList"":[""1:1""],""badTagList"":[""ZH_HANS""]}";
|
||||
|
||||
body = "{\"pageInfo\":{\"pageNo\":1,\"pageSize\":50},\"uploadStatusList\":[3],\"materialIdList\":[250822757735044],\"folderId\":0,\"minMaterialHeight\":800,\"minMaterialWidth\":800,\"maxMaterialSize\":2097152,\"proportion\":\"1:1\",\"proportionList\":[\"1:1\"],\"badTagList\":[\"ZH_HANS\"]}";
|
||||
|
||||
string refere = "https://agentseller.temu.com/goods/edit?productDraftId=" + draftId + "&from=menu&st_time="
|
||||
+ BaseClass.DateTimeToTimestampSeconds(DateTime.Now);
|
||||
return KJDHttpResponse.PostResponse2(shop, url, body, refere);
|
||||
}
|
||||
|
||||
private string GetImgUpSign(ShopLoginInfo shop, string draftId)
|
||||
{
|
||||
string url = "https://agentseller.temu.com/general_auth/get_signature?sdk_version=js-0.0.49&tag_name=product-material-tag&scene_id=agent-seller";
|
||||
string body = @"{""bucket_tag"":""product-material-tag""}";
|
||||
string refere = "https://agentseller.temu.com/goods/edit?productDraftId=" + draftId + "&from=menu&st_time="
|
||||
+ BaseClass.DateTimeToTimestampSeconds(DateTime.Now);
|
||||
|
||||
return KJDHttpResponse.PostResponse2(shop, url, body, refere);
|
||||
}
|
||||
|
||||
private string UploadImage(ShopLoginInfo shop, string draftId, string fileFullName, string uploadSign)
|
||||
{
|
||||
if (fileFullName == null)
|
||||
fileFullName = "";
|
||||
string fileName = fileFullName.Split('\\').LastOrDefault();
|
||||
string url = "https://agentseller.temu.com/api/galerie/v3/store_image?sdk_version=js-0.0.49&tag_name=product-material-tag";
|
||||
string boundary = "----WebKitFormBoundarybJAaZCwJYanqPxhq";
|
||||
string body = @"------WebKitFormBoundarybJAaZCwJYanqPxhq
|
||||
Content-Disposition: form-data; name=""url_width_height""
|
||||
|
||||
true
|
||||
------WebKitFormBoundarybJAaZCwJYanqPxhq
|
||||
Content-Disposition: form-data; name=""image""; filename=""" + fileName + @"""
|
||||
Content-Type: image/jpeg
|
||||
|
||||
<!>" + fileFullName + @"<!>
|
||||
------WebKitFormBoundarybJAaZCwJYanqPxhq
|
||||
Content-Disposition: form-data; name=""upload_sign""
|
||||
|
||||
" + uploadSign + @"
|
||||
------WebKitFormBoundarybJAaZCwJYanqPxhq--
|
||||
";
|
||||
string refere = "https://agentseller.temu.com/goods/edit?productDraftId=" + draftId + "&from=menu&st_time="
|
||||
+ BaseClass.DateTimeToTimestampSeconds(DateTime.Now);
|
||||
|
||||
return KJDHttpResponse.PostResponseUpload(shop, url, body, refere, boundary);
|
||||
}
|
||||
|
||||
|
||||
private void btnSetSubSa_Click(object sender, EventArgs e)
|
||||
{
|
||||
var lstProdId = dgvSelectProduct.Rows.Cast<DataGridViewRow>().Where(row
|
||||
@@ -1659,5 +1956,33 @@ namespace TemuKJD.KJDForms.ProductSelectForms
|
||||
|
||||
return JsonHelper.DeserializeJsonToList<TemuDBPriceInfo>(jArr.ToString());
|
||||
}
|
||||
|
||||
private void btnCustomImg_Click(object sender, EventArgs e)
|
||||
{
|
||||
string text = "";
|
||||
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||||
openFileDialog.Multiselect = true;
|
||||
// 设置过滤条件,只显示文本文件
|
||||
openFileDialog.Filter = "图片文件 (*.jepg;*.jpg;*.png)|*.jepg;*.jpg;*.png|All files (*.*)|*.*";
|
||||
// 显示对话框并获取结果
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 读取文件内容
|
||||
//text = File.ReadAllText(openFileDialog.FileName);
|
||||
this.lstCustomImg = openFileDialog.FileNames.ToList();
|
||||
lblCustomImgNum.Text = "自定义图片 " + this.lstCustomImg.Count + " 张";
|
||||
// 显示文件内容
|
||||
//Console.WriteLine(text);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//Console.WriteLine("An error occurred: " + ex.Message);
|
||||
BaseMsgForm.ShowError(ex.Message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user