云库数据上传
This commit is contained in:
1 parent
cd82a1ec15
commit
dc977c45d8
12 files changed
+275
-96
No files matched your search
@@ -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<KJDDBProduct>(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<PDDProductInfo>(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 = "";
|
||||
|
||||
@@ -1101,6 +1101,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
{
|
||||
var selectProd = JsonHelper.DeserializeJsonToObject<TemuDBProductSelect>(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();
|
||||
|
||||
Reference in new issue
Block a user