shanji 3 years ago
parent
commit
2cb35ba95d
  1. 26
      BBWY.Client/APIServices/BillCorrectionService.cs
  2. 74
      BBWY.Client/Models/APIModel/Response/BillCorrection/BillCorrectionOrderResponse.cs
  3. 88
      BBWY.Client/Models/BillCorrection/BillCorrectionOrder.cs
  4. 1
      BBWY.Client/Models/MappingProfile.cs
  5. 118
      BBWY.Client/ViewModels/BillCorrection/BillCorrectionViewModel.cs
  6. 6
      BBWY.Client/ViewModels/MainViewModel.cs
  7. 23
      BBWY.Client/Views/BillCorrection/BillCorrectionView.xaml
  8. 28
      BBWY.Server.API/Controllers/BillCorrectionController.cs
  9. 77
      BBWY.Server.Business/BillCorrection/BillCorrectionBusiness.cs
  10. 15
      BBWY.Server.Model/Dto/Request/BillCorrection/QueryBillCorrectionOrderRequest.cs
  11. 74
      BBWY.Server.Model/Dto/Response/BillCorrection/BillCorrectionOrderResponse.cs

26
BBWY.Client/APIServices/BillCorrectionService.cs

@ -0,0 +1,26 @@
using BBWY.Client.Models;
using BBWY.Common.Http;
using BBWY.Common.Models;
using System;
using System.Collections.Generic;
using System.Net.Http;
namespace BBWY.Client.APIServices
{
public class BillCorrectionService : BaseApiService, IDenpendency
{
public BillCorrectionService(RestApiService restApiService, GlobalContext globalContext) : base(restApiService, globalContext)
{
}
public ApiResponse<IList<BillCorrectionOrderResponse>> GetBillCorrectionOrderList(IList<long> shopIds, DateTime startTime, DateTime endTime)
{
return SendRequest<IList<BillCorrectionOrderResponse>>(globalContext.BBYWApiHost, "api/billCorrection/GetBillCorrectionOrderList", new
{
shopIds,
startTime,
endTime
}, null, HttpMethod.Post);
}
}
}

74
BBWY.Client/Models/APIModel/Response/BillCorrection/BillCorrectionOrderResponse.cs

@ -0,0 +1,74 @@
using System;
namespace BBWY.Client.Models
{
public class BillCorrectionOrderResponse
{
/// <summary>
/// 订单号
/// </summary>
public string OrderId { get; set; }
/// <summary>
/// 订单状态
/// </summary>
public OrderState? OrderState { get; set; }
/// <summary>
/// 订单开始日期
/// </summary>
public DateTime? StartTime { get; set; }
/// <summary>
/// 发货类型
/// </summary>
public StorageType? StorageType { get; set; }
/// <summary>
/// 销售运费
/// </summary>
public decimal DeliveryExpressFreight { get; set; } = 0.00M;
/// <summary>
/// Sku成本(商品成本)
/// </summary>
public decimal SkuAmount { get; set; } = 0.00M;
/// <summary>
/// 采购运费
/// </summary>
public decimal PurchaseFreight { get; set; } = 0.00M;
/// <summary>
/// 头程运费
/// </summary>
public decimal FirstFreight { get; set; } = 0.00M;
/// <summary>
/// 入仓操作费
/// </summary>
public decimal InStorageAmount { get; set; } = 0.00M;
/// <summary>
/// 出仓操作费
/// </summary>
public decimal OutStorageAmount { get; set; } = 0.00M;
/// <summary>
/// 耗材费
/// </summary>
public decimal ConsumableAmount { get; set; } = 0.00M;
/// <summary>
/// 仓储费
/// </summary>
public decimal StorageAmount { get; set; } = 0.00M;
/// <summary>
/// 售后费用
/// </summary>
public decimal AfterTotalCost { get; set; }
public string WaybillNo { get; set; }
}
}

88
BBWY.Client/Models/BillCorrection/BillCorrectionOrder.cs

