用户产品数据库
用户1688采集
This commit is contained in:
1 parent
025b33b478
commit
c3ecb84a1e
25 files changed
+2050
-975
No files matched your search
@@ -35,6 +35,11 @@ namespace TemuKJD.ToolForms
|
||||
{
|
||||
public partial class Get1688ProductForm : BaseForms.BaseForm
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否是普通商品采集授权用户
|
||||
/// </summary>
|
||||
public bool IsAuthorityUser { get; set; } = false;
|
||||
|
||||
List<CefSharp.Cookie> lst1688cookie = null;
|
||||
public bool isGetProdLst = false;
|
||||
Dictionary<string, string> dicAfterSale = new Dictionary<string, string>();
|
||||
@@ -48,7 +53,7 @@ namespace TemuKJD.ToolForms
|
||||
private string currentGet1688ListParamData = "";
|
||||
private string currentGet1688ListProductData = "";
|
||||
private string appVersion = "";
|
||||
private string currentSupplierId = "";
|
||||
//private string currentSupplierId = "";
|
||||
int getDetailWait = 5;
|
||||
int pageStart = 1;
|
||||
int pageEnd = 9999;
|
||||
@@ -61,6 +66,14 @@ namespace TemuKJD.ToolForms
|
||||
|
||||
private void GetJuShuitanProdForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
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");
|
||||
@@ -300,18 +313,6 @@ namespace TemuKJD.ToolForms
|
||||
List<Cookie> cookieList = CEFBrowser.GetCookieList(".1688.com", cefWebBrowser.GetCookieManager(null));
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("1688_cookies", cookieList);
|
||||
BaseMsgForm.ShowInfo("保存成功");
|
||||
|
||||
//var url = BaseClass.BuildPDDObjString("user/update_scm121_cookie");
|
||||
//var data = UserLogin.GetSignaturex();
|
||||
//data += "&cookie=" + GetHtml.UrlEncodeUtf8(JsonHelper.SerializeObject(cookieList));
|
||||
//var result = GetHtml.PostUtf8(url, data);
|
||||
//if (!result.Contains("\"code\":200"))
|
||||
// result = GetHtml.PostUtf8(url, data);
|
||||
|
||||
//if (result.Contains("\"code\":200"))
|
||||
// BaseMsgForm.ShowInfo("保存成功");
|
||||
//else
|
||||
// BaseMsgForm.ShowInfo("保存失败,请重试");
|
||||
}
|
||||
|
||||
private void btnPrev_Click(object sender, EventArgs e)
|
||||
@@ -410,6 +411,9 @@ namespace TemuKJD.ToolForms
|
||||
}
|
||||
}
|
||||
|
||||
dgvProduct.BringToFront();
|
||||
this.pbLoading.BringToFront();
|
||||
|
||||
this.pbLoading.Visible = true;
|
||||
dgvProduct.Rows.Clear();
|
||||
lst1688OneProductListInfo.Clear();
|
||||
@@ -568,6 +572,9 @@ namespace TemuKJD.ToolForms
|
||||
return;
|
||||
}
|
||||
|
||||
dgvProduct.BringToFront();
|
||||
pbLoading.BringToFront();
|
||||
|
||||
if (cancellationTokenSource != null)
|
||||
cancellationTokenSource.Cancel();
|
||||
cancellationTokenSource = new CancellationTokenSource();
|
||||
@@ -624,6 +631,8 @@ namespace TemuKJD.ToolForms
|
||||
}
|
||||
}
|
||||
Thread.Sleep(Randomx.GetId(500, 1500));
|
||||
if (this.IsAuthorityUser)
|
||||
Thread.Sleep(1000);
|
||||
|
||||
// 采集商品详情
|
||||
currentDetailData = "";
|
||||
@@ -802,12 +811,10 @@ namespace TemuKJD.ToolForms
|
||||
|
||||
private void btnSaveDb_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (btnSaveDb.Text == "商品入库")
|
||||
if (btnSaveDb.Text == "采集商品入库")
|
||||
{
|
||||
//"&product_get_type=" + HttpUtility.UrlEncode("厂商直采", Encoding.UTF8);
|
||||
List<Cookie> cookieList = CEFBrowser.GetCookieList(".scm121.com", cefWebBrowser.GetCookieManager(null));
|
||||
var shop = new ShopLoginInfo();
|
||||
shop.Cookies = JsonHelper.SerializeObject(cookieList);
|
||||
dgvProduct.BringToFront();
|
||||
pbLoading.BringToFront();
|
||||
|
||||
List<DataGridViewRow> rowLst = new List<DataGridViewRow>();
|
||||
rowLst.AddRange(dgvProduct.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colCheck"].Value.ParseToBool() == true));
|
||||
@@ -860,12 +867,19 @@ namespace TemuKJD.ToolForms
|
||||
}
|
||||
|
||||
Thread.Sleep(25);
|
||||
if (this.IsAuthorityUser)
|
||||
Thread.Sleep(1000);
|
||||
if (row.Index % 20 == 0)
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("1688_product_list_" + MainForm.ProcessCount, lst1688OneProductListInfo);
|
||||
|
||||
// 商品采集权限用户采集的数据加上用户前缀(商品前缀显示给用户的时候隐藏)
|
||||
string collectAuthorityTag = "";
|
||||
if (IsAuthorityUser)
|
||||
collectAuthorityTag = "-" + BaseClass.UserName;
|
||||
|
||||
bool isExist = false;
|
||||
var existUrl = BaseClass.BuildPDDObjString("product/get_product_spu_id_list");
|
||||
string existData = UserLogin.GetSignaturex() + "&search_spu_ids=" + prod.offerId;
|
||||
string existData = UserLogin.GetSignaturex() + "&search_spu_ids=" + prod.offerId + collectAuthorityTag;
|
||||
string html = GetHtml.PostUtf8(existUrl, existData);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
html = GetHtml.PostUtf8(existUrl, existData);
|
||||
@@ -909,7 +923,7 @@ namespace TemuKJD.ToolForms
|
||||
"&from_shop_name=" + prod.dbProduct.from_shop_name +
|
||||
//"&offline_supplier_id=" + prod.dbProduct.offline_supplier_id +
|
||||
//"&offline_supplier_name=" + prod.dbProduct.offline_supplier_name +
|
||||
"&spu_id=" + prod.dbProduct.spu_id.ParseToString() +
|
||||
"&spu_id=" + prod.dbProduct.spu_id.ParseToString() + collectAuthorityTag +
|
||||
"&skc_id=" + prod.dbProduct.skc_id.ParseToString() +
|
||||
"&price_text=" + prod.dbProduct.price_text +
|
||||
"&ext_code=" + HttpUtility.UrlEncode(prod.dbProduct.ext_code, Encoding.UTF8) +
|
||||
@@ -920,7 +934,12 @@ namespace TemuKJD.ToolForms
|
||||
"&sale_count_text=" + HttpUtility.UrlEncode(dbProd.sale_count_text, Encoding.UTF8) +
|
||||
"&main_img=" + HttpUtility.UrlEncode(dbProd.main_img, Encoding.UTF8) +
|
||||
"&wx_safe_status=" + HttpUtility.UrlEncode("未校验", Encoding.UTF8) +
|
||||
"&product_get_type=" + HttpUtility.UrlEncode("1688厂家", Encoding.UTF8);
|
||||
"&product_get_type=" + HttpUtility.UrlEncode("1688厂家", Encoding.UTF8);
|
||||
if (IsAuthorityUser)
|
||||
{
|
||||
data += "&add_user_name=" + BaseClass.UserName;
|
||||
data += "&group=用户" + BaseClass.UserName;
|
||||
}
|
||||
if (!isExist)
|
||||
{
|
||||
data += "&main_cat_id=" + prod.dbProduct.main_cat_id +
|
||||
@@ -1090,7 +1109,7 @@ namespace TemuKJD.ToolForms
|
||||
|
||||
private void btnExportCookie_Click(object sender, EventArgs e)
|
||||
{
|
||||
List<Cookie> cookieList = CEFBrowser.GetCookieList(".scm121.com", cefWebBrowser.GetCookieManager(null));
|
||||
List<Cookie> cookieList = CEFBrowser.GetCookieList(".1688.com", cefWebBrowser.GetCookieManager(null));
|
||||
var shop = new ShopLoginInfo();
|
||||
shop.Cookies = JsonHelper.SerializeObject(cookieList);
|
||||
|
||||
@@ -1100,23 +1119,23 @@ namespace TemuKJD.ToolForms
|
||||
cooks = new List<CefSharp.Cookie>();
|
||||
|
||||
string cookJs = "";
|
||||
var keys = new string[] { "acw_tc", "DISTRYBUTION_TOKEN" };
|
||||
//var keys = new string[] { "acw_tc", "DISTRYBUTION_TOKEN" };
|
||||
//foreach (var shopCook in cooks)
|
||||
//{
|
||||
// var cookie = shopCook.Name + "=" + shopCook.Value;
|
||||
// if (!keys.Any(k => cookie.StartsWith(k)))
|
||||
// continue;
|
||||
// cookJs += "\r\ndocument.cookie='" + cookie.Substring(0, Math.Max(0, cookie.IndexOf("="))) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';";
|
||||
//}
|
||||
foreach (var shopCook in cooks)
|
||||
{
|
||||
var cookie = shopCook.Name + "=" + shopCook.Value;
|
||||
if (!keys.Any(k => cookie.StartsWith(k)))
|
||||
continue;
|
||||
cookJs += "\r\ndocument.cookie='" + cookie.Substring(0, Math.Max(0, cookie.IndexOf("="))) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';";
|
||||
}
|
||||
foreach (var shopCook in cooks)
|
||||
{
|
||||
var cookie = shopCook.Name + "=" + shopCook.Value;
|
||||
if (!keys.Any(k => cookie.StartsWith(k)))
|
||||
continue;
|
||||
cookJs += "\r\ndocument.cookie='" + cookie + "; domain=.scm121.com; expires=" +
|
||||
//if (!keys.Any(k => cookie.StartsWith(k)))
|
||||
// continue;
|
||||
cookJs += "\r\ndocument.cookie='" + cookie + "; domain=.1688.com; expires=" +
|
||||
DateTime.Now.AddMonths(1).ToUniversalTime().ToString("ddd, dd MMM yyyy HH:mm:ss 'UTC'", new DateTimeFormatInfo()) + "; path=/';";
|
||||
}
|
||||
cookJs += "\r\nsetTimeout(() => { window.location.href='https://sc.scm121.com/suppliersManage/suppliersList/onlineSuppliers'; }, 200)";
|
||||
cookJs += "\r\nsetTimeout(() => { window.location.href='" + InitUrl + "'; }, 200)";
|
||||
Clipboard.SetDataObject(cookJs);
|
||||
BaseMsgForm.ShowInfo("复制成功");
|
||||
}
|
||||
@@ -1138,7 +1157,7 @@ namespace TemuKJD.ToolForms
|
||||
}
|
||||
else
|
||||
{
|
||||
btnSaveDb.Text = "商品入库";
|
||||
btnSaveDb.Text = "采集商品入库";
|
||||
btnGetDetail.Visible = true;
|
||||
btnGetGoods.Visible = true;
|
||||
}
|
||||
@@ -1153,6 +1172,9 @@ namespace TemuKJD.ToolForms
|
||||
// 显示对话框并获取结果
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
dgvOut1688Prod.BringToFront();
|
||||
pbLoading.BringToFront();
|
||||
|
||||
var filePathLst = openFileDialog.FileNames.ToList();
|
||||
dgvOut1688Prod.Rows.Clear();
|
||||
pbLoading.Visible = true;
|
||||
@@ -1174,6 +1196,8 @@ namespace TemuKJD.ToolForms
|
||||
}
|
||||
rst = Out1688ProdImportOne(path, content);
|
||||
Thread.Sleep(100);
|
||||
if (this.IsAuthorityUser)
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -1230,9 +1254,14 @@ namespace TemuKJD.ToolForms
|
||||
//if (row.Index % 20 == 0)
|
||||
// NaiBa.Util.Helper.ConfigHelper.SaveConfig("1688_product_list_" + MainForm.ProcessCount, lst1688OneProductListInfo);
|
||||
|
||||
// 商品采集权限用户采集的数据加上用户前缀(商品前缀显示给用户的时候隐藏)
|
||||
string collectAuthorityTag = "";
|
||||
if (IsAuthorityUser)
|
||||
collectAuthorityTag = "-" + BaseClass.UserName;
|
||||
|
||||
bool isExist = false;
|
||||
var existUrl = BaseClass.BuildPDDObjString("product/get_product_spu_id_list");
|
||||
string existData = UserLogin.GetSignaturex() + "&search_spu_ids=" + outProd.productId;
|
||||
string existData = UserLogin.GetSignaturex() + "&search_spu_ids=" + outProd.productId + collectAuthorityTag;
|
||||
string html = GetHtml.PostUtf8(existUrl, existData);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
html = GetHtml.PostUtf8(existUrl, existData);
|
||||
@@ -1297,12 +1326,13 @@ namespace TemuKJD.ToolForms
|
||||
//return "起批数量超过1,跳过";
|
||||
}
|
||||
|
||||
string from_shop_id = (string.IsNullOrEmpty(outProd.shopId) ? outProd.shopName : outProd.shopId);
|
||||
var data = Work.UserLogin.GetSignaturex() +
|
||||
"&from_shop_id=" + (string.IsNullOrEmpty(outProd.shopId) ? outProd.shopName : outProd.shopId) +
|
||||
"&from_shop_id=" + from_shop_id +
|
||||
"&from_shop_name=" + outProd.shopName +
|
||||
//"&offline_supplier_id=" + prod.dbProduct.offline_supplier_id +
|
||||
//"&offline_supplier_name=" + prod.dbProduct.offline_supplier_name +
|
||||
"&spu_id=" + prodInfo.detail.goods_id.ParseToString() +
|
||||
"&spu_id=" + prodInfo.detail.goods_id.ParseToString() + collectAuthorityTag +
|
||||
"&skc_id=" + prodInfo.detail.goods_id.ParseToString() +
|
||||
"&price_text=" + priceMin + "-" + priceMax +
|
||||
"&ext_code=" + HttpUtility.UrlEncode(prodInfo.detail.out_goods_sn, Encoding.UTF8) +
|
||||
@@ -1314,6 +1344,11 @@ 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)
|
||||
{
|
||||
data += "&add_user_name=" + BaseClass.UserName;
|
||||
data += "&group=用户" + BaseClass.UserName;
|
||||
}
|
||||
if (!isExist)
|
||||
{
|
||||
data += "&main_cat_id=" + "" +
|
||||
@@ -1363,5 +1398,10 @@ namespace TemuKJD.ToolForms
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private void btnOutProdSaveDb_Click(object sender, EventArgs e)
|
||||
{
|
||||
Out1688ProductImport();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user