From 2a4a3ef744fb930ed1131dddc2757fcb00ed0273 Mon Sep 17 00:00:00 2001 From: wule Date: Thu, 21 Aug 2025 19:34:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=97=E9=93=BA=E9=80=80=E8=B4=A7=E5=8C=85?= =?UTF-8?q?=E8=A3=B9=E8=AF=BB=E5=8F=96=E6=94=BE=E5=88=B0=E5=90=8E=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AllBase/BaseClass.cs | 4 +- AllBase/BaseRegex.cs | 32 ++ AllBase/Model/Result/ShopLoginInfo.cs | 134 +++-- .../ProductSelectForms/DbProductListForm.cs | 7 +- .../DbProductSelectEditNotesForm.Designer.cs | 90 ++-- .../DbProductSelectListManageForm.cs | 19 +- .../ProductThirdSelectListManageForm.cs | 19 +- .../ShopForms/ReturnPackageDetailForm.cs | 219 ++++++--- .../ShopForms/ShopLoginForm.Designer.cs | 40 +- .../Statistics/ShopStatisticsForm.Designer.cs | 329 +++++++------ .../Statistics/ShopStatisticsForm.cs | 457 +++++++++++++++++- .../Statistics/ShopStatisticsForm.resx | 13 +- TEMUKJD/StartUp.cs | 35 ++ 13 files changed, 1021 insertions(+), 377 deletions(-) diff --git a/AllBase/BaseClass.cs b/AllBase/BaseClass.cs index 424a051..6aca3c6 100644 --- a/AllBase/BaseClass.cs +++ b/AllBase/BaseClass.cs @@ -27,8 +27,8 @@ namespace AllBase /// /// 版本ID /// - public static int VersionCount = 535; - //public static int VersionCount = 535; + public static int VersionCount = 538; + //public static int VersionCount = 538; /// /// 版本号 diff --git a/AllBase/BaseRegex.cs b/AllBase/BaseRegex.cs index 26244b1..4995e8a 100644 --- a/AllBase/BaseRegex.cs +++ b/AllBase/BaseRegex.cs @@ -549,6 +549,23 @@ namespace AllBase return 0; } + /// + /// 获取值 + /// + /// + /// + /// + public static int? GetNullableIntJson(ref string html, string reg) + { + string temp = GetMatchRegexString(html, @"['""]" + reg + @"['""][\s]*:[\s]*['""]([^']+?)['""]"); + if (string.IsNullOrEmpty(temp)) + temp = GetMatchRegexString(html, @"['""]" + reg + @"['""][\s]*:[\s]*([\d-]+)"); + int i; + if (int.TryParse(temp, out i)) + return i; + return null; + } + /// /// 获取值 /// @@ -564,6 +581,21 @@ namespace AllBase return false; } + /// + /// 获取值 + /// + /// + /// + /// + public static bool? GetNullableBoolJson(ref string html, string reg) + { + var temp = GetMatchRegexString(html, @"['""]" + reg + @"['""][\s]*:[\s]*(true|false)"); + bool res; + if (bool.TryParse(temp, out res)) + return res; + return null; + } + /// /// 时间戳转字符串时间 /// diff --git a/AllBase/Model/Result/ShopLoginInfo.cs b/AllBase/Model/Result/ShopLoginInfo.cs index bc11366..0310896 100644 --- a/AllBase/Model/Result/ShopLoginInfo.cs +++ b/AllBase/Model/Result/ShopLoginInfo.cs @@ -261,76 +261,122 @@ namespace AllBase.Model.Result public string notes { get; set; } #endregion + #region 四个模块是否读取成功 /// - /// 有已发布商品 + /// 首页订单信息 /// - public bool? havePublishProduct { get; set; } = false; - public int? lackSkcNumber { get; set; } = 0; + public bool is_search_1 { get; set; } = false; /// - /// 建议备货 + /// 日到账金额信息 /// - public int? advicePrepareSkcNumber { get; set; } = 0; + public bool is_search_2 { get; set; } = false; /// - /// 商品信息待修改 + /// 月到账金额信息 /// - public int? waitProductNumber { get; set; } = 0; + public bool is_search_3 { get; set; } = false; /// - /// 调价待确认 + /// 店铺保证金信息 /// - public int? adjustPrice { get; set; } = 0; + public bool is_search_4 { get; set; } = false; + public string err_msg { get; set; } + #endregion + /// - /// 开款待价格确认 + /// 首页订单信息 有已发布商品 /// - public int? reviewAdjustPrice { get; set; } = 0; + public bool? havePublishProduct { get; set; } = null; /// - /// 在售商品数 + /// 首页订单信息 缺货数量? /// - public int? onSaleProductNumber { get; set; } = 0; + public int? lackSkcNumber { get; set; } = null; /// - /// 今日销量 + /// 首页订单信息 建议备货 /// - public int? saleVolume { get; set; } = 0; + public int? advicePrepareSkcNumber { get; set; } = null; /// - /// 近7日销量 + /// 首页订单信息 商品信息待修改 /// - public int? sevenDaysSaleVolume { get; set; } = 0; + public int? waitProductNumber { get; set; } = null; /// - /// 近30日销量 + /// 首页订单信息 调价待确认 /// - public int? thirtyDaysSaleVolume { get; set; } = 0; - public ShopStatisticsPermissionsInfo permissions { get; set; } + public int? adjustPrice { get; set; } = null; /// - /// 即将售罄(商品数量) + /// 首页订单信息 开款待价格确认 /// - public int? aboutToSellOutNumber { get; set; } = 0; + public int? reviewAdjustPrice { get; set; } = null; /// - /// 已经售罄(商品数量) + /// 首页订单信息 在售商品数 /// - public int? alreadySoldOutNumber { get; set; } = 0; + public int? onSaleProductNumber { get; set; } = null; /// - /// 近90天品质售后率 + /// 首页订单信息 今日销量 /// - public int? qualityAfterSaleRatio90d { get; set; } = 0; + public int? saleVolume { get; set; } = null; /// - /// 高价限流商品数 + /// 首页订单信息 近7日销量 /// - public int? highPriceLimitNumber { get; set; } = 0; + public int? sevenDaysSaleVolume { get; set; } = null; + /// + /// 首页订单信息 近30日销量 + /// + public int? thirtyDaysSaleVolume { get; set; } = null; + //public ShopStatisticsPermissionsInfo permissions { get; set; } + /// + /// 首页订单信息 即将售罄(商品数量) + /// + public int? aboutToSellOutNumber { get; set; } = null; + /// + /// 首页订单信息 已经售罄(商品数量) + /// + public int? alreadySoldOutNumber { get; set; } = null; + /// + /// 首页订单信息 近90天品质售后率 + /// + public int? qualityAfterSaleRatio90d { get; set; } = null; + /// + /// 首页订单信息 高价限流商品数 + /// + public int? highPriceLimitNumber { get; set; } = null; + + + public decimal? yesterdayIncomeAmount { get; set; } = 0; + public decimal? thisMonthIncomeAmount { get; set; } = 0; + public decimal? lastMonthIncomeAmount { get; set; } = 0; + + /// + /// 可提现金额(可用余额) + /// + public decimal? availableBalance { get; set; } = 0; + /// + /// 预留额度(门槛)(这两个不清楚具体哪个对哪个) + /// + public decimal? mallDepositThreshold { get; set; } = 0; + /// + /// 账户预留金额(这两个不清楚具体哪个对哪个) + /// + public decimal? mallDepositLimitAmount { get; set; } = 0; + + /// + /// 提现总金额 + /// + public decimal? withdrawCashAmount { get; set; } = 0; } - public class ShopStatisticsPermissionsInfo - { - public bool? thirtyDaysSaleVolume { get; set; } - public bool? qualityAfterSaleRatio90d { get; set; } - public bool? adjustPrice { get; set; } - public bool? alreadySoldOutNumber { get; set; } - public bool? reviewAdjustPrice { get; set; } - public bool? aboutToSellOutNumber { get; set; } - public bool? advicePrepareSkcNumber { get; set; } - public bool? waitProductNumber { get; set; } - public bool? highPriceLimitNumber { get; set; } - public bool? saleVolume { get; set; } - public bool? lackSkcNumber { get; set; } - public bool? sevenDaysSaleVolume { get; set; } - public bool? onSaleProductNumber { get; set; } - } + //public class ShopStatisticsPermissionsInfo + //{ + // public bool? thirtyDaysSaleVolume { get; set; } + // public bool? qualityAfterSaleRatio90d { get; set; } + // public bool? adjustPrice { get; set; } + // public bool? alreadySoldOutNumber { get; set; } + // public bool? reviewAdjustPrice { get; set; } + // public bool? aboutToSellOutNumber { get; set; } + // public bool? advicePrepareSkcNumber { get; set; } + // public bool? waitProductNumber { get; set; } + // public bool? highPriceLimitNumber { get; set; } + // public bool? saleVolume { get; set; } + // public bool? lackSkcNumber { get; set; } + // public bool? sevenDaysSaleVolume { get; set; } + // public bool? onSaleProductNumber { get; set; } + //} } diff --git a/TEMUKJD/KJDForms/ProductSelectForms/DbProductListForm.cs b/TEMUKJD/KJDForms/ProductSelectForms/DbProductListForm.cs index f6ca7f6..bfbdb89 100644 --- a/TEMUKJD/KJDForms/ProductSelectForms/DbProductListForm.cs +++ b/TEMUKJD/KJDForms/ProductSelectForms/DbProductListForm.cs @@ -12,6 +12,7 @@ using System.IO; using System.Linq; using System.Net; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows.Forms; using TemuKJD.KJDForms.BaseForms; @@ -444,7 +445,9 @@ namespace TemuKJD.KJDForms.ProductSelectForms string headWords = ""; if (!string.IsNullOrWhiteSpace(prod.head_words)) { - var numbers = prod.head_words.Split(new string[] { "-", "个" }, StringSplitOptions.RemoveEmptyEntries).Select(w => w.ParseToInt()).ToList(); + var numberRegex = BaseRegex.GetMatchRegex(prod.head_words.Trim(), "\\d{1,9}"); + var numbers = numberRegex.Cast().Select(m => m.Value.ParseToInt()).ToList(); + //var numbers = prod.head_words.Split(new string[] { "-", "个" }, StringSplitOptions.RemoveEmptyEntries).Select(w => w.ParseToInt()).ToList(); int minNum = 5; int maxNum = 19; if (numbers.Count > 0 && numbers[0] > 0) @@ -458,7 +461,7 @@ namespace TemuKJD.KJDForms.ProductSelectForms { maxNum = minNum; } - headWords += Randomx.GetId(minNum, maxNum + 1) + "个"; + headWords += Randomx.GetId(minNum, maxNum + 1) + prod.head_words.Trim().Replace(minNum + "-" + maxNum, ""); } } diff --git a/TEMUKJD/KJDForms/ProductSelectForms/DbProductSelectEditNotesForm.Designer.cs b/TEMUKJD/KJDForms/ProductSelectForms/DbProductSelectEditNotesForm.Designer.cs index eb7f800..c33dfe2 100644 --- a/TEMUKJD/KJDForms/ProductSelectForms/DbProductSelectEditNotesForm.Designer.cs +++ b/TEMUKJD/KJDForms/ProductSelectForms/DbProductSelectEditNotesForm.Designer.cs @@ -30,6 +30,10 @@ { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DbProductSelectEditNotesForm)); this.panel2 = new System.Windows.Forms.Panel(); + this.cmbStatus = new System.Windows.Forms.ComboBox(); + this.label6 = new System.Windows.Forms.Label(); + this.txtDraftId = new System.Windows.Forms.TextBox(); + this.label5 = new System.Windows.Forms.Label(); this.btnFission = new DevComponents.DotNetBar.PanelEx(); this.lblTextCount = new System.Windows.Forms.Label(); this.txtSkc = new System.Windows.Forms.TextBox(); @@ -44,10 +48,6 @@ this.label8 = new System.Windows.Forms.Label(); this.txtNotes = new DevComponents.DotNetBar.Controls.TextBoxX(); this.btnOk = new TemuKJD.UserControls.ButtonEx(); - this.txtDraftId = new System.Windows.Forms.TextBox(); - this.label5 = new System.Windows.Forms.Label(); - this.label6 = new System.Windows.Forms.Label(); - this.cmbStatus = new System.Windows.Forms.ComboBox(); this.panel2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); @@ -79,6 +79,47 @@ this.panel2.Size = new System.Drawing.Size(391, 546); this.panel2.TabIndex = 1; // + // cmbStatus + // + this.cmbStatus.Enabled = false; + this.cmbStatus.FormattingEnabled = true; + this.cmbStatus.Items.AddRange(new object[] { + "待上传", + "已上传", + "草稿箱"}); + this.cmbStatus.Location = new System.Drawing.Point(252, 397); + this.cmbStatus.Name = "cmbStatus"; + this.cmbStatus.Size = new System.Drawing.Size(101, 25); + this.cmbStatus.TabIndex = 442; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(220, 401); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(32, 17); + this.label6.TabIndex = 441; + this.label6.Text = "状态"; + // + // txtDraftId + // + this.txtDraftId.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtDraftId.Location = new System.Drawing.Point(88, 398); + this.txtDraftId.Name = "txtDraftId"; + this.txtDraftId.ReadOnly = true; + this.txtDraftId.Size = new System.Drawing.Size(106, 23); + this.txtDraftId.TabIndex = 440; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(42, 401); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(45, 17); + this.label5.TabIndex = 439; + this.label5.Text = "上传ID"; + // // btnFission // this.btnFission.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); @@ -251,47 +292,6 @@ this.btnOk.UseVisualStyleBackColor = false; this.btnOk.Click += new System.EventHandler(this.btnOk_Click); // - // txtDraftId - // - this.txtDraftId.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.txtDraftId.Location = new System.Drawing.Point(88, 398); - this.txtDraftId.Name = "txtDraftId"; - this.txtDraftId.ReadOnly = true; - this.txtDraftId.Size = new System.Drawing.Size(106, 23); - this.txtDraftId.TabIndex = 440; - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(42, 401); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(45, 17); - this.label5.TabIndex = 439; - this.label5.Text = "上传ID"; - // - // label6 - // - this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(220, 401); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(32, 17); - this.label6.TabIndex = 441; - this.label6.Text = "状态"; - // - // cmbStatus - // - this.cmbStatus.Enabled = false; - this.cmbStatus.FormattingEnabled = true; - this.cmbStatus.Items.AddRange(new object[] { - "待上传", - "已上传", - "草稿箱"}); - this.cmbStatus.Location = new System.Drawing.Point(252, 397); - this.cmbStatus.Name = "cmbStatus"; - this.cmbStatus.Size = new System.Drawing.Size(101, 25); - this.cmbStatus.TabIndex = 442; - // // DbProductSelectEditNotesForm // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; diff --git a/TEMUKJD/KJDForms/ProductSelectForms/DbProductSelectListManageForm.cs b/TEMUKJD/KJDForms/ProductSelectForms/DbProductSelectListManageForm.cs index 6a5cdd8..b44b703 100644 --- a/TEMUKJD/KJDForms/ProductSelectForms/DbProductSelectListManageForm.cs +++ b/TEMUKJD/KJDForms/ProductSelectForms/DbProductSelectListManageForm.cs @@ -23,6 +23,7 @@ using TemuKJD.KJDForms.AdminForms; using TemuKJD.KJDForms.ShopForms; using System.Globalization; using TemuKJD.KJDForms.ToolForms; +using System.Text.RegularExpressions; namespace TemuKJD.KJDForms.ProductSelectForms { @@ -863,19 +864,25 @@ namespace TemuKJD.KJDForms.ProductSelectForms // 头词 if (chkHeadWords.Checked) { - int[] heads = dbProd.head_words.Split(new string[] { "-", "个" }, StringSplitOptions.RemoveEmptyEntries) - .Select(s => s.ParseToInt()).ToArray(); + //int[] heads = dbProd.head_words.Split(new string[] { "-", "个" }, StringSplitOptions.RemoveEmptyEntries) + // .Select(s => s.ParseToInt()).ToArray(); + string headTemp = dbProd.head_words.Trim(); + var numberRegex = BaseRegex.GetMatchRegex(headTemp, "\\d{1,9}"); + int[] heads = numberRegex.Cast().Select(m => m.Value.ParseToInt()).ToArray(); if (heads.Length < 2) { - if (string.IsNullOrEmpty(GlobalConfig.ProductWords.HeadWords)) + if (GlobalConfig.ProductWords.HeadWords == null) GlobalConfig.ProductWords.HeadWords = ""; - heads = GlobalConfig.ProductWords.HeadWords.Split(new string[] { "-", "个" }, StringSplitOptions.RemoveEmptyEntries) - .Select(s => s.ParseToInt()).ToArray(); + //heads = GlobalConfig.ProductWords.HeadWords.Split(new string[] { "-", "个" }, StringSplitOptions.RemoveEmptyEntries) + // .Select(s => s.ParseToInt()).ToArray(); + headTemp = GlobalConfig.ProductWords.HeadWords.Trim(); + numberRegex = BaseRegex.GetMatchRegex(headTemp, "\\d{1,9}"); + heads = numberRegex.Cast().Select(m => m.Value.ParseToInt()).ToArray(); } if (heads.Length > 1 && heads[1] > heads[0]) - headWords = Randomx.GetId(heads[0], heads[1]) + "个"; + headWords = Randomx.GetId(heads[0], heads[1]) + headTemp.Replace(heads[0] + "-" + heads[1], ""); } // 尾词 diff --git a/TEMUKJD/KJDForms/ProductThirdSelectForms/ProductThirdSelectListManageForm.cs b/TEMUKJD/KJDForms/ProductThirdSelectForms/ProductThirdSelectListManageForm.cs index 758c5d9..e844e68 100644 --- a/TEMUKJD/KJDForms/ProductThirdSelectForms/ProductThirdSelectListManageForm.cs +++ b/TEMUKJD/KJDForms/ProductThirdSelectForms/ProductThirdSelectListManageForm.cs @@ -956,13 +956,16 @@ namespace TemuKJD.KJDForms.ProductThirdSelectForms // 头词 if (chkHeadWords.Checked) { - if (string.IsNullOrEmpty(GlobalConfig.ProductWords.HeadWords)) + if (GlobalConfig.ProductWords.HeadWords == null) GlobalConfig.ProductWords.HeadWords = ""; - int[] heads = GlobalConfig.ProductWords.HeadWords.Split(new string[] { "-", "个" }, StringSplitOptions.RemoveEmptyEntries) - .Select(s => s.ParseToInt()).ToArray(); + //int[] heads = GlobalConfig.ProductWords.HeadWords.Split(new string[] { "-", "个" }, StringSplitOptions.RemoveEmptyEntries) + // .Select(s => s.ParseToInt()).ToArray(); + string headTemp = GlobalConfig.ProductWords.HeadWords.Trim(); + var numberRegex = BaseRegex.GetMatchRegex(headTemp, "\\d{1,9}"); + int[] heads = numberRegex.Cast().Select(m => m.Value.ParseToInt()).ToArray(); if (heads.Length > 1 && heads[1] > heads[0]) - headWords = Randomx.GetId(heads[0], heads[1]) + "个"; + headWords = Randomx.GetId(heads[0], heads[1]) + headTemp.Replace(heads[0] + "-" + heads[1], ""); } // 尾词 @@ -1680,7 +1683,11 @@ namespace TemuKJD.KJDForms.ProductThirdSelectForms string headWords = ""; if (!string.IsNullOrWhiteSpace(GlobalConfig.ProductWords.HeadWords)) { - var numbers = GlobalConfig.ProductWords.HeadWords.Split(new string[] { "-", "个" }, StringSplitOptions.RemoveEmptyEntries).Select(w => w.ParseToInt()).ToList(); + //var numbers = GlobalConfig.ProductWords.HeadWords.Split(new string[] { "-", "个" }, StringSplitOptions.RemoveEmptyEntries).Select(w => w.ParseToInt()).ToList(); + string headTemp = GlobalConfig.ProductWords.HeadWords.Trim(); + var numberRegex = BaseRegex.GetMatchRegex(headTemp, "\\d{1,9}"); + var numbers = numberRegex.Cast().Select(m => m.Value.ParseToInt()).ToList(); + int minNum = 5; int maxNum = 19; if (numbers.Count > 0 && numbers[0] > 0) @@ -1694,7 +1701,7 @@ namespace TemuKJD.KJDForms.ProductThirdSelectForms { maxNum = minNum; } - headWords += Randomx.GetId(minNum, maxNum + 1) + "个"; + headWords += Randomx.GetId(minNum, maxNum + 1) + headTemp.Replace(minNum + "-" + maxNum, ""); } } diff --git a/TEMUKJD/KJDForms/ShopForms/ReturnPackageDetailForm.cs b/TEMUKJD/KJDForms/ShopForms/ReturnPackageDetailForm.cs index 7cb1c7b..5675c55 100644 --- a/TEMUKJD/KJDForms/ShopForms/ReturnPackageDetailForm.cs +++ b/TEMUKJD/KJDForms/ShopForms/ReturnPackageDetailForm.cs @@ -21,20 +21,20 @@ namespace TemuKJD.KJDForms.ShopForms public partial class ReturnPackageDetailForm : LRBaseForm { public CancellationTokenSource cancellationTokenSource { get; set; } = null; - ShopLoginInfo shop = null; - List lstShop = new List(); + ShopLoginInfo Shop = null; List lstReturnPackageInfo = new List(); + public static ReturnPackageDetailForm instance = null; Bitmap defaultBitmap = null; public ReturnPackageDetailForm(ShopLoginInfo _shop) { InitializeComponent(); + instance = this; - if (_shop!= null) - { - this.shop = _shop; - lstShop.Add(shop); + if (_shop != null) + { + this.Shop = _shop; } pbLoading.Visible = false; } @@ -47,11 +47,18 @@ namespace TemuKJD.KJDForms.ShopForms private void btnAdd_Click(object sender, EventArgs e) { - GetReturnPackage(); + GetReturnPackage(this.Shop); } - void GetReturnPackage() + /// + /// + /// + /// + /// 后台静默执行 + public bool GetReturnPackage(ShopLoginInfo shop, bool isBack = false) { + bool isError = false; + if (defaultBitmap == null) defaultBitmap = new Bitmap(80, 80); @@ -61,7 +68,8 @@ namespace TemuKJD.KJDForms.ShopForms var dgvRows = this.dgvSelectProduct.Rows.Cast();//.Where(r => lstShopId.Contains(r.Cells["colShopId"].Value.ParseToString())); foreach (var row in dgvRows) { - row.Cells["colMessage"].Value = ""; + if (!isBack) + row.Cells["colMessage"].Value = ""; } pbLoading.Visible = true; @@ -69,8 +77,14 @@ namespace TemuKJD.KJDForms.ShopForms DateTime startTime = this.dtpStartDate.Value.Date; DateTime endTime = this.dtpEndDate.Value.Date.AddDays(1); + + if (isBack) + { + endTime = this.dtpEndDate.Value.Date.AddDays(1); + startTime = endTime.AddMonths(-1); + } cancellationTokenSource = new CancellationTokenSource(); - Task.Run(() => + var t = Task.Run(() => { int i = 0; while (endTime > startTime) @@ -82,13 +96,17 @@ namespace TemuKJD.KJDForms.ShopForms long startTimeTick = BaseClass.DateTimeToTimestampMilliseconds(midTime); long endTimeTick = BaseClass.DateTimeToTimestampMilliseconds(endTime) - 1; - this.Invoke(new Action(() => + if (!isBack) { - this.statusBar.lblTaskStatus.Text = "正在查询" + midTime.ToString(" yy年MM月dd日 至 ") + endTime.ToString("yy年MM月dd日 ") + "..."; - this.statusBar.pgbTaskProgress.Maximum = i + 1; - this.statusBar.UpdateProgressBar(i + 1); - i++; - })); + this.Invoke(new Action(() => + { + this.statusBar.lblTaskStatus.Text = "正在查询" + midTime.ToString(" yy年MM月dd日 至 ") + endTime.ToString("yy年MM月dd日 ") + "..."; + this.statusBar.pgbTaskProgress.Maximum = i + 1; + this.statusBar.UpdateProgressBar(i + 1); + + i++; + })); + } endTime = midTime; @@ -101,35 +119,43 @@ namespace TemuKJD.KJDForms.ShopForms #region 检测登录 if (shop.LoginStatus != "登录成功" || shop.LoginStatus2 != "国际版在线") { - Invoke(new Action(() => + if (!isBack) { - BaseMsgForm.ShowError("店铺掉线,请重新登录"); - })); + Invoke(new Action(() => + { + BaseMsgForm.ShowError("店铺掉线,请重新登录"); + })); + } return; } AdminForms.AdminShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false); if (shop.LoginStatus != "登录成功" || shop.LoginStatus2 != "国际版在线") { - Invoke(new Action(() => + if (!isBack) { - BaseMsgForm.ShowError("店铺掉线,请重新登录"); - })); + Invoke(new Action(() => + { + BaseMsgForm.ShowError("店铺掉线,请重新登录"); + })); + } return; } #endregion - Invoke(new Action(() => + if (!isBack) { - //var rows = this.dgvSelectProduct.Rows.Cast().Where(r => r.Cells["colShopId"].Value.ToString() == shop.ShopId); - //foreach (var row in rows) - //{ - // row.Cells["colMessage"].Value = "正在查询"; - //} - })); + Invoke(new Action(() => + { + //var rows = this.dgvSelectProduct.Rows.Cast().Where(r => r.Cells["colShopId"].Value.ToString() == shop.ShopId); + //foreach (var row in rows) + //{ + // row.Cells["colMessage"].Value = "正在查询"; + //} + })); + } int page = 0; int totalPage = 1; - bool isError = false; string errMsg = ""; List packageLstTmp = new List(); while (page < totalPage) @@ -144,8 +170,14 @@ namespace TemuKJD.KJDForms.ShopForms string jsonStr = GetReturnPackage(shop, startTimeTick, endTimeTick, page); if (jsonStr.Contains("指定的值含有无效的控制字符")) { - BaseMsgForm.ShowError("店铺" + shop.LoginName + " " + shop.ShopId + "已掉线"); isError = true; + if (!isBack) + { + Invoke(new Action(() => + { + BaseMsgForm.ShowError("店铺" + shop.LoginName + " " + shop.ShopId + "已掉线"); + })); + } break; } if (jsonStr.Contains("当前操作人数太多,请稍后重试") && tryCount < 5) @@ -175,7 +207,14 @@ namespace TemuKJD.KJDForms.ShopForms if (jArr == null) jArr = new JArray(); } - catch (Exception ex) { BaseMsgForm.ShowError(ex.Message); } + catch (Exception ex) + { + isError = true; + Invoke(new Action(() => + { + BaseMsgForm.ShowError(ex.Message); + })); + } foreach (var item in jArr) { @@ -229,17 +268,31 @@ namespace TemuKJD.KJDForms.ShopForms } } } - catch (Exception ex) { BaseMsgForm.ShowError(ex.Message); } + catch (Exception ex) + { + isError = true; + if (!isBack) + { + Invoke(new Action(() => + { + BaseMsgForm.ShowError(ex.Message); + })); + } + } } else { + isError = true; AdminForms.AdminShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false); if (shop.LoginStatus != "登录成功" || shop.LoginStatus2 != "国际版在线") { - Invoke(new Action(() => + if (!isBack) { - BaseMsgForm.ShowError("店铺掉线,请重新登录"); - })); + Invoke(new Action(() => + { + BaseMsgForm.ShowError("店铺掉线,请重新登录"); + })); + } //将查询到的数组内容清空掉,防止后续商品未获取到仍然匹配并往仓库后台服务端送 packageLstTmp.Clear(); break; @@ -296,7 +349,16 @@ namespace TemuKJD.KJDForms.ShopForms if (!string.IsNullOrWhiteSpace(imgUrl)) image = GetHtml.GetUrlImg(imgUrl, out getImgError); if (!string.IsNullOrEmpty(getImgError)) - BaseMsgForm.ShowError(getImgError); + { + isError = true; + if (!isBack) + { + Invoke(new Action(() => + { + BaseMsgForm.ShowError(getImgError); + })); + } + } string imgBase64 = ""; using (MemoryStream memoryStream = new MemoryStream()) { @@ -359,48 +421,67 @@ namespace TemuKJD.KJDForms.ShopForms else { rst = BaseRegex.GetStringJson(ref html, "msg"); + if ((rst.Contains("此退货包裹号") && rst.Contains("已经存在")) || rst.Contains("店铺系统不存在")) + { + //这些情况直接跳过 + } + else + { + isError = true; + } } - Invoke(new Action(() => + if (!isBack) { - int rowId = this.dgvSelectProduct.Rows.Add( - true, - //shop.ShopAccount, - pack.productSpuId, - pack.productSkuId, - imgUrl, - defaultBitmap, //image, // skc图片 - pack.productSkcId, - /*"①" +*/ pack.mainSaleSpec + " " + /*"②" +*/ pack.secondarySaleSpec, - pack.extCode, - pack.purchaseSubOrderSn, // 备货单号 - string.Join(",", pack.reasonDesc), - pack.packageSn, - pack.returnTotalNum, - pack.quantity, - BaseClass.StampToDateTime((pack.outboundTime.ParseToLong() / 1000).ParseToInt()), // 出库时间 - rst // 操作结果,状态 - ); + Invoke(new Action(() => + { + int rowId = this.dgvSelectProduct.Rows.Add( + true, + //shop.ShopAccount, + pack.productSpuId, + pack.productSkuId, + imgUrl, + defaultBitmap, //image, // skc图片 + pack.productSkcId, + /*"①" +*/ pack.mainSaleSpec + " " + /*"②" +*/ pack.secondarySaleSpec, + pack.extCode, + pack.purchaseSubOrderSn, // 备货单号 + string.Join(",", pack.reasonDesc), + pack.packageSn, + pack.returnTotalNum, + pack.quantity, + BaseClass.StampToDateTime((pack.outboundTime.ParseToLong() / 1000).ParseToInt()), // 出库时间 + rst // 操作结果,状态 + ); - dgvSelectProduct.Rows[rowId].Height = 60; - })); + dgvSelectProduct.Rows[rowId].Height = 60; + })); + } } lstReturnPackageInfo.AddRange(packageLst); - ShowDgvImg(); + if (!isBack) + ShowDgvImg(); } - Invoke(new Action(() => + if (!isBack) { - splitContainer1.Panel1.Enabled = true; - pbLoading.Visible = false; - string sRst = "已完成退货包裹明细查询!"; - if (cancellationTokenSource.IsCancellationRequested) - sRst = "已取消查询!"; + Invoke(new Action(() => + { + splitContainer1.Panel1.Enabled = true; + pbLoading.Visible = false; + string sRst = "已完成退货包裹明细查询!"; + if (cancellationTokenSource.IsCancellationRequested) + sRst = "已取消查询!"; - BaseMsgForm.ShowInfo(sRst); - this.statusBar.lblTaskStatus.Text = sRst; - })); + BaseMsgForm.ShowInfo(sRst); + this.statusBar.lblTaskStatus.Text = sRst; + })); + } }, cancellationTokenSource.Token); + if (isBack) + t.Wait(); + + return isError; } void ShowDgvImg() @@ -460,7 +541,7 @@ namespace TemuKJD.KJDForms.ShopForms page = Math.Max(page, 1); string url = "https://seller.kuajingmaihuo.com/dunland/api/gmp/returnSupplier/package/pageReturnPackageSkuDetailList"; string body; - body = @"{""outboundTimeStart"":" +startTime + @",""outboundTimeEnd"":" + endTime + @",""pageNo"":" + page + @",""pageSize"":200}"; + body = @"{""outboundTimeStart"":" + startTime + @",""outboundTimeEnd"":" + endTime + @",""pageNo"":" + page + @",""pageSize"":200}"; string refere = "https://seller.kuajingmaihuo.com/wms/stock-mgt/return-package-detail"; diff --git a/TEMUKJD/KJDForms/ShopForms/ShopLoginForm.Designer.cs b/TEMUKJD/KJDForms/ShopForms/ShopLoginForm.Designer.cs index 4468020..30a8c3f 100644 --- a/TEMUKJD/KJDForms/ShopForms/ShopLoginForm.Designer.cs +++ b/TEMUKJD/KJDForms/ShopForms/ShopLoginForm.Designer.cs @@ -30,6 +30,7 @@ { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ShopLoginForm)); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.btnReturnPackage = new TemuKJD.UserControls.ButtonEx(); this.btnLoginAgain = new TemuKJD.UserControls.ButtonEx(); this.pnlMultiLogin = new System.Windows.Forms.Panel(); this.cmbMultiCookieName = new DevComponents.DotNetBar.Controls.ComboBoxEx(); @@ -46,7 +47,6 @@ this.chkCloseAfterLogin = new DevComponents.DotNetBar.Controls.CheckBoxX(); this.splitContainer2 = new System.Windows.Forms.SplitContainer(); this.txtAddress = new System.Windows.Forms.TextBox(); - this.btnReturnPackage = new TemuKJD.UserControls.ButtonEx(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); @@ -83,10 +83,27 @@ this.splitContainer1.Panel2.Controls.Add(this.btnReload); this.splitContainer1.Panel2.Controls.Add(this.chkCloseAfterLogin); this.splitContainer1.Size = new System.Drawing.Size(1438, 736); - this.splitContainer1.SplitterDistance = 675; + this.splitContainer1.SplitterDistance = 676; this.splitContainer1.SplitterWidth = 3; this.splitContainer1.TabIndex = 4; // + // btnReturnPackage + // + this.btnReturnPackage.Anchor = System.Windows.Forms.AnchorStyles.Top; + this.btnReturnPackage.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255))))); + this.btnReturnPackage.Cursor = System.Windows.Forms.Cursors.Hand; + this.btnReturnPackage.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnReturnPackage.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btnReturnPackage.ForeColor = System.Drawing.Color.White; + this.btnReturnPackage.Location = new System.Drawing.Point(651, 28); + this.btnReturnPackage.Margin = new System.Windows.Forms.Padding(2); + this.btnReturnPackage.Name = "btnReturnPackage"; + this.btnReturnPackage.Size = new System.Drawing.Size(136, 25); + this.btnReturnPackage.TabIndex = 464; + this.btnReturnPackage.Text = "提交退货到库存管理"; + this.btnReturnPackage.UseVisualStyleBackColor = false; + this.btnReturnPackage.Click += new System.EventHandler(this.btnReturnPackage_Click); + // // btnLoginAgain // this.btnLoginAgain.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); @@ -330,23 +347,6 @@ this.txtAddress.TabIndex = 7; this.txtAddress.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtAddress_KeyDown); // - // btnReturnPackage - // - this.btnReturnPackage.Anchor = System.Windows.Forms.AnchorStyles.Top; - this.btnReturnPackage.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255))))); - this.btnReturnPackage.Cursor = System.Windows.Forms.Cursors.Hand; - this.btnReturnPackage.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnReturnPackage.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btnReturnPackage.ForeColor = System.Drawing.Color.White; - this.btnReturnPackage.Location = new System.Drawing.Point(651, 28); - this.btnReturnPackage.Margin = new System.Windows.Forms.Padding(2); - this.btnReturnPackage.Name = "btnReturnPackage"; - this.btnReturnPackage.Size = new System.Drawing.Size(136, 25); - this.btnReturnPackage.TabIndex = 464; - this.btnReturnPackage.Text = "提交退货到库存管理"; - this.btnReturnPackage.UseVisualStyleBackColor = false; - this.btnReturnPackage.Click += new System.EventHandler(this.btnReturnPackage_Click); - // // ShopLoginForm // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; @@ -378,7 +378,6 @@ #endregion private System.Windows.Forms.SplitContainer splitContainer1; - private DevComponents.DotNetBar.Controls.CheckBoxX chkCloseAfterLogin; private UserControls.ButtonEx btnStop; private UserControls.ButtonEx btnReload; private System.Windows.Forms.TextBox txtPassWord; @@ -395,5 +394,6 @@ private System.Windows.Forms.Panel pnlMultiLogin; private UserControls.ButtonEx btnLoginAgain; private UserControls.ButtonEx btnReturnPackage; + public DevComponents.DotNetBar.Controls.CheckBoxX chkCloseAfterLogin; } } \ No newline at end of file diff --git a/TEMUKJD/KJDForms/ShopForms/Statistics/ShopStatisticsForm.Designer.cs b/TEMUKJD/KJDForms/ShopForms/Statistics/ShopStatisticsForm.Designer.cs index 09767c8..85542af 100644 --- a/TEMUKJD/KJDForms/ShopForms/Statistics/ShopStatisticsForm.Designer.cs +++ b/TEMUKJD/KJDForms/ShopForms/Statistics/ShopStatisticsForm.Designer.cs @@ -30,21 +30,21 @@ namespace TemuKJD.KJDForms.ShopForms private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.ucGroupBoxEx3 = new TemuKJD.UserComponent.UcGroupBoxEx(this.components); this.btnGetNotGet = new DevComponents.DotNetBar.PanelEx(); this.btnGetSelect = new DevComponents.DotNetBar.PanelEx(); this.ucGroupBoxEx1 = new TemuKJD.UserComponent.UcGroupBoxEx(this.components); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); - this.label16 = new System.Windows.Forms.Label(); - this.label15 = new System.Windows.Forms.Label(); - this.label14 = new System.Windows.Forms.Label(); - this.label13 = new System.Windows.Forms.Label(); - this.label12 = new System.Windows.Forms.Label(); - this.label11 = new System.Windows.Forms.Label(); - this.label10 = new System.Windows.Forms.Label(); + this.lblWithdrawCashAmount = new System.Windows.Forms.Label(); + this.lblAvailableBalance = new System.Windows.Forms.Label(); + this.lblMallDepositLimitAmount = new System.Windows.Forms.Label(); + this.lblLastMonthIncomeAmount = new System.Windows.Forms.Label(); + this.lblThisMonthIncomeAmount = new System.Windows.Forms.Label(); + this.lblYesterdayIncomeAmount = new System.Windows.Forms.Label(); + this.lblSevenDaysSaleVolume = new System.Windows.Forms.Label(); this.label8 = new System.Windows.Forms.Label(); this.label7 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); @@ -53,11 +53,10 @@ namespace TemuKJD.KJDForms.ShopForms this.label3 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); - this.label9 = new System.Windows.Forms.Label(); + this.lblSaleVolume = new System.Windows.Forms.Label(); this.splitContainer2 = new System.Windows.Forms.SplitContainer(); this.pbLoading = new System.Windows.Forms.PictureBox(); this.dgvShop = new TemuKJD.UserComponent.DataGridViewEx(); - this.statusBar = new TemuKJD.UserControls.StatusBarUserControl(); this.colSelect = new System.Windows.Forms.DataGridViewCheckBoxColumn(); this.colLoginStatus = new System.Windows.Forms.DataGridViewLinkColumn(); this.colShopLoginName = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -70,11 +69,13 @@ namespace TemuKJD.KJDForms.ShopForms this.colHighPriceLimitNumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.colAboutToSellOutNumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.colAdvicePrepareSkcNumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.colYesterdayAmountReceived = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.colThisMonthAmountReceived = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.colLastMonthAmountReceived = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.colBalance = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.colBond = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.colYesterdayIncomeAmount = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.colThisMonthIncomeAmount = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.colLastMonthIncomeAmount = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.colAvailableBalance = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.colMallDepositLimitAmount = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.colWithdrawCashAmount = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.statusBar = new TemuKJD.UserControls.StatusBarUserControl(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); @@ -150,6 +151,7 @@ namespace TemuKJD.KJDForms.ShopForms this.btnGetNotGet.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255))))); this.btnGetNotGet.TabIndex = 431; this.btnGetNotGet.Text = "查询未获取"; + this.btnGetNotGet.Click += new System.EventHandler(this.btnGetNotGet_Click); // // btnGetSelect // @@ -174,6 +176,7 @@ namespace TemuKJD.KJDForms.ShopForms this.btnGetSelect.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255))))); this.btnGetSelect.TabIndex = 427; this.btnGetSelect.Text = "查询选中"; + this.btnGetSelect.Click += new System.EventHandler(this.btnGetSelect_Click); // // ucGroupBoxEx1 // @@ -202,13 +205,13 @@ namespace TemuKJD.KJDForms.ShopForms this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 10F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 13F)); - this.tableLayoutPanel1.Controls.Add(this.label16, 3, 3); - this.tableLayoutPanel1.Controls.Add(this.label15, 2, 3); - this.tableLayoutPanel1.Controls.Add(this.label14, 1, 3); - this.tableLayoutPanel1.Controls.Add(this.label13, 0, 3); - this.tableLayoutPanel1.Controls.Add(this.label12, 3, 1); - this.tableLayoutPanel1.Controls.Add(this.label11, 2, 1); - this.tableLayoutPanel1.Controls.Add(this.label10, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.lblWithdrawCashAmount, 3, 3); + this.tableLayoutPanel1.Controls.Add(this.lblAvailableBalance, 2, 3); + this.tableLayoutPanel1.Controls.Add(this.lblMallDepositLimitAmount, 1, 3); + this.tableLayoutPanel1.Controls.Add(this.lblLastMonthIncomeAmount, 0, 3); + this.tableLayoutPanel1.Controls.Add(this.lblThisMonthIncomeAmount, 3, 1); + this.tableLayoutPanel1.Controls.Add(this.lblYesterdayIncomeAmount, 2, 1); + this.tableLayoutPanel1.Controls.Add(this.lblSevenDaysSaleVolume, 1, 1); this.tableLayoutPanel1.Controls.Add(this.label8, 3, 2); this.tableLayoutPanel1.Controls.Add(this.label7, 2, 2); this.tableLayoutPanel1.Controls.Add(this.label6, 1, 2); @@ -217,7 +220,7 @@ namespace TemuKJD.KJDForms.ShopForms this.tableLayoutPanel1.Controls.Add(this.label3, 2, 0); this.tableLayoutPanel1.Controls.Add(this.label2, 1, 0); this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0); - this.tableLayoutPanel1.Controls.Add(this.label9, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.lblSaleVolume, 0, 1); this.tableLayoutPanel1.Location = new System.Drawing.Point(31, 19); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; this.tableLayoutPanel1.RowCount = 4; @@ -228,82 +231,82 @@ namespace TemuKJD.KJDForms.ShopForms this.tableLayoutPanel1.Size = new System.Drawing.Size(1253, 115); this.tableLayoutPanel1.TabIndex = 435; // - // label16 + // lblWithdrawCashAmount // - this.label16.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.label16.AutoSize = true; - this.label16.Font = new System.Drawing.Font("微软雅黑", 11F); - this.label16.Location = new System.Drawing.Point(924, 87); - this.label16.Name = "label16"; - this.label16.Size = new System.Drawing.Size(18, 20); - this.label16.TabIndex = 15; - this.label16.Text = "0"; + this.lblWithdrawCashAmount.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.lblWithdrawCashAmount.AutoSize = true; + this.lblWithdrawCashAmount.Font = new System.Drawing.Font("微软雅黑", 11F); + this.lblWithdrawCashAmount.Location = new System.Drawing.Point(924, 87); + this.lblWithdrawCashAmount.Name = "lblWithdrawCashAmount"; + this.lblWithdrawCashAmount.Size = new System.Drawing.Size(18, 20); + this.lblWithdrawCashAmount.TabIndex = 15; + this.lblWithdrawCashAmount.Text = "0"; // - // label15 + // lblAvailableBalance // - this.label15.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.label15.AutoSize = true; - this.label15.Font = new System.Drawing.Font("微软雅黑", 11F); - this.label15.Location = new System.Drawing.Point(617, 87); - this.label15.Name = "label15"; - this.label15.Size = new System.Drawing.Size(18, 20); - this.label15.TabIndex = 15; - this.label15.Text = "0"; + this.lblAvailableBalance.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.lblAvailableBalance.AutoSize = true; + this.lblAvailableBalance.Font = new System.Drawing.Font("微软雅黑", 11F); + this.lblAvailableBalance.Location = new System.Drawing.Point(617, 87); + this.lblAvailableBalance.Name = "lblAvailableBalance"; + this.lblAvailableBalance.Size = new System.Drawing.Size(18, 20); + this.lblAvailableBalance.TabIndex = 15; + this.lblAvailableBalance.Text = "0"; // - // label14 + // lblMallDepositLimitAmount // - this.label14.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.label14.AutoSize = true; - this.label14.Font = new System.Drawing.Font("微软雅黑", 11F); - this.label14.Location = new System.Drawing.Point(310, 87); - this.label14.Name = "label14"; - this.label14.Size = new System.Drawing.Size(18, 20); - this.label14.TabIndex = 15; - this.label14.Text = "0"; + this.lblMallDepositLimitAmount.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.lblMallDepositLimitAmount.AutoSize = true; + this.lblMallDepositLimitAmount.Font = new System.Drawing.Font("微软雅黑", 11F); + this.lblMallDepositLimitAmount.Location = new System.Drawing.Point(310, 87); + this.lblMallDepositLimitAmount.Name = "lblMallDepositLimitAmount"; + this.lblMallDepositLimitAmount.Size = new System.Drawing.Size(18, 20); + this.lblMallDepositLimitAmount.TabIndex = 15; + this.lblMallDepositLimitAmount.Text = "0"; // - // label13 + // lblLastMonthIncomeAmount // - this.label13.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.label13.AutoSize = true; - this.label13.Font = new System.Drawing.Font("微软雅黑", 11F); - this.label13.Location = new System.Drawing.Point(3, 87); - this.label13.Name = "label13"; - this.label13.Size = new System.Drawing.Size(18, 20); - this.label13.TabIndex = 15; - this.label13.Text = "0"; + this.lblLastMonthIncomeAmount.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.lblLastMonthIncomeAmount.AutoSize = true; + this.lblLastMonthIncomeAmount.Font = new System.Drawing.Font("微软雅黑", 11F); + this.lblLastMonthIncomeAmount.Location = new System.Drawing.Point(3, 87); + this.lblLastMonthIncomeAmount.Name = "lblLastMonthIncomeAmount"; + this.lblLastMonthIncomeAmount.Size = new System.Drawing.Size(18, 20); + this.lblLastMonthIncomeAmount.TabIndex = 15; + this.lblLastMonthIncomeAmount.Text = "0"; // - // label12 + // lblThisMonthIncomeAmount // - this.label12.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.label12.AutoSize = true; - this.label12.Font = new System.Drawing.Font("微软雅黑", 11F); - this.label12.Location = new System.Drawing.Point(924, 30); - this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(18, 20); - this.label12.TabIndex = 15; - this.label12.Text = "0"; + this.lblThisMonthIncomeAmount.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.lblThisMonthIncomeAmount.AutoSize = true; + this.lblThisMonthIncomeAmount.Font = new System.Drawing.Font("微软雅黑", 11F); + this.lblThisMonthIncomeAmount.Location = new System.Drawing.Point(924, 30); + this.lblThisMonthIncomeAmount.Name = "lblThisMonthIncomeAmount"; + this.lblThisMonthIncomeAmount.Size = new System.Drawing.Size(18, 20); + this.lblThisMonthIncomeAmount.TabIndex = 15; + this.lblThisMonthIncomeAmount.Text = "0"; // - // label11 + // lblYesterdayIncomeAmount // - this.label11.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.label11.AutoSize = true; - this.label11.Font = new System.Drawing.Font("微软雅黑", 11F); - this.label11.Location = new System.Drawing.Point(617, 30); - this.label11.Name = "label11"; - this.label11.Size = new System.Drawing.Size(18, 20); - this.label11.TabIndex = 15; - this.label11.Text = "0"; + this.lblYesterdayIncomeAmount.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.lblYesterdayIncomeAmount.AutoSize = true; + this.lblYesterdayIncomeAmount.Font = new System.Drawing.Font("微软雅黑", 11F); + this.lblYesterdayIncomeAmount.Location = new System.Drawing.Point(617, 30); + this.lblYesterdayIncomeAmount.Name = "lblYesterdayIncomeAmount"; + this.lblYesterdayIncomeAmount.Size = new System.Drawing.Size(18, 20); + this.lblYesterdayIncomeAmount.TabIndex = 15; + this.lblYesterdayIncomeAmount.Text = "0"; // - // label10 + // lblSevenDaysSaleVolume // - this.label10.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.label10.AutoSize = true; - this.label10.Font = new System.Drawing.Font("微软雅黑", 11F); - this.label10.Location = new System.Drawing.Point(310, 30); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(18, 20); - this.label10.TabIndex = 15; - this.label10.Text = "0"; + this.lblSevenDaysSaleVolume.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.lblSevenDaysSaleVolume.AutoSize = true; + this.lblSevenDaysSaleVolume.Font = new System.Drawing.Font("微软雅黑", 11F); + this.lblSevenDaysSaleVolume.Location = new System.Drawing.Point(310, 30); + this.lblSevenDaysSaleVolume.Name = "lblSevenDaysSaleVolume"; + this.lblSevenDaysSaleVolume.Size = new System.Drawing.Size(18, 20); + this.lblSevenDaysSaleVolume.TabIndex = 15; + this.lblSevenDaysSaleVolume.Text = "0"; // // label8 // @@ -393,21 +396,22 @@ namespace TemuKJD.KJDForms.ShopForms this.label1.TabIndex = 0; this.label1.Text = "今日销量"; // - // label9 + // lblSaleVolume // - this.label9.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.label9.AutoSize = true; - this.label9.Font = new System.Drawing.Font("微软雅黑", 11F); - this.label9.Location = new System.Drawing.Point(3, 30); - this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(18, 20); - this.label9.TabIndex = 14; - this.label9.Text = "0"; + this.lblSaleVolume.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.lblSaleVolume.AutoSize = true; + this.lblSaleVolume.Font = new System.Drawing.Font("微软雅黑", 11F); + this.lblSaleVolume.Location = new System.Drawing.Point(3, 30); + this.lblSaleVolume.Name = "lblSaleVolume"; + this.lblSaleVolume.Size = new System.Drawing.Size(18, 20); + this.lblSaleVolume.TabIndex = 14; + this.lblSaleVolume.Text = "0"; // // splitContainer2 // this.splitContainer2.BackColor = System.Drawing.Color.White; this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer2.FixedPanel = System.Windows.Forms.FixedPanel.Panel2; this.splitContainer2.Location = new System.Drawing.Point(0, 0); this.splitContainer2.Name = "splitContainer2"; this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal; @@ -423,14 +427,14 @@ namespace TemuKJD.KJDForms.ShopForms // this.splitContainer2.Panel2.Controls.Add(this.statusBar); this.splitContainer2.Size = new System.Drawing.Size(1438, 456); - this.splitContainer2.SplitterDistance = 422; + this.splitContainer2.SplitterDistance = 426; this.splitContainer2.TabIndex = 0; // // pbLoading // this.pbLoading.Anchor = System.Windows.Forms.AnchorStyles.None; this.pbLoading.Image = global::TemuKJD.Properties.Resources.loading_blue; - this.pbLoading.Location = new System.Drawing.Point(694, 186); + this.pbLoading.Location = new System.Drawing.Point(694, 188); this.pbLoading.Name = "pbLoading"; this.pbLoading.Size = new System.Drawing.Size(50, 50); this.pbLoading.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; @@ -442,19 +446,19 @@ namespace TemuKJD.KJDForms.ShopForms // this.dgvShop.AllowUserToAddRows = false; this.dgvShop.AllowUserToDeleteRows = false; - dataGridViewCellStyle1.BackColor = System.Drawing.Color.WhiteSmoke; - this.dgvShop.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; + dataGridViewCellStyle3.BackColor = System.Drawing.Color.WhiteSmoke; + this.dgvShop.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3; this.dgvShop.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dgvShop.BackgroundColor = System.Drawing.Color.White; this.dgvShop.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255))))); - dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.dgvShop.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2; + dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dgvShop.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4; this.dgvShop.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvShop.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.colSelect, @@ -469,30 +473,21 @@ namespace TemuKJD.KJDForms.ShopForms this.colHighPriceLimitNumber, this.colAboutToSellOutNumber, this.colAdvicePrepareSkcNumber, - this.colYesterdayAmountReceived, - this.colThisMonthAmountReceived, - this.colLastMonthAmountReceived, - this.colBalance, - this.colBond}); + this.colYesterdayIncomeAmount, + this.colThisMonthIncomeAmount, + this.colLastMonthIncomeAmount, + this.colAvailableBalance, + this.colMallDepositLimitAmount, + this.colWithdrawCashAmount}); this.dgvShop.Dock = System.Windows.Forms.DockStyle.Fill; this.dgvShop.Location = new System.Drawing.Point(4, 0); this.dgvShop.Name = "dgvShop"; this.dgvShop.ReadOnly = true; this.dgvShop.RowHeadersWidth = 36; this.dgvShop.RowTemplate.Height = 23; - this.dgvShop.Size = new System.Drawing.Size(1430, 422); + this.dgvShop.Size = new System.Drawing.Size(1430, 426); this.dgvShop.TabIndex = 5; - // - // statusBar - // - this.statusBar.BackColor = System.Drawing.Color.White; - this.statusBar.Dock = System.Windows.Forms.DockStyle.Bottom; - this.statusBar.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.statusBar.Location = new System.Drawing.Point(0, 1); - this.statusBar.Margin = new System.Windows.Forms.Padding(0); - this.statusBar.Name = "statusBar"; - this.statusBar.Size = new System.Drawing.Size(1438, 29); - this.statusBar.TabIndex = 1; + this.dgvShop.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvShop_CellContentClick); // // colSelect // @@ -572,35 +567,52 @@ namespace TemuKJD.KJDForms.ShopForms this.colAdvicePrepareSkcNumber.Name = "colAdvicePrepareSkcNumber"; this.colAdvicePrepareSkcNumber.ReadOnly = true; // - // colYesterdayAmountReceived + // colYesterdayIncomeAmount // - this.colYesterdayAmountReceived.HeaderText = "昨日到账金额"; - this.colYesterdayAmountReceived.Name = "colYesterdayAmountReceived"; - this.colYesterdayAmountReceived.ReadOnly = true; + this.colYesterdayIncomeAmount.HeaderText = "昨日到账金额"; + this.colYesterdayIncomeAmount.Name = "colYesterdayIncomeAmount"; + this.colYesterdayIncomeAmount.ReadOnly = true; // - // colThisMonthAmountReceived + // colThisMonthIncomeAmount // - this.colThisMonthAmountReceived.HeaderText = "本月到账金额"; - this.colThisMonthAmountReceived.Name = "colThisMonthAmountReceived"; - this.colThisMonthAmountReceived.ReadOnly = true; + this.colThisMonthIncomeAmount.HeaderText = "本月到账金额"; + this.colThisMonthIncomeAmount.Name = "colThisMonthIncomeAmount"; + this.colThisMonthIncomeAmount.ReadOnly = true; // - // colLastMonthAmountReceived + // colLastMonthIncomeAmount // - this.colLastMonthAmountReceived.HeaderText = "上月到账金额"; - this.colLastMonthAmountReceived.Name = "colLastMonthAmountReceived"; - this.colLastMonthAmountReceived.ReadOnly = true; + this.colLastMonthIncomeAmount.HeaderText = "上月到账金额"; + this.colLastMonthIncomeAmount.Name = "colLastMonthIncomeAmount"; + this.colLastMonthIncomeAmount.ReadOnly = true; // - // colBalance + // colAvailableBalance // - this.colBalance.HeaderText = "可用余额"; - this.colBalance.Name = "colBalance"; - this.colBalance.ReadOnly = true; + this.colAvailableBalance.HeaderText = "可提现余额"; + this.colAvailableBalance.Name = "colAvailableBalance"; + this.colAvailableBalance.ReadOnly = true; // - // colBond + // colMallDepositLimitAmount // - this.colBond.HeaderText = "账户预留金额"; - this.colBond.Name = "colBond"; - this.colBond.ReadOnly = true; + this.colMallDepositLimitAmount.HeaderText = "账户预留金额"; + this.colMallDepositLimitAmount.Name = "colMallDepositLimitAmount"; + this.colMallDepositLimitAmount.ReadOnly = true; + // + // colWithdrawCashAmount + // + this.colWithdrawCashAmount.HeaderText = "提现总金额"; + this.colWithdrawCashAmount.Name = "colWithdrawCashAmount"; + this.colWithdrawCashAmount.ReadOnly = true; + // + // statusBar + // + this.statusBar.BackColor = System.Drawing.Color.White; + this.statusBar.Dock = System.Windows.Forms.DockStyle.Fill; + this.statusBar.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.statusBar.Location = new System.Drawing.Point(0, 0); + this.statusBar.Margin = new System.Windows.Forms.Padding(0); + this.statusBar.Name = "statusBar"; + this.statusBar.Size = new System.Drawing.Size(1438, 26); + this.statusBar.TabIndex = 1; // // ShopStatisticsForm // @@ -650,14 +662,14 @@ namespace TemuKJD.KJDForms.ShopForms private System.Windows.Forms.Label label7; private System.Windows.Forms.Label label6; private System.Windows.Forms.Label label5; - private System.Windows.Forms.Label label9; - private System.Windows.Forms.Label label16; - private System.Windows.Forms.Label label15; - private System.Windows.Forms.Label label14; - private System.Windows.Forms.Label label13; - private System.Windows.Forms.Label label12; - private System.Windows.Forms.Label label11; - private System.Windows.Forms.Label label10; + private System.Windows.Forms.Label lblSaleVolume; + private System.Windows.Forms.Label lblWithdrawCashAmount; + private System.Windows.Forms.Label lblAvailableBalance; + private System.Windows.Forms.Label lblMallDepositLimitAmount; + private System.Windows.Forms.Label lblLastMonthIncomeAmount; + private System.Windows.Forms.Label lblThisMonthIncomeAmount; + private System.Windows.Forms.Label lblYesterdayIncomeAmount; + private System.Windows.Forms.Label lblSevenDaysSaleVolume; private System.Windows.Forms.DataGridViewCheckBoxColumn colSelect; private System.Windows.Forms.DataGridViewLinkColumn colLoginStatus; private System.Windows.Forms.DataGridViewTextBoxColumn colShopLoginName; @@ -670,10 +682,11 @@ namespace TemuKJD.KJDForms.ShopForms private System.Windows.Forms.DataGridViewTextBoxColumn colHighPriceLimitNumber; private System.Windows.Forms.DataGridViewTextBoxColumn colAboutToSellOutNumber; private System.Windows.Forms.DataGridViewTextBoxColumn colAdvicePrepareSkcNumber; - private System.Windows.Forms.DataGridViewTextBoxColumn colYesterdayAmountReceived; - private System.Windows.Forms.DataGridViewTextBoxColumn colThisMonthAmountReceived; - private System.Windows.Forms.DataGridViewTextBoxColumn colLastMonthAmountReceived; - private System.Windows.Forms.DataGridViewTextBoxColumn colBalance; - private System.Windows.Forms.DataGridViewTextBoxColumn colBond; + private System.Windows.Forms.DataGridViewTextBoxColumn colYesterdayIncomeAmount; + private System.Windows.Forms.DataGridViewTextBoxColumn colThisMonthIncomeAmount; + private System.Windows.Forms.DataGridViewTextBoxColumn colLastMonthIncomeAmount; + private System.Windows.Forms.DataGridViewTextBoxColumn colAvailableBalance; + private System.Windows.Forms.DataGridViewTextBoxColumn colMallDepositLimitAmount; + private System.Windows.Forms.DataGridViewTextBoxColumn colWithdrawCashAmount; } } \ No newline at end of file diff --git a/TEMUKJD/KJDForms/ShopForms/Statistics/ShopStatisticsForm.cs b/TEMUKJD/KJDForms/ShopForms/Statistics/ShopStatisticsForm.cs index 2aaf2d5..2629f73 100644 --- a/TEMUKJD/KJDForms/ShopForms/Statistics/ShopStatisticsForm.cs +++ b/TEMUKJD/KJDForms/ShopForms/Statistics/ShopStatisticsForm.cs @@ -1,6 +1,8 @@ -using AllBase.Helper; +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; @@ -11,11 +13,16 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using TemuKJD.Extension; +using TemuKJD.KJDForms.BaseForms; namespace TemuKJD.KJDForms.ShopForms { public partial class ShopStatisticsForm : Form { + public List lstShopStatisticsInfo = new List(); + public bool IsOperate = false; + public bool isFirstLoad = false; + public ShopStatisticsForm() { InitializeComponent(); @@ -23,7 +30,7 @@ namespace TemuKJD.KJDForms.ShopForms private void ShopStatisticsForm_Load(object sender, EventArgs e) { - + this.dgvShop.AddSelectorColumn("colSelect"); } private void ShopStatisticsForm_VisibleChanged(object sender, EventArgs e) @@ -34,6 +41,7 @@ namespace TemuKJD.KJDForms.ShopForms private void RefreshShop() { + this.pbLoading.Visible = true; // 店铺Id var selectIds = dgvShop.Rows.Cast().Where(row => row.Cells["colSelect"]?.Value.ParseToBool() == true).Select(r => r.Cells["colShopId"]?.Value.ToString()).ToList(); @@ -45,12 +53,70 @@ namespace TemuKJD.KJDForms.ShopForms { dgvShop.Rows.Remove(row); } - // 绑定其他店铺(含新导入的店铺) + // 获取被删除的统计信息并删除 + List statisticsDeleteLst = lstShopStatisticsInfo.Where(row + => !GlobalConfig.ShopLoginList.Any(s => s.ShopId == row.shop_id.ToString())).ToList(); + foreach (var s in statisticsDeleteLst) + { + lstShopStatisticsInfo.Remove(s); + } + + // 绑定店铺(含新导入的店铺) foreach (ShopLoginInfo shopEntity in GlobalConfig.ShopLoginList) { if (!string.IsNullOrEmpty(shopEntity.ShopId)) BindShop(shopEntity, selectIds); } + + GetShopStatistics(GlobalConfig.ShopLoginList.ToList(), selectIds); + } + + private void GetShopStatistics(List shops, List selectIds) + { + Task.Run(() => + { + foreach (ShopLoginInfo shopEntity in shops) + { + if (string.IsNullOrEmpty(shopEntity.ShopId)) + continue; + bool canUse = shopEntity.LoginStatus == "登录成功" && shopEntity.LoginStatus2 == "国际版在线"; + if (!canUse) + { + BindShop(shopEntity, selectIds); + continue; + } + + ShopStatisticsInfo statistics = lstShopStatisticsInfo.FirstOrDefault(s => s.shop_id.ToString() == shopEntity.ShopId); + if (statistics == null) + { + statistics = new ShopStatisticsInfo() + { + notes = shopEntity.Notes, + shop_id = shopEntity.ShopId.ParseToLong(), + shop_account = shopEntity.ShopAccount, + }; + lstShopStatisticsInfo.Add(statistics); + } + GetShopStatistics(shopEntity, statistics); + Invoke(new Action(() => + { + this.lblSaleVolume.Text = this.lstShopStatisticsInfo.Sum(s => s.saleVolume).ToString(); + this.lblSevenDaysSaleVolume.Text = this.lstShopStatisticsInfo.Sum(s => s.sevenDaysSaleVolume).ToString(); + this.lblYesterdayIncomeAmount.Text = this.lstShopStatisticsInfo.Sum(s => s.yesterdayIncomeAmount).ToString(); + this.lblThisMonthIncomeAmount.Text = this.lstShopStatisticsInfo.Sum(s => s.thisMonthIncomeAmount).ToString(); + this.lblLastMonthIncomeAmount.Text = this.lstShopStatisticsInfo.Sum(s => s.lastMonthIncomeAmount).ToString(); + + this.lblAvailableBalance.Text = this.lstShopStatisticsInfo.Sum(s => s.availableBalance).ToString(); + this.lblMallDepositLimitAmount.Text = this.lstShopStatisticsInfo.Sum(s => s.mallDepositLimitAmount).ToString(); + this.lblWithdrawCashAmount.Text = this.lstShopStatisticsInfo.Sum(s => s.withdrawCashAmount).ToString(); + BindShop(shopEntity, selectIds); + })); + } + Invoke(new Action(() => + { + this.pbLoading.Visible = false; + })); + }); } private void BindShop(ShopLoginInfo shopEntity, List selectShopId = null) @@ -60,24 +126,48 @@ namespace TemuKJD.KJDForms.ShopForms if (selectShopId == null) selectShopId = new List(); + ShopStatisticsInfo statistics = lstShopStatisticsInfo.FirstOrDefault(s => s.shop_id.ToString() == shopEntity.ShopId); + if (statistics == null) + { + statistics = new ShopStatisticsInfo() + { + notes = shopEntity.Notes, + shop_id = shopEntity.ShopId.ParseToLong(), + shop_account = shopEntity.ShopAccount, + }; + lstShopStatisticsInfo.Add(statistics); + } + bool canUse = shopEntity.LoginStatus == "登录成功" && shopEntity.LoginStatus2 == "国际版在线"; var row = dgvShop.Rows.Cast().FirstOrDefault( p => p.Cells.GetCellValueFromColumnName("colShopId").ParseToString() == shopEntity.ShopId); if (row == null) { - int id = this.dgvShop.Rows.Add( - true && canUse, + int rowId = this.dgvShop.Rows.Add( + false, canUse ? "在线" : "掉线", shopEntity.LoginName, shopEntity.ShopId, shopEntity.ShopAccount, shopEntity.Notes, - string.Empty + statistics.onSaleProductNumber == null ? "-" : statistics.onSaleProductNumber.ToString(), //在售商品数 + statistics.saleVolume == null ? "-" : statistics.saleVolume.ToString(), //今日销量 + statistics.sevenDaysSaleVolume == null ? "-" : statistics.sevenDaysSaleVolume.ToString(), //7日销量 + statistics.highPriceLimitNumber == null ? "-" : statistics.highPriceLimitNumber.ToString(), //高价限流商品数 + statistics.aboutToSellOutNumber == null ? "-" : statistics.aboutToSellOutNumber.ToString(), //即将售罄 + statistics.advicePrepareSkcNumber == null ? "-" : statistics.advicePrepareSkcNumber.ToString(), //建议备货 + statistics.yesterdayIncomeAmount, + statistics.thisMonthIncomeAmount, + statistics.lastMonthIncomeAmount, + statistics.availableBalance, + statistics.mallDepositLimitAmount, + statistics.withdrawCashAmount ); - row = dgvShop.Rows[id]; + row = dgvShop.Rows[rowId]; (row.Cells["colLoginStatus"] as DataGridViewLinkCell).Style.ForeColor = canUse ? Color.Green : Color.Red; (row.Cells["colLoginStatus"] as DataGridViewLinkCell).LinkColor = canUse ? Color.Green : Color.Red; - (row.Cells["colLoginStatus"] as DataGridViewLinkCell).ActiveLinkColor = canUse ? Color.Green : Color.Red; + (row.Cells["colLoginStatus"] as DataGridViewLinkCell).ActiveLinkColor = canUse ? Color.LightGreen : Color.OrangeRed; + (row.Cells["colLoginStatus"] as DataGridViewLinkCell).VisitedLinkColor = canUse ? Color.DarkGreen : Color.DarkRed; row.Height = 32; } else @@ -86,27 +176,354 @@ namespace TemuKJD.KJDForms.ShopForms row.Cells["colLoginStatus"].Value = canUse ? "在线" : "掉线"; (row.Cells["colLoginStatus"] as DataGridViewLinkCell).Style.ForeColor = canUse ? Color.Green : Color.Red; (row.Cells["colLoginStatus"] as DataGridViewLinkCell).LinkColor = canUse ? Color.Green : Color.Red; - (row.Cells["colLoginStatus"] as DataGridViewLinkCell).ActiveLinkColor = canUse ? Color.Green : Color.Red; + (row.Cells["colLoginStatus"] as DataGridViewLinkCell).ActiveLinkColor = canUse ? Color.LightGreen : Color.OrangeRed; + (row.Cells["colLoginStatus"] as DataGridViewLinkCell).VisitedLinkColor = canUse ? Color.DarkGreen : Color.DarkRed; row.Cells["colShopLoginName"].Value = shopEntity.LoginName; - row.Cells["colShopName"].Value = shopEntity.ShopAccount; - row.Cells["colShopNotes"].Value = shopEntity.Notes; + row.Cells["colShopAccount"].Value = shopEntity.ShopAccount; + row.Cells["colNotes"].Value = shopEntity.Notes; + row.Cells["colOnSaleProductNumber"].Value = statistics.onSaleProductNumber == null ? "-" : statistics.onSaleProductNumber.ToString(); //在售商品数 + row.Cells["colSaleVolume"].Value = statistics.saleVolume == null ? "-" : statistics.saleVolume.ToString(); //今日销量 + row.Cells["colSevenDaysSaleVolume"].Value = statistics.sevenDaysSaleVolume == null ? "-" : statistics.sevenDaysSaleVolume.ToString(); //7日销量 + row.Cells["colHighPriceLimitNumber"].Value = statistics.highPriceLimitNumber == null ? "-" : statistics.highPriceLimitNumber.ToString(); //高价限流商品数 + row.Cells["colAboutToSellOutNumber"].Value = statistics.aboutToSellOutNumber == null ? "-" : statistics.aboutToSellOutNumber.ToString(); //即将售罄 + row.Cells["colAdvicePrepareSkcNumber"].Value = statistics.advicePrepareSkcNumber == null ? "-" : statistics.advicePrepareSkcNumber.ToString(); //建议备货 + + row.Cells["colYesterdayIncomeAmount"].Value = statistics.yesterdayIncomeAmount; + row.Cells["colThisMonthIncomeAmount"].Value = statistics.thisMonthIncomeAmount; + row.Cells["colLastMonthIncomeAmount"].Value = statistics.lastMonthIncomeAmount; + + row.Cells["colAvailableBalance"].Value = statistics.availableBalance; + row.Cells["colMallDepositLimitAmount"].Value = statistics.mallDepositLimitAmount; + row.Cells["colWithdrawCashAmount"].Value = statistics.withdrawCashAmount; } } - private string GetMainStatistics(ShopLoginInfo shop, List adjustIdList, string refuseReason) + private void GetShopStatistics(ShopLoginInfo shop, ShopStatisticsInfo statistics, List selectShopId = null) + { + if (statistics.is_search_1 != true) + { + try + { + string html = GetMainStatistics(shop); + if (html.Contains("\"success\":true")) + { + statistics.aboutToSellOutNumber = BaseRegex.GetNullableIntJson(ref html, "aboutToSellOutNumber"); + statistics.adjustPrice = BaseRegex.GetNullableIntJson(ref html, "adjustPrice"); + statistics.advicePrepareSkcNumber = BaseRegex.GetNullableIntJson(ref html, "advicePrepareSkcNumber"); + statistics.alreadySoldOutNumber = BaseRegex.GetNullableIntJson(ref html, "alreadySoldOutNumber"); + statistics.havePublishProduct = BaseRegex.GetNullableBoolJson(ref html, "havePublishProduct"); + statistics.highPriceLimitNumber = BaseRegex.GetNullableIntJson(ref html, "highPriceLimitNumber"); + statistics.lackSkcNumber = BaseRegex.GetNullableIntJson(ref html, "lackSkcNumber"); + statistics.onSaleProductNumber = BaseRegex.GetNullableIntJson(ref html, "onSaleProductNumber"); + statistics.qualityAfterSaleRatio90d = BaseRegex.GetNullableIntJson(ref html, "qualityAfterSaleRatio90d"); + statistics.reviewAdjustPrice = BaseRegex.GetNullableIntJson(ref html, "reviewAdjustPrice"); + statistics.saleVolume = BaseRegex.GetNullableIntJson(ref html, "saleVolume"); + statistics.sevenDaysSaleVolume = BaseRegex.GetNullableIntJson(ref html, "sevenDaysSaleVolume"); + statistics.thirtyDaysSaleVolume = BaseRegex.GetNullableIntJson(ref html, "thirtyDaysSaleVolume"); + statistics.waitProductNumber = BaseRegex.GetNullableIntJson(ref html, "waitProductNumber"); + statistics.is_search_1 = true; + } + else + { + string errStr = BaseRegex.GetStringJson(ref html, "errorMsg"); + if (string.IsNullOrEmpty(errStr)) + errStr = errStr = BaseRegex.GetStringJson(ref html, "error_msg"); + if (string.IsNullOrEmpty(errStr)) + errStr = html; + if (errStr.Contains("Invalid Login State")) + { + ShopListForm.Instance.CheckShopLogin(new string[] { shop.LoginName }, false); + } + System.Threading.Thread.Sleep(Randomx.GetId(100, 200)); + statistics.err_msg = errStr; + return; + } + System.Threading.Thread.Sleep(Randomx.GetId(100, 200)); + } + catch (Exception ex) + { + System.Threading.Thread.Sleep(Randomx.GetId(100, 200)); + statistics.err_msg = ex.Message; + return; + } + } + + if (statistics.is_search_2 != true) + { + try + { + string html = GetFundDaily(shop, DateTime.Now.Date.AddDays(-1)); + if (html.Contains("\"success\":true")) + { + JObject jObj = JObject.Parse(html); + string jStr = JsonHelper.SerializeObject(jObj["result"]["resultList"][0]); + + statistics.yesterdayIncomeAmount = BaseRegex.GetStringJson(ref jStr, "incomeAmount").Split('¥').LastOrDefault().ParseToDecimal(); + statistics.is_search_2 = true; + } + else + { + string errStr = BaseRegex.GetStringJson(ref html, "errorMsg"); + if (string.IsNullOrEmpty(errStr)) + errStr = errStr = BaseRegex.GetStringJson(ref html, "error_msg"); + if (string.IsNullOrEmpty(errStr)) + errStr = html; + if (errStr.Contains("Invalid Login State")) + { + ShopListForm.Instance.CheckShopLogin(new string[] { shop.LoginName }, false); + } + System.Threading.Thread.Sleep(Randomx.GetId(100, 200)); + statistics.err_msg = errStr; + return; + } + System.Threading.Thread.Sleep(Randomx.GetId(100, 200)); + } + catch (Exception ex) + { + System.Threading.Thread.Sleep(Randomx.GetId(100, 200)); + statistics.err_msg = ex.Message; + return; + } + } + if (statistics.is_search_3 != true) + { + try + { + string html = GetFundMonthly(shop, DateTime.Now.Date); + string html2 = "\"success\":true"; + if (DateTime.Now.ToString("MM") == "01") + html2 = GetFundMonthly(shop, DateTime.Now.Date.AddYears(-1)); + if (html.Contains("\"success\":true") && html2.Contains("\"success\":true")) + { + JObject jObj = JObject.Parse(html); + string jStr = JsonHelper.SerializeObject(jObj["result"]["resultList"][0]); + + statistics.thisMonthIncomeAmount = BaseRegex.GetStringJson(ref jStr, "incomeAmount").Split('¥').LastOrDefault().ParseToDecimal(); + + if (jObj["result"]["resultList"].Count() > 1) + { + jStr = JsonHelper.SerializeObject(jObj["result"]["resultList"][1]); + statistics.lastMonthIncomeAmount = BaseRegex.GetStringJson(ref jStr, "incomeAmount").Split('¥').LastOrDefault().ParseToDecimal(); + } + else + { + jObj = JObject.Parse(html2); + jStr = JsonHelper.SerializeObject(jObj["result"]["resultList"][0]); + statistics.lastMonthIncomeAmount = BaseRegex.GetStringJson(ref jStr, "incomeAmount").Split('¥').LastOrDefault().ParseToDecimal(); + } + + statistics.is_search_3 = true; + } + else + { + string errStr = BaseRegex.GetStringJson(ref html, "errorMsg"); + if (string.IsNullOrEmpty(errStr)) + errStr = errStr = BaseRegex.GetStringJson(ref html, "error_msg"); + if (string.IsNullOrEmpty(errStr)) + errStr = errStr = BaseRegex.GetStringJson(ref html2, "errorMsg"); + if (string.IsNullOrEmpty(errStr)) + errStr = errStr = BaseRegex.GetStringJson(ref html2, "error_msg"); + if (string.IsNullOrEmpty(errStr)) + errStr = html.Contains("\"success\":true") ? html2 : html; + if (errStr.Contains("Invalid Login State")) + { + ShopListForm.Instance.CheckShopLogin(new string[] { shop.LoginName }, false); + } + System.Threading.Thread.Sleep(Randomx.GetId(100, 200)); + statistics.err_msg = errStr; + return; + } + System.Threading.Thread.Sleep(Randomx.GetId(100, 200)); + } + catch (Exception ex) + { + System.Threading.Thread.Sleep(Randomx.GetId(100, 200)); + statistics.err_msg = ex.Message; + return; + } + } + if (statistics.is_search_4 != true) + { + try + { + string html = GetAccountAmount(shop); + string html2 = GetWithdrawCash(shop); + if (html.Contains("\"success\":true") && html2.Contains("\"success\":true")) + { + string jStr = html; + statistics.availableBalance = BaseRegex.GetStringJson(ref jStr, "availableBalance").Split('¥').LastOrDefault().ParseToDecimal(); + statistics.mallDepositThreshold = BaseRegex.GetStringJson(ref jStr, "mallDepositThreshold").Split('¥').LastOrDefault().ParseToDecimal(); + statistics.mallDepositLimitAmount = BaseRegex.GetStringJson(ref jStr, "mallDepositLimitAmount").Split('¥').LastOrDefault().ParseToDecimal(); + + var jObj = JObject.Parse(html2); + statistics.withdrawCashAmount = 0; + foreach (var item in jObj["result"]["resultList"]) + { + jStr = JsonHelper.SerializeObject(item); + if (!item["withdrawCashStatus"].IsNullOrEmpty() && item["withdrawCashStatus"].ParseToString() == "银行受理成功" && + !item["fundAccount"].IsNullOrEmpty() && item["fundAccount"].ParseToString() == "货款提现") + { + statistics.withdrawCashAmount += BaseRegex.GetDecimalJson(ref jStr, "digitalText"); + } + } + + statistics.is_search_4 = true; + } + else + { + string errStr = BaseRegex.GetStringJson(ref html, "errorMsg"); + if (string.IsNullOrEmpty(errStr)) + errStr = errStr = BaseRegex.GetStringJson(ref html, "error_msg"); + if (string.IsNullOrEmpty(errStr)) + errStr = errStr = BaseRegex.GetStringJson(ref html2, "errorMsg"); + if (string.IsNullOrEmpty(errStr)) + errStr = errStr = BaseRegex.GetStringJson(ref html2, "error_msg"); + if (string.IsNullOrEmpty(errStr)) + errStr = html.Contains("\"success\":true") ? html2 : html; + if (errStr.Contains("Invalid Login State")) + { + ShopListForm.Instance.CheckShopLogin(new string[] { shop.LoginName }, false); + } + System.Threading.Thread.Sleep(Randomx.GetId(100, 200)); + statistics.err_msg = errStr; + return; + } + System.Threading.Thread.Sleep(Randomx.GetId(100, 200)); + } + catch (Exception ex) + { + System.Threading.Thread.Sleep(Randomx.GetId(100, 200)); + statistics.err_msg = ex.Message; + return; + } + } + } + + private string GetMainStatistics(ShopLoginInfo shop) { string url = "https://agentseller.temu.com/bg/swift/api/common/statistics/web/queryStatisticDataFullManaged"; - string body = "{\"adjustList\":["; - foreach (var adjustId in adjustIdList) - { - body += "{\"adjustId\":" + adjustId + ",\"result\":2,\"reason\":\"" + refuseReason + "\"},"; - } - body = body.TrimEnd(','); - body += "]}"; - string refere = "https://agentseller.temu.com/main/adjust-price-manage/order-price"; + string body = @"{}"; + string refere = "https://agentseller.temu.com/"; return KJDHttpResponse.PostResponse2(shop, url, body, refere); } + + private string GetFundDaily(ShopLoginInfo shop, DateTime date) + { + string url = "https://seller.kuajingmaihuo.com/api/merchant/fund/detail/daily"; + string body = @"{""month"":""" + date.ToString("yyyy-MM") + @"""}"; + string refere = "https://seller.kuajingmaihuo.com/labor/bill"; + + return KJDHttpResponse.PostResponse(shop, url, body, refere); + } + + private string GetFundMonthly(ShopLoginInfo shop, DateTime date) + { + string url = "https://seller.kuajingmaihuo.com/api/merchant/fund/detail/monthly"; + string body = @"{""year"":""" + date.ToString("yyyy") + @"""}"; + string refere = "https://seller.kuajingmaihuo.com/labor/bill"; + + return KJDHttpResponse.PostResponse(shop, url, body, refere); + } + + /// + /// 资金总览 + /// + /// + /// + private string GetAccountAmount(ShopLoginInfo shop) + { + string url = "https://seller.kuajingmaihuo.com/api/merchant/payment/account/amount/info"; + string body = @"{}"; + string refere = "https://seller.kuajingmaihuo.com/labor/account"; + + return KJDHttpResponse.PostResponse(shop, url, body, refere); + } + /// + /// 提现记录 + /// + /// + /// + private string GetWithdrawCash(ShopLoginInfo shop, int page = 1) + { + string url = "https://seller.kuajingmaihuo.com/api/merchant/payment/account/withdraw/cash/record"; + string body = @"{""page"":" + page + @",""pageSize"":100}"; + string refere = "https://seller.kuajingmaihuo.com/labor/account"; + + return KJDHttpResponse.PostResponse(shop, url, body, refere); + } + + private void dgvShop_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + if (e.ColumnIndex < 0 || e.RowIndex < 0) + return; + string headerText = dgvShop.Columns[e.ColumnIndex].HeaderText; + string loginName = dgvShop.Rows[e.RowIndex].Cells["colShopLoginName"].Value.ParseToString(); + string accountId = dgvShop.Rows[e.RowIndex].Cells["colShopId"].Value.ParseToString(); + var shop = GlobalConfig.ShopLoginList.FirstOrDefault(v => v.LoginName == loginName && v.ShopId == accountId); + + switch (headerText) + { + case "检测": + break; + case "进入店铺": + IsOperate = true; + { + ShopLoginForm shopLoginForm = new ShopLoginForm(shop); + //shopLoginForm.Parent = this; + shopLoginForm.openType = EnumOpenType.manage; + shopLoginForm.WindowState = FormWindowState.Maximized; + shopLoginForm.InitUrl = "https://agentseller.temu.com"; + shopLoginForm.Show(); + IsOperate = false; + } + break; + case "状态": + IsOperate = true; + { + ShopLoginForm shopLoginForm = new ShopLoginForm(shop); + shopLoginForm.chkCloseAfterLogin.Checked = false; + shopLoginForm.openType = EnumOpenType.login; + shopLoginForm.ShowDialog(); + var rows = this.dgvShop.Rows.Cast().Where(r => r.Cells["colShopLoginName"].Value.ToString() == loginName); + bool canUse = shop.LoginStatus == "登录成功" && shop.LoginStatus2 == "国际版在线"; + foreach (var row in rows) + { + row.Cells["colLoginStatus"].Value = canUse ? "在线" : "掉线"; + (row.Cells["colLoginStatus"] as DataGridViewLinkCell).Style.ForeColor = canUse ? Color.Green : Color.Red; + (row.Cells["colLoginStatus"] as DataGridViewLinkCell).LinkColor = canUse ? Color.Green : Color.Red; + (row.Cells["colLoginStatus"] as DataGridViewLinkCell).ActiveLinkColor = canUse ? Color.LightGreen : Color.OrangeRed; + (row.Cells["colLoginStatus"] as DataGridViewLinkCell).VisitedLinkColor = canUse ? Color.DarkGreen : Color.DarkRed; + } + } + IsOperate = false; + break; + default: + dgvShop.Rows[e.RowIndex].Cells["colSelect"].Value = !(bool)dgvShop.Rows[e.RowIndex].Cells["colSelect"].Value; + break; + } + } + + private void btnGetNotGet_Click(object sender, EventArgs e) + { + RefreshShop(); + } + + private void btnGetSelect_Click(object sender, EventArgs e) + { + var selectIds = dgvShop.Rows.Cast().Where(row + => row.Cells["colSelect"]?.Value.ParseToBool() == true).Select(r => r.Cells["colShopId"]?.Value.ToString()).ToList(); + var shopList = GlobalConfig.ShopLoginList.Where(s => selectIds.Contains(s.ShopId)).ToList(); + foreach (var shop in shopList) + { + ShopStatisticsInfo statistics = lstShopStatisticsInfo.FirstOrDefault(s => s.shop_id.ToString() == shop.ShopId); + if (statistics != null) + statistics.is_search_1 = statistics.is_search_2 = statistics.is_search_3 = statistics.is_search_4 = false; + } + + this.pbLoading.Visible = true; + GetShopStatistics(shopList, selectIds); + } } } diff --git a/TEMUKJD/KJDForms/ShopForms/Statistics/ShopStatisticsForm.resx b/TEMUKJD/KJDForms/ShopForms/Statistics/ShopStatisticsForm.resx index 089ada7..aadbc76 100644 --- a/TEMUKJD/KJDForms/ShopForms/Statistics/ShopStatisticsForm.resx +++ b/TEMUKJD/KJDForms/ShopForms/Statistics/ShopStatisticsForm.resx @@ -153,19 +153,22 @@ True - + True - + True - + True - + True - + + True + + True \ No newline at end of file diff --git a/TEMUKJD/StartUp.cs b/TEMUKJD/StartUp.cs index 6b33ff1..25e0736 100644 --- a/TEMUKJD/StartUp.cs +++ b/TEMUKJD/StartUp.cs @@ -21,6 +21,7 @@ using System.Threading.Tasks; using Work; using Work.DouyinApiClass; using AllBase.Model.Param.TemuProductManage; +using TemuKJD.KJDForms.ShopForms; namespace TemuKJD { @@ -216,6 +217,40 @@ namespace TemuKJD //} }); #endregion + + #region 读取库存信息 + Task.Run(() => + { + while (!IsShopInit) + { + Thread.Sleep(100); + } + + ReturnPackageDetailForm retrunPackageForm = new ReturnPackageDetailForm(null); + retrunPackageForm.Show(); + retrunPackageForm.Hide(); + Dictionary dicUpReturn = new Dictionary(); + + while(true) + { + foreach(var shop in GlobalConfig.ShopLoginList) + { + if (string.IsNullOrEmpty(shop.ShopId)) + continue; + + if (dicUpReturn.Keys.Contains(shop) && dicUpReturn[shop] == DateTime.Now.ToString("yyyyMMdd")) //今日已获取过 + continue; + + var rst = retrunPackageForm.GetReturnPackage(shop, true); + if (rst == false && shop.LoginStatus == "登录成功" && shop.LoginStatus2 == "国际版在线") + { + dicUpReturn[shop] = DateTime.Now.ToString("yyyyMMdd"); + } + } + Thread.Sleep(1000 * 60 * 60); + } + }); + #endregion } public static void InitProxy()