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

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;
wxImgMapDic = GetImageCaches(prodInfo);
//Dictionary<string, string> wxImgMapDic = new Dictionary<string, string>();
//if (!string.IsNullOrEmpty(dbProd.wx_img_map_json))
//{
// try
// {
// wxImgMapDic = JsonHelper.DeserializeJsonToObject<Dictionary<string, string>>(dbProd.wx_img_map_json);
// }
// catch
// {
// isChangeImgDic = true;
// wxImgMapDic = new Dictionary<string, string>();
// }
//}
// 旧盗链
Dictionary<string, string> wxImgMapOldDic = new Dictionary<string, string>();
if (!string.IsNullOrEmpty(dbProd.wx_img_map_json))
{
try
{
wxImgMapOldDic = JsonHelper.DeserializeJsonToObject<Dictionary<string, string>>(dbProd.wx_img_map_json);
}
catch
{
isChangeImgDic = true;
wxImgMapOldDic = new Dictionary<string, string>();
}
}
#endregion
#region 提取源商品详情,根据需要生成sku货号
@@ -2611,6 +2610,12 @@ namespace TemuKJD.WXForms.ProductForms
upProdParam.product.info.headImg.Add(image.PlatformUrl);
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"))
{
@@ -2651,6 +2656,9 @@ namespace TemuKJD.WXForms.ProductForms
Md5 = BaseClass.GetMd5(gallery_item.url),
PlatformUrl = upImgUrl,
};
wxImgMapOldDic[BaseClass.GetMd5(gallery_item.url)] = upImgUrl;
isChangeImgDic = true;
continue;
}
@@ -2711,6 +2719,8 @@ namespace TemuKJD.WXForms.ProductForms
PlatformUrl = upImgUrl,
};
wxImgMapOldDic[BaseClass.GetMd5(gallery_item.url)] = upImgUrl;
isChangeImgDic = true;
continue;
}
@@ -2804,8 +2814,11 @@ namespace TemuKJD.WXForms.ProductForms
#region 保存缓存盗链图片
if (isChangeImgDic)
{
SaveImageCaches(Platform, wxImgMapDic.Values);
SaveImageCacheOld(dbProd.spu_id, wxImgMapOldDic);
isChangeImgDic = false;
}
@@ -3599,6 +3612,12 @@ namespace TemuKJD.WXForms.ProductForms
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"))
{
// 如果想打码或者需要打码,就走差异化详情图,不走api直传
@@ -3637,6 +3656,9 @@ namespace TemuKJD.WXForms.ProductForms
Md5 = BaseClass.GetMd5(gallery_item.url),
PlatformUrl = upImgUrl,
};
wxImgMapOldDic[BaseClass.GetMd5(gallery_item.url)] = upImgUrl;
isChangeImgDic = true;
continue;
}
@@ -3695,6 +3717,9 @@ namespace TemuKJD.WXForms.ProductForms
Md5 = BaseClass.GetMd5(gallery_item.url),
PlatformUrl = upImgUrl,
};
wxImgMapOldDic[BaseClass.GetMd5(gallery_item.url)] = upImgUrl;
isChangeImgDic = true;
continue;
}
@@ -3724,8 +3749,12 @@ namespace TemuKJD.WXForms.ProductForms
#endregion
#region 保存缓存盗链图片
if (isChangeImgDic)
{
SaveImageCaches(Platform, wxImgMapDic.Values);
SaveImageCacheOld(dbProd.spu_id, wxImgMapOldDic);
isChangeImgDic = false;
}
#endregion
@@ -4663,6 +4692,14 @@ namespace TemuKJD.WXForms.ProductForms
attrParam.items.Add(new productSaleAttrItemParam() { value = spec.spec_name, imgUrl = image.PlatformUrl, });
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图
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),
PlatformUrl = upImgUrl,
};
wxImgMapOldDic[BaseClass.GetMd5(sku.thumb_url)] = upImgUrl;
isChangeImgDic = true;
continue; // 传图成功跳过模拟上传
}
@@ -4751,6 +4791,9 @@ namespace TemuKJD.WXForms.ProductForms
Md5 = BaseClass.GetMd5(sku.thumb_url),
PlatformUrl = upImgUrl,
};
wxImgMapOldDic[BaseClass.GetMd5(sku.thumb_url)] = upImgUrl;
isChangeImgDic = true;
continue;
}
@@ -4796,8 +4839,12 @@ namespace TemuKJD.WXForms.ProductForms
#endregion
#region 保存缓存盗链图片
if (isChangeImgDic)
{
SaveImageCaches(Platform, wxImgMapDic.Values);
SaveImageCacheOld(dbProd.spu_id, wxImgMapOldDic);
isChangeImgDic = false;
}
#endregion
@@ -5923,8 +5970,12 @@ namespace TemuKJD.WXForms.ProductForms
}
#region 保存缓存盗链图片
if (isChangeImgDic)
{
SaveImageCaches(Platform, wxImgMapDic.Values);
SaveImageCacheOld(dbProd.spu_id, wxImgMapOldDic);
isChangeImgDic = false;
}
#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)
{
if (IsFormLoad)