Merge branch 'master' of http://git.ts.e57.cn/chfei/KJD
This commit is contained in:
commit
b3c763ce2b
3 files changed
+160
-122
No files matched your search
@@ -31,7 +31,7 @@ namespace AllBase
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 版本ID
|
/// 版本ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static int VersionCount = 1357;
|
public static int VersionCount = 1359;
|
||||||
public static string MainPath = "29wx";
|
public static string MainPath = "29wx";
|
||||||
//public static string MainPath = "29wx";
|
//public static string MainPath = "29wx";
|
||||||
//public static string MainPath = "29pdd";
|
//public static string MainPath = "29pdd";
|
||||||
|
|||||||
@@ -2344,7 +2344,7 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
#region 图片盗链映射生成字典(如果有)
|
#region 图片盗链映射生成字典(如果有)
|
||||||
Dictionary<string, ImageCache> wxImgMapDic = new Dictionary<string, ImageCache>(StringComparer.OrdinalIgnoreCase);
|
Dictionary<string, ImageCache> wxImgMapDic = new Dictionary<string, ImageCache>(StringComparer.OrdinalIgnoreCase);
|
||||||
bool isChangeImgDic = false;
|
bool isChangeImgDic = false;
|
||||||
wxImgMapDic = GetImageCaches(prodInfo);
|
wxImgMapDic = ImageCacheService.GetImageCaches(prodInfo);
|
||||||
|
|
||||||
// 旧盗链
|
// 旧盗链
|
||||||
Dictionary<string, string> wxImgMapOldDic = new Dictionary<string, string>();
|
Dictionary<string, string> wxImgMapOldDic = new Dictionary<string, string>();
|
||||||
@@ -2816,7 +2816,7 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
#region 保存缓存盗链图片
|
#region 保存缓存盗链图片
|
||||||
if (isChangeImgDic)
|
if (isChangeImgDic)
|
||||||
{
|
{
|
||||||
SaveImageCaches(Platform, wxImgMapDic.Values);
|
ImageCacheService.SaveImageCaches(Platform, wxImgMapDic.Values);
|
||||||
|
|
||||||
SaveImageCacheOld(dbProd.spu_id, wxImgMapOldDic);
|
SaveImageCacheOld(dbProd.spu_id, wxImgMapOldDic);
|
||||||
isChangeImgDic = false;
|
isChangeImgDic = false;
|
||||||
@@ -3751,7 +3751,7 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
#region 保存缓存盗链图片
|
#region 保存缓存盗链图片
|
||||||
if (isChangeImgDic)
|
if (isChangeImgDic)
|
||||||
{
|
{
|
||||||
SaveImageCaches(Platform, wxImgMapDic.Values);
|
ImageCacheService.SaveImageCaches(Platform, wxImgMapDic.Values);
|
||||||
|
|
||||||
SaveImageCacheOld(dbProd.spu_id, wxImgMapOldDic);
|
SaveImageCacheOld(dbProd.spu_id, wxImgMapOldDic);
|
||||||
|
|
||||||
@@ -4850,7 +4850,7 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
#region 保存缓存盗链图片
|
#region 保存缓存盗链图片
|
||||||
if (isChangeImgDic)
|
if (isChangeImgDic)
|
||||||
{
|
{
|
||||||
SaveImageCaches(Platform, wxImgMapDic.Values);
|
ImageCacheService.SaveImageCaches(Platform, wxImgMapDic.Values);
|
||||||
|
|
||||||
SaveImageCacheOld(dbProd.spu_id, wxImgMapOldDic);
|
SaveImageCacheOld(dbProd.spu_id, wxImgMapOldDic);
|
||||||
|
|
||||||
@@ -5981,7 +5981,7 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
#region 保存缓存盗链图片
|
#region 保存缓存盗链图片
|
||||||
if (isChangeImgDic)
|
if (isChangeImgDic)
|
||||||
{
|
{
|
||||||
SaveImageCaches(Platform, wxImgMapDic.Values);
|
ImageCacheService.SaveImageCaches(Platform, wxImgMapDic.Values);
|
||||||
|
|
||||||
SaveImageCacheOld(dbProd.spu_id, wxImgMapOldDic);
|
SaveImageCacheOld(dbProd.spu_id, wxImgMapOldDic);
|
||||||
|
|
||||||
@@ -7541,99 +7541,7 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
globalShopUploadCntLimitRetryTimes = numJumpCnt.Value.ParseToInt();
|
globalShopUploadCntLimitRetryTimes = numJumpCnt.Value.ParseToInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取图片缓存
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="product"></param>
|
|
||||||
private Dictionary<string, ImageCache> GetImageCaches(PDDProductInfo product)
|
|
||||||
{
|
|
||||||
Dictionary<string, ImageCache> wxImgMapDic = new Dictionary<string, ImageCache>(StringComparer.OrdinalIgnoreCase);
|
|
||||||
if (EnvironmentHelper.IsProduction)
|
|
||||||
{
|
|
||||||
return wxImgMapDic;
|
|
||||||
}
|
|
||||||
List<string> imageUrls = new List<string>();
|
|
||||||
imageUrls.AddRange(product.detail.galleries.Where(g => g.type == 1).Take(9).Select(a => a.url));
|
|
||||||
var temp_detailGalleries = product.detail.galleries.Where(g => g.type == 2).ToList();
|
|
||||||
if (temp_detailGalleries.Count == 0)
|
|
||||||
temp_detailGalleries.Add(new gallery_item() { type = 2, url = product.detail.galleries.FirstOrDefault(g => g.type == 1)?.url });
|
|
||||||
imageUrls.AddRange(temp_detailGalleries.Select(a => a.url));
|
|
||||||
|
|
||||||
|
|
||||||
if (product.detail.sku.FirstOrDefault()?.spec?.Count > 0)
|
|
||||||
{
|
|
||||||
imageUrls.AddRange(product.detail.sku.Select(a => a.thumb_url));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
List<string> imageUrlMd5s = imageUrls.Select(a => BaseClass.GetMd5(a)).ToList();
|
|
||||||
|
|
||||||
var url = BaseClass.BuildObjString("ImageCache/GetImageCache");//获取缓存
|
|
||||||
var data = JsonConvert.SerializeObject(new
|
|
||||||
{
|
|
||||||
md5s = imageUrlMd5s
|
|
||||||
});
|
|
||||||
|
|
||||||
var html = GetHtml.PostUtf8(url, data, contentType: "application/json");
|
|
||||||
if (string.IsNullOrEmpty(html))
|
|
||||||
html = GetHtml.PostUtf8(url, data);
|
|
||||||
var ret = JsonConvert.DeserializeObject<Result<List<ImageCache>>>(html);
|
|
||||||
if (ret.Code == 200)
|
|
||||||
{
|
|
||||||
foreach (var item in ret.Data)
|
|
||||||
{
|
|
||||||
item.IsCache = true;
|
|
||||||
wxImgMapDic[item.Md5] = item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return wxImgMapDic;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 保存缓存图片
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="platform"></param>
|
|
||||||
/// <param name="images"></param>
|
|
||||||
private void SaveImageCaches(PlatformType platform, IEnumerable<ImageCache> images)
|
|
||||||
{
|
|
||||||
if (EnvironmentHelper.IsProduction)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var url = BaseClass.BuildObjString("ImageCache/AddOrUpdate");
|
|
||||||
var data = "";
|
|
||||||
data = JsonHelper.SerializeObject(images.Where(a => a.IsCache == false).Select(a =>
|
|
||||||
new
|
|
||||||
{
|
|
||||||
md5 = a.Md5,
|
|
||||||
Platform = platform,
|
|
||||||
PlatformUrl = a.PlatformUrl
|
|
||||||
}
|
|
||||||
));
|
|
||||||
|
|
||||||
var html = GetHtml.PostUtf8(url, data, contentType: "application/json");
|
|
||||||
if (string.IsNullOrEmpty(html))
|
|
||||||
html = GetHtml.PostUtf8(url, data);
|
|
||||||
var ret = JsonConvert.DeserializeObject<Result<JToken>>(html);
|
|
||||||
List<string> failed = new List<string>();
|
|
||||||
if (ret.Code == 500)
|
|
||||||
{
|
|
||||||
if (ret.Data is JArray jArray)
|
|
||||||
{
|
|
||||||
failed = jArray.ToObject<List<string>>() ?? new List<string>();
|
|
||||||
}
|
|
||||||
else if (ret.Data is JValue jValue && jValue.Value is string str)
|
|
||||||
{
|
|
||||||
failed.Add(str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach (ImageCache item in images)
|
|
||||||
{
|
|
||||||
item.IsCache = !failed.Contains(item.Md5, StringComparer.OrdinalIgnoreCase);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void SaveImageCacheOld(string spuId, Dictionary<string, string> wxImgMapOldDic)
|
void SaveImageCacheOld(string spuId, Dictionary<string, string> wxImgMapOldDic)
|
||||||
{
|
{
|
||||||
@@ -7642,20 +7550,20 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
// return;
|
// return;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
var url = BaseClass.BuildObjString("product/mdy_pdd_product");
|
//var url = BaseClass.BuildObjString("product/mdy_pdd_product");
|
||||||
var data = "";
|
//var data = "";
|
||||||
Invoke(new Action(() =>
|
//Invoke(new Action(() =>
|
||||||
{
|
//{
|
||||||
data = UserLogin.GetSignaturex();
|
// data = UserLogin.GetSignaturex();
|
||||||
//data += "&spu_id=" + dbProd.spu_id;
|
// //data += "&spu_id=" + dbProd.spu_id;
|
||||||
data += "&spu_id=" + spuId;
|
// data += "&spu_id=" + spuId;
|
||||||
data += "&wx_img_map_json=" + JsonHelper.SerializeObject(wxImgMapOldDic);
|
// data += "&wx_img_map_json=" + JsonHelper.SerializeObject(wxImgMapOldDic);
|
||||||
}));
|
//}));
|
||||||
var html = GetHtml.PostUtf8(url, data);
|
//var html = GetHtml.PostUtf8(url, data);
|
||||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
//if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||||
html = GetHtml.PostUtf8(url, data);
|
// html = GetHtml.PostUtf8(url, data);
|
||||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
//if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||||
html = GetHtml.PostUtf8(url, data);
|
// html = GetHtml.PostUtf8(url, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void chkNotUploadShopProdMoreThan_CheckedChanged(object sender, EventArgs e)
|
private void chkNotUploadShopProdMoreThan_CheckedChanged(object sender, EventArgs e)
|
||||||
@@ -8186,15 +8094,7 @@ Content-Type: application/octet-stream
|
|||||||
public int NotUploadShopProdMoreThan { get; set; } = 500;
|
public int NotUploadShopProdMoreThan { get; set; } = 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ImageCache
|
|
||||||
{
|
|
||||||
public string Md5 { get; set; }
|
|
||||||
public int Platform { get; set; }
|
|
||||||
[JsonProperty("platform_url")]
|
|
||||||
public string PlatformUrl { get; set; }
|
|
||||||
public bool IsCache { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
class WaitingProductConfig : BindableBase
|
class WaitingProductConfig : BindableBase
|
||||||
{
|
{
|
||||||
public WaitingProductConfig()
|
public WaitingProductConfig()
|
||||||
|
|||||||
@@ -0,0 +1,138 @@
|
|||||||
|
using AllBase;
|
||||||
|
using AllBase.Helper;
|
||||||
|
using AllBase.Model.Result;
|
||||||
|
using AllBase.Model.Result.PDDResult;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Work.Services;
|
||||||
|
|
||||||
|
public class ImageCache
|
||||||
|
{
|
||||||
|
public string Md5 { get; set; }
|
||||||
|
public int Platform { get; set; }
|
||||||
|
[JsonProperty("platform_url")]
|
||||||
|
public string PlatformUrl { get; set; }
|
||||||
|
public bool IsCache { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ImageCacheService
|
||||||
|
{
|
||||||
|
private static string ServerUrl = "http://103.90.155.78:9001";
|
||||||
|
static ImageCacheService()
|
||||||
|
{
|
||||||
|
if (EnvironmentHelper.IsDevelopment)
|
||||||
|
{
|
||||||
|
ServerUrl = "http://localhost:14312";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取图片缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="product"></param>
|
||||||
|
public static Dictionary<string, ImageCache> GetImageCaches(PDDProductInfo product)
|
||||||
|
{
|
||||||
|
Dictionary<string, ImageCache> wxImgMapDic = new Dictionary<string, ImageCache>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//if (EnvironmentHelper.IsProduction)
|
||||||
|
//{
|
||||||
|
// return wxImgMapDic;
|
||||||
|
//}
|
||||||
|
List<string> imageUrls = new List<string>();
|
||||||
|
imageUrls.AddRange(product.detail.galleries.Where(g => g.type == 1).Take(9).Select(a => a.url));
|
||||||
|
var temp_detailGalleries = product.detail.galleries.Where(g => g.type == 2).ToList();
|
||||||
|
if (temp_detailGalleries.Count == 0)
|
||||||
|
temp_detailGalleries.Add(new gallery_item() { type = 2, url = product.detail.galleries.FirstOrDefault(g => g.type == 1)?.url });
|
||||||
|
imageUrls.AddRange(temp_detailGalleries.Select(a => a.url));
|
||||||
|
|
||||||
|
|
||||||
|
if (product.detail.sku.FirstOrDefault()?.spec?.Count > 0)
|
||||||
|
{
|
||||||
|
imageUrls.AddRange(product.detail.sku.Select(a => a.thumb_url));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
List<string> imageUrlMd5s = imageUrls.Select(a => BaseClass.GetMd5(a)).ToList();
|
||||||
|
|
||||||
|
var url = ServerUrl + "/api/ImageCache/GetImageCache";//获取缓存
|
||||||
|
var html = GetHtml.PostJson(url, new { md5s = imageUrlMd5s });
|
||||||
|
var ret = JsonConvert.DeserializeObject<Result<List<ImageCache>>>(html);
|
||||||
|
if (ret.Code == 200)
|
||||||
|
{
|
||||||
|
foreach (var item in ret.Data)
|
||||||
|
{
|
||||||
|
item.IsCache = true;
|
||||||
|
wxImgMapDic[item.Md5] = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
return wxImgMapDic;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存缓存图片
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="platform"></param>
|
||||||
|
/// <param name="images"></param>
|
||||||
|
public static void SaveImageCaches(PlatformType platform, IEnumerable<ImageCache> images)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//if (EnvironmentHelper.IsProduction)
|
||||||
|
//{
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
var data = "";
|
||||||
|
data = JsonHelper.SerializeObject(images.Where(a => a.IsCache == false).Select(a =>
|
||||||
|
new
|
||||||
|
{
|
||||||
|
md5 = a.Md5,
|
||||||
|
Platform = platform,
|
||||||
|
PlatformUrl = a.PlatformUrl
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
|
var url = ServerUrl + "/api/ImageCache/AddOrUpdate";
|
||||||
|
var html = GetHtml.PostJson(url, data);
|
||||||
|
|
||||||
|
|
||||||
|
var ret = JsonConvert.DeserializeObject<Result<JToken>>(html);
|
||||||
|
List<string> failed = new List<string>();
|
||||||
|
if (ret.Code == 500)
|
||||||
|
{
|
||||||
|
if (ret.Data is JArray jArray)
|
||||||
|
{
|
||||||
|
failed = jArray.ToObject<List<string>>() ?? new List<string>();
|
||||||
|
}
|
||||||
|
else if (ret.Data is JValue jValue && jValue.Value is string str)
|
||||||
|
{
|
||||||
|
failed.Add(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (ImageCache item in images)
|
||||||
|
{
|
||||||
|
item.IsCache = !failed.Contains(item.Md5, StringComparer.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in new issue
Block a user