@ -0,0 +1,88 @@
using System;
namespace BBWY.Client.Models
{
public class BillCorrectionOrder : NotifyObject
{
private string changedContent;
private decimal newDeliveryExpressFreight;
/// <summary>
/// 订单号
/// </summary>
public string OrderId { get; set; }
/// <summary>
/// 订单状态
/// </summary>
public OrderState? OrderState { get; set; }
/// <summary>
/// 订单开始日期
/// </summary>
public DateTime? StartTime { get; set; }
/// <summary>
/// 发货类型
/// </summary>
public StorageType? StorageType { get; set; }
/// <summary>
/// 销售运费
/// </summary>
public decimal DeliveryExpressFreight { get; set; } = 0.00M;
/// <summary>
/// Sku成本(商品成本)
/// </summary>
public decimal SkuAmount { get; set; } = 0.00M;
/// <summary>
/// 采购运费
/// </summary>
public decimal PurchaseFreight { get; set; } = 0.00M;
/// <summary>
/// 头程运费
/// </summary>
public decimal FirstFreight { get; set; } = 0.00M;
/// <summary>
/// 入仓操作费
/// </summary>
public decimal InStorageAmount { get; set; } = 0.00M;
/// <summary>
/// 出仓操作费
/// </summary>
public decimal OutStorageAmount { get; set; } = 0.00M;
/// <summary>
/// 耗材费
/// </summary>
public decimal ConsumableAmount { get; set; } = 0.00M;
/// <summary>
/// 仓储费
/// </summary>
public decimal StorageAmount { get; set; } = 0.00M;
/// <summary>
/// 售后费用
/// </summary>
public decimal AfterTotalCost { get; set; }
/// <summary>
/// 矫正内容
/// </summary>
public string ChangedContent { get => changedContent; set { Set(ref changedContent, value); } }
/// <summary>
/// 新销售运费
/// </summary>
public decimal NewDeliveryExpressFreight { get => newDeliveryExpressFreight; set { Set(ref newDeliveryExpressFreight, value); } }
public string WaybillNo { get; set; }
}
}

1
BBWY.Client/Models/MappingProfile.cs

@ -29,6 +29,7 @@ namespace BBWY.Client.Models
CreateMap<PurchaseOrderResponse, PurchaseOrder>();
CreateMap<ToDayOrderAchievementResponse, ToDayOrderAchievement>();
CreateMap<SDGroupPersonStatisticsResponse, SDGroupPersonStatistics>();
CreateMap<BillCorrectionOrderResponse, BillCorrectionOrder>();
}
}
}

118
BBWY.Client/ViewModels/BillCoreection/BillCorrectionViewModel.cs → BBWY.Client/ViewModels/BillCorrection/BillCorrectionViewModel.cs

