统计订单列表页 增加退款成功按钮
This commit is contained in:
1 parent
1ed9d72815
commit
87a0d34526
7 files changed
+135
-17
No files matched your search
@@ -1,7 +1,10 @@
|
||||
using _29WxOrderWpf.BaseWindows;
|
||||
using _29WxOrderWpf.Commands;
|
||||
using _29WxOrderWpf.Common;
|
||||
using _29WxOrderWpf.Ctrls.Statistics.Models;
|
||||
using _29WxOrderWpf.Ctrls.Statistics.Services;
|
||||
using _29WxOrderWpf.ToolCtrls;
|
||||
using NaiBa.Util.Extension;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -30,10 +33,14 @@ public partial class ShowOrderDialogView : UserControl
|
||||
{
|
||||
private readonly KeyEventHandler shortcutKeyHandler;
|
||||
|
||||
public ShowOrderDialogView(List<ShopOrderDetailResponse> list)
|
||||
public ShowOrderDialogView(List<ShopOrderDetailResponse> list, ShopOrderDetailType detailType, IShopRevenueStatisticsService statisticsService)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.DataContext = new ShowOrderDialogViewModel(list);
|
||||
this.DataContext = new ShowOrderDialogViewModel(list, statisticsService);
|
||||
|
||||
// “操作”列(退款成功按钮)只在“买手未退回金额的订单”弹窗里显示
|
||||
if (detailType == ShopOrderDetailType.BuyerUnrefunded)
|
||||
colUpdateRefund.Visibility = Visibility.Visible;
|
||||
|
||||
shortcutKeyHandler = ShowOrderDialogView_PreviewKeyDown;
|
||||
|
||||
@@ -83,6 +90,7 @@ public partial class ShowOrderDialogView : UserControl
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 弹窗级快捷键:Ctrl+A 全选(筛选后显示的)行,Ctrl+C 复制数据。
|
||||
/// 焦点在文本框里(如订单号搜索框)时不拦截,保留文本自身的 Ctrl+A/Ctrl+C/Ctrl+V 行为。
|
||||
@@ -139,7 +147,7 @@ public partial class ShowOrderDialogView : UserControl
|
||||
/// 没有买手订单时占一行且买手字段为空),不把多笔买手订单合并到同一行。
|
||||
/// 商铺订单级字段(店名/订单号/创建时间/金额等)在多行之间重复,保证每行都是一条完整记录。
|
||||
/// </summary>
|
||||
class ShopOrderDetailRow
|
||||
class ShopOrderDetailRow : BindableBaseEx
|
||||
{
|
||||
public string ShopName { get; set; }
|
||||
|
||||
@@ -155,17 +163,28 @@ class ShopOrderDetailRow
|
||||
|
||||
public int UnrefundedAmount { get; set; }
|
||||
|
||||
/// <summary>买手订单表ID</summary>
|
||||
public long BuyerId { get; set; }
|
||||
|
||||
/// <summary>买手(外部)订单号;无买手订单时为空</summary>
|
||||
public string OutOrderSn { get; set; }
|
||||
|
||||
/// <summary>买手订单金额(分)</summary>
|
||||
public int BuyerOutAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 买手退款表 id
|
||||
/// </summary>
|
||||
public long BuyerRefundId { get; set; }
|
||||
/// <summary>买手订单退款金额(分)</summary>
|
||||
public int BuyerRefundAmount { get; set; }
|
||||
|
||||
/// <summary>买手订单退款状态</summary>
|
||||
public string BuyerRefundStatusText { get; set; }
|
||||
/// <summary>买手订单退款状态(更新成功后就地改为“退款成功”)</summary>
|
||||
public string BuyerRefundStatusText
|
||||
{
|
||||
get => GetValue<string>();
|
||||
set => SetValue(value);
|
||||
}
|
||||
|
||||
/// <summary>把接口返回的订单明细按买手订单展平成表格行</summary>
|
||||
public static List<ShopOrderDetailRow> Flatten(IEnumerable<ShopOrderDetailResponse> list)
|
||||
@@ -202,7 +221,9 @@ class ShopOrderDetailRow
|
||||
OrderRefundAmount = item.OrderRefundAmount,
|
||||
OutAmount = item.OutAmount,
|
||||
UnrefundedAmount = item.UnrefundedAmount,
|
||||
BuyerId = buyerOrder == null ? 0 : buyerOrder.Id,
|
||||
OutOrderSn = buyerOrder == null ? null : buyerOrder.OutOrderSn,
|
||||
BuyerRefundId = buyerOrder == null ? 0 : buyerOrder.RefundId,
|
||||
BuyerOutAmount = buyerOrder == null ? 0 : buyerOrder.OutAmount,
|
||||
BuyerRefundAmount = buyerOrder == null ? 0 : buyerOrder.RefundAmount,
|
||||
BuyerRefundStatusText = buyerOrder == null ? null : buyerOrder.RefundStatusText,
|
||||
@@ -212,14 +233,17 @@ class ShopOrderDetailRow
|
||||
|
||||
class ShowOrderDialogViewModel : BindableBaseEx
|
||||
{
|
||||
private readonly IShopRevenueStatisticsService _statisticsService;
|
||||
|
||||
public ObservableCollection<ShopOrderDetailRow> Data { get; set; }
|
||||
public ICollectionView DataView { get; private set; }
|
||||
public ShowOrderDialogViewModel(List<ShopOrderDetailResponse> list)
|
||||
public ShowOrderDialogViewModel(List<ShopOrderDetailResponse> list, IShopRevenueStatisticsService statisticsService)
|
||||
{
|
||||
// 按买手订单展平:一笔买手订单一一行,不合并
|
||||
Data = new ObservableCollection<ShopOrderDetailRow>(ShopOrderDetailRow.Flatten(list));
|
||||
DataView = CollectionViewSource.GetDefaultView(Data);
|
||||
DataView.Filter = FilterRow;
|
||||
_statisticsService = statisticsService;
|
||||
}
|
||||
|
||||
private bool FilterRow(object obj)
|
||||
@@ -258,13 +282,9 @@ class ShowOrderDialogViewModel : BindableBaseEx
|
||||
list = GetFilteredRows();
|
||||
}
|
||||
|
||||
Window window = Application.Current.Windows
|
||||
.OfType<Window>()
|
||||
.FirstOrDefault(w => w.IsActive) ?? Application.Current.MainWindow;
|
||||
|
||||
if (list.Count == 0)
|
||||
{
|
||||
ToastHelper.Show(window, "没有可复制的数据", type: ToastType.Warning);
|
||||
ToastHelper.Show("没有可复制的数据", type: ToastType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -272,11 +292,43 @@ class ShowOrderDialogViewModel : BindableBaseEx
|
||||
{
|
||||
string text = BuildCopyText(list);
|
||||
Application.Current.Dispatcher.Invoke(() => Clipboard.SetText(text));
|
||||
ToastHelper.Show(window, "复制成功");
|
||||
ToastHelper.Show("复制成功");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ToastHelper.Show(window, "复制失败 " + ex.Message, type: ToastType.Error);
|
||||
ToastHelper.Show("复制失败 " + ex.Message, type: ToastType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ICommand UpdateBuyerRefundStatusCommand => new AsyncDelegateCommand<ShopOrderDetailRow>(UpdateBuyerRefundStatus);
|
||||
|
||||
private async Task UpdateBuyerRefundStatus(ShopOrderDetailRow row)
|
||||
{
|
||||
if (row.BuyerRefundId == 0)
|
||||
{
|
||||
ToastHelper.Show("该行缺少买手订单ID,无法更新", type: ToastType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var ret = await _statisticsService.UpdateBuyerRefundStatusAsync(row.BuyerRefundId);
|
||||
if (ret)
|
||||
{
|
||||
row.BuyerRefundStatusText = "退款成功";
|
||||
ToastHelper.Show("操作成功");
|
||||
}
|
||||
else
|
||||
throw new Exception("状态更改失败");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ToastHelper.Show("操作失败 " + ex.Message, type: ToastType.Error);
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user