From dc977c45d8c5119b5cec67bac967bc73afb03450 Mon Sep 17 00:00:00 2001 From: wule Date: Tue, 8 Sep 2026 20:51:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=91=E5=BA=93=E6=95=B0=E6=8D=AE=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AllBase/Model/Result/KJDDBProduct.cs | 1 + AllBase/Model/Result/TemuDBProductSelect.cs | 1 + .../ImportConverters/ConvertToPddFactory.cs | 24 +++- .../BLL/ImportConverters/IGoodsConverter.cs | 46 ++++--- TEMUKJD/BLL/PDDProdFormConverter.cs | 70 ++++++---- TEMUKJD/MainForm.cs | 79 ++++++----- .../ProductSelectForms/CloudGoodsForm.cs | 4 +- ...PDDDBProdUploadSelectCacheForm.Designer.cs | 10 ++ .../PDDDBProdUploadSelectCacheForm.cs | 2 + .../PDDDBProdUploadSelectCacheForm.resx | 3 + .../ProductForms/WXDBProdUploadForm.cs | 130 ++++++++++++++++-- .../WXUserCollectAuthProdListForm.cs | 1 + 12 files changed, 275 insertions(+), 96 deletions(-) diff --git a/AllBase/Model/Result/KJDDBProduct.cs b/AllBase/Model/Result/KJDDBProduct.cs index 80c411c..d1f737c 100644 --- a/AllBase/Model/Result/KJDDBProduct.cs +++ b/AllBase/Model/Result/KJDDBProduct.cs @@ -86,6 +86,7 @@ namespace AllBase.Model.Result /// public int product_get_type { get; set; } public string product_get_type_text { get; set; } + public string db_type { get; set; } public string head_words { get; set; } public string end_words { get; set; } public string fission_words { get; set; } diff --git a/AllBase/Model/Result/TemuDBProductSelect.cs b/AllBase/Model/Result/TemuDBProductSelect.cs index 6e72932..c57343d 100644 --- a/AllBase/Model/Result/TemuDBProductSelect.cs +++ b/AllBase/Model/Result/TemuDBProductSelect.cs @@ -53,6 +53,7 @@ namespace AllBase.Model.Result public KJDDBProduct kjdDbProduct { get; set; } = null; public WXUploadProductParam wxDraftProduct { get; set; } = null; public string product_get_type_text { get; set; } + public string db_type { get; set; } = "基础数据"; #endregion } } diff --git a/TEMUKJD/BLL/ImportConverters/ConvertToPddFactory.cs b/TEMUKJD/BLL/ImportConverters/ConvertToPddFactory.cs index 4c6dd63..25dc756 100644 --- a/TEMUKJD/BLL/ImportConverters/ConvertToPddFactory.cs +++ b/TEMUKJD/BLL/ImportConverters/ConvertToPddFactory.cs @@ -1,4 +1,5 @@ using AllBase.Model.Result.PDDResult; +using NaiBa.Util.Extension; using System; using System.Collections.Generic; using System.Linq; @@ -38,5 +39,26 @@ namespace TemuKJD.BLL.ImportConverts return null; } - } + + public static PDDFrontProductInfo5 SetContentConvert(string content) + { + + foreach (IGoodsConverter item in _converters) + { + try + { + item.SetContent(content.ParseToString()); + if (item.IsMatch()) + { + return item.Convert(); + } + } + catch (Exception ex) + { + throw ex; + } + } + return null; + } + } } diff --git a/TEMUKJD/BLL/ImportConverters/IGoodsConverter.cs b/TEMUKJD/BLL/ImportConverters/IGoodsConverter.cs index 5656b10..a9ba3bb 100644 --- a/TEMUKJD/BLL/ImportConverters/IGoodsConverter.cs +++ b/TEMUKJD/BLL/ImportConverters/IGoodsConverter.cs @@ -31,16 +31,21 @@ namespace TemuKJD.BLL.ImportConverters /// 支持的平台类型 /// PlatformType Platform { get; } - /// - /// 读取内容 - /// - /// - void ReadContent(string filePath); - /// - /// 判断是否匹配当前转换器 - /// - /// 是否匹配 - bool IsMatch(); + /// + /// 读取内容 + /// + /// + void ReadContent(string filePath); + /// + /// 直接赋值内容 + /// + /// + void SetContent(string content); + /// + /// 判断是否匹配当前转换器 + /// + /// 是否匹配 + bool IsMatch(); /// /// 转换为标准商品模型 @@ -56,11 +61,15 @@ namespace TemuKJD.BLL.ImportConverters public abstract string ConverterName { get; } public abstract PlatformType Platform { get; } - void IGoodsConverter.ReadContent(string filePath) - { - ReadContent(filePath); - } - protected virtual void ReadContent(string filePath) + void IGoodsConverter.ReadContent(string filePath) + { + ReadContent(filePath); + } + void IGoodsConverter.SetContent(string content) + { + SetContent(content); + } + protected virtual void ReadContent(string filePath) { if (File.Exists(filePath) == false) throw new Exception("文件不存在"); FilePath = filePath; @@ -69,9 +78,12 @@ namespace TemuKJD.BLL.ImportConverters RawData = sr.ReadToEnd(); } } + protected virtual void SetContent(string content) + { + RawData = content; + } - - public virtual bool IsMatch() + public virtual bool IsMatch() { _isMatch = true; return IsMatchProvider(); diff --git a/TEMUKJD/BLL/PDDProdFormConverter.cs b/TEMUKJD/BLL/PDDProdFormConverter.cs index df570c8..ae5ce13 100644 --- a/TEMUKJD/BLL/PDDProdFormConverter.cs +++ b/TEMUKJD/BLL/PDDProdFormConverter.cs @@ -8,6 +8,7 @@ using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Linq; +using System.Security.Cryptography.X509Certificates; using System.Text; using System.Threading.Tasks; using TemuKJD.BLL.ImportConverts; @@ -16,7 +17,7 @@ using Work; namespace TemuKJD.BLL { public class PDDProdFormConverter - { + { /// /// 拼多多前端采集转拼多多后台采集数据 /// @@ -24,7 +25,7 @@ namespace TemuKJD.BLL /// /// /// - public string PddFrontToPddBackConvert(string outProdJson, bool UpdateOldData = true, string specialProdType = null, bool IsCollectAuthorityUser = false) + public string PddFrontToPddBackConvert(string outProdJson, bool UpdateOldData = true, string specialProdType = null, bool IsCollectAuthorityUser = false, bool isSaveDb = true) { PDDFrontProductInfo frontProdInfo = null; try @@ -328,8 +329,12 @@ namespace TemuKJD.BLL dbProd.main_img = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1).url; dbProd.product_json = JsonHelper.SerializeObject(prodInfo); - // 商品采集权限用户采集的数据加上用户前缀(商品前缀显示给用户的时候隐藏) - string collectAuthorityTag = ""; + if (!isSaveDb) + return "success" + dbProd.product_json; + + + // 商品采集权限用户采集的数据加上用户前缀(商品前缀显示给用户的时候隐藏) + string collectAuthorityTag = ""; if (IsCollectAuthorityUser) collectAuthorityTag = "-" + BaseClass.UserName; @@ -406,7 +411,7 @@ namespace TemuKJD.BLL /// /// /// - public string PddFrontToPddBackConvert2(string outProdJson, bool UpdateOldData = true, string specialProdType = null, bool IsCollectAuthorityUser = false) + public string PddFrontToPddBackConvert2(string outProdJson, bool UpdateOldData = true, string specialProdType = null, bool IsCollectAuthorityUser = false, bool isSaveDb = true) { PDDFrontProductInfo2 frontProdInfo = null; try @@ -800,8 +805,11 @@ namespace TemuKJD.BLL dbProd.main_img = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1).url; dbProd.product_json = JsonHelper.SerializeObject(prodInfo); - // 商品采集权限用户采集的数据加上用户前缀(商品前缀显示给用户的时候隐藏) - string collectAuthorityTag = ""; + if (!isSaveDb) + return "success" + dbProd.product_json; + + // 商品采集权限用户采集的数据加上用户前缀(商品前缀显示给用户的时候隐藏) + string collectAuthorityTag = ""; if (IsCollectAuthorityUser) collectAuthorityTag = "-" + BaseClass.UserName; @@ -880,7 +888,7 @@ namespace TemuKJD.BLL /// /// /// - public string PddFrontToPddBackConvert3(string outProdJson3, bool UpdateOldData = true, string specialProdType = null, bool IsCollectAuthorityUser = false) + public string PddFrontToPddBackConvert3(string outProdJson3, bool UpdateOldData = true, string specialProdType = null, bool IsCollectAuthorityUser = false, bool isSaveDb = true) { initDataObjInfo frontProdInfo = null; try @@ -1201,8 +1209,11 @@ namespace TemuKJD.BLL dbProd.main_img = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1).url; dbProd.product_json = JsonHelper.SerializeObject(prodInfo); - // 商品采集权限用户采集的数据加上用户前缀(商品前缀显示给用户的时候隐藏) - string collectAuthorityTag = ""; + if (!isSaveDb) + return "success" + dbProd.product_json; + + // 商品采集权限用户采集的数据加上用户前缀(商品前缀显示给用户的时候隐藏) + string collectAuthorityTag = ""; if (IsCollectAuthorityUser) collectAuthorityTag = "-" + BaseClass.UserName; @@ -1282,7 +1293,7 @@ namespace TemuKJD.BLL /// /// /// - public string PddFrontToPddBackConvertV4(string outProdJson, bool UpdateOldData = true, string specialProdType = null, bool IsCollectAuthorityUser = false) + public string PddFrontToPddBackConvertV4(string outProdJson, bool UpdateOldData = true, string specialProdType = null, bool IsCollectAuthorityUser = false, bool isSaveDb = true) { @@ -1603,8 +1614,11 @@ namespace TemuKJD.BLL dbProd.main_img = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1).url; dbProd.product_json = JsonHelper.SerializeObject(prodInfo); - // 商品采集权限用户采集的数据加上用户前缀(商品前缀显示给用户的时候隐藏) - string collectAuthorityTag = ""; + if (!isSaveDb) + return "success" + dbProd.product_json; + + // 商品采集权限用户采集的数据加上用户前缀(商品前缀显示给用户的时候隐藏) + string collectAuthorityTag = ""; if (IsCollectAuthorityUser) collectAuthorityTag = "-" + BaseClass.UserName; @@ -1675,20 +1689,23 @@ namespace TemuKJD.BLL } - /// - /// 外来格式V5 - /// - /// - /// - /// - /// - /// - public string PddFrontToPddBackConvertFactory(string filePath, bool UpdateOldData = true, string specialProdType = null, bool IsCollectAuthorityUser = false) + /// + /// 外来格式V5 + /// + /// + /// + /// + /// + /// + public string PddFrontToPddBackConvertFactory(string filePath, bool UpdateOldData = true, string specialProdType = null, bool IsCollectAuthorityUser = false, bool isSaveDb = true, string content = null) { PDDFrontProductInfo5 frontProdInfo = null; try { - frontProdInfo = ConverterToPddFactory.Convert(filePath); + if (!content.IsNullOrEmpty()) + frontProdInfo = ConverterToPddFactory.SetContentConvert(content); + else + frontProdInfo = ConverterToPddFactory.Convert(filePath); } catch (Exception ex) { @@ -1992,8 +2009,11 @@ namespace TemuKJD.BLL dbProd.main_img = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1).url; dbProd.product_json = JsonHelper.SerializeObject(prodInfo); - // 商品采集权限用户采集的数据加上用户前缀(商品前缀显示给用户的时候隐藏) - string collectAuthorityTag = ""; + if (!isSaveDb) + return "success" + dbProd.product_json; + + // 商品采集权限用户采集的数据加上用户前缀(商品前缀显示给用户的时候隐藏) + string collectAuthorityTag = ""; if (IsCollectAuthorityUser) collectAuthorityTag = "-" + BaseClass.UserName; diff --git a/TEMUKJD/MainForm.cs b/TEMUKJD/MainForm.cs index a6ed46f..88f8bcd 100644 --- a/TEMUKJD/MainForm.cs +++ b/TEMUKJD/MainForm.cs @@ -1,53 +1,54 @@ -using System; +using AllBase; +using AllBase.Helper; +using AllBase.Model.Param.ProductManage; +using AllBase.Model.Result; +using AllBase.Model.Result.PDDResult; +using AllBase.Model.Result.WXResult; +using CefSharp; +using CefSharp.WinForms; +using DevComponents.DotNetBar; +using NaiBa.CefHelper; +using NaiBa.CefHelper.Handler; +using NaiBa.Util; +using NaiBa.Util.Extension; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; +using System.Drawing.Drawing2D; +using System.IO; +using System.IO.Compression; using System.Linq; +using System.Net; +using System.Reflection; using System.Runtime.InteropServices; +using System.Text; using System.Threading; +using System.Threading.Tasks; using System.Timers; using System.Windows.Forms; -using System.Threading.Tasks; -using CefSharp.WinForms; -using DevComponents.DotNetBar; -using AllBase; -using Work; -using TemuKJD.UserForm; using TemuKJD.BaseForms; -using TemuKJD.KJDForms.ToolForms; -using System.Reflection; -using System.Net; -using System.Collections; +using TemuKJD.Helper; using TemuKJD.KJDForms.AdminForms; -using TemuKJD.KJDForms.ShopForms; -using TemuKJD.KJDForms.ProductForms; -using TemuKJD.KJDForms.OrderForms; -using TemuKJD.KJDForms.SystemForms; -using Work.CollectClass; -using Newtonsoft.Json; -using System.Text; -using System.IO; -using CefSharp; -using System.IO.Compression; -using AllBase.Helper; -using System.Drawing.Drawing2D; -using NaiBa.CefHelper; -using Newtonsoft.Json.Linq; -using AllBase.Model.Result; -using NaiBa.Util.Extension; -using NaiBa.Util; -using AllBase.Model.Param.ProductManage; -using TemuKJD.KJDForms.SalesCenterForms; -using NaiBa.CefHelper.Handler; -using TemuKJD.PDDForms.AdminForms; -using TemuKJD.PDDForms.ShopForms; -using TemuKJD.PDDForms.ProductForms; using TemuKJD.KJDForms.JITForms; -using TemuKJD.WXForms.ShopForms; +using TemuKJD.KJDForms.OrderForms; +using TemuKJD.KJDForms.ProductForms; +using TemuKJD.KJDForms.SalesCenterForms; +using TemuKJD.KJDForms.ShopForms; +using TemuKJD.KJDForms.SystemForms; +using TemuKJD.KJDForms.ToolForms; +using TemuKJD.PDDForms.AdminForms; +using TemuKJD.PDDForms.ProductForms; +using TemuKJD.PDDForms.ShopForms; +using TemuKJD.UserForm; using TemuKJD.WXForms.AdminForms; using TemuKJD.WXForms.ProductForms; -using AllBase.Model.Result.WXResult; -using AllBase.Model.Result.PDDResult; +using TemuKJD.WXForms.ShopForms; +using Work; +using Work.CollectClass; namespace TemuKJD { @@ -208,7 +209,9 @@ namespace TemuKJD var pName = Process.GetCurrentProcess().ProcessName; ProcessCount = Process.GetProcesses().Count(p => p.ProcessName == pName); //138版cef自己不会分缓存,会因占用导致报错,手动分缓存 - settings.CachePath = Path.Combine(Environment.CurrentDirectory, "Cache\\" + ProcessCount); + //settings.CachePath = Path.Combine(Environment.CurrentDirectory, "Cache\\" + ProcessCount); + settings.RootCachePath = Path.Combine(Environment.CurrentDirectory, "Cache"); + //settings.CachePath = Path.Combine(settings.RootCachePath, ProcessCount.ParseToString()); //settings.CachePath = null; //禁止缓存 //settings.CefCommandLineArgs.Add("enable-javascript", "1"); //settings.CefCommandLineArgs.Add("disable-features", "NetworkService,NetworkServiceInProcess"); diff --git a/TEMUKJD/PDDForms/ProductSelectForms/CloudGoodsForm.cs b/TEMUKJD/PDDForms/ProductSelectForms/CloudGoodsForm.cs index 6eb5b2d..af41232 100644 --- a/TEMUKJD/PDDForms/ProductSelectForms/CloudGoodsForm.cs +++ b/TEMUKJD/PDDForms/ProductSelectForms/CloudGoodsForm.cs @@ -418,11 +418,13 @@ namespace TemuKJD.PDDForms.ProductSelectForms } WXDBProdUploadForm.Instance.lstTemuDBProductSelect.Add(new TemuDBProductSelect { - out_product_Id = item.GoodsId.ToString(), + //out_product_Id = item.GoodsId.ToString(), spu_id = item.GoodsId.ToString(), main_img = item.ThumbUrl, product_name = item.Title, cat_name = catName, + product_get_type_text = item.Platform == 1 ? ("多多") : item.Platform == 2 ? ("微信") : ("未知"), + db_type = "云端数据", }); succ++; } diff --git a/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdUploadSelectCacheForm.Designer.cs b/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdUploadSelectCacheForm.Designer.cs index d219d58..6fc8544 100644 --- a/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdUploadSelectCacheForm.Designer.cs +++ b/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdUploadSelectCacheForm.Designer.cs @@ -40,6 +40,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms this.colCheck = new System.Windows.Forms.DataGridViewCheckBoxColumn(); this.colId = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.colGetType = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.colDbType = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.colSpuId = new System.Windows.Forms.DataGridViewLinkColumn(); this.colImgUrl = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.colProductSkcPic = new System.Windows.Forms.DataGridViewImageColumn(); @@ -145,6 +146,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms this.colCheck, this.colId, this.colGetType, + this.colDbType, this.colSpuId, this.colImgUrl, this.colProductSkcPic, @@ -188,6 +190,13 @@ namespace TemuKJD.PDDForms.ProductSelectForms this.colGetType.ReadOnly = true; this.colGetType.Visible = false; // + // colDbType + // + this.colDbType.HeaderText = "商品库"; + this.colDbType.Name = "colDbType"; + this.colDbType.ReadOnly = true; + this.colDbType.Visible = false; + // // colSpuId // this.colSpuId.HeaderText = "商品ID"; @@ -287,6 +296,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms private System.Windows.Forms.DataGridViewCheckBoxColumn colCheck; private System.Windows.Forms.DataGridViewTextBoxColumn colId; private System.Windows.Forms.DataGridViewTextBoxColumn colGetType; + private System.Windows.Forms.DataGridViewTextBoxColumn colDbType; private System.Windows.Forms.DataGridViewLinkColumn colSpuId; private System.Windows.Forms.DataGridViewTextBoxColumn colImgUrl; private System.Windows.Forms.DataGridViewImageColumn colProductSkcPic; diff --git a/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdUploadSelectCacheForm.cs b/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdUploadSelectCacheForm.cs index 88c602b..2007f11 100644 --- a/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdUploadSelectCacheForm.cs +++ b/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdUploadSelectCacheForm.cs @@ -32,6 +32,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms if (BaseClass.UserName == "15288888888") { dgvSelectProduct.Columns["colGetType"].Visible = true; + dgvSelectProduct.Columns["colDbType"].Visible = true; } if (BaseClass.MainPath == "29pdd") { @@ -50,6 +51,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms false, prodSelect.id, prodSelect.product_get_type_text, + prodSelect.db_type, BaseClass.SaLevel > 0 ? prodSelect.spu_id : prodSelect.spu_id.ParseToString().GetHashCode().ParseToString().Trim('-'), prodSelect.main_img, DataGridViewExtension.defaultBitmap, diff --git a/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdUploadSelectCacheForm.resx b/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdUploadSelectCacheForm.resx index 0bc9aec..f3c988a 100644 --- a/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdUploadSelectCacheForm.resx +++ b/TEMUKJD/PDDForms/ProductSelectForms/PDDDBProdUploadSelectCacheForm.resx @@ -126,6 +126,9 @@ True + + True + True diff --git a/TEMUKJD/WXForms/ProductForms/WXDBProdUploadForm.cs b/TEMUKJD/WXForms/ProductForms/WXDBProdUploadForm.cs index 2205cba..2d3c218 100644 --- a/TEMUKJD/WXForms/ProductForms/WXDBProdUploadForm.cs +++ b/TEMUKJD/WXForms/ProductForms/WXDBProdUploadForm.cs @@ -20,6 +20,7 @@ using System.Drawing; using System.IO; using System.Linq; using System.Net.Http; +using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using System.Threading; @@ -34,6 +35,7 @@ using TemuKJD.UserControls; using TemuKJD.WXForms.ShopForms; using Work; using Work.BLL.Tools; +using Work.Services; using static System.Net.Mime.MediaTypeNames; namespace TemuKJD.WXForms.ProductForms @@ -609,8 +611,9 @@ namespace TemuKJD.WXForms.ProductForms RefreshShopLogin(); updateAuthor(); RefreshDbProdGroupAndCate(); + lblWaitToUp.Text = "待上传 " + lstTemuDBProductSelect.Count + " 件"; - if (!isInit) + if (!isInit) { Task.Run(() => { @@ -1252,7 +1255,13 @@ namespace TemuKJD.WXForms.ProductForms KJDDBProduct kjdDbProd = selectProd.kjdDbProduct; string errStr = ""; if (kjdDbProd == null) - kjdDbProd = GetProductDetail(selectProd.out_product_Id.ToString(), out errStr, true, true); + { + if (selectProd.db_type == "云端数据") + kjdDbProd = GetCloudProductDetail(selectProd, out errStr, true, true); + else + kjdDbProd = GetProductDetail(selectProd.out_product_Id.ToString(), out errStr, true, true); + kjdDbProd.db_type = selectProd.db_type; + } if (kjdDbProd == null || kjdDbProd.id == 0) { if (kjdDbProd?.id == 0) @@ -1492,7 +1501,39 @@ namespace TemuKJD.WXForms.ProductForms } } - public static WXGetEditProductInfoLite GetProductWXComplate(string secret_spu_id, out string errMsg) + public static KJDDBProduct GetCloudProductDetail(TemuDBProductSelect selectProd, out string errMsg, bool noViolationProduct = false, bool noBanWx = false) + { + errMsg = ""; + + if (string.IsNullOrEmpty(selectProd?.spu_id)) + { + errMsg = "产品编号为空"; + return new KJDDBProduct(); + } + + var html = CloudGoodsService.GetGoodsDetail(selectProd.spu_id.ParseToLong()); + if (string.IsNullOrEmpty(html) || html.Length < 100) + html = CloudGoodsService.GetGoodsDetail(selectProd.spu_id.ParseToLong()); + if (string.IsNullOrEmpty(html) || html.Length < 100) + { + return null; + } + + try + { + KJDDBProduct item = JsonHelper.DeserializeJsonToObject(JsonHelper.SerializeObject(selectProd)); + item.product_json = html; + item.id = 29; + + return item; + } + catch (Exception ex) + { + return null; + } + } + + public static WXGetEditProductInfoLite GetProductWXComplate(string secret_spu_id, out string errMsg) { errMsg = ""; @@ -1643,8 +1684,15 @@ namespace TemuKJD.WXForms.ProductForms else { var searchExtCode = dbProd.ext_code; - if (searchExtCode.ParseToString().Length < 10) - searchExtCode = GetEC1ExtCode(dbProd.spu_id); + if (dbProd.db_type == "云端数据") + { + dbProd.ext_code = searchExtCode = GetNewExtCode(dbProd.spu_id); + } + else + { + if (searchExtCode.ParseToString().Length < 10) + searchExtCode = GetEC1ExtCode(dbProd.spu_id); + } if (dbProd.sku_secret_json != null && dbProd.sku_secret_json.Contains("goodsId")) { var sku_secret_json = dbProd.sku_secret_json; @@ -1840,10 +1888,54 @@ namespace TemuKJD.WXForms.ProductForms if (!string.IsNullOrEmpty(convertRst)) return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"商品查询错误 " + convertRst + "\"}"; } - #endregion + #endregion - #region 将产品数据初始化成微信小店支持的参数 - JObject prodJObj = new JObject(); + #region 云端数据格式转换 + if (dbProd.db_type == "云端数据" && dbProd.product_get_type_text == "多多") + { + string convertRst = ""; + + var content = dbProd.product_json; + if (content.Contains("\"spec_keys\"") && content.Contains("\"spec_values\"") && content.Contains("\"is_sku_pre_sale\"")) + { + convertRst = new PDDProdFormConverter().PddFrontToPddBackConvert(content, true, null, true, false); + } + else if (content.Contains("\"goods_id\"") && content.Contains("\"goods_name\"") && content.Contains("\"gallery\"") && + content.Contains("\"priority\"") && content.Contains("\"enable_share\"") && content.Contains("\"goods_property\"") && + (content.Contains("\"ref_pid\"") || content.Contains("\"goods_property\":[]")) && content.Contains("\"sku_id\"") && content.Contains("\"quantity\"") && + content.Contains("\"specs\"") && content.Contains("\"spec_key\"") && content.Contains("\"spec_value\"") && + content.Contains("\"group_price\"") && content.Contains("img.pddpic.com")) + { + convertRst = new PDDProdFormConverter().PddFrontToPddBackConvert2(content, true, null, true, false); + } + else if (content.Contains("\"mallId\"") && content.Contains("\"mallName\"") && content.Contains("\"goodsId\"") && content.Contains("\"goodsName\"") && + content.Contains("\"catID\"") && content.Contains("\"catID4\"") && content.Contains("\"topGallery\"") && content.Contains("\"detailGallery\"") && + content.Contains("\"shareDesc\"") && content.Contains("\"maxOnSaleGroupPriceInCent\"") && content.Contains("\"shareDesc\"") && + content.Contains("\"specs\"") && content.Contains("\"spec_key\"") && content.Contains("\"spec_value\"") && + content.Contains("\"groupPrice\"") && content.Contains("img.pddpic.com")) + { + convertRst = new PDDProdFormConverter().PddFrontToPddBackConvert3(content, true, null, true, false); + } + else if (content.Contains("\"商品编号\"") && content.Contains("\"商品链接\"") && content.Contains("\"标题\"")) + { + convertRst = new PDDProdFormConverter().PddFrontToPddBackConvertV4(content, true, null, true, false); + } + else + { + convertRst = new PDDProdFormConverter().PddFrontToPddBackConvertFactory("", true, null, true, false, content); + } + + if (!string.IsNullOrEmpty(convertRst) && !convertRst.StartsWith("success")) + return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"商品查询错误 " + convertRst + "\"}"; + + if (convertRst.StartsWith("success")) + convertRst = convertRst.Substring("success".Length); + dbProd.product_json = convertRst; + } + #endregion + + #region 将产品数据初始化成微信小店支持的参数 + JObject prodJObj = new JObject(); try { prodJObj = JObject.Parse(dbProd.product_json); @@ -2190,7 +2282,17 @@ namespace TemuKJD.WXForms.ProductForms var prodInfo = JsonHelper.DeserializeJsonToObject(dbProd.product_json); // 如果没有货号或有相同货号无法区分sku,自定义货号 - if (dbProd.product_get_type_text != "厂商直采") + if (dbProd.db_type == "云端数据") + { + foreach (var sku in prodInfo.detail.sku) + { + var skuId = sku.sku_id; + if (skuId.IsNullOrZero()) + skuId = BaseClass.GetLong(string.Join(";", sku.spec.Select(s => s.spec_name))); + sku.out_sku_sn = GetNewExtCode(skuId.ParseToString()); + } + } + else if (dbProd.product_get_type_text != "厂商直采") { if (prodInfo.detail.sku.Any(s => s.out_sku_sn.IsNullOrEmpty()) || prodInfo.detail.sku.Select(s => s.out_sku_sn).ToList().Count > prodInfo.detail.sku.Select(s => s.out_sku_sn).Distinct().ToList().Count) @@ -2605,7 +2707,7 @@ namespace TemuKJD.WXForms.ProductForms #endregion #region 保存缓存盗链图片 - if (isChangeImgDic) + if (isChangeImgDic && dbProd.db_type != "云端数据") { var url = BaseClass.BuildObjString("product/mdy_pdd_product"); var data = ""; @@ -3482,8 +3584,8 @@ namespace TemuKJD.WXForms.ProductForms #endregion #region 保存缓存盗链图片 - if (isChangeImgDic) - { + if (isChangeImgDic && dbProd.db_type != "云端数据") + { var url = BaseClass.BuildObjString("product/mdy_pdd_product"); var data = ""; Invoke(new Action(() => @@ -4556,7 +4658,7 @@ namespace TemuKJD.WXForms.ProductForms #endregion #region 保存缓存盗链图片 - if (isChangeImgDic) + if (isChangeImgDic && dbProd.db_type != "云端数据") { var url = BaseClass.BuildObjString("product/mdy_pdd_product"); var data = ""; @@ -5696,7 +5798,7 @@ namespace TemuKJD.WXForms.ProductForms } #region 保存缓存盗链图片 - if (isChangeImgDic) + if (isChangeImgDic && dbProd.db_type != "云端数据") { var url = BaseClass.BuildObjString("product/mdy_pdd_product"); var data = ""; diff --git a/TEMUKJD/WXForms/ProductForms/WXUserCollectAuthProdListForm.cs b/TEMUKJD/WXForms/ProductForms/WXUserCollectAuthProdListForm.cs index 4df5e60..b79ac5f 100644 --- a/TEMUKJD/WXForms/ProductForms/WXUserCollectAuthProdListForm.cs +++ b/TEMUKJD/WXForms/ProductForms/WXUserCollectAuthProdListForm.cs @@ -1101,6 +1101,7 @@ namespace TemuKJD.WXForms.ProductForms { var selectProd = JsonHelper.DeserializeJsonToObject(JsonHelper.SerializeObject(prod)); selectProd.product_name = productName; + selectProd.db_type = "我的商品库"; if (chkFissionProduct.Checked) selectProd.is_fission_title = true; selectProd.out_product_Id = prod.id.ToString();