@ -1,8 +1,11 @@
using BBWY.Client.Models;
using BBWY.Client.APIServices;
using BBWY.Client.Models;
using BBWY.Client.Views.BillCorrection;
using BBWY.Common.Models;
using BBWY.Common.Trigger;
using GalaSoft.MvvmLight.Command;
using Microsoft.Win32;
using Newtonsoft.Json;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
@ -11,17 +14,21 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using BBWY.Common.Extensions;
namespace BBWY.Client.ViewModels
{
public class BillCorrectionViewModel : BaseVM, IDenpendency
{
private bool isShowShopKeyword;
private BillCorrectionService billCorrectionService;
private string searchShopKeyWord;
private DelayTrigger delayTrigger;
private bool isLoading;
public GlobalContext GlobalContext { get; set; }
private GlobalContext globalContext;
public DateTime StartDate { get; set; }
@ -37,31 +44,72 @@ namespace BBWY.Client.ViewModels
/// </summary>
public List<BillModel> SaleFreightBillList { get; set; }
public IList<Shop> ShopList { get; set; }
/// <summary>
/// 导入快递账单
/// 店铺搜索关键词
/// </summary>
public ICommand ImportSaleFreightBillCommand { get; set; }
public string SearchShopKeyWord
{
get => searchShopKeyWord;
set
{
if (Set(ref searchShopKeyWord, value))
{
delayTrigger.SetKey(value);
}
}
}
/// <summary>
/// 是否显示店铺搜索关键词
/// 导入快递账单
/// </summary>
public bool IsShowShopKeyword { get => isShowShopKeyword; set { Set(ref isShowShopKeyword, value); } }
public IList<ShopResponse> ShopList { get; set; }
public ICommand ImportSaleFreightBillCommand { get; set; }
/// <summary>
/// 店铺搜索关键词
/// 查询订单
/// </summary>
public string SearchShopKeyWord { get => searchShopKeyWord; set { Set(ref searchShopKeyWord, value); } }
public ICommand SearchBillCorrectionOrderCommand { get; set; }
public bool IsLoading { get => isLoading; set { Set(ref isLoading, value); } }
public IList<BillCorrectionOrder> OrderList { get; set; }
public BillCorrectionViewModel(GlobalContext globalContext)
public BillCorrectionViewModel(GlobalContext globalContext, BillCorrectionService billCorrectionService)
{
this.GlobalContext = globalContext;
this.billCorrectionService = billCorrectionService;
this.globalContext = globalContext;
var shopList = JsonConvert.DeserializeObject<List<Shop>>(JsonConvert.SerializeObject(globalContext.User.ShopList));
this.ShopList = new ObservableCollection<Shop>(shopList);
SaleFreightBillFileList = new ObservableCollection<string>();
SaleFreightBillList = new List<BillModel>();
StartDate = DateTime.Now.Date.AddDays((DateTime.Now.Day - 1) * -1).AddMonths(-1);
EndDate = StartDate.AddMonths(1).AddDays(-1);
delayTrigger = new DelayTrigger(500);
delayTrigger.OnExecute = OnSearchShopKeyWordChanged;
OrderList = new ObservableCollection<BillCorrectionOrder>();
ImportSaleFreightBillCommand = new RelayCommand<string>(ImportSaleFreightBill);
SearchBillCorrectionOrderCommand = new RelayCommand(SearchBillCorrectionOrder);
}
private void OnSearchShopKeyWordChanged(string key)
{
foreach (var s in this.ShopList)
s.IsSelected = false;
App.Current.Dispatcher.Invoke(() =>
{
this.ShopList.Clear();
var keyWordShopList = string.IsNullOrEmpty(key) ? globalContext.User.ShopList : globalContext.User.ShopList.Where(s => s.ShopName.Contains(key));
if (keyWordShopList.Count() > 0)
{
foreach (var shop in keyWordShopList)
ShopList.Add(shop);
}
});
}
private void ImportSaleFreightBill(string expressName)
@ -241,5 +289,49 @@ namespace BBWY.Client.ViewModels
}
return list;
}
/// <summary>
/// 查询
/// </summary>
private void SearchBillCorrectionOrder()
{
IsLoading = true;
OrderList.Clear();
var shopIds = ShopList.Where(s => s.IsSelected).Select(s => s.ShopId).ToList();
Task.Factory.StartNew(() => billCorrectionService.GetBillCorrectionOrderList(shopIds, StartDate, EndDate))
.ContinueWith(t =>
{
IsLoading = false;
var response = t.Result;
if (!response.Success)
{
App.Current.Dispatcher.Invoke(() => MessageBox.Show(response.Msg, "提示"));
return;
}
if (response.Data == null || response.Data.Count() == 0)
return;
var list = response.Data.Map<IList<BillCorrectionOrder>>();
App.Current.Dispatcher.BeginInvoke((Action)delegate
{
foreach (var order in list)
{
if (string.IsNullOrEmpty(order.WaybillNo))
continue;
var billModel = SaleFreightBillList.FirstOrDefault(b => b.BillNo == order.WaybillNo);
if (billModel == null)
continue;
if (billModel.Amount != order.DeliveryExpressFreight)
{
order.NewDeliveryExpressFreight = billModel.Amount;
order.ChangedContent = $"销售运费 {order.DeliveryExpressFreight} -> {order.NewDeliveryExpressFreight}";
}
OrderList.Add(order);
}
});
});
}
}
}

6
BBWY.Client/ViewModels/MainViewModel.cs

