using AllBase; using AllBase.Helper; using AllBase.Model.Result; using NaiBa.Util.Extension; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Net.Http; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using TemuKJD.Extension; using TemuKJD.BaseForms; using TemuKJD.ToolForms; using Work; using TemuKJD.BLL; using System.Text.RegularExpressions; using TemuKJD.PDDForms.ProductSelectForms; using TemuKJD.WXForms.ShopForms; using AllBase.Model.Result.PDDResult; using AllBase.Model.Param.WXParam; using AllBase.Model.Result.WXResult; namespace TemuKJD.WXForms.ProductForms { public partial class WXDBProdUploadForm : BaseForm { public CancellationTokenSource cancellationTokenSource { get; set; } = null; public bool IsLoadComplate { get; set; } = false; bool isInit = false; bool isStepAddPrice = false; CheckBox chkSelectAll = null; Dictionary dicShopGetCount = new Dictionary(); Dictionary> dicNotSupportCate = new Dictionary>(); public NaiBa.Util.ConcurrentList lstTemuDBProductSelect = new NaiBa.Util.ConcurrentList(); NaiBa.Util.ConcurrentList lstAddPriceRule = new NaiBa.Util.ConcurrentList(); AddPriceRule defaultAddPriceRule = null; WXUploadRule wxUploadRule = null; public WXDBProdUploadForm() { InitializeComponent(); } private void UserSelectDbProductForm_Load(object sender, EventArgs e) { this.splitContainer1.Dock = DockStyle.Fill; this.panel1.Location = new Point(40, 30); this.panel1.Width = this.Width - 80; this.panel1.Height = this.Height - 60; this.panel1.SendToBack(); lstTemuDBProductSelect = NaiBa.Util.Helper.ConfigHelper.LoadConfig>("wx_db_prod_upload_list"); if (lstTemuDBProductSelect == null) lstTemuDBProductSelect = new NaiBa.Util.ConcurrentList(); lstAddPriceRule = NaiBa.Util.Helper.ConfigHelper.LoadConfig>("wx_add_price_rules"); if (lstAddPriceRule == null) { lstAddPriceRule = new NaiBa.Util.ConcurrentList(); lstAddPriceRule.Add(new AddPriceRule() { MoreThanPrice = 0, LessThanPrice = 10, AddPriceTimes = 2, AddMorePrice = 5, SinglePriceAdd = 1 }); lstAddPriceRule.Add(new AddPriceRule() { MoreThanPrice = 10, LessThanPrice = 20, AddPriceTimes = 2, AddMorePrice = 5, SinglePriceAdd = 1 }); lstAddPriceRule.Add(new AddPriceRule() { MoreThanPrice = 20, LessThanPrice = 999, AddPriceTimes = 2, AddMorePrice = 5, SinglePriceAdd = 1 }); } this.fPnlPriceRule.Controls.Clear(); foreach (var priceItem in lstAddPriceRule) { var ucPrice = new UcAddPrice() { PriceEnd = priceItem.LessThanPrice, PriceStart = priceItem.MoreThanPrice, PriceAddTimes = priceItem.AddPriceTimes, PriceAddMore = priceItem.AddMorePrice, SinglePriceAdd = priceItem.SinglePriceAdd, }; if (IsSetFontScaleNone) { Font of = ucPrice.Font; Font nf = new Font(of.FontFamily, (of.Size * 96.0 / FormDpi).ParseToFloat(), of.Style, of.Unit, of.GdiCharSet, of.Bold); ucPrice.Font = nf; } this.fPnlPriceRule.Controls.Add(ucPrice); ucPrice.PriceChange += ucAddPrice_PriceChange; } defaultAddPriceRule = NaiBa.Util.Helper.ConfigHelper.LoadConfig("wx_default_add_price_rule"); if (defaultAddPriceRule == null) { defaultAddPriceRule = new AddPriceRule() { AddPriceTimes = 1.3m, AddMorePrice = 1, SinglePriceAdd = 1 }; } this.txtAddTimes.Text = defaultAddPriceRule.AddPriceTimes.ToString(); this.txtAddMorePrice.Text = defaultAddPriceRule.AddMorePrice.ToString(); this.txtSinglePriceAdd.Text = defaultAddPriceRule.SinglePriceAdd.ToString(); this.txtStockNum.Text = defaultAddPriceRule.StockNum.ToString(); this.chkAddMorePriceFirst.Checked = defaultAddPriceRule.AddMorePriceFirst; wxUploadRule = NaiBa.Util.Helper.ConfigHelper.LoadConfig("wx_upload_rule"); if (wxUploadRule == null) wxUploadRule = new WXUploadRule(); this.lblWaitToUp.Text = "待上传商品 " + lstTemuDBProductSelect.Count + " 件"; int prodCount = 0; var list = GetRandomProductList(out prodCount, 1, 1); lblGoodsCount.Text = "产品库中共有 " + prodCount + " 件商品"; this.panel1.SendToBack(); chkSelectAll = dgvShop.Columns["colSelect"].AddHeaderCheckBox(HorizontalAlignment.Center, 0, 0, null, null, false); dgvShop.Columns["colSelect"].HeaderText = ""; //chkSelectAll.Width = chkSelectAll.Height = 13; chkSelectAll.CheckedChanged += chkSelectAll_CheckedChanged; chkSelectAll.Checked = true; this.dgvSelectProduct.AddSelectorColumn("colCheck"); dgvSelectProduct.AddImgColumn("colProductSkcPic", "colImgUrl"); dgvSelectProduct.AddImgColumn("colSkuFakeImg", "colSkuFakeImgUrl"); dgvSelectProduct.Columns["colSkuFakeImg"].Visible = false; // if (BaseClass.SaLevel == 1) // { // dgvSelectProduct.Columns["colSkuFakeImg"].Visible = true; // } //#if DEBUG // dgvSelectProduct.Columns["colSkuFakeImg"].Visible = true; //#endif IsLoadComplate = true; } private void chkSelectAll_CheckedChanged(object sender, EventArgs e) { if (!chkSelectAll.Checked) { foreach (DataGridViewRow row in dgvShop.Rows) { row.Cells["colSelect"].Value = false; } } else { //var list = GlobalConfig.ShopLoginList.Where(s => s.LoginStatus == "登录成功").Select(ss => ss.ShopId); foreach (DataGridViewRow row in dgvShop.Rows) { //if (list.Any(l => l == row.Cells["colShopId"]?.Value?.ToString())) row.Cells["colSelect"].Value = true; } } } private void btnRefreshShop_Click(object sender, EventArgs e) { RefreshShop(); RefreshDbProd(); } private void UserSelectDbProductForm_VisibleChanged(object sender, EventArgs e) { if (Visible == true) { RefreshShop(); RefreshDbProd(); isInit = true; } } private void RefreshDbProd() { Task.Run(() => { PDDDBProdListForm.GetPDDProductGroup(cmbGroupFilter); // 同时刷新下商品分组 GetPddProductCate(); }); } /// /// 获取商品所有类目 /// void GetPddProductCate() { var url = BaseClass.BuildObjString("product/get_pdd_product_cates"); var data = UserLogin.GetSignaturex(); var html = GetHtml.PostUtf8(url, data); if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200")) html = GetHtml.PostUtf8(url, data); if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200")) { //BaseMsgForm.ShowError("商品分组获取失败,请重试!" + BaseRegex.GetStringJson(ref html, "msg")); } else { Invoke(new Action(() => { cmbCateFilter.Items.Clear(); var groups = BaseRegex.GetStringJson(ref html, "data"); foreach (var item in groups.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)) { cmbCateFilter.Items.Add(item); } cmbCateFilter.Items.Add(""); })); } } private void RefreshShop() { // 店铺Id var selectIds = dgvShop.Rows.Cast().Where(row => row.Cells["colSelect"]?.Value.ParseToBool() == true).Select(r => r.Cells["colShopId"]?.Value.ToString()).ToList(); // 获取被删除的店铺 List dgvRowList = dgvShop.Rows.Cast().Where(row => !GlobalConfig.ShopLoginList.Any(s => s.ShopId == row.Cells["colShopId"]?.Value?.ToString())).ToList(); // 更新被删除的店铺列表 foreach (var row in dgvRowList) { dgvShop.Rows.Remove(row); } // 绑定其他店铺(含新导入的店铺) foreach (ShopLoginInfo shopEntity in GlobalConfig.ShopLoginList) { if (!string.IsNullOrEmpty(shopEntity.ShopId)) BindShop(shopEntity, selectIds); } } private void BindShop(ShopLoginInfo shopEntity, List selectShopId = null) { if (shopEntity == null) return; if (selectShopId == null) selectShopId = new List(); bool canUse = shopEntity.LoginStatus == "登录成功"; //canUse = true; // 内部库不需要校验登录状态 var row = dgvShop.Rows.Cast().FirstOrDefault(p => p.Cells.GetCellValueFromColumnName("colShopId").ParseToString() == shopEntity.ShopId); if (row == null) { this.dgvShop.Rows.Add( !isInit || (selectShopId.Contains(shopEntity.ShopId) && canUse), shopEntity.LoginName, shopEntity.ShopId, shopEntity.ShopAccount, shopEntity.Notes, "选择商品", canUse ? "在线" : "掉线", canUse, shopEntity.AddProductRemaining, string.Empty ); } else { row.Cells["colSelect"].Value = !isInit || (selectShopId.Contains(shopEntity.ShopId) && canUse); row.Cells["colShopLoginName"].Value = shopEntity.LoginName; row.Cells["colShopName"].Value = shopEntity.ShopAccount; row.Cells["colShopNotes"].Value = shopEntity.Notes; row.Cells["colLoginStatus"].Value = canUse ? "在线" : "掉线"; row.Cells["colLoginStatus"].Style.ForeColor = canUse ? Color.Green : Color.Red; row.Cells["colCanUse"].Value = canUse; row.Cells["colRemaining"].Value = shopEntity.AddProductRemaining; } } private void dgvShop_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex < 0 || e.RowIndex < 0) return; string headerText = dgvShop.Columns[e.ColumnIndex].HeaderText; string columnName = dgvShop.Columns[e.ColumnIndex].Name; string shopId = dgvShop.Rows[e.RowIndex].Cells["colShopId"].Value.ParseToString(); string shopAccount = dgvShop.Rows[e.RowIndex].Cells["colShopName"].Value.ToString(); var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ShopId == shopId.ToString()); var row = dgvShop.Rows[e.RowIndex]; switch (columnName) { case "colSelect": //if (row.Cells["colCanUse"].Value.ParseToBool()) { row.Cells["colSelect"].Value = !row.Cells["colSelect"].Value.ParseToBool(); chkSelectAll.CheckedChanged -= chkSelectAll_CheckedChanged; if (dgvShop.Rows.Cast().All(r => r.Cells["colSelect"].Value.ParseToBool())) chkSelectAll.Checked = true; else chkSelectAll.Checked = false; chkSelectAll.CheckedChanged += chkSelectAll_CheckedChanged; } //else { //BaseMsgForm.ShowInfo("店铺未登录!"); } break; case "colLoginStatus": if (WXShopListForm.Instance == null) WXShopListForm.Instance = new WXShopListForm(); WXShopListForm.Instance.CheckShopLogin(new string[] { shop.LoginName }, false); WXShopLoginForm shopLoginForm = new WXShopLoginForm(shop); //shopLoginForm.prodUserSelectForm = this; if (shop.LoginStatus != "登录成功") { shopLoginForm.openType = EnumOpenType.login; shopLoginForm.ShowDialog(); RefreshShop(); } else { shopLoginForm.openType = EnumOpenType.manage; shopLoginForm.WindowState = FormWindowState.Maximized; shopLoginForm.Show(); } break; } } private void btnSearch_Click(object sender, EventArgs e) { var lstShopId = dgvShop.Rows.Cast().Where(row => row.Cells["colSelect"]?.Value.ParseToBool() == true).Select(r => r.Cells["colShopId"]?.Value.ToString()).ToList(); if (lstShopId.Count == 0) { BaseMsgForm.ShowInfo("请选择店铺!"); return; } } private void dgvSelectProduct_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex < 0 || e.RowIndex < 0) return; string headerText = dgvSelectProduct.Columns[e.ColumnIndex].HeaderText; var dbId = dgvSelectProduct.Rows[e.RowIndex].Cells["colSelectId"].Value.ParseToString(); var dbProduct = lstTemuDBProductSelect.FirstOrDefault(p => p.id.ToString() == dbId); var shopId = dgvSelectProduct.Rows[e.RowIndex].Cells["colSupplierId"].Value.ParseToString(); var draftId = dgvSelectProduct.Rows[e.RowIndex].Cells["colDraftId"].Value.ParseToString(); var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ShopId == shopId); switch (headerText) { case "删除": break; case "登录": { WXShopLoginForm shopLoginForm = new WXShopLoginForm(shop); //shopLoginForm.prodUserSelectForm = this; shopLoginForm.openType = EnumOpenType.login; shopLoginForm.ShowDialog(); RefreshShop(); } break; case "进店": { WXShopLoginForm shopLoginForm = new WXShopLoginForm(shop); //shopLoginForm.prodUserSelectForm = this; shopLoginForm.openType = EnumOpenType.manage; shopLoginForm.WindowState = FormWindowState.Maximized; shopLoginForm.InitUrl = "https://store.weixin.qq.com/shop/home"; shopLoginForm.Show(); } break; case "上传商品Id": //if (!string.IsNullOrEmpty(draftId) && shop != null) //{ // ShopLoginForm shopLoginForm = new ShopLoginForm(shop); // shopLoginForm.InitUrl = "https://seller.kuajingmaihuo.com/goods/product-create/product-edit?productDraftId=" + // draftId + "&from=productDraftList"; // shopLoginForm.openType = EnumOpenType.manage; // shopLoginForm.WindowState = FormWindowState.Maximized; // shopLoginForm.ShowDialog(); //} break; case "图片": { ShowImgForm imgFrom = new ShowImgForm(dgvSelectProduct.Rows[e.RowIndex].Cells["colImgUrl"].Value.ParseToString()); imgFrom.ShowDialog(); break; } case "SKU替换图": { ShowImgForm imgFrom = new ShowImgForm(dgvSelectProduct.Rows[e.RowIndex].Cells["colSkuFakeImgUrl"].Value.ParseToString()); imgFrom.ShowDialog(); break; } case "": dgvSelectProduct.Rows[e.RowIndex].Cells["colCheck"].Value = !(bool)dgvSelectProduct.Rows[e.RowIndex].Cells["colCheck"].Value; break; default: break; } } private void btnUpload_Click(object sender, EventArgs e) { var shopIdLst = dgvShop.Rows.Cast().Where(row => row.Cells["colSelect"]?.Value.ParseToBool() == true).Select(r => r.Cells["colShopId"]?.Value.ToString()).ToList(); if (shopIdLst.Count <= 0) { BaseMsgForm.ShowError("未勾选上传店铺!"); return; } if (lstTemuDBProductSelect.Count() > 0) { if (WXShopLoginForm.shopLoginInstance != null && WXShopLoginForm.shopLoginInstance.IsDisposed != true) WXShopLoginForm.shopLoginInstance.Dispose(); this.btnUpload.Enabled = false; cancellationTokenSource = new CancellationTokenSource(); Task.Run(() => { AddProductArr(shopIdLst); Invoke(new Action(() => { this.btnUpload.Enabled = true; })); }, cancellationTokenSource.Token); } else { BaseMsgForm.ShowError("请选择要上传的商品!"); } } void AddProductArr(List shopIdLst) { Invoke(new Action(() => { this.pbLoading.Visible = true; this.statusBar.lblTaskStatus.Text = "正在上传" + "...".Substring(0, DateTime.Now.Second % 4); this.statusBar.pgbTaskProgress.Maximum = lstTemuDBProductSelect.Count; this.statusBar.UpdateProgressBar(0); })); NaiBa.Util.ConcurrentList currentShopList = new NaiBa.Util.ConcurrentList(); while (lstTemuDBProductSelect.Count > 0) { if (cancellationTokenSource.IsCancellationRequested) break; Invoke(new Action(() => { shopIdLst = dgvShop.Rows.Cast().Where(row => row.Cells["colSelect"]?.Value.ParseToBool() == true).Select(r => r.Cells["colShopId"]?.Value.ToString()).ToList(); })); while (shopIdLst.Count <= 0) { Invoke(new Action(() => { this.statusBar.lblTaskStatus.Text = "请至少勾选一个店铺"; shopIdLst = dgvShop.Rows.Cast().Where(row => row.Cells["colSelect"]?.Value.ParseToBool() == true).Select(r => r.Cells["colShopId"]?.Value.ToString()).ToList(); })); Thread.Sleep(1000); if (cancellationTokenSource.IsCancellationRequested) break; } var randomShopLst = new NaiBa.Util.ConcurrentList(); randomShopLst.AddRange(GlobalConfig.ShopLoginList.Where(s => shopIdLst.Contains(s.ShopId) && s.LoginStatus == "登录成功")); while (randomShopLst.Count <= 0) { Thread.Sleep(1000); Invoke(new Action(() => { shopIdLst = dgvShop.Rows.Cast().Where(row => row.Cells["colSelect"]?.Value.ParseToBool() == true).Select(r => r.Cells["colShopId"]?.Value.ToString()).ToList(); })); Invoke(new Action(() => { this.statusBar.lblTaskStatus.Text = "所有店铺都已掉线,请登录店铺"; randomShopLst.Clear(); randomShopLst.AddRange(GlobalConfig.ShopLoginList.Where(s => shopIdLst.Contains(s.ShopId) && s.LoginStatus == "登录成功")); })); if (cancellationTokenSource.IsCancellationRequested) break; } if (cancellationTokenSource.IsCancellationRequested) break; var randomShop = randomShopLst[Randomx.GetId(randomShopLst.Count)]; while (currentShopList.Count >= 5) // 最多5店同传 { Thread.Sleep(100); } if (cancellationTokenSource.IsCancellationRequested) break; while (currentShopList.Any(s => s.ShopId == randomShop.ShopId)) { Thread.Sleep(500); randomShop = randomShopLst[Randomx.GetId(randomShopLst.Count)]; } currentShopList.Add(randomShop); if (cancellationTokenSource.IsCancellationRequested) break; if (lstTemuDBProductSelect.Count <= 0) { currentShopList.Remove(randomShop); break; } var prod = lstTemuDBProductSelect[0]; if (randomShop != null) { prod.shop_id = randomShop.ShopId; prod.shop_account = randomShop.ShopAccount = randomShop.ShopAccount; } else { currentShopList.Remove(randomShop); continue; } if (cancellationTokenSource.IsCancellationRequested) break; lstTemuDBProductSelect.RemoveAt(0); NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_db_prod_upload_list", this.lstTemuDBProductSelect); Invoke(new Action(() => { lblWaitToUp.Text = "待上传商品 " + lstTemuDBProductSelect.Count + " 件"; })); Invoke(new Action(() => { this.statusBar.lblTaskStatus.Text = "正在上传" + "...".Substring(0, DateTime.Now.Second % 4); this.statusBar.pgbTaskProgress.Maximum = lstTemuDBProductSelect.Count + this.statusBar.pgbTaskProgress.Value + 1; this.statusBar.UpdateProgressBar(this.statusBar.pgbTaskProgress.Value + 1); })); if (prod == null) { Invoke(new Action(() => { BaseMsgForm.ShowError("商品为空,将为您跳过该商品!"); })); currentShopList.Remove(randomShop); continue; } Invoke(new Action(() => { int rowIndex = 0; this.dgvSelectProduct.Rows.Insert(rowIndex, true, prod.id, prod.shop_id, prod.shop_account, "登录", "进店", prod.spu_id, prod.skc_id, prod.main_img, null, "", null, prod.product_name, // 用户端显示商品原名 prod.cat_name, prod.ext_code, prod.status, prod.draft_id, prod.notes, (prod.user_notes + " 编辑").Trim(), "删除", "", ""); dgvSelectProduct.Rows[rowIndex].Height = 60; int maxRowCount = 10000; while (dgvSelectProduct.Rows.Count > maxRowCount) { dgvSelectProduct.Rows.RemoveAt(maxRowCount); } })); Invoke(new Action(() => { this.pbLoading.Visible = false; })); Task.Run(() => { DateTime startTime = DateTime.Now; for (int j = 0; j < 1; j++) { var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ShopId == prod.shop_id); if (shop == null) continue; var row = dgvSelectProduct.Rows.Cast().FirstOrDefault(r => r.Cells["colSelectId"]?.Value.ToString() == prod.id.ToString()); double duration = 0; if (row == null) { Invoke(new Action(() => { BaseMsgForm.ShowError("商品已被清除,将为您跳过该商品!"); })); continue; } KJDDBProduct kjdDbProd = prod.kjdDbProduct; if (kjdDbProd == null) kjdDbProd = GetProductDetail(prod.out_product_Id.ToString()); if (kjdDbProd == null || kjdDbProd.id == 0) { if (kjdDbProd?.id == 0) { prod.status = "已清除"; } Invoke(new Action(() => { if (row.Index >= 0) { row.Cells["colOpResult"].Value = "选品数据库商品已被清除"; if (kjdDbProd?.id == 0) row.Cells["colStatus"].Value = "已清除"; } })); continue; } var result = ""; try { WXShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false); if (shop.LoginStatus != "登录成功") { Invoke(new Action(() => { if (row.Index >= 0) { row.Cells["colOpResult"].Value = "店铺掉线"; } })); continue; } if (cancellationTokenSource.IsCancellationRequested) break; //将商品上传 result = UploadProduct(shop, kjdDbProd, prod, row.Cells["colOpResult"], startTime); Invoke(new Action(() => { row.Cells["colSkuFakeImgUrl"].Value = kjdDbProd.sku_img_replace_url; if (row.Displayed) { string getImgError = ""; Image img = GetHtml.GetUrlImg(kjdDbProd.sku_img_replace_url.Replace("https://", "http://"), out getImgError); if (string.IsNullOrEmpty(getImgError)) row.Cells["colSkuFakeImg"].Value = img; } })); if (!result.Contains("success")) { WXShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false); } } catch (Exception ex) { result = "{\"success\":false,\"status\":\"未上传\",\"errMsg\":\"" + ex.Message + "\"}"; } Thread.Sleep(Randomx.GetId(200, 300)); var timeSpan = DateTime.Now - startTime; duration = timeSpan.TotalSeconds; var error = BaseRegex.GetStringJson(ref result, "errMsg"); if (!result.Contains("\"success\":true") && !result.Contains("上传成功")) { if (string.IsNullOrWhiteSpace(error)) error = result; Invoke(new Action(() => { if (row.Index >= 0) { row.Cells["colOpResult"].Value = error + " " + duration.ParseToInt() + "秒"; } })); goto UploadEnd; } prod.status = BaseRegex.GetStringJson(ref result, "status"); if (string.IsNullOrWhiteSpace(prod.status)) prod.status = "待上传"; var productDraftId = BaseRegex.GetStringJson(ref result, "draftId"); Invoke(new Action(() => { if (row.Index >= 0) { row.Cells["colDraftId"].Value = productDraftId; // 草稿箱id row.Cells["colAddTime"].Value = DateTime.Now.ToString("yy-MM-dd HH:mm:ss"); row.Cells["colOpResult"].Value = (prod.status == "已上传" ? "已成功上传" : "已上传 发生错误:") + (" " + error).TrimEnd(' ') + " " + duration.ParseToInt() + "秒"; row.Cells["colMsg"].Value = prod.status; } })); UploadEnd:; //额外等待时间(无论失败与否) var waitTime = 0; Invoke(new Action(() => { waitTime = txtWaitSeconds.Text.Trim().ParseToInt(); })); if (waitTime > 0) Thread.Sleep(Randomx.GetId(waitTime * 1000, (waitTime + 10) * 1000)); } currentShopList.Remove(randomShop); }); } for (int i = 0; i < 200 && currentShopList.Count > 0; i++) { Thread.Sleep(1000); if (cancellationTokenSource.IsCancellationRequested) break; } Invoke(new Action(() => { if (cancellationTokenSource.IsCancellationRequested) BaseMsgForm.ShowInfo("上传停止!"); else BaseMsgForm.ShowInfo("上传完成!"); })); Invoke(new Action(() => { this.pbLoading.Visible = false; if (cancellationTokenSource.IsCancellationRequested) this.statusBar.lblTaskStatus.Text = "上传停止"; else this.statusBar.lblTaskStatus.Text = "上传完成"; //this.statusBar.UpdateProgressBar(lstTemuDBProductSelect.Count); })); } public static KJDDBProduct GetProductDetail(string prodDbId) { if (string.IsNullOrEmpty(prodDbId)) return new KJDDBProduct(); List list = new List(); var url = BaseClass.BuildObjString("product/get_pdd_product_detail_list"); var data = ""; data = UserLogin.GetSignaturex() + "&search_db_ids=" + prodDbId; var html = GetHtml.PostUtf8(url, data); if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200")) html = GetHtml.PostUtf8(url, data); if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200")) { return null; } var jArr = JObject.Parse(html)["data"]; if (jArr.Count() == 0) return null; var sProd = JsonHelper.SerializeObject(jArr); try { list = JsonHelper.DeserializeJsonToList(sProd); var item = list.FirstOrDefault(); if (item == null) item = new KJDDBProduct(); return item; } catch (Exception ex) { return null; } } string UploadProduct(ShopLoginInfo shop, KJDDBProduct dbProd, TemuDBProductSelect selectProd, DataGridViewCell cell, DateTime startTime) { Thread.Sleep(Randomx.GetId(300, 2000)); if (shop == null || string.IsNullOrEmpty(shop.ShopId) || shop.LoginStatus != "登录成功") { return "店铺为空或未登录!"; } if (cell != null) { Invoke(new Action(() => { cell.Value = "正在初始化上传"; })); } var prodInfo = JsonHelper.DeserializeJsonToObject(dbProd.product_json); prodInfo.detail.galleries.RemoveAll(g => g.type == 6); // 视频暂时移除,以后再视情况加上 if ((prodInfo?.detail?.galleries?.Where(g => g.type == 1).Count()).ParseToInt() < 3) { Invoke(new Action(() => { cell.Value = "主图数量少于三张"; })); return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"msg\":\"主图数量少于三张\"}"; } // 生成初始化上传商品对象 var upProdInitParam = new WXUploadProductInitParam(); // 生成上传商品对象 var upProdParam = new WXUploadProductParam(); upProdInitParam.product.info.title = prodInfo.detail.goods_name; upProdParam.product.info.title = prodInfo.detail.goods_name; upProdParam.sessionInfo.sessionId = upProdInitParam.product.sessionId; int imgId = 0; string tempImgPath = Path.GetTempPath() + "\\"; string folderLetters = "abcdefghijklmnopqrstuvwxyz1234567890"; for (int i = 0; i < 8; i++) { tempImgPath += folderLetters[Randomx.GetId(folderLetters.Length)]; } List tempImgFullPathLst = new List(); foreach (var gallery_item in prodInfo.detail.galleries.Where(g => g.type == 1).Take(9)) // 9张主图 { var upImgAuthRst = WXUpload.getUploadTempImgAuth(shop); if (!upImgAuthRst.Contains("\"code\":0")) { var error = BaseRegex.GetStringJson(ref upImgAuthRst, "msg"); if (string.IsNullOrEmpty(error)) error = upImgAuthRst; return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"" + error + "\"}"; } string disK = BaseRegex.GetStringJson(ref upImgAuthRst, "disK"); long disT = BaseRegex.GetLongJson(ref upImgAuthRst, "disT"); string ext = BaseRegex.GetStringJson(ref upImgAuthRst, "ext"); string imgBase64 = ""; //------------------------------------------------------------------------------------------------------------------------------------- //生成主图base64字符串 string getImgError; var image = GetHtml.GetUrlImg(gallery_item.url.Replace("https://", "http://"), out getImgError); var imageBg = new Bitmap(800, 800); if (!string.IsNullOrEmpty(getImgError) || image == null) { return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"初始化主图上传失败\"}"; } try { using (Graphics g = Graphics.FromImage(imageBg)) { g.DrawImage(image, new Rectangle(0, 0, imageBg.Width, imageBg.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel); } if (imgId < 3) { imgId++; if (!Directory.Exists(tempImgPath)) Directory.CreateDirectory(tempImgPath); string imgFullPath = tempImgPath + "\\图片" + imgId + ".jpg"; tempImgFullPathLst.Add(imgFullPath); if (imgId == 1) image.Save(imgFullPath, System.Drawing.Imaging.ImageFormat.Jpeg); else { // 只需要传一张真实图像即可 int fileSize = Randomx.GetId(1024, 10240); using (BinaryWriter writer = new BinaryWriter(File.Create(imgFullPath))) { for (int i = 0; i < fileSize; i++) { writer.Write((byte)Randomx.GetId(256)); // 生成0到255之间的随机字节 } } } } using (MemoryStream memoryStream = new MemoryStream()) { imageBg.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] imageBytes = memoryStream.ToArray(); imgBase64 = Convert.ToBase64String(imageBytes); } } catch (Exception ex) { return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"" + "修改sku图片失败 " + ex.Message + "\"}"; } //------------------------------------------------------------------------------------------------------------------------------------- //上传主图获取路径 var upImgRst = WXUpload.adtimageupload(shop, imgBase64, disK, disT, ext).ParseToString(); var location = BaseRegex.GetStringJson(ref upImgRst, "Location"); if (string.IsNullOrEmpty(location)) { var error = BaseRegex.GetStringJson(ref upImgAuthRst, "msg"); if (string.IsNullOrEmpty(error)) error = upImgAuthRst; return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"主图上传失败 " + error + "\"}"; } upProdInitParam.product.info.headImg.Add(location); upProdParam.product.info.headImg.Add(location); Thread.Sleep(Randomx.GetId(10, 50)); } //{"code":0,"predInfo":{"firstCatRes":[{"catId":10000111,"catName":"服饰内衣","level":1},{"catId":10000111,"catName":"服饰内衣","level":1},{"catId":10000111,"catName":"服饰内衣","level":1}],"secondCatRes":[{"catId":10000113,"catName":"女装","level":2},{"catId":10000113,"catName":"女装","level":2},{"catId":10000113,"catName":"女装","level":2}],"thirdCatRes":[{"catId":547705,"catName":"牛仔裤","level":3,"modelVersion":""},{"catId":547704,"catName":"加绒裤","level":3,"modelVersion":"商品标题含'加绒加厚、保暖'等关键词,这表示裤子具备加绒保暖功能。主图展示了加绒内衬,也符合【服饰内衣:女装:裤子:加绒裤】类目特征。"},{"catId":547701,"catName":"休闲裤","level":3,"modelVersion":""}],"singleSecondCatRes":[],"singleFirstCatRes":[],"isSupportedCate":1},"aiCategoryList":[{"id":547705,"paths":[{"id":"10000111","name":"服饰内衣","sonIdList":["10000397","10000115","10000112","10000113","10000114"],"fId":"0","level":1,"leaf":false},{"id":"10000113","name":"女装","sonIdList":["546810","546811","530041","547706","6090","6089","6088","6087","6083","6076","6073","6070","6065","6063","6058","10000672","10000671","10000670","10000669","10000668","10000667","10000666","10000665","10000664","10000663","10000662","10000661","10000660","10000659","10000658","10000657","10000656","10000655"],"fId":"10000111","level":2,"leaf":false},{"id":"10000672","name":"裤子","sonIdList":["547699","547700","547701","547702","547703","547704","547705"],"fId":"10000113","level":3,"leaf":false},{"id":"547705","name":"牛仔裤","fId":"10000672","level":4,"leaf":true,"state":0,"hasTrialCategory":false,"isTrialCategory":false,"isLocalLife":false}],"depositAmount":0,"catAuth":true,"limitSubjectTypes":[]},{"id":547704,"paths":[{"id":"10000111","name":"服饰内衣","sonIdList":["10000397","10000115","10000112","10000113","10000114"],"fId":"0","level":1,"leaf":false},{"id":"10000113","name":"女装","sonIdList":["546810","546811","530041","547706","6090","6089","6088","6087","6083","6076","6073","6070","6065","6063","6058","10000672","10000671","10000670","10000669","10000668","10000667","10000666","10000665","10000664","10000663","10000662","10000661","10000660","10000659","10000658","10000657","10000656","10000655"],"fId":"10000111","level":2,"leaf":false},{"id":"10000672","name":"裤子","sonIdList":["547699","547700","547701","547702","547703","547704","547705"],"fId":"10000113","level":3,"leaf":false},{"id":"547704","name":"加绒裤","fId":"10000672","level":4,"leaf":true,"state":0,"hasTrialCategory":false,"isTrialCategory":false,"isLocalLife":false}],"depositAmount":0,"catAuth":true,"limitSubjectTypes":[]},{"id":547701,"paths":[{"id":"10000111","name":"服饰内衣","sonIdList":["10000397","10000115","10000112","10000113","10000114"],"fId":"0","level":1,"leaf":false},{"id":"10000113","name":"女装","sonIdList":["546810","546811","530041","547706","6090","6089","6088","6087","6083","6076","6073","6070","6065","6063","6058","10000672","10000671","10000670","10000669","10000668","10000667","10000666","10000665","10000664","10000663","10000662","10000661","10000660","10000659","10000658","10000657","10000656","10000655"],"fId":"10000111","level":2,"leaf":false},{"id":"10000672","name":"裤子","sonIdList":["547699","547700","547701","547702","547703","547704","547705"],"fId":"10000113","level":3,"leaf":false},{"id":"547701","name":"休闲裤","fId":"10000672","level":4,"leaf":true,"state":0,"hasTrialCategory":false,"isTrialCategory":false,"isLocalLife":false}],"depositAmount":0,"catAuth":true,"limitSubjectTypes":[]}],"version":"ProductClsRAG","noQualificationCatIds":[547705,547704,547701],"depositCatInfos":[{"catId":547705,"amountToPay":0,"error":false},{"catId":547704,"amountToPay":0,"error":false},{"catId":547701,"amountToPay":0,"error":false}],"visionCallMethod":"ProductClsRAG"} var productClassifyRst = WXUpload.getProductClassify(shop, upProdInitParam.product.info.title, tempImgFullPathLst); if (!productClassifyRst.Contains("\"code\":0")) { var error = BaseRegex.GetStringJson(ref productClassifyRst, "msg"); if (string.IsNullOrEmpty(error)) error = productClassifyRst; return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"" + error + "\"}"; } WXGetProdCateInfo cateInfo = new WXGetProdCateInfo(); try { cateInfo = JsonHelper.DeserializeJsonToObject(productClassifyRst); } catch (Exception ex) { return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"" + "根据图片获取类目失败 " + ex.Message + "\"}"; } if (cell != null) { Invoke(new Action(() => { cell.Value = "正在提交商品"; })); } Thread.Sleep(2000); if (cell != null) { Invoke(new Action(() => { var timeSpan = DateTime.Now - startTime; var duration = timeSpan.TotalSeconds; cell.Value = "商品已上传" + " " + duration.ParseToInt() + "秒"; })); } return "{\"success\":true,\"draftId\":" + "1000000000000000000000" + ",\"status\":\"已上传\",\"msg\":\"上传成功\"}"; } private void panel1_Paint(object sender, PaintEventArgs e) { } private void btnStop_Click(object sender, EventArgs e) { if (this.cancellationTokenSource != null) this.cancellationTokenSource.Cancel(); } private void btnRandomAdd_Click(object sender, EventArgs e) { int addCount = txtAddCount.Text.Trim().ParseToInt(); Task.Run(() => { while (addCount > 0) { int prodCount = 0; var list = GetRandomProductList(out prodCount, 1, 50); if (list.Count == 0) // 等于0要么库里没数据要么出错了,跳出 break; Invoke(new Action(() => { lblGoodsCount.Text = "产品库中共有 " + prodCount + " 件商品"; })); Thread.Sleep(Randomx.GetId(50,100)); foreach (var prod in list) { var selectProd = JsonHelper.DeserializeJsonToObject(JsonHelper.SerializeObject(prod)); selectProd.out_product_Id = prod.id.ToString(); selectProd.id = 1; if(lstTemuDBProductSelect.Count > 0) selectProd.id = lstTemuDBProductSelect.Max(p => p.id) + 1; this.lstTemuDBProductSelect.Add(selectProd); Invoke(new Action(() => { lblWaitToUp.Text = "待上传商品 " + lstTemuDBProductSelect.Count + " 件"; })); addCount--; if (addCount <= 0) break; } NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_db_prod_upload_list", this.lstTemuDBProductSelect); } }); } public List GetRandomProductList(out int totalCount, int page = 1, int pageSize = 50) { var lstShopId = dgvShop.Rows.Cast().Where(row => row.Cells["colSelect"]?.Value.ParseToBool() == true).Select(r => r.Cells["colShopId"]?.Value.ToString()).ToList(); List list = new List(); int pageCount = 1; totalCount = 0; var url = BaseClass.BuildObjString("product/get_pdd_product_list_random"); var data = ""; Invoke(new Action(() => { data = UserLogin.GetSignaturex() + "&page=" + 1 + "&page_size=" + pageSize; data += "&in_ext_codes=" + txtExtCodeFilter.Text; data += "&in_skc_ids=" + txtIdFilter.Text; data += "&in_groups=" + cmbGroupFilter.Text; data += "&in_cates=" + cmbCateFilter.Text; })); var html = GetHtml.PostUtf8(url, data); if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200")) html = GetHtml.PostUtf8(url, data); if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200")) html = GetHtml.PostUtf8(url, data); if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200")) { Invoke(new Action(() => { BaseMsgForm.ShowError("获取商品失败,请重试!" + BaseRegex.GetStringJson(ref html, "msg")); })); return new List(); } int count = BaseRegex.GetIntJson(ref html, "count"); totalCount = count; pageCount = Math.Ceiling(1.0 * count / pageSize).ParseToInt(); pageCount = Math.Max(pageCount, 1); var jArr = JObject.Parse(html)["data"]; if (jArr.Count() == 0) return list; var sProd = JsonHelper.SerializeObject(jArr); try { list = JsonHelper.DeserializeJsonToList(sProd); return list; } catch (Exception ex) { return new List(); } } private void btnClearUpload_Click(object sender, EventArgs e) { if (BaseMsgForm.ShowConfirm("确定清空待上传商品吗?清空后不可恢复!").DialogResult == DialogResult.Cancel) return; this.lstTemuDBProductSelect.Clear(); NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_db_prod_upload_list", this.lstTemuDBProductSelect); lblWaitToUp.Text = "待上传商品 " + lstTemuDBProductSelect.Count + " 件"; } private void lblNewAddPrice_Click(object sender, EventArgs e) { var ucPrice = new UcAddPrice(); if (IsSetFontScaleNone) { Font of = ucPrice.Font; Font nf = new Font(of.FontFamily, (of.Size * 96.0 / FormDpi).ParseToFloat(), of.Style, of.Unit, of.GdiCharSet, of.Bold); ucPrice.Font = nf; } ucPrice.PriceChange += ucAddPrice_PriceChange; this.fPnlPriceRule.Controls.Add(ucPrice); } private void ucAddPrice_PriceChange(object obj) { List priceRuleLst = new List(); foreach (var ucItem in fPnlPriceRule.Controls) { var ucPrice = ucItem as UcAddPrice; if (ucPrice != null) { priceRuleLst.Add(new AddPriceRule() { AddMorePrice = ucPrice.PriceAddMore, AddPriceTimes = ucPrice.PriceAddTimes, LessThanPrice = ucPrice.PriceEnd, MoreThanPrice = ucPrice.PriceStart, SinglePriceAdd = ucPrice.SinglePriceAdd, }); } } this.lstAddPriceRule.Clear(); this.lstAddPriceRule.AddRange(priceRuleLst); NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_add_price_rules", lstAddPriceRule); } private void txtAddPrice_TextChanged(object sender, EventArgs e) { if (IsLoadComplate) { defaultAddPriceRule.AddPriceTimes = txtAddTimes.Text.Trim().ParseToDecimal(); defaultAddPriceRule.AddMorePrice = txtAddMorePrice.Text.Trim().ParseToDecimal(); defaultAddPriceRule.SinglePriceAdd = txtSinglePriceAdd.Text.Trim().ParseToDecimal(); defaultAddPriceRule.StockNum = txtStockNum.Text.Trim().ParseToInt(); NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_default_add_price_rule", defaultAddPriceRule); } } private void chkStepAddPrice_CheckedChanged(object sender, EventArgs e) { isStepAddPrice = this.chkStepAddPrice.Checked; } private void btnClearDgv_Click(object sender, EventArgs e) { //this.dgvSelectProduct.Rows.Clear(); var rows = this.dgvSelectProduct.Rows.Cast().ToList(); //Cast后Rows做foreach循环时仍会夹花跳过,所以要ToList转一个新的数组。 foreach (var row in rows) { if (row.Cells["colCheck"].Value.ParseToBool() == true) this.dgvSelectProduct.Rows.Remove(row); } } private void chkAddMorePriceFirst_CheckedChanged(object sender, EventArgs e) { if (IsLoadComplate) { defaultAddPriceRule.AddMorePriceFirst = chkAddMorePriceFirst.Checked; NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_default_add_price_rule", defaultAddPriceRule); } } private void lblGoodsCount_Click(object sender, EventArgs e) { //PDDDBProdListForm f = new PDDDBProdListForm(); //f.Width = 1366; //f.Height = 768; //f.ShowMaximizeBox = true; //f.ShowDialog(); } private void lblWaitToUp_Click(object sender, EventArgs e) { PDDDBProdUserSelectCacheForm selectCacheForm = new PDDDBProdUserSelectCacheForm(lstTemuDBProductSelect); selectCacheForm.ShowDialog(); lblWaitToUp.Text = "待上传商品 " + lstTemuDBProductSelect.Count + " 件"; } private void btnClearFilter_Click(object sender, EventArgs e) { txtIdFilter.Text = ""; txtExtCodeFilter.Text = ""; cmbGroupFilter.Text = ""; cmbCateFilter.Text = ""; int prodCount; GetRandomProductList(out prodCount, 1, 1); lblGoodsCount.Text = "产品库中共有 " + prodCount + " 件商品"; } } public class WXUpload { public static string getUploadTempImgAuth(ShopLoginInfo shop, int uploadScene = 3) { string url = "https://store.weixin.qq.com/shop-faas/mmecchannelspicture/cgi/getUploadTempImgAuth?token=&lang=zh_CN&uploadScene=" + uploadScene; string refere = "https://store.weixin.qq.com/shop/goods/entry"; //{"code":0,"disK":"538c14e950da7b678ce9f5a12658c8acddd09e4b","disT":1767870926,"ext":"23aa0ecfb792a","url":"https://westore.video.qq.com/adtimageupload"} var result = WXHttpResponseBLL.WeiXinGetResponse(shop, url, refere); return result; } public static string adtimageupload(ShopLoginInfo shop, string imgBase64, string dis_k, long dis_t, string ext) { string url = "https://westorealpha.video.qq.com/adtimageupload"; string referer = "https://store.weixin.qq.com/"; string body = imgBase64; var result = WXHttpResponseBLL.WeiXinImgPostResponse(shop, url, body, dis_k, dis_t, ext, referer); return result; } public static string getProductClassify(ShopLoginInfo shop, string goodsName, List goodImgUrlsLst) { string boundaryLetters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; string boundaryStr = "----WebKitFormBoundary"; for (int i = 0; i < 16; i++) { boundaryStr += boundaryLetters[Randomx.GetId(boundaryLetters.Length)]; } string url = "https://store.weixin.qq.com/shop-faas/cgi/common/productClassify?from=B&title=" + GetHtml.UrlEncodeUtf8(goodsName) + "&token=&lang=zh_CN"; string referer = "https://store.weixin.qq.com/shop/goods/entry"; string body = @"--" + boundaryStr + @" "; foreach (var imgFullPath in goodImgUrlsLst) { string fileName = imgFullPath.Split('\\').LastOrDefault(); body += @"Content-Disposition: form-data; name=""file""; filename=""" + fileName + @""" Content-Type: image/jpeg " + imgFullPath + @" --" + boundaryStr; } body += @"-- "; var result = WXHttpResponseBLL.WeiXinUploadResponse(shop, url, body, boundaryStr, referer); return result; } public static string getCategoryOnShelf(ShopLoginInfo shop, List catIdLst) { string url = "https://store.weixin.qq.com/shop-faas/mmchannelstradecategory/cgi/product/getCategoryOnShelfV2?token=&lang=zh_CN"; string referer = "https://store.weixin.qq.com/shop/goods/entry"; string body = @"{""catIdList"":[" + string.Join(",", catIdLst) + @"],""brandId"":2100000000}"; var result = WXHttpResponseBLL.WeiXinPostResponse(shop, url, body, referer); return result; } public static string genProductShortTitle(ShopLoginInfo shop, WXGetShortTitleParam getShortTitleParam) { string url = "https://store.weixin.qq.com/shop-faas/mmecnodeproductupload/common/cgi/goods/genProductShortTitle?token=&lang=zh_CN"; string referer = "https://store.weixin.qq.com/shop/goods/entry"; string body = JsonHelper.SerializeObject(getShortTitleParam); //{"productTitle":"妈妈老年中年阔脚裤冬季秋季时尚牛仔裤","headImgUrls":["https://wst.wxapp.tc.qq.com/160/20304/snscosdownload/SH/reserved/6xykWLEnztKEVU0iahAM7HQ28puCia87zPkvSbFT8Fcia99g2ZNWRdy8licxD6qwsqV4bCicoxwQF9e6jh3qwibgzxuA?token=x5Y29zUxcibCe0pFyoSA8zb1aYVKnIBLkQ8ZUXMcwEq3qYHsko3TDzv2rsL2AfJPd&idx=1&expire=1768211170","https://wst.wxapp.tc.qq.com/160/20304/snscosdownload/SH/reserved/6xykWLEnztKEVU0iahAM7Hbwaw1AboTKxjGsLhJgVreuYNxwyQxrk9RtvCv3XsXSnic9WfBFMAIZYpNgYkWd7VDQ?token=x5Y29zUxcibCe0pFyoSA8zb1aYVKnIBLk4qWUsS2WZiaCjXhZLj0D6PYyddX71qNiat&idx=1&expire=1768211170","https://wst.wxapp.tc.qq.com/160/20304/snscosdownload/SH/reserved/6xykWLEnztKEVU0iahAM7HTa1Ej2xJpy6Ej84arVO7A3vxIDD1XP6ZRVw43OficKLXPcXPUvDNmc8A4lMHCgbic3A?token=x5Y29zUxcibCe0pFyoSA8zb1aYVKnIBLkhejArCiaiaLIEKtvOicA5chibIj1tfELV0Mm&idx=1&expire=1768211170"],"categories":[{"catId":"10000111","catName":"服饰内衣"},{"catId":"10000113","catName":"女装"},{"catId":"10000672","catName":"裤子"},{"catId":"547705","catName":"牛仔裤"}]} var result = WXHttpResponseBLL.WeiXinPostResponse(shop, url, body, referer); return result; } public static string getFreightTemplate(ShopLoginInfo shop) { string url = "https://store.weixin.qq.com/shop-faas/mmecnodeproductupload/express/cgi/goods/getFreightTemplate?token=&lang=zh_CN"; string referer = "https://store.weixin.qq.com/shop/goods/entry"; var result = WXHttpResponseBLL.WeiXinGetResponse(shop, url, referer); return result; } } public class AddPriceRule { /// /// 加价金额区间大于 不包含 /// public decimal MoreThanPrice { get; set; } /// /// 加价金额区间小于 包含 /// public decimal LessThanPrice { get; set; } /// /// 加价倍数 /// public decimal AddPriceTimes { get; set; } /// /// 额外加价金额 /// public decimal AddMorePrice { get; set; } /// /// 单买加价 /// public decimal SinglePriceAdd { get; set; } /// /// 先加后乘 /// public bool AddMorePriceFirst { get; set; } = false; /// /// 上货库存量设置 /// public int StockNum { get; set; } = 0; } public class WXUploadRule { public bool IsUseUpperSizeSpec { get; set; } = true; public bool IsKeepChanceGoodImg { get; set; } = true; /// /// 是否报名活动(提交一个虚拟高倍率加价再通过活动价格实现商品原价) /// public bool IsSignActivity { get; set; } = true; /// /// 准备报名活动的商品原价加价倍率 /// public decimal ActivityAddPriceTimes { get; set; } = 3m; public bool IsLowPriceSku { get; set; } = true; public string LowPriceSkuName { get; set; } = "福利款"; public decimal LowPriceSkuLowestPrice { get; set; } = 5m; /// /// 升级版 /// public bool IsUpgradeVersion { get; set; } = false; public string UpgradeVersionName { get; set; } = "升级版"; /// /// 升级版额外加价 /// public decimal UpgradeVersionAddPrice { get; set; } = 1m; public bool IsUseExtCodePrice { get; set; } public bool sign20981 { get; set; } public bool sign22347 { get; set; } public bool sign15996 { get; set; } public bool sign21365 { get; set; } } }