|
|
@@ -42,6 +42,7 @@ using EyeSoft.Runtime.InteropServices;
|
|
|
using NPOI.HPSF;
|
|
|
using System.Data.OleDb;
|
|
|
using Org.BouncyCastle.Crypto;
|
|
|
+using OfficeOpenXml;
|
|
|
|
|
|
namespace OASystem.API.Controllers
|
|
|
{
|
|
|
@@ -936,7 +937,9 @@ namespace OASystem.API.Controllers
|
|
|
string items = "";
|
|
|
foreach (var fr in _ForeignReceivables)
|
|
|
{
|
|
|
- items += fr.PriceName + " " + fr.Currency + " " + fr.Price.ToString("#0.00") + " * " + fr.Count + " " + fr.Unit + " * " + fr.Rate + ".................. RMB " + fr.ItemSumPrice.ToString("#0.00") + "\n";
|
|
|
+ var currInfo = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == fr.Currency).First();
|
|
|
+
|
|
|
+ items += $"{fr.PriceName} {currInfo?.Name} {fr.Price.ToString("#0.00")} * {fr.Count} {fr.Unit} * {fr.Rate}.................. RMB {fr.ItemSumPrice.ToString("#0.00")}\n";
|
|
|
sumPrice += fr.ItemSumPrice;
|
|
|
}
|
|
|
Bookmark mark = doc.Range.Bookmarks["PayItemContent"];
|
|
|
@@ -3615,6 +3618,99 @@ Group by PriceType ", dto.diId);
|
|
|
|
|
|
#region 信用卡对账
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ ///将指定的Excel的文件转换成DataTable (Excel的第一个sheet)
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="fullFielPath">文件的绝对路径</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private DataTable WorksheetToTable(string fullFielPath, string sheetName = null)
|
|
|
+ {
|
|
|
+ //如果是“EPPlus”,需要指定LicenseContext。
|
|
|
+ //EPPlus.Core 不需要指定。
|
|
|
+ ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
|
|
+
|
|
|
+ FileInfo existingFile = new FileInfo(fullFielPath);
|
|
|
+
|
|
|
+ ExcelPackage package = new ExcelPackage(existingFile);
|
|
|
+ ExcelWorksheet worksheet = null;
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(sheetName))
|
|
|
+ {
|
|
|
+ //不传入 sheetName 默认取第1个sheet。
|
|
|
+ //EPPlus 索引是0
|
|
|
+ //EPPlus.Core 索引是1
|
|
|
+ worksheet = package.Workbook.Worksheets[0];
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ worksheet = package.Workbook.Worksheets[sheetName];
|
|
|
+ }
|
|
|
+
|
|
|
+ if (worksheet == null)
|
|
|
+ throw new Exception("指定的sheetName不存在");
|
|
|
+
|
|
|
+ return WorksheetToTable(worksheet);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 将worksheet转成datatable
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="worksheet">待处理的worksheet</param>
|
|
|
+ /// <returns>返回处理后的datatable</returns>
|
|
|
+ private DataTable WorksheetToTable(ExcelWorksheet worksheet)
|
|
|
+ {
|
|
|
+ //获取worksheet的行数
|
|
|
+ int rows = worksheet.Dimension.End.Row;
|
|
|
+ //获取worksheet的列数
|
|
|
+ int cols = worksheet.Dimension.End.Column;
|
|
|
+
|
|
|
+ DataTable dt = new DataTable(worksheet.Name);
|
|
|
+ DataRow dr = null;
|
|
|
+ for (int i = 1; i <= rows; i++)
|
|
|
+ {
|
|
|
+ if (i > 1)
|
|
|
+ dr = dt.Rows.Add();
|
|
|
+
|
|
|
+ for (int j = 1; j <= cols; j++)
|
|
|
+ {
|
|
|
+ //默认将第一行设置为datatable的标题
|
|
|
+ if (i == 1)
|
|
|
+ dt.Columns.Add(GetString(worksheet.Cells[i, j].Value));
|
|
|
+ //剩下的写入datatable
|
|
|
+ else
|
|
|
+ dr[j - 1] = GetString(worksheet.Cells[i, j].Value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return dt;
|
|
|
+ }
|
|
|
+
|
|
|
+ private string GetString(object obj)
|
|
|
+ {
|
|
|
+
|
|
|
+ if (obj == null)
|
|
|
+ return "";
|
|
|
+
|
|
|
+ return obj.ToString();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private DataTable ExcelFileToDataTable(IFormFile file)
|
|
|
+ {
|
|
|
+ DataTable dtTest = null;
|
|
|
+ using (var stream = new MemoryStream())
|
|
|
+ {
|
|
|
+ file.CopyTo(stream);
|
|
|
+ using (var package = new ExcelPackage(stream))
|
|
|
+ {
|
|
|
+ ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
|
|
+ ExcelWorksheet worksheet = package.Workbook.Worksheets[0];
|
|
|
+
|
|
|
+ dtTest = WorksheetToTable(worksheet);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return dtTest;
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 信用卡对账
|
|
|
/// </summary>
|
|
|
@@ -3627,7 +3723,7 @@ Group by PriceType ", dto.diId);
|
|
|
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
public async Task<IActionResult> PostCreditCardBill(IFormFile file, int cardType, string beginDt, string endDt)
|
|
|
{
|
|
|
- if (file == null || file.Length < 1)
|
|
|
+ if (file == null || file.Length < 1)
|
|
|
{
|
|
|
return Ok(JsonView(false, "请上传文件!"));
|
|
|
}
|
|
|
@@ -3640,25 +3736,19 @@ Group by PriceType ", dto.diId);
|
|
|
if (cardType < 1) return Ok(JsonView(false, "请传入有效的卡类型!"));
|
|
|
|
|
|
|
|
|
- if (string.IsNullOrEmpty(beginDt) || string.IsNullOrEmpty(endDt )) return Ok(JsonView(false, "请输入开始/结束日期!"));
|
|
|
+ if (string.IsNullOrEmpty(beginDt) || string.IsNullOrEmpty(endDt)) return Ok(JsonView(false, "请输入开始/结束日期!"));
|
|
|
|
|
|
var beginValid = DateTime.TryParse(beginDt, out _);
|
|
|
var endValid = DateTime.TryParse(endDt, out _);
|
|
|
if (!beginValid || !endValid) return Ok(JsonView(false, "请输入正确的日期格式"));
|
|
|
|
|
|
-
|
|
|
- //保存文件
|
|
|
- string filePath = $"{AppSettingsHelper.Get("ExcelBasePath")}/CreditCardBill";
|
|
|
- if (!Directory.Exists(filePath))
|
|
|
+ //读取ExcelFile
|
|
|
+ DataTable dt = ExcelFileToDataTable(file);
|
|
|
+ dt.TableName = "TB";
|
|
|
+ if (dt == null)
|
|
|
{
|
|
|
- Directory.CreateDirectory(filePath);
|
|
|
- }
|
|
|
- filePath = $"{filePath}/{file.FileName}";
|
|
|
- using (var stream = new FileStream(filePath, FileMode.Create))
|
|
|
- {
|
|
|
- await stream.CopyToAsync(stream);
|
|
|
+ return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
|
|
|
}
|
|
|
-
|
|
|
//信用卡信息
|
|
|
string sql = string.Format($"Select * From Grp_CreditCardPayment Where Isdel = 0 And CTDId = {cardType} And ConsumptionDate between '{beginDt}' and '{endDt}' ");
|
|
|
var List_ccp = await _sqlSugar.SqlQueryable<Grp_CreditCardPayment>(sql).ToListAsync();
|
|
|
@@ -3671,7 +3761,6 @@ Group by PriceType ", dto.diId);
|
|
|
//资源信息
|
|
|
var delegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
|
|
|
var users = _sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0).ToList();
|
|
|
- string cardTempPath = $"{AppSettingsHelper.Get("ExcelBasePath")}/Template";
|
|
|
string url = string.Empty;
|
|
|
try
|
|
|
{
|
|
|
@@ -3688,7 +3777,6 @@ Group by PriceType ", dto.diId);
|
|
|
var ids = new List<int>();
|
|
|
if (cardType == 74) //美元卡
|
|
|
{
|
|
|
- cardTempPath = $"{cardTempPath}/信用卡对账模板-美元卡.xls";
|
|
|
var AirGroupReuslt = List_ccp.Where(x => x.CTable == 85).GroupBy(x => x.DIId).ToList();
|
|
|
if (AirGroupReuslt != null && AirGroupReuslt.Count > 0)
|
|
|
{
|
|
|
@@ -3704,193 +3792,192 @@ Group by PriceType ", dto.diId);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (Directory.Exists(filePath))
|
|
|
+ //dt.AcceptChanges(); //提交
|
|
|
+
|
|
|
+ //修改table列名
|
|
|
+ dt.Columns[0].ColumnName = "accountType"; // 账户类型
|
|
|
+ dt.Columns[1].ColumnName = "tradeDate"; //交易日期
|
|
|
+ dt.Columns[2].ColumnName = "BillingDate"; // 记账日期
|
|
|
+ dt.Columns[3].ColumnName = "CardNo"; // 卡号
|
|
|
+ dt.Columns[4].ColumnName = "deposit"; // 存入金额
|
|
|
+ dt.Columns[5].ColumnName = "SpendingAmount"; // 支出金额
|
|
|
+ dt.Columns[6].ColumnName = "TransactionDescription"; // 交易描述
|
|
|
+ dt.Columns[7].ColumnName = "TeamRemark"; // 团组备注描述
|
|
|
+ dt.Columns[8].ColumnName = "Handlers"; // 经手人
|
|
|
+ dt.Columns[9].ColumnName = "State"; // 状态
|
|
|
+
|
|
|
+ //删除第一行数据
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
{
|
|
|
- Workbook wb = new Workbook(filePath);
|
|
|
- WorksheetCollection collection = wb.Worksheets;
|
|
|
- DataTable dt = new DataTable();
|
|
|
- if (collection.Count == 1) dt = ExcelToDataTable(filePath, collection[0].Name);
|
|
|
- else return Ok(JsonView(false, "请检查工作簿页数,请保留一页工作簿页数!!!"));
|
|
|
-
|
|
|
- if (dt == null) return Ok(JsonView(false, "您上传的Excel工作表没有内容,请检查!!!"));
|
|
|
-
|
|
|
- dt.AcceptChanges(); //提交
|
|
|
-
|
|
|
- dt.Columns.Add("TeamRemark", Type.GetType("System.String")); //团组备注描述
|
|
|
- dt.Columns.Add("Handlers", Type.GetType("System.String")); //经手人
|
|
|
- dt.Columns.Add("State", Type.GetType("System.String")); //状态
|
|
|
-
|
|
|
- //修改table列名
|
|
|
- dt.Columns[0].ColumnName = "accountType"; // 账户类型
|
|
|
- dt.Columns[1].ColumnName = "tradeDate"; //交易日期
|
|
|
- dt.Columns[2].ColumnName = "BillingDate"; // 记账日期
|
|
|
- dt.Columns[3].ColumnName = "CardNo"; // 卡号
|
|
|
- dt.Columns[4].ColumnName = "deposit"; // 存入金额
|
|
|
- dt.Columns[5].ColumnName = "SpendingAmount"; // 支出金额
|
|
|
- dt.Columns[6].ColumnName = "TransactionDescription"; // 交易描述
|
|
|
-
|
|
|
- foreach (DataRow item in dt.Rows)
|
|
|
+ string accountType = dt.Rows[0]["accountType"].ToString();
|
|
|
+ if (dt.Rows[0]["accountType"].ToString().Equals("账户类型"))
|
|
|
{
|
|
|
- #region 匹配的金额
|
|
|
- decimal ExcelAmount = 0.00M;
|
|
|
- decimal deposit = 0.00M;
|
|
|
- if (!string.IsNullOrEmpty(item["SpendingAmount"].ToString()))
|
|
|
+ dt.Rows[0].Delete();
|
|
|
+ dt.AcceptChanges(); //提交
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ foreach (DataRow item in dt.Rows)
|
|
|
+ {
|
|
|
+ #region 匹配的金额
|
|
|
+ decimal ExcelAmount = 0.00M;
|
|
|
+ decimal deposit = 0.00M;
|
|
|
+ if (!string.IsNullOrEmpty(item["SpendingAmount"].ToString()))
|
|
|
+ {
|
|
|
+ var isParase = decimal.TryParse(item["SpendingAmount"].ToString(), out ExcelAmount);
|
|
|
+ if (isParase)
|
|
|
{
|
|
|
- var isParase = decimal.TryParse(item["SpendingAmount"].ToString(), out ExcelAmount);
|
|
|
- if (isParase)
|
|
|
+ var CList = List_ccp.FindAll(x => x.PayMoney == ExcelAmount);
|
|
|
+ if (CList != null && CList.Count > 0)
|
|
|
{
|
|
|
- var CList = List_ccp.FindAll(x => x.PayMoney == ExcelAmount);
|
|
|
- if (CList != null && CList.Count > 0)
|
|
|
- {
|
|
|
- item["TeamRemark"] = delegationInfos.Find(it => it.Id == CList.First().DIId)?.TeamName;
|
|
|
- item["Handlers"] = users.Find(it => it.Id == CList.First().CreateUserId)?.CnName;
|
|
|
- item["State"] = 1;
|
|
|
- }
|
|
|
+ item["TeamRemark"] = delegationInfos.Find(it => it.Id == CList.First().DIId)?.TeamName;
|
|
|
+ item["Handlers"] = users.Find(it => it.Id == CList.First().CreateUserId)?.CnName;
|
|
|
+ item["State"] = 1;
|
|
|
}
|
|
|
}
|
|
|
- if (!string.IsNullOrEmpty(item["deposit"].ToString()))
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrEmpty(item["deposit"].ToString()))
|
|
|
+ {
|
|
|
+ var isParse = decimal.TryParse(item["deposit"].ToString(), out deposit);
|
|
|
+ if (isParse)
|
|
|
{
|
|
|
- var isParse = decimal.TryParse(item["deposit"].ToString(), out deposit);
|
|
|
- if (isParse)
|
|
|
+ var CList = List_ccp.FindAll(x => x.PayMoney == deposit);
|
|
|
+ if (CList != null && CList.Count > 0)
|
|
|
{
|
|
|
- var CList = List_ccp.FindAll(x => x.PayMoney == deposit);
|
|
|
- if (CList != null && CList.Count > 0)
|
|
|
- {
|
|
|
- item["TeamRemark"] = delegationInfos.Find(it => it.Id == CList.First().DIId)?.TeamName;
|
|
|
- item["Handlers"] = users.Find(it => it.Id == CList.First().CreateUserId)?.CnName;
|
|
|
- item["State"] = 1;
|
|
|
- }
|
|
|
+ item["TeamRemark"] = delegationInfos.Find(it => it.Id == CList.First().DIId)?.TeamName;
|
|
|
+ item["Handlers"] = users.Find(it => it.Id == CList.First().CreateUserId)?.CnName;
|
|
|
+ item["State"] = 1;
|
|
|
}
|
|
|
}
|
|
|
- #endregion
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
|
|
|
- //交易描述
|
|
|
- if (!string.IsNullOrEmpty(item["TransactionDescription"].ToString()))
|
|
|
+ //交易描述
|
|
|
+ if (!string.IsNullOrEmpty(item["TransactionDescription"].ToString()))
|
|
|
+ {
|
|
|
+ string TransactionDescription = item["TransactionDescription"].ToString();
|
|
|
+ var startIndex = TransactionDescription.LastIndexOf("[");
|
|
|
+ var endIndex = TransactionDescription.LastIndexOf("]");
|
|
|
+ if (startIndex != -1 && endIndex != -1)
|
|
|
{
|
|
|
- string TransactionDescription = item["TransactionDescription"].ToString();
|
|
|
- var startIndex = TransactionDescription.LastIndexOf("[");
|
|
|
- var endIndex = TransactionDescription.LastIndexOf("]");
|
|
|
- if (startIndex != -1 && endIndex != -1)
|
|
|
+ var moenyList = TransactionDescription.Substring(startIndex + 1, endIndex - startIndex - 1).Split(' ').
|
|
|
+ Where(x => !string.IsNullOrEmpty(x)).ToList();
|
|
|
+ decimal money = 0.00M;
|
|
|
+ foreach (var itemMoeny in moenyList)
|
|
|
{
|
|
|
- var moenyList = TransactionDescription.Substring(startIndex + 1, endIndex - startIndex - 1).Split(' ').
|
|
|
- Where(x => !string.IsNullOrEmpty(x)).ToList();
|
|
|
- decimal money = 0.00M;
|
|
|
- foreach (var itemMoeny in moenyList)
|
|
|
+ if (itemMoeny.Contains('.'))
|
|
|
{
|
|
|
- if (itemMoeny.Contains('.'))
|
|
|
+ string itemMoenyStr = itemMoeny.Replace(",", string.Empty);
|
|
|
+ bool istrue = decimal.TryParse(itemMoenyStr, out money);
|
|
|
+ if (istrue)
|
|
|
{
|
|
|
- string itemMoenyStr = itemMoeny.Replace(",", string.Empty);
|
|
|
- bool istrue = decimal.TryParse(itemMoenyStr, out money);
|
|
|
- if (istrue)
|
|
|
+ var CList = List_ccp.FindAll(x => x.PayMoney == money);
|
|
|
+ if (CList != null && CList.Count > 0)
|
|
|
{
|
|
|
- var CList = List_ccp.FindAll(x => x.PayMoney == money);
|
|
|
- if (CList != null && CList.Count > 0)
|
|
|
- {
|
|
|
- item["TeamRemark"] = delegationInfos.Find(it => it.Id == CList.First().DIId)?.TeamName;
|
|
|
- item["Handlers"] = users.Find(it => it.Id == CList.First().CreateUserId)?.CnName;
|
|
|
- item["State"] = 1;
|
|
|
- }
|
|
|
+ item["TeamRemark"] = delegationInfos.Find(it => it.Id == CList.First().DIId)?.TeamName;
|
|
|
+ item["Handlers"] = users.Find(it => it.Id == CList.First().CreateUserId)?.CnName;
|
|
|
+ item["State"] = 1;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- string fileName1 = $"信用卡账单(美元卡){DateTime.Now.ToString("yyyy.MM.dd")}.xls";
|
|
|
- Dictionary<string, object> pairs = new Dictionary<string, object>();
|
|
|
- List<DataTable> datas = new List<DataTable>();
|
|
|
- datas.Add(dt);
|
|
|
- url = AsposeHelper.ExpertExcelToModel("信用卡对账模板-美元卡.xls", "TB", fileName1, pairs, datas);
|
|
|
}
|
|
|
- else return Ok(JsonView(false, "操作失败", "上传的文件不存在!"));
|
|
|
+
|
|
|
+ string fileName1 = $"信用卡账单(美元卡){DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
|
|
|
+ Dictionary<string, object> pairs = new Dictionary<string, object>();
|
|
|
+ List<DataTable> datas = new List<DataTable>();
|
|
|
+ datas.Add(dt);
|
|
|
+ url = AsposeHelper.ExpertExcelToModel("信用卡对账模板-美元卡.xls", $"CreditCardBill", fileName1, pairs, datas);
|
|
|
|
|
|
}
|
|
|
else if (cardType == 75) //欧元卡
|
|
|
{
|
|
|
- cardTempPath = $"{cardTempPath}/信用卡对账模板-欧元卡.xls";
|
|
|
- if (Directory.Exists(filePath))
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
{
|
|
|
- Workbook wb = new Workbook(filePath);
|
|
|
- WorksheetCollection collection = wb.Worksheets;
|
|
|
- DataTable dt = new DataTable();
|
|
|
- if (collection.Count == 1) dt = ExcelToDataTable(filePath, collection[0].Name);
|
|
|
- else return Ok(JsonView(false, "请检查工作簿页数,请保留一页工作簿页数!!!"));
|
|
|
-
|
|
|
- dt.Columns[0].ColumnName = "All";
|
|
|
-
|
|
|
- DataTable dt1 = new DataTable();
|
|
|
- dt1.Columns.Add("TradingDate", Type.GetType("System.String"));//交易日期
|
|
|
- dt1.Columns.Add("TallyDate", Type.GetType("System.String")); //记账日期
|
|
|
- dt1.Columns.Add("TradindDesc", Type.GetType("System.String"));//交易描述
|
|
|
- dt1.Columns.Add("TradindMoney", Type.GetType("System.String"));//交易币种/金额
|
|
|
- dt1.Columns.Add("ClearindMoney", Type.GetType("System.String"));// 清算币种/金额
|
|
|
- dt1.Columns.Add("TeamRemark", Type.GetType("System.String")); //团组备注描述
|
|
|
- dt1.Columns.Add("Handlers", Type.GetType("System.String")); //经手人
|
|
|
- dt1.Columns.Add("State", Type.GetType("System.String")); //状态
|
|
|
-
|
|
|
- for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
+ string accountType = dt.Rows[0][0].ToString();
|
|
|
+ if (accountType.Equals("账户类型"))
|
|
|
{
|
|
|
- string[] str = dt.Rows[i]["All"].ToString().Split(' ');
|
|
|
- DataRow dr = dt1.NewRow();
|
|
|
- dr["TradingDate"] = str[0].ToString();
|
|
|
- dr["TallyDate"] = str[1].ToString();
|
|
|
- dr["TradindDesc"] = str[2].ToString() + " " + str[3].ToString();
|
|
|
- dr["TradindMoney"] = str[4].ToString() + " " + str[5].ToString();
|
|
|
- dr["ClearindMoney"] = str[6].ToString() + " " + str[7].ToString();
|
|
|
- dt1.Rows.Add(dr);
|
|
|
+ dt.Rows[0].Delete();
|
|
|
+ dt.AcceptChanges(); //提交
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ //dt.Columns[0].ColumnName = "All";
|
|
|
+
|
|
|
+ DataTable dt1 = new DataTable();
|
|
|
+ dt1.TableName = "TB";
|
|
|
+ dt1.Columns.Add("TradingDate", Type.GetType("System.String"));//交易日期
|
|
|
+ dt1.Columns.Add("TallyDate", Type.GetType("System.String")); //记账日期
|
|
|
+ dt1.Columns.Add("TradindDesc", Type.GetType("System.String"));//交易描述
|
|
|
+ dt1.Columns.Add("TradindMoney", Type.GetType("System.String"));//交易币种/金额
|
|
|
+ dt1.Columns.Add("ClearindMoney", Type.GetType("System.String"));// 清算币种/金额
|
|
|
+ dt1.Columns.Add("TeamRemark", Type.GetType("System.String")); //团组备注描述
|
|
|
+ dt1.Columns.Add("Handlers", Type.GetType("System.String")); //经手人
|
|
|
+ dt1.Columns.Add("State", Type.GetType("System.String")); //状态
|
|
|
|
|
|
- foreach (DataRow item in dt1.Rows)
|
|
|
+ for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
+ {
|
|
|
+ string[] str = dt.Rows[i]["All"].ToString().Split(' ');
|
|
|
+ //string[] str = dt.Rows[i];
|
|
|
+ DataRow dr = dt1.NewRow();
|
|
|
+ dr["TradingDate"] = str[0].ToString();
|
|
|
+ dr["TallyDate"] = str[1].ToString();
|
|
|
+ dr["TradindDesc"] = str[2].ToString() + " " + str[3].ToString();
|
|
|
+ dr["TradindMoney"] = str[4].ToString() + " " + str[5].ToString();
|
|
|
+ dr["ClearindMoney"] = str[6].ToString() + " " + str[7].ToString();
|
|
|
+ dt1.Rows.Add(dr);
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (DataRow item in dt1.Rows)
|
|
|
+ {
|
|
|
+ for (int i = 0; i < List_ccp.Count; i++)
|
|
|
{
|
|
|
- for (int i = 0; i < List_ccp.Count; i++)
|
|
|
- {
|
|
|
- DateTime dtTime1 = Convert.ToDateTime(item["TradingDate"].ToString() == "" ? DateTime.Now.ToString("MM/dd") : item["TradingDate"].ToString()); //交易日期
|
|
|
- string USDPrice = item["TradindMoney"].ToString(); //支出金额
|
|
|
- USDPrice = USDPrice.Split(' ')[1].Trim(); //替换掉非数字
|
|
|
+ DateTime dtTime1 = Convert.ToDateTime(item["TradingDate"].ToString() == "" ? DateTime.Now.ToString("MM/dd") : item["TradingDate"].ToString()); //交易日期
|
|
|
+ string USDPrice = item["TradindMoney"].ToString(); //支出金额
|
|
|
+ USDPrice = USDPrice.Split(' ')[1].Trim(); //替换掉非数字
|
|
|
|
|
|
- //USDPrice = USDPrice.Split('/')[1];
|
|
|
- // 经手人 and excel行状态
|
|
|
- if (!string.IsNullOrEmpty(List_ccp[i].ConsumptionDate) && !string.IsNullOrEmpty(USDPrice))
|
|
|
+ //USDPrice = USDPrice.Split('/')[1];
|
|
|
+ // 经手人 and excel行状态
|
|
|
+ if (!string.IsNullOrEmpty(List_ccp[i].ConsumptionDate) && !string.IsNullOrEmpty(USDPrice))
|
|
|
+ {
|
|
|
+ DateTime dtTime2 = Convert.ToDateTime(List_ccp[i].ConsumptionDate.ToString() == "" ? DateTime.Now.ToString("MM/dd") : List_ccp[i].ConsumptionDate.ToString());
|
|
|
+ float price1 = float.Parse(USDPrice);
|
|
|
+ float price2 = float.Parse(List_ccp[i].PayMoney.ToString("F2"));
|
|
|
+ if (dtTime1 == dtTime2 && price1 == price2)
|
|
|
{
|
|
|
- DateTime dtTime2 = Convert.ToDateTime(List_ccp[i].ConsumptionDate.ToString() == "" ? DateTime.Now.ToString("MM/dd") : List_ccp[i].ConsumptionDate.ToString());
|
|
|
- float price1 = float.Parse(USDPrice);
|
|
|
- float price2 = float.Parse(List_ccp[i].PayMoney.ToString("F2"));
|
|
|
- if (dtTime1 == dtTime2 && price1 == price2)
|
|
|
- {
|
|
|
- item["TeamRemark"] = delegationInfos.Find(it => it.Id == List_ccp[i].DIId)?.TeamName;
|
|
|
- item["Handlers"] = users.Find(it => it.Id == List_ccp[i].CreateUserId)?.CnName;
|
|
|
- item["State"] = "1";
|
|
|
- i = List_ccp.Count - 1;
|
|
|
- }
|
|
|
- else item["State"] = "0";
|
|
|
+ item["TeamRemark"] = delegationInfos.Find(it => it.Id == List_ccp[i].DIId)?.TeamName;
|
|
|
+ item["Handlers"] = users.Find(it => it.Id == List_ccp[i].CreateUserId)?.CnName;
|
|
|
+ item["State"] = "1";
|
|
|
+ i = List_ccp.Count - 1;
|
|
|
}
|
|
|
else item["State"] = "0";
|
|
|
}
|
|
|
-
|
|
|
- if (item["TradindDesc"].ToString().Contains("财付通"))
|
|
|
- item["State"] = "2";
|
|
|
- else if (item["TradindDesc"].ToString().Contains("京东"))
|
|
|
- item["State"] = "2";
|
|
|
- else if (item["TradindDesc"].ToString().Contains("微信支付"))
|
|
|
- item["State"] = "2";
|
|
|
- else if (item["TradindDesc"].ToString().Contains("淘宝"))
|
|
|
- item["State"] = "2";
|
|
|
+ else item["State"] = "0";
|
|
|
}
|
|
|
|
|
|
- string fileName1 = $"信用卡账单(欧元卡){DateTime.Now.ToString("yyyy.MM.dd")}.xls";
|
|
|
- Dictionary<string, object> pairs = new Dictionary<string, object>();
|
|
|
- List<DataTable> datas = new List<DataTable>();
|
|
|
- datas.Add(dt);
|
|
|
- url = AsposeHelper.ExpertExcelToModel("信用卡对账模板-欧元卡.xls", "TB", fileName1, pairs, datas);
|
|
|
-
|
|
|
+ if (item["TradindDesc"].ToString().Contains("财付通"))
|
|
|
+ item["State"] = "2";
|
|
|
+ else if (item["TradindDesc"].ToString().Contains("京东"))
|
|
|
+ item["State"] = "2";
|
|
|
+ else if (item["TradindDesc"].ToString().Contains("微信支付"))
|
|
|
+ item["State"] = "2";
|
|
|
+ else if (item["TradindDesc"].ToString().Contains("淘宝"))
|
|
|
+ item["State"] = "2";
|
|
|
}
|
|
|
- else return Ok(JsonView(false, "操作失败", "上传的文件不存在!"));
|
|
|
+
|
|
|
+ string fileName1 = $"信用卡账单(欧元卡){DateTime.Now.ToString("yyyy.MM.dd")}.xls";
|
|
|
+ Dictionary<string, object> pairs = new Dictionary<string, object>();
|
|
|
+ List<DataTable> datas = new List<DataTable>();
|
|
|
+ datas.Add(dt);
|
|
|
+ url = AsposeHelper.ExpertExcelToModel("信用卡对账模板-欧元卡.xls", "TB", fileName1, pairs, datas);
|
|
|
+
|
|
|
|
|
|
}
|
|
|
else if (cardType == 86) //招行卡
|
|
|
{
|
|
|
- cardTempPath = $"{cardTempPath}/信用卡对账模板-招行卡.xls";
|
|
|
var AirGroupReuslt1 = List_ccp.Where(x => x.CTable == 85).GroupBy(x => x.DIId).ToList();
|
|
|
if (AirGroupReuslt1 != null && AirGroupReuslt1.Count > 0)
|
|
|
{
|
|
|
@@ -3950,154 +4037,140 @@ Group by PriceType ", dto.diId);
|
|
|
obj.RMBPrice = item.Sum(x => x.RMBPrice);//合计人民币
|
|
|
List_ccp.Add(obj);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
#region
|
|
|
- //上传保存文档
|
|
|
- if (Directory.Exists(filePath))
|
|
|
+ dt.Rows[0].Delete();//删除列名行
|
|
|
+ dt.AcceptChanges();
|
|
|
+
|
|
|
+ DataTable dt1 = new DataTable();
|
|
|
+ dt1.TableName = "TB";
|
|
|
+ dt1.Columns.Add("TradingDay", Type.GetType("System.String")); // 交易日
|
|
|
+ dt1.Columns.Add("TallyDay", Type.GetType("System.String")); // 记账日
|
|
|
+ dt1.Columns.Add("TransactionDesc", Type.GetType("System.String")); // 交易描述
|
|
|
+ dt1.Columns.Add("RMBMoney", Type.GetType("System.String")); // 人名币金额
|
|
|
+ dt1.Columns.Add("CardNo", Type.GetType("System.String")); // 卡号
|
|
|
+ dt1.Columns.Add("TradingMoney", Type.GetType("System.String")); // 交易地金额
|
|
|
+ dt1.Columns.Add("Currency", Type.GetType("System.String")); // 币种
|
|
|
+ dt1.Columns.Add("TeamRemark", Type.GetType("System.String")); //团组备注描述
|
|
|
+ dt1.Columns.Add("Handlers", Type.GetType("System.String")); //经手人
|
|
|
+ dt1.Columns.Add("State", Type.GetType("System.String")); //状态
|
|
|
+
|
|
|
+ for (int j = 0; j < dt.Rows.Count; j++)//遍历行
|
|
|
{
|
|
|
- //得到书签下的所有标签名
|
|
|
- Workbook wk = new Workbook(filePath ); //读取excel
|
|
|
- WorksheetCollection myColection = wk.Worksheets; //获取excel sheet页
|
|
|
-
|
|
|
- DataTable dt = new DataTable(); //实例一张表格
|
|
|
- //修改table列名
|
|
|
- dt.Columns.Add("TradingDay", Type.GetType("System.String")); // 交易日
|
|
|
- dt.Columns.Add("TallyDay", Type.GetType("System.String")); // 记账日
|
|
|
- dt.Columns.Add("TransactionDesc", Type.GetType("System.String")); // 交易描述
|
|
|
- dt.Columns.Add("RMBMoney", Type.GetType("System.String")); // 人名币金额
|
|
|
- dt.Columns.Add("CardNo", Type.GetType("System.String")); // 卡号
|
|
|
- dt.Columns.Add("TradingMoney", Type.GetType("System.String")); // 交易地金额
|
|
|
- dt.Columns.Add("Currency", Type.GetType("System.String")); // 币种
|
|
|
- dt.Columns.Add("TeamRemark", Type.GetType("System.String")); //团组备注描述
|
|
|
- dt.Columns.Add("Handlers", Type.GetType("System.String")); //经手人
|
|
|
- dt.Columns.Add("State", Type.GetType("System.String")); //状态
|
|
|
-
|
|
|
- for (int i = 0; i < myColection.Count; i++) //遍历读取的sheet页
|
|
|
+ DataRow dr = dt1.NewRow(); //获取每一行的数据
|
|
|
+ dr["TradingDay"] = dt.Rows[j][0].ToString();
|
|
|
+ dr["TallyDay"] = dt.Rows[j][1].ToString();
|
|
|
+ dr["TransactionDesc"] = dt.Rows[j][2].ToString();
|
|
|
+ dr["RMBMoney"] = dt.Rows[j][3].ToString();
|
|
|
+ dr["CardNo"] = dt.Rows[j][4].ToString();
|
|
|
+ string currency = "CN";
|
|
|
+ string money = dt.Rows[j][5].ToString();
|
|
|
+ if (money.Contains('('))
|
|
|
{
|
|
|
- DataTable dt1 = ExcelToDataTable(filePath , myColection[i].Name);//sheet页转dataTable
|
|
|
- for (int j = 0; j < dt1.Rows.Count; j++)//遍历行
|
|
|
- {
|
|
|
- DataRow dr = dt.NewRow(); //获取每一行的数据
|
|
|
- dr["TradingDay"] = dt1.Rows[j][0].ToString();
|
|
|
- dr["TallyDay"] = dt1.Rows[j][1].ToString();
|
|
|
- dr["TransactionDesc"] = dt1.Rows[j][2].ToString();
|
|
|
- dr["RMBMoney"] = dt1.Rows[j][3].ToString();
|
|
|
- dr["CardNo"] = dt1.Rows[j][4].ToString();
|
|
|
- string currency = "CN";
|
|
|
- string money = dt1.Rows[j][5].ToString();
|
|
|
- if (money.Contains('('))
|
|
|
- {
|
|
|
- string[] strs = money.Split('(');
|
|
|
- money = strs[0];
|
|
|
- currency = strs[1].Replace(")", "");
|
|
|
- }
|
|
|
- dr["TradingMoney"] = money;
|
|
|
- dr["Currency"] = currency;
|
|
|
- if (string.IsNullOrEmpty(money))
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
- dt.Rows.Add(dr);
|
|
|
- }
|
|
|
+ string[] strs = money.Split('(');
|
|
|
+ money = strs[0];
|
|
|
+ currency = strs[1].Replace(")", "");
|
|
|
}
|
|
|
- //dt.Rows[0].Delete();//删除列名行
|
|
|
- //datatable 排序
|
|
|
- //dt.DefaultView.Sort = "TradingDay asc";
|
|
|
- //dt = dt.DefaultView.ToTable();
|
|
|
-
|
|
|
- foreach (DataRow item in dt.Rows)
|
|
|
+ dr["TradingMoney"] = money;
|
|
|
+ dr["Currency"] = currency;
|
|
|
+ if (string.IsNullOrEmpty(money))
|
|
|
{
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ dt1.Rows.Add(dr);
|
|
|
+ }
|
|
|
|
|
|
- if (item["TradingDay"] == "" && item["RMBMoney"] == "")
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
+ //datatable 排序
|
|
|
+ dt1.DefaultView.Sort = "TradingDay asc";
|
|
|
+ dt1 = dt1.DefaultView.ToTable();
|
|
|
|
|
|
- //excel获取交易日期
|
|
|
- string ExcelDt = string.Empty;
|
|
|
- //C表交易日期
|
|
|
- string DBDt = string.Empty;
|
|
|
- //excel交易的金额
|
|
|
- decimal TradingMoney = decimal.Parse(item["TradingMoney"].ToString());
|
|
|
+ foreach (DataRow item in dt1.Rows)
|
|
|
+ {
|
|
|
+ if (item["TradingDay"] == "" && item["RMBMoney"] == "")
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
- if (item["TradingDay"] != null)
|
|
|
- {
|
|
|
- ExcelDt = DateTime.Parse(item["TradingDay"].ToString()).ToString("MMdd");
|
|
|
- }
|
|
|
+ //excel获取交易日期
|
|
|
+ string ExcelDt = string.Empty;
|
|
|
+ //C表交易日期
|
|
|
+ string DBDt = string.Empty;
|
|
|
+ //excel交易的金额
|
|
|
+ decimal TradingMoney = decimal.Parse(item["TradingMoney"].ToString());
|
|
|
+
|
|
|
+ if (item["TradingDay"] != null)
|
|
|
+ {
|
|
|
+ ExcelDt = DateTime.Parse(item["TradingDay"].ToString()).ToString("MMdd");
|
|
|
+ }
|
|
|
|
|
|
- //加一获取金额区间
|
|
|
- decimal MaxTradingMoney = TradingMoney + 1;
|
|
|
- decimal MinTradingMoney = TradingMoney - 1;
|
|
|
+ //加一获取金额区间
|
|
|
+ decimal MaxTradingMoney = TradingMoney + 1;
|
|
|
+ decimal MinTradingMoney = TradingMoney - 1;
|
|
|
|
|
|
- //匹配C表金额相等的值
|
|
|
- var CList = List_ccp.FindAll(x => x.PayMoney < MaxTradingMoney && x.PayMoney > MinTradingMoney);
|
|
|
+ //匹配C表金额相等的值
|
|
|
+ var CList = List_ccp.FindAll(x => x.PayMoney < MaxTradingMoney && x.PayMoney > MinTradingMoney);
|
|
|
|
|
|
- if (CList != null && CList.Count > 0)
|
|
|
+ if (CList != null && CList.Count > 0)
|
|
|
+ {
|
|
|
+ #region 日期匹配
|
|
|
+ foreach (var Citem in CList)
|
|
|
{
|
|
|
- #region 日期匹配
|
|
|
- foreach (var Citem in CList)
|
|
|
+ if (!string.IsNullOrWhiteSpace(Citem.ConsumptionDate))
|
|
|
{
|
|
|
- if (!string.IsNullOrWhiteSpace(Citem.ConsumptionDate))
|
|
|
- {
|
|
|
- DBDt = DateTime.Parse(Citem.ConsumptionDate).ToString("MMdd");
|
|
|
+ DBDt = DateTime.Parse(Citem.ConsumptionDate).ToString("MMdd");
|
|
|
|
|
|
- if (DBDt == ExcelDt)
|
|
|
- {
|
|
|
- item["TeamRemark"] = delegationInfos.Find(it => it.Id == Citem.DIId)?.TeamName;
|
|
|
- item["Handlers"] = users.Find(it => it.Id == Citem.CreateUserId)?.CnName;
|
|
|
+ if (DBDt == ExcelDt)
|
|
|
+ {
|
|
|
+ item["TeamRemark"] = delegationInfos.Find(it => it.Id == Citem.DIId)?.TeamName;
|
|
|
+ item["Handlers"] = users.Find(it => it.Id == Citem.CreateUserId)?.CnName;
|
|
|
|
|
|
- ids.Add(Citem.Id);
|
|
|
- }
|
|
|
+ ids.Add(Citem.Id);
|
|
|
}
|
|
|
}
|
|
|
- #endregion
|
|
|
}
|
|
|
+ #endregion
|
|
|
+ }
|
|
|
|
|
|
- if (item["TransactionDesc"].ToString().Contains("财付通"))
|
|
|
- item["State"] = "2";
|
|
|
- else if (item["TransactionDesc"].ToString().Contains("京东支付"))
|
|
|
- item["State"] = "2";
|
|
|
- else if (item["TransactionDesc"].ToString().Contains("微信支付"))
|
|
|
- item["State"] = "2";
|
|
|
- else if (item["TransactionDesc"].ToString().Contains("淘宝"))
|
|
|
- item["State"] = "2";
|
|
|
- else if (item["TransactionDesc"].ToString().Contains("支付宝"))
|
|
|
- item["State"] = "2";
|
|
|
- else if (item["TransactionDesc"].ToString().Contains("拼多多"))
|
|
|
- item["State"] = "2";
|
|
|
- else
|
|
|
- item["State"] = "0";
|
|
|
+ if (item["TransactionDesc"].ToString().Contains("财付通"))
|
|
|
+ item["State"] = "2";
|
|
|
+ else if (item["TransactionDesc"].ToString().Contains("京东支付"))
|
|
|
+ item["State"] = "2";
|
|
|
+ else if (item["TransactionDesc"].ToString().Contains("微信支付"))
|
|
|
+ item["State"] = "2";
|
|
|
+ else if (item["TransactionDesc"].ToString().Contains("淘宝"))
|
|
|
+ item["State"] = "2";
|
|
|
+ else if (item["TransactionDesc"].ToString().Contains("支付宝"))
|
|
|
+ item["State"] = "2";
|
|
|
+ else if (item["TransactionDesc"].ToString().Contains("拼多多"))
|
|
|
+ item["State"] = "2";
|
|
|
+ else
|
|
|
+ item["State"] = "0";
|
|
|
|
|
|
- if (!string.IsNullOrEmpty(item["TeamRemark"].ToString()) && !string.IsNullOrEmpty(item["Handlers"].ToString()))
|
|
|
- item["State"] = "1";
|
|
|
- }
|
|
|
+ if (!string.IsNullOrEmpty(item["TeamRemark"].ToString()) && !string.IsNullOrEmpty(item["Handlers"].ToString()))
|
|
|
+ item["State"] = "1";
|
|
|
+ }
|
|
|
|
|
|
- //更改匹配项状态
|
|
|
- if (ids.Count > 0 )
|
|
|
+ //更改匹配项状态
|
|
|
+ if (ids.Count > 0)
|
|
|
+ {
|
|
|
+ var _CreditCardPayments = new List<Grp_CreditCardPayment>();
|
|
|
+ foreach (var item in ids)
|
|
|
{
|
|
|
- var _CreditCardPayments = new List<Grp_CreditCardPayment>();
|
|
|
- foreach (var item in ids)
|
|
|
- {
|
|
|
- _CreditCardPayments.Add(new Grp_CreditCardPayment() {Id = item,IsMatchCreditCard = 1.00M });
|
|
|
- }
|
|
|
- var updateStatus = _sqlSugar.Updateable<Grp_CreditCardPayment>(_CreditCardPayments)
|
|
|
- .UpdateColumns(it => new { it.IsMatchCreditCard })
|
|
|
- .Where(it => ids.Contains(it.Id))
|
|
|
- .ExecuteCommand();
|
|
|
+ _CreditCardPayments.Add(new Grp_CreditCardPayment() { Id = item, IsMatchCreditCard = 1.00M });
|
|
|
}
|
|
|
-
|
|
|
- string fileName1 = $"信用卡账单(招行卡){DateTime.Now.ToString("yyyy.MM.dd")}.xls";
|
|
|
- Dictionary<string, object> pairs = new Dictionary<string, object>();
|
|
|
- List<DataTable> datas = new List<DataTable>();
|
|
|
- datas.Add(dt);
|
|
|
- url = AsposeHelper.ExpertExcelToModel("信用卡对账模板-招行卡.xls", "TB", fileName1, pairs, datas);
|
|
|
-
|
|
|
+ var updateStatus = _sqlSugar.Updateable<Grp_CreditCardPayment>(_CreditCardPayments)
|
|
|
+ .UpdateColumns(it => new { it.IsMatchCreditCard })
|
|
|
+ .Where(it => ids.Contains(it.Id))
|
|
|
+ .ExecuteCommand();
|
|
|
}
|
|
|
- else return Ok(JsonView(false, "操作失败", "上传的文件不存在!"));
|
|
|
+
|
|
|
+ string fileName1 = $"信用卡账单(招行卡){DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
|
|
|
+ Dictionary<string, object> pairs = new Dictionary<string, object>();
|
|
|
+ List<DataTable> datas = new List<DataTable>();
|
|
|
+ datas.Add(dt1);
|
|
|
+ url = AsposeHelper.ExpertExcelToModel("信用卡对账模板-招行卡.xls", "CreditCardBill", fileName1, pairs, datas);
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
@@ -4105,177 +4178,153 @@ Group by PriceType ", dto.diId);
|
|
|
}
|
|
|
else if (cardType == 346) //中信卡
|
|
|
{
|
|
|
- cardTempPath = $"{cardTempPath}/信用卡对账模板-中信卡.xls";
|
|
|
- if (Directory.Exists(filePath))
|
|
|
+ dt.Columns.Add("TeamRemark", Type.GetType("System.String")); //团组备注描述
|
|
|
+ dt.Columns.Add("Handlers", Type.GetType("System.String")); //经手人
|
|
|
+ dt.Columns.Add("State", Type.GetType("System.String")); //状态
|
|
|
+
|
|
|
+ //修改table列名
|
|
|
+ dt.Columns[0].ColumnName = "TransactionDesc"; // 交易描述
|
|
|
+ dt.Columns[1].ColumnName = "TradingCurrencyAndMoney"; // 交易币种和金额
|
|
|
+ dt.Columns[2].ColumnName = "TransactionDate"; // 交易日期
|
|
|
+ dt.Columns[3].ColumnName = "SettlementCurrencyAndMoney";// 结算币种和金额
|
|
|
+ dt.Columns[4].ColumnName = "BookedDate"; // 入账日期
|
|
|
+
|
|
|
+ foreach (DataRow item in dt.Rows)
|
|
|
{
|
|
|
- Workbook wb = new Workbook(filePath);
|
|
|
- WorksheetCollection collection = wb.Worksheets;
|
|
|
- DataTable dt = new DataTable();
|
|
|
- if (collection.Count == 1)
|
|
|
- dt = ExcelToDataTable(filePath, collection[0].Name);
|
|
|
- else return Ok(JsonView(false, "请检查工作簿页数,请保留一页工作簿页数!!!"));
|
|
|
-
|
|
|
- dt.Columns.Add("TeamRemark", Type.GetType("System.String")); //团组备注描述
|
|
|
- dt.Columns.Add("Handlers", Type.GetType("System.String")); //经手人
|
|
|
- dt.Columns.Add("State", Type.GetType("System.String")); //状态
|
|
|
-
|
|
|
- //修改table列名
|
|
|
- dt.Columns[0].ColumnName = "TransactionDesc"; // 交易描述
|
|
|
- dt.Columns[1].ColumnName = "TradingCurrencyAndMoney"; // 交易币种和金额
|
|
|
- dt.Columns[2].ColumnName = "TransactionDate"; // 交易日期
|
|
|
- dt.Columns[3].ColumnName = "SettlementCurrencyAndMoney";// 结算币种和金额
|
|
|
- dt.Columns[4].ColumnName = "BookedDate"; // 入账日期
|
|
|
-
|
|
|
- foreach (DataRow item in dt.Rows)
|
|
|
+ for (int i = 0; i < List_ccp.Count; i++)
|
|
|
{
|
|
|
- for (int i = 0; i < List_ccp.Count; i++)
|
|
|
+ if (string.IsNullOrEmpty(item["TransactionDate"].ToString()))
|
|
|
+ break;
|
|
|
+
|
|
|
+ DateTime dtTime1 = Convert.ToDateTime(item["TransactionDate"].ToString()); //交易日期
|
|
|
+ string USDPrice = item["TradingCurrencyAndMoney"].ToString(); //支出金额
|
|
|
+ USDPrice = USDPrice.Split('/')[1];
|
|
|
+ //string USDPrice1 = USDPrice.ToString("0.00");
|
|
|
+ // 经手人 and excel行状态
|
|
|
+ if (!string.IsNullOrEmpty(List_ccp[i].ConsumptionDate) && !string.IsNullOrEmpty(USDPrice))
|
|
|
{
|
|
|
- if (string.IsNullOrEmpty(item["TransactionDate"].ToString()))
|
|
|
- break;
|
|
|
-
|
|
|
- DateTime dtTime1 = Convert.ToDateTime(item["TransactionDate"].ToString()); //交易日期
|
|
|
- string USDPrice = item["TradingCurrencyAndMoney"].ToString(); //支出金额
|
|
|
- USDPrice = USDPrice.Split('/')[1];
|
|
|
- //string USDPrice1 = USDPrice.ToString("0.00");
|
|
|
- // 经手人 and excel行状态
|
|
|
- if (!string.IsNullOrEmpty(List_ccp[i].ConsumptionDate) && !string.IsNullOrEmpty(USDPrice))
|
|
|
+ DateTime dtTime2 = Convert.ToDateTime(List_ccp[i].ConsumptionDate);
|
|
|
+ float price1 = float.Parse(USDPrice);
|
|
|
+ float price2 = float.Parse(List_ccp[i].PayMoney.ToString("F2"));
|
|
|
+ if (dtTime1 == dtTime2 && price1 == price2)
|
|
|
{
|
|
|
- DateTime dtTime2 = Convert.ToDateTime(List_ccp[i].ConsumptionDate);
|
|
|
- float price1 = float.Parse(USDPrice);
|
|
|
- float price2 = float.Parse(List_ccp[i].PayMoney.ToString("F2"));
|
|
|
- if (dtTime1 == dtTime2 && price1 == price2)
|
|
|
- {
|
|
|
- item["TeamRemark"] = delegationInfos.Find(it => it.Id == List_ccp[i].DIId)?.TeamName;
|
|
|
- item["Handlers"] = users.Find(it => it.Id == List_ccp[i].CreateUserId)?.CnName;
|
|
|
- item["State"] = "1";
|
|
|
- i = List_ccp.Count - 1;
|
|
|
- }
|
|
|
- else
|
|
|
- item["State"] = "0";
|
|
|
+ item["TeamRemark"] = delegationInfos.Find(it => it.Id == List_ccp[i].DIId)?.TeamName;
|
|
|
+ item["Handlers"] = users.Find(it => it.Id == List_ccp[i].CreateUserId)?.CnName;
|
|
|
+ item["State"] = "1";
|
|
|
+ i = List_ccp.Count - 1;
|
|
|
}
|
|
|
else
|
|
|
item["State"] = "0";
|
|
|
-
|
|
|
}
|
|
|
- //判断是否是数字
|
|
|
- //if (IsNumber(item["TradingCurrencyAndMoney"].ToString().Split('/')[1]) == false)
|
|
|
- // item["State"] = "0";
|
|
|
-
|
|
|
- if (item["TransactionDesc"].ToString().Contains("财付通"))
|
|
|
- item["State"] = "2";
|
|
|
- else if (item["TransactionDesc"].ToString().Contains("京东"))
|
|
|
- item["State"] = "2";
|
|
|
- else if (item["TransactionDesc"].ToString().Contains("微信支付"))
|
|
|
- item["State"] = "2";
|
|
|
- else if (item["TransactionDesc"].ToString().Contains("淘宝"))
|
|
|
- item["State"] = "2";
|
|
|
+ else
|
|
|
+ item["State"] = "0";
|
|
|
+
|
|
|
}
|
|
|
+ //判断是否是数字
|
|
|
+ //if (IsNumber(item["TradingCurrencyAndMoney"].ToString().Split('/')[1]) == false)
|
|
|
+ // item["State"] = "0";
|
|
|
+
|
|
|
+ if (item["TransactionDesc"].ToString().Contains("财付通"))
|
|
|
+ item["State"] = "2";
|
|
|
+ else if (item["TransactionDesc"].ToString().Contains("京东"))
|
|
|
+ item["State"] = "2";
|
|
|
+ else if (item["TransactionDesc"].ToString().Contains("微信支付"))
|
|
|
+ item["State"] = "2";
|
|
|
+ else if (item["TransactionDesc"].ToString().Contains("淘宝"))
|
|
|
+ item["State"] = "2";
|
|
|
+ }
|
|
|
|
|
|
- #region DownExcel
|
|
|
+ #region DownExcel
|
|
|
|
|
|
- string fileName1 = $"信用卡账单(中信卡){DateTime.Now.ToString("yyyy.MM.dd")}.xls";
|
|
|
- Dictionary<string, object> pairs = new Dictionary<string, object>();
|
|
|
- List<DataTable> datas = new List<DataTable>();
|
|
|
- datas.Add(dt);
|
|
|
- url = AsposeHelper.ExpertExcelToModel("信用卡对账模板-中信卡.xls", "TB", fileName1, pairs, datas);
|
|
|
-
|
|
|
+ string fileName1 = $"信用卡账单(中信卡){DateTime.Now.ToString("yyyy.MM.dd")}.xls";
|
|
|
+ Dictionary<string, object> pairs = new Dictionary<string, object>();
|
|
|
+ List<DataTable> datas = new List<DataTable>();
|
|
|
+ datas.Add(dt);
|
|
|
+ url = AsposeHelper.ExpertExcelToModel("信用卡对账模板-中信卡.xls", "TB", fileName1, pairs, datas);
|
|
|
|
|
|
- #endregion
|
|
|
|
|
|
- }
|
|
|
- else return Ok(JsonView(false, "操作失败", "上传的文件不存在!"));
|
|
|
+ #endregion
|
|
|
|
|
|
}
|
|
|
else if (cardType == 363) //交行卡
|
|
|
{
|
|
|
-
|
|
|
- if (Directory.Exists(filePath))
|
|
|
+ dt.Columns[0].ColumnName = "All";
|
|
|
+
|
|
|
+ DataTable dt1 = new DataTable();
|
|
|
+ dt1.Columns.Add("TradingDate", Type.GetType("System.String"));//交易日期
|
|
|
+ dt1.Columns.Add("TallyDate", Type.GetType("System.String")); //记账日期
|
|
|
+ dt1.Columns.Add("TradindDesc", Type.GetType("System.String"));//交易描述
|
|
|
+ dt1.Columns.Add("TradindMoney", Type.GetType("System.String"));//交易币种/金额
|
|
|
+ dt1.Columns.Add("ClearindMoney", Type.GetType("System.String"));// 清算币种/金额
|
|
|
+ dt1.Columns.Add("TeamRemark", Type.GetType("System.String")); //团组备注描述
|
|
|
+ dt1.Columns.Add("Handlers", Type.GetType("System.String")); //经手人
|
|
|
+ dt1.Columns.Add("State", Type.GetType("System.String")); //状态
|
|
|
+
|
|
|
+ for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
{
|
|
|
+ string[] str = dt.Rows[i]["All"].ToString().Split(' ');
|
|
|
+ DataRow dr = dt1.NewRow();
|
|
|
+ dr["TradingDate"] = str[0].ToString();
|
|
|
+ dr["TallyDate"] = str[1].ToString();
|
|
|
+ dr["TradindDesc"] = str[2].ToString() + " " + str[3].ToString();
|
|
|
+ dr["TradindMoney"] = str[4].ToString() + " " + str[5].ToString();
|
|
|
+ dr["ClearindMoney"] = str[6].ToString() + " " + str[7].ToString();
|
|
|
+ dt1.Rows.Add(dr);
|
|
|
+ }
|
|
|
|
|
|
- Workbook wb = new Workbook(filePath );
|
|
|
- WorksheetCollection collection = wb.Worksheets;
|
|
|
- DataTable dt = new DataTable();
|
|
|
- if (collection.Count == 1) dt = ExcelToDataTable(filePath, collection[0].Name);
|
|
|
- else return Ok(JsonView(false, "请检查工作簿页数,请保留一页工作簿页数!!!"));
|
|
|
-
|
|
|
- dt.Columns[0].ColumnName = "All";
|
|
|
-
|
|
|
- DataTable dt1 = new DataTable();
|
|
|
- dt1.Columns.Add("TradingDate", Type.GetType("System.String"));//交易日期
|
|
|
- dt1.Columns.Add("TallyDate", Type.GetType("System.String")); //记账日期
|
|
|
- dt1.Columns.Add("TradindDesc", Type.GetType("System.String"));//交易描述
|
|
|
- dt1.Columns.Add("TradindMoney", Type.GetType("System.String"));//交易币种/金额
|
|
|
- dt1.Columns.Add("ClearindMoney", Type.GetType("System.String"));// 清算币种/金额
|
|
|
- dt1.Columns.Add("TeamRemark", Type.GetType("System.String")); //团组备注描述
|
|
|
- dt1.Columns.Add("Handlers", Type.GetType("System.String")); //经手人
|
|
|
- dt1.Columns.Add("State", Type.GetType("System.String")); //状态
|
|
|
-
|
|
|
- for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
+ foreach (DataRow item in dt1.Rows)
|
|
|
+ {
|
|
|
+ for (int i = 0; i < List_ccp.Count; i++)
|
|
|
{
|
|
|
- string[] str = dt.Rows[i]["All"].ToString().Split(' ');
|
|
|
- DataRow dr = dt1.NewRow();
|
|
|
- dr["TradingDate"] = str[0].ToString();
|
|
|
- dr["TallyDate"] = str[1].ToString();
|
|
|
- dr["TradindDesc"] = str[2].ToString() + " " + str[3].ToString();
|
|
|
- dr["TradindMoney"] = str[4].ToString() + " " + str[5].ToString();
|
|
|
- dr["ClearindMoney"] = str[6].ToString() + " " + str[7].ToString();
|
|
|
- dt1.Rows.Add(dr);
|
|
|
- }
|
|
|
+ DateTime dtTime1 = Convert.ToDateTime(item["TradingDate"].ToString() == "" ? DateTime.Now.ToString("MM/dd") : item["TradingDate"].ToString()); //交易日期
|
|
|
+ string USDPrice = item["TradindMoney"].ToString(); //支出金额
|
|
|
+ USDPrice = USDPrice.Split(' ')[1].Trim(); //替换掉非数字
|
|
|
|
|
|
- foreach (DataRow item in dt1.Rows)
|
|
|
- {
|
|
|
- for (int i = 0; i < List_ccp.Count; i++)
|
|
|
+ //USDPrice = USDPrice.Split('/')[1];
|
|
|
+ // 经手人 and excel行状态
|
|
|
+ if (!string.IsNullOrEmpty(List_ccp[i].ConsumptionDate) && !string.IsNullOrEmpty(USDPrice))
|
|
|
{
|
|
|
- DateTime dtTime1 = Convert.ToDateTime(item["TradingDate"].ToString() == "" ? DateTime.Now.ToString("MM/dd") : item["TradingDate"].ToString()); //交易日期
|
|
|
- string USDPrice = item["TradindMoney"].ToString(); //支出金额
|
|
|
- USDPrice = USDPrice.Split(' ')[1].Trim(); //替换掉非数字
|
|
|
-
|
|
|
- //USDPrice = USDPrice.Split('/')[1];
|
|
|
- // 经手人 and excel行状态
|
|
|
- if (!string.IsNullOrEmpty(List_ccp[i].ConsumptionDate) && !string.IsNullOrEmpty(USDPrice))
|
|
|
+ DateTime dtTime2 = Convert.ToDateTime(List_ccp[i].ConsumptionDate.ToString() == "" ? DateTime.Now.ToString("MM/dd") : List_ccp[i].ConsumptionDate.ToString());
|
|
|
+ float price1 = float.Parse(USDPrice);
|
|
|
+ float price2 = float.Parse(List_ccp[i].PayMoney.ToString("F2"));
|
|
|
+ if (dtTime1 == dtTime2 && price1 == price2)
|
|
|
{
|
|
|
- DateTime dtTime2 = Convert.ToDateTime(List_ccp[i].ConsumptionDate.ToString() == "" ? DateTime.Now.ToString("MM/dd") : List_ccp[i].ConsumptionDate.ToString());
|
|
|
- float price1 = float.Parse(USDPrice);
|
|
|
- float price2 = float.Parse(List_ccp[i].PayMoney.ToString("F2"));
|
|
|
- if (dtTime1 == dtTime2 && price1 == price2)
|
|
|
- {
|
|
|
- item["TeamRemark"] = delegationInfos.Find(it => it.Id == List_ccp[i].DIId)?.TeamName;
|
|
|
+ item["TeamRemark"] = delegationInfos.Find(it => it.Id == List_ccp[i].DIId)?.TeamName;
|
|
|
|
|
|
- item["Handlers"] = users.Find(it => it.Id == List_ccp[i].CreateUserId)?.CnName;
|
|
|
- item["State"] = "1";
|
|
|
- i = List_ccp.Count - 1;
|
|
|
- }
|
|
|
- else
|
|
|
- item["State"] = "0";
|
|
|
+ item["Handlers"] = users.Find(it => it.Id == List_ccp[i].CreateUserId)?.CnName;
|
|
|
+ item["State"] = "1";
|
|
|
+ i = List_ccp.Count - 1;
|
|
|
}
|
|
|
else
|
|
|
item["State"] = "0";
|
|
|
}
|
|
|
-
|
|
|
- if (item["TradindDesc"].ToString().Contains("财付通"))
|
|
|
- item["State"] = "2";
|
|
|
- else if (item["TradindDesc"].ToString().Contains("京东"))
|
|
|
- item["State"] = "2";
|
|
|
- else if (item["TradindDesc"].ToString().Contains("微信支付"))
|
|
|
- item["State"] = "2";
|
|
|
- else if (item["TradindDesc"].ToString().Contains("淘宝"))
|
|
|
- item["State"] = "2";
|
|
|
+ else
|
|
|
+ item["State"] = "0";
|
|
|
}
|
|
|
|
|
|
- string fileName1 = $"信用卡账单(交行卡){DateTime.Now.ToString("yyyy.MM.dd")}.xls";
|
|
|
- Dictionary<string, object> pairs = new Dictionary<string, object>();
|
|
|
- List<DataTable> datas = new List<DataTable>();
|
|
|
- datas.Add(dt);
|
|
|
- url = AsposeHelper.ExpertExcelToModel("信用卡对账模板-交行卡.xls", "TB", fileName1, pairs, datas);
|
|
|
-
|
|
|
+ if (item["TradindDesc"].ToString().Contains("财付通"))
|
|
|
+ item["State"] = "2";
|
|
|
+ else if (item["TradindDesc"].ToString().Contains("京东"))
|
|
|
+ item["State"] = "2";
|
|
|
+ else if (item["TradindDesc"].ToString().Contains("微信支付"))
|
|
|
+ item["State"] = "2";
|
|
|
+ else if (item["TradindDesc"].ToString().Contains("淘宝"))
|
|
|
+ item["State"] = "2";
|
|
|
}
|
|
|
- else return Ok(JsonView(false, "操作失败", "上传的文件不存在!"));
|
|
|
+
|
|
|
+ string fileName1 = $"信用卡账单(交行卡){DateTime.Now.ToString("yyyy.MM.dd")}.xls";
|
|
|
+ Dictionary<string, object> pairs = new Dictionary<string, object>();
|
|
|
+ List<DataTable> datas = new List<DataTable>();
|
|
|
+ datas.Add(dt);
|
|
|
+ url = AsposeHelper.ExpertExcelToModel("信用卡对账模板-交行卡.xls", "TB", fileName1, pairs, datas);
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- return Ok(JsonView(false, ex.Message));
|
|
|
+ return Ok(JsonView(false, $"匹配失败,{ex.Message}!"));
|
|
|
}
|
|
|
|
|
|
return Ok(JsonView(true, "操作成功", new { url = url }));
|