Browse Source

合并

AddValidOverTime
506583276@qq.com 2 years ago
parent
commit
2abe5eb127
  1. 32
      BBWY.Client/APIServices/OrderService.cs
  2. 2
      BBWY.Client/GlobalContext.cs
  3. 46
      BBWY.Client/Models/APIModel/Response/Order/ExportOrderSkuResponse.cs
  4. 17
      BBWY.Client/Models/Shop/Shop.cs
  5. 3
      BBWY.Client/ViewModels/MainViewModel.cs
  6. 223
      BBWY.Client/ViewModels/Order/ExportOrderSkuViewModel.cs
  7. 9
      BBWY.Client/ViewModels/ViewModelLocator.cs
  8. 166
      BBWY.Client/Views/Order/ExportOrderSkuView.xaml
  9. 26
      BBWY.Client/Views/Order/ExportOrderSkuView.xaml.cs
  10. 22
      BBWY.Server.API/Controllers/OrderController.cs
  11. 80
      BBWY.Server.Business/Order/OrderBusiness.cs
  12. 23
      BBWY.Server.Model/Dto/Request/Order/QueryOrderSkuRequest.cs
  13. 39
      BBWY.Server.Model/Dto/Response/Order/ExportOrderSkuResponse.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 = "10162";
ClientVersion = "10163";
}
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; }
}
}

17
BBWY.Client/Models/Shop/Shop.cs

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
namespace BBWY.Client.Models
{
@ -7,7 +8,19 @@ namespace BBWY.Client.Models
private bool isSelected;
private string shopName;
public bool IsSelected { get => isSelected; set { Set(ref isSelected, value); } }
public bool IsSelected
{
get => isSelected; set
{
if (Set(ref isSelected, value))
{
OnIsSelectedChanged?.Invoke();
}
}
}
public Action OnIsSelectedChanged { get; set; }
/// <summary>
/// 店铺Id
/// </summary>

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" }
}
}));
}

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

@ -0,0 +1,223 @@
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 bool isShowAll_Shop;
private bool isShowAll_Department;
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 bool IsShowAll_Shop { get => isShowAll_Shop; set { Set(ref isShowAll_Shop, value); } }
public bool IsShowAll_Department { get => isShowAll_Department; set { Set(ref isShowAll_Department, 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()
});
}
IsShowAll_Department = IsShowAll_Shop = true;
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.OnIsSelectedChanged = OnShopSelectionChanged;
s.IsSelected = false;
ShopList.Add(s);
}
}
IsShowAll_Department = !DepartmentList.Any(d => d.IsSelected);
}
private void OnShopSelectionChanged()
{
IsShowAll_Shop = !ShopList.Any(s => s.IsSelected);
}
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);
List<long> shopIds = new List<long>();
if (ShopList.Count() > 0)
{
if (ShopList.Any(s => s.IsSelected))
shopIds.AddRange(ShopList.Where(s => s.IsSelected).Select(s => s.ShopId));
else
shopIds.AddRange(ShopList.Select(s => s.ShopId));
}
var response = orderService.QueryOrderSkuList(StartDate,
EndDate,
purchasePlatform,
shopIds,
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

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

@ -0,0 +1,166 @@
<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"
xmlns:converter="clr-namespace:HandyControl.Tools.Converter;assembly=HandyControl"
xmlns:interactivity="clr-namespace:HandyControl.Interactivity;assembly=HandyControl"
xmlns:ex="clr-namespace:HandyControl.Tools.Extension;assembly=HandyControl"
xmlns:langs="clr-namespace:HandyControl.Properties.Langs;assembly=HandyControl">
<Page.Resources>
</Page.Resources>
<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">
<Grid>
<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>
<TextBlock Text="全部" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0,0,0"
Visibility="{Binding IsShowAll_Department,ConverterParameter=true:Visible:Collapsed,Converter={StaticResource objConverter}}"/>
</Grid>
<Grid>
<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>
<TextBlock Text="全部" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10,0,0,0"
Visibility="{Binding IsShowAll_Shop,ConverterParameter=true:Visible:Collapsed,Converter={StaticResource objConverter}}"/>
</Grid>
<!--<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>-->
<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();
}
}
}

22
BBWY.Server.API/Controllers/OrderController.cs

@ -144,5 +144,27 @@ namespace BBWY.Server.API.Controllers
{
return orderBusiness.SDGroupPullOrder(request);
}
/// <summary>
/// 查询订单SKU列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public ExportOrderSkuListResponse QueryOrderSkuList([FromBody] QueryOrderSkuRequest request)
{
return orderBusiness.QueryOrderSkuList(request);
}
/// <summary>
/// 导出订单SKU列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public IList<ExportOrderSkuResponse> ExportOrderSkuList([FromBody] ExportOrderSkuRequest request)
{
return orderBusiness.ExportOrderSkuList(request);
}
}
}

80
BBWY.Server.Business/Order/OrderBusiness.cs

