From a5638a7bdba7444b06ea080104786ce62332ffed Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Sat, 3 Dec 2022 03:38:22 +0800 Subject: [PATCH] 1 --- .../BillCoreection/BillCorrectionViewModel.cs | 68 +++++++++++++++++-- .../Views/BillCorrection/YTBasicAmount.xaml | 35 ++++++++++ .../BillCorrection/YTBasicAmount.xaml.cs | 40 +++++++++++ 3 files changed, 138 insertions(+), 5 deletions(-) create mode 100644 BBWY.Client/Views/BillCorrection/YTBasicAmount.xaml create mode 100644 BBWY.Client/Views/BillCorrection/YTBasicAmount.xaml.cs diff --git a/BBWY.Client/ViewModels/BillCoreection/BillCorrectionViewModel.cs b/BBWY.Client/ViewModels/BillCoreection/BillCorrectionViewModel.cs index 487a24b5..1e1aefa8 100644 --- a/BBWY.Client/ViewModels/BillCoreection/BillCorrectionViewModel.cs +++ b/BBWY.Client/ViewModels/BillCoreection/BillCorrectionViewModel.cs @@ -1,4 +1,5 @@ using BBWY.Client.Models; +using BBWY.Client.Views.BillCorrection; using BBWY.Common.Models; using GalaSoft.MvvmLight.Command; using Microsoft.Win32; @@ -17,6 +18,9 @@ namespace BBWY.Client.ViewModels { public class BillCorrectionViewModel : BaseVM, IDenpendency { + private bool isShowShopKeyword; + private string searchShopKeyWord; + public GlobalContext GlobalContext { get; set; } public DateTime StartDate { get; set; } @@ -38,13 +42,25 @@ namespace BBWY.Client.ViewModels /// public ICommand ImportSaleFreightBillCommand { get; set; } - public BillCorrectionViewModel() + /// + /// 是否显示店铺搜索关键词 + /// + public bool IsShowShopKeyword { get => isShowShopKeyword; set { Set(ref isShowShopKeyword, value); } } + + public IList ShopList { get; set; } + + /// + /// 店铺搜索关键词 + /// + public string SearchShopKeyWord { get => searchShopKeyWord; set { Set(ref searchShopKeyWord, value); } } + + public BillCorrectionViewModel(GlobalContext globalContext) { + this.GlobalContext = globalContext; SaleFreightBillFileList = new ObservableCollection(); SaleFreightBillList = new List(); StartDate = DateTime.Now.Date.AddDays((DateTime.Now.Day - 1) * -1).AddMonths(-1); EndDate = StartDate.AddMonths(1).AddDays(-1); - ImportSaleFreightBillCommand = new RelayCommand(ImportSaleFreightBill); } @@ -75,7 +91,11 @@ namespace BBWY.Client.ViewModels IList billModelList = null; 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") { @@ -178,10 +198,48 @@ namespace BBWY.Client.ViewModels return list; } + /// + /// 读取JD运费账单 + /// + /// + /// + /// private IList LoadJDSaleBillFile(IWorkbook xbook, string belongFileName) { - - return null; + var sheet = xbook.GetSheetAt(1); + 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 list = new List(); + 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; } } } diff --git a/BBWY.Client/Views/BillCorrection/YTBasicAmount.xaml b/BBWY.Client/Views/BillCorrection/YTBasicAmount.xaml new file mode 100644 index 00000000..7f442e13 --- /dev/null +++ b/BBWY.Client/Views/BillCorrection/YTBasicAmount.xaml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/BBWY.Client/Views/BillCorrection/YTBasicAmount.xaml.cs b/BBWY.Client/Views/BillCorrection/YTBasicAmount.xaml.cs new file mode 100644 index 00000000..4bc3875f --- /dev/null +++ b/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 +{ + /// + /// YTBasicAmount.xaml 的交互逻辑 + /// + 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(); + } + } +}