1优化订单列表展示 2拍单逻辑优化调整 3自动拍单

This commit is contained in:
wule committed 2026-09-11 11:41:54 +08:00
1 parent b2d91563ed
commit b03753e0cf
10 files changed
+309 -95

No files matched your search

@@ -608,17 +608,29 @@
Content="已关联拍单"
FontSize="12" />
<Button
x:Name="btnAutoBuy"
Width="Auto"
Height="22"
MinWidth="48"
Margin="8,0,4,0"
Padding="4,0"
c:DebugVisibility.Enable="True"
Click="Button_Click"
Command="{Binding MultipleShipGiftCommand}"
Click="btnAutoBuy_Click"
Content="自动拍单"
FontSize="12"
Style="{StaticResource BasePageButtonStyle}" />
<Button
x:Name="btnAutoBuyIntorduction"
Width="Auto"
Height="22"
MinWidth="48"
Margin="0,0,4,0"
Padding="4,0"
c:DebugVisibility.Enable="True"
Click="btnAutoBuyIntroduction_Click"
Content="自动拍单说明"
FontSize="12"
Style="{StaticResource BasePageButtonLightStyle}" />
<Polyline
Grid.Column="5"
Width="10"
@@ -2706,7 +2706,23 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
FilterOrders();
}
private async void Button_Click(object sender, RoutedEventArgs e)
private async void btnAutoBuy_Click(object sender, RoutedEventArgs e)
{
var buyOrders = GlobalConfig.lstFilterOrder.Where(o => o.IsWaitBuy && o.orderItems?.Count == 1 && o.orderItems.FirstOrDefault()?.BuyMap != null && o.IsSelect == true).ToList();
if (buyOrders.Count == 0)
{
BaseMsgWindow.ShowError("未勾选符合条件的订单!");
return;
}
foreach (var order in buyOrders)
{
var orderItem = order.orderItems.FirstOrDefault();
await OrderListRowItemCtrl.BuyOrder(orderItem, true);
}
}
private void btnAutoBuyIntroduction_Click(object sender, RoutedEventArgs e)
{
}
@@ -51,7 +51,7 @@
<ColumnDefinition Width="36" />
<ColumnDefinition Width="28" />
<ColumnDefinition Width="200*" />
<ColumnDefinition Width="100*" MinWidth="200" />
<ColumnDefinition Width="100*" MinWidth="180" />
<ColumnDefinition Width="75*" MinWidth="130" />
<ColumnDefinition Width="170*" MinWidth="280" />
<ColumnDefinition Width="120*" />
@@ -196,7 +196,7 @@
VerticalSpacing="2">
<wpf:TitleContent Title="成交时间:">
<uc:UcWaterMarkTextBox1
d:Text="2000-01-01 01:01:01"
d:Text="00-01-01 01:01:01"
Background="Transparent"
BorderThickness="0"
IsReadOnly="True"
@@ -647,7 +647,8 @@
Title="采购账户:"
Cursor="Hand"
Foreground="#0099ff"
MouseLeftButtonUp="TransitOrderBuye_Click">
MouseLeftButtonUp="TransitOrderBuye_Click"
Visibility="{Binding ElementName=txtTransitOrderBuyerStr, Path=Text, Converter={StaticResource HasTextVisibility}}">
<WrapPanel Orientation="Horizontal">
<uc:UcWaterMarkTextBox1
x:Name="txtTransitOrderBuyerStr"
@@ -692,7 +693,8 @@
x:Name="wpBuyOrderId"
Title="采购单号:"
Cursor="Hand"
Foreground="#0099ff">
Foreground="#0099ff"
Visibility="{Binding ElementName=txtTransitOrderNumStr, Path=Text, Converter={StaticResource HasTextVisibility}}">
<WrapPanel Orientation="Horizontal">
<uc:UcWaterMarkTextBox1
x:Name="txtTransitOrderNumStr"
@@ -730,7 +732,8 @@
<wpf:TitleContent
x:Name="wpBuyTime"
Title="采购时间:"
Foreground="{Binding OutOrderTimeQualifiedBrush}">
Foreground="{Binding OutOrderTimeQualifiedBrush}"
Visibility="{Binding ElementName=txtOutOrderTimeQualifiedStr, Path=Text, Converter={StaticResource HasTextVisibility}}">
<uc:UcWaterMarkTextBox1
x:Name="txtOutOrderTimeQualifiedStr"
Margin="-2,2"
@@ -869,6 +872,23 @@
</Border>
</WrapPanel>
</wpf:TitleContent>
<!-- 采购时间 -->
<wpf:TitleContent
x:Name="wpDirectBuyTime"
Title="外采时间:"
Visibility="{Binding ElementName=txtDirectOrderBuyTimeStr, Path=Text, Converter={StaticResource HasTextVisibility}}">
<uc:UcWaterMarkTextBox1
x:Name="txtDirectOrderBuyTimeStr"
Margin="-2,2"
Padding="0"
VerticalAlignment="Top"
Background="Transparent"
BorderThickness="0"
IsReadOnly="True"
Text="{Binding DirectOrderBuyTimeStr}"
TextWrapping="Wrap"
WaterMark="采购时间:" />
</wpf:TitleContent>
<!-- 外采物流 -->
<wpf:TitleContent Title="外采物流:" Visibility="{Binding ItemOrder.OutExpressNoStr, Converter={StaticResource HasTextVisibility}}">
@@ -956,12 +976,12 @@
<!-- 买家留言 -->
<wpf:TitleContent Title="买家留言:">
<uc:UcWaterMarkTextBox1
d:Text="留言留言"
Background="Transparent"
BorderThickness="1"
IsReadOnly="True"
Text=""
TextWrapping="Wrap"
WaterMark="买家留言" />
TextWrapping="Wrap" />
</wpf:TitleContent>
<!-- 店铺备注 -->
@@ -1166,20 +1186,24 @@
Grid.Column="8"
VerticalAlignment="Center"
Orientation="Vertical"
VerticalSpacing="5">
VerticalSpacing="6">
<wpf:TitleContent>
<Button
x:Name="btnMapSkus"
Height="24"
MinWidth="38"
Margin="4,0,0,0"
HorizontalAlignment="Center"
Click="btnMapSkus_Click"
Content="选择SKU"
Style="{StaticResource BasePageButtonLightStyle}"
Visibility="{Binding MapSkusBtnVisibility}" />
</wpf:TitleContent>
<!-- 操作按钮行(原 Row 1) -->
<wpf:TitleContent>
<WrapPanel HorizontalAlignment="Center" Orientation="Vertical">
<Button
x:Name="btnMapSkus"
Height="24"
MinWidth="38"
Margin="4,4,0,4"
HorizontalAlignment="Center"
Click="btnMapSkus_Click"
Content="选择SKU"
Style="{StaticResource BasePageButtonLightStyle}"
Visibility="{Binding MapSkusBtnVisibility}" />
<Button
x:Name="btnBuyOrder"
@@ -309,14 +309,18 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
txtAppRemark.IsReadOnly = true;
}
private void btnBuyOrder_Click(object sender, RoutedEventArgs e)
private async void btnBuyOrder_Click(object sender, RoutedEventArgs e)
{
BuyOrder();
if (this.DataContext is oms_wei_order_item_info orderItem)
{
btnBuyOrder.IsEnabled = false;
await BuyOrder(orderItem);
btnBuyOrder.IsEnabled = true;
}
}
public void BuyOrder(bool isAbnormalOrder = false)
public static async Task BuyOrder(oms_wei_order_item_info orderItem, bool isAutoBuy = false, bool isAbnormalOrder = false)
{
var orderItem = this.DataContext as oms_wei_order_item_info;
if (orderItem == null)
{
BaseMsgWindow.ShowError("订单信息为空");
@@ -342,14 +346,7 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
return;
}
btnBuyOrder.Cursor = Cursors.Wait;
btnBuyOrder.IsEnabled = false;
Task.Run(() =>
{
Thread.Sleep(2000);
Dispatcher.Invoke(new Action(() => { btnBuyOrder.IsEnabled = true; }));
});
Task.Run(() =>
await Task.Run(() =>
{
// 拍单前查询订单是否退款
var orderId = orderItem.order_id;
@@ -387,11 +384,7 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
}
if (GlobalConfig.CurrentPddBuyer.status != "在线")
{
Dispatcher.Invoke(new Action(() =>
{
BaseMsgWindow.ShowError("买手号掉线");
btnBuyOrder.Cursor = Cursors.Hand;
}));
BaseMsgWindow.ShowError("买手号掉线");
return;
}
@@ -404,10 +397,7 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
{
if (BaseClass.Balance < 10)
{
Dispatcher.Invoke(new Action(() =>
{
BaseMsgWindow.ShowError("软件快递余额不足(剩余" + BaseClass.Balance.ToString("0.00") + "元,拍单至少需保留10元),无法中转拍单,请先充值!");
}));
BaseMsgWindow.ShowError("软件快递余额不足(剩余" + BaseClass.Balance.ToString("0.00") + "元,拍单至少需保留10元),无法中转拍单,请先充值!");
return;
}
}
@@ -423,10 +413,6 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
html = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
{
Dispatcher.Invoke(new Action(() =>
{
btnBuyOrder.Cursor = Cursors.Hand;
}));
GlobalConfig.BuyConfig.IsUseAppBalance = true;
StartUp.SaveBuyConfig();
BaseMsgWindow.ShowError("未找到店铺账户!" + BaseRegex.GetStringJson(ref html, "msg") + ",自动切换为快递余额拍单。");
@@ -440,10 +426,6 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
var erpM = erpMs.FirstOrDefault();
if (erpM == null)
{
Dispatcher.Invoke(new Action(() =>
{
btnBuyOrder.Cursor = Cursors.Hand;
}));
GlobalConfig.BuyConfig.IsUseAppBalance = true;
StartUp.SaveBuyConfig();
BaseMsgWindow.ShowError("未找到店铺账户!自动切换为快递余额拍单。");
@@ -453,10 +435,6 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
var balance = erpM.balance.ParseToDecimal();
if (balance < 10)
{
Dispatcher.Invoke(new Action(() =>
{
btnBuyOrder.Cursor = Cursors.Hand;
}));
GlobalConfig.BuyConfig.IsUseAppBalance = true;
StartUp.SaveBuyConfig();
BaseMsgWindow.ShowError("ERP账户余额不足(剩余" + balance.ToString("0.00") + "元,拍单至少需保留10元),无法中转拍单,自动切换为快递余额拍单。");
@@ -465,11 +443,7 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
}
catch
{
Dispatcher.Invoke(new Action(() =>
{
BaseMsgWindow.ShowError("拍单校验出错,请稍后重试");
btnBuyOrder.Cursor = Cursors.Hand;
}));
BaseMsgWindow.ShowError("拍单校验出错,请稍后重试");
return;
}
}
@@ -507,10 +481,6 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
// Dispatcher.Invoke(new Action(() => { o.UpdateOrderItemBuyButton(); }));
//}
}
Dispatcher.Invoke(new Action(() =>
{
btnBuyOrder.Cursor = Cursors.Hand;
}));
return;
}
@@ -572,13 +542,9 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
{
// 更新代发管理情况
foreach (var oi in ord.orderItems)
Dispatcher.Invoke(new Action(() => { oi.UpdateOrderItemBuyButton(); }));
MainWindow.Instance.Dispatcher.Invoke(new Action(() => { oi.UpdateOrderItemBuyButton(); }));
}
Dispatcher.Invoke(new Action(() =>
{
BaseMsgWindow.ShowError("请登录店铺");
btnBuyOrder.Cursor = Cursors.Hand;
}));
BaseMsgWindow.ShowError("请登录店铺");
return;
}
@@ -586,12 +552,11 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
//return;
// 打开拍单窗口
Dispatcher.Invoke(new Action(() =>
MainWindow.Instance.Dispatcher.Invoke(new Action(() =>
{
btnBuyOrder.Cursor = Cursors.Hand;
PddMobileBuyOrderForm buyOrderForm = new PddMobileBuyOrderForm(MainWindow.Instance.orderListCtrl.FilterOneOrder, StartUp.UpdateBalance,
orderItem, GlobalConfig.CurrentPddBuyer, orderItem.BuyMap);
buyOrderForm.IsAutoBuy = isAutoBuy;
buyOrderForm.TitleText = "买手拍单 - 当前买手 " + GlobalConfig.CurrentPddBuyer.buyer_nick;
@@ -698,7 +663,7 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
/// </summary>
/// <param name="order_item"></param>
/// <returns></returns>
bool GetIsAbnormalOrderRebuy(oms_wei_order_item_info order_item)
static bool GetIsAbnormalOrderRebuy(oms_wei_order_item_info order_item)
{
// 不是异常单的不可异常重拍
if (order_item?.ItemOrder?.isAbnormal != true)
@@ -1126,12 +1091,12 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
}
}
private void btnAbnormalOrderRebuy_Click(object sender, RoutedEventArgs e)
private async void btnAbnormalOrderRebuy_Click(object sender, RoutedEventArgs e)
{
if (this.DataContext is oms_wei_order_item_info orderItem)
{
if (orderItem.ItemOrder.status > 21 && orderItem.ItemTransitOrder != null && orderItem.ItemTransitOrder.refund_status == "买手退款成功")
BuyOrder(true);
await BuyOrder(orderItem, false, true);
}
}
@@ -1315,11 +1280,11 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
});
}
bool CheckIsRefund(oms_wei_order_item_info orderItem)
static bool CheckIsRefund(oms_wei_order_item_info orderItem)
{
if (/*orderItem?.ItemRefund?.count > 0 &&*/ orderItem.refund_status > 1)
{
Dispatcher.Invoke(new Action(() =>
MainWindow.Instance.Dispatcher.Invoke(new Action(() =>
{
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ErpShopId == orderItem.shop_id.ParseToString());
if (shop != null)