shanji 3 years ago
parent
commit
a5638a7bdb
  1. 68
      BBWY.Client/ViewModels/BillCoreection/BillCorrectionViewModel.cs
  2. 35
      BBWY.Client/Views/BillCorrection/YTBasicAmount.xaml
  3. 40
      BBWY.Client/Views/BillCorrection/YTBasicAmount.xaml.cs

68
BBWY.Client/ViewModels/BillCoreection/BillCorrectionViewModel.cs

@ -1,4 +1,5 @@
using BBWY.Client.Models; using BBWY.Client.Models;
using BBWY.Client.Views.BillCorrection;
using BBWY.Common.Models; using BBWY.Common.Models;
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
using Microsoft.Win32; using Microsoft.Win32;
@ -17,6 +18,9 @@ namespace BBWY.Client.ViewModels
{ {
public class BillCorrectionViewModel : BaseVM, IDenpendency public class BillCorrectionViewModel : BaseVM, IDenpendency
{ {
private bool isShowShopKeyword;
private string searchShopKeyWord;
public GlobalContext GlobalContext { get; set; } public GlobalContext GlobalContext { get; set; }
public DateTime StartDate { get; set; } public DateTime StartDate { get; set; }
@ -38,13 +42,25 @@ namespace BBWY.Client.ViewModels
/// </summary> /// </summary>
public ICommand ImportSaleFreightBillCommand { get; set; } public ICommand ImportSaleFreightBillCommand { get; set; }
public BillCorrectionViewModel() /// <summary>
/// 是否显示店铺搜索关键词
/// </summary>
public bool IsShowShopKeyword { get => isShowShopKeyword; set { Set(ref isShowShopKeyword, value); } }
public IList<ShopResponse> ShopList { get; set; }
/// <summary>
/// 店铺搜索关键词
/// </summary>
public string SearchShopKeyWord { get => searchShopKeyWord; set { Set(ref searchShopKeyWord, value); } }
public BillCorrectionViewModel(GlobalContext globalContext)
{ {
this.GlobalContext = globalContext;
SaleFreightBillFileList = new ObservableCollection<string>(); SaleFreightBillFileList = new ObservableCollection<string>();
SaleFreightBillList = new List<BillModel>(); SaleFreightBillList = new List<BillModel>();
StartDate = DateTime.Now.Date.AddDays((DateTime.Now.Day - 1) * -1).AddMonths(-1); StartDate = DateTime.Now.Date.AddDays((DateTime.Now.Day - 1) * -1).AddMonths(-1);
EndDate = StartDate.AddMonths(1).AddDays(-1); EndDate = StartDate.AddMonths(1).AddDays(-1);
ImportSaleFreightBillCommand = new RelayCommand<string>(ImportSaleFreightBill); ImportSaleFreightBillCommand = new RelayCommand<string>(ImportSaleFreightBill);
} }
@ -75,7 +91,11 @@ namespace BBWY.Client.ViewModels
IList<BillModel> billModelList = null; IList<BillModel> billModelList = null;
if (expressName == "YT") if (expressName == "YT")
{ {
billModelList = LoadYTSaleBillFile(xbook, fileName, 0); var basicAmountW = new YTBasicAmount();
if (basicAmountW.ShowDialog() != true)
return;
var basicAmount = basicAmountW.BasicAmount;
billModelList = LoadYTSaleBillFile(xbook, fileName, basicAmount);
} }
else if (expressName == "YZ") else if (expressName == "YZ")
{ {
@ -178,10 +198,48 @@ namespace BBWY.Client.ViewModels
return list; return list;
} }
/// <summary>
/// 读取JD运费账单
/// </summary>
/// <param name="xbook"></param>
/// <param name="belongFileName"></param>
/// <returns></returns>
private IList<BillModel> LoadJDSaleBillFile(IWorkbook xbook, string belongFileName) private IList<BillModel> LoadJDSaleBillFile(IWorkbook xbook, string belongFileName)
{ {
var sheet = xbook.GetSheetAt(1);
return null; if (sheet == null)
throw new Exception("验证JD快递账单失败-未读取到sheet1");
var waybillNoCellTitle = sheet.GetRow(0).GetCell(2);
if (waybillNoCellTitle == null || waybillNoCellTitle.StringCellValue != "运单号")
throw new Exception("验证JD快递账单失败-未读取到运单号");
var saleExpressFreightCellTitle = sheet.GetRow(0).GetCell(35);
if (saleExpressFreightCellTitle == null || saleExpressFreightCellTitle.StringCellValue != "结算金额")
throw new Exception("验证JD快递账单失败-未读取到结算金额");
var rowCount = sheet.LastRowNum;
IList<BillModel> list = new List<BillModel>();
for (var i = 1; i < rowCount; i++)
{
var row = sheet.GetRow(i);
if (row == null)
break;
var waybillNoCell = row.GetCell(2);
if (string.IsNullOrEmpty(waybillNoCell.StringCellValue))
break;
var saleExpressFreightCell = row.GetCell(35);
var b = list.FirstOrDefault(b => b.BillNo == waybillNoCell.StringCellValue);
if (b == null)
{
b = new BillModel()
{
BelongFileName = belongFileName,
BillNo = waybillNoCell.StringCellValue,
BillType = BillCorrectionType.
};
list.Add(b);
}
b.Amount += Convert.ToDecimal(saleExpressFreightCell.NumericCellValue);
}
return list;
} }
} }
} }

35
BBWY.Client/Views/BillCorrection/YTBasicAmount.xaml

@ -0,0 +1,35 @@
<c:BWindow x:Class="BBWY.Client.Views.BillCorrection.YTBasicAmount"
xmlns:c="clr-namespace:BBWY.Controls;assembly=BBWY.Controls"
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:BBWY.Client.Views.BillCorrection"
mc:Ignorable="d"
Style="{StaticResource bwstyle}"
MinButtonVisibility="Collapsed"
MaxButtonVisibility="Collapsed"
Title="导入圆通账单" Height="150" Width="300">
<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="导入圆通账单" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="每单已支付面单金额" HorizontalAlignment="Right" VerticalAlignment="Center"/>
<c:BTextBox x:Name="txtBasicAmount" Grid.Column="1" Margin="5,0,8,0"/>
</Grid>
<c:BButton x:Name="btn_Save" Content="保存" Grid.Row="2" Width="60" HorizontalAlignment="Right" Margin="0,0,8,0"
Click="btn_Save_Click"/>
</Grid>
</c:BWindow>

40
BBWY.Client/Views/BillCorrection/YTBasicAmount.xaml.cs

@ -0,0 +1,40 @@
using BBWY.Controls;
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.Shapes;
namespace BBWY.Client.Views.BillCorrection
{
/// <summary>
/// YTBasicAmount.xaml 的交互逻辑
/// </summary>
public partial class YTBasicAmount : BWindow
{
public decimal BasicAmount { get; private set; }
public YTBasicAmount()
{
InitializeComponent();
}
private void btn_Save_Click(object sender, RoutedEventArgs e)
{
if (!decimal.TryParse(txtBasicAmount.Text, out decimal amount))
{
MessageBox.Show("输入金额格式错误", "提示");
return;
}
BasicAmount = amount;
this.DialogResult = true;
this.Close();
}
}
}
Loading…
Cancel
Save