Browse Source

10162

AddValidOverTime
shanji 2 years ago
parent
commit
b6056aa3fb
  1. 32
      BBWY.Client/APIServices/OrderService.cs
  2. 2
      BBWY.Client/GlobalContext.cs
  3. 46
      BBWY.Client/Models/APIModel/Response/Order/ExportOrderSkuResponse.cs
  4. 3
      BBWY.Client/ViewModels/MainViewModel.cs
  5. 202
      BBWY.Client/ViewModels/Order/ExportOrderSkuViewModel.cs
  6. 9
      BBWY.Client/ViewModels/ViewModelLocator.cs
  7. 167
      BBWY.Client/Views/Order/ExportOrderSkuView.xaml
  8. 26
      BBWY.Client/Views/Order/ExportOrderSkuView.xaml.cs

32
BBWY.Client/APIServices/OrderService.cs

@ -278,5 +278,37 @@ namespace BBWY.Client.APIServices
shop.AppToken
}, null, HttpMethod.Post);
}
public ApiResponse<ExportOrderSkuListResponse> QueryOrderSkuList(DateTime startDate,
DateTime endDate,
int? purchasePlatform,
IList<long> shopIds,
int pageIndex,
int pageSize)
{
return SendRequest<ExportOrderSkuListResponse>(globalContext.BBYWApiHost, "api/order/queryorderskulist", new
{
shopIds,
purchasePlatform,
startTime = startDate,
endTime = endDate,
pageIndex,
pageSize
}, null, HttpMethod.Post);
}
public ApiResponse<IList<ExportOrderSkuResponse>> ExportOrderSkuList(DateTime startDate,
DateTime endDate,
int? purchasePlatform,
IList<long> shopIds)
{
return SendRequest<IList<ExportOrderSkuResponse>>(globalContext.BBYWApiHost, "api/order/exportorderskulist", new
{
shopIds,
purchasePlatform,
startTime = startDate,
endTime = endDate
}, null, HttpMethod.Post);
}
}
}

2
BBWY.Client/GlobalContext.cs

@ -13,7 +13,7 @@ namespace BBWY.Client
{
ShopServiceGroupList = new List<string>();
ShopServiceGroupLowerList = new List<string>();
ClientVersion = "10161";
ClientVersion = "10162";
}
private User user;

46
BBWY.Client/Models/APIModel/Response/Order/ExportOrderSkuResponse.cs

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
namespace BBWY.Client.Models
{
public class ExportOrderSkuResponse
{
public string OrderId { get; set; }
public DateTime? StartTime { get; set; }
public long ShopId { get; set; }
public string ShopName { get; set; }
public string Spu { get; set; }
public string Sku { get; set; }
public StorageType? StorageType { get; set; }
public decimal? PurchaseSkuAmount { get; set; }
public decimal? PurchaseFreight { get; set; }
public decimal? PurchaseAmount { get { return PurchaseSkuAmount + PurchaseFreight; } }
public decimal? SkuPrice { get; set; }
public int? ItemTotal { get; set; }
public string SpuName { get; set; }
public override string ToString()
{
return $"{StartTime},{ShopName},{OrderId},{Spu},{Sku},{StorageType},{PurchaseAmount},{SkuPrice},{ItemTotal},{SpuName}";
}
}
public class ExportOrderSkuListResponse
{
public long Count { get; set; }
public IList<ExportOrderSkuResponse> ItemList { get; set; }
}
}

3
BBWY.Client/ViewModels/MainViewModel.cs

@ -228,7 +228,8 @@ namespace BBWY.Client.ViewModels
ChildList = new List<MenuModel>()
{
new MenuModel(){ Name="采购审计",Url="/Views/FinancialTerminal/ProcurementAudit.xaml" },
new MenuModel(){ Name="费用矫正",Url="/Views/BillCorrection/BillCorrectionView.xaml" }
new MenuModel(){ Name="费用矫正",Url="/Views/BillCorrection/BillCorrectionView.xaml" },
new MenuModel(){ Name="订单导出",Url="/Views/Order/ExportOrderSkuView.xaml" }
}
}));
}

202
BBWY.Client/ViewModels/Order/ExportOrderSkuViewModel.cs

