using AllBase; using AllBase.Helper; using AllBase.Model.Param.UploadManage; using AllBase.Model.Result; using DevComponents.DotNetBar; using LittleRabbit.Extension; using LittleRabbit.LittleRabbitForms.BaseForms; using LittleRabbit.LittleRabbitForms.ToolForms; using NaiBa.Util; using NaiBa.Util.Extension; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.IO.Compression; using System.Linq; using System.Net; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using Work; using Work.BLL.Upload; using Work.CollectClass; using Work.DouyinApiClass; using Work.GoodDetail; namespace LittleRabbit.LittleRabbitForms.UploadForms { public partial class UploadProductForm : Form { public static UploadProductForm instance = null; public static List lstFissionPcb = new List(); // 数据净化的数据列表 public string formName = "商品发布"; public static IeForm ieForm = new IeForm(); public List lstCommissionAddResult; // 添加佣金商品的列表 public string failedUploadFileName = "上货失败文件备份" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt"; public UploadProductForm() { InitializeComponent(); lstCommissionAddResult = NaiBa.Util.Helper.ConfigHelper.LoadConfig>("upload_commission_list"); if (lstCommissionAddResult == null) lstCommissionAddResult = new List(); this.ucTabControlMetro1.TabPages.Remove(tabPage4); } private void UploadProductForm_Load(object sender, EventArgs e) { instance = this; // 加载所有全局属性和资质 UploadProductBLL.sGlobalPropList = NaiBa.Util.Helper.ConfigHelper.LoadConfig>("global_prop_list"); if (UploadProductBLL.sGlobalPropList == null) UploadProductBLL.sGlobalPropList = new List(); UploadProductBLL.sGlobalQualifications = NaiBa.Util.Helper.ConfigHelper.LoadConfig>("global_qualifications"); if (UploadProductBLL.sGlobalQualifications == null) UploadProductBLL.sGlobalQualifications = new List(); this.txtBrand.TextChanged -= this.txtBrand_TextChanged; this.txt生产企业名称.TextChanged -= this.txt生产企业名称_TextChanged; this.txt食品生产许可证编号.TextChanged -= this.txt食品生产许可证号_TextChanged; this.txtBrand.Text = UploadProductBLL.sGlobalPropList.Find(p => p.Key == "品牌")?.Value + ""; this.txt生产企业名称.Text = UploadProductBLL.sGlobalPropList.Find(p => p.Key == "生产企业名称")?.Value + ""; this.txt食品生产许可证编号.Text = UploadProductBLL.sGlobalPropList.Find(p => p.Key == "食品生产许可证编号")?.Value + ""; var pic1 = UploadProductBLL.sGlobalQualifications.Find(q => q.quality_name == "食品生产许可证")?.quality_attachments.FirstOrDefault().url; if (pic1 != null) try { this.pictureBox1.Load(pic1); } catch (Exception ex) { BaseMsgForm.ShowError("食品生产许可证:" + ex.Message); } var pic2 = UploadProductBLL.sGlobalQualifications.Find(q => q.quality_name == "包装标签图")?.quality_attachments.FirstOrDefault().url; if (pic2 != null) try { this.pictureBox2.Load(pic2); } catch (Exception ex) { BaseMsgForm.ShowError("包装标签图:" + ex.Message); } var pic3 = UploadProductBLL.sGlobalQualifications.Find(q => q.quality_name == "质检报告")?.quality_attachments.FirstOrDefault().url; if (pic3 != null) try { this.pictureBox3.Load(pic3); } catch (Exception ex) { BaseMsgForm.ShowError("质检报告:" + ex.Message); } this.txt食品生产许可证编号.TextChanged += this.txt食品生产许可证号_TextChanged; this.txt生产企业名称.TextChanged += this.txt生产企业名称_TextChanged; this.txtBrand.TextChanged += this.txtBrand_TextChanged; //this.ucTabControlMetro1.TabPages.RemoveAt(2); #if DEBUG this.cmbSendType.Items.Add("现货-预售"); this.cmbSendType.Items.Add("新预售"); //this.chkSaveToOffLine.Visible = true; #endif chkMultiUpload_CheckedChanged(null, null); LoadShops(); GetUploadParam(); Task.Run(() => { LoadStock(); ImportFromFission(lstFissionPcb); lstFissionPcb.Clear(); }); txtMultiple_TextChanged(null, null); txtMultiple2_TextChanged(null, null); txtPostage_TextChanged(null, null); txtPostage2_TextChanged(null, null); proxyCheckBox_CheckedChanged(null, null); lowPricecheckBox_CheckedChanged(null, null); lowPricePercenttextBox_TextChanged(null, null); lowPriceAddtextBox_TextChanged(null, null); new Thread(RefreshIeForm).Start(); this.dgvShop.AddSelectorColumn("colSelect"); this.cmb7Day.SelectedIndex = 2; ReadUrlImage(); InitCommissionCef(); } private void ReadUrlImage() { try { if (FileBase.Exists("temp/imageUrl.txt")) { UploadProductBLL.baseImageUrl = FileBase.ReadAllText("temp/imageUrl.txt").Trim(); } } catch (Exception) { throw; } } public void LoadShops() { for (int i = 0; i < GlobalConfig.DouShopLoginList.Count; i++) { var shop = GlobalConfig.DouShopLoginList[i]; dgvShop.Rows.Add(false, shop.ShopAccountId, shop.ShopAccount, 0, shop.LoginStatus); } } public void RefreshIeForm() { while (true) { try { if (!string.IsNullOrEmpty(BaseClass.IeUrlShow)) { Invoke(new Action(() => { if (IeForm.IsShowIeForm) { IeForm VerfyForm = new IeForm(); VerfyForm.Url = BaseClass.IeUrlShow; BaseClass.IeUrlShow = ""; VerfyForm.Text = "淘宝验证窗口"; VerfyForm.ShowDialog(); } })); } if (UploadProductBLL.IsNoToken) { Invoke(new Action(() => { TokenNewForm tokenForm = new TokenNewForm(); tokenForm.ShowDialog(); if (PinduoduoProductCollect.PinDuoDuoTokenList.Where(to => to.ProductDetailStatus == 1).ToList().Count == 0) { UploadProductBLL.IsNoToken = false; } })); } } catch { } Thread.Sleep(10); } } bool isRunning = false; private void btnUpload_Click(object sender, EventArgs e) { if (isRunning) return; SaveUploadParam(); failedUploadFileName = "上货失败文件备份" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt"; if (string.IsNullOrEmpty(txtPhone.Text)) { BaseMsgForm.ShowError("请输入客服电话号码!", "上传提醒", FormLevel.MEDIUM); return; } //if (TaobaoMobileCollect.CookiesDic.Count == 0 && UploadProductBLL.ProductStock.Exists(s => s.FromType == "淘宝")) //{ // BaseMsgForm.ShowInfo("为了正常上传,请登录淘宝买手号", "提示"); // ieForm.Show(); // ieForm.WindowState = FormWindowState.Normal; // ieForm.Activate(); // return; //} string delayType = cmbSendType.SelectedItem.ToString(); if (delayType == "现货发货") UploadProductBLL.delayType = "0"; if (delayType == "预售发货") UploadProductBLL.delayType = "1"; if (delayType == "阶梯发货") UploadProductBLL.delayType = "2"; if (delayType == "现货-预售") UploadProductBLL.delayType = "3"; if (delayType == "新预售") UploadProductBLL.delayType = "4"; UploadProductBLL.newPreTime = cmbNewPreTime.SelectedItem.ToString(); string sendDay = this.cmbSendDay.SelectedItem.ToString(); if (sendDay == "24") UploadProductBLL.sendDay = "1"; if (sendDay == "48") UploadProductBLL.sendDay = "2"; UploadProductBLL.isRandomMainImage = chkRandomMainImage.Checked; UploadProductBLL.isDraft = chkSaveToDraft.Checked; UploadProductBLL.IsFilterTitleWord = chkFilterTitle.Checked; UploadProductBLL.IsFilterRemoveTitleWord = chkFilterRemoveTitle.Checked; UploadProductBLL.IsFilterSkuWord = chkFilterSku.Checked; UploadProductBLL.IsFilterBrandWord = chkFilterBrand.Checked; UploadProductBLL.IsFilterTMChaoShi = chkFilterTMChaoShi.Checked; UploadProductBLL.isCustomStock = chkCustomStock.Checked; UploadProductBLL.skuCustomStock = int.Parse(txtCustomStock.Text); if (!string.IsNullOrEmpty(txtMinSku.Text)) UploadProductBLL.minSkuStock = int.Parse(txtMinSku.Text); UploadProductBLL.isMinSkuStock = chkMinSku.Checked; UploadProductBLL.isMultiUpload = chkMultiUpload.Checked; //UploadProductBLL.isShopFissionUpload = chkShopFissionUpload.Checked; if (delayType == "预售发货") { DateTime endDate; DateTime.TryParse(this.endDateTimePicker.Text + " 23:59:59", out endDate); if ((endDate - DateTime.Now).TotalDays < 2) { MessageBox.Show("预售时间不能早于当前时间加2天"); return; } if ((endDate - DateTime.Now).TotalDays > 30) { MessageBox.Show("无法设置,预售时间超过设置范围,最大30天"); return; } UploadProductBLL.preEndTime = endDate.ToString("yyyy-MM-dd HH:mm:ss"); } UploadProductBLL.endDay = cmbSendDayAfterPre.SelectedItem.ToString(); UploadProductBLL.recommend_remark = txtremark.Text; SetButtonCanNotUse(); isRunning = true; UploadProductBLL.ids = dgvShop.Rows.Cast() .Where(r1 => r1.Cells["colSelect"].Value.ToString().ToLower() == "true") .Select(r2 => r2.Cells["colShopId"].Value?.ToString()).ToList(); UploadProductBLL.isSaveToOffLine = this.chkSaveToOffLine.Checked; UploadProductBLL.IsUseGlobalQualifications = this.chkUseGlobalQualifications.Checked; UploadProductBLL.supply_7day_return = this.cmb7Day.SelectedIndex.ToString(); UploadProductBLL.isViolateCheck = this.chkViolateCheck.Checked; UploadProductBLL.isRoundPrice = this.chkRoundPrice.Checked; UploadProductBLL.productBrand = this.txtProductBrand.Text.Trim(); UploadProductBLL.IsDelMainPic = this.chkDelMainPic.Checked; UploadProductBLL.DelMainPicId = this.cmbDelMainPic.Text.ParseToInt(); UploadProductBLL.IsDelFirstContentPic = this.chkDelFirstContentPic.Checked; UploadPropertyBLL.IsFuzzyMatching = this.chkFuzzyMatching.Checked; UploadProductBLL.phone = txtPhone.Text; foreach (var shop in GlobalConfig.DouShopLoginList) { shop.CanUpload = shop.LoginStatus == "登录成功" && shop.ApiAuthStatus == "授权成功"; } Task.Run(() => { Upload(); isRunning = false; Invoke(new Action(() => { SetButtonCanUse(1); })); }); } public void Upload() { if (UploadProductBLL.isMultiUpload) { UploadProductBLL.ProductStockTemp.Clear(); for (int i = 0; i < UploadProductBLL.ProductStock.Count; i++) { UploadProductBLL.ProductStockTemp.Add(UploadProductBLL.ProductStock[i]); } } List ts = new List(); for (int i = 0; i < GlobalConfig.DouShopLoginList.Count; i++) { var shop = GlobalConfig.DouShopLoginList[i]; if (!UploadProductBLL.ids.Any(id => id == shop.ShopAccountId) || shop.ApiAuthStatus != "授权成功") continue; if (UploadProductBLL.isMultiUpload) Threadx.ThreadListWait(ref ts, new Thread(GetMulti), UploadProductBLL.ShopThreadCount, shop); else Threadx.ThreadListWait(ref ts, new Thread(Get), UploadProductBLL.ShopThreadCount, shop); Thread.Sleep(1000); } Threadx.ThreadListWait(ref ts); isRunning = false; } public void SetButtonCanNotUse() { btnUploadGood.Enabled = false; } public void SetButtonCanUse(int waitSecond = 5) { Task.Run(() => { Thread.Sleep(1000 * waitSecond); Invoke(new Action(() => { btnUploadGood.Enabled = true; })); }); } public void Get(object shop) { var Shop = shop as DouShopLoginInfo; var bll = new UploadProductBLL(formName, Shop); bll.productHandler = RefreshGridView; bll.noticeHandler = RefreshLog; bll.remainHandler = ReMain; bll.UploadProduct(); } /// /// 分裂上传(一件商品传到所有店铺) /// /// public void GetMulti(object shop) { var Shop = shop as DouShopLoginInfo; var bll = new UploadProductBLL(formName, Shop); bll.productHandler = RefreshGridView; bll.noticeHandler = RefreshLog; bll.remainHandler = ReMain; bll.UploadProductMulti(); } public void RefreshGridView(TaobaoProductBase p) { // 佣金设置 if (p != null && uploadParam.isSetCommission && !lstCommissionAddResult.Any(g => g.ProductId == p?.GoodsId)) { UploadCommissionParam comm = new UploadCommissionParam(); comm.ProductId = p.GoodsId; comm.ShopName = p.ShopName; comm.Rate = uploadParam.commissionRatio; lstCommissionAddResult.Add(comm); NaiBa.Util.Helper.ConfigHelper.SaveConfig("upload_commission_list", lstCommissionAddResult); } // 上货成功后显示到列表 this.Invoke(new Action(() => { //dgvProduct.Rows.Add(p.FromIdBak > 0 ? p.FromIdBak : p.FromId, p.GoodsId, p.ShopName, p.Titlte, p.Price / 100, p.FromType, p.Message); totalPage = (int)Math.Ceiling((double)UploadProductBLL.ProductTemp.Count / pageSize); if (totalPage == 0) totalPage = 1; if (newCurrentPage != oldCurrentPage) { dgvProduct.Rows.Clear(); oldCurrentPage = newCurrentPage; } if (newCurrentPage > totalPage) newCurrentPage = totalPage; if (newCurrentPage < 1) newCurrentPage = 1; if (totalPage > newCurrentPage && isNewPage) newCurrentPage = totalPage; this.lblCurrentPage.Text = newCurrentPage.ToString(); this.lblTotalPage.Text = "共" + totalPage.ToString() + "页"; for (int num = (newCurrentPage - 1) * pageSize; num < (newCurrentPage - 1) * pageSize + pageSize; num++) { if (num >= UploadProductBLL.ProductTemp.Count) break; int i = num - (newCurrentPage - 1) * pageSize; p = UploadProductBLL.ProductTemp[num]; if (p == null) continue; //bool had = false; if (dgvProduct.Rows.Count > i) { continue; } //dgvProduct.currentPage = (newCurrentPage - 1) * pageSize; dgvProduct.Rows.Add(p.FromIdBak > 0 ? p.FromIdBak : p.FromId, p.GoodsId, p.ShopName, p.Titlte, p.Price / 100, p.FromType, "货源网", p.Message); } if (p?.Message == "提交成功") { var row = dgvShop.Rows.Cast().FirstOrDefault(r => r.Cells["colShopName"]?.Value?.ToString() == p.ShopName); var shop = GlobalConfig.DouShopLoginList.FirstOrDefault(s => s.ShopAccount == p.ShopName); if (shop != null && row != null) { row.Cells["colUploadCount"].Value = shop.UploadCount; } } else { if (uploadParam.isAutoSaveUploadFailedProduct) { var fileName = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory).Trim('\\') + "\\" + failedUploadFileName; var url = ""; if (p.FromType == "淘宝") url = "https://item.taobao.com/item.htm?id=" + p.FromId; else if (p.FromType == "阿里巴巴") url = "https://detail.1688.com/offer/" + p.FromId + ".html"; else if (p.FromType == "微店") url = "https://weidian.com/item.html?itemID=" + p.FromId; else if (p.FromType == "京喜") url = "https://item.m.jd.com/product/" + p.FromId + ".html"; else if (p.FromType == "拼多多") url = "http://mobile.yangkeduo.com/goods.html?goods_id=" + p.FromId; else if (p.FromType == "抖音" || p.FromType == "") url = "https://haohuo.jinritemai.com/views/product/detail?id=" + p.FromId; FileBase.AppendAllText(fileName, url + "====" + p.ShopName + "====" + p.Message + "\r\n"); } } })); } public void RefreshLog(string message) { Task.Run(() => { if (this.Created) { this.Invoke(new Action(() => { this.statusBar.lblTaskStatus.Text = message; this.statusBar.pgbTaskProgress.Maximum = UploadProductBLL.maxCount; this.statusBar.pgbTaskProgress.Value = UploadProductBLL.ProductTemp.Count; this.statusBar.pgbTaskProgress.Text = UploadProductBLL.ProductTemp.Count + "/" + UploadProductBLL.maxCount; })); } }); } public void ReMain() { this.Invoke(new Action(() => { // 显示剩下未上货商品数量 if (UploadProductBLL.isMultiUpload && UploadProductBLL.MultiUploadRestCount > -1) countLabel.Text = UploadProductBLL.MultiUploadRestCount + "个"; else countLabel.Text = UploadProductBLL.ProductStock.Count + "个"; })); } private void txtMultiple_TextChanged(object sender, EventArgs e) { if (txtMultiple.Text == "-") return; try { if (!string.IsNullOrEmpty(txtMultiple.Text)) { var multiple = decimal.Parse(txtMultiple.Text); //把倍数变成百分比 UploadProductBLL.addMultiple = multiple * 100 - 100; if (UploadProductBLL.addMultiple > UploadProductBLL.addMultiple2) { UploadProductBLL.addMultiple2 = UploadProductBLL.addMultiple; this.txtMultiple2.Text = "" + ((UploadProductBLL.addMultiple2 + 100m) / 100); } } } catch { } } private void txtMultiple2_TextChanged(object sender, EventArgs e) { if (txtMultiple2.Text == "-") return; try { if (!string.IsNullOrEmpty(txtMultiple2.Text)) { var multiple2 = decimal.Parse(txtMultiple2.Text); //把倍数变成百分比 UploadProductBLL.addMultiple2 = multiple2 * 100 - 100; if (UploadProductBLL.addMultiple2 < UploadProductBLL.addMultiple) { UploadProductBLL.addMultiple = UploadProductBLL.addMultiple2; this.txtMultiple.Text = "" + ((UploadProductBLL.addMultiple + 100m) / 100); } } } catch { } } private void txtPostage_TextChanged(object sender, EventArgs e) { if (txtPostage.Text == "-") return; try { if (!string.IsNullOrEmpty(txtPostage.Text)) UploadProductBLL.postage = decimal.Parse(txtPostage.Text); if (cmbPlusOrMinus.SelectedItem.ToString() != "+") UploadProductBLL.postage = -UploadProductBLL.postage; if (UploadProductBLL.postage > UploadProductBLL.postage2) { UploadProductBLL.postage2 = UploadProductBLL.postage; this.txtPostage2.Text = UploadProductBLL.postage2.ToString().Trim('-'); if (UploadProductBLL.postage2.ToString().Contains("-")) cmbPlusOrMinus2.SelectedItem = "-"; else cmbPlusOrMinus2.SelectedItem = "+"; } } catch { } } private void txtPostage2_TextChanged(object sender, EventArgs e) { if (txtPostage2.Text == "-") return; try { if (!string.IsNullOrEmpty(txtPostage2.Text)) UploadProductBLL.postage2 = decimal.Parse(txtPostage2.Text); if (cmbPlusOrMinus2.SelectedItem.ToString() != "+") UploadProductBLL.postage2 = -UploadProductBLL.postage2; if (UploadProductBLL.postage2 < UploadProductBLL.postage) { UploadProductBLL.postage = UploadProductBLL.postage2; this.txtPostage.Text = UploadProductBLL.postage.ToString().Trim('-'); if (UploadProductBLL.postage.ToString().Contains("-")) cmbPlusOrMinus.SelectedItem = "-"; else cmbPlusOrMinus.SelectedItem = "+"; } } catch { } } private void dgvShop_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex < 0 || e.RowIndex < 0) return; //string name = dgvShop.Columns[e.ColumnIndex].HeaderText; string colId = dgvShop.Columns[e.ColumnIndex].Name; long shopId = dgvShop.Rows[e.RowIndex].Cells["colShopId"].Value.ParseToLong(); var shop = GlobalConfig.DouShopLoginList.FirstOrDefault(s => s.ShopAccountId == shopId.ToString()); if (colId == "colSelect") { bool canUse = shop?.ApiAuthStatus == "授权成功" && shop?.LoginStatus == "登录成功"; if (!canUse) { BaseMsgForm.ShowInfo("店铺未授权或未登录!"); return; } bool ok = !bool.Parse(dgvShop.Rows[e.RowIndex].Cells["colSelect"].Value.ToString()); //string shopName = dgvShop.Rows[e.RowIndex].Cells["colShopId"].Value.ToString(); dgvShop.Rows[e.RowIndex].Cells["colSelect"].Value = ok; //if (ok) //{ // UploadProductBLL.ids.Add(shopName); //} //else //{ // if (UploadProductBLL.ids.Select(id => id ==shopName).FirstOrDefault()) // { // UploadProductBLL.ids.Remove(shopName); // } //} } } #region 导入数据 private async void button3_Click(object sender, EventArgs e) { btnUpload.Enabled = false; OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.Title = "选择文件"; fileDialog.Filter = "All files (*.*)|*.*"; fileDialog.FilterIndex = 1; fileDialog.RestoreDirectory = true; if (fileDialog.ShowDialog() != DialogResult.OK) { btnUpload.Enabled = true; return; } await InputData(fileDialog.FileName); btnUpload.Enabled = true; } public async Task InputData(string file) { await Task.Run(() => { string[] arrTmp = FileBase.ReadAllLines(file, GetFileEncoding(file)); InputDataData(arrTmp); }); } public async Task InputDataData(string[] arr) { bool message = false; if (arr == null || arr.Length == 0) return; for (int i = 0; i < arr.Length; i++) { if (string.IsNullOrEmpty(arr[i])) continue; // 外部版暂时只支持拼多多上货 if (!BaseClass.IsCloudBuyOrder && !arr[i].Contains("yangkeduo.com") && !arr[i].Contains("pinduoduo.com")) continue; string strTmp = arr[i]; if (!(strTmp.Contains("detail.tmall") || strTmp.Contains("taobao.com") || strTmp.Contains("jinritemai.com") || strTmp.Contains("1688.com") || strTmp.Contains("weidian.com") || strTmp.Contains("jd.com"))) { try { if (!(strTmp.Contains("yangkeduo.com") || strTmp.Contains("pinduoduo.com"))) strTmp = Md5Base.EncryptDecode(strTmp); } catch { continue; } } if ((arr[i].Contains("淘宝") || arr[i].Contains("阿里巴巴")) && arr[i].Split(',').Length <= 7) strTmp = arr[i]; if (string.IsNullOrEmpty(strTmp)) continue; string lb = strTmp; string sp = "-----"; string url = strTmp, title = "", shop = "", catid = "", from = "", fid = ""; string viname = "", viId = "", viPrice = "", viMPrice = ""; if (strTmp.Contains("\",\"")) { var mm = BaseRegex.GetMatchRegex(strTmp, @"(.*?),""([\d]+)"",""([^""]+?)"",""([\d]+)"",""([\d]+)"",""([\d]+)"",""([\d]+)"",""([\d]+)"",""([-.\d]+%\+[-.\d]+)"",""([^""]+?)"""); if (mm != null && mm.Count > 0) { from = mm[0].Groups[1].Value.Replace("\"", "").Replace("\"", ""); fid = mm[0].Groups[2].Value; title = mm[0].Groups[3].Value; catid = mm[0].Groups[6].Value; viname = mm[0].Groups[7].Value; viId = mm[0].Groups[8].Value; viPrice = mm[0].Groups[9].Value; viMPrice = mm[0].Groups[10].Value; goto End; } var m = BaseRegex.GetMatchRegex(strTmp, @"""([^""]+?)"",""([\d]+?)"",""([^""]+?)"",""([\d]+?)"",""([\d]+?)"",""([\d]+?)"",""([^""]+?)"",""([\d]+?)"",""([^""]+?)"""); if (m.Count == 0) m = BaseRegex.GetMatchRegex(strTmp, @"""([^""]+?)"",""([\d]+?)"",""([^""]+?)"",""([\d]+?)"",""([\d]+?)"",""([\d]+?)"""); if (m != null && m.Count > 0) { from = m[0].Groups[1].Value; fid = m[0].Groups[2].Value; title = m[0].Groups[3].Value; catid = m[0].Groups[6].Value; viname = m[0].Groups[7].Value; viId = m[0].Groups[8].Value; viPrice = m[0].Groups[9].Value; goto End; } } if (strTmp.Contains(sp)) { url = strTmp.Substring(0, strTmp.IndexOf(sp)); strTmp = strTmp.Substring(strTmp.IndexOf(sp) + sp.Length); title = strTmp; } if (title.Contains(sp)) { title = strTmp.Substring(0, strTmp.IndexOf(sp)); strTmp = strTmp.Substring(strTmp.IndexOf(sp) + sp.Length); shop = strTmp; } if (shop.Contains(sp)) { shop = strTmp.Substring(0, strTmp.IndexOf(sp)); strTmp = strTmp.Substring(strTmp.IndexOf(sp) + sp.Length); catid = BaseRegex.GetMatchRegexString(strTmp, @"([\d]+)"); } fid = BaseRegex.GetMatchRegexString(url, @"/([\d]+)\.html"); if (string.IsNullOrEmpty(fid)) fid = BaseRegex.GetMatchRegexString(url, @"goods_id=([\d]+)"); if (string.IsNullOrEmpty(fid)) fid = BaseRegex.GetMatchRegexString(url, @"id=([\d]+)"); if (url.Contains(".taobao.com") || url.Contains(".tmall.com")) from = "淘宝"; if (url.Contains(".1688.com")) from = "阿里巴巴"; if (url.Contains("weidian.com")) from = "微店"; if (url.Contains("jd.com")) from = "京喜"; if (url.Contains("yangkeduo.com") || url.Contains("pinduoduo.com")) from = "拼多多"; if (url.Contains("jinritemai.com")) from = "抖音"; if (!lb.Contains("-----") && lb.Contains(@""",""")) { var m = BaseRegex.GetMatchRegex(ref lb, @"""(.*?)"",""([\d]+)"",""(.*?)"""); if (m == null || m.Count <= 0) continue; if (m.Count > 0) { from = m[0].Groups[1].Value; fid = m[0].Groups[2].Value; title = m[0].Groups[3].Value; catid = ""; } } End: if (!string.IsNullOrEmpty(viname) && viname != "6" && viname != "1") continue; if (string.IsNullOrEmpty(fid) || string.IsNullOrEmpty(from)) continue; if (!string.IsNullOrEmpty(viPrice) && string.IsNullOrEmpty(viMPrice)) { if (!message) { MessageBox.Show("老格式数据已经不支持\r\n请升级采集程序,重新转化数据后导入新格式,重新转化速度会很快", "提示:老格式已经不支持"); message = true; } continue; } if (BaseClass.UpIds.Count > 0) { bool ishas = false; for (int j = 0; j < BaseClass.UpIds.Count; j++) { string rid = BaseRegex.GetMatchRegexString(BaseClass.UpIds[j], @"([\d]+)"); if (string.IsNullOrEmpty(rid)) continue; if (fid == rid) { ishas = true; break; } } if (ishas) continue; } TaobaoProductBase t = new TaobaoProductBase(); long idx; if (!long.TryParse(fid, out idx)) continue; t.TolerantFormId = fid; t.FromId = idx; t.ViGoodsName = viname; long.TryParse(viId, out t.ViGoodsId); t.ViPrice = viPrice; t.FromType = from; if (!string.IsNullOrEmpty(viMPrice)) { t.ViPriceMaxMin = viMPrice; string[] strPrice = viMPrice.Split(':'); if (strPrice.Length == 3) { t.ViPriceMin = (int)(decimal.Parse(strPrice[0]) * 100); t.ViPriceMax = (int)(decimal.Parse(strPrice[1]) * 100); t.ViExpressPrice = (int)(decimal.Parse(strPrice[2])); } } t.Titlte = title.Replace("\",\"", ""); if (!UploadProductBLL.ProductStock.Exists(p => p != null && p.FromId == t.FromId && p.Titlte == t.Titlte)) { UploadProductBLL.ProductStock.Add(t); //if (t.MainCatId > 0) DataBaseTemp.Add(t); batchDataBaseTemp.Add(t); if (batchDataBaseTemp.Count == 50) { AddListToDataBaseSingle(batchDataBaseTemp); batchDataBaseTemp.Clear(); } } ReMain(); LogSave.Add(formName, strTmp + "正在被导入..."); } if (batchDataBaseTemp.Count > 0) { AddListToDataBaseSingle(batchDataBaseTemp); batchDataBaseTemp.Clear(); } UploadProductBLL.maxCount = UploadProductBLL.ProductStock.Count; LogSave.Add(formName, "已经成功导入!"); } public void AddListToDataBaseSingle(List temp) { for (int i = 0; i < temp.Count; i++) { AddbatchToDataBase(temp[i]); } SqliteHelper.BatchExecuteNonQuery(batchString); batchString.Clear(); } public static void AddbatchToDataBase(TaobaoProductBase p) { string content = p.FromId + "," + p.FromType + "," + p.Titlte + "," + p.Cat1 + "," + p.Cat2 + "," + p.Cat3 + "," + p.Cat4 + "," + p.CatId + "," + p.MainCatId + "," + p.MainCatName + "," + p.MainImage + "," + p.Price + "," + p.SaleCount + "," + p.ShopName + "," + p.AddPrice; if (!string.IsNullOrEmpty(p.ViGoodsName)) content += "," + p.ViGoodsId + "," + p.ViGoodsName + "," + p.ViPrice + "," + p.ViPriceMaxMin; content = JsonHelper.SerializeObject(p); string sql = "insert into Product(content,fromid) values('" + SqliteHelper.ReplaceSqlx(content) + "','" + p.guid + "')"; batchString.Add(sql); } public static List formIdlist = new List(); /// /// 加载缓存 /// public void LoadStock() { SqliteHelper.CreateProductTable(); formIdlist.Clear(); DataTable dt = SqliteHelper.ExecuteTable("select fromid,content from Product"); for (int i = 0; dt != null && i < dt.Rows.Count; i++) { try { string s = dt.Rows[i]["content"].ToString(); formIdlist.Add(dt.Rows[i]["fromid"].ToString()); TaobaoProductBase t = JsonHelper.DeserializeJsonToObject(s); if (t != null && t.FromId != 0) { UploadProductBLL.ProductStock.Add(t); ReMain(); } } catch { } try { string s = dt.Rows[i]["content"].ToString(); formIdlist.Add(dt.Rows[i]["fromid"].ToString()); if (string.IsNullOrEmpty(s) || !s.Contains(",")) continue; string[] ll = s.Split(','); if (ll.Length != 13 && ll.Length != 15 && ll.Length != 19) continue; TaobaoProductBase t = new TaobaoProductBase(); if (string.IsNullOrEmpty(ll[0])) continue; t.FromId = long.Parse(ll[0]); t.FromType = ll[1]; t.Titlte = ll[2].Replace("\",\"", ""); t.Cat1 = int.Parse(ll[3]); t.Cat2 = int.Parse(ll[4]); t.Cat3 = int.Parse(ll[5]); t.Cat4 = int.Parse(ll[6]); t.CatId = int.Parse(ll[7]); t.MainCatId = int.Parse(ll[8]); t.MainCatName = ll[9]; t.MainImage = int.Parse(ll[10]); t.Price = decimal.Parse(ll[11]); t.SaleCount = int.Parse(ll[12]); t.guid = dt.Rows[i]["fromid"].ToString(); if (ll.Length == 15 || ll.Length == 19) { t.ShopName = ll[13]; t.AddPrice = int.Parse(ll[14]); } if (ll.Length > 15) { long.TryParse(ll[15], out t.ViGoodsId); t.ViGoodsName = ll[16]; t.ViPrice = ll[17]; t.ViPriceMaxMin = ll[18]; string[] strPrice = t.ViPriceMaxMin.Split(':'); if (strPrice.Length == 3) { t.ViPriceMin = (int)(decimal.Parse(strPrice[0]) * 100); t.ViPriceMax = (int)(decimal.Parse(strPrice[1]) * 100); t.ViExpressPrice = (int)(decimal.Parse(strPrice[2])); } } //if (t.ViGoodsName != "6") // 临时开放转换淘宝 //if (t.ViGoodsName != "6" && !((t.FromType == "淘宝" || t.FromType == "阿里巴巴") && string.IsNullOrEmpty(t.ViGoodsName))) if (t.ViGoodsName != "6" && t.ViGoodsName != "1" && !((t.FromType == "淘宝" || t.FromType == "阿里巴巴" || t.FromType == "微店" || t.FromType == "京喜" || t.FromType == "抖音") && string.IsNullOrEmpty(t.ViGoodsName))) continue; UploadProductBLL.ProductStock.Add(t); ReMain(); //ProductTempStock.Add(t); } catch { } } } public static List batchString = new List(); public List DataBaseTemp = new List(); public List batchDataBaseTemp = new List(); public static System.Text.Encoding GetFileEncoding(string filename) { using (var fs = new System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read)) using (var br = new System.IO.BinaryReader(fs)) { var buffer = br.ReadBytes(2); if (buffer[0] >= 0xEF) { if (buffer[0] == 0xEF && buffer[1] == 0xBB) { return System.Text.Encoding.UTF8; } if (buffer[0] == 0xFE && buffer[1] == 0xFF) { return System.Text.Encoding.BigEndianUnicode; } if (buffer[0] == 0xFF && buffer[1] == 0xFE) { return System.Text.Encoding.Unicode; } } return GetEncodingWithBomUtf8(fs, System.Text.Encoding.Default); } } private static System.Text.Encoding GetEncodingWithBomUtf8(Stream fs, Encoding defaultEncoding) { byte[] unicode = new byte[] { 0xFF, 0xFE, 0x41 }; byte[] unicodeBig = new byte[] { 0xFE, 0xFF, 0x00 }; //带BOM byte[] utf8 = new byte[] { 0xEF, 0xBB, 0xBF }; var reVal = defaultEncoding; using (var r = new System.IO.BinaryReader(fs)) { byte[] ss = r.ReadBytes(4); if (ss[0] == 0xFE && ss[1] == 0xFF && ss[2] == 0x00) { reVal = Encoding.BigEndianUnicode; } else if (ss[0] == 0xFF && ss[1] == 0xFE && ss[2] == 0x41) { reVal = Encoding.Unicode; } else { if (ss[0] == 0xEF && ss[1] == 0xBB && ss[2] == 0xBF) { reVal = Encoding.UTF8; } else { int i; int.TryParse(fs.Length.ToString(), out i); ss = r.ReadBytes(i); if (IsUtf8Bytes(ss)) { reVal = Encoding.UTF8; } } } return reVal; } } private static bool IsUtf8Bytes(byte[] data) { int charByteCounter = 1;  //计算当前正分析的字符应还有的字节数 for (int i = 0; i < data.Length; i++) { var curByte = data[i]; //当前分析的字节. if (charByteCounter == 1) { if (curByte >= 0x80) { //判断当前 while (((curByte <<= 1) & 0x80) != 0) { charByteCounter++; } //标记位首位若为非0 则至少以2个1开始 如:110XXXXX...........1111110X  if (charByteCounter == 1 || charByteCounter > 6) { return false; } } } else { //若是UTF-8 此时第一位必须为1 if ((curByte & 0xC0) != 0x80) { return false; } charByteCounter--; } } if (charByteCounter > 1) { throw new Exception("非预期的byte格式!"); } return true; } #endregion public bool isNewPage = true; int oldCurrentPage = 0; int newCurrentPage = 1; int totalPage = 1; int pageSize = 100; private void btnPrev_Click(object sender, EventArgs e) { if (newCurrentPage == 1) return; newCurrentPage--; RefreshGridView(null); } private void btnNext_Click(object sender, EventArgs e) { if (totalPage == newCurrentPage) return; newCurrentPage++; RefreshGridView(null); } private void btnGo_Click(object sender, EventArgs e) { int.TryParse(txtGoPage.Text, out newCurrentPage); RefreshGridView(null); } private void lblPage1_Click(object sender, EventArgs e) { newCurrentPage = 1; RefreshGridView(null); } private void lblTotalPage_Click(object sender, EventArgs e) { newCurrentPage = totalPage; RefreshGridView(null); } private void button3_Click_1(object sender, EventArgs e) { UploadProductBLL.ProductTemp.Clear(); TaobaoProductBase t = new TaobaoProductBase(); t.FromId = 111; UploadProductBLL.ProductTemp.Add(t); RefreshGridView(t); TaobaoProductBase t2 = new TaobaoProductBase(); t2.FromId = 222; UploadProductBLL.ProductTemp.Add(t2); RefreshGridView(t); TaobaoProductBase t3 = new TaobaoProductBase(); t3.FromId = 333; UploadProductBLL.ProductTemp.Add(t3); RefreshGridView(t); TaobaoProductBase t4 = new TaobaoProductBase(); t4.FromId = 444; UploadProductBLL.ProductTemp.Add(t4); RefreshGridView(t); TaobaoProductBase t5 = new TaobaoProductBase(); t5.FromId = 555; UploadProductBLL.ProductTemp.Add(t5); RefreshGridView(t); TaobaoProductBase t6 = new TaobaoProductBase(); t6.FromId = 666; UploadProductBLL.ProductTemp.Add(t6); RefreshGridView(t); } private void AutoRefcheckBox_CheckedChanged(object sender, EventArgs e) { if (AutoRefcheckBox.Checked && !isNewPage) isNewPage = true; if (!AutoRefcheckBox.Checked) isNewPage = false; if (AutoRefcheckBox.Checked && dgvProduct.Rows.Count > 0) { if (dgvProduct.CurrentCell.RowIndex >= dgvProduct.Rows.Count - 1)//若当前值不小于行号,则不执行后面代码 { return; } dgvProduct.CurrentCell = dgvProduct.Rows[dgvProduct.Rows.Count - 1].Cells[0]; } } private void button4_Click(object sender, EventArgs e) { if (BaseMsgForm.ShowConfirm("是否清除全部列表数据", "提示").DialogResult == DialogResult.OK) { dgvProduct.Rows.Clear(); UploadProductBLL.ProductTemp.Clear(); } if (BaseMsgForm.ShowConfirm("是否清除全部备用上货数据", "提示").DialogResult == DialogResult.OK) { UploadProductBLL.ProductStock.Clear(); UploadProductBLL.Delete(""); ReMain(); } } private void beforPricetextBox_TextChanged(object sender, EventArgs e) { if (!string.IsNullOrEmpty(beforPricetextBox.Text)) UploadProductBLL.beforPrice = decimal.Parse(beforPricetextBox.Text); } private void chkStockLessThan_CheckedChanged(object sender, EventArgs e) { UploadProductBLL.isStockLessThan = chkStockLessThan.Checked; } private void txtStockLessThanCount_TextChanged(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtStockLessThanCount.Text)) UploadProductBLL.StockLessThanCount = decimal.Parse(txtStockLessThanCount.Text); } private void littleSkuCheckBox_CheckedChanged(object sender, EventArgs e) { UploadProductBLL.isLitterSku = littleSkuCheckBox.Checked; } private void txtSingleUpload_TextChanged(object sender, EventArgs e) { UploadProductBLL.MaxSingleShopUploadCount = int.Parse(txtSingleUpload.Text); } private void button6_Click(object sender, EventArgs e) { GetBrandList(); } /// /// 获取商品详情 /// public long GetBrandList() { var shop = GlobalConfig.DouShopLoginList.FirstOrDefault(s => s.ShopAccount == "开箱小店"); DouyinApi api = new DouyinApi(shop); api.JsonData = new Dictionary(); api.JsonData.Add("product_id", "3522394014194236398"); api.JsonData.Add("show_draft", "false"); string html = api.GetProductDetail(); GoodDetail good = null; try { good = JsonConvert.DeserializeObject(html); } catch (Exception ex) { } int a = 0; var p = good.data; Dictionary dictionary = new Dictionary(); dictionary.Add("product_id", p.product_id.ToString()); dictionary.Add("product_type", "0"); int catid = 0; var cat = p.category_detail; if (cat.second_cid > 0) catid = cat.second_cid; if (cat.third_cid > 0) catid = cat.third_cid; if (cat.fourth_cid > 0) catid = cat.fourth_cid; dictionary.Add("category_leaf_id", catid.ToString()); dictionary.Add("first_cid", p.first_cid.ToString()); dictionary.Add("second_cid", p.second_cid.ToString()); dictionary.Add("third_cid", p.third_cid.ToString()); string prop = p.product_format; string propStr = ""; //货号 | 8888 ^ 上市年份季节 | 2018年秋季 var m = BaseRegex.GetMatchRegex(ref prop, @"""[\w\W]+?"":""[\w\W]+?"""); for (int i = 0; m != null && i < m.Count; i++) { string item = m[i].Groups[0].Value.Replace(":", "|"); propStr += item + "^"; } propStr = propStr.Replace("\"", ""); dictionary.Add("product_format", propStr); dictionary.Add("name", p.name); dictionary.Add("recommend_remark", p.recommend_remark); var picStr = p.pic; var pic = ""; for (int i = 0; i < picStr.Count; i++) { if (pic.Trim() != "") { pic += "|"; } pic += picStr[i]; } dictionary.Add("pic", pic); var description = p.description; string contentImage = ""; m = BaseRegex.GetMatchRegex(ref description, @"]*?src=[""'](.*?)[""']"); if (m.Count == 0) m = BaseRegex.GetMatchRegex(ref description, @"]*?>(.*?)"); if (m.Count == 0) m = BaseRegex.GetMatchRegex(ref description, @"]+?>(.*?)"); for (int j = 0; j < m.Count; j++) { string urlImg = m[j].Groups[1].Value.Replace(".src", ""); if (contentImage.Trim() != "") { contentImage += "|"; } if (!string.IsNullOrEmpty(urlImg)) { urlImg = m[j].Groups[1].Value.Replace(".src", ""); } contentImage += urlImg; } //商品描述,目前只支持图片。多张图片用 "|" 分开 dictionary.Add("description", contentImage); dictionary.Add("pay_type", p.pay_type.ToString()); dictionary.Add("market_price", p.market_price.ToString()); dictionary.Add("discount_price", p.discount_price.ToString()); //dictionary.Add("reduce_type", p.reduce_type.ToString()); //dictionary.Add("assoc_ids", p.assoc_ids.ToString()); //dictionary.Add("freight_id", p.freight_id.ToString()); //dictionary.Add("weight", p.weight.ToString()); //dictionary.Add("weight_unit", p.weight_unit.ToString()); dictionary.Add("delivery_delay_day", "2"); dictionary.Add("presell_type", p.presell_type.ToString()); //dictionary.Add("presell_delay", p.presell_delay.ToString()); //dictionary.Add("presell_end_time", p.presell_end_time.ToString()); //dictionary.Add("supply_7day_return", p.supply_7day_return.ToString()); dictionary.Add("mobile", p.mobile.ToString()); dictionary.Add("commit", "true"); //dictionary.Add("brand_id", p.brand_id.ToString()); //dictionary.Add("remark", p.remark.ToString()); //dictionary.Add("quality_report", p.quality_report.ToString()); //dictionary.Add("class_quality", p.class_quality.ToString()); //dictionary.Add("class_quality", p.class_quality.ToString()); //dictionary.Add("quality_list", p.quality_list.ToString()); dictionary.Add("out_product_id", p.out_product_id.ToString()); //dictionary.Add("spec_name", p.class_quality.ToString()); var specs = p.specs; string specsStr = ""; for (int i = 0; i < specs.Count; i++) { var item = specs[i]; string specitem = item.name + "|"; for (int j = 0; j < item.values.Count; j++) { specitem += item.values[j].name + ","; } specsStr += specitem.Substring(0, specitem.Length - 1); if (!string.IsNullOrEmpty(specsStr)) { specsStr += "^"; } } dictionary.Add("specs", specsStr); var specPic = p.spec_pics; string specPicStr = ""; for (int i = 0; i < specPic.Count; i++) { if (specPicStr.Trim() != "") { specPicStr += ","; } specPicStr += specPic[i].pic; } dictionary.Add("spec_pic", specsStr); var dic = GetSpecDic(p.specs); var specsx = p.spec_prices; string specStr = ""; StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < specsx.Count; i++) { var specItem = specsx[i]; IDictionary dictionary2 = new Dictionary(); var id1 = specItem.spec_detail_id1; var id2 = specItem.spec_detail_id2; var id3 = specItem.spec_detail_id3; string name1 = ""; if (id1 > 0 && dic.ContainsKey(id1)) name1 = dic[id1]; string name2 = ""; if (id2 > 0 && dic.ContainsKey(id2)) name2 = dic[id2]; string name3 = ""; if (id3 > 0 && dic.ContainsKey(id3)) name3 = dic[id3]; dictionary2.Add("spec_detail_name1", name1); dictionary2.Add("spec_detail_name2", name2); dictionary2.Add("spec_detail_name3", name3); dictionary2.Add("stock_num", specItem.stock_num.ToString()); dictionary2.Add("price", specItem.price.ToString()); dictionary2.Add("code", specItem.code); dictionary2.Add("step_stock_num", "0"); foreach (string current in dictionary2.Keys) { if (current.ToString().Trim() == "stock_num" || current.ToString().Trim() == "price" || current.ToString().Trim() == "step_stock_num") { stringBuilder.AppendFormat((stringBuilder.Length > 0) ? ",\\\"{0}\\\":{1}" : "\\\"{0}\\\":{1}", current, dictionary2[current].ToString().Replace(" ", "")); } else { stringBuilder.AppendFormat((stringBuilder.Length > 0) ? ",\\\"{0}\\\":\\\"{1}\\\"" : "\\\"{0}\\\":\\\"{1}\\\"", current, dictionary2[current].ToString().Replace(" ", "")); } } string str = "{" + stringBuilder.ToString() + "}"; if (specStr.Trim() != "") { specStr += ","; } specStr += str; } specStr = "[" + specStr + "]"; //sku详情 dictionary.Add("spec_prices", specStr); dictionary.Add("maximum_per_order", p.maximum_per_order.ToString()); dictionary.Add("limit_per_buyer", p.limit_per_buyer.ToString()); dictionary.Add("minimum_per_order", p.minimum_per_order.ToString()); DouyinApi apix = new DouyinApi(shop); apix.JsonData = dictionary; html = apix.GetProductEdit(); long product_id = BaseRegex.GetLongJson(ref html, "product_id"); //DouyinApi api = new DouyinApi(shop); return 0; } public Dictionary GetSpecDic(List specs) { Dictionary specDic = new Dictionary(); for (int j = 0; j < specs.Count; j++) { var item = specs[j]; for (int k = 0; k < item.values.Count; k++) { var s = item.values[k]; specDic.Add(s.id, s.name); } } return specDic; } //修改库存 private void button7_Click(object sender, EventArgs e) { var shop = GlobalConfig.DouShopLoginList[0]; DouyinApi api = new DouyinApi(shop); api.JsonData = new Dictionary(); api.JsonData.Add("product_id", "3492731930347180135"); api.JsonData.Add("show_draft", "false"); string html = api.GetProductDetail(); GoodDetail good = null; try { good = JsonConvert.DeserializeObject(html); } catch (Exception ex) { } var p = good.data; Dictionary dictionary = new Dictionary(); var specsx = p.spec_prices; string skuid = ""; for (int i = 0; i < specsx.Count; i++) { var specItem = specsx[i]; skuid = specItem.sku_id.ToString(); } dictionary.Add("sku_id", skuid.ToString()); dictionary.Add("stock_num", "100"); DouyinApi apix = new DouyinApi(shop); apix.JsonData = dictionary; html = apix.GetEditStock(); } //修改价格 private void button8_Click(object sender, EventArgs e) { var shop = GlobalConfig.DouShopLoginList[0]; DouyinApi api = new DouyinApi(shop); api.JsonData = new Dictionary(); api.JsonData.Add("product_id", "3492731930347180135"); api.JsonData.Add("show_draft", "false"); string html = api.GetProductDetail(); GoodDetail good = null; try { good = JsonConvert.DeserializeObject(html); } catch (Exception ex) { } var p = good.data; Dictionary dictionary = new Dictionary(); var specsx = p.spec_prices; string skuid = ""; for (int i = 0; i < specsx.Count; i++) { var specItem = specsx[i]; skuid = specItem.sku_id.ToString(); } dictionary.Add("sku_id", skuid.ToString()); dictionary.Add("price", "30000"); DouyinApi apix = new DouyinApi(shop); apix.JsonData = dictionary; html = apix.GetEditPrice(); } private void waitButton_Click(object sender, EventArgs e) { if (waitButton.Text == "暂停") { waitButton.Text = "继续"; UploadProductBLL.isWaiting = true; } else { waitButton.Text = "暂停"; UploadProductBLL.isWaiting = false; } } private void buttonEx2_Click(object sender, EventArgs e) { //ChatForm frm = new ChatForm(); //frm.Show(); } public List levellst = new List(); public List levellst1 = new List(); public List levellst2 = new List(); public List levellst3 = new List(); public List levellst4 = new List(); public void GetCat() { levellst.Clear(); string url = "https://fxg.jinritemai.com/product/tproduct/categoryOptionsN?cid=0&appid=1&__token=57ae746dad0cd8c610061da3542bdca8&_lid=185395514703&_signature=_02B4Z6wo00901BWAKpgAAIDDpXHGUFOei0gVhC4AAGVdRDUVkGu0m2x2ZmO7k20IVvpSoGVVeqaYlfIyO5UnExFgL-vcYloVLZPcQAdaoEzdEN.gW97C2FBkXmV4VaxIK566gX6w5Dmb-H1A1d"; string refere = "https://fxg.jinritemai.com/ffa/g/create"; string data = ""; string cookies = "ttcid=e377739c28ce4d18874fa6254b5aae0725; ttwid=1%7CQ2FXDv1XIHPVZa_hjjk6pZMPJKpmh59Y9QK9SmHGygE%7C1609827277%7Ccc7fa8c19ff0f500121b04ca16db39ede90af210620896d14c5ef778f70417ec; passport_csrf_token=e8c9361338d419e123eb9ca6f3cf47d5; passport_csrf_token_default=e8c9361338d419e123eb9ca6f3cf47d5; d_ticket=fd4f4a000273570e1b0a578f3c4b63e9c94fb; source=seo.baidu.001; Hm_lvt_b6520b076191ab4b36812da4c90f7a5e=1614154781; s_v_web_id=verify_klj62wum_mq6ot7Pj_Vd9w_4sZh_85CG_HCdNJeZbV830; SLARDAR_WEB_ID=unLoggedUser; PHPSESSID=bc522a983651ee361db01bef9a77f850; PHPSESSID_SS=bc522a983651ee361db01bef9a77f850; gfpart_1.0.0.3872_38475=0; MONITOR_WEB_ID=4e9f2d73-635d-4692-a761-1429b1436273; gftoken=MWNmNWVjNDllN3wxNjE0MTU0OTE1Mzl8fDAGBgYGBgY; gfpart_1.0.0.82_38574=0; Hm_lpvt_b6520b076191ab4b36812da4c90f7a5e=1614155399; tt_scid=kuImDaeMQkJDlV7RNBzK-cV.aUezLmPA8bf8-e4wjzbBldoQ3mxldypTfyI-r3KK6d9c; odin_tt=9848cda8c40345c38f0e4126ebee82067582ed5810871563287be65b4b5ada777abe060cbea27f6d6bac7de933729a8465d14ae31f9e01d0471d4a4e7918c9ca; n_mh=7-_t6pVZ0Rq_6lA_MFK-D1JitiJQbXT5uC_H35vCdp0; passport_auth_status=5e7c0775b54c286c732d68d07d44907c%2C; passport_auth_status_ss=5e7c0775b54c286c732d68d07d44907c%2C; sid_guard=f5734358799652f2f6d5ad4cf1a06620%7C1614156254%7C5184000%7CSun%2C+25-Apr-2021+08%3A44%3A14+GMT; uid_tt=63b8bfad66b71960e189a182fe122306; uid_tt_ss=63b8bfad66b71960e189a182fe122306; sid_tt=f5734358799652f2f6d5ad4cf1a06620; sessionid=f5734358799652f2f6d5ad4cf1a06620; sessionid_ss=f5734358799652f2f6d5ad4cf1a06620"; string html = GetPostTaobaoHtml.UploadTaobao(url, refere, true, cookies); CategoryResult categoryResult = Newtonsoft.Json.JsonConvert.DeserializeObject(html); for (int i = 0; i < categoryResult.data.Count; i++) { var fxgCatBase = categoryResult.data[i]; FxgCatLevel level = new FxgCatLevel(); level.id = fxgCatBase.id; level.name = fxgCatBase.name; level.cat1id = fxgCatBase.id; level.cat1name = fxgCatBase.name; level.level = fxgCatBase.level; level.is_leaf = fxgCatBase.is_leaf; levellst1.Add(level); levellst.Add(level); } for (int i = 0; i < levellst1.Count; i++) { int cid = levellst1[i].id; url = "https://fxg.jinritemai.com/product/tproduct/categoryOptionsN?cid=" + cid + "&appid=1&__token=57ae746dad0cd8c610061da3542bdca8&_lid=185395514703&_signature=_02B4Z6wo00901BWAKpgAAIDDpXHGUFOei0gVhC4AAGVdRDUVkGu0m2x2ZmO7k20IVvpSoGVVeqaYlfIyO5UnExFgL-vcYloVLZPcQAdaoEzdEN.gW97C2FBkXmV4VaxIK566gX6w5Dmb-H1A1d"; html = GetPostTaobaoHtml.UploadTaobao(url, refere, true, cookies); CategoryResult categoryResult2 = Newtonsoft.Json.JsonConvert.DeserializeObject(html); for (int j = 0; j < categoryResult2.data.Count; j++) { var fxgCatBase = categoryResult2.data[j]; FxgCatLevel level = new FxgCatLevel(); level.id = fxgCatBase.id; level.name = fxgCatBase.name; level.cat1id = levellst1[i].id; level.cat1name = levellst1[i].name; level.cat2id = fxgCatBase.id; level.cat2name = fxgCatBase.name; level.level = fxgCatBase.level; level.is_leaf = fxgCatBase.is_leaf; levellst2.Add(level); levellst.Add(level); } Thread.Sleep(2000); } for (int i = 0; i < levellst2.Count; i++) { int cid = levellst2[i].id; url = "https://fxg.jinritemai.com/product/tproduct/categoryOptionsN?cid=" + cid + "&appid=1&__token=57ae746dad0cd8c610061da3542bdca8&_lid=185395514703&_signature=_02B4Z6wo00901BWAKpgAAIDDpXHGUFOei0gVhC4AAGVdRDUVkGu0m2x2ZmO7k20IVvpSoGVVeqaYlfIyO5UnExFgL-vcYloVLZPcQAdaoEzdEN.gW97C2FBkXmV4VaxIK566gX6w5Dmb-H1A1d"; html = GetPostTaobaoHtml.UploadTaobao(url, refere, true, cookies); CategoryResult categoryResult3 = Newtonsoft.Json.JsonConvert.DeserializeObject(html); for (int j = 0; j < categoryResult3.data.Count; j++) { var fxgCatBase = categoryResult3.data[j]; FxgCatLevel level = new FxgCatLevel(); level.id = fxgCatBase.id; level.name = fxgCatBase.name; level.cat1id = levellst2[i].cat1id; level.cat1name = levellst2[i].cat1name; level.cat2id = levellst2[i].cat2id; level.cat2name = levellst2[i].cat2name; level.cat3id = fxgCatBase.id; level.cat3name = fxgCatBase.name; level.level = fxgCatBase.level; level.is_leaf = fxgCatBase.is_leaf; levellst3.Add(level); levellst.Add(level); } Thread.Sleep(2000); } for (int i = 0; i < levellst3.Count; i++) { int cid = levellst3[i].id; url = "https://fxg.jinritemai.com/product/tproduct/categoryOptionsN?cid=" + cid + "&appid=1&__token=57ae746dad0cd8c610061da3542bdca8&_lid=185395514703&_signature=_02B4Z6wo00901BWAKpgAAIDDpXHGUFOei0gVhC4AAGVdRDUVkGu0m2x2ZmO7k20IVvpSoGVVeqaYlfIyO5UnExFgL-vcYloVLZPcQAdaoEzdEN.gW97C2FBkXmV4VaxIK566gX6w5Dmb-H1A1d"; html = GetPostTaobaoHtml.UploadTaobao(url, refere, true, cookies); if (html.Contains("\"total\":0")) continue; CategoryResult categoryResult4 = Newtonsoft.Json.JsonConvert.DeserializeObject(html); for (int j = 0; j < categoryResult4.data.Count; j++) { var fxgCatBase = categoryResult4.data[j]; FxgCatLevel level = new FxgCatLevel(); level.id = fxgCatBase.id; level.name = fxgCatBase.name; level.cat1id = levellst3[i].cat1id; level.cat1name = levellst3[i].cat1name; level.cat2id = levellst3[i].cat2id; level.cat2name = levellst3[i].cat2name; level.cat3id = levellst3[i].cat3id; level.cat3name = levellst3[i].cat3name; level.cat4id = fxgCatBase.id; level.cat4name = fxgCatBase.name; level.level = fxgCatBase.level; level.is_leaf = fxgCatBase.is_leaf; levellst3.Add(level); levellst.Add(level); } Thread.Sleep(2000); } var jsonBody = Newtonsoft.Json.JsonConvert.SerializeObject(levellst); //var jlst = Newtonsoft.Json.JsonConvert.DeserializeObject>(jsonBody); FileBase.WriteAllText("temp/cat.txt", jsonBody); } private void txtPhone_TextChanged(object sender, EventArgs e) { } private void btnGetUpId_Click(object sender, EventArgs e) { long product_id = 0; long.TryParse(txtUpProduct.Text, out product_id); if (product_id > 0) { string urlx = BaseClass.LoginApiUrl + "?obj=upshopid/upid_dd&act=get"; string datax = "&pid=" + product_id + "&table=" + (product_id % 1024); string htmlx = GetHtml.PostUtf8(urlx, UserLogin.GetSignaturex("", "") + datax); string id = BaseRegex.GetMatchRegexString(htmlx, @"([\d]+)"); string url = ""; if (htmlx.Contains("tb")) url = "https://item.taobao.com/item.htm?id=" + id; if (htmlx.Contains("pdd")) url = "https://mobile.yangkeduo.com/goods.html?goods_id=" + id; if (htmlx.Contains("al")) url = "https://detail.1688.com/offer/" + id + ".html"; if (htmlx.Contains("dy")) url = "https://weidian.com/item.html?itemID=" + id; GetHtml.OpenUrl(url); } } private void shopthreadCountTextBox_SelectedIndexChanged(object sender, EventArgs e) { UploadProductBLL.ShopThreadCount = int.Parse(shopthreadCountTextBox.Text); } private void btnSetTitleRemove_Click(object sender, EventArgs e) { FilterForm frm = new FilterForm("标题去除词"); frm.Show(); } private void btnSetTitleFilter_Click(object sender, EventArgs e) { FilterForm frm = new FilterForm(); frm.Show(); } private void btnSetSkuFilter_Click(object sender, EventArgs e) { FilterForm frm = new FilterForm("属性违规词"); frm.Show(); } private void btnSetBrandFilter_Click(object sender, EventArgs e) { FilterForm frm = new FilterForm("品牌违规词"); frm.Show(); } private void prefixTextBox_TextChanged(object sender, EventArgs e) { if (!string.IsNullOrEmpty(prefixTextBox.Text)) UploadProductBLL.PreFixTitle = prefixTextBox.Text.Trim(); else UploadProductBLL.PreFixTitle = ""; } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { UploadProductBLL.fixName = comboBox1.SelectedItem.ToString(); } private void proxyCheckBox_CheckedChanged(object sender, EventArgs e) { if (proxyCheckBox.Checked) { ProxyForm frm = new ProxyForm(); frm.Show(); UploadProductBLL.IsUseProxyCollectUp = true; } else { UploadProductBLL.IsUseProxyCollectUp = false; } } private void buttonEx4_Click(object sender, EventArgs e) { if (ieForm != null && IeForm.IsShowIeForm) { //ieForm.cefWebBrowser3.Load("https://www.taobao.com/"); ieForm.StartPosition = FormStartPosition.CenterScreen; ieForm.Show(); ieForm.Activate(); } } private void chkOnlyPostFree_CheckedChanged(object sender, EventArgs e) { UploadProductBLL.JustFree = chkOnlyPostFree.Checked; } private void chklogistime_CheckedChanged(object sender, EventArgs e) { UploadProductBLL.isLogistics = chklogistime.Checked; } private void cboHour_SelectedIndexChanged(object sender, EventArgs e) { UploadProductBLL.isLogistHour = Convert.ToInt32(cboHour.Text); } public UploadParam uploadParam = new UploadParam(); public class UploadParam { public string phone { get; set; } public string addMultiple { get; set; } = "1.2"; public string addMultiple2 { get; set; } = "1.3"; public string plusOrMinus { get; set; } = "+"; public string addPrice { get; set; } = "10"; public string plusOrMinus2 { get; set; } = "+"; public string addPrice2 { get; set; } = "10"; public bool isSetCommission { get; set; } = false; public int commissionRatio { get; set; } = 10; public bool isRoundPrice { get; set; } = false; public string productBrand { get; set; } public bool isAutoSaveUploadFailedProduct { get; set; } = false; } public void SaveUploadParam() { uploadParam.phone = txtPhone.Text; uploadParam.addMultiple = txtMultiple.Text; uploadParam.addMultiple2 = txtMultiple2.Text; uploadParam.plusOrMinus = cmbPlusOrMinus.Text; uploadParam.addPrice = txtPostage.Text; uploadParam.plusOrMinus2 = cmbPlusOrMinus2.Text; uploadParam.addPrice2 = txtPostage2.Text; uploadParam.commissionRatio = txtRatio.Text.ParseToInt(); uploadParam.isSetCommission = chkIsSetCommission.Checked; uploadParam.isRoundPrice = chkRoundPrice.Checked; uploadParam.productBrand = txtProductBrand.Text.Trim(); uploadParam.isAutoSaveUploadFailedProduct = chkSaveUploadFailed.Checked; try { NaiBa.Util.Helper.ConfigHelper.SaveConfig("upload_param", uploadParam); } catch { } } public void GetUploadParam() { try { uploadParam = NaiBa.Util.Helper.ConfigHelper.LoadConfig("upload_param"); if (uploadParam == null) uploadParam = new UploadParam(); txtMultiple.Text = uploadParam.addMultiple; txtMultiple2.Text = uploadParam.addMultiple2; cmbPlusOrMinus.SelectedItem = uploadParam.plusOrMinus; txtPostage.Text = uploadParam.addPrice; cmbPlusOrMinus2.SelectedItem = uploadParam.plusOrMinus2; txtPostage2.Text = uploadParam.addPrice2; txtPhone.Text = uploadParam.phone; txtRatio.Text = uploadParam.commissionRatio.ToString(); chkIsSetCommission.Checked = uploadParam.isSetCommission; chkRoundPrice.Checked = uploadParam.isRoundPrice; txtProductBrand.Text = uploadParam.productBrand; chkSaveUploadFailed.Checked = uploadParam.isAutoSaveUploadFailedProduct; } catch { } } private void dgvProduct_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0 || e.ColumnIndex < 0) return; var goodsId = dgvProduct.Rows[e.RowIndex].Cells["productIdColumn"].Value.ToString(); var upId = dgvProduct.Rows[e.RowIndex].Cells["idColumn"].Value.ToString(); var from = dgvProduct.Rows[e.RowIndex].Cells["fromColumn"].Value.ToString(); var columnName = dgvProduct.Columns[e.ColumnIndex].Name; if (columnName == "productIdColumn") { string url = "https://haohuo.jinritemai.com/views/product/item2?id=" + goodsId; GetHtml.OpenUrl(url); } else if (columnName == "idColumn") { var url = ""; if (from == "淘宝") url = "https://item.taobao.com/item.htm?id=" + upId; else if (from == "阿里巴巴") url = "https://detail.1688.com/offer/" + upId + ".html"; else if (from == "微店") url = "https://weidian.com/item.html?itemID=" + upId; else if (from == "京喜") url = "https://item.m.jd.com/product/" + upId + ".html"; else if (from == "拼多多") url = "http://mobile.yangkeduo.com/goods.html?goods_id=" + upId; else if (from == "抖音" || from == "") url = "https://haohuo.jinritemai.com/views/product/detail?id=" + upId; GetHtml.OpenUrl(url); } else if (columnName == "messageColumn") { if (dgvProduct.Rows[e.RowIndex].Cells["messageColumn"].Value.ToString() == "请去店铺后台创建产品尺码表!") { var url = "https://fxg.jinritemai.com/ffa/g/size-chart/manage"; var shopName = dgvProduct.Rows[e.RowIndex].Cells["shopNameColumn"].Value.ToString(); var shop = GlobalConfig.DouShopLoginList.FirstOrDefault(s => s.ShopAccount == shopName); if (shop != null) { var cookieStrArr = shop.Cookies.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); var cookieList = new List(); foreach (var cookieStr in cookieStrArr) { cookieList.Add(new CefSharp.Cookie { Domain = ".jinritemai.com", Name = cookieStr.Split('=').FirstOrDefault(), Value = cookieStr.Split('=').LastOrDefault(), Expires = DateTime.Now.AddMonths(1), Path = "/" }); } CefForm cf = new CefForm(url, cookieList); cf.ShowDialog(); } } } } private void lowPricePercenttextBox_TextChanged(object sender, EventArgs e) { if (!string.IsNullOrEmpty(lowPricePercenttextBox.Text)) UploadProductBLL.LowPricePercent = decimal.Parse(lowPricePercenttextBox.Text); } private void lowPriceAddtextBox_TextChanged(object sender, EventArgs e) { if (!string.IsNullOrEmpty(lowPriceAddtextBox.Text) && lowPriceAddtextBox.Text != "-") UploadProductBLL.LowPriceAdd = decimal.Parse(lowPriceAddtextBox.Text); if (comboBox5.SelectedItem.ToString() != "+") UploadProductBLL.LowPriceAdd = -UploadProductBLL.LowPriceAdd; } private void lowPricecheckBox_CheckedChanged(object sender, EventArgs e) { UploadProductBLL.LowPriceSku = lowPricecheckBox.Checked; } private void endDateTimePicker_ValueChanged(object sender, EventArgs e) { } private void comboBox3_SelectedIndexChanged(object sender, EventArgs e) { sendTime.Visible = false; cmbSendDayAfterPre.Visible = false; label12.Visible = false; label8.Visible = false; endDateTimePicker.Visible = false; cmbNewPreTime.Visible = lblNewPreTime.Visible = false; if (cmbSendType.SelectedItem.ToString() == "预售发货") { sendTime.Visible = true; cmbSendDayAfterPre.Visible = true; label12.Visible = true; label8.Visible = true; endDateTimePicker.Visible = true; } else if (cmbSendType.SelectedItem.ToString() == "新预售" || cmbSendType.SelectedItem.ToString() == "现货-预售") { cmbNewPreTime.Visible = lblNewPreTime.Visible = true; } } private void chkIsSetCommission_CheckedChanged(object sender, EventArgs e) { UploadProductBLL.IsSetCommission = chkIsSetCommission.Checked; } private void txtRatio_TextChanged(object sender, EventArgs e) { UploadProductBLL.CommissionRatio = txtRatio.Text.ParseToInt(); } private void lblWaitUpload_Click(object sender, EventArgs e) { //return; if (webBrowser != null && btn != null) { webBrowser.BringToFront(); btn.BringToFront(); } } private void buttonEx2_Click_1(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Multiselect = false;//该值确定是否可以选择多个文件 dialog.Title = "请选择文件夹"; //窗体标题 dialog.Filter = "图片文件(*.jpg,*.png,*.jpeg)|*.jpg;*.png;*.jpeg"; //dialog.Filter = "图片文件(*.jpg,*.jpeg,*.png)|*.jpg|*.jpeg|*.png|*.bmp|*.gif"; //文件筛选 dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer); if (dialog.ShowDialog() == DialogResult.OK) { string file = dialog.FileName;//文件夹路径 string path = file.Substring(file.LastIndexOf("\\") + 1); //格式化处理,提取文件名 FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read); byte[] img = new byte[fs.Length]; BinaryReader br = new BinaryReader(fs);//二进制读取器 img = br.ReadBytes(Convert.ToInt32(fs.Length)); UploadProductBLL.img = img; new Thread(SetFixedImage).Start(); } } public void SetFixedImage() { string baseImageUrl = HttpPostDataImage("https://fxg.jinritemai.com/common/img/batchupload?_bid=ffa_goods", "https://fxg.jinritemai.com/ffa/g/create", UploadProductBLL.img); UploadProductBLL.baseImageUrl = BaseRegex.GetMatchRegexString(baseImageUrl, @"\[""([\w\W]+?)""\]"); FileBase.WriteAllText("temp/imageUrl.txt", UploadProductBLL.baseImageUrl, Encoding.UTF8); } private static string HttpPostDataImage(string url, string referer, byte[] file) { var shop = GlobalConfig.DouShopLoginList.Where(s => s.LoginStatus == "登录成功").FirstOrDefault(); if (shop == null) return ""; string responseContent = ""; string cookie = shop.Cookies; if (string.IsNullOrEmpty(cookie)) { return ""; } var memStream = new MemoryStream(); var webRequest = (HttpWebRequest)WebRequest.Create(url); // 边界符 var boundary = "----WebKitFormBoundaryQ6FNeGKnNmZqtskD"; // 边界符 var beginBoundary = Encoding.ASCII.GetBytes("--" + boundary + "\r\n"); // 边界符 var secondBoundary = Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n"); // 最后的结束符 var endBoundary = Encoding.ASCII.GetBytes("\r\n--" + boundary + "--"); // 设置属性 webRequest.Method = "POST"; webRequest.KeepAlive = true; webRequest.Timeout = 5000; webRequest.ReadWriteTimeout = 5000; webRequest.ContentType = "multipart/form-data; boundary=" + boundary; webRequest.Referer = referer; webRequest.Accept = "*/*"; webRequest.UserAgent = BaseClass.ChromeUserAgent; webRequest.Headers.Add("Cookie", cookie); webRequest.Headers.Add("Origin", @"https://fxg.jinritemai.com"); //webRequest.Headers.Add("Sec-Fetch-Site", @"same-site"); //webRequest.Headers.Add("Sec-Fetch-Mode", @"cors"); webRequest.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate"); webRequest.Headers.Set(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9"); webRequest.Headers.Set(HttpRequestHeader.Cookie, cookie); webRequest.ServicePoint.Expect100Continue = false; string filePartHeader = "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\n" + "Content-Type: image/jpeg\r\n\r\n"; var header = string.Format(filePartHeader, "image[0]", "标签.jpg"); var headerbytes = Encoding.UTF8.GetBytes(header); memStream.Write(beginBoundary, 0, beginBoundary.Length); memStream.Write(headerbytes, 0, headerbytes.Length); // 写入文件 memStream.Write(file, 0, file.Length); // 写入最后的结束边界符 memStream.Write(endBoundary, 0, endBoundary.Length); webRequest.ContentLength = memStream.Length; using (Stream stream = webRequest.GetRequestStream()) { memStream.WriteTo(stream); } var httpWebResponse = (HttpWebResponse)webRequest.GetResponse(); if (httpWebResponse != null) { if (string.IsNullOrEmpty(responseContent)) responseContent = ReadResponsex(httpWebResponse); httpWebResponse.Close(); } return responseContent; } public static string ReadResponsex(HttpWebResponse response) { using (Stream responseStream = response.GetResponseStream()) { Stream streamToRead = responseStream; if (response.ContentEncoding.ToLower().Contains("gzip")) { streamToRead = new GZipStream(streamToRead, CompressionMode.Decompress); } else if (response.ContentEncoding.ToLower().Contains("deflate")) { streamToRead = new DeflateStream(streamToRead, CompressionMode.Decompress); } using (StreamReader streamReader = new StreamReader(streamToRead, Encoding.UTF8)) { return streamReader.ReadToEnd(); } } } //private string GetShopDetail(string productId) //{ // HttpWebResponse response = null; // string result; // try // { // string url = "https://ec.snssdk.com/product/getstock?id=3493426708055488550&add_cart=0&b_type_new=0&device_id=0&is_outside=1"; // HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); // request.ContentType = "application/x-www-form-urlencoded"; // request.Referer = "https://haohuo.jinritemai.com/"; // request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36 Edg/91.0.864.509"; // request.Headers.Add("origin", @"https://haohuo.jinritemai.com"); // response = (HttpWebResponse)request.GetResponse(); // } // catch (WebException ex) // { // if (ex.Status == WebExceptionStatus.ProtocolError) // { // response = (HttpWebResponse)ex.Response; // result = GetProxyHtml.ReadResponse(response); // return result; // } // else return ex.Message; // } // catch (Exception e) // { // if (response != null) response.Close(); // return e.Message; // } // result = GetProxyHtml.ReadResponse(response); // return result; //} #region 数据净化数据导入相关静态函数 /// /// 从数据净化导入数据 /// /// /// public static string ImportFromFission(List pcbList) { if (instance != null) instance.ImportFormFissionData(pcbList); else lstFissionPcb.AddRange(pcbList); return "ok"; } #endregion private void ImportFormFissionData(List pcbs) { foreach (var pcb in pcbs) { TaobaoProductBase t = new TaobaoProductBase(); t.TolerantFormId = pcb.from_id.ToString(); t.FromId = pcb.from_id; t.ViPrice = ""; t.ViGoodsId = 0; t.FromType = pcb.from; t.Titlte = pcb.name.Replace("\",\"", ""); t.pcb = pcb; if (!UploadProductBLL.ProductStock.Exists(p => p != null && p.FromId == t.FromId && p.Titlte == t.Titlte)) { UploadProductBLL.ProductStock.Add(t); DataBaseTemp.Add(t); batchDataBaseTemp.Add(t); if (batchDataBaseTemp.Count > 50) { AddListToDataBaseSingle(batchDataBaseTemp); batchDataBaseTemp.Clear(); ReMain(); } } } if (batchDataBaseTemp.Count > 0) { AddListToDataBaseSingle(batchDataBaseTemp); batchDataBaseTemp.Clear(); ReMain(); } } private void chkRandomMainImage_CheckedChanged(object sender, EventArgs e) { } private void chkSaveToOffLine_CheckedChanged(object sender, EventArgs e) { } FlowLayoutPanel pnlViolateCheck = null; private void btnSetViolateCheck_Click(object sender, EventArgs e) { UploadProductViolateSelectForm f = new UploadProductViolateSelectForm(); f.ShowDialog(); return; if (pnlViolateCheck == null) { pnlViolateCheck = new FlowLayoutPanel(); pnlViolateCheck.AutoScroll = true; pnlViolateCheck.Anchor = AnchorStyles.Top; pnlViolateCheck.BorderStyle = BorderStyle.FixedSingle; pnlViolateCheck.SetAutoScrollMargin(10, 10); this.Controls.Add(pnlViolateCheck); // 读取违规信息规则名称列表 ViolateManageForm.GetAllViolateRuleName(); // 显示违规信息规则名称列表 ViolateManageForm.SetViolateSelectList(pnlViolateCheck); } pnlViolateCheck.Width = this.Width - 150; pnlViolateCheck.Height = this.Height - 300; pnlViolateCheck.Location = new Point((this.Width - pnlViolateCheck.Width) / 2, 58); if (btnSetViolateCheck.Text == "设置") { pnlViolateCheck.Visible = true; pnlViolateCheck.BringToFront(); btnSetViolateCheck.Text = "关闭"; } else { pnlViolateCheck.Visible = false; pnlViolateCheck.SendToBack(); btnSetViolateCheck.Text = "设置"; } } private void chkMultiUpload_CheckedChanged(object sender, EventArgs e) { lblFromTo.Visible = lblFromTo2.Visible = txtMultiple2.Visible = cmbPlusOrMinus2.Visible = txtPostage2.Visible = chkMultiUpload.Checked; } private void txtSetBrand_TextChanged(object sender, EventArgs e) { //string result = ""; //while (result == "" || result.Contains("已过期")) //{ // var dyShop = GlobalConfig.DouShopLoginList.FirstOrDefault(s => s.ApiAuthStatus == "授权成功"); // if (dyShop == null) // { // BaseMsgForm.ShowError("请确保至少有一个店铺授权成功!"); // return; // } // var api = new DouyinApi(dyShop); // api.JsonData["category_id"] = detailDataPcb.cat_id.ToString(); // var textQuery = txt.Text.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries).LastOrDefault(); // api.JsonData["query"] = textQuery == null ? "" : textQuery; // "JIXIN/积鑫"; // result = api.cateBrandList(); //} // //try //{ // var jArr = JObject.Parse(result)["data"]["brand_list"] as JArray; // ShowBrandList(jArr, txt); //} //catch (Exception ex) { } } private void btn上传质检报告_Click(object sender, EventArgs e) { var imageUrl = uploadQualificationFile("3457058945162709852", "质检报告"); if (!string.IsNullOrEmpty(imageUrl)) this.pictureBox3.Load(imageUrl); } private void btn上传包装标签图_Click(object sender, EventArgs e) { var imageUrl = uploadQualificationFile("6966228537426575660", "包装标签图"); if (!string.IsNullOrEmpty(imageUrl)) this.pictureBox2.Load(imageUrl); } private void btn上传食品许可证_Click(object sender, EventArgs e) { var imageUrl = uploadQualificationFile("6921664837978194184", "食品生产许可证"); if (!string.IsNullOrEmpty(imageUrl)) this.pictureBox1.Load(imageUrl); } private string uploadQualificationFile(string qualityKey, string qualityName) { var uploadResult = new FissionBrowserObject().addLocalPic(false); if (uploadResult.Contains("\"msg\":\"success\"")) { var qualificationFile = new quality_file(); qualificationFile.quality_key = qualityKey; qualificationFile.quality_name = qualityName; if (qualityName == "食品生产许可证") { var prop = UploadProductBLL.sGlobalPropList.FirstOrDefault(pr => pr.Key == "食品生产许可证编号"); if (prop != null) qualificationFile.quality_number = prop.Value; } if (qualificationFile.quality_attachments == null) qualificationFile.quality_attachments = new List(); var imageUrl = BaseRegex.GetStringJson(ref uploadResult, "src")?.Replace("\\/", "/"); if (!string.IsNullOrEmpty(imageUrl)) { qualificationFile.quality_attachments.Clear(); qualificationFile.quality_attachments.Add(new quality_attachment { media_type = 1, url = imageUrl }); UploadProductBLL.sGlobalQualifications.RemoveAll(q => q.quality_name == qualificationFile.quality_name); UploadProductBLL.sGlobalQualifications.Add(qualificationFile); NaiBa.Util.Helper.ConfigHelper.SaveConfig("global_qualifications", UploadProductBLL.sGlobalQualifications); return imageUrl; } } return ""; } private void txt食品生产许可证号_TextChanged(object sender, EventArgs e) { UploadProductBLL.sGlobalPropList.RemoveAll(kv => kv.Key == "食品生产许可证编号"); if (!string.IsNullOrEmpty(txt食品生产许可证编号.Text.Trim())) { UploadProductBLL.sGlobalPropList.Add(new KeyValueBase("食品生产许可证编号", txt食品生产许可证编号.Text.Trim())); NaiBa.Util.Helper.ConfigHelper.SaveConfig("global_prop_list", UploadProductBLL.sGlobalPropList); var Qualifications = UploadProductBLL.sGlobalQualifications.FirstOrDefault(q => q.quality_name == "食品生产许可证"); if (Qualifications != null) { Qualifications.quality_number = txt食品生产许可证编号.Text.Trim(); NaiBa.Util.Helper.ConfigHelper.SaveConfig("global_qualifications", UploadProductBLL.sGlobalQualifications); } } } private void txt生产企业名称_TextChanged(object sender, EventArgs e) { UploadProductBLL.sGlobalPropList.RemoveAll(kv => kv.Key == "生产企业名称"); if (!string.IsNullOrEmpty(txt生产企业名称.Text.Trim())) { UploadProductBLL.sGlobalPropList.Add(new KeyValueBase("生产企业名称", txt生产企业名称.Text.Trim())); NaiBa.Util.Helper.ConfigHelper.SaveConfig("global_prop_list", UploadProductBLL.sGlobalPropList); } } private void txtBrand_TextChanged(object sender, EventArgs e) { UploadProductBLL.sGlobalPropList.RemoveAll(kv => kv.Key == "品牌"); if (!string.IsNullOrEmpty(txtBrand.Text.Trim())) { UploadProductBLL.sGlobalPropList.Add(new KeyValueBase("品牌", txtBrand.Text.Trim())); NaiBa.Util.Helper.ConfigHelper.SaveConfig("global_prop_list", UploadProductBLL.sGlobalPropList); } } private void dgvProduct_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e) { var row = dgvProduct.Rows[e.RowIndex]; if (row.Cells["messageColumn"].Value.ToString() == "请去店铺后台创建产品尺码表!") { var font = dgvProduct.RowsDefaultCellStyle.Font; row.Cells["messageColumn"].Style.Font = new Font(font.FontFamily, font.Size, FontStyle.Underline); } } private void chkSaveUploadFailed_CheckedChanged(object sender, EventArgs e) { } } public class OpenApiResponseBase { public string msg = ""; private int tpl_type = 0; private int page = 0; private int size = 0; private int st = 0; public int code = 0; public int total = 0; public List data { get; set; } public OpenApiResponseBase() { } } public class PropertiesBase { public string hint = ""; public int multi_select_max = 0; public int property_type = 0; public string property_id = ""; public int sequence = 0; public int relation_id = 0; public string name { get; set; } public int required { get; set; } public string type { get; set; } public List options { get; set; } public PropertiesBase() { } } public class PropertiesValuesBase { public string name { get; set; } public string value { get; set; } public PropertiesValuesBase() { } } public class FxgCatBase { /// /// /// public int id { get; set; } /// /// 名称 /// public string name { get; set; } /// /// 类目ID /// public int parent_cid { get; set; } /// /// 层级 /// public int level { get; set; } /// /// /// public int enable { get; set; } /// /// 叶子节点 /// public string is_leaf { get; set; } /// /// /// public string extra { get; set; } } public class CategoryResult { /// /// /// public int st { get; set; } /// /// /// public string msg { get; set; } /// /// /// public int code { get; set; } /// /// /// public List data { get; set; } /// /// /// public int page { get; set; } /// /// /// public int size { get; set; } /// /// /// public int total { get; set; } } public class FxgCatLevel { /// /// /// public int id { get; set; } /// /// 名称 /// public string name { get; set; } /// /// 类目ID /// public int cat1id { get; set; } /// /// 名称 /// public string cat1name { get; set; } /// /// 类目ID /// public int cat2id { get; set; } /// /// 名称 /// public string cat2name { get; set; } /// /// 类目ID /// public int cat3id { get; set; } /// /// 名称 /// public string cat3name { get; set; } /// /// 类目ID /// public int cat4id { get; set; } /// /// 名称 /// public string cat4name { get; set; } /// /// 层级 /// public int level { get; set; } /// /// 叶子节点 /// public string is_leaf { get; set; } } }