sku文字特效尝试
This commit is contained in:
1 parent
b62deb2e99
commit
cd0e96918b
28 files changed
+1587
-550
No files matched your search
@@ -81,7 +81,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
if (lstTemuDBProductSelect == null)
|
||||
lstTemuDBProductSelect = new NaiBa.Util.ConcurrentList<TemuDBProductSelect>();
|
||||
|
||||
lstAddPriceRule = NaiBa.Util.Helper.ConfigHelper.LoadConfig<NaiBa.Util.ConcurrentList<AddPriceRule>>("wx_add_price_rules");
|
||||
lstAddPriceRule = NaiBa.Util.Helper.ConfigHelper.LoadConfig<ConcurrentList<AddPriceRule>>("wx_add_price_rules");
|
||||
if (lstAddPriceRule == null)
|
||||
{
|
||||
lstAddPriceRule = new NaiBa.Util.ConcurrentList<AddPriceRule>();
|
||||
@@ -824,88 +824,54 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
int randomComProdInterval = Math.Max(1, BaseRegex.GetIntJson(ref html, "product_interval"));
|
||||
string randomComProdGroup = BaseRegex.GetStringJson(ref html, "product_group");
|
||||
int waitCompanyProdCnt = 0;
|
||||
List<TemuDBProductSelect> CompanyProdLst = new List<TemuDBProductSelect>();
|
||||
ConcurrentList<TemuDBProductSelect> CompanyProdLst = new ConcurrentList<TemuDBProductSelect>();
|
||||
|
||||
NaiBa.Util.ConcurrentList<ShopLoginInfo> currentShopList = new NaiBa.Util.ConcurrentList<ShopLoginInfo>();
|
||||
ConcurrentList<ShopLoginInfo> currentShopList = new ConcurrentList<ShopLoginInfo>();
|
||||
while (lstTemuDBProductSelect.Count > 0)
|
||||
{
|
||||
if (cancellationTokenSource.IsCancellationRequested)
|
||||
break;
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
shopIdLst = dgvShop.Rows.Cast<DataGridViewRow>().Where(row
|
||||
=> row.Cells["colSelect"]?.Value.ParseToBool() == true).Select(r => r.Cells["colShopId"]?.Value.ToString()).ToList();
|
||||
}));
|
||||
while (shopIdLst.Count <= 0)
|
||||
shopIdLst = dgvShop.Rows.Cast<DataGridViewRow>().Where(row => row.Cells["colSelect"]?.Value.ParseToBool() == true).Select(r => r.Cells["colShopId"]?.Value.ToString()).ToList();
|
||||
if (shopIdLst.Count <= 0)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
this.statusBar.lblTaskStatus.Text = "请至少勾选一个店铺";
|
||||
shopIdLst = dgvShop.Rows.Cast<DataGridViewRow>().Where(row
|
||||
=> row.Cells["colSelect"]?.Value.ParseToBool() == true).Select(r => r.Cells["colShopId"]?.Value.ToString()).ToList();
|
||||
}));
|
||||
Thread.Sleep(1000);
|
||||
if (cancellationTokenSource.IsCancellationRequested)
|
||||
break;
|
||||
Thread.Sleep(500);
|
||||
continue;
|
||||
}
|
||||
var randomShopLst = new NaiBa.Util.ConcurrentList<ShopLoginInfo>();
|
||||
var randomShopLst = new ConcurrentList<ShopLoginInfo>();
|
||||
randomShopLst.AddRange(GlobalConfig.ShopLoginList.Where(s => shopIdLst.Contains(s.ShopId) && s.LoginStatus == "登录成功"));
|
||||
while (randomShopLst.Count <= 0)
|
||||
if (randomShopLst.Count <= 0)
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
shopIdLst = dgvShop.Rows.Cast<DataGridViewRow>().Where(row
|
||||
=> row.Cells["colSelect"]?.Value.ParseToBool() == true).Select(r => r.Cells["colShopId"]?.Value.ToString()).ToList();
|
||||
}));
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
this.statusBar.lblTaskStatus.Text = "所有店铺都已掉线,请登录店铺";
|
||||
randomShopLst.Clear();
|
||||
randomShopLst.AddRange(GlobalConfig.ShopLoginList.Where(s => shopIdLst.Contains(s.ShopId) && s.LoginStatus == "登录成功"));
|
||||
}));
|
||||
if (cancellationTokenSource.IsCancellationRequested)
|
||||
break;
|
||||
}
|
||||
if (cancellationTokenSource.IsCancellationRequested)
|
||||
break;
|
||||
while (currentShopList.Count >= 20) // 最多20店同传
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
if (cancellationTokenSource.IsCancellationRequested)
|
||||
break;
|
||||
|
||||
var randomShop = randomShopLst[Randomx.GetId(randomShopLst.Count)];
|
||||
while (currentShopList.Any(s => s.ShopId == randomShop.ShopId))
|
||||
{
|
||||
Thread.Sleep(500);
|
||||
var randomShopTmpLst = randomShopLst.Where(s => !currentShopList.Contains(s)).ToList();
|
||||
if (randomShopTmpLst.Count == 0)
|
||||
continue;
|
||||
randomShop = randomShopTmpLst[Randomx.GetId(randomShopTmpLst.Count)];
|
||||
}
|
||||
currentShopList.Add(randomShop);
|
||||
if (cancellationTokenSource.IsCancellationRequested)
|
||||
break;
|
||||
|
||||
// 商品已全部上传,退出
|
||||
if (lstTemuDBProductSelect.Count <= 0)
|
||||
{
|
||||
currentShopList.Remove(randomShop);
|
||||
break;
|
||||
}
|
||||
if (randomShop == null)
|
||||
{
|
||||
currentShopList.Remove(randomShop);
|
||||
continue;
|
||||
}
|
||||
if (currentShopList.Count >= 20) // 最多20店同传
|
||||
{
|
||||
Thread.Sleep(500);
|
||||
continue;
|
||||
}
|
||||
|
||||
var randomShop = randomShopLst.Where(s => !currentShopList.Contains(s)).ToList().OrderBy(x => Randomx.GetId(999999)).FirstOrDefault();
|
||||
if (randomShop == null)
|
||||
{
|
||||
Thread.Sleep(500);
|
||||
continue;
|
||||
}
|
||||
currentShopList.Add(randomShop);
|
||||
|
||||
if (cancellationTokenSource.IsCancellationRequested)
|
||||
break;
|
||||
|
||||
// 每次挑选列表第一件商品
|
||||
var selectProd = lstTemuDBProductSelect[0];
|
||||
var selectProd = lstTemuDBProductSelect.FirstOrDefault();
|
||||
selectProd.shop_id = randomShop.ShopId;
|
||||
selectProd.shop_account = randomShop.ShopAccount;
|
||||
|
||||
@@ -935,7 +901,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
}
|
||||
else
|
||||
{
|
||||
lstTemuDBProductSelect.RemoveAt(0);
|
||||
lstTemuDBProductSelect.Remove(selectProd);
|
||||
}
|
||||
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_db_prod_upload_list", this.lstTemuDBProductSelect);
|
||||
@@ -963,16 +929,12 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
|
||||
// 过滤标题
|
||||
var lstTitleReplaceText = new List<string>();
|
||||
lstTitleReplaceText.Clear();
|
||||
if (!txtReplaceText.Text.Trim().IsNullOrEmpty())
|
||||
lstTitleReplaceText.AddRange(txtReplaceText.Text.Trim().Split(new string[] { ",", ",", " ", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries));
|
||||
// 过滤标题内指定词语
|
||||
if (lstTitleReplaceText.Count > 0)
|
||||
foreach (var txt in lstTitleReplaceText)
|
||||
{
|
||||
foreach (var txt in lstTitleReplaceText)
|
||||
{
|
||||
selectProd.product_name = selectProd.product_name.Replace(txt, "");
|
||||
}
|
||||
selectProd.product_name = selectProd.product_name.Replace(txt, "");
|
||||
}
|
||||
|
||||
Invoke(new Action(() =>
|
||||
@@ -1106,19 +1068,6 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
result = UploadProduct(shop, kjdDbProdTmp, selectProd, row.Cells["colOpResult"], startTime);
|
||||
}
|
||||
|
||||
// 拼多多的虚拟图,微信不需要
|
||||
//Invoke(new Action(() =>
|
||||
//{
|
||||
// row.Cells["colSkuFakeImgUrl"].Value = kjdDbProd.sku_img_replace_url;
|
||||
// if (row.Displayed)
|
||||
// {
|
||||
// string getImgError = "";
|
||||
// Image img = GetHtml.GetUrlImg(kjdDbProd.sku_img_replace_url.Replace("https://", "http://"), out getImgError);
|
||||
// if (string.IsNullOrEmpty(getImgError))
|
||||
// row.Cells["colSkuFakeImg"].Value = img;
|
||||
// }
|
||||
//}));
|
||||
|
||||
if (!result.Contains("success"))
|
||||
{
|
||||
WXShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false);
|
||||
@@ -1387,7 +1336,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
if (dbProd.product_get_type_text == "厂商直采" && dbProd.sku_secret_json != null && dbProd.sku_secret_json.Contains("goodsId"))
|
||||
{
|
||||
string convertRst = "";
|
||||
var ob = new PDDProdFormConverter().JstPddProdToPddConvert(out convertRst, dbProd);
|
||||
var pInfo = new PDDProdFormConverter().JstPddProdToPddConvert(out convertRst, dbProd);
|
||||
if (!string.IsNullOrEmpty(convertRst))
|
||||
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"商品查询错误 " + convertRst + "\"}";
|
||||
}
|
||||
@@ -1397,7 +1346,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
if (dbProd.product_get_type_text == "微信店采")
|
||||
{
|
||||
string convertRst = "";
|
||||
var ob = new PDDProdFormConverter().WXProdToPddConvert(out convertRst, dbProd);
|
||||
var pInfo = new PDDProdFormConverter().WXProdToPddConvert(out convertRst, dbProd);
|
||||
if (!string.IsNullOrEmpty(convertRst))
|
||||
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"商品查询错误 " + convertRst + "\"}";
|
||||
}
|
||||
@@ -1407,7 +1356,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
if (dbProd.product_get_type_text == "1688厂家")
|
||||
{
|
||||
string convertRst = "";
|
||||
var ob = new PDDProdFormConverter()._1688ClientToPddConvert(out convertRst, dbProd);
|
||||
var pInfo = new PDDProdFormConverter()._1688ClientToPddConvert(out convertRst, dbProd);
|
||||
if (!string.IsNullOrEmpty(convertRst))
|
||||
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"商品查询错误 " + convertRst + "\"}";
|
||||
}
|
||||
@@ -1417,7 +1366,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
if (dbProd.product_get_type_text == "微信小店")
|
||||
{
|
||||
string convertRst = "";
|
||||
var ob = new PDDProdFormConverter().WXClientToPddConvert(out convertRst, dbProd);
|
||||
var pInfo = new PDDProdFormConverter().WXClientToPddConvert(out convertRst, dbProd);
|
||||
if (!string.IsNullOrEmpty(convertRst))
|
||||
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"商品查询错误 " + convertRst + "\"}";
|
||||
}
|
||||
@@ -1430,7 +1379,6 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
prodJObj = JObject.Parse(dbProd.product_json);
|
||||
|
||||
var lstTitleReplaceText = new List<string>();
|
||||
lstTitleReplaceText.Clear();
|
||||
if (!txtReplaceText.Text.Trim().IsNullOrEmpty())
|
||||
lstTitleReplaceText.AddRange(txtReplaceText.Text.Trim().Split(new string[] { ",", ",", " ", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries));
|
||||
// 过滤标题敏感词
|
||||
@@ -1690,12 +1638,12 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
prodInfo.detail.cats.FirstOrDefault() == "书籍/杂志/报纸" || dbProd.main_cat_name == "图书" || dbProd.main_cat_name == "书籍/杂志/报纸");
|
||||
{
|
||||
List<gallery_item> galls = new List<gallery_item>();
|
||||
foreach (var gall in prodInfo.detail.galleries.Where(g => g.type == 1))
|
||||
foreach (var gall in prodInfo.detail.galleries.Where(g => g.type == 1).ToList())
|
||||
{
|
||||
if (!galls.Any(g => g.url == gall.url)/* && !prodInfo.detail.sku.Any(s => s.thumb_url == gall.url)*/)
|
||||
galls.Add(gall);
|
||||
}
|
||||
foreach (var gall in prodInfo.detail.galleries.Where(g => g.type == 2))
|
||||
foreach (var gall in prodInfo.detail.galleries.Where(g => g.type == 2).ToList())
|
||||
{
|
||||
if (!galls.Any(g => g.url == gall.url)/* && !prodInfo.detail.sku.Any(s => s.thumb_url == gall.url)*/)
|
||||
galls.Add(gall);
|
||||
@@ -1793,7 +1741,8 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
}));
|
||||
}
|
||||
Thread.Sleep(Randomx.GetId(100, 300));
|
||||
foreach (var gallery_item in prodInfo.detail.galleries.Where(g => g.type == 1).Take(9)) // 9张主图
|
||||
var mainGalleries = prodInfo.detail.galleries.Where(g => g.type == 1).Take(9).ToList();
|
||||
foreach (var gallery_item in mainGalleries) // 9张主图
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -2043,7 +1992,8 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
List<string> tempImgFullPathLst = new List<string>();
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------
|
||||
// 生成ai识别类目所需图片
|
||||
foreach (var gallery_item in prodInfo.detail.galleries.Where(g => g.type == 1).Take(3)) // 9张主图
|
||||
var aiGalleries = prodInfo.detail.galleries.Where(g => g.type == 1).Take(3).ToList();
|
||||
foreach (var gallery_item in aiGalleries) // 9张主图
|
||||
{
|
||||
string getImgError;
|
||||
var image = GetHtml.GetUrlImg(gallery_item.url.Replace("https://", "http://"), out getImgError);
|
||||
@@ -2522,6 +2472,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"运费模板解析失败 " + ex.Message + "\"}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3825,7 +3776,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
|
||||
string prodName = (upProdParam.product.info.category.Count > 2 ? upProdParam.product.info.category[2].name : upProdParam.product.info.category.LastOrDefault()?.name);
|
||||
|
||||
var baseImg = TemuKJD.Properties.Resources.qingxu;
|
||||
var baseImg = TemuKJD.Properties.Resources.qingqu;
|
||||
var newImg = new Bitmap(baseImg.Width, baseImg.Height);
|
||||
using (Graphics g = Graphics.FromImage(newImg))
|
||||
{
|
||||
@@ -4078,7 +4029,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
//add_secret_spu_id_shop_id_map //测试id "2017522348787531778" FC4C8B7F3C6E4B029AD2A12D4D323B41
|
||||
if (!string.IsNullOrEmpty(dbProd.secret_spu_id))
|
||||
{
|
||||
var url = BaseClass.BuildObjString("product/add_secret_spu_id_shop_id_map");
|
||||
var url = BaseClass.BuildObjString("product/wx_add_secret_id_up_map");
|
||||
var data = "";
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
@@ -4086,7 +4037,9 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
data += "&up_secret_spu_id=" + dbProd.secret_spu_id;
|
||||
data += "&up_spu_id=" + dbProd.spu_id;
|
||||
data += "&shop_id=" + shop.ShopId;
|
||||
data += "&index=" + dbProd.secret_spu_id.ParseToLong() % 1024;
|
||||
data += "&index=" + Math.Abs(dbProd.secret_spu_id.GetHashCode()) % 1024;
|
||||
data += "&price_max=" + upProdParam.product.productSkus.Max(s => s.productSkuInfo.salePrice);
|
||||
data += "&price_min=" + upProdParam.product.productSkus.Min(s => s.productSkuInfo.salePrice);
|
||||
}));
|
||||
var html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
@@ -4106,7 +4059,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
dicShopUpload[shop.ShopId].DicDayUploadCount[day] = 0;
|
||||
dicShopUpload[shop.ShopId].DicDayUploadCount[day] += 1;
|
||||
// 删除45天前的记录
|
||||
var removeKeys = dicShopUpload[shop.ShopId].DicDayUploadCount.Keys.Where(s => s < DateTime.Now.AddDays(-45).ToString("yyyyMMdd").ParseToInt());
|
||||
var removeKeys = dicShopUpload[shop.ShopId].DicDayUploadCount.Keys.Where(s => s < DateTime.Now.AddDays(-45).ToString("yyyyMMdd").ParseToInt()).ToList();
|
||||
foreach (var key in removeKeys)
|
||||
{
|
||||
dicShopUpload[shop.ShopId].DicDayUploadCount.Remove(key);
|
||||
|
||||
Reference in new issue
Block a user