订单任务,现已修改成全局任务列表 包括 订单任务和礼品单任务
订单列表动态展示礼品单状态
This commit is contained in:
1 parent
78dc8a5d03
commit
7998a753cc
20 files changed
+2820
-2627
No files matched your search
@@ -46,6 +46,7 @@ using TemuKJD.ToolForms;
|
||||
using Work;
|
||||
using Work._29Tools.BLL;
|
||||
using Work.BuyUsers;
|
||||
using Work.KJDServer.API.Models;
|
||||
using WPFCommon.Helpers;
|
||||
using static _29WxOrderWpf.Services.ShipGiftService;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
@@ -62,7 +63,9 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
|
||||
public OrderFilterConfig orderFilterConfig
|
||||
{
|
||||
get { return _orderFilterConfig; }
|
||||
set { if (_orderFilterConfig != value)
|
||||
set
|
||||
{
|
||||
if (_orderFilterConfig != value)
|
||||
_orderFilterConfig = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("orderFilterConfig"));
|
||||
}
|
||||
@@ -76,7 +79,7 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = this;
|
||||
_shipGiftService = new ShipGiftService();
|
||||
_shipGiftService = ShipGiftService.Instance;
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
@@ -103,8 +106,13 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
|
||||
borderFilterRemarkSelect.Visibility = Visibility.Collapsed;
|
||||
|
||||
AutoGetOrder();
|
||||
|
||||
TaskService.Instance.Start();
|
||||
TaskService.Instance.TaskChanged += Instance_TaskChanged;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//public void GetOrderTest()
|
||||
//{
|
||||
// for (int i = 0; i < 10000; i++)
|
||||
@@ -837,7 +845,7 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
|
||||
{
|
||||
|
||||
}
|
||||
if (orderItem.TransitRefundStatusStr.ParseToString().Contains("需手动申请售后") &&
|
||||
if (orderItem.TransitRefundStatusStr.ParseToString().Contains("需手动申请售后") &&
|
||||
orderItem.ItemTransitOrderWithVoid?.has_reject == 3 && orderItem.ItemTransitOrderWithVoid?.platform != "XDYYWC") // 义乌仓不支持拒收,等于3也是失败
|
||||
{
|
||||
// 拒收后24小时才去总店填拒收退货
|
||||
@@ -1043,7 +1051,7 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
|
||||
var type = 4;
|
||||
if (chkRst.Contains("\"interactType\":0"))
|
||||
type = 2;
|
||||
var result = AddReturnPddShopPackageInfo(buyer, orderSn, afterSalesId, waybillId,"韵达快递", "121", type.ToString());
|
||||
var result = AddReturnPddShopPackageInfo(buyer, orderSn, afterSalesId, waybillId, "韵达快递", "121", type.ToString());
|
||||
if (!result.Contains("\"result\":\"ok\""))
|
||||
{
|
||||
type = type == 4 ? 2 : 4;
|
||||
@@ -1096,7 +1104,7 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
|
||||
|
||||
TabItem tabItem = null;
|
||||
List<TabItem> tabItems = this.tabOrderType.Items.Cast<TabItem>().ToList();
|
||||
Dispatcher.Invoke(new Action(() => { tabItem = tabItems.FirstOrDefault(t => t.Header.ParseToString().StartsWith("待采购")); }));
|
||||
Dispatcher.Invoke(new Action(() => { tabItem = tabItems.FirstOrDefault(t => t.Header.ParseToString().StartsWith("待采购")); }));
|
||||
if (tabItem != null)
|
||||
{
|
||||
var filteLstTmp = userOrderLst.Where(o => !GetOrderIsFilter(o, "待采购")).ToList();
|
||||
@@ -1513,7 +1521,7 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
|
||||
{
|
||||
Thread.Sleep(5000);
|
||||
Dispatcher.Invoke(new Action(() => { this.btnSearch.IsEnabled = true; }));
|
||||
});
|
||||
});
|
||||
//Task.Run(() =>
|
||||
//{
|
||||
// GetOrder();
|
||||
@@ -1902,7 +1910,7 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
|
||||
public async Task DoReturnOrderBuyerRefendSlient()
|
||||
{
|
||||
List<oms_wei_order_info> emergencyRefundOrders = new List<oms_wei_order_info>();
|
||||
Dispatcher.Invoke(new Action(() =>
|
||||
Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
emergencyRefundOrders = GlobalConfig.lstOrder.Where(o => o.IsEmergency).ToList();
|
||||
}));
|
||||
@@ -2281,7 +2289,7 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
|
||||
FilterOrders();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -2398,7 +2406,27 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
|
||||
// set => SetProperty(ref _IsShipGift, value);
|
||||
//}
|
||||
|
||||
private void Instance_TaskChanged(object sender, IEnumerable<Work.KJDServer.API.Models.TaskItem> data)
|
||||
{
|
||||
var giftTaks = data.Where(a => a.TaskType == Work.KJDServer.API.Models.TaskType.Gifts && a.SubTasks != null)
|
||||
.SelectMany(a => a.SubTasks)
|
||||
.GroupBy(a => a.ObjectId)
|
||||
.Select(a => a.OrderByDescending(b => b.CreateTime).First())
|
||||
.ToList();
|
||||
|
||||
foreach (TaskSubItem item in giftTaks)
|
||||
{
|
||||
oms_wei_order_info order = GlobalConfig.lstOrder.FirstOrDefault(a => a.order_id == item.ObjectId);
|
||||
if (order != null)
|
||||
{
|
||||
order.GiftSuccessed = item.Status == 1;
|
||||
if (order.GiftSuccessed == false)
|
||||
{
|
||||
order.GiftErrorMsg = item.SysMsg;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class OrderFilterConfig : PropertyNotifyObject
|
||||
@@ -2408,7 +2436,7 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
|
||||
/// <summary>
|
||||
/// 隐藏标记
|
||||
/// </summary>
|
||||
public bool chkHideGreenFlagIsChecked
|
||||
public bool chkHideGreenFlagIsChecked
|
||||
{
|
||||
get { return this.GetValue(x => x.chkHideGreenFlagIsChecked); }
|
||||
set { this.SetValue(x => x.chkHideGreenFlagIsChecked, value); }
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -2,22 +2,29 @@
|
||||
x:Class="_29WxOrderWpf.Ctrls.OrderCtrls.OrderTaskDialogView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:comn="clr-namespace:_29WxOrderWpf.Common"
|
||||
xmlns:converters="clr-namespace:_29WxOrderWpf.Converters"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:_29WxOrderWpf.Ctrls.OrderCtrls"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:wpf="clr-namespace:_29WxOrderWpf.Common"
|
||||
xmlns:wpf1="WPFCommon"
|
||||
xmlns:md="clr-namespace:Work.KJDServer.API.Models;assembly=29WxOrderWork"
|
||||
xmlns:wpf="WPFCommon"
|
||||
xmlns:wpfex="clr-namespace:WPFCommon.Extensions;assembly=WPFCommon"
|
||||
comn:DialogWindowProperty.Height="600"
|
||||
comn:DialogWindowProperty.ResizeMode="CanResizeWithGrip"
|
||||
comn:DialogWindowProperty.ShowMinButton="False"
|
||||
comn:DialogWindowProperty.Width="1300"
|
||||
d:Background="White"
|
||||
d:DataContext="{d:DesignInstance Type=local:OrderTaskDialogViewModel}"
|
||||
d:DesignHeight="600"
|
||||
d:DesignWidth="1300"
|
||||
wpf:DialogWindowProperty.Height="600"
|
||||
wpf:DialogWindowProperty.ResizeMode="CanResizeWithGrip"
|
||||
wpf:DialogWindowProperty.ShowMinButton="False"
|
||||
wpf:DialogWindowProperty.Width="1300"
|
||||
mc:Ignorable="d">
|
||||
<UserControl.Resources>
|
||||
|
||||
<Style BasedOn="{StaticResource TitleContentBaseStyle}" TargetType="wpf:TitleContent">
|
||||
<Setter Property="Placement" Value="Left" />
|
||||
<Setter Property="TitleVerticalAlignment" Value="Center" />
|
||||
</Style>
|
||||
<!-- 单元格文字居中 -->
|
||||
<Style x:Key="CenterCellTextStyle" TargetType="TextBlock">
|
||||
<Setter Property="TextAlignment" Value="Center" />
|
||||
@@ -98,14 +105,30 @@
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Style="{StaticResource PanelTitleStyle}" Text="订单同步任务列表" />
|
||||
<CheckBox
|
||||
Margin="20,0,0,0"
|
||||
VerticalAlignment="Center"
|
||||
Content="查看全部"
|
||||
IsChecked="{Binding IsShowAll}" />
|
||||
</StackPanel>
|
||||
<wpf:SpacingStackPanel HorizontalSpacing="10" Orientation="Horizontal">
|
||||
<wpf:TitleContent Title="开始时间:">
|
||||
<DatePicker
|
||||
Width="100"
|
||||
BorderBrush="{StaticResource pageColorBrush}"
|
||||
Text="{Binding StartDate}" />
|
||||
</wpf:TitleContent>
|
||||
<wpf:TitleContent Title="结束时间:">
|
||||
<DatePicker
|
||||
Width="100"
|
||||
BorderBrush="{StaticResource pageColorBrush}"
|
||||
Text="{Binding EndDate}" />
|
||||
</wpf:TitleContent>
|
||||
<wpf:TitleContent Title="任务类型:">
|
||||
<ComboBox
|
||||
Width="100"
|
||||
wpf:EnumBindingExtension.SelectedEnum="{Binding SelectedTaskType}"
|
||||
ItemsSource="{wpf:EnumBindingMarkup EnumType=md:TaskType,
|
||||
Converter={StaticResource EnumDisplayConverter}}" />
|
||||
</wpf:TitleContent>
|
||||
<wpf:TitleContent Title="所有状态:" VerticalContentAlignment="Center">
|
||||
<CheckBox VerticalAlignment="Center" IsChecked="{Binding IsShowAll}" />
|
||||
</wpf:TitleContent>
|
||||
</wpf:SpacingStackPanel>
|
||||
<!--<StackPanel Grid.Column="1" Orientation="Horizontal">
|
||||
<Button
|
||||
Command="{Binding ClearFinishedCommand}"
|
||||
@@ -122,7 +145,7 @@
|
||||
<!-- ============ 任务列表 ============ -->
|
||||
<DataGrid
|
||||
Grid.Row="1"
|
||||
Margin="10,10,10,0"
|
||||
Margin="10,10,10,10"
|
||||
d:ItemsSource="{d:SampleData ItemCount=10}"
|
||||
AlternatingRowBackground="#FAFAFA"
|
||||
AutoGenerateColumns="False"
|
||||
@@ -141,7 +164,7 @@
|
||||
HorizontalGridLinesBrush="#EEEEEE"
|
||||
IsReadOnly="True"
|
||||
ItemsSource="{Binding TasksView}"
|
||||
RowHeight="40"
|
||||
RowHeight="35"
|
||||
ScrollViewer.CanContentScroll="True"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Auto"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
@@ -153,9 +176,9 @@
|
||||
<DataGridTextColumn
|
||||
Width="1.5*"
|
||||
MinWidth="120"
|
||||
Binding="{Binding TaskDescribe}"
|
||||
Binding="{Binding TaskType, Converter={StaticResource EnumDisplayConverter}}"
|
||||
ElementStyle="{StaticResource CenterCellTextStyle}"
|
||||
Header="任务描述" />
|
||||
Header="任务类型" />
|
||||
<!-- 店铺 -->
|
||||
<DataGridTextColumn
|
||||
Width="1*"
|
||||
@@ -164,7 +187,12 @@
|
||||
ElementStyle="{StaticResource CenterCellTextStyle}"
|
||||
Header="店铺" />
|
||||
|
||||
|
||||
<DataGridTextColumn
|
||||
Width="2*"
|
||||
MinWidth="100"
|
||||
Binding="{Binding ObjectIds}"
|
||||
ElementStyle="{StaticResource CenterCellTextStyle}"
|
||||
Header="订单号" />
|
||||
<!-- 状态 -->
|
||||
<DataGridTemplateColumn
|
||||
Width="1*"
|
||||
@@ -236,8 +264,8 @@
|
||||
<Grid VerticalAlignment="Center">
|
||||
<TextBlock
|
||||
HorizontalAlignment="Right"
|
||||
d:Text="距离下次刷新10秒"
|
||||
Text="{Binding RefreshTime, StringFormat='距离下次刷新:{0}秒'}" />
|
||||
d:Text="刷新10秒"
|
||||
Text="{Binding RefreshTime, StringFormat='刷新:{0}秒'}" />
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.ComTypes;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
@@ -44,7 +45,7 @@ public partial class OrderTaskDialogView : UserControl
|
||||
|
||||
private async void OrderTaskDialogView_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await _viewModel.LoadTasks();
|
||||
_viewModel.LoadTasks();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,75 +55,103 @@ public partial class OrderTaskDialogView : UserControl
|
||||
public class OrderTaskDialogViewModel : BindableBaseEx, IDisposable
|
||||
{
|
||||
private DispatcherTimer _timer;
|
||||
private const int RefreshIntervals = 10;
|
||||
private int _timeCount = 0;
|
||||
private readonly PullWXOrderService _service;
|
||||
private readonly NotifyCollectionChangedEventHandler _collectionChangedHandler;
|
||||
|
||||
private readonly TaskService _taskService;
|
||||
|
||||
public OrderTaskDialogViewModel()
|
||||
: this(PullWXOrderService.Instance)
|
||||
: this(TaskService.Instance)
|
||||
{
|
||||
_timer = new DispatcherTimer();
|
||||
_timer.Interval = TimeSpan.FromSeconds(1);
|
||||
_timer.Tick += _timer_Tick;
|
||||
_timer.Start();
|
||||
}
|
||||
|
||||
private async void _timer_Tick(object sender, EventArgs e)
|
||||
public OrderTaskDialogViewModel(TaskService taskService)
|
||||
{
|
||||
_timeCount++;
|
||||
if (_timeCount % RefreshIntervals == 0)
|
||||
{
|
||||
await LoadTasks();
|
||||
_timeCount = 0;
|
||||
}
|
||||
RefreshTime = RefreshIntervals - _timeCount;
|
||||
}
|
||||
|
||||
public OrderTaskDialogViewModel(PullWXOrderService service)
|
||||
{
|
||||
_service = service ?? PullWXOrderService.Instance;
|
||||
Tasks = _service.Tasks;
|
||||
_collectionChangedHandler = OnTasksCollectionChanged;
|
||||
Tasks.CollectionChanged += _collectionChangedHandler;
|
||||
_taskService = taskService;
|
||||
|
||||
|
||||
ClearFinishedCommand = new DelegateCommand(ClearFinished);
|
||||
ClearAllCommand = new DelegateCommand(ClearAll);
|
||||
StartDate = _taskService.StartDate;
|
||||
EndDate = _taskService.EndDate;
|
||||
|
||||
UpdateSummary();
|
||||
|
||||
|
||||
Tasks = new ObservableCollection<TaskItem>();
|
||||
|
||||
TasksView = CollectionViewSource.GetDefaultView(Tasks);
|
||||
TasksView.Filter = FilterTaskStatus;
|
||||
|
||||
_taskService.TaskChanged += TaskChanged;
|
||||
}
|
||||
private async void _timer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
RefreshTime = _taskService.ResetCountdown;
|
||||
}
|
||||
|
||||
public async Task LoadTasks()
|
||||
|
||||
public TaskType SelectedTaskType
|
||||
{
|
||||
await _service.GetTaskStatus();
|
||||
get => GetValue<TaskType>();
|
||||
set
|
||||
{
|
||||
SetValue(value);
|
||||
TasksView.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private void TaskChanged(object sender, IEnumerable<TaskItem> data)
|
||||
{
|
||||
LoadTasks();
|
||||
}
|
||||
|
||||
public void LoadTasks()
|
||||
{
|
||||
System.Windows.Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
Tasks.Clear();
|
||||
foreach (var item in TaskService.Instance.Tasks)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item.TaskFailReason))
|
||||
{
|
||||
if (item.TaskFailReason.Contains("任务执行异常"))
|
||||
{
|
||||
item.Status = 4;
|
||||
}
|
||||
}
|
||||
Tasks.Add(item);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 过滤
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
private bool FilterTaskStatus(object obj)
|
||||
{
|
||||
if (obj is not OrderTask task)
|
||||
if (obj is not TaskItem task)
|
||||
return false;
|
||||
|
||||
if (IsShowAll == true)
|
||||
return true;
|
||||
// Status 维度筛选
|
||||
bool statusMatch = IsShowAll || task.Status != 2;
|
||||
// 如果 IsShowAll=true,表示显示所有状态;否则只显示特定状态
|
||||
|
||||
return task.Status !=2;
|
||||
// TaskType 维度筛选
|
||||
bool typeMatch = SelectedTaskType == TaskType.ALL ? true : SelectedTaskType == task.TaskType;
|
||||
bool timeMatch = StartDate <= task.CreateTime && task.CreateTime <= EndDate;
|
||||
|
||||
// 如果 SelectedTaskType==null,表示显示所有类型;否则只显示特定类型
|
||||
return statusMatch && typeMatch && timeMatch;
|
||||
}
|
||||
|
||||
/// <summary>任务列表</summary>
|
||||
public ObservableCollection<OrderTask> Tasks { get; }
|
||||
public ObservableCollection<TaskItem> Tasks { get; }
|
||||
|
||||
public ICollectionView TasksView { get; }
|
||||
|
||||
/// <summary>清空已完成/失败任务</summary>
|
||||
public ICommand ClearFinishedCommand { get; }
|
||||
|
||||
/// <summary>清空全部任务</summary>
|
||||
public ICommand ClearAllCommand { get; }
|
||||
|
||||
/// <summary>汇总文字(总数/执行中/成功/失败)</summary>
|
||||
public string SummaryText
|
||||
{
|
||||
@@ -134,6 +163,19 @@ public class OrderTaskDialogViewModel : BindableBaseEx, IDisposable
|
||||
get => GetValue<int>();
|
||||
set => SetValue(value);
|
||||
}
|
||||
|
||||
|
||||
public DateTime StartDate
|
||||
{
|
||||
get => GetValue<DateTime>();
|
||||
set => SetValue(value);
|
||||
}
|
||||
public DateTime EndDate
|
||||
{
|
||||
get => GetValue<DateTime>();
|
||||
set => SetValue(value);
|
||||
}
|
||||
|
||||
public bool IsShowAll
|
||||
{
|
||||
get => GetValue<bool>();
|
||||
@@ -144,38 +186,7 @@ public class OrderTaskDialogViewModel : BindableBaseEx, IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearFinished()
|
||||
{
|
||||
_service.ClearFinished();
|
||||
}
|
||||
|
||||
private void ClearAll()
|
||||
{
|
||||
if (System.Windows.MessageBox.Show("确定清空全部任务吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question) != MessageBoxResult.OK)
|
||||
return;
|
||||
_service.ClearAll();
|
||||
}
|
||||
|
||||
private void OnTasksCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
UpdateSummary();
|
||||
}
|
||||
|
||||
private void OnTaskPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(OrderTask.Status))
|
||||
UpdateSummary();
|
||||
}
|
||||
|
||||
private void UpdateSummary()
|
||||
{
|
||||
var items = Tasks;
|
||||
//int running = items.Count(t => t.Status == OrderTask.Running);
|
||||
//int success = items.Count(t => t.Status == OrderTask.Success);
|
||||
//int failed = items.Count(t => t.Status == OrderTask.Failed);
|
||||
//string.Format("任务总数:{0} 执行中:{1} 成功:{2} 失败:{3}",
|
||||
//items.Length, running, success, failed);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user