云库数据上传
This commit is contained in:
1 parent
cd82a1ec15
commit
dc977c45d8
12 files changed
+275
-96
No files matched your search
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,16 +31,21 @@ namespace TemuKJD.BLL.ImportConverters
|
||||
/// 支持的平台类型
|
||||
/// </summary>
|
||||
PlatformType Platform { get; }
|
||||
/// <summary>
|
||||
/// 读取内容
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
void ReadContent(string filePath);
|
||||
/// <summary>
|
||||
/// 判断是否匹配当前转换器
|
||||
/// </summary>
|
||||
/// <returns>是否匹配</returns>
|
||||
bool IsMatch();
|
||||
/// <summary>
|
||||
/// 读取内容
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
void ReadContent(string filePath);
|
||||
/// <summary>
|
||||
/// 直接赋值内容
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
void SetContent(string content);
|
||||
/// <summary>
|
||||
/// 判断是否匹配当前转换器
|
||||
/// </summary>
|
||||
/// <returns>是否匹配</returns>
|
||||
bool IsMatch();
|
||||
|
||||
/// <summary>
|
||||
/// 转换为标准商品模型
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
{
|
||||
{
|
||||
/// <summary>
|
||||
/// 拼多多前端采集转拼多多后台采集数据
|
||||
/// </summary>
|
||||
@@ -24,7 +25,7 @@ namespace TemuKJD.BLL
|
||||
/// <param name="UpdateOldData"></param>
|
||||
/// <param name="specialProdType"></param>
|
||||
/// <returns></returns>
|
||||
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
|
||||
/// <param name="UpdateOldData"></param>
|
||||
/// <param name="specialProdType"></param>
|
||||
/// <returns></returns>
|
||||
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
|
||||
/// <param name="specialProdType"></param>
|
||||
/// <param name="IsCollectAuthorityUser"></param>
|
||||
/// <returns></returns>
|
||||
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
|
||||
/// <param name="specialProdType"></param>
|
||||
/// <param name="IsCollectAuthorityUser"></param>
|
||||
/// <returns></returns>
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 外来格式V5
|
||||
/// </summary>
|
||||
/// <param name="outProdJson"></param>
|
||||
/// <param name="UpdateOldData"></param>
|
||||
/// <param name="specialProdType"></param>
|
||||
/// <param name="IsCollectAuthorityUser"></param>
|
||||
/// <returns></returns>
|
||||
public string PddFrontToPddBackConvertFactory(string filePath, bool UpdateOldData = true, string specialProdType = null, bool IsCollectAuthorityUser = false)
|
||||
/// <summary>
|
||||
/// 外来格式V5
|
||||
/// </summary>
|
||||
/// <param name="outProdJson"></param>
|
||||
/// <param name="UpdateOldData"></param>
|
||||
/// <param name="specialProdType"></param>
|
||||
/// <param name="IsCollectAuthorityUser"></param>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
|
||||
|
||||
Reference in new issue
Block a user