批量补发功能

This commit is contained in:
wule committed 2026-06-08 09:43:43 +08:00
1 parent c72cbf7e23
commit 16845c59fc
4 files changed
+158 -19

No files matched your search

+1 -1
View File
@@ -27,7 +27,7 @@ namespace AllBase
/// <summary>
/// 版本ID
/// </summary>
public static int VersionCount = 1165;
public static int VersionCount = 1167;
public static string MainPath = "29wx";
//public static string MainPath = "29wx";
//public static string MainPath = "29pdd";
@@ -64,7 +64,7 @@ Section "MainSection" SEC01
SetOverwrite on
;/x 排除的目录或文件
;File /r /x "Config.xml" /x "choice.debug.tools" /x "DB.dll" /x "Publish.exe" /x "AllBase.pdb" /x "Work.pdb" /x "29供应链.pdb" /x "data" "${BIN_PATH}\*.*"
File /r /x "BaseClass.cs" /x "Config.xml" /x "choice.debug.tools" /x "DB.dll" /x "Publish.exe" /x "*.pdb" /x "*.zip" /x "data" /x "Cache" /x "29pdd.lnk" /x "29pdd.ico" "${BIN_PATH}\*.*"
File /r /x "BaseClass.cs" /x "Config.xml" /x "choice.debug.tools" /x "DB.dll" /x "Publish.exe" /x "*.pdb" /x "*.zip" /x "data" /x "Cache" /x "29wx.lnk" /x "29pdd.lnk" /x "29pdd.ico" "${BIN_PATH}\*.*"
CreateDirectory "$SMPROGRAMS\29供应链-微信小店管理工具"
CreateShortCut "$SMPROGRAMS\29供应链-微信小店管理工具\29供应链-微信小店管理工具.lnk" "$INSTDIR\29供应链.exe" "" "$INSTDIR\29wx.ico"
CreateShortCut "$DESKTOP\29供应链-微信小店管理工具.lnk" "$INSTDIR\29供应链.exe" "" "$INSTDIR\29wx.ico"
+42 -14
View File
@@ -137,6 +137,7 @@ namespace TemuKJD.WXForms.ShopForms
this.colRemaining = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colMessage = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.btnBatchOptimize = new DevComponents.DotNetBar.PanelEx();
this.chkUseReshipmentApi = new TemuKJD.UserComponent.UcCheckBox(this.components);
this.btnUpdateKdn = new DevComponents.DotNetBar.PanelEx();
this.txtFilterOrderId = new System.Windows.Forms.TextBox();
@@ -1013,6 +1014,7 @@ namespace TemuKJD.WXForms.ShopForms
//
// splitContainer2.Panel2
//
this.splitContainer2.Panel2.Controls.Add(this.btnBatchOptimize);
this.splitContainer2.Panel2.Controls.Add(this.chkUseReshipmentApi);
this.splitContainer2.Panel2.Controls.Add(this.btnUpdateKdn);
this.splitContainer2.Panel2.Controls.Add(this.txtFilterOrderId);
@@ -1025,6 +1027,31 @@ namespace TemuKJD.WXForms.ShopForms
this.splitContainer2.SplitterDistance = 365;
this.splitContainer2.TabIndex = 0;
//
// btnBatchOptimize
//
this.btnBatchOptimize.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnBatchOptimize.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.btnBatchOptimize.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnBatchOptimize.DisabledBackColor = System.Drawing.Color.Empty;
this.btnBatchOptimize.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnBatchOptimize.Location = new System.Drawing.Point(536, 7);
this.btnBatchOptimize.Name = "btnBatchOptimize";
this.btnBatchOptimize.Size = new System.Drawing.Size(62, 25);
this.btnBatchOptimize.Style.Alignment = System.Drawing.StringAlignment.Center;
this.btnBatchOptimize.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnBatchOptimize.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnBatchOptimize.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder;
this.btnBatchOptimize.Style.BorderDashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
this.btnBatchOptimize.Style.BorderSide = DevComponents.DotNetBar.eBorderSide.None;
this.btnBatchOptimize.Style.ForeColor.Color = System.Drawing.Color.White;
this.btnBatchOptimize.Style.GradientAngle = 90;
this.btnBatchOptimize.StyleMouseOver.Alignment = System.Drawing.StringAlignment.Center;
this.btnBatchOptimize.StyleMouseOver.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
this.btnBatchOptimize.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
this.btnBatchOptimize.TabIndex = 805;
this.btnBatchOptimize.Text = "批量补发";
this.btnBatchOptimize.Click += new System.EventHandler(this.btnBatchOptimize_Click);
//
// chkUseReshipmentApi
//
this.chkUseReshipmentApi.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
@@ -1525,7 +1552,7 @@ namespace TemuKJD.WXForms.ShopForms
this.tabPage2.Controls.Add(this.panel2);
this.tabPage2.Location = new System.Drawing.Point(2, 40);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Size = new System.Drawing.Size(1088, 489);
this.tabPage2.Size = new System.Drawing.Size(1088, 451);
this.tabPage2.TabIndex = 5;
this.tabPage2.Text = " 订单评价 ";
this.tabPage2.UseVisualStyleBackColor = true;
@@ -1538,14 +1565,14 @@ namespace TemuKJD.WXForms.ShopForms
this.panel2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.panel2.Location = new System.Drawing.Point(0, 0);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(1088, 489);
this.panel2.Size = new System.Drawing.Size(1088, 451);
this.panel2.TabIndex = 3;
//
// pictureBox2
//
this.pictureBox2.Anchor = System.Windows.Forms.AnchorStyles.None;
this.pictureBox2.Image = global::TemuKJD.Properties.Resources.loading_blue;
this.pictureBox2.Location = new System.Drawing.Point(519, 219);
this.pictureBox2.Location = new System.Drawing.Point(519, 200);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(50, 50);
this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
@@ -1601,7 +1628,7 @@ namespace TemuKJD.WXForms.ShopForms
this.dgvData2.Name = "dgvData2";
this.dgvData2.ReadOnly = true;
this.dgvData2.RowTemplate.Height = 23;
this.dgvData2.Size = new System.Drawing.Size(1088, 489);
this.dgvData2.Size = new System.Drawing.Size(1088, 451);
this.dgvData2.TabIndex = 187;
this.dgvData2.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvData_CellContentClick);
//
@@ -2106,7 +2133,7 @@ namespace TemuKJD.WXForms.ShopForms
this.tabPage4.Controls.Add(this.panel4);
this.tabPage4.Location = new System.Drawing.Point(2, 40);
this.tabPage4.Name = "tabPage4";
this.tabPage4.Size = new System.Drawing.Size(1088, 489);
this.tabPage4.Size = new System.Drawing.Size(1088, 451);
this.tabPage4.TabIndex = 2;
this.tabPage4.Text = " 配送不达标 ";
this.tabPage4.UseVisualStyleBackColor = true;
@@ -2119,14 +2146,14 @@ namespace TemuKJD.WXForms.ShopForms
this.panel4.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.panel4.Location = new System.Drawing.Point(0, 0);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(1088, 489);
this.panel4.Size = new System.Drawing.Size(1088, 451);
this.panel4.TabIndex = 2;
//
// pictureBox4
//
this.pictureBox4.Anchor = System.Windows.Forms.AnchorStyles.None;
this.pictureBox4.Image = global::TemuKJD.Properties.Resources.loading_blue;
this.pictureBox4.Location = new System.Drawing.Point(525, 219);
this.pictureBox4.Location = new System.Drawing.Point(525, 200);
this.pictureBox4.Name = "pictureBox4";
this.pictureBox4.Size = new System.Drawing.Size(50, 50);
this.pictureBox4.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
@@ -2184,7 +2211,7 @@ namespace TemuKJD.WXForms.ShopForms
this.dgvData4.Name = "dgvData4";
this.dgvData4.ReadOnly = true;
this.dgvData4.RowTemplate.Height = 23;
this.dgvData4.Size = new System.Drawing.Size(1088, 489);
this.dgvData4.Size = new System.Drawing.Size(1088, 451);
this.dgvData4.TabIndex = 187;
this.dgvData4.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvData_CellContentClick);
//
@@ -2403,7 +2430,7 @@ namespace TemuKJD.WXForms.ShopForms
this.tabPage5.Controls.Add(this.panel5);
this.tabPage5.Location = new System.Drawing.Point(2, 40);
this.tabPage5.Name = "tabPage5";
this.tabPage5.Size = new System.Drawing.Size(1088, 489);
this.tabPage5.Size = new System.Drawing.Size(1088, 451);
this.tabPage5.TabIndex = 3;
this.tabPage5.Text = " 物流负向反馈 ";
this.tabPage5.UseVisualStyleBackColor = true;
@@ -2416,14 +2443,14 @@ namespace TemuKJD.WXForms.ShopForms
this.panel5.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.panel5.Location = new System.Drawing.Point(0, 0);
this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(1088, 489);
this.panel5.Size = new System.Drawing.Size(1088, 451);
this.panel5.TabIndex = 3;
//
// pictureBox5
//
this.pictureBox5.Anchor = System.Windows.Forms.AnchorStyles.None;
this.pictureBox5.Image = global::TemuKJD.Properties.Resources.loading_blue;
this.pictureBox5.Location = new System.Drawing.Point(525, 219);
this.pictureBox5.Location = new System.Drawing.Point(525, 200);
this.pictureBox5.Name = "pictureBox5";
this.pictureBox5.Size = new System.Drawing.Size(50, 50);
this.pictureBox5.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
@@ -2480,7 +2507,7 @@ namespace TemuKJD.WXForms.ShopForms
this.dgvData5.Name = "dgvData5";
this.dgvData5.ReadOnly = true;
this.dgvData5.RowTemplate.Height = 23;
this.dgvData5.Size = new System.Drawing.Size(1088, 489);
this.dgvData5.Size = new System.Drawing.Size(1088, 451);
this.dgvData5.TabIndex = 187;
this.dgvData5.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvData_CellContentClick);
//
@@ -2689,7 +2716,7 @@ namespace TemuKJD.WXForms.ShopForms
this.tabPage6.Location = new System.Drawing.Point(2, 40);
this.tabPage6.Name = "tabPage6";
this.tabPage6.Padding = new System.Windows.Forms.Padding(3);
this.tabPage6.Size = new System.Drawing.Size(1088, 489);
this.tabPage6.Size = new System.Drawing.Size(1088, 451);
this.tabPage6.TabIndex = 6;
this.tabPage6.Text = " 快递助手 ";
this.tabPage6.UseVisualStyleBackColor = true;
@@ -2700,7 +2727,7 @@ namespace TemuKJD.WXForms.ShopForms
this.splitContainer4.Location = new System.Drawing.Point(3, 3);
this.splitContainer4.Name = "splitContainer4";
this.splitContainer4.Panel1MinSize = 0;
this.splitContainer4.Size = new System.Drawing.Size(1082, 483);
this.splitContainer4.Size = new System.Drawing.Size(1082, 445);
this.splitContainer4.SplitterDistance = 25;
this.splitContainer4.TabIndex = 0;
//
@@ -2998,5 +3025,6 @@ namespace TemuKJD.WXForms.ShopForms
private System.Windows.Forms.DataGridViewTextBoxColumn colDgv5Remark;
private System.Windows.Forms.DataGridViewTextBoxColumn colDgv5WaybillStatus;
private System.Windows.Forms.DataGridViewTextBoxColumn colDgv5WaybillLatelyTrace;
private DevComponents.DotNetBar.PanelEx btnBatchOptimize;
}
}
+114 -3
View File
@@ -2505,9 +2505,16 @@ namespace TemuKJD.WXForms.ShopForms
var spuId = row.Cells[$"colDgv{dgvNum}SpuId"].Value.ParseToString();
var skuId = row.Cells[$"colDgv{dgvNum}SkuId"].Value.ParseToString();
var cnt = row.Cells[$"colDgv{dgvNum}Cnt"].Value.ParseToInt();
var rst = OptimizeExpress(shop, orderId, orderCreateTime, spuId, skuId, cnt);
row.Cells[$"colDgv{dgvNum}OptimizeStatus"].Value = rst.Replace("修改物流信息失败,", "").Replace("修改物流信息失败,", "");
row.Cells[$"colDgv{dgvNum}OptimizeStatus"].Style.ForeColor = rst.Contains("成功") ? Control.DefaultForeColor : Color.Red;
Task.Run(() =>
{
var rst = OptimizeExpress(shop, orderId, orderCreateTime, spuId, skuId, cnt);
Invoke(new Action(() =>
{
pictureBox1.Visible = pictureBox2.Visible = pictureBox3.Visible = pictureBox4.Visible = pictureBox5.Visible = false;
row.Cells[$"colDgv{dgvNum}OptimizeStatus"].Value = rst.Replace("修改物流信息失败,", "").Replace("修改物流信息失败,", "");
row.Cells[$"colDgv{dgvNum}OptimizeStatus"].Style.ForeColor = rst.Contains("成功") ? Control.DefaultForeColor : Color.Red;
}));
});
break;
}
case "备注":
@@ -2771,6 +2778,110 @@ namespace TemuKJD.WXForms.ShopForms
//var waybillIds = string.Join(",", dgvRows1Tmp.Select(r => r.Cells["colDgv1OrderId"].Value.ParseToString()).Distinct());
}
private void btnBatchOptimize_Click(object sender, EventArgs e)
{
List<string> OrderIds = new List<string>();
List<DataGridViewRow> dgvRows = new List<DataGridViewRow>();
var dgvRows1 = dgvData1.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colDgv1Check"].Value.ParseToBool() == true).ToList();
dgvRows.AddRange(dgvRows1.Where(r => !OrderIds.Any(oId => oId == r.Cells["colDgv1OrderId"].Value.ParseToString())));
OrderIds.AddRange(dgvRows1.Select(r => r.Cells["colDgv1OrderId"].Value.ParseToString()));
var dgvRows2 = dgvData2.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colDgv2Check"].Value.ParseToBool() == true).ToList();
dgvRows.AddRange(dgvRows2.Where(r => !OrderIds.Any(oId => oId == r.Cells["colDgv2OrderId"].Value.ParseToString())));
OrderIds.AddRange(dgvRows2.Select(r => r.Cells["colDgv2OrderId"].Value.ParseToString()));
var dgvRows3 = dgvData3.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colDgv3Check"].Value.ParseToBool() == true).ToList();
dgvRows.AddRange(dgvRows3.Where(r => !OrderIds.Any(oId => oId == r.Cells["colDgv3OrderId"].Value.ParseToString())));
OrderIds.AddRange(dgvRows3.Select(r => r.Cells["colDgv3OrderId"].Value.ParseToString()));
var dgvRows4 = dgvData4.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colDgv4Check"].Value.ParseToBool() == true).ToList();
dgvRows.AddRange(dgvRows4.Where(r => !OrderIds.Any(oId => oId == r.Cells["colDgv4OrderId"].Value.ParseToString())));
OrderIds.AddRange(dgvRows4.Select(r => r.Cells["colDgv4OrderId"].Value.ParseToString()));
var dgvRows5 = dgvData5.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colDgv5Check"].Value.ParseToBool() == true).ToList();
dgvRows.AddRange(dgvRows5.Where(r => !OrderIds.Any(oId => oId == r.Cells["colDgv5OrderId"].Value.ParseToString())));
OrderIds.AddRange(dgvRows5.Select(r => r.Cells["colDgv5OrderId"].Value.ParseToString()));
OrderIds = OrderIds.Distinct().ToList();
if (dgvRows.Count <= 0)
{
BaseMsgForm.ShowError("请选择订单");
return;
}
pictureBox1.Visible = pictureBox2.Visible = pictureBox3.Visible = pictureBox4.Visible = pictureBox5.Visible = true;
Task.Run(() =>
{
int index = 0;
foreach (var row in dgvRows)
{
index++;
var dgvNum = row.DataGridView.Name.Replace("dgvData", "");
Invoke(new Action(() =>
{
statusBar.lblTaskStatus.Text = "正在批量补发 " + index + "/" + dgvRows.Count;
row.Cells[$"colDgv{dgvNum}OptimizeStatus"].Style.BackColor = row.Cells[$"colDgv{dgvNum}SpuId"].Style.BackColor;
}));
var orderId = row.Cells[$"colDgv{dgvNum}OrderId"].Value.ParseToString();
if (orderId.Contains("未获取到对应订单号"))
{
Invoke(new Action(() => { row.Cells[$"colDgv{dgvNum}OptimizeStatus"].Value = "缺少单编号无法补发!";
row.Cells[$"colDgv{dgvNum}OptimizeStatus"].Style.BackColor = Color.Yellow;
}));
continue;
}
if (orderId.Contains("获取到多条订单号"))
{
Invoke(new Action(() => { row.Cells[$"colDgv{dgvNum}OptimizeStatus"].Value = "获取到多条订单号!订单编号不符合补发条件!";
row.Cells[$"colDgv{dgvNum}OptimizeStatus"].Style.BackColor = Color.Yellow;
}));
continue;
}
orderId = orderId.Split(new string[] { "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault();
if (string.IsNullOrEmpty(orderId))
{
Invoke(new Action(() => { row.Cells[$"colDgv{dgvNum}OptimizeStatus"].Value = "缺少订单编号无法补发!";
row.Cells[$"colDgv{dgvNum}OptimizeStatus"].Style.BackColor = Color.Yellow;
}));
continue;
}
if (chkUseReshipmentApi.Checked && dgvNum != "2")
{
Invoke(new Action(() => { row.Cells[$"colDgv{dgvNum}OptimizeStatus"].Value = "补发货模式仅支持订单评价补发!";
row.Cells[$"colDgv{dgvNum}OptimizeStatus"].Style.BackColor = Color.Yellow;
}));
continue;
}
var shopId = row.Cells[$"colDgv{dgvNum}ShopId"].Value.ParseToString();
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ShopId == shopId);
if (shop == null)
{
Invoke(new Action(() => { row.Cells[$"colDgv{dgvNum}OptimizeStatus"].Value = "店铺不存在!";
row.Cells[$"colDgv{dgvNum}OptimizeStatus"].Style.BackColor = Color.Yellow;
}));
continue;
}
string orderCreateTime = "", spuId = "", skuId = "";
int cnt = 0;
Invoke(new Action(() =>
{
orderCreateTime = row.Cells[$"colDgv{dgvNum}OrderTime"].Value.ParseToString();
spuId = row.Cells[$"colDgv{dgvNum}SpuId"].Value.ParseToString();
skuId = row.Cells[$"colDgv{dgvNum}SkuId"].Value.ParseToString();
cnt = row.Cells[$"colDgv{dgvNum}Cnt"].Value.ParseToInt();
}));
var rst = OptimizeExpress(shop, orderId, orderCreateTime, spuId, skuId, cnt);
Invoke(new Action(() =>
{
row.Cells[$"colDgv{dgvNum}OptimizeStatus"].Value = rst.Replace("修改物流信息失败,", "").Replace("修改物流信息失败,", "");
row.Cells[$"colDgv{dgvNum}OptimizeStatus"].Style.ForeColor = rst.Contains("成功") ? Control.DefaultForeColor : Color.Red;
}));
}
Invoke(new Action(() =>
{
pictureBox1.Visible = pictureBox2.Visible = pictureBox3.Visible = pictureBox4.Visible = pictureBox5.Visible = false;
statusBar.lblTaskStatus.Text = "补发结束 " + dgvRows.Count + "/" + dgvRows.Count ;
}));
});
}
}
public static class ShopOptimize