允许调用旧缓存(但生产环境不给写)

This commit is contained in:
wule committed 2026-10-17 16:41:43 +08:00
1 parent 2f3c27de3d
commit 9a5c58f268
1 file changed
+89 -15
@@ -2346,21 +2346,20 @@ namespace TemuKJD.WXForms.ProductForms
bool isChangeImgDic = false; bool isChangeImgDic = false;
wxImgMapDic = GetImageCaches(prodInfo); wxImgMapDic = GetImageCaches(prodInfo);
// 旧盗链
Dictionary<string, string> wxImgMapOldDic = new Dictionary<string, string>();
//Dictionary<string, string> wxImgMapDic = new Dictionary<string, string>(); if (!string.IsNullOrEmpty(dbProd.wx_img_map_json))
//if (!string.IsNullOrEmpty(dbProd.wx_img_map_json)) {
//{ try
// try {
// { wxImgMapOldDic = JsonHelper.DeserializeJsonToObject<Dictionary<string, string>>(dbProd.wx_img_map_json);
// wxImgMapDic = JsonHelper.DeserializeJsonToObject<Dictionary<string, string>>(dbProd.wx_img_map_json); }
// } catch
// catch {
// { isChangeImgDic = true;
// isChangeImgDic = true; wxImgMapOldDic = new Dictionary<string, string>();
// wxImgMapDic = new Dictionary<string, string>(); }
// } }
//}
#endregion #endregion
#region 提取源商品详情,根据需要生成sku货号 #region 提取源商品详情,根据需要生成sku货号
@@ -2611,6 +2610,12 @@ namespace TemuKJD.WXForms.ProductForms
upProdParam.product.info.headImg.Add(image.PlatformUrl); upProdParam.product.info.headImg.Add(image.PlatformUrl);
continue; continue;
} }
if (wxImgMapOldDic.ContainsKey(BaseClass.GetMd5(gallery_item.url)))
{
upProdInitParam.product.info.headImg.Add(wxImgMapOldDic[BaseClass.GetMd5(gallery_item.url)]);
upProdParam.product.info.headImg.Add(wxImgMapOldDic[BaseClass.GetMd5(gallery_item.url)]);
continue;
}
if (needAddRandomBlock || wantAddRandomBlock || gallery_item.url.Contains("wst.wxapp.tc.qq.com")) if (needAddRandomBlock || wantAddRandomBlock || gallery_item.url.Contains("wst.wxapp.tc.qq.com"))
{ {
@@ -2651,6 +2656,9 @@ namespace TemuKJD.WXForms.ProductForms
Md5 = BaseClass.GetMd5(gallery_item.url), Md5 = BaseClass.GetMd5(gallery_item.url),
PlatformUrl = upImgUrl, PlatformUrl = upImgUrl,
}; };
wxImgMapOldDic[BaseClass.GetMd5(gallery_item.url)] = upImgUrl;
isChangeImgDic = true; isChangeImgDic = true;
continue; continue;
} }
@@ -2711,6 +2719,8 @@ namespace TemuKJD.WXForms.ProductForms
PlatformUrl = upImgUrl, PlatformUrl = upImgUrl,
}; };
wxImgMapOldDic[BaseClass.GetMd5(gallery_item.url)] = upImgUrl;
isChangeImgDic = true; isChangeImgDic = true;
continue; continue;
} }
@@ -2804,8 +2814,11 @@ namespace TemuKJD.WXForms.ProductForms
#region 保存缓存盗链图片 #region 保存缓存盗链图片
if (isChangeImgDic)
{ {
SaveImageCaches(Platform, wxImgMapDic.Values); SaveImageCaches(Platform, wxImgMapDic.Values);
SaveImageCacheOld(dbProd.spu_id, wxImgMapOldDic);
isChangeImgDic = false; isChangeImgDic = false;
} }
@@ -3599,6 +3612,12 @@ namespace TemuKJD.WXForms.ProductForms
continue; continue;
} }
if (wxImgMapOldDic.ContainsKey(BaseClass.GetMd5(gallery_item.url)))
{
upProdParam.product.info.detail.detailImg.Add(wxImgMapOldDic[BaseClass.GetMd5(gallery_item.url)]);
continue;
}
if (needAddRandomBlock || wantAddRandomBlock || gallery_item.url.Contains("wst.wxapp.tc.qq.com")) if (needAddRandomBlock || wantAddRandomBlock || gallery_item.url.Contains("wst.wxapp.tc.qq.com"))
{ {
// 如果想打码或者需要打码,就走差异化详情图,不走api直传 // 如果想打码或者需要打码,就走差异化详情图,不走api直传
@@ -3637,6 +3656,9 @@ namespace TemuKJD.WXForms.ProductForms
Md5 = BaseClass.GetMd5(gallery_item.url), Md5 = BaseClass.GetMd5(gallery_item.url),
PlatformUrl = upImgUrl, PlatformUrl = upImgUrl,
}; };
wxImgMapOldDic[BaseClass.GetMd5(gallery_item.url)] = upImgUrl;
isChangeImgDic = true; isChangeImgDic = true;
continue; continue;
} }
@@ -3695,6 +3717,9 @@ namespace TemuKJD.WXForms.ProductForms
Md5 = BaseClass.GetMd5(gallery_item.url), Md5 = BaseClass.GetMd5(gallery_item.url),
PlatformUrl = upImgUrl, PlatformUrl = upImgUrl,
}; };
wxImgMapOldDic[BaseClass.GetMd5(gallery_item.url)] = upImgUrl;
isChangeImgDic = true; isChangeImgDic = true;
continue; continue;
} }
@@ -3724,8 +3749,12 @@ namespace TemuKJD.WXForms.ProductForms
#endregion #endregion
#region 保存缓存盗链图片 #region 保存缓存盗链图片
if (isChangeImgDic)
{ {
SaveImageCaches(Platform, wxImgMapDic.Values); SaveImageCaches(Platform, wxImgMapDic.Values);
SaveImageCacheOld(dbProd.spu_id, wxImgMapOldDic);
isChangeImgDic = false; isChangeImgDic = false;
} }
#endregion #endregion
@@ -4663,6 +4692,14 @@ namespace TemuKJD.WXForms.ProductForms
attrParam.items.Add(new productSaleAttrItemParam() { value = spec.spec_name, imgUrl = image.PlatformUrl, }); attrParam.items.Add(new productSaleAttrItemParam() { value = spec.spec_name, imgUrl = image.PlatformUrl, });
continue; continue;
} }
if (wxImgMapOldDic.ContainsKey(BaseClass.GetMd5(sku.thumb_url)))
{
attrParam.items.Add(new productSaleAttrItemParam() { value = spec.spec_name, imgUrl = wxImgMapOldDic[BaseClass.GetMd5(sku.thumb_url)], });
continue;
}
// 使用接口链接传sku图 // 使用接口链接传sku图
if (1 == 1 && !sku.thumb_url.Contains("wst.wxapp.tc.qq.com")) if (1 == 1 && !sku.thumb_url.Contains("wst.wxapp.tc.qq.com"))
{ {
@@ -4697,6 +4734,9 @@ namespace TemuKJD.WXForms.ProductForms
Md5 = BaseClass.GetMd5(sku.thumb_url), Md5 = BaseClass.GetMd5(sku.thumb_url),
PlatformUrl = upImgUrl, PlatformUrl = upImgUrl,
}; };
wxImgMapOldDic[BaseClass.GetMd5(sku.thumb_url)] = upImgUrl;
isChangeImgDic = true; isChangeImgDic = true;
continue; // 传图成功跳过模拟上传 continue; // 传图成功跳过模拟上传
} }
@@ -4751,6 +4791,9 @@ namespace TemuKJD.WXForms.ProductForms
Md5 = BaseClass.GetMd5(sku.thumb_url), Md5 = BaseClass.GetMd5(sku.thumb_url),
PlatformUrl = upImgUrl, PlatformUrl = upImgUrl,
}; };
wxImgMapOldDic[BaseClass.GetMd5(sku.thumb_url)] = upImgUrl;
isChangeImgDic = true; isChangeImgDic = true;
continue; continue;
} }
@@ -4796,8 +4839,12 @@ namespace TemuKJD.WXForms.ProductForms
#endregion #endregion
#region 保存缓存盗链图片 #region 保存缓存盗链图片
if (isChangeImgDic)
{ {
SaveImageCaches(Platform, wxImgMapDic.Values); SaveImageCaches(Platform, wxImgMapDic.Values);
SaveImageCacheOld(dbProd.spu_id, wxImgMapOldDic);
isChangeImgDic = false; isChangeImgDic = false;
} }
#endregion #endregion
@@ -5923,8 +5970,12 @@ namespace TemuKJD.WXForms.ProductForms
} }
#region 保存缓存盗链图片 #region 保存缓存盗链图片
if (isChangeImgDic)
{ {
SaveImageCaches(Platform, wxImgMapDic.Values); SaveImageCaches(Platform, wxImgMapDic.Values);
SaveImageCacheOld(dbProd.spu_id, wxImgMapOldDic);
isChangeImgDic = false; isChangeImgDic = false;
} }
#endregion #endregion
@@ -7573,6 +7624,29 @@ namespace TemuKJD.WXForms.ProductForms
} }
void SaveImageCacheOld(string spuId, Dictionary<string, string> wxImgMapOldDic)
{
if (EnvironmentHelper.IsProduction)
{
return;
}
var url = BaseClass.BuildObjString("product/mdy_pdd_product");
var data = "";
Invoke(new Action(() =>
{
data = UserLogin.GetSignaturex();
//data += "&spu_id=" + dbProd.spu_id;
data += "&spu_id=" + spuId;
data += "&wx_img_map_json=" + JsonHelper.SerializeObject(wxImgMapOldDic);
}));
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);
}
private void chkNotUploadShopProdMoreThan_CheckedChanged(object sender, EventArgs e) private void chkNotUploadShopProdMoreThan_CheckedChanged(object sender, EventArgs e)
{ {
if (IsFormLoad) if (IsFormLoad)