@ -0,0 +1,202 @@
using BBWY.Client.APIServices;
using BBWY.Client.Models;
using BBWY.Common.Models;
using BBWY.Controls;
using GalaSoft.MvvmLight.Command;
using Microsoft.Win32;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
namespace BBWY.Client.ViewModels
{
public class ExportOrderSkuViewModel : BaseVM, IDenpendency
{
private DateTime startDate;
private DateTime endDate;
private GlobalContext globalContext;
private KVModel selectedPlatform;
private int pageIndex;
private int pageSize;
private long totalCount;
private bool isLoading;
private OrderService orderService;
public IList<Department> DepartmentList { get; set; }
public IList<Shop> ShopList { get; set; }
public IList<KVModel> PlatformList { get; set; }
public IList<ExportOrderSkuResponse> ExportSkuList { get; set; }
public DateTime StartDate { get => startDate; set { Set(ref startDate, value); } }
public DateTime EndDate { get => endDate; set { Set(ref endDate, value); } }
public KVModel SelectedPlatform { get => selectedPlatform; set { Set(ref selectedPlatform, value); } }
public ICommand SearchCommand { get; set; }
public ICommand ExportCommand { get; set; }
public ICommand OrderPageIndexChangedCommand { get; set; }
public int PageIndex { get => pageIndex; set { Set(ref pageIndex, value); } }
public int PageSize { get => pageSize; set { Set(ref pageSize, value); } }
public bool IsLoading { get => isLoading; set { Set(ref isLoading, value); } }
public long TotalCount { get => totalCount; set { Set(ref totalCount, value); } }
public ExportOrderSkuViewModel(GlobalContext globalContext, OrderService orderService)
{
this.orderService = orderService;
DepartmentList = new ObservableCollection<Department>();
ShopList = new ObservableCollection<Shop>();
PlatformList = new ObservableCollection<KVModel>();
ExportSkuList = new ObservableCollection<ExportOrderSkuResponse>();
SearchCommand = new RelayCommand(Search);
ExportCommand = new RelayCommand(Export);
OrderPageIndexChangedCommand = new RelayCommand<PageArgs>(p =>
{
//this.PageIndex = p.PageIndex;
Task.Factory.StartNew(() => SearchCore(p.PageIndex));
});
var platformEnumValues = Enum.GetValues(typeof(Platform));
foreach (var ev in platformEnumValues)
{
var p = (Platform)ev;
PlatformList.Add(new KVModel()
{
Key = p.ToString(),
Value = ((int)p).ToString()
});
}
this.globalContext = globalContext;
LoadDepartment();
StartDate = DateTime.Now.Date;
EndDate = DateTime.Now.Date;
PageIndex = 1;
PageSize = 20;
}
private void LoadDepartment()
{
var dlist = JsonConvert.DeserializeObject<IList<Department>>(JsonConvert.SerializeObject(globalContext.User.DepartmentList));
foreach (var d in dlist)
{
d.IsSelected = false;
DepartmentList.Add(d);
d.OnIsSelectedChanged = OnDeparmentSelectionChanged;
}
ShopList.Clear();
}
private void OnDeparmentSelectionChanged()
{
ShopList.Clear();
foreach (var d in DepartmentList)
{
if (!d.IsSelected)
continue;
foreach (var s in d.ShopList)
{
s.IsSelected = false;
ShopList.Add(s);
}
}
}
private void Search()
{
PageIndex = 1;
Task.Factory.StartNew(() => SearchCore(PageIndex));
}
private void SearchCore(int pageIndex)
{
IsLoading = true;
int? purchasePlatform = null;
if (SelectedPlatform != null)
purchasePlatform = int.Parse(SelectedPlatform.Value);
var response = orderService.QueryOrderSkuList(StartDate,
EndDate,
purchasePlatform,
ShopList.Where(s => s.IsSelected).Select(s => s.ShopId).ToList(),
pageIndex,
PageSize);
IsLoading = false;
TotalCount = 0;
if (!response.Success)
{
App.Current.Dispatcher.Invoke(() => MessageBox.Show(response.Msg, "提示"));
return;
}
TotalCount = response.Data.Count;
App.Current.Dispatcher.Invoke(() =>
{
ExportSkuList.Clear();
foreach (var item in response.Data.ItemList)
ExportSkuList.Add(item);
});
}
private void Export()
{
var sfd = new SaveFileDialog() { Filter = "csv files(*.csv)|*.csv" };
if (sfd.ShowDialog() != true)
return;
var ssaveFileName = sfd.FileName;
int? purchasePlatform = null;
if (SelectedPlatform != null)
purchasePlatform = int.Parse(SelectedPlatform.Value);
IsLoading = true;
Task.Factory.StartNew(() => orderService.ExportOrderSkuList(StartDate,
EndDate,
purchasePlatform,
ShopList.Where(s => s.IsSelected).Select(s => s.ShopId).ToList())).ContinueWith(t =>
{
var response = t.Result;
if (!response.Success)
{
IsLoading = false;
App.Current.Dispatcher.Invoke(() => MessageBox.Show(response.Msg, "提示"));
return;
}
try
{
var list = response.Data.Select(x => x.ToString()).ToList();
list.Insert(0, "开始时间,店铺名称,订单Id,SPU,SKU,仓储类型,采购成本(货款+运费),单价,数量,商品标题");
System.IO.File.WriteAllLines(ssaveFileName, list, Encoding.UTF8);
App.Current.Dispatcher.Invoke(() => MessageBox.Show("导出完成", "导出"));
}
catch (Exception ex)
{
App.Current.Dispatcher.Invoke(() => MessageBox.Show(response.Msg, "导出"));
return;
}
finally
{
IsLoading = false;
}
});
}
}
}

