自动拍单功能

This commit is contained in:
wule committed 2026-09-12 13:10:51 +08:00
1 parent 5906a1623f
commit e755da09a6
6 files changed
+141 -80

No files matched your search

@@ -614,19 +614,18 @@
MinWidth="48"
Margin="8,0,4,0"
Padding="4,0"
c:DebugVisibility.Enable="True"
Click="btnAutoBuy_Click"
Content="自动拍单"
FontSize="12"
Style="{StaticResource BasePageButtonStyle}" />
<!-- c:DebugVisibility.Enable="true" -->
<Button
x:Name="btnAutoBuyIntorduction"
Width="Auto"
Height="22"
MinWidth="48"
Margin="0,0,4,0"
Margin="0,0,8,0"
Padding="4,0"
c:DebugVisibility.Enable="True"
Click="btnAutoBuyIntroduction_Click"
Content="自动拍单设置说明"
FontSize="12"
@@ -59,6 +59,7 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
/// </summary>
public partial class OrderListCtrl : UserControl, INotifyPropertyChanged
{
public static bool IsAutoBuy { get; set; } = false;
public CheckBox chkSelectAll = null;
OrderFilterConfig _orderFilterConfig;
public OrderFilterConfig orderFilterConfig
@@ -2716,11 +2717,15 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
return;
}
IsAutoBuy = true;
foreach (var order in buyOrders)
{
var orderItem = order.orderItems.FirstOrDefault();
await OrderListRowItemCtrl.BuyOrder(orderItem, true);
if (IsAutoBuy == false)
break;
}
IsAutoBuy = false;
}
private void btnAutoBuyIntroduction_Click(object sender, RoutedEventArgs e)
@@ -323,17 +323,20 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
{
if (orderItem == null)
{
BaseMsgWindow.ShowError("订单信息为空");
if (!isAutoBuy)
BaseMsgWindow.ShowError("订单信息为空");
return;
}
if (GlobalConfig.CurrentPddBuyer == null)
{
BaseMsgWindow.ShowError("请选择买手号");
if (!isAutoBuy)
BaseMsgWindow.ShowError("请选择买手号");
return;
}
if (orderItem.ItemOrder.orderItems.Count > 1)
{
BaseMsgWindow.ShowError("多子单订单中转仓暂不支持");
if (!isAutoBuy)
BaseMsgWindow.ShowError("多子单订单中转仓暂不支持");
return;
}
@@ -342,7 +345,8 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
{
OrderListCtrl.InitOrderItemObservableProp(orderItem);
MainWindow.Instance.orderListCtrl.FilterOneOrder(orderItem.ItemOrder);
BaseMsgWindow.ShowError("已存在中转拍单信息,请核对后再拍单");
if (!isAutoBuy)
BaseMsgWindow.ShowError("已存在中转拍单信息,请核对后再拍单");
return;
}
@@ -590,6 +594,7 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
if (isAbnormalOrder)
buyOrderForm.AbnormalTransitWarehouseOrderInfo = orderItem.ItemTransitOrder;
buyOrderForm.ShowDialog();
OrderListCtrl.IsAutoBuy = buyOrderForm.IsAutoBuy;
}));
});
}
@@ -96,7 +96,6 @@
Margin="70,128,70,128"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Text="说明:请保存支付宝支付密码(仅记录在本地)供自动拍单支付,首次自动拍单前请手动拍单一次以缓存支付宝Cookie。"
TextWrapping="Wrap" />
TextWrapping="Wrap"><Run Text="说明:"/><Run Text="自动拍单支持已创建sku关联的商品"/><Run Language="zh-cn" Text="。"/><LineBreak/><Run Text=" "/><Run Text="请保存支付宝支付密码(仅记录在本地)供自动拍单支付,首次自动拍单前请手动拍单一次以缓存支付宝Cookie。"/></TextBlock>
</Grid>
</UserControl>
+88 -63
View File
@@ -114,6 +114,8 @@ namespace TemuKJD.ToolForms
chkUseAppBalance.Checked = true;
GlobalConfig.BuyConfig.IsUseAppBalance = true;
if (IsAutoBuy)
CloseAfterSecond = 60;
if (CloseAfterSecond > 0)
{
Task.Run(() =>
@@ -511,23 +513,26 @@ namespace TemuKJD.ToolForms
Invoke(new Action(() =>
{
if (BuyType == "direct" && txtBuyTransitWarehouse.Text.Contains("******"))
{
BaseMsgForm.ShowError("请手动输入合法地址信息再拍单!");
{
if (!IsAutoBuy)
BaseMsgForm.ShowError("请手动输入合法地址信息再拍单!");
return;
}
// 自动修改收货地址为中转仓(或直发)
var transit = TransitWarehouseData.TransitWarehouseList.FirstOrDefault(t => t.TransDetailAddress == txtBuyTransitWarehouse.Text.Trim());
if (transit == null && BuyType == "transit")
{
BaseMsgForm.ShowError("仓库已发生改变,请点击重新关联商品,选择仓库后重新拍单!");
{
if (!IsAutoBuy)
BaseMsgForm.ShowError("仓库已发生改变,请点击重新关联商品,选择仓库后重新拍单!");
return;
}
if ((transit != null || BuyType == "direct") && IsChangeAddress == false && HasChangeAddress == false)
{
if (IsSoldOut)
{
BaseMsgForm.ShowError("商品已售罄,请重新关联未售罄商品后再拍单!");
if (!IsAutoBuy)
BaseMsgForm.ShowError("商品已售罄,请重新关联未售罄商品后再拍单!");
return;
}
if (!IsSoldOut)
@@ -698,7 +703,7 @@ namespace TemuKJD.ToolForms
}
// 最后未执行成功也关闭窗口。
Thread.Sleep(Randomx.GetId(1112500, 1115000));
Thread.Sleep(Randomx.GetId(12500, 15000));
}
public async Task CheckSourceCode()
@@ -1228,14 +1233,16 @@ namespace TemuKJD.ToolForms
private async void btnManualUpdateBuyOrder_Click(object sender, EventArgs e)
{
if (BuyType == "transit" && txtSourceCode.Text.Trim().Length != 6)
{
BaseMsgForm.ShowError("溯源码长度错误!");
{
if (!IsAutoBuy)
BaseMsgForm.ShowError("溯源码长度错误!");
return;
}
var client = cefWebBrowser.GetDevToolsClient();
if (client == null)
{
BaseMsgForm.ShowError("页面未加载!");
{
if (!IsAutoBuy)
BaseMsgForm.ShowError("页面未加载!");
return;
}
//var sourceCode = txtSourceCode.Text.Trim();
@@ -1253,29 +1260,34 @@ namespace TemuKJD.ToolForms
// 付款页面没法匹配,暂时注释
//if (ts1.Result?.Result?.Value.ParseToString() != "success")
//{
// if (!IsAutoBuy)
// BaseMsgForm.ShowError("溯源码不匹配!");
// return;
//}
if (BuyType == "transit" && string.IsNullOrEmpty(txtBuyTransitWarehouse.Text.Trim()))
{
BaseMsgForm.ShowError("缺少中转地址,请重新绑定商品并选择仓库地址");
{
if (!IsAutoBuy)
BaseMsgForm.ShowError("缺少中转地址,请重新绑定商品并选择仓库地址");
return;
}
var transit = TransitWarehouseData.TransitWarehouseList.FirstOrDefault(t => t.TransDetailAddress == txtBuyTransitWarehouse.Text.Trim());
if (BuyType == "transit" && transit == null)
{
BaseMsgForm.ShowError("中转地址对应的中转仓不存在,请核对");
{
if (!IsAutoBuy)
BaseMsgForm.ShowError("中转地址对应的中转仓不存在,请核对");
return;
}
if (string.IsNullOrEmpty(txtBuyOrderId.Text.Trim()))
{
BaseMsgForm.ShowError("缺少拍单订单号,请拍单后再提交");
{
if (!IsAutoBuy)
BaseMsgForm.ShowError("缺少拍单订单号,请拍单后再提交");
return;
}
if ((txtBuyPrice.Text.ParseToDecimal() * 100).ParseToInt().IsNullOrZero())
{
BaseMsgForm.ShowError("缺少拍单金额,请拍单后再提交");
{
if (!IsAutoBuy)
BaseMsgForm.ShowError("缺少拍单金额,请拍单后再提交");
return;
}
@@ -1330,8 +1342,9 @@ namespace TemuKJD.ToolForms
catch
{
msg = exportRst.ParseToString();
}
BaseMsgForm.ShowError("拍单保存失败,服务端返回 " + msg, "拍单信息保存失败");
}
if (!IsAutoBuy)
BaseMsgForm.ShowError("拍单保存失败,服务端返回 " + msg, "拍单信息保存失败");
btnManualUpdateBuyOrder.Enabled = true;
return;
}
@@ -1361,40 +1374,41 @@ namespace TemuKJD.ToolForms
filterOrderAction(order, true);
}
//// 前一天的订单直接提前取号
//if (DateTime.Now.Date > BaseClass.StampToDateTime(order.create_time).Date)
//{
// JObject data = new JObject();
// data["outOrderNo"] = txtBuyOrderId.Text.Trim();
// //data2["outOrderNo"] = orderItem.ItemTransitOrder.order_code;
// data["warehouseCode"] = transit.TransId; // 中转仓仓库对应编码 XDYSZC XDYYWC ...
// //data["warehouseCode"] = txtBuyOrderId.Text.Trim(); // 中转仓仓库对应编码
// data["platform"] = "WEISHOP";
// var getVirtualTicketUrl = "https://po.e57.cn/prod-api/api/oms-api/external_procurement/order/virtual/create";
// var getVirtualTicketDataStr = JsonHelper.SerializeObject(data);
//// 前一天的订单直接提前取号
//if (DateTime.Now.Date > BaseClass.StampToDateTime(order.create_time).Date)
//{
// JObject data = new JObject();
// data["outOrderNo"] = txtBuyOrderId.Text.Trim();
// //data2["outOrderNo"] = orderItem.ItemTransitOrder.order_code;
// data["warehouseCode"] = transit.TransId; // 中转仓仓库对应编码 XDYSZC XDYYWC ...
// //data["warehouseCode"] = txtBuyOrderId.Text.Trim(); // 中转仓仓库对应编码
// data["platform"] = "WEISHOP";
// var getVirtualTicketUrl = "https://po.e57.cn/prod-api/api/oms-api/external_procurement/order/virtual/create";
// var getVirtualTicketDataStr = JsonHelper.SerializeObject(data);
// var getVirtualTicketRst = HttpResponseWXBLL.e57PostResponse(getVirtualTicketUrl, getVirtualTicketDataStr, "");
// if (!getVirtualTicketRst.ParseToString().Contains("<code>200</code>") && !getVirtualTicketRst.ParseToString().Contains("<code>0</code>"))
// {
// string msg = "";
// string code = "";
// try
// {
// System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
// xmlDoc.LoadXml(getVirtualTicketRst);
// code = xmlDoc["AjaxResult"]["code"].InnerText;
// msg = xmlDoc["AjaxResult"]["msg"].InnerText;
// }
// catch
// {
// msg = getVirtualTicketRst.ParseToString();
// }
// BaseMsgForm.ShowError("拍单信息保存成功,接收到服务端传递的错误消息:" + msg, "订单提前取号失败");
// btnManualUpdateBuyOrder.Enabled = true;
// return;
// }
//}
}
// var getVirtualTicketRst = HttpResponseWXBLL.e57PostResponse(getVirtualTicketUrl, getVirtualTicketDataStr, "");
// if (!getVirtualTicketRst.ParseToString().Contains("<code>200</code>") && !getVirtualTicketRst.ParseToString().Contains("<code>0</code>"))
// {
// string msg = "";
// string code = "";
// try
// {
// System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
// xmlDoc.LoadXml(getVirtualTicketRst);
// code = xmlDoc["AjaxResult"]["code"].InnerText;
// msg = xmlDoc["AjaxResult"]["msg"].InnerText;
// }
// catch
// {
// msg = getVirtualTicketRst.ParseToString();
// }
// if (!IsAutoBuy)
// BaseMsgForm.ShowError("拍单信息保存成功,接收到服务端传递的错误消息:" + msg, "订单提前取号失败");
// btnManualUpdateBuyOrder.Enabled = true;
// return;
// }
//}
}
#endregion
#region 秒退异常单中转重拍
@@ -1464,8 +1478,9 @@ namespace TemuKJD.ToolForms
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
html = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
{
BaseMsgForm.ShowError("直发拍单信息保存失败(01) " + BaseRegex.GetStringJson(ref html, "msg"));
{
if (!IsAutoBuy)
BaseMsgForm.ShowError("直发拍单信息保存失败(01) " + BaseRegex.GetStringJson(ref html, "msg"));
return;
}
var existOrderExtList = JsonHelper.DeserializeJsonToList<order_item_ext>(JsonHelper.JObjectParse(html)["data"].ParseToString());
@@ -1490,8 +1505,9 @@ namespace TemuKJD.ToolForms
data1 += "&buy_type=" + orderExt.buy_type;
var html1 = GetHtml.PostUtf8(url1, data1);
if (string.IsNullOrEmpty(html1) || !html1.Contains("\"code\":200"))
{
BaseMsgForm.ShowError("直发拍单信息保存失败(02) " + BaseRegex.GetStringJson(ref html1, "msg"));
{
if (!IsAutoBuy)
BaseMsgForm.ShowError("直发拍单信息保存失败(02) " + BaseRegex.GetStringJson(ref html1, "msg"));
return;
}
@@ -1504,8 +1520,9 @@ namespace TemuKJD.ToolForms
if (string.IsNullOrEmpty(html2) || !html2.Contains("\"code\":200"))
html2 = GetHtml.PostUtf8(url2, data2);
if (string.IsNullOrEmpty(html2) || !html2.Contains("\"code\":200"))
{
BaseMsgForm.ShowError("直发拍单信息保存失败(03) " + BaseRegex.GetStringJson(ref html2, "msg"));
{
if (!IsAutoBuy)
BaseMsgForm.ShowError("直发拍单信息保存失败(03) " + BaseRegex.GetStringJson(ref html2, "msg"));
return;
}
@@ -1545,13 +1562,15 @@ namespace TemuKJD.ToolForms
filterOrderAction(order, true);
}
BaseMsgForm.ShowInfo("拍单信息保存成功");
if (!IsAutoBuy)
BaseMsgForm.ShowInfo("拍单信息保存成功");
}
else
{
//order.sendStatus = "发送失败 " + (string.IsNullOrEmpty(msg) ? data : msg);
//NaiBa.Util.Helper.ConfigHelper.SaveConfig("other_buyer_order_list", lstOtherBuyerOrderInfoLite);
BaseMsgForm.ShowError("直发拍单保存失败,服务端返回 " + msg, "拍单信息保存失败");
//order.sendStatus = "发送失败 " + (string.IsNullOrEmpty(msg) ? data : msg);
//NaiBa.Util.Helper.ConfigHelper.SaveConfig("other_buyer_order_list", lstOtherBuyerOrderInfoLite);
if (!IsAutoBuy)
BaseMsgForm.ShowError("直发拍单保存失败,服务端返回 " + msg, "拍单信息保存失败");
return;
}
#endregion
@@ -1757,5 +1776,11 @@ namespace TemuKJD.ToolForms
}
}
}
private void btnCancelAutoBuy_Click(object sender, EventArgs e)
{
IsAutoBuy = false;
BaseMsgForm.ShowInfo("已取消自动拍单");
}
}
}
+36 -8
View File
@@ -109,6 +109,7 @@
this.chkAutoChangeWarehouseAddress = new Work.UserComponents.UcCheckBox(this.components);
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.pnlMap = new System.Windows.Forms.Panel();
this.btnCancelAutoBuy = new DevComponents.DotNetBar.PanelEx();
((System.ComponentModel.ISupportInitialize)(this.pbCloseBase)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
@@ -468,11 +469,11 @@
this.label13.TabIndex = 815;
this.label13.Text = "关联商品信息:";
//
// txtUpSpuCode
// txtSpuCode
//
this.txtSpuCode.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtSpuCode.Location = new System.Drawing.Point(85, 228);
this.txtSpuCode.Name = "txtUpSpuCode";
this.txtSpuCode.Name = "txtSpuCode";
this.txtSpuCode.Size = new System.Drawing.Size(152, 23);
this.txtSpuCode.TabIndex = 814;
//
@@ -485,13 +486,13 @@
this.label12.TabIndex = 813;
this.label12.Text = "平台SKU编码";
//
// txtUpSkuCode
// txtSkuCode
//
this.txtSkuCode.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtSkuCode.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtSkuCode.Location = new System.Drawing.Point(321, 228);
this.txtSkuCode.Name = "txtUpSkuCode";
this.txtSkuCode.Name = "txtSkuCode";
this.txtSkuCode.Size = new System.Drawing.Size(152, 23);
this.txtSkuCode.TabIndex = 812;
//
@@ -755,6 +756,7 @@
//
this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right)));
this.panel1.Controls.Add(this.btnCancelAutoBuy);
this.panel1.Controls.Add(this.panel2);
this.panel1.Controls.Add(this.pnlDirectAddressAnalysis);
this.panel1.Controls.Add(this.chkUseAppBalance);
@@ -949,7 +951,7 @@
this.txtShopName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtShopName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtShopName.Location = new System.Drawing.Point(321, 60);
this.txtShopName.Location = new System.Drawing.Point(321, 67);
this.txtShopName.Name = "txtShopName";
this.txtShopName.Size = new System.Drawing.Size(152, 23);
this.txtShopName.TabIndex = 876;
@@ -958,7 +960,7 @@
//
this.label27.AutoSize = true;
this.label27.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label27.Location = new System.Drawing.Point(253, 63);
this.label27.Location = new System.Drawing.Point(253, 70);
this.label27.Name = "label27";
this.label27.Size = new System.Drawing.Size(68, 17);
this.label27.TabIndex = 875;
@@ -968,7 +970,7 @@
//
this.label26.AutoSize = true;
this.label26.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label26.Location = new System.Drawing.Point(253, 92);
this.label26.Location = new System.Drawing.Point(253, 99);
this.label26.Name = "label26";
this.label26.Size = new System.Drawing.Size(68, 17);
this.label26.TabIndex = 874;
@@ -979,7 +981,7 @@
this.txtOrderId.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtOrderId.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtOrderId.Location = new System.Drawing.Point(321, 89);
this.txtOrderId.Location = new System.Drawing.Point(321, 96);
this.txtOrderId.Name = "txtOrderId";
this.txtOrderId.Size = new System.Drawing.Size(152, 23);
this.txtOrderId.TabIndex = 873;
@@ -1137,6 +1139,31 @@
this.pnlMap.Size = new System.Drawing.Size(468, 203);
this.pnlMap.TabIndex = 871;
//
// btnCancelAutoBuy
//
this.btnCancelAutoBuy.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnCancelAutoBuy.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.btnCancelAutoBuy.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnCancelAutoBuy.DisabledBackColor = System.Drawing.Color.Empty;
this.btnCancelAutoBuy.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnCancelAutoBuy.Location = new System.Drawing.Point(376, 35);
this.btnCancelAutoBuy.Name = "btnCancelAutoBuy";
this.btnCancelAutoBuy.Size = new System.Drawing.Size(97, 23);
this.btnCancelAutoBuy.Style.Alignment = System.Drawing.StringAlignment.Center;
this.btnCancelAutoBuy.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(152)))), ((int)(((byte)(99)))), ((int)(((byte)(143)))));
this.btnCancelAutoBuy.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(152)))), ((int)(((byte)(99)))), ((int)(((byte)(143)))));
this.btnCancelAutoBuy.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder;
this.btnCancelAutoBuy.Style.BorderDashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
this.btnCancelAutoBuy.Style.BorderSide = DevComponents.DotNetBar.eBorderSide.None;
this.btnCancelAutoBuy.Style.ForeColor.Color = System.Drawing.Color.White;
this.btnCancelAutoBuy.Style.GradientAngle = 90;
this.btnCancelAutoBuy.StyleMouseOver.Alignment = System.Drawing.StringAlignment.Center;
this.btnCancelAutoBuy.StyleMouseOver.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(107)))), ((int)(((byte)(83)))), ((int)(((byte)(147)))));
this.btnCancelAutoBuy.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(107)))), ((int)(((byte)(83)))), ((int)(((byte)(147)))));
this.btnCancelAutoBuy.TabIndex = 887;
this.btnCancelAutoBuy.Text = "取消自动拍单";
this.btnCancelAutoBuy.Click += new System.EventHandler(this.btnCancelAutoBuy_Click);
//
// PddMobileBuyOrderForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
@@ -1259,5 +1286,6 @@
private System.Windows.Forms.ComboBox cmbMapSkus;
private System.Windows.Forms.Label label31;
private System.Windows.Forms.PictureBox pictureBox2;
private DevComponents.DotNetBar.PanelEx btnCancelAutoBuy;
}
}