增加发票助手 开票过程中错误提示

This commit is contained in:
chfei committed 2026-10-21 11:30:39 +08:00
1 parent 3affb4a732
commit 483d87f57d
3 files changed
+108 -53

No files matched your search

@@ -1,7 +1,5 @@
using _29WxOrderWpf.BaseWindows;
using _29WxOrderWpf.CefHelper;
using WxOrder.Framework.Commons;
using WxOrder.Framework.Commons;
using _29WxOrderWpf.Ctrls.Statistics;
using AllBase;
using AllBase.Helper;
@@ -14,6 +12,7 @@ using CefSharp.Wpf;
using NaiBa.Util.Extension;
using Newtonsoft.Json;
using NPOI.SS.Formula.Functions;
using Org.BouncyCastle.Asn1.X509;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -37,6 +36,8 @@ using WPFCommon.Converters;
using WPFCommon.Helpers;
using WPFCommon.Models;
using WxOrder.Framework.Commons;
using WxOrder.Framework.Commons;
using WxOrder.Framework.Commons;
using WxOrder.Framework.Commons.Dialogs;
using WxOrder.Framework.Helpers;
@@ -284,7 +285,7 @@ public partial class PDDInvoiceViewModel : BindableBaseEx, IDialogAware, IDispos
public ICommand ResetCommand => new DelegateCommand(ResetSearch);
public ICommand OpenInvoiceCommand => new DelegateCommand<PddBrowserOrderInvoiceViewModel>(OpenInvoice);
public ICommand OpenInvoiceCommand => new AsyncDelegateCommand<PddBrowserOrderInvoiceViewModel>(OpenInvoice);
public ICommand ShowInvoiceCommand => new DelegateCommand<PddBrowserOrderInvoiceViewModel>(ShowInvoice);
@@ -434,7 +435,7 @@ public partial class PDDInvoiceViewModel : BindableBaseEx, IDialogAware, IDispos
}
/// <summary> 当前正在批量处理的订单,页面脚本执行完成后通过它回传结果 </summary>
private TaskCompletionSource<bool> _currentInvoiceTcs;
private TaskCompletionSource<Result<bool>> _currentInvoiceTcs;
public ICommand BatchInvoiceCommand => new AsyncDelegateCommand(BatchInvoice);
@@ -471,8 +472,19 @@ public partial class PDDInvoiceViewModel : BindableBaseEx, IDialogAware, IDispos
//Config.TaxNo = TaxNo;
//Config.MaxAmount = MaxAmount;
//NaiBa.Util.Helper.ConfigHelper.SaveConfig(ConfigPath, Config);
try
{
await BatchInvoiceAsync(targets);
}
catch (Exception ex)
{
BaseMsgWindow.ShowError("批量开票异常:" + ex.Message);
await BatchInvoiceAsync(targets);
}
finally
{
BaseMsgWindow.ShowInfo(BottomMsg);
}
}
public ICommand StopBatchInvoiceCommand => new AsyncDelegateCommand(StopBatchInvoice);
@@ -541,12 +553,12 @@ public partial class PDDInvoiceViewModel : BindableBaseEx, IDialogAware, IDispos
}
else
{
_currentInvoiceTcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
_currentInvoiceTcs = new TaskCompletionSource<Result<bool>>(TaskCreationOptions.RunContinuationsAsynchronously);
BrowserDetail.Load($"https://mobile.yangkeduo.com/transac_return_compensation.html?_t_timestamp=transac_modify_invoice&order_sn={order.order_sn}");
// 等待页面脚本执行完成(最长 60 秒)
var done = await Task.WhenAny(_currentInvoiceTcs.Task, Task.Delay(TimeSpan.FromSeconds(60)));
ok = done == _currentInvoiceTcs.Task && _currentInvoiceTcs.Task.Result;
Task done = await Task.WhenAny(_currentInvoiceTcs.Task, Task.Delay(TimeSpan.FromSeconds(10)));
ok = done == _currentInvoiceTcs.Task && _currentInvoiceTcs.Task.Result.Data;
}
if (ok)
{
@@ -562,6 +574,10 @@ public partial class PDDInvoiceViewModel : BindableBaseEx, IDialogAware, IDispos
}
else
{
if (_currentInvoiceTcs.Task.IsCompleted)
{
order.InvoiceStatusText = _currentInvoiceTcs.Task.Result.Msg;
}
fail++;
}
ProgressValue = success + fail;
@@ -580,7 +596,7 @@ public partial class PDDInvoiceViewModel : BindableBaseEx, IDialogAware, IDispos
catch (Exception ex)
{
fail = targets.Count - success;
BaseMsgWindow.ShowError("批量开票异常:" + ex.Message);
throw ex;
}
finally
{
@@ -588,7 +604,6 @@ public partial class PDDInvoiceViewModel : BindableBaseEx, IDialogAware, IDispos
ProgressMaximum = targets.Count;
ProgressValue = targets.Count;
IsBatchInvoicing = false;
BaseMsgWindow.ShowInfo(BottomMsg);
}
}
/// <summary>
@@ -642,7 +657,7 @@ public partial class PDDInvoiceViewModel : BindableBaseEx, IDialogAware, IDispos
/// 申请开票
/// </summary>
/// <param name="order"></param>
private void OpenInvoice(PddBrowserOrderInvoiceViewModel order)
private async Task OpenInvoice(PddBrowserOrderInvoiceViewModel order)
{
SelectedOrder = order;
if (string.IsNullOrEmpty(Config.Title) || string.IsNullOrEmpty(Config.TaxNo))
@@ -650,8 +665,19 @@ public partial class PDDInvoiceViewModel : BindableBaseEx, IDialogAware, IDispos
BaseMsgWindow.ShowError("未填写公司或税号");
return;
}
BrowserDetail.Load($"https://mobile.yangkeduo.com/transac_return_compensation.html?_t_timestamp=transac_modify_invoice&order_sn={order.order_sn}");
ShowOrderBrowserDetail();
//BrowserDetail.Load($"https://mobile.yangkeduo.com/transac_return_compensation.html?_t_timestamp=transac_modify_invoice&order_sn={order.order_sn}");
try
{
await BatchInvoiceAsync(new List<PddBrowserOrderInvoiceViewModel>
{
order
});
}
catch (Exception ex)
{
BaseMsgWindow.ShowError("开票异常:" + ex.Message);
}
}
private void ShowInvoice(PddBrowserOrderInvoiceViewModel order)