From 1b2b6bb5534556844b9dddf8521c22804af6bde4 Mon Sep 17 00:00:00 2001 From: wule Date: Mon, 23 Feb 2026 21:28:09 +0800 Subject: [PATCH] =?UTF-8?q?=E8=81=9A=E6=B0=B4=E6=BD=AD=E9=A3=9F=E5=93=81?= =?UTF-8?q?=E7=B1=BB=E7=9B=AE=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AllBase/BaseClass.cs | 2 +- AllBase/Model/Result/KJDDBProduct.cs | 4 + .../BLL/BXX/BXXProductManage.cs | 31 ++- .../KJD_WebService/BLL/KJD/ToolManage.cs | 32 ++- .../BLL/WXXD/WXProductManage.cs | 62 ++++- .../KJD_WebService/KJD_WebService.csproj.user | 2 +- .../Model/DBProductResultParam.cs | 1 + .../KJD_WebService/WXProductService.asmx.cs | 12 + TEMUKJD/BLL/PDDProdFormConverter.cs | 6 +- TEMUKJD/ToolForms/GetJuShuitanProdForm.cs | 50 ++++ .../ProductForms/WXDBProdUploadForm.cs | 242 +++++++++++++++++- .../WXForms/ProductForms/WXProdPreSaleForm.cs | 2 +- 12 files changed, 430 insertions(+), 16 deletions(-) diff --git a/AllBase/BaseClass.cs b/AllBase/BaseClass.cs index a584561..117168e 100644 --- a/AllBase/BaseClass.cs +++ b/AllBase/BaseClass.cs @@ -27,7 +27,7 @@ namespace AllBase /// /// 版本ID /// - public static int VersionCount = 860; + public static int VersionCount = 862; //public static int VersionCount = 613; /// diff --git a/AllBase/Model/Result/KJDDBProduct.cs b/AllBase/Model/Result/KJDDBProduct.cs index ca6b82f..6d862c4 100644 --- a/AllBase/Model/Result/KJDDBProduct.cs +++ b/AllBase/Model/Result/KJDDBProduct.cs @@ -35,6 +35,10 @@ namespace AllBase.Model.Result public string price_text { get; set; } public string ext_code { get; set; } /// + /// 加密id,对应聚水潭加密商品编号goodsId + /// + public string secret_spu_id { get; set; } + /// /// 拼多多货号价格 /// public int? ext_code_price { get; set; } diff --git a/KJDService/KJD_WebService/BLL/BXX/BXXProductManage.cs b/KJDService/KJD_WebService/BLL/BXX/BXXProductManage.cs index e747452..aa56497 100644 --- a/KJDService/KJD_WebService/BLL/BXX/BXXProductManage.cs +++ b/KJDService/KJD_WebService/BLL/BXX/BXXProductManage.cs @@ -115,6 +115,7 @@ namespace KJD_Web.BLL.BXX string offline_supplier_name = RegexUtils.GetStringQuery(ref inputData, "offline_supplier_name")?.Replace("'", "\\'"); string spu_id = RegexUtils.GetStringQuery(ref inputData, "spu_id")?.Replace("'", "\\'"); string skc_id = RegexUtils.GetStringQuery(ref inputData, "skc_id")?.Replace("'", "\\'"); + string secret_spu_id = RegexUtils.GetStringQuery(ref inputData, "secret_spu_id")?.Replace("'", "\\'"); string price_text = RegexUtils.GetStringQuery(ref inputData, "price_text")?.Replace("'", "\\'"); string main_cat_id = RegexUtils.GetStringQuery(ref inputData, "main_cat_id")?.Replace("'", "\\'"); string main_cat_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "main_cat_name"))?.Replace("'", "\\'"); @@ -175,6 +176,8 @@ namespace KJD_Web.BLL.BXX sql += " p.product_name='" + product_name + "',"; if (ext_code != null) sql += " p.ext_code='" + ext_code + "',"; + if (secret_spu_id != null) + sql += " p.secret_spu_id='" + secret_spu_id + "',"; if (main_img != null) sql += " p.main_img='" + main_img + "',"; if (product_json != null) @@ -264,6 +267,7 @@ namespace KJD_Web.BLL.BXX var search_group = RegexUtils.GetStringQuery(ref inputData, "search_group")?.Replace("'", "\\'"); var search_notes = RegexUtils.GetStringQuery(ref inputData, "search_notes")?.Replace("'", "\\'"); var search_db_ids = RegexUtils.GetStringQuery(ref inputData, "search_db_ids")?.Replace("'", "\\'"); + var search_secret_spu_ids = RegexUtils.GetStringQuery(ref inputData, "search_secret_spu_ids")?.Replace("'", "\\'"); var get_select_count = RegexUtils.GetStringQuery(ref inputData, "get_select_count")?.Replace("'", "\\'"); var select_shop_id = RegexUtils.GetStringQuery(ref inputData, "select_shop_id")?.Replace("'", "\\'"); var from_shop_id = RegexUtils.GetStringQuery(ref inputData, "from_shop_id")?.Replace("'", "\\'"); @@ -283,7 +287,7 @@ namespace KJD_Web.BLL.BXX string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); - string sql = "select count(*) from bxx.product p where p.is_del=0"; + string sql = "select count(*) from bxx.product p FORCE INDEX (index_wx_safe_status) where p.is_del=0"; string where = ""; if (!string.IsNullOrEmpty(from_shop_id)) @@ -292,6 +296,8 @@ namespace KJD_Web.BLL.BXX where += " and p.from_shop_name ='" + from_shop_name + "'"; if (!string.IsNullOrEmpty(search_db_ids)) where += " and p.id in (" + search_db_ids + ")"; + if (!string.IsNullOrEmpty(search_secret_spu_ids)) + where += " and p.secret_spu_id in ('" + string.Join("','", search_secret_spu_ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)) + "')"; if (!string.IsNullOrEmpty(product_get_type)) where += " and p.product_get_type ='" + product_get_type + "'"; if (!string.IsNullOrEmpty(wx_safe_status)) @@ -381,7 +387,7 @@ namespace KJD_Web.BLL.BXX sql = "select p.id,p.from_shop_id,p.spu_id,p.skc_id,p.main_cat_id,p.main_cat_name,p.cat_id,p.cat_name,p.price_text,p.ext_code,p.product_name," + " p.main_img,p.notes,p.add_time,p.mdy_time,p.select_total_count,p.fission_words,p.head_words,p.end_words,p.sku_img_replace_id,p.group," + " p.product_get_type,p.wx_safe_status,p.sale_count,p.sale_count_text,p.special_prod_type,p.from_shop_name,p.wx_cat_1,p.wx_cat_2,p.wx_cat_3," + - " p.wx_cat_leaf,p.send_to_out_server," + + " p.wx_cat_leaf,p.send_to_out_server,p.secret_spu_id," + " s.img_url,e.ext_code_price" + " FROM bxx.product p " + " left join bxx.sku_img_replace s ON p.sku_img_replace_id=s.id" + @@ -391,7 +397,7 @@ namespace KJD_Web.BLL.BXX sql = "SELECT p.id,p.from_shop_id,p.spu_id,p.skc_id,p.main_cat_id,p.main_cat_name,p.cat_id,p.cat_name,p.price_text,p.ext_code,p.product_name," + " p.main_img,p.notes,p.add_time,p.mdy_time,p.select_total_count,p.fission_words,p.head_words,p.end_words,p.sku_img_replace_id,p.group," + " p.product_get_type,p.wx_safe_status,p.sale_count,p.sale_count_text,p.special_prod_type,p.from_shop_name,p.wx_cat_1,p.wx_cat_2,p.wx_cat_3," + - " p.wx_cat_leaf,p.send_to_out_server," + + " p.wx_cat_leaf,p.send_to_out_server,p.secret_spu_id," + " s.img_url,COUNT(se.id) AS select_count,e.ext_code_price" + " FROM bxx.product p left join bxx.sku_img_replace s ON p.sku_img_replace_id=s.id LEFT JOIN bxx.product_select se ON p.id=se.out_product_id AND se.shop_id='" + select_shop_id + "' " + " LEFT JOIN bxx.ext_code_price e ON p.ext_code=e.ext_code" + @@ -458,6 +464,7 @@ namespace KJD_Web.BLL.BXX main_cat_id = row["main_cat_id"].ToString(), main_cat_name = row["main_cat_name"].ToString(), send_to_out_server = row["send_to_out_server"].ParseToInt(), + secret_spu_id = row["secret_spu_id"].IsNullOrEmpty() ? null : row["secret_spu_id"].ParseToString(), }; if (isDetail) { @@ -468,6 +475,24 @@ namespace KJD_Web.BLL.BXX prod.sku_img_replace_base64 = row["img_base64"].ToString(); //prod.sku_img_replace_url = row["img_url"].ToString(); prod.wx_img_map_json = row["wx_img_map_json"].ToString(); + + if(!prod.sku_secret_json.IsNullOrEmpty() && prod.secret_spu_id.IsNullOrEmpty()) + { + var secret_json = prod.sku_secret_json; + var goodsId = RegexUtils.GetStringJson(ref secret_json, "goodsId"); + prod.secret_spu_id = goodsId; + if (!string.IsNullOrWhiteSpace(goodsId)) + { + mySql = new MysqlUtils(conn); + try + { + sql = "update bxx.product set secret_spu_id='" + goodsId + "' where spu_id='" + prod.spu_id + "'"; + mySql.ExecuteNonQuery(sql); + } + catch { } + mySql.Close(); + } + } } if (!string.IsNullOrEmpty(get_select_count)) { diff --git a/KJDService/KJD_WebService/BLL/KJD/ToolManage.cs b/KJDService/KJD_WebService/BLL/KJD/ToolManage.cs index ba1b975..efa41f7 100644 --- a/KJDService/KJD_WebService/BLL/KJD/ToolManage.cs +++ b/KJDService/KJD_WebService/BLL/KJD/ToolManage.cs @@ -1,4 +1,5 @@ using KJD_Web.Utils; +using NaiBa.Util.Extension; using System; using System.Collections.Generic; using System.Linq; @@ -32,6 +33,29 @@ namespace KJD_Web.BLL public void CreateTable() { + +// string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; +// MysqlUtils mySql = new MysqlUtils(conn); +// string sql = ""; +// for (int i = 0; i < 1024; i++) +// { +// sql = @"drop table if exists wxxd_product_shop_map.product_shop_map_" + i.ParseToString().PadLeft(4, '0') + ";\r\n"; +// sql += @" +//CREATE TABLE wxxd_product_shop_map.product_shop_map_" + i.ParseToString().PadLeft(4, '0') + @" ( +// `id` int NOT NULL AUTO_INCREMENT, +// `up_secret_spu_id` varchar(50) NOT NULL COMMENT '加密源商品id信息,此字段为分表依据,对应商品货号字段', +// `up_spu_id` varchar(50) NOT NULL COMMENT '源商品id信息', +// `shop_id` varchar(50) NOT NULL COMMENT '上传到的店铺id', +// `add_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, +// PRIMARY KEY(`id`), +// KEY `index_add_time` (`add_time`) USING BTREE, +// KEY `index_up_secret_spu_id_shop_id` (`up_secret_spu_id`, `shop_id`) USING BTREE +//) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '记录微信商品上传到哪些店铺的信息'"; +// var rst = mySql.ExecuteNonQuery(sql); +// } +// mySql.Close(); + + // string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; // MysqlUtils mySql = new MysqlUtils(conn); // string sql = ""; @@ -85,9 +109,9 @@ namespace KJD_Web.BLL - string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; - MysqlUtils mySql = new MysqlUtils(conn); - string sql = ""; + //string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; + //MysqlUtils mySql = new MysqlUtils(conn); + //string sql = ""; // for (int i = 1; i <= 12; i++) // { @@ -166,7 +190,7 @@ namespace KJD_Web.BLL // // sql = "ALTER TABLE\r\n kjd_order.order_code_" + i + " DROP COLUMN `subPurchaseOrderSn`,\r\n DROP COLUMN `jiaTongCode`,\r\n DROP COLUMN `shippingMark​Md5`,\r\n DROP COLUMN `shippingMarkBase64`,\r\n CHANGE COLUMN `barCodeMd5` `fileCodeMd5` varchar (32) NOT NULL,\r\n CHANGE COLUMN `barCodeBase64` `fileCodeBase64` longtext NOT NULL,\r\nMODIFY\r\n COLUMN `add_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP\r\nAFTER\r\n `fileCodeBase64`,\r\nMODIFY\r\n COLUMN `mdy_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP\r\nAFTER\r\n `add_time`,\r\n DROP INDEX `index_subPurchaseOrderSn`,\r\nADD\r\n UNIQUE `index_fileCodeMd5` USING btree (`fileCodeMd5`)"; // var rst = mySql.ExecuteNonQuery(sql); //} - mySql.Close(); + //mySql.Close(); } } } \ No newline at end of file diff --git a/KJDService/KJD_WebService/BLL/WXXD/WXProductManage.cs b/KJDService/KJD_WebService/BLL/WXXD/WXProductManage.cs index 81890f0..220e6b4 100644 --- a/KJDService/KJD_WebService/BLL/WXXD/WXProductManage.cs +++ b/KJDService/KJD_WebService/BLL/WXXD/WXProductManage.cs @@ -419,6 +419,67 @@ namespace KJD_Web.BLL.WXXD return new BXX.BXXProductManage().MdyProduct(inputData); } + public string WXAddSecretSpuIdShopIdMap(string inputData) + { + if (!string.IsNullOrEmpty(inputData)) + { + var time = RegexUtils.GetStringQuery(ref inputData, "time").ParseToInt(); + string time1 = RegexUtils.GetStringQuery(ref inputData, "code"); + if (time1 != EncrypUtil.Encryption(time)) + return "{\"code\":50000,\"msg\":\"校验失败\"}"; + + var up_secret_spu_id = RegexUtils.GetStringQuery(ref inputData, "up_secret_spu_id")?.Replace("'", "\\'"); + if (string.IsNullOrEmpty(up_secret_spu_id)) + { + return "{\"code\":500,\"msg\":\"缺少商品编号1\"}"; + } + var index = RegexUtils.GetStringQuery(ref inputData, "index").ParseToNullableLong(); + if (index == null) + index = up_secret_spu_id.ParseToLong() % 1024; + var up_spu_id = RegexUtils.GetStringQuery(ref inputData, "up_spu_id")?.Replace("'", "\\'"); + if (string.IsNullOrEmpty(up_spu_id)) + { + return "{\"code\":500,\"msg\":\"缺少商品编号2\"}"; + } + var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id")?.Replace("'", "\\'"); + if (string.IsNullOrEmpty(shop_id)) + { + return "{\"code\":500,\"msg\":\"缺少店铺编号\"}"; + } + + string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; + MysqlUtils mySql = new MysqlUtils(conn); + string sql = "select id from wxxd_product_shop_map.product_shop_map_" + index.ParseToString().PadLeft(4, '0') + + " where up_secret_spu_id='" + up_secret_spu_id + "'and shop_id='" + shop_id + "'"; + + DataTable dt = mySql.ExecuteDataTable(sql); + if (!string.IsNullOrEmpty(mySql.Message) || dt == null || dt.Rows == null) + { + mySql.Close(); + return "{\"code\":500,\"msg\":\"失败:" + mySql.Message + "\"}"; + } + if (dt.Rows.Count > 0) + { + mySql.Close(); + return "{\"code\":200,\"msg\":\"数据已存在\"}"; + } + + sql = "insert into wxxd_product_shop_map.product_shop_map_" + index.ParseToString().PadLeft(4, '0') + + " (up_secret_spu_id,up_spu_id,shop_id) " + + " values ('" + up_secret_spu_id + "','" + up_spu_id + "','" + shop_id + "');"; + mySql.ExecuteNonQuery(sql); + mySql.Close(); + if (mySql.Message.IsNullOrEmpty()) + { + return "{\"code\":200,\"msg\":\"成功\"}"; + } + else + { + return "{\"code\":500,\"msg\":\"失败:" + mySql.Message + "\"}"; + } + } + return "{\"code\":19999,\"msg\":\"输入为空\"}"; + } public string WXAddMdyAfterSale(string inputData) { @@ -548,7 +609,6 @@ namespace KJD_Web.BLL.WXXD return "{\"code\":19999,\"msg\":\"输入为空\"}"; } - public string WXAddMdyShippingTemplate(string inputData) { if (!string.IsNullOrEmpty(inputData)) diff --git a/KJDService/KJD_WebService/KJD_WebService.csproj.user b/KJDService/KJD_WebService/KJD_WebService.csproj.user index a48a5b1..1b87364 100644 --- a/KJDService/KJD_WebService/KJD_WebService.csproj.user +++ b/KJDService/KJD_WebService/KJD_WebService.csproj.user @@ -1,4 +1,4 @@ - + true diff --git a/KJDService/KJD_WebService/Model/DBProductResultParam.cs b/KJDService/KJD_WebService/Model/DBProductResultParam.cs index bd3df7c..3e2495c 100644 --- a/KJDService/KJD_WebService/Model/DBProductResultParam.cs +++ b/KJDService/KJD_WebService/Model/DBProductResultParam.cs @@ -50,6 +50,7 @@ namespace KJD_Web.Model /// public string change_cat_name { get; set; } public string ext_code { get; set; } + public string secret_spu_id { get; set; } /// /// 拼多多 设置类目价格 /// diff --git a/KJDService/KJD_WebService/WXProductService.asmx.cs b/KJDService/KJD_WebService/WXProductService.asmx.cs index c9e5761..43e5664 100644 --- a/KJDService/KJD_WebService/WXProductService.asmx.cs +++ b/KJDService/KJD_WebService/WXProductService.asmx.cs @@ -122,6 +122,18 @@ namespace KJD_Web Context.Response.End(); } + [WebMethod] + public void add_secret_spu_id_shop_id_map() + { + string jsontext = GetRequestJsonString(); + + var result = jsontext; + result = new WXProductManage().WXAddSecretSpuIdShopIdMap(jsontext); + + Context.Response.Write(result); + Context.Response.End(); + } + //WXAddMdyAfterSale [WebMethod] public void wx_add_mdy_after_sale() diff --git a/TEMUKJD/BLL/PDDProdFormConverter.cs b/TEMUKJD/BLL/PDDProdFormConverter.cs index e099485..96e0fb5 100644 --- a/TEMUKJD/BLL/PDDProdFormConverter.cs +++ b/TEMUKJD/BLL/PDDProdFormConverter.cs @@ -724,11 +724,12 @@ namespace TemuKJD.BLL } } goods_propertie_item propInfo = new goods_propertie_item(); + prodInfo.property.goods_properties.Add(propInfo); propInfo.name = name; propInfo.ref_pid = jProp["refPid"].ParseToInt(); string propStr = JsonHelper.SerializeObject(jProp); propInfo.values = new List(); - if (propStr.Contains("multipleValue")) + if (propStr.Contains("multipleValue") && !propStr.Contains("\"multipleValue\":[]")) { foreach (var propValueObj in jProp["multipleValue"]) { @@ -745,6 +746,9 @@ namespace TemuKJD.BLL { var label = BaseRegex.GetStringJson(ref propStr, "label"); var valueId = BaseRegex.GetStringJson(ref propStr, "value").ParseToLong(); + if (string.IsNullOrEmpty(label)) + label = BaseRegex.GetStringJson(ref propStr, "inputValue") + " " + BaseRegex.GetStringJson(ref propStr, "valueUnit"); + label = label.Trim(); propInfo.values.Add(new value_item() { value = label, diff --git a/TEMUKJD/ToolForms/GetJuShuitanProdForm.cs b/TEMUKJD/ToolForms/GetJuShuitanProdForm.cs index 13de8c5..323c232 100644 --- a/TEMUKJD/ToolForms/GetJuShuitanProdForm.cs +++ b/TEMUKJD/ToolForms/GetJuShuitanProdForm.cs @@ -824,6 +824,7 @@ namespace TemuKJD.ToolForms jstPddShopId = BaseRegex.GetStringJson(ref getShopIdRst, "shopId"); } + // 获取属性 var getPropRst = GetPddProp(shop, prod, prod.dbProduct.cat_id, jstPddShopId); if (!getPropRst.Contains("\"success\":true")) { @@ -849,11 +850,45 @@ namespace TemuKJD.ToolForms name_alias = pObj["name_alias"].IsJTokenNullOrEmpty() ? null : pObj["name_alias"].ParseToString(), }); } + if (pddPropMap.Count == 0 && 1==2) + { + // 取商品属性 作废 + getPropRst = GetPddPropForUpdate(shop, prod, prod.dbProduct.cat_id, jstPddShopId); + if (!getPropRst.Contains("\"success\":true")) + { + var errMsg = BaseRegex.GetStringJson(ref getPropRst, "message"); + if (string.IsNullOrEmpty(errMsg)) + errMsg = getPropRst; + prod.getProductMsg = "采集失败 " + errMsg; + Invoke(new Action(() => + { + try { row.Cells["colMsg"].Value = prod.getProductMsg; } catch { } + })); + continue; + } + pddPropMap = new List(); + pddPropObj = JsonHelper.JObjectParse(getPropRst)["data"]; + foreach (JObject pObj in pddPropObj["cateAttrList"]) + { + pddPropMap.Add(new PDDPropRefPidNameMap() + { + id = pObj["id"].IsJTokenNullOrEmpty() ? new long?() : pObj["id"].ParseToLong(), + ref_pid = pObj["ref_pid"].IsJTokenNullOrEmpty() ? new long?() : pObj["ref_pid"].ParseToLong(), + name = pObj["name"].IsJTokenNullOrEmpty() ? null : pObj["name"].ParseToString(), + name_alias = pObj["name_alias"].IsJTokenNullOrEmpty() ? null : pObj["name_alias"].ParseToString(), + }); + } + } + // 没有属性的预测属性 // 不进行类目属性预测 //var getPropRstV2 = GetPddPropForecastV2(shop, prod, prod.dbProduct.cat_id); prod.dbProduct.main_cat_id = jObj["categoryData"].FirstOrDefault().ParseToString(); var prodDataJson = JsonHelper.SerializeObject(jObj); + //if (jObj["pddPropMap"].IsJTokenNullOrEmpty() && !jObj["pddData"]["categoryPropStr"].IsJTokenNullOrEmpty()) + //{ + + //} var propMapJson = JsonHelper.SerializeObject(pddPropMap); prod.dbProduct.product_json = "{\"pddData\":" + prodDataJson + ",\"pddPropMap\":" + propMapJson + ",\"jstProd\":" + prod.jstProductJson + "}"; var priceMin = jObj["skuInfo"]["goodsSkuDetail"].Min(s => s["supplyPrice"].ParseToDecimal()); @@ -1039,6 +1074,21 @@ namespace TemuKJD.ToolForms return response; } + public string GetPddPropForUpdate(ShopLoginInfo shop, JSTListProductInfo jstLstProd, string catId, string shopId = "20115638") + { + string url = "https://sc.scm121.com/api/goods/supplier/shopManage/querySupplierShopSpuForUpdate"; + string referer = "https://sc.scm121.com/manage/goods/qualitySupplier/detail/" + jstLstProd.supplierId + "?showErpList=1"; + string body = @"{""itemSpuId"":""" + jstLstProd.itemSpuId + @""",""shopType"":""Pinduoduo"",""itemCoId"":""" + jstLstProd.itemCoId + + @""",""companyType"":""SUPPLIER""}"; + var propRst = ""; + for (int i = 0; i < 3 && !propRst.Contains("\"success\":true"); i++) + { + Thread.Sleep(Randomx.GetId(1000, 2000)); + propRst = JSTHttpResponseBLL.JSTPostResponse(shop, url, body, referer, appVersion); + } + return propRst; + } + /// /// 没有商品属性的,类目属性预测 /// diff --git a/TEMUKJD/WXForms/ProductForms/WXDBProdUploadForm.cs b/TEMUKJD/WXForms/ProductForms/WXDBProdUploadForm.cs index 2b33db4..7ec8123 100644 --- a/TEMUKJD/WXForms/ProductForms/WXDBProdUploadForm.cs +++ b/TEMUKJD/WXForms/ProductForms/WXDBProdUploadForm.cs @@ -50,8 +50,8 @@ namespace TemuKJD.WXForms.ProductForms public Dictionary dicShopUpload = new Dictionary(); public string pdd_product_cates = ""; public List forceFilteKeyWords = new List() - { - "亏本", "冲量", "白菜价", "跳楼价", "xxx", "xx", "最大", "最小", "低价", "降价", "成本", "赔钱", "甩卖", + { + "顶级", "之王", "二手", "亏本", "冲量", "白菜价", "跳楼价", "xxx", "xx", "最大", "最小", "低价", "降价", "成本", "赔钱", "甩卖", "真丝", "蚕丝", "香云纱", "羊绒", "羊毛", "羊羔绒", "羊羔毛", "羽绒", "皮草" }; public WXDBProdUploadForm() @@ -1223,7 +1223,7 @@ namespace TemuKJD.WXForms.ProductForms } #endregion - #region 将聚水潭产品数据格式进行转换成pdd格式统一上传,匹配加密的spuCode和skuCoke + #region 将聚水潭产品数据格式进行转换成pdd格式统一上传,匹配加密的spuCode和skuCoke 微信小店的货号spuCode和外部商品编号outProductId/out_product_id对应加密的聚水潭goodsId if (dbProd.sku_secret_json != null && dbProd.sku_secret_json.Contains("goodsId")) { string convertRst = ""; @@ -2153,6 +2153,13 @@ namespace TemuKJD.WXForms.ProductForms var shipRst = GetHtml.PostUtf8(urlShip, dataShip); if (string.IsNullOrEmpty(shipRst) || !shipRst.Contains("\"code\":0")) shipRst = GetHtml.PostUtf8(urlShipping, dataShipping); + if (!shipRst.Contains("\"code\":0")) + { + var errMsg = BaseRegex.GetStringJson(ref shipRst, "msg"); + if (string.IsNullOrEmpty(errMsg)) + errMsg = shipRst; + return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"运费模板获取失败 " + errMsg + "\"}"; + } try { //[{"id":"204","warehouseNum":"15016108","freightType":0,"provinces":"香港特别行政区,台湾省,澳门特别行政区","freightPrice":9999900,"createBy":"vmslin","createTime":"2026-01-30T16:45:03+08:00","updateBy":"vmslin","updateTime":"2026-01-30T16:45:03+08:00"},{"id":"205","warehouseNum":"15016108","freightType":3,"provinces":"海南省,新疆维吾尔自治区,西藏自治区,内蒙古自治区","freightPrice":1530,"createBy":"vmslin","createTime":"2026-01-30T16:45:51+08:00","updateBy":"vmslin","updateTime":"2026-01-30T16:45:51+08:00"},{"id":"206","warehouseNum":"15016108","freightType":1,"provinces":"北京市,上海市","freightPrice":410,"createBy":"vmslin","createTime":"2026-01-30T16:46:04+08:00","updateBy":"vmslin","updateTime":"2026-01-30T16:46:04+08:00"},{"id":"207","warehouseNum":"15016108","freightType":1,"provinces":"安徽省,重庆市,福建省,广东省,甘肃省,广西壮族自治区,贵州省,河北省,湖北省,黑龙江省,河南省,湖南省,吉林省,江苏省,江西省,辽宁省,宁夏回族自治区,青海省,四川省,山东省,山西省,陕西省,天津市,云南省,浙江省","freightPrice":310,"createBy":"vmslin","createTime":"2026-01-30T16:46:17+08:00","updateBy":"vmslin","updateTime":"2026-01-30T16:46:17+08:00"}] @@ -2381,6 +2388,11 @@ namespace TemuKJD.WXForms.ProductForms foreach (var propInfo in prodInfo.property.goods_properties) { var attr = productAttr.attr.FirstOrDefault(r => r.name == propInfo.name); + if (propInfo.name == "生产日期") + { + propInfo.values.FirstOrDefault().value = DateTime.Now.Date.AddDays(-15).ToString("yyyy-MM-dd"); + propInfo.values.FirstOrDefault().raw_value = propInfo.values.FirstOrDefault().value; + } if (attr == null) { if (propInfo.name.Contains("面料俗称")) @@ -2418,6 +2430,33 @@ namespace TemuKJD.WXForms.ProductForms else if (propInfo.name == "包册数") attr = productAttr.attr.FirstOrDefault(r => 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 == "食品生产许可证编号") + 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 == "配料表"); + //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) { @@ -2425,6 +2464,27 @@ namespace TemuKJD.WXForms.ProductForms } var attrValueLst = attr.value.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries).ToList(); var attrValue = attrValueLst.FirstOrDefault(v => v == propInfo.values.FirstOrDefault().value); + if (propInfo.name == "保质期" ) + { + attrValue = "30 天"; + if (propInfo.values.FirstOrDefault().value.Contains("年") || propInfo.values.FirstOrDefault().value.Contains("月") + || propInfo.values.FirstOrDefault().value.Contains("日") || propInfo.values.FirstOrDefault().value.Contains("天") + || propInfo.values.FirstOrDefault().value.Contains("见包装")) + { + attrValue = propInfo.values.FirstOrDefault().value; + } + if (attrValue.Contains("天") && attrValue.Replace("天", "").ParseToInt() < 30) + { + return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"食品保质期小于30天,跳过上传\"}"; + } + } + + if (propInfo.name == "产品重量" ) + { + attrValue = "10g"; + if (propInfo.values.FirstOrDefault().value.Contains("g") || propInfo.values.FirstOrDefault().value.Contains("kg")) + attrValue = propInfo.values.FirstOrDefault().value; + } if (propInfo.name == "风格" && attrValue == null) { attrValue = attrValueLst.FirstOrDefault(v => v == propInfo.values.FirstOrDefault().value + "风"); @@ -2527,6 +2587,8 @@ namespace TemuKJD.WXForms.ProductForms else if (attr.name == "是否进口") { attrValue = "非进口"; + if (attr.value == "是;否") + attrValue = "否"; } else if (attr.name == "商品产地") { @@ -2561,6 +2623,45 @@ namespace TemuKJD.WXForms.ProductForms if (attr.name == "包装") attrValue = "平装"; } + if (upProdParam.product.info.category.FirstOrDefault()?.name == "食品饮料" || prodInfo.detail.cats.FirstOrDefault() == "食品饮料") + { + if (attr.name == "食品名称") + attrValue = upProdParam.product.info.title; + if (attr.name == "生产企业名称") + attrValue = "见包装"; + if (attr.name == "食品生产许可证编号") + { + attrValue = "SC10241162100670"; + attrValue = "见包装"; + } + if (attr.name == "产品标准号") + { + attrValue = "GB 2726"; + attrValue = "见包装"; + } + if (attr.name == "生产日期") + attrValue = DateTime.Now.Date.AddDays(-15).ToString("yyyy-MM-dd"); + if (attr.name == "净含量") + attrValue = "见包装"; + if (attr.name == "单件净含量") + { + //attrValue = "见包装"; + } + if (attr.name == "包装方式") + attrValue = "袋装"; + if (attr.name == "配料表") + attrValue = "水"; + if (attr.name == "联系方式") + attrValue = "无"; + if (attr.name == "地址") + attrValue = "见包装"; + if (attr.name == "贮存条件") + attrValue = "常温"; + if (attr.name == "保质期") + { + return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"食品属性不含保质期,跳过上传\"}"; + } + } } if (attrValue.IsNullOrEmpty() && attr.type == "string") { @@ -2576,6 +2677,8 @@ namespace TemuKJD.WXForms.ProductForms attrValue = "10 g"; else if (attr.value == "kg") attrValue = "1 kg"; + else if (attr.value == "g;kg;ml;L") + attrValue = "100 g"; } var wxPropParam = new propParam(); @@ -2619,6 +2722,30 @@ namespace TemuKJD.WXForms.ProductForms 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 (upProdParam.product.info.category.FirstOrDefault()?.name == "食品饮料" || prodInfo.detail.cats.FirstOrDefault() == "食品饮料") + { + if (selectProd.cat_name == "坚果炒货" || selectProd.cat_name == "果干") + { + if (!prodInfo.detail.sku.FirstOrDefault().spec.Any(s => s.parent_name == "规格/净含量")) + { + foreach (var sku in prodInfo.detail.sku) + { + sku.spec.FirstOrDefault().parent_name = "规格/净含量"; + } + } + } + else + { + if (!prodInfo.detail.sku.FirstOrDefault().spec.Any(s => s.parent_name == "规格")) + { + foreach (var sku in prodInfo.detail.sku) + { + sku.spec.FirstOrDefault().parent_name = "规格"; + } + } + } + } if (prodInfo.detail.sku.FirstOrDefault()?.spec?.Count > 0) { productSaleAttrParam attrParam = new productSaleAttrParam() @@ -2982,6 +3109,94 @@ namespace TemuKJD.WXForms.ProductForms } #endregion + #region 食品类生成食品图片 + //qualificationList + if (upProdParam.product.info.category.FirstOrDefault()?.name == "食品饮料" || prodInfo.detail.cats.FirstOrDefault() == "食品饮料") + { + if (cell != null) + { + Invoke(new Action(() => + { + cell.Value = "正在生成食品饮料专有信息"; + })); + } + + + string foodName = "食品名称:"; + string companyName = "生产企业名称:见包装"; + string SCID = "食品生产许可证编号:SC10241162100670"; + string GBID = "产品标准号:GB 2726"; + string ExpDate = "保质期:30天"; + string MakeDate = "生产日期:" + DateTime.Now.AddDays(-15).ToString("yyyy-MM-dd"); + string NetContent = "净含量:见包装"; + string Pack = "包装方式:袋装"; + string inList = "配料表:水"; + string contact = "联系方式:无"; + string address = "地址:见包装"; + string Storage = "贮存条件:常温"; + + foreach (var propParam in upProdParam.product.info.param) + { + if (propParam.categorys[0].name.Contains("食品名称")) + foodName = "食品名称:" + propParam.categorys[1].name; + else if (propParam.categorys[0].name.Contains("生产企业名称")) + companyName = "生产企业名称:" + propParam.categorys[1].name; + else if (propParam.categorys[0].name.Contains("食品生产许可证编号") && propParam.categorys[1].name != "见包装") + SCID = "食品生产许可证编号:" + propParam.categorys[1].name; + else if (propParam.categorys[0].name.Contains("产品标准号") && propParam.categorys[1].name != "见包装") + GBID = "产品标准号:" + propParam.categorys[1].name; + else if (propParam.categorys[0].name.Contains("保质期")) + ExpDate = "保质期:" + propParam.categorys[1].name; + else if (propParam.categorys[0].name.Contains("生产日期")) + MakeDate = "生产日期:" + propParam.categorys[1].name; + else if (propParam.categorys[0].name.Contains("净含量")) + NetContent = "净含量:" + propParam.categorys[1].name; + else if (propParam.categorys[0].name.Contains("包装方式")) + Pack = "包装方式:" + propParam.categorys[1].name; + else if (propParam.categorys[0].name.Contains("配料表")) + inList = "配料表:" + propParam.categorys[1].name; + else if (propParam.categorys[0].name.Contains("联系方式")) + contact = "联系方式:" + propParam.categorys[1].name; + else if (propParam.categorys[0].name.Contains("地址")) + address = "地址:" + propParam.categorys[1].name; + else if (propParam.categorys[0].name.Contains("贮存条件")) + Storage = "贮存条件:" + propParam.categorys[1].name; + } + + var bookStr = foodName + "\r\n" + "\r\n"; + bookStr += companyName + "\r\n" + "\r\n"; + bookStr += SCID + "\r\n" + "\r\n"; + bookStr += GBID + "\r\n" + "\r\n"; + bookStr += ExpDate + "\r\n" + "\r\n"; + bookStr += MakeDate + "\r\n" + "\r\n"; + bookStr += NetContent + "\r\n" + "\r\n"; + bookStr += Pack + "\r\n" + "\r\n"; + bookStr += inList + "\r\n" + "\r\n"; + bookStr += contact + "\r\n" + "\r\n"; + bookStr += address + "\r\n" + "\r\n"; + bookStr += Storage + "\r\n" + "\r\n"; + + 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 = "50000057", qualificationUrl = new List() { location }, }); + } + #endregion + if (cell != null) { Invoke(new Action(() => @@ -3184,6 +3399,25 @@ namespace TemuKJD.WXForms.ProductForms if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200")) html = GetHtml.PostUtf8(url, data); } + //add_secret_spu_id_shop_id_map //测试id "2017522348787531778" FC4C8B7F3C6E4B029AD2A12D4D323B41 + if (!string.IsNullOrEmpty(dbProd.secret_spu_id)) + { + var url = BaseClass.BuildObjString("product/add_secret_spu_id_shop_id_map"); + var data = ""; + Invoke(new Action(() => + { + data = UserLogin.GetSignaturex(); + data += "&up_secret_spu_id=" + dbProd.secret_spu_id; + data += "&up_spu_id=" + dbProd.spu_id; + data += "&shop_id=" + shop.ShopId; + data += "&index=" + dbProd.secret_spu_id.ParseToLong() % 1024; + })); + var 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); + } //colUploadCount var dgvShopRow = dgvShop.Rows.Cast().FirstOrDefault(row => row.Cells["colShopId"]?.Value.ParseToString() == shop.ShopId); @@ -4352,7 +4586,7 @@ Content-Type: application/octet-stream { public int PreSaleDays { get; set; } = 5; - public string FilterWords { get; set; } = "二手,亏本,冲量,白菜价,跳楼价,xx,xxx,最大,最小,低价,降价,成本,赔钱,甩卖,真丝,蚕丝,香云纱,羊绒,羊毛,羊羔绒,羊羔毛,羽绒,皮草"; + public string FilterWords { get; set; } = "顶级,之王,二手,亏本,冲量,白菜价,跳楼价,xx,xxx,最大,最小,低价,降价,成本,赔钱,甩卖,真丝,蚕丝,香云纱,羊绒,羊毛,羊羔绒,羊羔毛,羽绒,皮草"; public int SkuMinPrice { get; set; } = 10; diff --git a/TEMUKJD/WXForms/ProductForms/WXProdPreSaleForm.cs b/TEMUKJD/WXForms/ProductForms/WXProdPreSaleForm.cs index d39549e..efe836d 100644 --- a/TEMUKJD/WXForms/ProductForms/WXProdPreSaleForm.cs +++ b/TEMUKJD/WXForms/ProductForms/WXProdPreSaleForm.cs @@ -1280,7 +1280,7 @@ namespace TemuKJD.WXForms.ProductForms { public int PreSaleDays { get; set; } = 5; - public string FilterWords { get; set; } = "二手,亏本,冲量,白菜价,跳楼价,xx,xxx,最大,最小,低价,降价,成本,赔钱,甩卖,真丝,蚕丝,香云纱,羊绒,羊毛,羊羔绒,羊羔毛,羽绒,皮草"; + public string FilterWords { get; set; } = "顶级,之王,二手,亏本,冲量,白菜价,跳楼价,xx,xxx,最大,最小,低价,降价,成本,赔钱,甩卖,真丝,蚕丝,香云纱,羊绒,羊毛,羊羔绒,羊羔毛,羽绒,皮草"; public int SkuMinPrice { get; set; } = 10;