@ -207,13 +207,13 @@ namespace BBWY.Client.ViewModels
throw new Exception(response.Msg);
departmentList = response.Data.Map<IList<Department>>();
if (GlobalContext.User.TeamName == "刷单组")
{
//if (GlobalContext.User.TeamName == "刷单组")
//{
var shopList = new List<Shop>();
foreach (var d in departmentList)
shopList.AddRange(d.ShopList);
GlobalContext.User.ShopList = shopList;
}
//}
}
else
{

23
BBWY.Client/Views/BillCorrection/BillCorrectionView.xaml

@ -7,6 +7,7 @@
xmlns:c="clr-namespace:BBWY.Controls;assembly=BBWY.Controls"
xmlns:cmodel="clr-namespace:BBWY.Client.Models" xmlns:sys="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
xmlns:hc="https://handyorg.github.io/handycontrol"
DataContext="{Binding BillCorrection,Source={StaticResource Locator}}"
d:DesignHeight="1080" d:DesignWidth="1920"
Title="BillCorrectionView">
@ -39,9 +40,29 @@
</ResourceDictionary>
</Border.Resources>
<StackPanel Orientation="Horizontal">
<c:BTextBox WaterRemark="店铺关键字" Width="150"
Text="{Binding SearchShopKeyWord,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
<hc:CheckComboBox IsTextSearchEnabled="True" ItemsSource="{Binding ShopList}"
ShowClearButton="True"
MinWidth="150"
Height="25"
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>
<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" Padding="10,0" Command="{Binding SearchHistoryCommand}"/>
<c:BButton Content="查询" Margin="5,0,0,0" Padding="10,0" Command="{Binding SearchBillCorrectionOrderCommand}"/>
<c:BButton Content="矫正" Padding="10,0" Command="{Binding CorrectCommand}" Background="#02A7F0"/>
<c:BButton Content="清空" Padding="10,0" Command="{Binding ClearCommand}" Background="{StaticResource Text.Pink}"/>
</StackPanel>

28
BBWY.Server.API/Controllers/BillCorrectionController.cs

@ -0,0 +1,28 @@
using BBWY.Server.Business;
using BBWY.Server.Model.Dto;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
namespace BBWY.Server.API.Controllers
{
public class BillCorrectionController : BaseApiController
{
private BillCorrectionBusiness billCorrectionBusiness;
public BillCorrectionController(IHttpContextAccessor httpContextAccessor, BillCorrectionBusiness billCorrectionBusiness) : base(httpContextAccessor)
{
this.billCorrectionBusiness = billCorrectionBusiness;
}
/// <summary>
/// 获取待矫正费用订单
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public IList<BillCorrectionOrderResponse> GetBillCorrectionOrderList([FromBody] QueryBillCorrectionOrderRequest request)
{
return billCorrectionBusiness.GetBillCorrectionOrderList(request);
}
}
}

77
BBWY.Server.Business/BillCorrection/BillCorrectionBusiness.cs

@ -0,0 +1,77 @@
using BBWY.Common.Models;
using BBWY.Server.Model.Db;
using BBWY.Server.Model.Dto;
using System.Collections.Generic;
using Yitter.IdGenerator;
using System.Linq;
namespace BBWY.Server.Business
{
public class BillCorrectionBusiness : BaseBusiness, IDenpendency
{
public BillCorrectionBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator) : base(fsql, nLogManager, idGenerator)
{
}
public IList<BillCorrectionOrderResponse> GetBillCorrectionOrderList(QueryBillCorrectionOrderRequest request)
{
request.EndTime = request.EndTime.Date.AddDays(1).AddSeconds(-1);
var orderList = fsql.Select<Order>()
.Where(o => request.ShopIds.Contains(o.ShopId) && o.StartTime >= request.StartTime && o.StartTime <= request.EndTime)
.OrderBy(o => o.StartTime)
.ToList(o => new BillCorrectionOrderResponse
{
OrderId = o.Id,
StartTime = o.StartTime,
StorageType = o.StorageType,
OrderState = o.OrderState,
WaybillNo = o.WaybillNo
});
var orderIds = orderList.Select(o => o.OrderId).ToList();
var orderCostDetailList = fsql.Select<OrderCostDetail>()
.Where(ocd => orderIds.Contains(ocd.OrderId))
.GroupBy(ocd => ocd.OrderId)
.ToList(g => new
{
OrderId = g.Key,
DeliveryExpressFreight = g.Sum(g.Value.DeliveryExpressFreight),
SkuAmount = g.Sum(g.Value.SkuAmount),
PurchaseFreight = g.Sum(g.Value.PurchaseFreight),
FirstFreight = g.Sum(g.Value.FirstFreight),
InStorageAmount = g.Sum(g.Value.InStorageAmount),
OutStorageAmount = g.Sum(g.Value.OutStorageAmount),
ConsumableAmount = g.Sum(g.Value.ConsumableAmount),
StorageAmount = g.Sum(g.Value.StorageAmount)
});
var afterOrderList = fsql.Select<AfterSaleOrder>()
.Where(aso => orderIds.Contains(aso.OrderId))
.GroupBy(aso => aso.OrderId)
.ToList(g => new
{
OrderId = g.Key,
AfterTotalCost = g.Sum(g.Value.AfterTotalCost)
});
foreach (var order in orderList)
{
var orderCostDetail = orderCostDetailList.FirstOrDefault(ocd => ocd.OrderId == order.OrderId);
var afterOrder = afterOrderList.FirstOrDefault(aso => aso.OrderId == order.OrderId);
order.DeliveryExpressFreight = orderCostDetail?.DeliveryExpressFreight ?? 0M;
order.SkuAmount = orderCostDetail?.SkuAmount ?? 0M;
order.PurchaseFreight = orderCostDetail?.PurchaseFreight ?? 0M;
order.FirstFreight = orderCostDetail?.FirstFreight ?? 0M;
order.InStorageAmount = orderCostDetail?.InStorageAmount ?? 0M;
order.OutStorageAmount = orderCostDetail?.OutStorageAmount ?? 0M;
order.ConsumableAmount = orderCostDetail?.ConsumableAmount ?? 0M;
order.StorageAmount = orderCostDetail?.StorageAmount ?? 0M;
order.AfterTotalCost = afterOrder?.AfterTotalCost ?? 0M;
}
return orderList;
}
}
}

