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

@@ -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)