@ -33,6 +33,9 @@ namespace BBWY.Server.Business
private Lazy<FreeSqlMultiDBManager> freeSqlMultiDBManagerLazy;
private FreeSqlMultiDBManager freeSqlMultiDBManager => freeSqlMultiDBManagerLazy.Value;
private Lazy<VenderBusiness> venderBusinessLazy;
private VenderBusiness venderBusiness => venderBusinessLazy.Value;
private IMemoryCache memoryCache;
private static TimeSpan sdGroupExpirationTimeSpan = TimeSpan.FromMinutes(20);
@ -48,6 +51,7 @@ namespace BBWY.Server.Business
this.memoryCache = memoryCache;
freeSqlMultiDBManagerLazy = new Lazy<FreeSqlMultiDBManager>(() => serviceProvider.GetService<FreeSqlMultiDBManager>());
productBusinessLazy = new Lazy<ProductBusiness>(() => serviceProvider.GetService<ProductBusiness>());
venderBusinessLazy = new Lazy<VenderBusiness>(() => serviceProvider.GetService<VenderBusiness>());
}
private ISelect<Order, OrderConsignee, OrderCost, Storehouse> GetOrderListQueryConditions(SearchOrderRequest searchOrderRequest)
@ -1102,5 +1106,81 @@ namespace BBWY.Server.Business
}
return orderResponse;
}
private ISelect<OrderSku, Order, OrderCostDetail, PurchaseOrder, Product> GetQueryOrderSkuListConditions(ExportOrderSkuRequest request)
{
var select = fsql.Select<OrderSku, Order, OrderCostDetail, PurchaseOrder, Product>()
.InnerJoin((osku, o, ocd, po, p) => osku.OrderId == o.Id)
.InnerJoin((osku, o, ocd, po, p) => osku.OrderId == ocd.OrderId && osku.SkuId == ocd.SkuId)
.InnerJoin((osku, o, ocd, po, p) => ocd.PurchaseOrderPKId == po.Id)
.LeftJoin((osku, o, ocd, po, p) => osku.ProductId == p.Id)
.WhereIf(request.ShopIds != null && request.ShopIds.Count() > 0, (osku, o, ocd, po, p) => request.ShopIds.Contains(o.ShopId))
.WhereIf(request.PurchasePlatform != null, (osku, o, ocd, po, p) => po.PurchasePlatform == request.PurchasePlatform)
.Where((osku, o, ocd, po, p) => o.StartTime >= request.StartTime &&
o.StartTime <= request.EndTime &&
o.OrderState != Enums.OrderState.)
.OrderByDescending((osku, o, ocd, po, p) => o.StartTime);
return select;
}
private Expression<Func<OrderSku, Order, OrderCostDetail, PurchaseOrder, Product, ExportOrderSkuResponse>> GetQueryOrderSkuListField()
{
return (osku, o, ocd, po, p) => new ExportOrderSkuResponse()
{
ItemTotal = osku.ItemTotal,
OrderId = osku.OrderId,
PurchaseFreight = ocd.PurchaseFreight,
PurchaseSkuAmount = ocd.SkuAmount,
ShopId = o.ShopId,
Sku = osku.SkuId,
SkuPrice = osku.Price,
Spu = osku.ProductId,
SpuName = p.Title,
StartTime = o.StartTime,
StorageType = o.StorageType
};
}
public ExportOrderSkuListResponse QueryOrderSkuList(QueryOrderSkuRequest request)
{
request.EndTime = request.EndTime.Date.AddDays(1).AddSeconds(-1);
var select = GetQueryOrderSkuListConditions(request);
var list = select.Count(out long count).Page(request.PageIndex, request.PageSize).ToList(GetQueryOrderSkuListField());
if (list.Count() > 0)
{
var shops = venderBusiness.GetShopList();
foreach (var item in list)
{
var shopId = item.ShopId.ToString();
item.ShopName = shops.Where(s => s.ShopId == shopId).FirstOrDefault()?.ShopName;
}
}
return new ExportOrderSkuListResponse()
{
Count = count,
ItemList = list
};
}
public IList<ExportOrderSkuResponse> ExportOrderSkuList(ExportOrderSkuRequest request)
{
request.EndTime = request.EndTime.Date.AddDays(1).AddSeconds(-1);
var select = GetQueryOrderSkuListConditions(request);
var list = select.ToList(GetQueryOrderSkuListField());
if (list.Count() > 0)
{
var shops = venderBusiness.GetShopList();
foreach (var item in list)
{
var shopId = item.ShopId.ToString();
item.ShopName = shops.Where(s => s.ShopId == shopId).FirstOrDefault()?.ShopName;
}
}
return list;
}
}
}

23
BBWY.Server.Model/Dto/Request/Order/QueryOrderSkuRequest.cs

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
namespace BBWY.Server.Model.Dto
{
public class QueryOrderSkuRequest : ExportOrderSkuRequest
{
public int PageIndex { get; set; }
public int PageSize { get; set; }
}
public class ExportOrderSkuRequest
{
public List<long> ShopIds { get; set; }
public Enums.Platform? PurchasePlatform { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
}
}

39
BBWY.Server.Model/Dto/Response/Order/ExportOrderSkuResponse.cs

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
namespace BBWY.Server.Model.Dto
{
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 Enums.StorageType? StorageType { get; set; }
public decimal? PurchaseSkuAmount { get; set; }
public decimal? PurchaseFreight { get; set; }
public decimal? SkuPrice { get; set; }
public int? ItemTotal { get; set; }
public string SpuName { get; set; }
}
public class ExportOrderSkuListResponse
{
public long Count { get; set; }
public IList<ExportOrderSkuResponse> ItemList { get; set; }
}
}
Loading…
Cancel
Save