shanji 3 years ago
parent
commit
b0370d2ca1
  1. 79
      BBWY.Client/ViewModels/BillCoreection/BillCorrectionViewModel.cs

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

@ -75,23 +75,21 @@ namespace BBWY.Client.ViewModels
IList<BillModel> billModelList = null;
if (expressName == "YT")
{
billModelList = LoadYTSaleBillFile(xbook);
billModelList = LoadYTSaleBillFile(xbook, fileName, 0);
}
else if (expressName == "YZ")
{
billModelList = LoadYZSaleBillFile(xbook);
billModelList = LoadYZSaleBillFile(xbook, fileName);
}
else if (expressName == "JD")
{
billModelList = LoadJDSaleBillFile(xbook);
billModelList = LoadJDSaleBillFile(xbook, fileName);
}
if (billModelList != null && billModelList.Count() > 0)
{
SaleFreightBillList.AddRange(billModelList);
SaleFreightBillFileList.Add(fileName);
}
}
}
catch (Exception ex)
@ -101,37 +99,88 @@ namespace BBWY.Client.ViewModels
}
}
private IList<BillModel> LoadYTSaleBillFile(IWorkbook xbook)
/// <summary>
/// 读取圆通运费账单
/// </summary>
/// <param name="xbook"></param>
/// <param name="belongFileName"></param>
/// <param name="basicSaleFreight">基础面单价格</param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
private IList<BillModel> LoadYTSaleBillFile(IWorkbook xbook, string belongFileName, decimal basicSaleFreight)
{
return null;
var sheet = xbook.GetSheetAt(0);
var waybillNoCellTitle = sheet.GetRow(0).GetCell(1);
if (waybillNoCellTitle == null || waybillNoCellTitle.StringCellValue != "运单号码")
throw new Exception("验证圆通快递账单失败-未读取到运单号码");
var saleExpressFreightCellTitle = sheet.GetRow(0).GetCell(5);
if (saleExpressFreightCellTitle == null || saleExpressFreightCellTitle.StringCellValue != "补差")
throw new Exception("验证圆通快递账单失败-未读取到补差");
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(1);
if (string.IsNullOrEmpty(waybillNoCell.StringCellValue))
break;
var saleExpressFreightCell = row.GetCell(5);
list.Add(new BillModel()
{
Amount = Convert.ToDecimal(saleExpressFreightCell.NumericCellValue) + basicSaleFreight,
BillNo = waybillNoCell.StringCellValue,
BillType = BillCorrectionType.,
BelongFileName = belongFileName
});
}
return list;
}
/// <summary>
/// 读取邮政运费账单
/// <para>验证邮件号和总邮资</para>
/// </summary>
/// <param name="xbook"></param>
/// <param name="belongFileName"></param>
/// <returns></returns>
private IList<BillModel> LoadYZSaleBillFile(IWorkbook xbook)
/// <exception cref="Exception"></exception>
private IList<BillModel> LoadYZSaleBillFile(IWorkbook xbook, string belongFileName)
{
var sheet = xbook.GetSheetAt(0);
var waybillNoCellTitle = sheet.GetRow(0).GetCell(2);
if (waybillNoCellTitle == null || waybillNoCellTitle.StringCellValue != "邮件号")
throw new Exception("验证邮政快递账单失败-未读取到邮件号");
var saleExpressFreight = sheet.GetRow(0).GetCell(8);
if (saleExpressFreight == null || saleExpressFreight.StringCellValue != "总邮资")
var saleExpressFreightCellTitle = sheet.GetRow(0).GetCell(8);
if (saleExpressFreightCellTitle == null || saleExpressFreightCellTitle.StringCellValue != "总邮资")
throw new Exception("验证邮政快递账单失败-未读取到总邮资");
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(8);
list.Add(new BillModel()
{
Amount = Convert.ToDecimal(saleExpressFreightCell.NumericCellValue),
BillNo = waybillNoCell.StringCellValue,
BillType = BillCorrectionType.,
BelongFileName = belongFileName
});
}
return null;
return list;
}
private IList<BillModel> LoadJDSaleBillFile(IWorkbook xbook)
private IList<BillModel> LoadJDSaleBillFile(IWorkbook xbook, string belongFileName)
{
return null;
}
}

Loading…
Cancel
Save