9
BBWY.Client/ViewModels/ViewModelLocator.cs

@ -367,6 +367,15 @@ namespace BBWY.Client.ViewModels
}
}
public ExportOrderSkuViewModel ExportOrderSkuVM
{
get
{
using var s = sp.CreateScope();
return s.ServiceProvider.GetRequiredService<ExportOrderSkuViewModel>();
}
}
//public ShopSealBoxListViewModel ShopSealBoxListVM
//{
// get

167
BBWY.Client/Views/Order/ExportOrderSkuView.xaml

@ -0,0 +1,167 @@
<Page x:Class="BBWY.Client.Views.Order.ExportOrderSkuView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:c="clr-namespace:BBWY.Controls;assembly=BBWY.Controls"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:cmodel="clr-namespace:BBWY.Client.Models"
xmlns:local="clr-namespace:BBWY.Client.Views.Order"
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
mc:Ignorable="d"
d:DesignHeight="769" d:DesignWidth="1024"
DataContext="{Binding ExportOrderSkuVM,Source={StaticResource Locator}}"
Title="ExportOrderSkuView">
<Grid>
<c:RoundWaitProgress Play="{Binding IsLoading}" Panel.ZIndex="999"/>
<Grid Margin="5,0">
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="5"/>
<RowDefinition />
<RowDefinition Height="5"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Grid Background="{StaticResource Border.Background}">
<Grid.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml"/>
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Grid.Resources>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="5,0">
<hc:CheckComboBox IsTextSearchEnabled="True" ItemsSource="{Binding DepartmentList}"
ShowClearButton="True"
MinWidth="150"
Height="30">
<hc:CheckComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="5,2.5">
<CheckBox Content="{Binding Name}" IsChecked="{Binding IsSelected,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
</StackPanel>
</DataTemplate>
</hc:CheckComboBox.ItemTemplate>
<hc:CheckComboBox.ItemContainerStyle>
<Style TargetType="{x:Type hc:CheckComboBoxItem}" BasedOn="{StaticResource NoBgListBoxItemStyle}">
<Setter Property="IsSelected" Value="{Binding IsSelected,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
</Style>
</hc:CheckComboBox.ItemContainerStyle>
</hc:CheckComboBox>
<hc:CheckComboBox IsTextSearchEnabled="True" ItemsSource="{Binding ShopList}"
ShowClearButton="True"
MinWidth="150"
Margin="5,0,0,0">
<hc:CheckComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="5,2.5">
<CheckBox Content="{Binding ShopName}" IsChecked="{Binding IsSelected,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
</StackPanel>
</DataTemplate>
</hc:CheckComboBox.ItemTemplate>
<hc:CheckComboBox.ItemContainerStyle>
<Style TargetType="{x:Type hc:CheckComboBoxItem}" BasedOn="{StaticResource NoBgListBoxItemStyle}">
<Setter Property="IsSelected" Value="{Binding IsSelected,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
</Style>
</hc:CheckComboBox.ItemContainerStyle>
</hc:CheckComboBox>
<hc:CheckComboBox IsTextSearchEnabled="True" ItemsSource="{Binding PlatformList}"
ShowClearButton="True"
MinWidth="150"
Margin="5,0,0,0"
SelectionMode="Single"
SelectedItem="{Binding SelectedPlatform,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
DisplayMemberPath="Key">
<!--<hc:CheckComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="5,2.5">
-->
<!--<CheckBox Content="{Binding Key}" IsChecked="{Binding IsSelected,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>-->
<!--
<TextBlock Text="{Binding Key}"/>
</StackPanel>
</DataTemplate>
</hc:CheckComboBox.ItemTemplate>-->
<!--<hc:CheckComboBox.ItemContainerStyle>
<Style TargetType="{x:Type hc:CheckComboBoxItem}" BasedOn="{StaticResource NoBgListBoxItemStyle}">
<Setter Property="IsSelected" Value="{Binding IsSelected,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
</Style>
</hc:CheckComboBox.ItemContainerStyle>-->
</hc:CheckComboBox>
<DatePicker Height="30" Margin="5,0,0,0" SelectedDate="{Binding StartDate,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
<DatePicker Height="30" Margin="5,0,0,0" SelectedDate="{Binding EndDate,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
<c:BButton Content="查询" Margin="5,0,0,0" Width="80" Command="{Binding SearchCommand}"/>
<c:BButton Content="导出" Width="80" Margin="5,0,0,0" Command="{Binding ExportCommand}" Background="#02A7F0"/>
</StackPanel>
</Grid>
<DataGrid Grid.Row="2"
ItemsSource="{Binding ExportSkuList}"
BorderThickness="1,1,0,0"
BorderBrush="{StaticResource Border.Brush}"
VirtualizingPanel.IsVirtualizing="True">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding StartTime,StringFormat=yyyy-MM-dd HH:mm:ss}" Header="订单日期"
ElementStyle="{StaticResource middleTextBlock}"
HeaderStyle="{StaticResource ColumnHeaderStyle_Center}"
Width="140"/>
<DataGridTextColumn Binding="{Binding ShopName}" Header="店铺名称"
ElementStyle="{StaticResource middleTextBlock}"
HeaderStyle="{StaticResource ColumnHeaderStyle_Center}"
Width="150"/>
<DataGridTextColumn Binding="{Binding OrderId}" Header="订单号"
ElementStyle="{StaticResource middleTextBlock}"
HeaderStyle="{StaticResource ColumnHeaderStyle_Center}"
Width="110"/>
<DataGridTextColumn Binding="{Binding Spu}" Header="SPU"
ElementStyle="{StaticResource middleTextBlock}"
HeaderStyle="{StaticResource ColumnHeaderStyle_Center}"
Width="120"/>
<DataGridTextColumn Binding="{Binding Sku}" Header="SKU"
ElementStyle="{StaticResource middleTextBlock}"
HeaderStyle="{StaticResource ColumnHeaderStyle_Center}"
Width="120"/>
<DataGridTextColumn Binding="{Binding StorageType}" Header="仓储类型"
ElementStyle="{StaticResource middleTextBlock}"
HeaderStyle="{StaticResource ColumnHeaderStyle_Center}"
Width="80"/>
<DataGridTextColumn Binding="{Binding PurchaseAmount,Mode=OneWay}" Header="采购成本"
ElementStyle="{StaticResource middleTextBlock}"
HeaderStyle="{StaticResource ColumnHeaderStyle_Center}"
Width="80"/>
<DataGridTextColumn Binding="{Binding SkuPrice}" Header="单价"
ElementStyle="{StaticResource middleTextBlock}"
HeaderStyle="{StaticResource ColumnHeaderStyle_Center}"
Width="80"/>
<DataGridTextColumn Binding="{Binding ItemTotal}" Header="数量"
ElementStyle="{StaticResource middleTextBlock}"
HeaderStyle="{StaticResource ColumnHeaderStyle_Center}"
Width="50"/>
<DataGridTextColumn Binding="{Binding SpuName}" Header="商品标题" ElementStyle="{StaticResource middleTextBlock}"
HeaderStyle="{StaticResource ColumnHeaderStyle_Center}"
Width="*"/>
</DataGrid.Columns>
</DataGrid>
<c:PageControl PageIndex="{Binding PageIndex}"
PageSize="{Binding PageSize}"
RecordCount="{Binding TotalCount}"
Grid.Row="4"
HorizontalAlignment="Left">
<b:Interaction.Triggers>
<b:EventTrigger EventName="OnPageIndexChanged">
<b:InvokeCommandAction Command="{Binding OrderPageIndexChangedCommand}" PassEventArgsToCommand="True"/>
</b:EventTrigger>
</b:Interaction.Triggers>
</c:PageControl>
</Grid>
</Grid>
</Page>

26
BBWY.Client/Views/Order/ExportOrderSkuView.xaml.cs

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;
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.Navigation;
using System.Windows.Shapes;
namespace BBWY.Client.Views.Order
{
/// <summary>
/// ExportOrderSkuView.xaml 的交互逻辑
/// </summary>
public partial class ExportOrderSkuView : Page
{
public ExportOrderSkuView()
{
InitializeComponent();
}
}
}
Loading…
Cancel
Save