店铺订单数据优化逻辑
This commit is contained in:
1 parent
1b87ae3a28
commit
51fa4ca578
11 files changed
+912
-741
No files matched your search
@@ -28,6 +28,7 @@ using TemuKJD.BLL;
|
||||
using TemuKJD.Extension;
|
||||
using TemuKJD.Helper;
|
||||
using TemuKJD.PDDForms.ProductSelectForms;
|
||||
using TemuKJD.UserControls;
|
||||
using TemuKJD.WXForms.ProductForms;
|
||||
using Work;
|
||||
|
||||
@@ -68,16 +69,13 @@ namespace TemuKJD.ToolForms
|
||||
{
|
||||
if(IsAuthorityUser)
|
||||
{
|
||||
tabPage2.Controls.Add(dgvOut1688Prod);
|
||||
this.ucTabControlMetro1.TabPages.RemoveAt(3);
|
||||
this.ucTabControlMetro1.TabPages.RemoveAt(2);
|
||||
btnOutProdSaveDb.Visible = true;
|
||||
}
|
||||
|
||||
this.splitContainer1.SplitterDistance = 472;
|
||||
this.dgvProduct.AddSelectorColumn("colCheck");
|
||||
this.dgvProduct.AddImgColumn("colImg", "colImgUrl");
|
||||
this.dgvOut1688Prod.AddImgColumn("colOutImg", "colOutImgUrl");
|
||||
|
||||
lst1688cookie = NaiBa.Util.Helper.ConfigHelper.LoadConfig<List<Cookie>>("1688_cookies");
|
||||
if (lst1688cookie == null)
|
||||
@@ -987,10 +985,6 @@ namespace TemuKJD.ToolForms
|
||||
}));
|
||||
}, cancellationTokenSource.Token);
|
||||
}
|
||||
else if (btnSaveDb.Text == "外部商品入库" || btnSaveDb.Text == "已采集数据入库")
|
||||
{
|
||||
Out1688ProductImport();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1140,31 +1134,11 @@ namespace TemuKJD.ToolForms
|
||||
BaseMsgForm.ShowInfo("复制成功");
|
||||
}
|
||||
|
||||
|
||||
private void btnStop_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (CancelReturn != null)
|
||||
CancelReturn.Cancel();
|
||||
}
|
||||
|
||||
private void ucTabControlMetro1_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (ucTabControlMetro1.SelectedTab.Text == "1688外部数据" || ucTabControlMetro1.SelectedTab.Text == "已采集数据")
|
||||
{
|
||||
btnSaveDb.Text = "外部商品入库";
|
||||
btnSaveDb.Text = "已采集数据入库";
|
||||
btnGetDetail.Visible = false;
|
||||
btnGetGoods.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
btnSaveDb.Text = "采集商品入库";
|
||||
btnGetDetail.Visible = true;
|
||||
btnGetGoods.Visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Out1688ProductImport()
|
||||
public static void Out1688ProductImport(bool isAuthorityUser, StatusBarUserControl statusBar, PictureBox pbLoading)
|
||||
{
|
||||
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||||
openFileDialog.Multiselect = true;
|
||||
@@ -1173,14 +1147,14 @@ namespace TemuKJD.ToolForms
|
||||
// 显示对话框并获取结果
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
dgvOut1688Prod.BringToFront();
|
||||
pbLoading.BringToFront();
|
||||
//dgvOut1688Prod.BringToFront();
|
||||
//pbLoading.BringToFront();
|
||||
|
||||
var filePathLst = openFileDialog.FileNames.ToList();
|
||||
dgvOut1688Prod.Rows.Clear();
|
||||
pbLoading.Visible = true;
|
||||
this.statusBar.pgbTaskProgress.Maximum = filePathLst.Count;
|
||||
this.statusBar.UpdateProgressBar(0);
|
||||
//dgvOut1688Prod.Rows.Clear();
|
||||
//pbLoading.Visible = true;
|
||||
statusBar.pgbTaskProgress.Maximum = filePathLst.Count;
|
||||
statusBar.UpdateProgressBar(0);
|
||||
Task.Run(() =>
|
||||
{
|
||||
int successNum = 0;
|
||||
@@ -1195,49 +1169,47 @@ namespace TemuKJD.ToolForms
|
||||
{
|
||||
content = sr.ReadToEnd();
|
||||
}
|
||||
rst = Out1688ProdImportOne(path, content);
|
||||
rst = Out1688ProdImportOne(isAuthorityUser, path, content);
|
||||
Thread.Sleep(100);
|
||||
if (this.IsAuthorityUser)
|
||||
if (isAuthorityUser)
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
rst = ex.Message;
|
||||
}
|
||||
if (string.IsNullOrEmpty(rst))
|
||||
if (string.IsNullOrEmpty(rst) || rst.Contains("成功"))
|
||||
successNum++;
|
||||
else
|
||||
failedNum++;
|
||||
Invoke(new Action(() =>
|
||||
statusBar.Invoke(new Action(() =>
|
||||
{
|
||||
this.statusBar.UpdateProgressBar(this.statusBar.pgbTaskProgress.Value + 1);
|
||||
this.statusBar.lblTaskStatus.Text = "正在导入";
|
||||
statusBar.UpdateProgressBar(statusBar.pgbTaskProgress.Value + 1);
|
||||
statusBar.lblTaskStatus.Text = "正在导入 成功" + successNum + " 失败" + failedNum;
|
||||
}));
|
||||
}
|
||||
Invoke(new Action(() =>
|
||||
statusBar.Invoke(new Action(() =>
|
||||
{
|
||||
pbLoading.Visible = false;
|
||||
this.statusBar.lblTaskStatus.Text = "导入完成";
|
||||
statusBar.lblTaskStatus.Text = "导入完成 成功" + successNum + " 失败" + failedNum;
|
||||
BaseMsgForm.ShowInfo("导入完成!");
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
string Out1688ProdImportOne(string filePath, string content)
|
||||
public static string Out1688ProdImportOne(bool isAuthorityUser, string filePath, string content)
|
||||
{
|
||||
|
||||
DataGridViewRow row = null;
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
var index = dgvOut1688Prod.Rows.Add(false, filePath);
|
||||
row = dgvOut1688Prod.Rows[index];
|
||||
row.Height = 60;
|
||||
}));
|
||||
//DataGridViewRow row = null;
|
||||
//Invoke(new Action(() =>
|
||||
//{
|
||||
// var index = dgvOut1688Prod.Rows.Add(false, filePath);
|
||||
// row = dgvOut1688Prod.Rows[index];
|
||||
// row.Height = 60;
|
||||
//}));
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(content) || content.Length < 10)
|
||||
return "商品数据为空";
|
||||
|
||||
@@ -1252,12 +1224,10 @@ namespace TemuKJD.ToolForms
|
||||
return convertRst;
|
||||
|
||||
Thread.Sleep(25);
|
||||
//if (row.Index % 20 == 0)
|
||||
// NaiBa.Util.Helper.ConfigHelper.SaveConfig("1688_product_list_" + MainForm.ProcessCount, lst1688OneProductListInfo);
|
||||
|
||||
// 商品采集权限用户采集的数据加上用户前缀(商品前缀显示给用户的时候隐藏)
|
||||
string collectAuthorityTag = "";
|
||||
if (IsAuthorityUser)
|
||||
if (isAuthorityUser)
|
||||
collectAuthorityTag = "-" + BaseClass.UserName;
|
||||
|
||||
bool isExist = false;
|
||||
@@ -1268,10 +1238,10 @@ namespace TemuKJD.ToolForms
|
||||
html = GetHtml.PostUtf8(existUrl, existData);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
row.Cells["colOutMsg"].Value = "入库失败,产品数据库连接失败";
|
||||
}));
|
||||
//Invoke(new Action(() =>
|
||||
//{
|
||||
// row.Cells["colOutMsg"].Value = "入库失败,产品数据库连接失败";
|
||||
//}));
|
||||
return "入库失败,产品数据库连接失败";
|
||||
}
|
||||
else
|
||||
@@ -1280,42 +1250,37 @@ namespace TemuKJD.ToolForms
|
||||
isExist = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
var priceMin = (prodInfo.detail.sku?.Min(x => x.multi_price)).ParseToInt() * 0.01m;
|
||||
var priceMax = (prodInfo.detail.sku?.Max(x => x.multi_price)).ParseToInt() * 0.01m;
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
row.Cells["colOutSupplierId"].Value = (string.IsNullOrEmpty(outProd.shopId) ? outProd.shopName : outProd.shopId);
|
||||
row.Cells["colOutSupplierName"].Value = outProd.shopName;
|
||||
row.Cells["colOutGoodsId"].Value = prodInfo.detail.goods_id.ParseToString();
|
||||
row.Cells["colOutGoodsName"].Value = prodInfo.detail.goods_name;
|
||||
row.Cells["colOutCat"].Value = outProd.categoryName;
|
||||
row.Cells["colOutImgUrl"].Value = prodInfo.detail.image_url;
|
||||
row.Cells["colOutPrice"].Value = priceMin + "-" + priceMax;
|
||||
}));
|
||||
|
||||
|
||||
|
||||
//Invoke(new Action(() =>
|
||||
//{
|
||||
// row.Cells["colOutSupplierId"].Value = (string.IsNullOrEmpty(outProd.shopId) ? outProd.shopName : outProd.shopId);
|
||||
// row.Cells["colOutSupplierName"].Value = outProd.shopName;
|
||||
// row.Cells["colOutGoodsId"].Value = prodInfo.detail.goods_id.ParseToString();
|
||||
// row.Cells["colOutGoodsName"].Value = prodInfo.detail.goods_name;
|
||||
// row.Cells["colOutCat"].Value = outProd.categoryName;
|
||||
// row.Cells["colOutImgUrl"].Value = prodInfo.detail.image_url;
|
||||
// row.Cells["colOutPrice"].Value = priceMin + "-" + priceMax;
|
||||
//}));
|
||||
|
||||
//var SetPartnerSpuRst = "";
|
||||
var url = BaseClass.BuildPDDObjString("product/add_product");
|
||||
if (isExist)
|
||||
{
|
||||
if (chkOverride.Checked)
|
||||
{
|
||||
//if (chkOverride.Checked)
|
||||
//{
|
||||
url = BaseClass.BuildPDDObjString("product/mdy_product");
|
||||
}
|
||||
else
|
||||
{
|
||||
//入库成功 已存在相同id商品
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
row.Cells["colOutMsg"].Value = "已存在相同商品Id,跳过";
|
||||
}));
|
||||
return "";
|
||||
}
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// //入库成功 已存在相同id商品
|
||||
// Invoke(new Action(() =>
|
||||
// {
|
||||
// row.Cells["colOutMsg"].Value = "已存在相同商品Id,跳过";
|
||||
// }));
|
||||
// return "";
|
||||
//}
|
||||
}
|
||||
|
||||
if (outProd.minOrderQuaitity.ParseToInt() > 1)
|
||||
@@ -1345,7 +1310,7 @@ namespace TemuKJD.ToolForms
|
||||
"&main_img=" + HttpUtility.UrlEncode(prodInfo.detail.image_url, Encoding.UTF8) +
|
||||
"&wx_safe_status=" + HttpUtility.UrlEncode("未校验", Encoding.UTF8) +
|
||||
"&product_get_type=" + HttpUtility.UrlEncode("1688外部数据", Encoding.UTF8);
|
||||
if (IsAuthorityUser)
|
||||
if (isAuthorityUser)
|
||||
{
|
||||
data += "&add_user_name=" + BaseClass.UserName;
|
||||
data += "&group=用户" + BaseClass.UserName;
|
||||
@@ -1371,38 +1336,32 @@ namespace TemuKJD.ToolForms
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
{
|
||||
string msg = "商品入库失败!请检查网络连接:" + BaseRegex.GetStringJson(ref html, "msg");
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
row.Cells["colOutMsg"].Value = msg;
|
||||
}));
|
||||
//Invoke(new Action(() =>
|
||||
//{
|
||||
// row.Cells["colOutMsg"].Value = msg;
|
||||
//}));
|
||||
return msg;
|
||||
}
|
||||
else
|
||||
{
|
||||
var getProductMsg = "商品入库成功!";
|
||||
if (url == BaseClass.BuildPDDObjString("product/mdy_product"))
|
||||
getProductMsg = "商品覆盖成功!";
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
row.Cells["colOutMsg"].Value = getProductMsg;
|
||||
}));
|
||||
//var getProductMsg = "商品入库成功!";
|
||||
//if (url == BaseClass.BuildPDDObjString("product/mdy_product"))
|
||||
// getProductMsg = "商品覆盖成功!";
|
||||
//Invoke(new Action(() =>
|
||||
//{
|
||||
// row.Cells["colOutMsg"].Value = getProductMsg;
|
||||
//}));
|
||||
}
|
||||
//NaiBa.Util.Helper.ConfigHelper.SaveConfig("1688_product_list_" + MainForm.ProcessCount, lst1688OneProductListInfo);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
row.Cells["colOutMsg"].Value = "商品入库失败" + ex.Message;
|
||||
}));
|
||||
//Invoke(new Action(() =>
|
||||
//{
|
||||
// row.Cells["colOutMsg"].Value = "商品入库失败" + ex.Message;
|
||||
//}));
|
||||
return "商品入库失败" + ex.Message;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private void btnOutProdSaveDb_Click(object sender, EventArgs e)
|
||||
{
|
||||
Out1688ProductImport();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user