Merge branch 'main' of http://git.ts.e57.cn/chfei/29WxOrder
This commit is contained in:
commit
82165f25a8
11 files changed
+269
-127
No files matched your search
@@ -23,6 +23,10 @@ namespace _29WxOrderWpf.Ctrls.Statistics.Models
|
||||
/// 空/Null 表示全部店铺(服务层会取全部店铺的 ErpShopId)。
|
||||
/// </summary>
|
||||
public List<string> ShopIds { get; set; }
|
||||
/// <summary>
|
||||
/// 是否统计快递费用
|
||||
/// </summary>
|
||||
public bool StatPackages { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -111,6 +115,10 @@ namespace _29WxOrderWpf.Ctrls.Statistics.Models
|
||||
/// 被拒绝金额(分)
|
||||
/// </summary>
|
||||
public long RejectedRefund { get; set; }
|
||||
/// <summary>
|
||||
/// 包裹费用
|
||||
/// </summary>
|
||||
public long PackageAmount { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -199,6 +207,7 @@ namespace _29WxOrderWpf.Ctrls.Statistics.Models
|
||||
/// </summary>
|
||||
public int UnrefundedAmount { get; set; }
|
||||
|
||||
public long PackageAmount { get; set; }
|
||||
/// <summary>
|
||||
/// 买手订单信息(一个订单号对应多个买手订单)
|
||||
/// </summary>
|
||||
@@ -288,6 +297,10 @@ namespace _29WxOrderWpf.Ctrls.Statistics.Models
|
||||
public decimal BuyerRefundSuccessedAmount { get; set; }
|
||||
/// <summary>买手号剩余退款金额(尚未成功退款的金额,元)</summary>
|
||||
public decimal BuyerRefundRemainingAmount => BuyerRefundAmount - BuyerRefundSuccessedAmount;
|
||||
/// <summary>
|
||||
/// 包裹费用
|
||||
/// </summary>
|
||||
public decimal PackageAmount { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -355,6 +368,10 @@ namespace _29WxOrderWpf.Ctrls.Statistics.Models
|
||||
|
||||
/// <summary>平均利润率(利润 / 采购金额,百分数,如 12.34 表示 12.34%)</summary>
|
||||
public decimal AverageProfitRate { get; set; }
|
||||
/// <summary>
|
||||
/// 包裹费用
|
||||
/// </summary>
|
||||
public decimal PackageAmount { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:vm="clr-namespace:_29WxOrderWpf.Ctrls.Statistics.ViewModels"
|
||||
xmlns:wpf="WPFCommon"
|
||||
d:DataContext="{d:DesignInstance Type=vm:ShopRevenueStatisticsViewModel,
|
||||
IsDesignTimeCreatable=True}"
|
||||
mc:Ignorable="d">
|
||||
@@ -48,9 +49,9 @@
|
||||
Width="110"
|
||||
Height="32"
|
||||
VerticalContentAlignment="Center"
|
||||
BorderThickness="1"
|
||||
DisplayMemberPath="Text"
|
||||
IsReadOnly="True"
|
||||
BorderThickness="1"
|
||||
ItemsSource="{Binding TimeRangeOptions}"
|
||||
SelectedItem="{Binding SelectedTimeRange, Mode=TwoWay}"
|
||||
Style="{StaticResource RoundedComboBox}" />
|
||||
@@ -60,9 +61,10 @@
|
||||
FontSize="14"
|
||||
Foreground="#666666"
|
||||
Text="日期" />
|
||||
<DatePicker BorderBrush="{StaticResource pageColorBrush}"
|
||||
<DatePicker
|
||||
Height="32"
|
||||
VerticalContentAlignment="Center"
|
||||
BorderBrush="{StaticResource pageColorBrush}"
|
||||
SelectedDate="{Binding StartDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<TextBlock
|
||||
Margin="6,0"
|
||||
@@ -70,9 +72,10 @@
|
||||
FontSize="14"
|
||||
Foreground="#666666"
|
||||
Text="~" />
|
||||
<DatePicker BorderBrush="{StaticResource pageColorBrush}"
|
||||
<DatePicker
|
||||
Height="32"
|
||||
VerticalContentAlignment="Center"
|
||||
BorderBrush="{StaticResource pageColorBrush}"
|
||||
SelectedDate="{Binding EndDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<TextBlock
|
||||
Margin="14,0,6,0"
|
||||
@@ -95,6 +98,14 @@
|
||||
ItemsSource="{Binding ShopOptions}"
|
||||
SelectedItem="{Binding SelectedShop, Mode=TwoWay}"
|
||||
Style="{StaticResource BaseComboBoxStyle}" />-->
|
||||
<wpf:TitleContent
|
||||
Title="去除快递费"
|
||||
Margin="10,0,0,0"
|
||||
VerticalContentAlignment="Center"
|
||||
Placement="Left"
|
||||
TitleVerticalAlignment="Center">
|
||||
<CheckBox IsChecked="{Binding StatPackages}" Style="{StaticResource ToggleSwitch}" />
|
||||
</wpf:TitleContent>
|
||||
<Button
|
||||
Height="32"
|
||||
Margin="18,0,0,0"
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace _29WxOrderWpf.Ctrls.Statistics.Services
|
||||
decimal buyerPaymentAmount = ToYuan(list.Sum(a => a.TotalPurchase));
|
||||
decimal buyerRefundAmount = ToYuan(list.Sum(a => a.TotalRefund));
|
||||
decimal buyerRefundSuccessedAmount = ToYuan(list.Sum(a => a.DoneRefund));
|
||||
|
||||
decimal packageAmount = ToYuan(list.Sum(a => a.PackageAmount));
|
||||
int validOrderCount = list.Sum(a => a.OrderCount); // 新接口 OrderCount 不含退款订单
|
||||
int refundOrderCount = list.Sum(a => a.RefundOrderCount);
|
||||
int totalOrderCount = validOrderCount + refundOrderCount;
|
||||
@@ -128,6 +128,7 @@ namespace _29WxOrderWpf.Ctrls.Statistics.Services
|
||||
BuyerPaymentAmount = buyerPaymentAmount,
|
||||
BuyerRefundAmount = buyerRefundAmount,
|
||||
BuyerRefundSuccessedAmount = buyerRefundSuccessedAmount,
|
||||
PackageAmount = packageAmount
|
||||
};
|
||||
}
|
||||
|
||||
@@ -248,7 +249,7 @@ namespace _29WxOrderWpf.Ctrls.Statistics.Services
|
||||
decimal profit = ToYuan(list.Sum(a => a.ProfitAmount));
|
||||
decimal buyerPaymentAmount = ToYuan(list.Sum(a => a.TotalPurchase));
|
||||
int orderCount = list.Sum(a => a.OrderCount);
|
||||
|
||||
decimal packageAmount = ToYuan(list.Sum(a => a.PackageAmount));
|
||||
return new ShopStatisticsItem
|
||||
{
|
||||
ShopName = ResolveShopName(shopId),
|
||||
@@ -260,7 +261,8 @@ namespace _29WxOrderWpf.Ctrls.Statistics.Services
|
||||
PlatformFeeTotal = ToYuan(list.Sum(a => a.PlatformFee)),
|
||||
Commission = 0m, // 新接口无“达人佣金”字段,保留占位
|
||||
AvgOrderAmount = orderCount == 0 ? 0m : salesAmount / orderCount,
|
||||
AverageProfitRate = buyerPaymentAmount == 0m ? 0m : profit / buyerPaymentAmount * 100m
|
||||
AverageProfitRate = buyerPaymentAmount == 0m ? 0m : profit / buyerPaymentAmount * 100m,
|
||||
PackageAmount = packageAmount
|
||||
};
|
||||
}
|
||||
|
||||
@@ -385,7 +387,13 @@ namespace _29WxOrderWpf.Ctrls.Statistics.Services
|
||||
// 顺序请求:签名中的 time/code 由当前时间生成,并发请求有被判重复签名的风险。
|
||||
var summaryStats = await RequestStatsAsync(query, ShopStatsGroupType.Summary);
|
||||
var trend = await RequestTrendAsync(query);
|
||||
|
||||
if (query.StatPackages)
|
||||
{
|
||||
foreach (var item in summaryStats)
|
||||
{
|
||||
item.ProfitAmount -= item.PackageAmount;
|
||||
}
|
||||
}
|
||||
return new ShopRevenueStatisticsResult
|
||||
{
|
||||
Summary = ShopStatsAggregator.GetSummary(summaryStats),
|
||||
@@ -399,7 +407,13 @@ namespace _29WxOrderWpf.Ctrls.Statistics.Services
|
||||
{
|
||||
// 按天/周/月粒度取数;接口不返回整段汇总,卡片由返回的周期记录在客户端合计
|
||||
var stats = await RequestStatsAsync(query, ToGroupType(periodType));
|
||||
|
||||
if (query.StatPackages)
|
||||
{
|
||||
foreach (var item in stats)
|
||||
{
|
||||
item.ProfitAmount -= item.PackageAmount;
|
||||
}
|
||||
}
|
||||
return new ShopPeriodStatisticsResult
|
||||
{
|
||||
Summary = ShopStatsAggregator.GetSummary(stats),
|
||||
|
||||
@@ -274,30 +274,32 @@
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
<!-- helper -->
|
||||
<Border
|
||||
Margin="0,20,30,0"
|
||||
Padding="10"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
Background="{StaticResource pageColorBrush}"
|
||||
BorderThickness="1"
|
||||
Cursor="Hand"
|
||||
MouseLeftButtonDown="help_mouseLeftButtonDown">
|
||||
<WrapPanel>
|
||||
<TextBlock
|
||||
Margin="0,0,10,0"
|
||||
Foreground="White"
|
||||
Style="{StaticResource TextBlockIcon}"
|
||||
Text="{StaticResource txt-chat_help}" />
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontWeight="Black"
|
||||
Foreground="White"
|
||||
Text="利润计算逻辑" />
|
||||
</WrapPanel>
|
||||
</Border>
|
||||
|
||||
<WrapPanel
|
||||
Margin="0,20,30,0"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top">
|
||||
<Border
|
||||
Padding="10"
|
||||
Background="{StaticResource pageColorBrush}"
|
||||
BorderThickness="1"
|
||||
Cursor="Hand"
|
||||
MouseLeftButtonDown="help_mouseLeftButtonDown">
|
||||
<WrapPanel>
|
||||
<TextBlock
|
||||
Margin="0,0,10,0"
|
||||
Foreground="White"
|
||||
Style="{StaticResource TextBlockIcon}"
|
||||
Text="{StaticResource txt-chat_help}" />
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontWeight="Black"
|
||||
Foreground="White"
|
||||
Text="利润计算逻辑" />
|
||||
</WrapPanel>
|
||||
</Border>
|
||||
</WrapPanel>
|
||||
<!-- Popup 弹出层 -->
|
||||
<Popup
|
||||
x:Name="InfoPopup"
|
||||
|
||||
@@ -157,7 +157,11 @@
|
||||
Binding="{Binding ProfitAmount, Converter={StaticResource FenToYuanConverter}, StringFormat={}¥{0:N2}}"
|
||||
ElementStyle="{StaticResource CenterCellTextStyle}"
|
||||
Header="利润" />
|
||||
|
||||
<DataGridTextColumn
|
||||
Width="*"
|
||||
Binding="{Binding PackageAmount, Converter={StaticResource FenToYuanConverter}, StringFormat={}¥{0:N2}}"
|
||||
ElementStyle="{StaticResource CenterCellTextStyle}"
|
||||
Header="快递费" />
|
||||
<!-- 买手订单:一笔买手订单占一行,不合并 -->
|
||||
<DataGridTextColumn
|
||||
Width="1.6*"
|
||||
|
||||
@@ -166,7 +166,10 @@ class ShopOrderDetailRow : BindableBaseEx
|
||||
/// 利润
|
||||
/// </summary>
|
||||
public long ProfitAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 包裹费用
|
||||
/// </summary>
|
||||
public long PackageAmount { get; set; }
|
||||
/// <summary>
|
||||
/// 平台佣金
|
||||
/// </summary>
|
||||
@@ -246,6 +249,7 @@ class ShopOrderDetailRow : BindableBaseEx
|
||||
OrderPrice = item.OrderPrice,
|
||||
OrderRefundAmount = item.OrderRefundAmount,
|
||||
ProfitAmount = item.ProfitAmount,
|
||||
PackageAmount = item.PackageAmount,
|
||||
PlatformFee = item.PlatformFee,
|
||||
OutAmount = item.OutAmount,
|
||||
UnrefundedAmount = item.UnrefundedAmount,
|
||||
@@ -411,7 +415,7 @@ class ShowOrderDialogViewModel : BindableBaseEx
|
||||
bool includeRemark = _detailType == ShopOrderDetailType.BuyerUnrefunded;
|
||||
|
||||
// 表头
|
||||
List<string> headers = ["店名", "订单", "创建时间", "金额", "退款金额", "平台费用", "利润", "买手单号", "外采金额", "买手退款", "退款状态"];
|
||||
List<string> headers = ["店名", "订单", "创建时间", "金额", "退款金额", "平台费用", "利润","快递费", "买手单号", "外采金额", "买手退款", "退款状态"];
|
||||
if (includeRemark)
|
||||
headers.Add("备注");
|
||||
sb.AppendLine(string.Join("\t", headers));
|
||||
@@ -428,6 +432,7 @@ class ShowOrderDialogViewModel : BindableBaseEx
|
||||
(item.OrderRefundAmount / 100m).ToString("0.00"),
|
||||
(item.PlatformFee / 100m).ToString("0.00"),
|
||||
(item.ProfitAmount / 100m).ToString("0.00"),
|
||||
(item.PackageAmount / 100m).ToString("0.00"),
|
||||
CsvEscape(item.OutOrderSn),
|
||||
(item.BuyerOutAmount / 100m).ToString("0.00"),
|
||||
(item.BuyerRefundAmount / 100m).ToString("0.00"),
|
||||
|
||||
@@ -177,7 +177,11 @@ namespace _29WxOrderWpf.Ctrls.Statistics.ViewModels
|
||||
#endregion
|
||||
|
||||
#region 查询条件
|
||||
|
||||
public bool StatPackages
|
||||
{
|
||||
get { return this.GetValue(x => x.StatPackages); }
|
||||
set { this.SetValue(x => x.StatPackages, value); }
|
||||
}
|
||||
/// <summary>时间范围选项</summary>
|
||||
public ObservableCollection<TimeRangeOption> TimeRangeOptions { get; }
|
||||
|
||||
@@ -455,20 +459,20 @@ namespace _29WxOrderWpf.Ctrls.Statistics.ViewModels
|
||||
EndDate = now;
|
||||
break;
|
||||
case "week":
|
||||
{
|
||||
int diff = today.DayOfWeek == DayOfWeek.Sunday ? 6 : (int)today.DayOfWeek - 1;
|
||||
StartDate = today.AddDays(-diff);
|
||||
EndDate = now;
|
||||
}
|
||||
break;
|
||||
{
|
||||
int diff = today.DayOfWeek == DayOfWeek.Sunday ? 6 : (int)today.DayOfWeek - 1;
|
||||
StartDate = today.AddDays(-diff);
|
||||
EndDate = now;
|
||||
}
|
||||
break;
|
||||
case "lastweek":
|
||||
{
|
||||
int diff = today.DayOfWeek == DayOfWeek.Sunday ? 6 : (int)today.DayOfWeek - 1;
|
||||
var thisWeekStart = today.AddDays(-diff);
|
||||
StartDate = thisWeekStart.AddDays(-7);
|
||||
EndDate = thisWeekStart.AddDays(-1).AddHours(23).AddMinutes(59).AddSeconds(59);
|
||||
}
|
||||
break;
|
||||
{
|
||||
int diff = today.DayOfWeek == DayOfWeek.Sunday ? 6 : (int)today.DayOfWeek - 1;
|
||||
var thisWeekStart = today.AddDays(-diff);
|
||||
StartDate = thisWeekStart.AddDays(-7);
|
||||
EndDate = thisWeekStart.AddDays(-1).AddHours(23).AddMinutes(59).AddSeconds(59);
|
||||
}
|
||||
break;
|
||||
case "last2weeks":
|
||||
StartDate = today.AddDays(-13);
|
||||
EndDate = now;
|
||||
@@ -482,12 +486,12 @@ namespace _29WxOrderWpf.Ctrls.Statistics.ViewModels
|
||||
EndDate = now;
|
||||
break;
|
||||
case "lastmonth":
|
||||
{
|
||||
var firstOfThisMonth = new DateTime(today.Year, today.Month, 1);
|
||||
StartDate = firstOfThisMonth.AddMonths(-1);
|
||||
EndDate = firstOfThisMonth.AddDays(-1).AddHours(23).AddMinutes(59).AddSeconds(59);
|
||||
}
|
||||
break;
|
||||
{
|
||||
var firstOfThisMonth = new DateTime(today.Year, today.Month, 1);
|
||||
StartDate = firstOfThisMonth.AddMonths(-1);
|
||||
EndDate = firstOfThisMonth.AddDays(-1).AddHours(23).AddMinutes(59).AddSeconds(59);
|
||||
}
|
||||
break;
|
||||
case "last3months":
|
||||
StartDate = new DateTime(today.Year, today.Month, 1).AddMonths(-2);
|
||||
EndDate = now;
|
||||
@@ -541,6 +545,7 @@ namespace _29WxOrderWpf.Ctrls.Statistics.ViewModels
|
||||
StartDate = StartDate,
|
||||
EndDate = EndDate,
|
||||
ShopIds = BuildSelectedShopIds(),
|
||||
StatPackages = StatPackages
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,11 @@ namespace _29WxOrderWpf.Ctrls.Statistics.ViewModels
|
||||
|
||||
InitializeAsync();
|
||||
}
|
||||
public bool StatPackages
|
||||
{
|
||||
get { return this.GetValue(x => x.StatPackages); }
|
||||
set { this.SetValue(x => x.StatPackages, value); }
|
||||
}
|
||||
|
||||
#region 查询条件
|
||||
|
||||
@@ -288,6 +293,7 @@ namespace _29WxOrderWpf.Ctrls.Statistics.ViewModels
|
||||
StartDate = StartDate,
|
||||
EndDate = EndDate,
|
||||
ShopIds = BuildSelectedShopIds(),
|
||||
StatPackages = StatPackages,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -298,7 +304,7 @@ namespace _29WxOrderWpf.Ctrls.Statistics.ViewModels
|
||||
try
|
||||
{
|
||||
var result = await _service.QueryAsync(BuildQuery());
|
||||
|
||||
|
||||
Summary = result.Summary;
|
||||
TrendData = new ObservableCollection<RevenueTrendPoint>(result.Trend ?? new List<RevenueTrendPoint>());
|
||||
ShopProportionData = new ObservableCollection<ShopSalesProportionItem>(result.ShopProportions ?? new List<ShopSalesProportionItem>());
|
||||
|
||||
Reference in new issue
Block a user