书籍类目上传

This commit is contained in:
wule_5900x committed 2026-01-18 20:40:11 +08:00
1 parent dbc954a200
commit 2ae38c8105
10 files changed
+339 -89

No files matched your search

+32 -34
View File
@@ -32,12 +32,12 @@ namespace TemuKJD.WXForms.ProductForms
private void InitializeComponent()
{
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 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.ucGroupBoxEx2 = new TemuKJD.UserComponent.UcGroupBoxEx(this.components);
this.chkSkipUploaded = new TemuKJD.UserComponent.UcCheckBox(this.components);
@@ -201,6 +201,7 @@ namespace TemuKJD.WXForms.ProductForms
this.ucGroupBoxEx2.Controls.Add(this.label8);
this.ucGroupBoxEx2.Controls.Add(this.txtReplaceText);
this.ucGroupBoxEx2.Controls.Add(this.label3);
this.ucGroupBoxEx2.Controls.Add(this.chkUpDraft);
this.ucGroupBoxEx2.Controls.Add(this.chkHighestPriceSku);
this.ucGroupBoxEx2.Controls.Add(this.label7);
this.ucGroupBoxEx2.Controls.Add(this.txtWaitSeconds);
@@ -1010,7 +1011,6 @@ namespace TemuKJD.WXForms.ProductForms
this.splitContainer2.Panel2.Controls.Add(this.pbLoading);
this.splitContainer2.Panel2.Controls.Add(this.label11);
this.splitContainer2.Panel2.Controls.Add(this.txtSinglePriceAdd);
this.splitContainer2.Panel2.Controls.Add(this.chkUpDraft);
this.splitContainer2.Panel2.Controls.Add(this.dgvSelectProduct);
this.splitContainer2.Panel2.Padding = new System.Windows.Forms.Padding(0, 0, 4, 0);
this.splitContainer2.Size = new System.Drawing.Size(1523, 362);
@@ -1021,19 +1021,19 @@ namespace TemuKJD.WXForms.ProductForms
//
this.dgvShop.AllowUserToAddRows = false;
this.dgvShop.AllowUserToDeleteRows = false;
dataGridViewCellStyle1.BackColor = System.Drawing.Color.WhiteSmoke;
this.dgvShop.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
dataGridViewCellStyle13.BackColor = System.Drawing.Color.WhiteSmoke;
this.dgvShop.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle13;
this.dgvShop.AutoRowNumber = true;
this.dgvShop.BackgroundColor = System.Drawing.Color.White;
this.dgvShop.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dgvShop.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2;
dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle14.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle14.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle14.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle14.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle14.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle14.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dgvShop.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle14;
this.dgvShop.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvShop.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.colSelect,
@@ -1210,33 +1210,31 @@ namespace TemuKJD.WXForms.ProductForms
//
// chkUpDraft
//
this.chkUpDraft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.chkUpDraft.AutoSize = true;
this.chkUpDraft.Location = new System.Drawing.Point(999, 31);
this.chkUpDraft.Location = new System.Drawing.Point(678, 91);
this.chkUpDraft.Name = "chkUpDraft";
this.chkUpDraft.Size = new System.Drawing.Size(99, 21);
this.chkUpDraft.TabIndex = 769;
this.chkUpDraft.Text = "上传到草稿箱";
this.chkUpDraft.UseVisualStyleBackColor = true;
this.chkUpDraft.Visible = false;
//
// dgvSelectProduct
//
this.dgvSelectProduct.AllowUserToAddRows = false;
this.dgvSelectProduct.AllowUserToDeleteRows = false;
dataGridViewCellStyle3.BackColor = System.Drawing.Color.WhiteSmoke;
this.dgvSelectProduct.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3;
dataGridViewCellStyle15.BackColor = System.Drawing.Color.WhiteSmoke;
this.dgvSelectProduct.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle15;
this.dgvSelectProduct.AutoRowNumber = true;
this.dgvSelectProduct.BackgroundColor = System.Drawing.Color.White;
this.dgvSelectProduct.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dgvSelectProduct.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4;
dataGridViewCellStyle16.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle16.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle16.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle16.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle16.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle16.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle16.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dgvSelectProduct.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle16;
this.dgvSelectProduct.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvSelectProduct.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.colCheck,
@@ -1296,8 +1294,8 @@ namespace TemuKJD.WXForms.ProductForms
//
// colSupplierName
//
dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.colSupplierName.DefaultCellStyle = dataGridViewCellStyle5;
dataGridViewCellStyle17.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.colSupplierName.DefaultCellStyle = dataGridViewCellStyle17;
this.colSupplierName.Frozen = true;
this.colSupplierName.HeaderText = "店铺名称";
this.colSupplierName.Name = "colSupplierName";
@@ -1375,8 +1373,8 @@ namespace TemuKJD.WXForms.ProductForms
//
// colProductName
//
dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.colProductName.DefaultCellStyle = dataGridViewCellStyle6;
dataGridViewCellStyle18.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.colProductName.DefaultCellStyle = dataGridViewCellStyle18;
this.colProductName.HeaderText = "商品标题";
this.colProductName.Name = "colProductName";
this.colProductName.ReadOnly = true;
@@ -1286,7 +1286,7 @@ namespace TemuKJD.WXForms.ProductForms
}
// 检测是否有类目上传权限
long leafCatId = (upProdParam.product.info.category.LastOrDefault()?.catId).ParseToLong();
long leafCatId = (upProdParam.product.info.category.LastOrDefault()?.catId).ParseToLong(); //哲学经典著作
var cateUpCheckRst = WXUpload.batchCheckCategoryRelation(shop, leafCatId);
if (!cateUpCheckRst.Contains("\"code\":0") && !cateUpCheckRst.Contains("\"success\":true"))
{
@@ -1333,7 +1333,6 @@ namespace TemuKJD.WXForms.ProductForms
upProdParam.product.info.aiGenShortTitle = upProdParam.product.info.shortTitle;
#endregion
#region 售后信息
var addressRst = WXUpload.getAddress(shop);
if (!addressRst.Contains("\"code\":0") && !addressRst.Contains("\"success\":true"))
@@ -1360,6 +1359,7 @@ namespace TemuKJD.WXForms.ProductForms
upProdParam.product.info.expressInfo.templateId = BaseRegex.GetStringJson(ref expressRst, "templateId");
#endregion
#region 详情图
if (cell != null)
{
Invoke(new Action(() =>
@@ -1368,9 +1368,11 @@ namespace TemuKJD.WXForms.ProductForms
}));
}
Thread.Sleep(Randomx.GetId(500, 800));
#region 详情图
upProdParam.product.info.detail = new productDetailParam(); // 详情图
foreach (var gallery_item in prodInfo.detail.galleries.Where(g => g.type == 2))
var detailGalleries = prodInfo.detail.galleries.Where(g => g.type == 2).ToList();
if (detailGalleries.Count == 0)
detailGalleries.Add(new gallery_item() { type = 2, url = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1)?.url });
foreach (var gallery_item in detailGalleries)
{
var locationStr = UploadImg(shop, gallery_item.url, cell);
if (!locationStr.Contains("\"success\":true"))
@@ -1402,6 +1404,29 @@ namespace TemuKJD.WXForms.ProductForms
{
attr = productAttr.attr.FirstOrDefault(r => r.name == "填充物种类" || r.name == "填充物");
}
// 书籍类目匹配
if (upProdParam.product.info.category.FirstOrDefault()?.name == "图书" || prodInfo.detail.cats.FirstOrDefault() == "书籍/杂志/报纸")
{
if (propInfo.name == "出版社名称")
attr = productAttr.attr.FirstOrDefault(r => r.name == "出版社名称");
else if (propInfo.name == "ISBN编号")
attr = productAttr.attr.FirstOrDefault(r => r.name == "ISBN版号/CN刊号");
else if (propInfo.name == "书名")
attr = productAttr.attr.FirstOrDefault(r => r.name == "书名");
else if (propInfo.name == "定价")
attr = productAttr.attr.FirstOrDefault(r => r.name == "定价");
else if (propInfo.name == "作者")
attr = productAttr.attr.FirstOrDefault(r => r.name == "作者");
else if (propInfo.name == "出版时间")
attr = productAttr.attr.FirstOrDefault(r => r.name == "出版时间");
else if (propInfo.name == "版次")
attr = productAttr.attr.FirstOrDefault(r => r.name == "版次");
else if (propInfo.name == "装帧类型")
attr = productAttr.attr.FirstOrDefault(r => r.name == "包装");
else if (propInfo.name == "包册数")
attr = productAttr.attr.FirstOrDefault(r => r.name == "图书册数");
}
}
if (attr == null)
{
@@ -1417,6 +1442,18 @@ namespace TemuKJD.WXForms.ProductForms
{
attrValue = propInfo.values.FirstOrDefault()?.value;
}
if (upProdParam.product.info.category.FirstOrDefault()?.name == "图书" || prodInfo.detail.cats.FirstOrDefault() == "书籍/杂志/报纸")
{
if (attrValue.IsNullOrEmpty() && attr.type == "integer_unit" && (propInfo.values.FirstOrDefault()?.value).IsNumber())
{
attrValue = propInfo.values.FirstOrDefault()?.value + " " + attr.value.Split(';').FirstOrDefault();
}
if (attrValue.IsNullOrEmpty() && attr.name == "包装")
{
if (propInfo.values.FirstOrDefault()?.value == "平装-胶订")
attrValue = "平装";
}
}
if (attrValue.IsNullOrEmpty() && attr.isRequired == true)
{
if (attrValueLst.Contains("其他"))
@@ -1481,10 +1518,6 @@ namespace TemuKJD.WXForms.ProductForms
var attrValueLst = attr.value.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries).ToList();
string attrValue = "";
if (attr.type == "string")
{
attrValue = "其他";
}
if (attrValue.IsNullOrEmpty() && attr.isRequired == true)
{
if (attrValueLst.Contains("其他"))
@@ -1503,6 +1536,25 @@ namespace TemuKJD.WXForms.ProductForms
}
else
attrValue = attrValueLst.Where(v => !"真丝、蚕丝、香云纱、羊绒、羊毛、羊羔绒、羊羔毛、羽绒、皮草".Contains(v)).OrderBy(x => Guid.NewGuid()).FirstOrDefault();
//书籍属性处理
if (upProdParam.product.info.category.FirstOrDefault()?.name == "图书" || prodInfo.detail.cats.FirstOrDefault() == "书籍/杂志/报纸")
{
if (attr.name == "是否为单一书号丛书")
attrValue = "是";
if (attr.name == "图书册数")
attrValue = "1 册";
if (attr.name == "出版社名称")
attrValue = new List<string>() { "技术出版社", "文化出版社", "美术出版社" }[Randomx.GetId(3)];
if (attr.name == "作者")
attrValue = new List<string>() { "李老师", "张老师", "王老师" }[Randomx.GetId(3)];
if (attr.name == "包装")
attrValue = "平装";
}
}
if (attrValue.IsNullOrEmpty() && attr.type == "string")
{
attrValue = "其他";
}
if (attr.type == "decimal4_unit" || attr.type == "integer_unit")
{
@@ -1535,6 +1587,7 @@ namespace TemuKJD.WXForms.ProductForms
}
#endregion
#region sku规格属性
if (cell != null)
{
@@ -1545,8 +1598,17 @@ namespace TemuKJD.WXForms.ProductForms
}
Thread.Sleep(1000);
#region sku规格属性
upProdParam.product.info.productSaleAttrs = new List<productSaleAttrParam>();
if (prodInfo.detail.sku == null)
prodInfo.detail.sku = new List<sku_item>();
if (prodInfo.detail.sku.Count == 0)
prodInfo.detail.sku.Add(new sku_item() { spec = new List<spec_item>() });
if (prodInfo.detail.sku.FirstOrDefault().spec == null)
prodInfo.detail.sku.FirstOrDefault().spec = new List<spec_item>();
if (prodInfo.detail.sku.FirstOrDefault().spec.Count == 0)
prodInfo.detail.sku.FirstOrDefault().spec.Add(new spec_item() { parent_name = "规格", spec_name = "默认" });
if (prodInfo.detail.sku.FirstOrDefault().thumb_url.IsNullOrEmpty())
prodInfo.detail.sku.FirstOrDefault().thumb_url = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1)?.url;
if (prodInfo.detail.sku.FirstOrDefault()?.spec?.Count > 0)
{
productSaleAttrParam attrParam = new productSaleAttrParam()
@@ -1692,6 +1754,76 @@ namespace TemuKJD.WXForms.ProductForms
}
#endregion
#region 书籍类生成书籍图片
//qualificationList
if (1 == 1)
{
if (cell != null)
{
Invoke(new Action(() =>
{
cell.Value = "正在生成图书专有信息";
}));
}
string publisher = "出版社:" + new List<string>() { "技术出版社", "文化出版社", "美术出版社" }[Randomx.GetId(3)];
string isbn = "ISBN:";
string bookName = "书名:";
string bookPrice = "定价:" + upProdParam.product.productSkus.Max(s => s.productSkuInfo.salePrice) * 0.01;
string author = "作者:王老师";
string publishTime = "出版时间:" + DateTime.Now.AddMonths(-3);
string edition = "版次:1";
string binding = "装帧:平装";
foreach (var propParam in upProdParam.product.info.param)
{
if (propParam.categorys[0].name.Contains("出版社名称"))
publisher = "出版社:" + propParam.categorys[1].name;
else if (propParam.categorys[0].name.Contains("ISBN版号/CN刊号"))
isbn = "ISBN:" + propParam.categorys[1].name;
else if (propParam.categorys[0].name.Contains("书名"))
bookName = "书名:" + propParam.categorys[1].name;
else if (propParam.categorys[0].name.Contains("定价"))
bookPrice = "定价:" + propParam.categorys[1].name;
else if (propParam.categorys[0].name.Contains("作者"))
author = "作者:" + propParam.categorys[1].name;
else if (propParam.categorys[0].name.Contains("出版时间"))
publishTime = "出版时间:" + propParam.categorys[1].name;
else if (propParam.categorys[0].name.Contains("版次"))
edition = "版次:" + propParam.categorys[1].name;
else if (propParam.categorys[0].name.Contains("包装"))
binding = "装帧:" + propParam.categorys[1].name;
}
var bookStr = publisher + "\r\n" + "\r\n" +
isbn + "\r\n" + "\r\n" +
bookName + "\r\n" + "\r\n" +
bookPrice + "\r\n" + "\r\n" +
author + "\r\n" + "\r\n" +
publishTime + "\r\n" + "\r\n" +
edition + "\r\n" + "\r\n" +
binding;
var bookImg = new Bitmap(800, 800);
using (Graphics g = Graphics.FromImage(bookImg))
{
g.Clear(Color.White);
//Font font = new Font("宋体", 15, FontStyle.Bold);
Font font = new Font("微软雅黑", 15, FontStyle.Regular);
Brush textBrush = Brushes.Black;
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
RectangleF rectF = new RectangleF(80, 80, 800 - 80, 800 - 80);
g.DrawString(bookStr, font, textBrush, rectF);
}
Thread.Sleep(Randomx.GetId(500, 800));
var locationStr = UploadImg(shop, bookImg, cell);
if (!locationStr.Contains("\"success\":true"))
return locationStr;
var location = BaseRegex.GetStringJson(ref locationStr, "Location");
upProdParam.product.info.qualificationList.Add(new qualificationParam() { qualificationId = "1111485", qualificationUrl = new List<string>() { location }, });
}
#endregion
if (cell != null)
{
@@ -1738,6 +1870,8 @@ namespace TemuKJD.WXForms.ProductForms
if (!uploadProdRst.Contains("\"code\":0") && !uploadProdRst.Contains("\"success\":true"))
{
var error = BaseRegex.GetStringJson(ref uploadProdRst, "msg");
if (string.IsNullOrEmpty(error))
error = BaseRegex.GetStringJson(ref uploadProdRst, "errmsg");
if (string.IsNullOrEmpty(error))
error = uploadProdRst;
return "{\"success\":false,\"draftId\":" + upProdParam.product.productKey.productId + ",\"status\":\"草稿箱\",\"errMsg\":\"上架失败 " + error + "\"}";
@@ -1782,11 +1916,36 @@ namespace TemuKJD.WXForms.ProductForms
return "{\"success\":true,\"draftId\":" + upProdParam.product.productKey.productId + ",\"status\":\"已上传\",\"msg\":\"上传成功\"}";
}
public string UploadImg(ShopLoginInfo shop, string img_url, DataGridViewCell cell = null)
{
string getImgError;
var image = GetHtml.GetUrlImg(img_url.Replace("https://", "http://"), out getImgError);
if (image == null)
image = new Bitmap(800, 800);
var imageBg = new Bitmap(image.Width, image.Height);
if (!string.IsNullOrEmpty(getImgError) || image == null)
{
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"初始化图片上传失败\"}";
}
try
{
using (Graphics g = Graphics.FromImage(imageBg))
{
g.DrawImage(image, new Rectangle(0, 0, imageBg.Width, imageBg.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel);
}
}
catch (Exception ex)
{
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"" + "修改图片失败 " + ex.Message + "\"}";
}
return UploadImg(shop, imageBg, cell);
}
public string UploadImg(ShopLoginInfo shop, Bitmap img, DataGridViewCell cell = null)
{
var upImgAuthRst = WXUpload.getUploadTempImgAuth(shop);
for (int i = 0; i < 10 && upImgAuthRst.Contains("LogicError"); i++)
@@ -1814,23 +1973,12 @@ namespace TemuKJD.WXForms.ProductForms
string imgBase64 = "";
//-------------------------------------------------------------------------------------------------------------------------------------
//生成详情图base64字符串
string getImgError;
var image = GetHtml.GetUrlImg(img_url.Replace("https://", "http://"), out getImgError);
var imageBg = new Bitmap(image.Width, image.Height);
if (!string.IsNullOrEmpty(getImgError) || image == null)
{
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"初始化图片上传失败\"}";
}
//生成图片base64字符串
try
{
using (Graphics g = Graphics.FromImage(imageBg))
{
g.DrawImage(image, new Rectangle(0, 0, imageBg.Width, imageBg.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel);
}
using (MemoryStream memoryStream = new MemoryStream())
{
imageBg.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg);
img.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] imageBytes = memoryStream.ToArray();
imgBase64 = Convert.ToBase64String(imageBytes);
}
@@ -1841,7 +1989,7 @@ namespace TemuKJD.WXForms.ProductForms
}
//-------------------------------------------------------------------------------------------------------------------------------------
//上传详情图,获取图片路径
//上传图片,获取图片路径
var upImgRst = WXUpload.adtimageupload(shop, imgBase64, disK, disT, ext).ParseToString();
var location = BaseRegex.GetStringJson(ref upImgRst, "Location");
if (string.IsNullOrEmpty(location))
@@ -2270,6 +2418,11 @@ Content-Type: image/jpeg
string referer = "https://store.weixin.qq.com/shop/goods/entry";
string body = @"{""categoryInfo"":{""categories"":[{""id"":""" + catId + @"""}]},""brandIdList"":[],""leafCategoryId"":""" + catId + @""",""reuse"":0,""applyType"":1}";
var result = WXHttpResponseBLL.WeiXinPostResponse(shop, url, body, referer);
//{"categoryInfo":{"categories":[{"id":10000257},{"id":10000245},{"id":112888}],"categoryDeposit":"10000.00","isNewApplyCat":true,"licenseGroupList":[{"licenseGroupId":"17","license":{"licenseId":"5","cosIdList":["1768635607165-orc0V2WjFHdNvjNnk967_g14awFw-7487"],"licenseFieldList":[{"key":"audit_license_no","value":"新出发皖字第1027号"},{"key":"audit_license_validty_period","value":"2029-04-30"}],"isReuse":true}}],"ruleVersion":5234,"certificate":[]},"brandIdList":[],"leafCategoryId":112888,"reuse":0,"applyType":"normalApply"}
//{"code":0,"baseResp":{"errcode":0,"errmsg":"ok"},"auditId":"8362856529"}
//string body = @"{""categoryInfo"":{""categories"":[{""id"":10000257},{""id"":10000245},{""id"":112888}],""categoryDeposit"":""10000.00"",""isNewApplyCat"":true,""licenseGroupList"":[{""licenseGroupId"":""17"",""license"":{""licenseId"":""5"",""cosIdList"":[""1768635607165-orc0V2WjFHdNvjNnk967_g14awFw-7487""],""licenseFieldList"":[{""key"":""audit_license_no"",""value"":""新出发皖字第1027号""},{""key"":""audit_license_validty_period"",""value"":""2029-04-30""}],""isReuse"":true}}],""ruleVersion"":5234,""certificate"":[]},""brandIdList"":[],""leafCategoryId"":112888,""reuse"":0,""applyType"":""normalApply""}";
// request.Referer = "https://store.weixin.qq.com/shop/brandAndCat/category/apply?defaultCategoryIds=%5B%2210000257%22%2C%2210000245%22%2C%22112888%22%5D&source=goods&type=apply";
return result;
}