优化清理无流量逻辑 修复用户导入商品失败问题 图书上传资质文件逻辑完成

This commit is contained in:
wule committed 2026-08-11 22:14:33 +08:00
1 parent 7d07c83579
commit 3514be2dba
16 files changed
+705 -340

No files matched your search

@@ -2,6 +2,7 @@
using AllBase.Extension;
using AllBase.Helper;
using AllBase.Model.Config;
using AllBase.Model.DBModel;
using AllBase.Model.Param.WXParam;
using AllBase.Model.Result;
using AllBase.Model.Result.PDDResult;
@@ -29,8 +30,10 @@ using TemuKJD.BLL;
using TemuKJD.Extension;
using TemuKJD.PDDForms.ProductSelectForms;
using TemuKJD.ToolForms;
using TemuKJD.UserControls;
using TemuKJD.WXForms.ShopForms;
using Work;
using Work.BLL.Tools;
using static System.Net.Mime.MediaTypeNames;
namespace TemuKJD.WXForms.ProductForms
@@ -67,6 +70,8 @@ namespace TemuKJD.WXForms.ProductForms
// 微信带货助手cookie
List<Cookie> lstWxSaleAssistantCookie = new List<Cookie>();
List<wx_qualification_image_info> lstQulificationImage = new List<wx_qualification_image_info>();
public WXDBProdUploadForm()
{
InitializeComponent();
@@ -2699,12 +2704,32 @@ namespace TemuKJD.WXForms.ProductForms
if (bound.cat_bound < minBount || bound.cat_bound > maxBount )
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"类目保证金(" + bound.cat_bound + ")超过过滤限制(" + minBount + "-" + maxBount + ")\"}";
// 定向类目需指定品牌Id
var spBrandId = "";
var spBrandName = "";
if (leafCatId == 547591)
{
var rst = WXUpload.getMixBrand(shop, leafCatId.ToString());
// 先写死
spBrandId = 10914219.ToString();
//spBrandId = 10914219.ToString();
var rst = WXUpload.getMixBrand(shop, leafCatId.ToString());
Invoke(new Action(() => { spBrandName = cmbSpBrandName.Text.Trim(); }));
if (!string.IsNullOrEmpty(spBrandName) && rst.Contains("\"code\":0"))
{
var jObj = JsonHelper.JObjectParse(rst);
foreach (var jItem in jObj["mixBrandList"]) // bizuinBrandList mixBrandList
{
if (jItem["chName"].ParseToString() == spBrandName)
spBrandId = jItem["brandId"].ParseToString();
}
}
if (spBrandId.IsNullOrEmpty())
{
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"定向类目绑定品牌失败\"}";
}
// 国表定向类目
upProdParam.product.info.brandId = spBrandId.ParseToLong();
}
@@ -3869,6 +3894,16 @@ namespace TemuKJD.WXForms.ProductForms
wxPropParam.categorys.Add(wxCategoryParam2);
}
}
foreach (var wxPropParam in upProdParam.product.info.param)
{
if (wxPropParam.categorys.Count > 0 &&
wxPropParam.categorys.FirstOrDefault().name == "作者" && (wxPropParam.categorys.LastOrDefault().name == "无" ||
wxPropParam.categorys.LastOrDefault().name == "-" || wxPropParam.categorys.LastOrDefault().name == "/") )
{
wxPropParam.categorys.LastOrDefault().name = upProdParam.product.info.param.FirstOrDefault(p => p.categorys.FirstOrDefault()?.name == "出版社名称").categorys.LastOrDefault()?.name;
}
}
foreach (var attr in productAttr.attr)
{
if (attr.isRequired != true)
@@ -4646,6 +4681,24 @@ namespace TemuKJD.WXForms.ProductForms
}));
}
if (lstQulificationImage.Count == 0)
{
var pageCount = 1;
var seconds = 0m;
lstQulificationImage = AdminForms.WXAdminQualificationImageForm.AdminGetServerQualificationImageLst(out pageCount, out seconds, "图书");
}
var qulificationImage = lstQulificationImage.OrderBy(x => Guid.NewGuid()).FirstOrDefault();
if (qulificationImage != null)
{
if (qulificationImage.img_base64.IsNullOrEmpty())
{
var pageCount = 1;
var seconds = 0m;
qulificationImage.img_base64 = AdminForms.WXAdminQualificationImageForm.AdminGetServerQualificationImageLst(out pageCount, out seconds, "图书", qulificationImage.img_md5)
.FirstOrDefault()?.img_base64;
}
}
//string publisher = "出版社名称:" + new List<string>() { "技术出版社", "文化出版社", "美术出版社" }[Randomx.GetId(3)];
////string isbn = "ISBN:";
//string isbn = "ISBN/CN刊号:";
@@ -4792,7 +4845,12 @@ namespace TemuKJD.WXForms.ProductForms
propParam.categorys[1].name = bookPrice;
}
else if (propParam.categorys[0].name.Contains("作者"))
author = "作  者:" + propParam.categorys[1].name;
{
if (propParam.categorys[1].name != "/")
author = "作  者:" + propParam.categorys[1].name;
else
author = "";
}
else if (propParam.categorys[0].name.Contains("出版时间"))
publishTime = "出版时间:" + propParam.categorys[1].name;
else if (propParam.categorys[0].name.Contains("版次"))
@@ -4800,6 +4858,8 @@ namespace TemuKJD.WXForms.ProductForms
else if (propParam.categorys[0].name.Contains("包装"))
binding = "装  帧:" + propParam.categorys[1].name;
}
if (author.IsNullOrEmpty())
author = "作  者:" + publisher.Replace("出版发行:", "");
var bookStr = publisher + "\r\n" + "\r\n" +
isbn + "\r\n" + "\r\n" +
@@ -4833,17 +4893,34 @@ namespace TemuKJD.WXForms.ProductForms
textImgH = size.Height.ParseToInt() + 180;
}
var bookImg = TemuKJD.Properties.Resources.empty_book_900_1200;
if (!string.IsNullOrEmpty(qulificationImage?.img_base64))
{
// 使用服务端随即图
try
{
bookImg = Base64ChangeImgUrl.Base64ToImage(qulificationImage.img_base64);
}
catch (Exception ex)
{
}
}
imgH = bookImg.Height;
imgW = bookImg.Width;
using (Graphics g = Graphics.FromImage(bookImg))
{
Brush textBrush = Brushes.Black;
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
float txtTop = 240;
float txtBottom = 240;
float txtLeft = 280;
float txtRight = 270;
float txtTop = 240, txtBottom = 240, txtLeft = 280, txtRight = 270;
if (qulificationImage.txt_margin.ParseToString().Split(',').Select(m => m.ParseToInt()).ToList() is List<int> marginValueList && marginValueList.Count == 4)
{
txtLeft = marginValueList[0] + 10 - Randomx.GetId(21);
txtTop = marginValueList[1] + 10 - Randomx.GetId(21);
txtRight = marginValueList[2] + 10 - Randomx.GetId(21);
txtBottom = marginValueList[3] + 10 - Randomx.GetId(21);
}
int txtWidth = (int)imgW - (int)txtLeft - (int)txtRight; // 370;
// 书名
@@ -4913,9 +4990,10 @@ namespace TemuKJD.WXForms.ProductForms
// 测量文本的高度
textSize = g.MeasureString(isbn.Replace("ISBN/CN刊号:", "书  号:ISBN "), font, txtWidth);
textSize = g.MeasureString(isbn.Replace("ISBN/CN刊号:", "书  号:"), font, txtWidth);
txtTop -= (10 + textSize.Height);
rectF = new RectangleF(txtLeft, txtTop, txtWidth, imgH - txtTop);
g.DrawString(isbn.Replace("ISBN/CN刊号:", "书  号:ISBN "), font, textBrush, rectF);
g.DrawString(isbn.Replace("ISBN/CN刊号:", "书  号: "), font, textBrush, rectF);
// 测量文本的高度
textSize = g.MeasureString(publisher, font, txtWidth);