增加 利润明细
移除有效订单明细 增加待退回金额明细 列表备注功能
This commit is contained in:
1 parent
8d4d3157a2
commit
cc0904c728
8 files changed
+413
-51
No files matched your search
@@ -0,0 +1,65 @@
|
||||
<Window
|
||||
x:Class="_29WxOrderWpf.Common.InputDialog"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:_29WxOrderWpf.Common"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
Title="输入"
|
||||
Width="360"
|
||||
ContentRendered="Window_ContentRendered"
|
||||
ResizeMode="NoResize"
|
||||
ShowInTaskbar="False"
|
||||
SizeToContent="Height"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid Margin="16">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock
|
||||
x:Name="PromptText"
|
||||
Grid.Row="0"
|
||||
Margin="0,0,0,8"
|
||||
TextWrapping="Wrap" />
|
||||
|
||||
<TextBox
|
||||
x:Name="InputBox"
|
||||
Grid.Row="1"
|
||||
Height="26"
|
||||
VerticalContentAlignment="Center"
|
||||
PreviewTextInput="InputBox_PreviewTextInput" />
|
||||
|
||||
<TextBlock
|
||||
x:Name="ErrorText"
|
||||
Grid.Row="2"
|
||||
Margin="0,6,0,0"
|
||||
Foreground="Red"
|
||||
TextWrapping="Wrap"
|
||||
Visibility="Collapsed" />
|
||||
|
||||
<StackPanel
|
||||
Grid.Row="3"
|
||||
Margin="0,16,0,0"
|
||||
HorizontalAlignment="Right"
|
||||
Orientation="Horizontal">
|
||||
<Button
|
||||
Width="80"
|
||||
Height="28"
|
||||
Click="Ok_Click"
|
||||
Content="确定"
|
||||
IsDefault="True" />
|
||||
<Button
|
||||
Width="80"
|
||||
Height="28"
|
||||
Margin="8,0,0,0"
|
||||
Content="取消"
|
||||
IsCancel="True" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,163 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace _29WxOrderWpf.Common;
|
||||
|
||||
public enum InputType
|
||||
{
|
||||
Text, // 任意文本
|
||||
Integer, // 整数
|
||||
Decimal // 小数
|
||||
}
|
||||
/// <summary>
|
||||
/// InputDialog.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class InputDialog : Window
|
||||
{
|
||||
private readonly InputType _type;
|
||||
private readonly bool _allowEmpty;
|
||||
|
||||
// 输入过程中允许的"部分输入"格式(如 "-"、"1." 也允许)
|
||||
private static readonly Regex IntPartial = new(@"^-?\d*$");
|
||||
private static readonly Regex DecPartial = new(@"^-?\d*\.?\d*$");
|
||||
|
||||
/// <summary>用户输入的原始文本</summary>
|
||||
public string ResultText { get; private set; } = "";
|
||||
|
||||
private InputDialog(Window? owner, string title, string prompt,
|
||||
string defaultValue, InputType type, bool allowEmpty)
|
||||
{
|
||||
InitializeComponent();
|
||||
Owner = owner ?? Application.Current.Windows
|
||||
.OfType<Window>()
|
||||
.FirstOrDefault(w => w.IsActive) ?? Application.Current.MainWindow;
|
||||
if (Owner == null) WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
|
||||
Title = title;
|
||||
PromptText.Text = prompt;
|
||||
InputBox.Text = defaultValue;
|
||||
_type = type;
|
||||
_allowEmpty = allowEmpty;
|
||||
|
||||
// 粘贴时同样校验
|
||||
DataObject.AddPastingHandler(InputBox, (s, e) =>
|
||||
{
|
||||
if (_type == InputType.Text) return;
|
||||
if (e.DataObject.GetData(DataFormats.Text) is not string pasted ||
|
||||
!IsPartialValid(Preview(pasted)))
|
||||
e.CancelCommand();
|
||||
});
|
||||
}
|
||||
|
||||
private void Window_ContentRendered(object? sender, EventArgs e)
|
||||
{
|
||||
InputBox.Focus();
|
||||
InputBox.SelectAll();
|
||||
}
|
||||
|
||||
// 按键输入时实时限制字符
|
||||
private void InputBox_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
|
||||
{
|
||||
if (_type == InputType.Text) return;
|
||||
e.Handled = !IsPartialValid(Preview(e.Text));
|
||||
}
|
||||
|
||||
// 计算输入/粘贴后的文本
|
||||
private string Preview(string incoming)
|
||||
{
|
||||
var t = InputBox.Text;
|
||||
return t.Remove(InputBox.SelectionStart, InputBox.SelectionLength)
|
||||
.Insert(InputBox.SelectionStart, incoming);
|
||||
}
|
||||
|
||||
private bool IsPartialValid(string text) => _type switch
|
||||
{
|
||||
InputType.Integer => IntPartial.IsMatch(text),
|
||||
InputType.Decimal => DecPartial.IsMatch(text),
|
||||
_ => true
|
||||
};
|
||||
|
||||
private void Ok_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var text = InputBox.Text.Trim();
|
||||
|
||||
if (text.Length == 0 && !_allowEmpty)
|
||||
{
|
||||
ShowError("内容不能为空");
|
||||
return;
|
||||
}
|
||||
|
||||
if (text.Length > 0)
|
||||
{
|
||||
if (_type == InputType.Integer && !int.TryParse(text, NumberStyles.AllowLeadingSign,
|
||||
CultureInfo.InvariantCulture, out _))
|
||||
{
|
||||
ShowError("请输入有效的整数");
|
||||
return;
|
||||
}
|
||||
if (_type == InputType.Decimal && !double.TryParse(text, NumberStyles.Float,
|
||||
CultureInfo.InvariantCulture, out _))
|
||||
{
|
||||
ShowError("请输入有效的数字");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ResultText = text;
|
||||
DialogResult = true;
|
||||
}
|
||||
|
||||
private void ShowError(string msg)
|
||||
{
|
||||
ErrorText.Text = msg;
|
||||
ErrorText.Visibility = Visibility.Visible;
|
||||
InputBox.Focus();
|
||||
InputBox.SelectAll();
|
||||
}
|
||||
|
||||
// ================= 静态帮助方法 =================
|
||||
|
||||
/// <summary>输入文本。取消返回 null。</summary>
|
||||
public static string? ShowText(string prompt, string title = "输入",
|
||||
string defaultValue = "", bool allowEmpty = false, Window? owner = null)
|
||||
{
|
||||
var dlg = new InputDialog(owner, title, prompt, defaultValue, InputType.Text, allowEmpty);
|
||||
return dlg.ShowDialog() == true ? dlg.ResultText : null;
|
||||
}
|
||||
|
||||
/// <summary>输入整数。取消返回 null。</summary>
|
||||
public static int? ShowInt(string prompt, string title = "输入",
|
||||
int? defaultValue = null, Window? owner = null)
|
||||
{
|
||||
var dlg = new InputDialog(owner, title, prompt,
|
||||
defaultValue?.ToString(CultureInfo.InvariantCulture) ?? "", InputType.Integer, false);
|
||||
return dlg.ShowDialog() == true
|
||||
? int.Parse(dlg.ResultText, CultureInfo.InvariantCulture)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>输入小数。取消返回 null。</summary>
|
||||
public static double? ShowDouble(string prompt, string title = "输入",
|
||||
double? defaultValue = null, Window? owner = null)
|
||||
{
|
||||
var dlg = new InputDialog(owner, title, prompt,
|
||||
defaultValue?.ToString(CultureInfo.InvariantCulture) ?? "", InputType.Decimal, false);
|
||||
return dlg.ShowDialog() == true
|
||||
? double.Parse(dlg.ResultText, CultureInfo.InvariantCulture)
|
||||
: null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,6 +179,16 @@ namespace _29WxOrderWpf.Ctrls.Statistics.Models
|
||||
/// </summary>
|
||||
public int OrderRefundAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 利润
|
||||
/// </summary>
|
||||
public long ProfitAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 平台佣金
|
||||
/// </summary>
|
||||
public long PlatformFee { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 外采金额(分),即该订单下所有买手订单的购买金额之和
|
||||
/// </summary>
|
||||
@@ -228,6 +238,9 @@ namespace _29WxOrderWpf.Ctrls.Statistics.Models
|
||||
/// 退款状态
|
||||
/// </summary>
|
||||
public string RefundStatusText { get; set; }
|
||||
|
||||
public DateTime CreateTime { get; set; }
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -401,7 +414,11 @@ namespace _29WxOrderWpf.Ctrls.Statistics.Models
|
||||
Refund = 2,
|
||||
|
||||
/// <summary>买手未退回金额的订单:退款订单中买手款项还没退回的(对应统计里的未退回金额口径)</summary>
|
||||
BuyerUnrefunded = 3
|
||||
BuyerUnrefunded = 3,
|
||||
/// <summary>
|
||||
/// 利润订单 有效订单+退款订单利润>0
|
||||
/// </summary>
|
||||
Profit = 4,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -80,16 +80,6 @@
|
||||
</StackPanel>
|
||||
|
||||
</Border>
|
||||
<Button
|
||||
Margin="10"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
Command="{Binding ShowOrderListCommand}"
|
||||
CommandParameter="ValidOrderCount"
|
||||
Content="明细"
|
||||
FontSize="12"
|
||||
Foreground="{StaticResource pageColorBrush}"
|
||||
Style="{StaticResource IconButtonStyle}" />
|
||||
</Grid>
|
||||
<!-- 采购金额 -->
|
||||
<Border Style="{StaticResource CardBorderStyle}">
|
||||
@@ -113,25 +103,37 @@
|
||||
</Border>
|
||||
|
||||
<!-- 利润 -->
|
||||
<Border Style="{StaticResource CardBorderStyle}">
|
||||
<StackPanel>
|
||||
<TextBlock
|
||||
FontSize="14"
|
||||
Foreground="#888888"
|
||||
Text="利润" />
|
||||
<TextBlock
|
||||
Margin="0,12,0,0"
|
||||
FontSize="30"
|
||||
FontWeight="Bold"
|
||||
Foreground="#333333"
|
||||
Text="{Binding Summary.Profit, StringFormat={}¥{0:N2}}" />
|
||||
<TextBlock
|
||||
Margin="0,10,0,0"
|
||||
FontSize="12"
|
||||
Foreground="#999999"
|
||||
Text="实际利润" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Grid>
|
||||
<Border Style="{StaticResource CardBorderStyle}">
|
||||
<StackPanel>
|
||||
<TextBlock
|
||||
FontSize="14"
|
||||
Foreground="#888888"
|
||||
Text="利润" />
|
||||
<TextBlock
|
||||
Margin="0,12,0,0"
|
||||
FontSize="30"
|
||||
FontWeight="Bold"
|
||||
Foreground="#333333"
|
||||
Text="{Binding Summary.Profit, StringFormat={}¥{0:N2}}" />
|
||||
<TextBlock
|
||||
Margin="0,10,0,0"
|
||||
FontSize="12"
|
||||
Foreground="#999999"
|
||||
Text="实际利润" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Button
|
||||
Margin="10"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
Command="{Binding ShowOrderListCommand}"
|
||||
CommandParameter="ProfitOrder"
|
||||
Content="明细"
|
||||
FontSize="12"
|
||||
Foreground="{StaticResource pageColorBrush}"
|
||||
Style="{StaticResource IconButtonStyle}" />
|
||||
</Grid>
|
||||
<!-- 平均利润率 -->
|
||||
<Border Style="{StaticResource CardBorderStyle}">
|
||||
<StackPanel>
|
||||
@@ -255,7 +257,7 @@
|
||||
<TextBlock
|
||||
FontSize="14"
|
||||
Foreground="#888888"
|
||||
Text="总采购金额" />
|
||||
Text="售后采购金额" />
|
||||
<TextBlock
|
||||
Margin="0,12,0,0"
|
||||
FontSize="30"
|
||||
|
||||
@@ -43,6 +43,7 @@ namespace _29WxOrderWpf.Ctrls.Statistics.Services
|
||||
/// </summary>
|
||||
/// <param name="id">买手退款表ID(<see cref="BuyerOrderInfo.RefundId"/>,即表格当前行的 id)</param>
|
||||
Task<bool> UpdateBuyerRefundStatusAsync(long id);
|
||||
Task<bool> UpdateBuyerAfterOrderRemark(long id, string remark);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -654,5 +655,22 @@ namespace _29WxOrderWpf.Ctrls.Statistics.Services
|
||||
EnsureSuccess(ret);
|
||||
return ret.Data;
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateBuyerAfterOrderRemark(long id, string remark)
|
||||
{
|
||||
if (id == 0)
|
||||
throw new Exception("更新失败:缺少买手订单ID");
|
||||
|
||||
var url = BaseClass.Build29WxObjString("buyer/UpdateBuyerAfterRemark");
|
||||
var html = await GetHtml.PostJsonAsync(url, UserLogin.GetSignPostData(new
|
||||
{
|
||||
id = id,
|
||||
remark
|
||||
}));
|
||||
|
||||
var ret = Deserialize<Result<bool>>(html);
|
||||
EnsureSuccess(ret);
|
||||
return ret.Data;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,14 +149,14 @@
|
||||
Header="退款金额" />
|
||||
<DataGridTextColumn
|
||||
Width="*"
|
||||
Binding="{Binding OutAmount, Converter={StaticResource FenToYuanConverter}, StringFormat={}¥{0:N2}}"
|
||||
Binding="{Binding PlatformFee, Converter={StaticResource FenToYuanConverter}, StringFormat={}¥{0:N2}}"
|
||||
ElementStyle="{StaticResource CenterCellTextStyle}"
|
||||
Header="外采金额" />
|
||||
Header="平台费用" />
|
||||
<DataGridTextColumn
|
||||
Width="*"
|
||||
Binding="{Binding UnrefundedAmount, Converter={StaticResource FenToYuanConverter}, StringFormat={}¥{0:N2}}"
|
||||
Binding="{Binding ProfitAmount, Converter={StaticResource FenToYuanConverter}, StringFormat={}¥{0:N2}}"
|
||||
ElementStyle="{StaticResource CenterCellTextStyle}"
|
||||
Header="未退回金额" />
|
||||
Header="利润" />
|
||||
|
||||
<!-- 买手订单:一笔买手订单占一行,不合并 -->
|
||||
<DataGridTextColumn
|
||||
@@ -168,7 +168,8 @@
|
||||
Width="*"
|
||||
Binding="{Binding BuyerOutAmount, Converter={StaticResource FenToYuanConverter}, StringFormat={}¥{0:N2}}"
|
||||
ElementStyle="{StaticResource CenterCellTextStyle}"
|
||||
Header="买手金额" />
|
||||
Header="外采金额" />
|
||||
|
||||
<DataGridTextColumn
|
||||
Width="*"
|
||||
Binding="{Binding BuyerRefundAmount, Converter={StaticResource FenToYuanConverter}, StringFormat={}¥{0:N2}}"
|
||||
@@ -179,7 +180,12 @@
|
||||
Binding="{Binding BuyerRefundStatusText}"
|
||||
ElementStyle="{StaticResource CenterCellTextStyle}"
|
||||
Header="退款状态" />
|
||||
|
||||
<DataGridTextColumn
|
||||
Width="1.1*"
|
||||
Binding="{Binding Remark}"
|
||||
ElementStyle="{StaticResource CenterCellTextStyle}"
|
||||
Header="备注"
|
||||
Visibility="{Binding Source={StaticResource ViewModel}, Path=Data.IsBuyerUnrefunded, Converter={StaticResource Boolean2VisibilityConverter}}" />
|
||||
<!-- 操作:仅“买手未退回金额的订单”弹窗显示(列可见性在构造函数里按订单明细类型设置) -->
|
||||
<DataGridTemplateColumn
|
||||
x:Name="colUpdateRefund"
|
||||
@@ -194,12 +200,31 @@
|
||||
VerticalAlignment="Center"
|
||||
Command="{Binding Source={StaticResource ViewModel}, Path=Data.UpdateBuyerRefundStatusCommand}"
|
||||
CommandParameter="{Binding}"
|
||||
Content="退款成功"
|
||||
Content="确认成功"
|
||||
Style="{StaticResource BasePageButtonLightStyle}"
|
||||
ToolTip="把该笔买手订单标记为退款成功" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn
|
||||
x:Name="colRemark"
|
||||
Width="*"
|
||||
d:Visibility="Visible"
|
||||
Header="操作"
|
||||
Visibility="{Binding Source={StaticResource ViewModel}, Path=Data.IsBuyerUnrefunded, Converter={StaticResource Boolean2VisibilityConverter}}">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Button
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Command="{Binding Source={StaticResource ViewModel}, Path=Data.UpdateRemarkCommand}"
|
||||
CommandParameter="{Binding}"
|
||||
Content="备注"
|
||||
Style="{StaticResource BasePageButtonLightStyle}"
|
||||
ToolTip="设置备注" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
|
||||
@@ -4,6 +4,7 @@ using _29WxOrderWpf.Common;
|
||||
using _29WxOrderWpf.Ctrls.Statistics.Models;
|
||||
using _29WxOrderWpf.Ctrls.Statistics.Services;
|
||||
using _29WxOrderWpf.ToolCtrls;
|
||||
using AllBase;
|
||||
using NaiBa.Util.Extension;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -22,6 +23,7 @@ using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using Work.BaseForms;
|
||||
using WPFCommon.Models;
|
||||
|
||||
namespace _29WxOrderWpf.Ctrls.Statistics;
|
||||
@@ -36,11 +38,14 @@ public partial class ShowOrderDialogView : UserControl
|
||||
public ShowOrderDialogView(List<ShopOrderDetailResponse> list, ShopOrderDetailType detailType, IShopRevenueStatisticsService statisticsService)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.DataContext = new ShowOrderDialogViewModel(list, statisticsService);
|
||||
this.DataContext = new ShowOrderDialogViewModel(list, detailType, statisticsService);
|
||||
|
||||
// “操作”列(退款成功按钮)只在“买手未退回金额的订单”弹窗里显示
|
||||
if (detailType == ShopOrderDetailType.BuyerUnrefunded)
|
||||
{
|
||||
colUpdateRefund.Visibility = Visibility.Visible;
|
||||
//colRemark.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
shortcutKeyHandler = ShowOrderDialogView_PreviewKeyDown;
|
||||
|
||||
@@ -158,7 +163,15 @@ class ShopOrderDetailRow : BindableBaseEx
|
||||
public int OrderPrice { get; set; }
|
||||
|
||||
public int OrderRefundAmount { get; set; }
|
||||
/// <summary>
|
||||
/// 利润
|
||||
/// </summary>
|
||||
public long ProfitAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 平台佣金
|
||||
/// </summary>
|
||||
public long PlatformFee { get; set; }
|
||||
public int OutAmount { get; set; }
|
||||
|
||||
public int UnrefundedAmount { get; set; }
|
||||
@@ -185,9 +198,13 @@ class ShopOrderDetailRow : BindableBaseEx
|
||||
get => GetValue<string>();
|
||||
set => SetValue(value);
|
||||
}
|
||||
|
||||
public string Remark
|
||||
{
|
||||
get => GetValue<string>();
|
||||
set => SetValue(value);
|
||||
}
|
||||
/// <summary>把接口返回的订单明细按买手订单展平成表格行</summary>
|
||||
public static List<ShopOrderDetailRow> Flatten(IEnumerable<ShopOrderDetailResponse> list)
|
||||
public static List<ShopOrderDetailRow> Flatten(IEnumerable<ShopOrderDetailResponse> list, ShopOrderDetailType detailType)
|
||||
{
|
||||
var rows = new List<ShopOrderDetailRow>();
|
||||
if (list == null)
|
||||
@@ -203,9 +220,19 @@ class ShopOrderDetailRow : BindableBaseEx
|
||||
rows.Add(Create(item, null));
|
||||
continue;
|
||||
}
|
||||
if (detailType == ShopOrderDetailType.Profit)
|
||||
{
|
||||
// 利润订单只取最后一个买手订单
|
||||
rows.Add(Create(item, item.BuyerOrders.LastOrDefault()));
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var buyerOrder in item.BuyerOrders)
|
||||
{
|
||||
rows.Add(Create(item, buyerOrder));
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var buyerOrder in item.BuyerOrders)
|
||||
rows.Add(Create(item, buyerOrder));
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
@@ -219,6 +246,8 @@ class ShopOrderDetailRow : BindableBaseEx
|
||||
CreateTime = item.CreateTime,
|
||||
OrderPrice = item.OrderPrice,
|
||||
OrderRefundAmount = item.OrderRefundAmount,
|
||||
ProfitAmount = item.ProfitAmount,
|
||||
PlatformFee = item.PlatformFee,
|
||||
OutAmount = item.OutAmount,
|
||||
UnrefundedAmount = item.UnrefundedAmount,
|
||||
BuyerId = buyerOrder == null ? 0 : buyerOrder.Id,
|
||||
@@ -227,6 +256,7 @@ class ShopOrderDetailRow : BindableBaseEx
|
||||
BuyerOutAmount = buyerOrder == null ? 0 : buyerOrder.OutAmount,
|
||||
BuyerRefundAmount = buyerOrder == null ? 0 : buyerOrder.RefundAmount,
|
||||
BuyerRefundStatusText = buyerOrder == null ? null : buyerOrder.RefundStatusText,
|
||||
Remark = buyerOrder == null ? null : buyerOrder.Remark,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -237,10 +267,11 @@ class ShowOrderDialogViewModel : BindableBaseEx
|
||||
|
||||
public ObservableCollection<ShopOrderDetailRow> Data { get; set; }
|
||||
public ICollectionView DataView { get; private set; }
|
||||
public ShowOrderDialogViewModel(List<ShopOrderDetailResponse> list, IShopRevenueStatisticsService statisticsService)
|
||||
public ShowOrderDialogViewModel(List<ShopOrderDetailResponse> list, ShopOrderDetailType detailType, IShopRevenueStatisticsService statisticsService)
|
||||
{
|
||||
// 按买手订单展平:一笔买手订单一一行,不合并
|
||||
Data = new ObservableCollection<ShopOrderDetailRow>(ShopOrderDetailRow.Flatten(list));
|
||||
IsBuyerUnrefunded = detailType == ShopOrderDetailType.BuyerUnrefunded;
|
||||
// 按买手订单展平:一笔买手订单一一行, 利润明细合并,只展示一条
|
||||
Data = new ObservableCollection<ShopOrderDetailRow>(ShopOrderDetailRow.Flatten(list, detailType));
|
||||
DataView = CollectionViewSource.GetDefaultView(Data);
|
||||
DataView.Filter = FilterRow;
|
||||
_statisticsService = statisticsService;
|
||||
@@ -262,6 +293,11 @@ class ShowOrderDialogViewModel : BindableBaseEx
|
||||
get => GetValue<string>();
|
||||
set => SetValue(value, () => DataView.Refresh());
|
||||
}
|
||||
public bool IsBuyerUnrefunded
|
||||
{
|
||||
get => GetValue<bool>();
|
||||
set => SetValue(value);
|
||||
}
|
||||
|
||||
/// <summary>当前筛选后显示的行(按表格显示顺序)</summary>
|
||||
public List<ShopOrderDetailRow> GetFilteredRows()
|
||||
@@ -310,7 +346,13 @@ class ShowOrderDialogViewModel : BindableBaseEx
|
||||
ToastHelper.Show("该行缺少买手订单ID,无法更新", type: ToastType.Warning);
|
||||
return;
|
||||
}
|
||||
var result = MessageBox.Show($"确定要把订单:{row.OrderId}\n设为已退款成功状态?", "提示",
|
||||
MessageBoxButton.YesNo, MessageBoxImage.Question);
|
||||
|
||||
if (result != MessageBoxResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var ret = await _statisticsService.UpdateBuyerRefundStatusAsync(row.BuyerRefundId);
|
||||
@@ -331,6 +373,35 @@ class ShowOrderDialogViewModel : BindableBaseEx
|
||||
{
|
||||
}
|
||||
}
|
||||
public ICommand UpdateRemarkCommand => new AsyncDelegateCommand<ShopOrderDetailRow>(UpdateRemark);
|
||||
|
||||
private async Task UpdateRemark(ShopOrderDetailRow row)
|
||||
{
|
||||
string? remark = InputDialog.ShowText("请输入备注:", "备注", row.Remark);
|
||||
if (remark == null)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
var ret = await _statisticsService.UpdateBuyerAfterOrderRemark(row.BuyerRefundId, remark);
|
||||
if (ret)
|
||||
{
|
||||
row.Remark = remark;
|
||||
ToastHelper.Show("操作成功");
|
||||
}
|
||||
else
|
||||
throw new Exception("备注更改失败");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ToastHelper.Show("操作失败 " + ex.Message, type: ToastType.Error);
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>把行拼成制表符分隔的文本(第一行是表头)</summary>
|
||||
private string BuildCopyText(IEnumerable<ShopOrderDetailRow> rows)
|
||||
@@ -338,7 +409,7 @@ class ShowOrderDialogViewModel : BindableBaseEx
|
||||
var sb = new StringBuilder();
|
||||
|
||||
// 表头
|
||||
sb.AppendLine("店名\t订单\t创建时间\t金额\t退款金额\t外采金额\t未退回金额\t买手单号\t买手金额\t买手退款\t退款状态");
|
||||
sb.AppendLine("店名\t订单\t创建时间\t金额\t退款金额\t平台费用\t利润\t买手单号\t外采金额\t买手退款\t退款状态");
|
||||
|
||||
// 数据行
|
||||
foreach (var item in rows)
|
||||
@@ -348,14 +419,14 @@ class ShowOrderDialogViewModel : BindableBaseEx
|
||||
string createTime = item.CreateTime.ToString("yyyy-MM-dd HH:mm");
|
||||
string orderPrice = (item.OrderPrice / 100m).ToString("0.00");
|
||||
string refundAmount = (item.OrderRefundAmount / 100m).ToString("0.00");
|
||||
string outAmount = (item.OutAmount / 100m).ToString("0.00");
|
||||
string unrefundedAmount = (item.UnrefundedAmount / 100m).ToString("0.00");
|
||||
string platformFee = (item.PlatformFee / 100m).ToString("0.00");
|
||||
string profitAmount = (item.ProfitAmount / 100m).ToString("0.00");
|
||||
string buyerOrderSn = CsvEscape(item.OutOrderSn);
|
||||
string buyerOutAmount = (item.BuyerOutAmount / 100m).ToString("0.00");
|
||||
string buyerRefundAmount = (item.BuyerRefundAmount / 100m).ToString("0.00");
|
||||
string buyerRefundStatus = CsvEscape(item.BuyerRefundStatusText);
|
||||
|
||||
sb.AppendLine($"{shopName}\t{orderId}\t{createTime}\t{orderPrice}\t{refundAmount}\t{outAmount}\t{unrefundedAmount}\t{buyerOrderSn}\t{buyerOutAmount}\t{buyerRefundAmount}\t{buyerRefundStatus}");
|
||||
sb.AppendLine($"{shopName}\t{orderId}\t{createTime}\t{orderPrice}\t{refundAmount}\t{platformFee}\t{profitAmount}\t{buyerOrderSn}\t{buyerOutAmount}\t{buyerRefundAmount}\t{buyerRefundStatus}");
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
|
||||
@@ -333,7 +333,6 @@ namespace _29WxOrderWpf.Ctrls.Statistics.ViewModels
|
||||
{
|
||||
var detailType = ParseDetailType(type);
|
||||
List<ShopOrderDetailResponse> showList;
|
||||
// 明细接口数据量大、耗时长,期间显示页面统一的加载遮罩,避免点了没反应
|
||||
IsLoading = true;
|
||||
try
|
||||
{
|
||||
@@ -373,6 +372,8 @@ namespace _29WxOrderWpf.Ctrls.Statistics.ViewModels
|
||||
return ShopOrderDetailType.Refund; //退款订单
|
||||
case "BuyerRefundRemainingAmount":
|
||||
return ShopOrderDetailType.BuyerUnrefunded; //买手未退回金额的订单
|
||||
case "ProfitOrder":
|
||||
return ShopOrderDetailType.Profit; //买手未退回金额的订单
|
||||
default:
|
||||
return ShopOrderDetailType.Valid; //有效订单
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user