Browse Source

客户端支持关联多单

qianyi
shanji 3 years ago
parent
commit
7e004f1ffd
  1. 15
      BBWY.Client/APIServices/OrderService.cs
  2. 3
      BBWY.Client/Models/Order/RelationPurchaseOrderSku.cs
  3. 4
      BBWY.Client/Resources/Themes/Path.xaml
  4. 19
      BBWY.Client/ViewModels/Order/OrderListViewModel.cs
  5. 22
      BBWY.Client/Views/Order/ManualCalculationCost.xaml
  6. 100
      BBWY.Client/Views/Order/RelationPurchaseOrder.xaml
  7. 85
      BBWY.Client/Views/Order/RelationPurchaseOrder.xaml.cs

15
BBWY.Client/APIServices/OrderService.cs

@ -172,19 +172,12 @@ namespace BBWY.Client.APIServices
}, null, HttpMethod.Post);
}
/// <summary>
/// 关联代发订单
/// </summary>
/// <param name="orderDropShipping"></param>
/// <param name="relationPurchaseOrderSkuList"></param>
/// <returns></returns>
public ApiResponse<object> RelationPurchaseOrder(OrderDropShipping orderDropShipping, IList<RelationPurchaseOrderSku> relationPurchaseOrderSkuList, decimal platformCommissionRatio)
public ApiResponse<object> RelationPurchaseOrderV2(IList<OrderDropShipping> orderDropShippingList, decimal platformCommissionRatio)
{
return SendRequest<object>(globalContext.BBYWApiHost, "api/order/RelationPurchaseOrder", new
return SendRequest<object>(globalContext.BBYWApiHost, "api/order/RelationPurchaseOrderV2", new
{
orderDropShipping,
relationPurchaseOrderSkuList,
platformCommissionRatio
orderDropShippingList,
platformCommissionRatio,
}, null, HttpMethod.Post);
}

3
BBWY.Client/Models/Order/RelationPurchaseOrderSku.cs

@ -9,7 +9,7 @@ namespace BBWY.Client.Models
{
SingleSkuAmountStr = (0).ToString();
}
private bool isSelected;
private string singleSkuAmountStr;
private decimal singleSkuAmount;
private decimal skuAmount;
@ -65,5 +65,6 @@ namespace BBWY.Client.Models
[JsonIgnore]
public Action OnSkuAmountChanged { get; set; }
public bool IsSelected { get => isSelected; set { Set(ref isSelected, value); } }
}
}

4
BBWY.Client/Resources/Themes/Path.xaml

@ -22,4 +22,8 @@
<Style x:Key="path_flag" TargetType="Path" BasedOn="{StaticResource basePath}">
<Setter Property="Data" Value="M1.9000015,1.4000239L7.6999969,31.300008 5.8000031,31.700002 0,1.8000178z M9.5999985,0C17.300003,1.653807E-07,28.699997,2.1000055,28.699997,2.1000057L26,11.100002 32,20.400018C14.800003,15.999994,6.6999969,18.999993,6.6999969,18.999993L3.1999969,1.2000117C4.1999969,0.30001835,6.5999985,1.653807E-07,9.5999985,0z"/>
</Style>
<Style x:Key="path_close" TargetType="Path" BasedOn="{StaticResource basePath}">
<Setter Property="Data" Value="M814.060 781.227q-67.241-67.241-269.773-269.773 67.241-67.241 269.773-269.773 5.671-6.481 5.671-12.962 0 0-0.81-0.81 0-6.481-4.861-9.722-4.861-4.051-11.342-4.861-0.81 0-0.81 0-5.671 0-11.342 4.861-89.924 89.924-269.773 269.773-67.241-67.241-269.773-269.773-4.861-4.861-12.962-4.861-7.291 0.81-10.532 4.861-5.671 5.671-5.671 11.342 0 6.481 5.671 12.152 89.924 89.924 269.773 269.773-67.241 67.241-269.773 269.773-11.342 11.342 0 23.494 12.152 11.342 23.494 0 89.924-89.924 269.773-269.773 67.241 67.241 269.773 269.773 5.671 5.671 11.342 5.671 5.671 0 12.152-5.671 4.861-5.671 4.861-12.962 0-6.481-4.861-10.532z"/>
</Style>
</ResourceDictionary>

19
BBWY.Client/ViewModels/Order/OrderListViewModel.cs

