商品选品准备工作

This commit is contained in:
wule committed 2025-07-15 19:09:45 +08:00
1 parent dda4fdfc5f
commit a77278c6d1
34 files changed
+2336 -48

No files matched your search

+12 -4
View File
@@ -560,7 +560,7 @@ namespace TemuKJD.KJDForms.AdminForms
{
var goodsLayerDecorationItem = new GoodsLayerDecorationReqsItem()
{
floorId = "" + goodsLayerDecorationVOInfo.floorId,
floorId = goodsLayerDecorationVOInfo.floorId,
key = goodsLayerDecorationVOInfo.key,
lang = goodsLayerDecorationVOInfo.lang,
priority = goodsLayerDecorationVOInfo.priority,
@@ -579,12 +579,16 @@ namespace TemuKJD.KJDForms.AdminForms
}
prodParam.goodsLayerDecorationReqs.Add(goodsLayerDecorationItem);
}
prodParam.goodsModelReqs = prodInfo.goodsModelList;
prodParam.goodsModelReqs = prodInfo.goodsModelList != null? prodInfo.goodsModelList : new List<object>();
prodParam.materialImgUrl = prodInfo.materialImgUrl;
prodParam.materialMultiLanguages = prodInfo.productLocalExtAttr.materialMultiLanguages != null ?
prodInfo.productLocalExtAttr.materialMultiLanguages : new List<object>();
prodParam.personalizationSwitch = prodInfo.productWhExtAttr.personalizationSwitch.ParseToInt();
prodParam.productCarouseVideoReqList = prodInfo.carouseVideoVOList;
var carouseVideoVOList = JsonHelper.SerializeObject(prodInfo.carouseVideoVOList);
prodParam.productCarouseVideoReqList = JsonHelper.DeserializeJsonToList<productCarouseVideoReqItem>(carouseVideoVOList);
if (prodParam.productCarouseVideoReqList == null)
prodParam.productCarouseVideoReqList = new List<productCarouseVideoReqItem>();
//此处打开商品编辑详情无法获取到,如何查询存疑
prodParam.productComplianceStatementReq = new ProductComplianceStatementReq
{
@@ -709,6 +713,8 @@ namespace TemuKJD.KJDForms.AdminForms
};
skuItem.productSkuNonAuditExtAttrReq = JsonHelper.DeserializeJsonToObject<ProductSkuNonAuditExtAttrReq>(
JsonHelper.SerializeObject(skuInfo.productSkuNonAuditExtAttr));
if (skuItem.productSkuNonAuditExtAttrReq == null)
skuItem.productSkuNonAuditExtAttrReq = new ProductSkuNonAuditExtAttrReq();
skuItem.productSkuSpecReqs=new List<ProductSkuSpecReqsItem>();
int groupId = 0;
foreach(var skuSpecInfo in skuInfo.productSkuSpecList)
@@ -808,7 +814,9 @@ namespace TemuKJD.KJDForms.AdminForms
else
{
var error = BaseRegex.GetStringJson(ref html, "errorMsg");
BaseMsgForm.ShowError("上传商品失败" + error + "\r\n,请在草稿箱查找商品!");
if (string.IsNullOrWhiteSpace(error))
error = BaseRegex.GetStringJson(ref html, "error_msg");
BaseMsgForm.ShowError(("上传商品失败\r\n" + error + "\r\n请在草稿箱查找商品!").Replace("\r\n\r\n","\r\n"));
return;
}
}
@@ -339,7 +339,8 @@ namespace TemuKJD.KJDForms.AdminForms
private void ShopObj_OnInfoReceived(string information)
{
//BaseMsgForm.ShowInfo(information);
cefWebBrowser.GetBrowser().MainFrame.EvaluateScriptAsync("alert('" + information + "');");
if (!string.IsNullOrEmpty(information))
cefWebBrowser.GetBrowser().MainFrame.EvaluateScriptAsync("alert('" + information + "');");
}
private void CefWebBrowser_LoadError(object sender, CefSharp.LoadErrorEventArgs e)
+106 -37
View File
@@ -32,49 +32,110 @@ namespace TemuKJD.KJDForms.AdminForms
return "failed";
}
Task.Run(() => {
var shop1 = shop;
var prodId1 = prodId;
var html = ProductQuery(shop1, prodId1.ToString());
if (html.Contains("\"success\":true") && html.Contains("\"result\""))
Task.Run(() =>
{
try
{
var shop1 = shop;
var prodId1 = prodId;
string err_msg = "";
var html = ProductQuery(shop1, prodId1.ToString());
if (!html.Contains("\"success\":true") || !html.Contains("\"result\""))
{
OnInfoReceived("商品获取失败!" + BaseRegex.GetStringJson(ref html, "errorMsg"));
return;
}
JObject obj = JObject.Parse(html);
try
var result = JsonHelper.SerializeObject(obj["result"]);
var sizeRst = "";
TemuProductInfo product = JsonHelper.DeserializeJsonToObject<TemuProductInfo>(result);
if (product.sizeTemplateId > 0)
{
var result = JsonHelper.SerializeObject(obj["result"]);
TemuProductInfo product = JsonHelper.DeserializeJsonToObject<TemuProductInfo>(result);
// 创建 SaveFileDialog 的实例
SaveFileDialog saveFileDialog = new SaveFileDialog();
// 单线程单元(STA)模式运行文件对话框,否则会报错。
System.Threading.Thread InvokeThread = new System.Threading.Thread(new System.Threading.ThreadStart(()=> {
// 设置对话框的属性
saveFileDialog.Title = "保存商品";
saveFileDialog.Filter = "商品文件 (*.prd)|*.prd|所有文件 (*.*)|*.*"; // 过滤文件类型
saveFileDialog.FileName = product.productId.ParseToString(); // 默认文件名
saveFileDialog.DefaultExt = "txt"; // 默认文件扩展名
// 显示对话框并获取结果
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
// 用户点击了“保存”按钮,此时可以获取文件的路径
string filePath = saveFileDialog.FileName;
// 在这里处理文件保存逻辑,例如写入数据到文件
System.IO.File.WriteAllText(filePath, result);
}
//BaseMsgForm.ShowInfo("商品保存成功!");
OnInfoReceived("商品保存成功!");
}));
InvokeThread.SetApartmentState(System.Threading.ApartmentState.STA);
InvokeThread.Start();
InvokeThread.Join();
html = SizeSpecQuery(shop1, prodId1.ToString(), product.sizeTemplateId.ToString());
if(!html.Contains("\"success\":true"))
{
err_msg += "尺码表获取失败!" + BaseRegex.GetStringJson(ref html, "errorMsg");
}
else
{
obj = JObject.Parse(html);
sizeRst = JsonHelper.SerializeObject(obj["result"]);
}
}
catch(Exception ex)
var cat = product.categories.cat10;
if (string.IsNullOrWhiteSpace(cat.catName))
cat = product.categories.cat9;
if (string.IsNullOrWhiteSpace(cat.catName))
cat = product.categories.cat8;
if (string.IsNullOrWhiteSpace(cat.catName))
cat = product.categories.cat7;
if (string.IsNullOrWhiteSpace(cat.catName))
cat = product.categories.cat6;
if (string.IsNullOrWhiteSpace(cat.catName))
cat = product.categories.cat5;
if (string.IsNullOrWhiteSpace(cat.catName))
cat = product.categories.cat4;
if (string.IsNullOrWhiteSpace(cat.catName))
cat = product.categories.cat3;
if (string.IsNullOrWhiteSpace(cat.catName))
cat = product.categories.cat2;
if (string.IsNullOrWhiteSpace(cat.catName))
cat = product.categories.cat1;
var url = BaseClass.BuildObjString("product/add_product");
var data = Work.UserLogin.GetSignaturex() +
"&spu_id=" + product.productId +
"&skc_id=" + product.productSkcList.FirstOrDefault().productSkcId +
"&cat_id=" + cat.catId +
"&cat_name=" + HttpUtility.UrlEncode(cat.catName, Encoding.UTF8) +
"&product_name=" + HttpUtility.UrlEncode(product.productName, Encoding.UTF8) +
"&product_json=" + HttpUtility.UrlEncode(result, Encoding.UTF8) +
"&size_json=" + HttpUtility.UrlEncode(sizeRst, Encoding.UTF8) +
"&main_img=" + HttpUtility.UrlEncode(product.carouselImageUrls.FirstOrDefault(), Encoding.UTF8);
html = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
html = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
html = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
{
}
//// 创建 SaveFileDialog 的实例
//SaveFileDialog saveFileDialog = new SaveFileDialog();
//// 单线程单元(STA)模式运行文件对话框,否则会报错。
//System.Threading.Thread InvokeThread = new System.Threading.Thread(new System.Threading.ThreadStart(()=> {
// // 设置对话框的属性
// saveFileDialog.Title = "保存商品";
// saveFileDialog.Filter = "商品文件 (*.prd)|*.prd|所有文件 (*.*)|*.*"; // 过滤文件类型
// saveFileDialog.FileName = product.productId.ParseToString(); // 默认文件名
// saveFileDialog.DefaultExt = "txt"; // 默认文件扩展名
// // 显示对话框并获取结果
// if (saveFileDialog.ShowDialog() == DialogResult.OK)
// {
// // 用户点击了“保存”按钮,此时可以获取文件的路径
// string filePath = saveFileDialog.FileName;
// // 在这里处理文件保存逻辑,例如写入数据到文件
// System.IO.File.WriteAllText(filePath, result);
// //BaseMsgForm.ShowInfo("商品保存成功!");
// }
//}));
//InvokeThread.SetApartmentState(System.Threading.ApartmentState.STA);
//InvokeThread.Start();
//InvokeThread.Join();
}
catch (Exception ex)
{
}
});
@@ -90,5 +151,13 @@ namespace TemuKJD.KJDForms.AdminForms
string refere = "https://seller.kuajingmaihuo.com/goods/product-create/product-edit?from=productList&productId=" + prodId;
return KJDHttpResponse.PostResponse(shop, url, body, refere);
}
private string SizeSpecQuery(ShopLoginInfo shop, string prodId, string sizeSpecId)
{
string url = "https://seller.kuajingmaihuo.com/bg-anniston-mms/sizespec/query";
string body = @"{""businessId"":17593513382470,""reusable"":false}";
string refere = "https://seller.kuajingmaihuo.com/goods/product-create/product-edit?from=productList&productId=" + prodId;
return KJDHttpResponse.PostResponse(shop, url, body, refere);
}
}
}