修复上传问题

This commit is contained in:
wule_5900x committed 2026-04-03 02:05:23 +08:00
1 parent c0b7c2d986
commit b62deb2e99
4 files changed
+77 -71

No files matched your search

+1 -1
View File
@@ -27,7 +27,7 @@ namespace AllBase
/// <summary> /// <summary>
/// 版本ID /// 版本ID
/// </summary> /// </summary>
public static int VersionCount = 953; public static int VersionCount = 955;
//public static int VersionCount = 613; //public static int VersionCount = 613;
/// <summary> /// <summary>
+4 -1
View File
@@ -736,7 +736,7 @@ namespace TemuKJD.Extension
public static void AddImgColumn(this DataGridView dgv, string imgColumn, string imgPathColumn, bool isSetHttpsHttp = true) public static void AddImgColumn(this DataGridView dgv, string imgColumn, string imgPathColumn, bool isSetHttpsHttp = true)
{ {
bool isScroll = false; //bool isScroll = false;
CancellationTokenSource cancelToken = new CancellationTokenSource(); CancellationTokenSource cancelToken = new CancellationTokenSource();
dgv.Scroll += (s, e) => dgv.Scroll += (s, e) =>
@@ -782,6 +782,9 @@ namespace TemuKJD.Extension
//while (isScroll && 1 == 1) //while (isScroll && 1 == 1)
// Thread.Sleep(1); // Thread.Sleep(1);
//isScroll = true; //isScroll = true;
if (e.RowIndex < (dgv.FirstDisplayedScrollingRowIndex + dgv.DisplayedRowCount(true)))
ShowDgvImg(cancelToken, dgv, dgv.Rows.Cast<DataGridViewRow>().ToList(), imgColumn, imgPathColumn, isSetHttpsHttp);
else
ShowDgvImg(cancelToken, dgv, new List<DataGridViewRow> { dgv.Rows[e.RowIndex] }, imgColumn, imgPathColumn, isSetHttpsHttp); ShowDgvImg(cancelToken, dgv, new List<DataGridViewRow> { dgv.Rows[e.RowIndex] }, imgColumn, imgPathColumn, isSetHttpsHttp);
//isScroll = false; //isScroll = false;
}, cancelToken.Token); }, cancelToken.Token);
@@ -593,60 +593,6 @@ namespace TemuKJD.PDDForms.ProductSelectForms
} }
//Bitmap defaultBitmap = new Bitmap(80, 80);
void ShowDgvImg()
{
//Task.Run(() =>
//{
// foreach (DataGridViewRow row in this.dgvSelectProduct.Rows)
// {
// if (row.Index > 0 && row.Cells["colProductSkcPic"].Displayed == false)
// {
// try
// {
// Invoke(new Action(() =>
// {
// row.Cells["colProductSkcPic"].Value = defaultBitmap;
// }));
// }
// catch
// {
// }
// continue;
// }
// if (row.Index >= 0 && row.Cells["colProductSkcPic"].Value != null && row.Cells["colProductSkcPic"].Value != defaultBitmap)
// continue;
// Image image = null;
// if (row.Index >= 0)
// {
// string imgUrl = row.Cells["colImgUrl"]?.Value.ParseToString();
// string getImgError = "";
// if (!string.IsNullOrWhiteSpace(imgUrl))
// image = GetHtml.GetUrlImg(imgUrl, out getImgError);
// if (!string.IsNullOrEmpty(getImgError))
// //BaseMsgForm.ShowError("图片加载失败 " + getImgError);
// image = TemuKJD.Properties.Resources.errpic;
// }
// try
// {
// Invoke(new Action(() =>
// {
// if (row.Index >= 0)
// {
// row.Cells["colProductSkcPic"].Value = image;
// }
// }));
// }
// catch
// {
// }
// }
//});
}
private void dgvSelectProduct_Scroll(object sender, ScrollEventArgs e) private void dgvSelectProduct_Scroll(object sender, ScrollEventArgs e)
{ {
//ShowDgvImg(); //ShowDgvImg();
@@ -6110,7 +6056,7 @@ Content-Type: image/jpeg
{ {
Invoke(new Action(() => Invoke(new Action(() =>
{ {
BaseMsgForm.ShowError("获取商品失败,请重试!" + BaseRegex.GetStringJson(ref html, "msg")); //BaseMsgForm.ShowError("获取商品失败,请重试!" + BaseRegex.GetStringJson(ref html, "msg"));
})); }));
return new List<KJDDBProduct>(); return new List<KJDDBProduct>();
} }
@@ -6810,7 +6756,8 @@ Content-Type: image/jpeg
} }
// 选出一个勾选且空闲的店铺 // 选出一个勾选且空闲的店铺
var selectShopLst = GlobalConfig.ShopLoginList.Where(s => shopIdLst.Contains(s.ShopId)); NaiBa.Util.ConcurrentList<ShopLoginInfo> selectShopLst = new NaiBa.Util.ConcurrentList<ShopLoginInfo>();
selectShopLst.AddRange(GlobalConfig.ShopLoginList.Where(s => shopIdLst.Contains(s.ShopId)));
var canUpShop = selectShopLst.OrderBy(x => Randomx.GetId(int.MaxValue)).FirstOrDefault(s => !currentUpShopLst.Contains(s)); var canUpShop = selectShopLst.OrderBy(x => Randomx.GetId(int.MaxValue)).FirstOrDefault(s => !currentUpShopLst.Contains(s));
if (canUpShop == null) if (canUpShop == null)
{ {
@@ -6844,11 +6791,19 @@ Content-Type: image/jpeg
} }
} }
selectProd = CompanyProdLst.FirstOrDefault(); selectProd = CompanyProdLst.FirstOrDefault();
if (selectProd != null)
{
selectProd.shop_id = canUpShop.ShopId; selectProd.shop_id = canUpShop.ShopId;
selectProd.shop_account = canUpShop.ShopAccount; selectProd.shop_account = canUpShop.ShopAccount;
CompanyProdLst.Remove(selectProd); CompanyProdLst.Remove(selectProd);
} }
else else
{
Thread.Sleep(500);
continue;
}
}
else
{ {
lstTemuDBProductSelect.Remove(selectProd); lstTemuDBProductSelect.Remove(selectProd);
} }
@@ -6871,6 +6826,8 @@ Content-Type: image/jpeg
Invoke(new Action(() => Invoke(new Action(() =>
{ {
int rowIndex = 0; int rowIndex = 0;
try
{
this.dgvSelectProduct.Rows.Insert(rowIndex, this.dgvSelectProduct.Rows.Insert(rowIndex,
true, true,
selectProd.id, selectProd.id,
@@ -6882,9 +6839,9 @@ Content-Type: image/jpeg
BaseClass.SaLevel > 0 ? selectProd.spu_id : selectProd.spu_id.ParseToString().GetHashCode().ParseToString().Trim('-'), BaseClass.SaLevel > 0 ? selectProd.spu_id : selectProd.spu_id.ParseToString().GetHashCode().ParseToString().Trim('-'),
selectProd.skc_id, selectProd.skc_id,
selectProd.main_img, selectProd.main_img,
null, DataGridViewExtension.defaultBitmap,
"", "",
null, DataGridViewExtension.defaultBitmap,
selectProd.product_name, // 用户端显示商品原名 selectProd.product_name, // 用户端显示商品原名
selectProd.cat_name, selectProd.cat_name,
//prod.secret_spu_id == null ? prod.ext_code : prod.secret_spu_id, //prod.secret_spu_id == null ? prod.ext_code : prod.secret_spu_id,
@@ -6904,6 +6861,11 @@ Content-Type: image/jpeg
{ {
dgvSelectProduct.Rows.RemoveAt(maxRowCount); dgvSelectProduct.Rows.RemoveAt(maxRowCount);
} }
}
catch
{
}
})); }));
// 接口上传 // 接口上传
@@ -6979,6 +6941,7 @@ Content-Type: image/jpeg
DataGridViewCell cell = row.Cells["colOpResult"]; DataGridViewCell cell = row.Cells["colOpResult"];
Invoke(new Action(() => Invoke(new Action(() =>
{ {
if (cell != null)
cell.Value = "正在初始化商品"; cell.Value = "正在初始化商品";
})); }));
@@ -6991,25 +6954,40 @@ Content-Type: image/jpeg
dbProd = GetProductDetail(selectProd.out_product_Id.ToString()); dbProd = GetProductDetail(selectProd.out_product_Id.ToString());
if (!string.IsNullOrEmpty(dbProd.secret_spu_id)) if (!string.IsNullOrEmpty(dbProd.secret_spu_id))
{ {
Invoke(new Action(() => { row.Cells["colExtCode"].Value = dbProd.secret_spu_id; })); Invoke(new Action(() =>
{
if (row != null && row.Index >= 0)
row.Cells["colExtCode"].Value = dbProd.secret_spu_id;
}));
} }
if (dbProd == null || dbProd.id == 0) if (dbProd == null || dbProd.id == 0)
{ {
if (selectProd?.id == 0) if (selectProd?.id == 0)
{ {
Invoke(new Action(() => { row.Cells["colStatus"].Value = "已清除"; }));
selectProd.status = "已清除"; selectProd.status = "已清除";
Invoke(new Action(() =>
{
if (row != null && row.Index >= 0)
row.Cells["colStatus"].Value = "已清除";
}));
} }
return "数据库商品获取失败"; return "数据库商品获取失败";
} }
#region 将聚水潭产品数据格式进行转换成pdd格式统一上传,匹配加密的spuCode和skuCoke #region 将聚水潭产品数据格式进行转换成pdd格式统一上传,匹配加密的spuCode和skuCoke
if (dbProd.product_get_type_text == "厂商直采" && dbProd.sku_secret_json != null && dbProd.sku_secret_json.Contains("goodsId")) if (dbProd.product_get_type_text == "厂商直采" && dbProd.sku_secret_json != null && dbProd.sku_secret_json.Contains("goodsId"))
{
try
{ {
string convertRst = ""; string convertRst = "";
var pProd = new PDDProdFormConverter().JstPddProdToPddConvert(out convertRst, dbProd); var pProd = new PDDProdFormConverter().JstPddProdToPddConvert(out convertRst, dbProd);
if (!string.IsNullOrEmpty(convertRst)) if (!string.IsNullOrEmpty(convertRst))
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"商品查询错误 " + convertRst + "\"}"; return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"源商品查询错误 " + convertRst + "\"}";
}
catch (Exception ex)
{
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"源商品格式转换错误 " + ex.Message + "\"}";
}
} }
#endregion #endregion
@@ -7026,7 +7004,8 @@ Content-Type: image/jpeg
cnt++; cnt++;
Invoke(new Action(() => Invoke(new Action(() =>
{ {
cell.Value = "正在上传主图 " + cnt + "/" + prodInfo.detail.galleries.Where(g => g.type == 1).ToList().Count; if (cell != null)
cell.Value = "正在上传主图 " + cnt + "/" + prodInfo.detail?.galleries?.Where(g => g.type == 1).ToList().Count;
})); }));
string errMsg = ""; string errMsg = "";
@@ -7054,6 +7033,7 @@ Content-Type: image/jpeg
Invoke(new Action(() => Invoke(new Action(() =>
{ {
if (cell != null)
cell.Value = "正在选取运费模板"; cell.Value = "正在选取运费模板";
})); }));
// 运费模板 // 运费模板
@@ -7085,7 +7065,8 @@ Content-Type: image/jpeg
cnt++; cnt++;
Invoke(new Action(() => Invoke(new Action(() =>
{ {
cell.Value = "正在上传详情图 " + cnt + "/" + prodInfo.detail.galleries.Where(g => g.type == 2).ToList().Count; if (cell != null)
cell.Value = "正在上传详情图 " + cnt + "/" + prodInfo.detail?.galleries?.Where(g => g.type == 2).ToList().Count;
})); }));
string errMsg = ""; string errMsg = "";
@@ -7115,6 +7096,7 @@ Content-Type: image/jpeg
Invoke(new Action(() => Invoke(new Action(() =>
{ {
if (cell != null)
cell.Value = "正在生成属性"; cell.Value = "正在生成属性";
})); }));
// 获取类目属性模板 // 获取类目属性模板
@@ -7247,10 +7229,12 @@ Content-Type: image/jpeg
#region 厂商直采获取推单运费模板,计算运费加价。 #region 厂商直采获取推单运费模板,计算运费加价。
//Invoke(new Action(() => //Invoke(new Action(() =>
//{ //{
// if (cell != null)
// cell.Value = "正在选取运费模板"; // cell.Value = "正在选取运费模板";
//})); //}));
Invoke(new Action(() => Invoke(new Action(() =>
{ {
if (cell != null)
cell.Value = "正在计算加价"; cell.Value = "正在计算加价";
})); }));
@@ -7432,6 +7416,7 @@ Content-Type: image/jpeg
{ {
Invoke(new Action(() => Invoke(new Action(() =>
{ {
if (cell != null)
cell.Value = "正在生成Sku规格 " + (i + 1) + "/" + addPriceSkuInfoLst.Count; cell.Value = "正在生成Sku规格 " + (i + 1) + "/" + addPriceSkuInfoLst.Count;
})); }));
@@ -7480,6 +7465,7 @@ Content-Type: image/jpeg
{ {
Invoke(new Action(() => Invoke(new Action(() =>
{ {
if (cell != null)
cell.Value = "正在拼接Sku " + (i + 1) + "/" + addPriceSkuInfoLst.Count; cell.Value = "正在拼接Sku " + (i + 1) + "/" + addPriceSkuInfoLst.Count;
})); }));
@@ -7640,9 +7626,7 @@ Content-Type: image/jpeg
Invoke(new Action(() => Invoke(new Action(() =>
{ {
if (cell != null) if (cell != null)
{
cell.Value = "正在编辑商品属性"; cell.Value = "正在编辑商品属性";
}
})); }));
List<goods_property_param> goods_property_param_lst = new List<goods_property_param>(); List<goods_property_param> goods_property_param_lst = new List<goods_property_param>();
goods_property_param_lst.Add(prop); goods_property_param_lst.Add(prop);
@@ -2789,7 +2789,7 @@ namespace TemuKJD.WXForms.ProductForms
{ {
foreach (var propInfo in prodInfo.property.goods_properties) foreach (var propInfo in prodInfo.property.goods_properties)
{ {
if (propInfo.name == "单件净含量") if (propInfo.name == "容量")
{ {
} }
@@ -2984,8 +2984,19 @@ namespace TemuKJD.WXForms.ProductForms
// attrValue = "20 cm"; // attrValue = "20 cm";
//else if (attr.value.Contains("岁以上") && attr.value.Contains("个月以上")) //else if (attr.value.Contains("岁以上") && attr.value.Contains("个月以上"))
// attrValue = "7 岁以上"; // attrValue = "7 岁以上";
//else if (attr.value == "只;个") else if (attr.value == "只;个")
// attrValue = "1 个"; {
if ((propInfo.values.FirstOrDefault()?.value).ParseToString().EndsWith("只") || (propInfo.values.FirstOrDefault()?.value).ParseToString().EndsWith("个"))
{
attrValue = propInfo.values.FirstOrDefault()?.value;
if (attrValue.TrimEnd('只', '个').ParseToInt() == 0)
attrValue = BaseRegex.GetMatchMaxRegexString(ref attrValue, "(\\d{1,6})") + (attrValue.Contains("只") ? " 只" : " 个");
if (attrValue.TrimEnd('只', '个').ParseToInt() == 0)
attrValue = "1 个";
}
else
attrValue = "1 个";
}
else if (attr.value == "ml") else if (attr.value == "ml")
{ {
if ((propInfo.values.FirstOrDefault()?.value).ParseToString().EndsWith(attr.value)) if ((propInfo.values.FirstOrDefault()?.value).ParseToString().EndsWith(attr.value))
@@ -2996,9 +3007,15 @@ namespace TemuKJD.WXForms.ProductForms
else if (attr.value == "L") else if (attr.value == "L")
{ {
if ((propInfo.values.FirstOrDefault()?.value).ParseToString().EndsWith(attr.value)) if ((propInfo.values.FirstOrDefault()?.value).ParseToString().EndsWith(attr.value))
{
attrValue = propInfo.values.FirstOrDefault()?.value; attrValue = propInfo.values.FirstOrDefault()?.value;
if (attrValue.TrimEnd('L').ParseToInt() == 0)
attrValue = BaseRegex.GetMatchMaxRegexString(ref attrValue, "(\\d{1,6})") + " L";
if (attrValue.TrimEnd('L').ParseToInt() == 0)
attrValue = "1 L";
}
else else
attr.value = "100 ml"; attr.value = "1 L";
} }
else if (attr.value == "g;kg;ml;L") else if (attr.value == "g;kg;ml;L")
{ {
@@ -3158,6 +3175,8 @@ namespace TemuKJD.WXForms.ProductForms
attrValue = "1 个"; attrValue = "1 个";
else if (attr.value == "ml") else if (attr.value == "ml")
attrValue = "100 ml"; attrValue = "100 ml";
else if (attr.value == "L")
attrValue = "1 L";
} }
var wxPropParam = new wxPropParam(); var wxPropParam = new wxPropParam();