14 changed files with 365 additions and 27 deletions
@ -1,41 +1,42 @@ |
|||
using System; |
|||
using CommunityToolkit.Mvvm.ComponentModel; |
|||
using System; |
|||
|
|||
namespace BBWYB.Client.Models |
|||
{ |
|||
public class OrderSkuResponse |
|||
public class OrderSkuResponse : ObservableObject |
|||
{ |
|||
|
|||
public long Id { get; set; } |
|||
public long Id { get; set; } |
|||
|
|||
public DateTime? CreateTime { get; set; } |
|||
public DateTime? CreateTime { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 销售数量
|
|||
/// </summary>
|
|||
public int ItemTotal { get; set; } |
|||
/// <summary>
|
|||
/// 销售数量
|
|||
/// </summary>
|
|||
public int ItemTotal { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Logo
|
|||
/// </summary>
|
|||
/// <summary>
|
|||
/// Logo
|
|||
/// </summary>
|
|||
|
|||
public string Logo { get; set; } |
|||
public string Logo { get; set; } |
|||
|
|||
|
|||
public string OrderId { get; set; } |
|||
public string OrderId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 销售单价
|
|||
/// </summary>
|
|||
public decimal? Price { get; set; } |
|||
/// <summary>
|
|||
/// 销售单价
|
|||
/// </summary>
|
|||
public decimal? Price { get; set; } |
|||
|
|||
public string ProductId { get; set; } |
|||
public string ProductId { get; set; } |
|||
|
|||
public string SkuId { get; set; } |
|||
public string SkuId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Sku标题
|
|||
/// </summary>
|
|||
public string Title { get; set; } |
|||
} |
|||
/// <summary>
|
|||
/// Sku标题
|
|||
/// </summary>
|
|||
public string Title { get; set; } |
|||
} |
|||
} |
|||
|
@ -0,0 +1,30 @@ |
|||
using System; |
|||
|
|||
namespace BBWYB.Client.Models |
|||
{ |
|||
public class OrderSkuEditPrice : OrderSku |
|||
{ |
|||
private decimal newPrice; |
|||
private decimal freightAmount; |
|||
private bool isResponseFreightChanged; |
|||
|
|||
public decimal NewPrice { get => newPrice; set { SetProperty(ref newPrice, value); } } |
|||
|
|||
public decimal FreightAmount |
|||
{ |
|||
get => freightAmount; |
|||
set |
|||
{ |
|||
if (SetProperty(ref freightAmount, value)) |
|||
{ |
|||
IsResponseFreightChanged = false; |
|||
OnFreightChanged?.Invoke(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public bool IsResponseFreightChanged { get => isResponseFreightChanged; set { SetProperty(ref isResponseFreightChanged, value); } } |
|||
|
|||
public Action OnFreightChanged { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,72 @@ |
|||
using BBWYB.Client.Models; |
|||
using CommunityToolkit.Mvvm.Input; |
|||
using System.Collections.Generic; |
|||
using System.Collections.ObjectModel; |
|||
using System.Linq; |
|||
using System.Windows; |
|||
using System.Windows.Input; |
|||
|
|||
namespace BBWYB.Client.ViewModels |
|||
{ |
|||
public class EditPriceViewModel : BaseVM |
|||
{ |
|||
public IList<OrderSkuEditPrice> OrderSkuList { get; set; } |
|||
private Order order; |
|||
private decimal freightAmount; |
|||
private bool isResponseFreightChanged; |
|||
|
|||
public ICommand DistributFreightCommand { get; set; } |
|||
public decimal FreightAmount { get => freightAmount; set { SetProperty(ref freightAmount, value); } } |
|||
|
|||
public EditPriceViewModel() |
|||
{ |
|||
OrderSkuList = new ObservableCollection<OrderSkuEditPrice>(); |
|||
DistributFreightCommand = new RelayCommand(DistributFreight); |
|||
} |
|||
|
|||
private void SetData(Order order) |
|||
{ |
|||
this.order = order; |
|||
foreach (var orderSku in order.ItemList) |
|||
{ |
|||
OrderSkuList.Add(new OrderSkuEditPrice() |
|||
{ |
|||
Id = orderSku.Id, |
|||
Logo = orderSku.Logo, |
|||
Title = orderSku.Title, |
|||
SkuId = orderSku.SkuId, |
|||
Price = orderSku.Price, |
|||
NewPrice = orderSku.Price ?? 0, |
|||
ItemTotal = orderSku.ItemTotal, |
|||
OnFreightChanged = OnFreightChanged |
|||
}); |
|||
} |
|||
} |
|||
|
|||
private void DistributFreight() |
|||
{ |
|||
if (FreightAmount <= 0) |
|||
{ |
|||
MessageBox.Show("运费不正确", "提示"); |
|||
return; |
|||
} |
|||
isResponseFreightChanged = false; |
|||
var totalItemCount = OrderSkuList.Sum(s => s.ItemTotal); |
|||
foreach (var orderSku in OrderSkuList) |
|||
{ |
|||
var quantityRatio = 1M * orderSku.ItemTotal / totalItemCount; |
|||
var currentFreightAmount = FreightAmount * quantityRatio; |
|||
orderSku.FreightAmount = currentFreightAmount; |
|||
orderSku.IsResponseFreightChanged = true; |
|||
} |
|||
isResponseFreightChanged = true; |
|||
} |
|||
|
|||
private void OnFreightChanged() |
|||
{ |
|||
if (!isResponseFreightChanged) |
|||
return; |
|||
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,63 @@ |
|||
<c:BWindow x:Class="BBWYB.Client.Views.Order.EditPrice" |
|||
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
|||
xmlns:local="clr-namespace:BBWYB.Client.Views.Order" |
|||
xmlns:c="clr-namespace:SJ.Controls;assembly=SJ.Controls" |
|||
mc:Ignorable="d" |
|||
Title="修改价格" Height="400" Width="600" |
|||
Style="{StaticResource bwstyle}" |
|||
MinButtonVisibility="Collapsed" |
|||
MaxButtonVisibility="Collapsed" |
|||
DataContext="{Binding EditPrice,Source={StaticResource Locator}}" |
|||
SnapsToDevicePixels="True" |
|||
UseLayoutRounding="True"> |
|||
<Grid> |
|||
<Grid.RowDefinitions> |
|||
<RowDefinition Height="30"/> |
|||
<RowDefinition Height="40"/> |
|||
<RowDefinition Height="30"/> |
|||
<RowDefinition/> |
|||
<RowDefinition Height="60"/> |
|||
</Grid.RowDefinitions> |
|||
|
|||
<Border BorderThickness="0,0,0,1" BorderBrush="{StaticResource MainMenu.BorderBrush}" |
|||
Background="{StaticResource Border.Background}"> |
|||
<TextBlock Text="改价" HorizontalAlignment="Center" VerticalAlignment="Center"/> |
|||
</Border> |
|||
|
|||
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="5,0"> |
|||
<TextBlock Text="订单采购运费" VerticalAlignment="Center"/> |
|||
<c:BTextBox Width="100" Margin="5,0" |
|||
Text="{Binding FreightAmount}"/> |
|||
<c:BButton Content="等比均分" Width="80"/> |
|||
</StackPanel> |
|||
|
|||
<Border BorderBrush="{StaticResource Border.Brush}" |
|||
BorderThickness="1,1,1,0" |
|||
Grid.Row="2" |
|||
Background="{StaticResource Border.Background}" |
|||
Margin="5,0"> |
|||
<Grid> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="300"/> |
|||
<ColumnDefinition/> |
|||
<ColumnDefinition/> |
|||
<ColumnDefinition/> |
|||
</Grid.ColumnDefinitions> |
|||
<TextBlock Text="店铺商品信息" Style="{StaticResource middleTextBlock}"/> |
|||
<TextBlock Text="原单价" Style="{StaticResource middleTextBlock}" Grid.Column="1"/> |
|||
<TextBlock Text="现单价" Style="{StaticResource middleTextBlock}" Grid.Column="2"/> |
|||
<TextBlock Text="总运费" Style="{StaticResource middleTextBlock}" Grid.Column="3"/> |
|||
|
|||
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}"/> |
|||
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="1"/> |
|||
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="2"/> |
|||
</Grid> |
|||
</Border> |
|||
|
|||
|
|||
<c:BButton Content="保存" Grid.Row="4" HorizontalAlignment="Right" Margin="0,0,5,0" Width="80"/> |
|||
</Grid> |
|||
</c:BWindow> |
@ -0,0 +1,16 @@ |
|||
using BBWYB.Client.Models; |
|||
using SJ.Controls; |
|||
|
|||
namespace BBWYB.Client.Views.Order |
|||
{ |
|||
/// <summary>
|
|||
/// EditPrice.xaml 的交互逻辑
|
|||
/// </summary>
|
|||
public partial class EditPrice : BWindow |
|||
{ |
|||
public EditPrice(Models.Order order) |
|||
{ |
|||
InitializeComponent(); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,35 @@ |
|||
namespace SDKAdapter.OperationPlatform.Models |
|||
{ |
|||
public class OP_EditPriceRequest : BasePlatformRequest |
|||
{ |
|||
public string OrderId { get; set; } |
|||
|
|||
public IList<OP_EditPriceSkuRequest> EditItems { get; set; } |
|||
} |
|||
|
|||
public class OP_EditPriceSkuRequest |
|||
{ |
|||
/// <summary>
|
|||
/// 订单Sku商品Id
|
|||
/// </summary>
|
|||
public string OrderSkuId { get; set; } |
|||
|
|||
|
|||
public string SkuId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 单价
|
|||
/// </summary>
|
|||
public decimal Price { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 数量
|
|||
/// </summary>
|
|||
public int Quantity { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 运费
|
|||
/// </summary>
|
|||
public decimal Freight { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,22 @@ |
|||
namespace SDKAdapter.OperationPlatform.Models |
|||
{ |
|||
public class OP_EditPriceResponse |
|||
{ |
|||
public string OrderId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 订单总价
|
|||
/// </summary>
|
|||
public decimal OrderTotalAmount { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 订单货款
|
|||
/// </summary>
|
|||
public decimal OrderProductAmount { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 运费
|
|||
/// </summary>
|
|||
public decimal FreightAmount { get; set; } |
|||
} |
|||
} |
Loading…
Reference in new issue