@ -347,6 +347,25 @@ namespace BBWY.Client.ViewModels
private void RelationPurchaseOrder_Closed(object sender, EventArgs e)
{
var relationPurchaseOrder = sender as RelationPurchaseOrder;
if (relationPurchaseOrder.DialogResult != true)
return;
var orderDropShippingList = relationPurchaseOrder.OrderDropShippingList;
var orderId = relationPurchaseOrder.OrderId;
IsLoading = true;
Task.Factory.StartNew(() => orderService.RelationPurchaseOrderV2(orderDropShippingList, globalContext.User.Shop.PlatformCommissionRatio ?? 0.05M))
.ContinueWith(t =>
{
var response = t.Result;
if (!response.Success)
{
IsLoading = false;
App.Current.Dispatcher.Invoke(() => MessageBox.Show(response.Msg, "关联采购订单"));
return;
}
RefreshOrder(orderId);
});
//var relationPurchaseOrder = sender as RelationPurchaseOrder;
//if (relationPurchaseOrder.DialogResult != true)
// return;

22
BBWY.Client/Views/Order/ManualCalculationCost.xaml

@ -203,17 +203,17 @@
Click="btn_fillFromLately_Click"/>
</Grid>-->
<StackPanel Orientation="Horizontal" Grid.Row="2" HorizontalAlignment="Right" Margin="0,0,8,0">
<TextBlock Text="销售运费总计" VerticalAlignment="Center"/>
<TextBlock x:Name="txtTotalDeliveryExpressFreight" Text="100" VerticalAlignment="Center" Margin="2,0" Foreground="#EC808D"/>
<TextBlock Text="元" VerticalAlignment="Center"/>
<TextBlock Text="采购成本总计" VerticalAlignment="Center" Margin="10,0,0,0"/>
<TextBlock x:Name="txtTotalCost" Text="100" VerticalAlignment="Center" Margin="2,0" Foreground="#EC808D"/>
<TextBlock Text="元" VerticalAlignment="Center"/>
<c:BButton x:Name="btn_Save" Content="保存" Width="60" Margin="10,0,0,0"
Click="btn_Save_Click"/>
<StackPanel Orientation="Horizontal" Grid.Row="2" HorizontalAlignment="Left" Margin="8,0,0,0">
<TextBlock Text="销售运费总计" VerticalAlignment="Center" FontSize="16"/>
<TextBlock x:Name="txtTotalDeliveryExpressFreight" Text="100" VerticalAlignment="Center" Margin="2,0" Foreground="#EC808D" FontSize="16"/>
<TextBlock Text="元" VerticalAlignment="Center" FontSize="16"/>
<TextBlock Text="采购成本总计" VerticalAlignment="Center" Margin="10,0,0,0" FontSize="16"/>
<TextBlock x:Name="txtTotalCost" Text="100" VerticalAlignment="Center" Margin="2,0" Foreground="#EC808D" FontSize="16"/>
<TextBlock Text="元" VerticalAlignment="Center" FontSize="16"/>
</StackPanel>
<c:BButton x:Name="btn_Save" Content="保存" Width="60" Margin="0,0,8,0"
Click="btn_Save_Click" Grid.Row="2" HorizontalAlignment="Right"/>
</Grid>
</c:BWindow>

100
BBWY.Client/Views/Order/RelationPurchaseOrder.xaml

@ -9,7 +9,7 @@
xmlns:sys="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
Title="关联采购订单"
Height="500" Width="500"
Height="800" Width="500"
Style="{StaticResource bwstyle}"
MinButtonVisibility="Collapsed"
MaxButtonVisibility="Collapsed">
@ -26,7 +26,7 @@
<!--<RowDefinition Height="130"/>
<RowDefinition Height="1*"/>-->
<RowDefinition Height="*"/>
<RowDefinition Height="40"/>
<RowDefinition Height="60"/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<Border BorderThickness="0,0,0,1" BorderBrush="{StaticResource MainMenu.BorderBrush}"
@ -46,7 +46,7 @@
<Grid.RowDefinitions>
<RowDefinition Height="130"/>
<RowDefinition/>
<RowDefinition Height="40"/>
<RowDefinition Height="60"/>
</Grid.RowDefinitions>
<Grid Margin="5,0">
@ -154,10 +154,12 @@
</ListBox>
</Grid>
<c:BButton Grid.Row="2" Style="{StaticResource LinkButton}">
<c:BButton Grid.Row="2" Style="{StaticResource LinkButton}"
Command="{Binding DataContext.AddRelationPurchaseOrderSkuCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type c:BWindow}}}"
CommandParameter="{Binding }">
<StackPanel>
<Path Style="{StaticResource path_add}" Fill="{StaticResource Text.Link.Color}" Width="16"/>
<TextBlock Text="添加采购单"/>
<TextBlock Text="添加Sku"/>
</StackPanel>
</c:BButton>
</Grid>
@ -166,21 +168,81 @@
</ListBox.ItemTemplate>
</ListBox>
<c:BButton Grid.Row="2" Style="{StaticResource LinkButton}">
<StackPanel>
<Path Style="{StaticResource path_add}" Fill="{StaticResource Text.Link.Color}" Width="16"/>
<TextBlock Text="添加采购单"/>
</StackPanel>
</c:BButton>
<StackPanel Orientation="Horizontal" Grid.Row="3" HorizontalAlignment="Right">
<TextBlock VerticalAlignment="Center" Margin="0,0,8,0">
<Run Text="总计"/>
<Border Grid.Row="2" BorderThickness="1" BorderBrush="{StaticResource Border.Brush}" Margin="5,0">
<c:BButton x:Name="btn_AddOrderDropShipping"
Style="{StaticResource LinkButton}"
Command="{Binding AddOrderDropShippingCommand}">
<StackPanel>
<Path Style="{StaticResource path_add}" Fill="{StaticResource Text.Link.Color}" Width="16"/>
<TextBlock Text="添加采购单"/>
</StackPanel>
</c:BButton>
</Border>
<TextBlock VerticalAlignment="Center" Margin="5,0,0,0" Grid.Row="3" FontSize="16">
<Run Text="采购总额(含运费)"/>
<Run Text="{Binding TotalCost}" Foreground="#EC808D"/>
<Run Text="元"/>
</TextBlock>
<c:BButton x:Name="btn_Save" Content="保存" Width="60" Margin="0,0,8,0"
Click="btn_Save_Click"/>
</StackPanel>
</TextBlock>
<c:BButton x:Name="btn_Save" Content="保存" Width="60" Grid.Row="3" Margin="0,0,5,0"
Click="btn_Save_Click" HorizontalAlignment="Right"/>
<Border Grid.Row="1" Background="White" Margin="20" BorderBrush="{StaticResource Border.Brush}" BorderThickness="1"
Visibility="{Binding IsShowChooseSkuPanel,Converter={StaticResource objConverter},ConverterParameter=true:Visible:Collapsed}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<Border BorderThickness="0,0,0,1" BorderBrush="{StaticResource MainMenu.BorderBrush}"
Background="{StaticResource Border.Background}">
<TextBlock Text="选择Sku" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<c:BButton HorizontalAlignment="Right" Width="14" Height="14" Margin="0,0,8,0" Background="Transparent"
Command="{Binding CloseShowChooseSkuPanelCommand}">
<Path Style="{StaticResource path_close}" Fill="{StaticResource Text.Color}"/>
</c:BButton>
<ListBox x:Name="listBox_chooseSku" Grid.Row="1" ItemsSource="{Binding ChooseRelationPurchaseOrderSkuList}"
Style="{StaticResource NoScrollViewListBoxStyle}"
ItemContainerStyle="{StaticResource NoBgListBoxItemStyle}"
BorderThickness="1,1,1,0"
VerticalAlignment="Top"
BorderBrush="{StaticResource Border.Brush}"
Margin="10">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Width="{Binding ActualWidth,ElementName=listBox_chooseSku}" Height="90">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<CheckBox IsChecked="{Binding IsSelected,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
HorizontalAlignment="Center"/>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}"/>
<StackPanel Orientation="Horizontal" Grid.Column="1">
<c:BAsyncImage UrlSource="{Binding Logo}"
Width="80" DecodePixelWidth="80" Margin="5,0,0,0"/>
<TextBlock Text="{Binding Title}" Grid.Column="1" VerticalAlignment="Center" Margin="5,0,0,0"
TextWrapping="Wrap"/>
</StackPanel>
<Border Height="1" VerticalAlignment="Bottom" Grid.ColumnSpan="2" Background="{StaticResource Border.Brush}"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<c:BButton Content="确定" Width="60" Grid.Row="2" Margin="0,0,5,0" HorizontalAlignment="Right"
Command="{Binding CloseShowChooseSkuPanelCommand}"/>
</Grid>
</Border>
</Grid>
</c:BWindow>