15
BBWY.Server.Model/Dto/Request/BillCorrection/QueryBillCorrectionOrderRequest.cs

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace BBWY.Server.Model.Dto
{
public class QueryBillCorrectionOrderRequest
{
public IList<long> ShopIds { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
}
}

74
BBWY.Server.Model/Dto/Response/BillCorrection/BillCorrectionOrderResponse.cs

@ -0,0 +1,74 @@
using System;
namespace BBWY.Server.Model.Dto
{
public class BillCorrectionOrderResponse
{
/// <summary>
/// 订单号
/// </summary>
public string OrderId { get; set; }
/// <summary>
/// 订单状态
/// </summary>
public Enums.OrderState? OrderState { get; set; }
/// <summary>
/// 订单开始日期
/// </summary>
public DateTime? StartTime { get; set; }
/// <summary>
/// 发货类型
/// </summary>
public Enums.StorageType? StorageType { get; set; }
/// <summary>
/// 销售运费
/// </summary>
public decimal DeliveryExpressFreight { get; set; } = 0.00M;
/// <summary>
/// Sku成本(商品成本)
/// </summary>
public decimal SkuAmount { get; set; } = 0.00M;
/// <summary>
/// 采购运费
/// </summary>
public decimal PurchaseFreight { get; set; } = 0.00M;
/// <summary>
/// 头程运费
/// </summary>
public decimal FirstFreight { get; set; } = 0.00M;
/// <summary>
/// 入仓操作费
/// </summary>
public decimal InStorageAmount { get; set; } = 0.00M;
/// <summary>
/// 出仓操作费
/// </summary>
public decimal OutStorageAmount { get; set; } = 0.00M;
/// <summary>
/// 耗材费
/// </summary>
public decimal ConsumableAmount { get; set; } = 0.00M;
/// <summary>
/// 仓储费
/// </summary>
public decimal StorageAmount { get; set; } = 0.00M;
/// <summary>
/// 售后费用
/// </summary>
public decimal AfterTotalCost { get; set; }
public string WaybillNo { get; set; }
}
}
Loading…
Cancel
Save