85
BBWY.Client/Views/Order/RelationPurchaseOrder.xaml.cs

@ -1,9 +1,12 @@
using BBWY.Client.Models;
using BBWY.Controls;
using GalaSoft.MvvmLight.Command;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Input;
namespace BBWY.Client.Views.Order
{
@ -12,22 +15,48 @@ namespace BBWY.Client.Views.Order
/// </summary>
public partial class RelationPurchaseOrder : BWindow
{
public ICommand AddRelationPurchaseOrderSkuCommand { get; set; }
public ICommand AddOrderDropShippingCommand { get; set; }
public ICommand CloseShowChooseSkuPanelCommand { get; set; }
public IList<OrderDropShipping> OrderDropShippingList { get; set; }
public IList<RelationPurchaseOrderSku> RelationPurchaseOrderSkuList { get; set; }
public IList<RelationPurchaseOrderSku> ChooseRelationPurchaseOrderSkuList { get; set; }
public IList<PurchaseAccount> PurchaseAccountList { get; set; }
public string OrderId { get; set; }
public decimal TotalCost { get => totalCost; set { Set(ref totalCost, value); } }
public bool IsShowChooseSkuPanel
{
get => isShowChooseSkuPanel; set
{
if (Set(ref isShowChooseSkuPanel, value))
{
if (!value)
OnShowChooseSkuPanelClose();
}
}
}
private decimal totalCost;
private bool isShowChooseSkuPanel;
private OrderDropShipping currentOds;
public RelationPurchaseOrder(string orderId, IList<PurchaseAccount> purchaseAccountList, IList<OrderDropShipping> orderDropShippingList, IList<RelationPurchaseOrderSku> relationPurchaseOrderSkuList)
{
InitializeComponent();
this.DataContext = this;
this.PurchaseAccountList = purchaseAccountList;
this.OrderId = orderId;
OrderDropShippingList = new ObservableCollection<OrderDropShipping>();
@ -46,11 +75,22 @@ namespace BBWY.Client.Views.Order
}
}
this.RelationPurchaseOrderSkuList = relationPurchaseOrderSkuList;
RelationPurchaseOrderSkuList = relationPurchaseOrderSkuList;
ChooseRelationPurchaseOrderSkuList = new ObservableCollection<RelationPurchaseOrderSku>();
RefreshChooseRelationPurchaseOrderSkuList();
foreach (var sku in RelationPurchaseOrderSkuList)
sku.OnSkuAmountChanged = OnSkuAmountChanged;
OnPurchaseAmountChanged();
AddOrderDropShippingCommand = new RelayCommand(() => OrderDropShippingList.Add(new OrderDropShipping()
{
BuyerAccount = PurchaseAccountList.FirstOrDefault()?.AccountName,
OnPurchaseAmountChanged = OnPurchaseAmountChanged
}));
AddRelationPurchaseOrderSkuCommand = new RelayCommand<OrderDropShipping>(AddRelationPurchaseOrderSku);
CloseShowChooseSkuPanelCommand = new RelayCommand(() => IsShowChooseSkuPanel = false);
}
private void OnSkuAmountChanged()
@ -64,8 +104,23 @@ namespace BBWY.Client.Views.Order
TotalCost = OrderDropShippingList.Sum(ods => ods.PurchaseAmount);
}
private void btn_Save_Click(object sender, System.Windows.RoutedEventArgs e)
private void btn_Save_Click(object sender, RoutedEventArgs e)
{
if (OrderDropShippingList.Count() == 0)
{
MessageBox.Show("关联订单信息不全", "提示");
return;
}
if (OrderDropShippingList.Any(ods => ods.RelationPurchaseOrderSkuList.Count() == 0 ||
string.IsNullOrEmpty(ods.PurchaseOrderId) ||
string.IsNullOrEmpty(ods.SellerAccount) ||
string.IsNullOrEmpty(ods.BuyerAccount) ||
ods.PurchaseAmount == 0))
{
MessageBox.Show("关联订单信息不全", "提示");
return;
}
//if (string.IsNullOrEmpty(OrderDropShipping.PurchaseOrderId) ||
// string.IsNullOrEmpty(OrderDropShipping.SellerAccount) ||
// string.IsNullOrEmpty(OrderDropShipping.BuyerAccount) ||
@ -77,5 +132,31 @@ namespace BBWY.Client.Views.Order
this.DialogResult = true;
this.Close();
}
private void AddRelationPurchaseOrderSku(OrderDropShipping ods)
{
currentOds = ods;
IsShowChooseSkuPanel = true;
}
private void OnShowChooseSkuPanelClose()
{
var chooseSkuList = ChooseRelationPurchaseOrderSkuList.Where(rsku => rsku.IsSelected);
foreach (var chooseSku in chooseSkuList)
{
chooseSku.OrderDropShippingId = currentOds.Id;
currentOds.RelationPurchaseOrderSkuList.Add(chooseSku);
}
RefreshChooseRelationPurchaseOrderSkuList();
}
private void RefreshChooseRelationPurchaseOrderSkuList()
{
ChooseRelationPurchaseOrderSkuList.Clear();
var noChooseList = RelationPurchaseOrderSkuList.Where(rsku => rsku.OrderDropShippingId == null);
foreach (var noChooseSku in noChooseList)
ChooseRelationPurchaseOrderSkuList.Add(noChooseSku);
}
}
}

Loading…
Cancel
Save