|
@@ -71,6 +71,8 @@ using NPOI.POIFS.NIO;
|
|
|
using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
|
|
|
using OASystem.Domain.ViewModels.Statistics;
|
|
|
using NPOI.XSSF.Model;
|
|
|
+using NetTaste;
|
|
|
+using Microsoft.AspNetCore.Http;
|
|
|
|
|
|
namespace OASystem.API.Controllers
|
|
|
{
|
|
@@ -10351,12 +10353,43 @@ namespace OASystem.API.Controllers
|
|
|
//#endregion
|
|
|
|
|
|
#endregion
|
|
|
+ decimal _rate = 1.00M;
|
|
|
+ string _currency = "";
|
|
|
|
|
|
+ var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
|
|
|
List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
|
|
|
+ if (hrDtas.Count < 1) return Ok(JsonView(false, "酒店预订费用未录入,不支持预定成本Excel导出"));
|
|
|
|
|
|
- //判断数据是否完整
|
|
|
- if (hrDtas.Count < 1) return Ok(JsonView(false, "请先录入酒店预订信息!"));
|
|
|
+ Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
|
|
|
+ if (_GroupCostParameter == null) return Ok(JsonView(false, "团组成本费用未录入,不支持预定成本Excel导出"));
|
|
|
+ if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出"));
|
|
|
+ }
|
|
|
+ _currency = _GroupCostParameter.Currency;
|
|
|
+
|
|
|
+ bool isIntType = int.TryParse(_currency, out int currId);
|
|
|
+ if (isIntType)
|
|
|
+ {
|
|
|
+ _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
|
|
|
|
|
|
+ var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
|
|
|
+ if (currInfo == null)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出"));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!_currency.ToUpper().Equals("CNY"))
|
|
|
+ {
|
|
|
+ _rate = _GroupCostParameter.Rate;
|
|
|
+ }
|
|
|
+
|
|
|
+ _rate = currInfo.Rate;
|
|
|
hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
|
|
|
string strFileName = "HotelStatement/";
|
|
|
|
|
@@ -10365,38 +10398,85 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
#region 数据处理
|
|
|
|
|
|
- var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
|
|
|
foreach (var item in hrDtas)
|
|
|
{
|
|
|
var ccpInfo = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
|
|
|
string roomCurr = currDatas.Find(it => it.Id == ccpInfo.PaymentCurrency)?.Name ?? "";
|
|
|
+
|
|
|
+ string singleRoomFeeStr = string.Empty,
|
|
|
+ doubleRoomFeeStr = string.Empty,
|
|
|
+ suiteRoomFeeStr = string.Empty,
|
|
|
+ otherRoomFeeStr = string.Empty,
|
|
|
+ payMoneyStr = string.Empty,
|
|
|
+ cardPriceStr = string.Empty;
|
|
|
+ if (roomCurr.Equals(_currency))
|
|
|
+ {
|
|
|
+ singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
|
|
|
+ doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
|
|
|
+ suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
|
|
|
+ otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
|
|
|
+ payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
|
|
|
+ cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ singleRoomFeeStr = $"{(item.SingleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
|
|
|
+ doubleRoomFeeStr = $"{(item.DoubleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
|
|
|
+ suiteRoomFeeStr = $"{(item.SuiteRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
|
|
|
+ otherRoomFeeStr = $"{(item.OtherRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
|
|
|
+ payMoneyStr = $"{(ccpInfo.PayMoney / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
|
|
|
+ cardPriceStr = $"{(item.CardPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
|
|
|
+ }
|
|
|
+ string breakfastPriceStr = string.Empty,
|
|
|
+ breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
|
|
|
+ governmentRentStr = string.Empty,
|
|
|
+ governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
|
|
|
+ cityTaxStrStr = string.Empty,
|
|
|
+ cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
|
|
|
+
|
|
|
+ //if (breakfastCurrency.Equals(_currency))
|
|
|
+ //{
|
|
|
+ // breakfastPriceStr = $"{item.BreakfastPrice.ToString("#0.00")} ({_currency})";
|
|
|
+ //}
|
|
|
+ //if (governmentRentCurrency.Equals(_currency))
|
|
|
+ //{
|
|
|
+ // governmentRentStr = $"{item.GovernmentRent.ToString("#0.00")} ({_currency})";
|
|
|
+ //}
|
|
|
+ //if (cityTaxStrCurrency.Equals(_currency))
|
|
|
+ //{
|
|
|
+ // cityTaxStrStr = $"{item.CityTax.ToString("#0.00")} ({_currency})";
|
|
|
+ //}
|
|
|
+
|
|
|
+ breakfastPriceStr = $"{item.BreakfastPrice.ToString("#0.00")} {_currency}";
|
|
|
+ governmentRentStr = $"{item.GovernmentRent.ToString("#0.00")} {_currency}";
|
|
|
+ cityTaxStrStr = $"{item.CityTax.ToString("#0.00")} {_currency}";
|
|
|
+
|
|
|
pcfds.Add(new HotelReservations_PCFD_View()
|
|
|
{
|
|
|
City = item.City,
|
|
|
HotelName = item.HotelName,
|
|
|
Date = $"{item.CheckInDate} - {item.CheckOutDate}",
|
|
|
- SingleRoomCount = item.SingleRoomCount,
|
|
|
- SingleRoomPrice = item.SingleRoomPrice.ToString("#0.00") + " " + roomCurr,
|
|
|
- DoubleRoomCount = item.DoubleRoomCount,
|
|
|
- DoubleRoomPrice = item.DoubleRoomPrice.ToString("#0.00") + " " + roomCurr,
|
|
|
- SuiteRoomCount = item.SuiteRoomCount,
|
|
|
- SuiteRoomPrice = item.SuiteRoomPrice.ToString("#0.00") + " " + roomCurr,
|
|
|
- OtherRoomPrice = item.OtherRoomPrice.ToString("#0.00") + " " + roomCurr,
|
|
|
- OtherRoomCount = item.OtherRoomCount,
|
|
|
- RoomCurrency = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == ccpInfo.PaymentCurrency).First()?.Name ?? "",
|
|
|
-
|
|
|
- BreakfastPrice = $"{item.BreakfastPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? ""}",
|
|
|
- GovernmentRent = $"{item.GovernmentRent.ToString("#0.00")} {currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? ""}",
|
|
|
- CityTax = $"{item.CityTax.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? ""}",
|
|
|
+ // SingleRoomCount = item.SingleRoomCount,
|
|
|
+ SingleRoomPrice = singleRoomFeeStr,
|
|
|
+ // DoubleRoomCount = item.DoubleRoomCount,
|
|
|
+ DoubleRoomPrice = doubleRoomFeeStr,
|
|
|
+ //SuiteRoomCount = item.SuiteRoomCount,
|
|
|
+ SuiteRoomPrice = suiteRoomFeeStr,
|
|
|
+ OtherRoomPrice = otherRoomFeeStr,
|
|
|
+ //OtherRoomCount = item.OtherRoomCount,
|
|
|
+
|
|
|
+ BreakfastPrice = breakfastPriceStr,
|
|
|
+ GovernmentRent = governmentRentStr,
|
|
|
+ CityTax = cityTaxStrStr,
|
|
|
|
|
|
RoomExplanation = item.RoomExplanation,
|
|
|
PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == ccpInfo.PayDId).First()?.Name ?? "",
|
|
|
PayTime = ccpInfo.ConsumptionDate,
|
|
|
BankNo = ccpInfo.BankNo,
|
|
|
- PayMoney = ccpInfo.PayMoney.ToString("#0.00") + " " + _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == ccpInfo.PaymentCurrency).First()?.Name ?? "",
|
|
|
- PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
|
|
|
- PayMoneyCurrency = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == ccpInfo.PaymentCurrency).First()?.Name ?? "",
|
|
|
- CardPrice = item.CardPrice + " " + _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == ccpInfo.PaymentCurrency).First()?.Name ?? "",
|
|
|
+ PayMoney = payMoneyStr,
|
|
|
+ //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
|
|
|
+ ConsumptionPatterns = ccpInfo.ConsumptionPatterns,
|
|
|
+ CardPrice = cardPriceStr,
|
|
|
Remark = ccpInfo.Remark
|
|
|
|
|
|
});
|
|
@@ -10411,7 +10491,7 @@ namespace OASystem.API.Controllers
|
|
|
var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
|
|
|
var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
|
|
|
designer.SetDataSource("TourNo", groupInfo.TourCode);
|
|
|
- designer.SetDataSource("TeamName", groupInfo.TeamName);
|
|
|
+ designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
|
|
|
designer.SetDataSource("Opertor", userInfo.CnName);
|
|
|
|
|
|
DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
|
|
@@ -10419,10 +10499,124 @@ namespace OASystem.API.Controllers
|
|
|
designer.SetDataSource(dt);
|
|
|
designer.Process();
|
|
|
string fileName = ($"HotelReservation/{groupInfo.TeamName}_酒店预订成本_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls").Replace(":", "");
|
|
|
- designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
|
|
|
+ string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
|
|
|
+ designer.Workbook.Save(serverPath);
|
|
|
string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
|
|
|
+
|
|
|
+ #region 删除指定行
|
|
|
+
|
|
|
+ bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, remarkDel = true;
|
|
|
+ int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
|
|
|
+ doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
|
|
|
+ suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
|
|
|
+ otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
|
|
|
+ zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
|
|
|
+ dsIndex = dt.Columns["GovernmentRent"].Ordinal,
|
|
|
+ cssIndex = dt.Columns["CityTax"].Ordinal,
|
|
|
+ remarkIndex = dt.Columns["Remark"].Ordinal;
|
|
|
+ //删除指定列
|
|
|
+ foreach (DataRow item in dt.Rows)
|
|
|
+ {
|
|
|
+ string singleStr = item["SingleRoomPrice"].ToString();
|
|
|
+ bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
|
|
|
+ if (containsDigitButNotZero1) singleDel = false;
|
|
|
+ singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
|
|
|
+
|
|
|
+ string doubleStr = item["DoubleRoomPrice"].ToString();
|
|
|
+ bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
|
|
|
+ if (containsDigitButNotZero2) doubleDel = false;
|
|
|
+
|
|
|
+
|
|
|
+ string suiteStr = item["SuiteRoomPrice"].ToString();
|
|
|
+ bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
|
|
|
+ if (containsDigitButNotZero3) suiteDel = false;
|
|
|
+
|
|
|
+
|
|
|
+ string otherStr = item["OtherRoomPrice"].ToString();
|
|
|
+ bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
|
|
|
+ if (containsDigitButNotZero4) otherDel = false;
|
|
|
+
|
|
|
+
|
|
|
+ string zcStr = item["BreakfastPrice"].ToString();
|
|
|
+ bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
|
|
|
+ if (containsDigitButNotZero5) zcDel = false;
|
|
|
+
|
|
|
+
|
|
|
+ string dsStr = item["GovernmentRent"].ToString();
|
|
|
+ bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
|
|
|
+ if (containsDigitButNotZero6) dsDel = false;
|
|
|
+
|
|
|
+
|
|
|
+ string cssStr = item["CityTax"].ToString();
|
|
|
+ bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
|
|
|
+ if (!containsDigitButNotZero7) cssDel = false;
|
|
|
+
|
|
|
+ string remarkStr = item["Remark"].ToString();
|
|
|
+ if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
|
|
|
+
|
|
|
+ }
|
|
|
+ //singleDel = true,doubleDel = true, suiteDel = true,otherDel = true,zcDel = true,dsDel = true,cssDel = true;
|
|
|
+ int delColumn = 0;
|
|
|
+ if (singleDel) { DeleteColumn(serverPath, singleIndex - delColumn); delColumn++; }
|
|
|
+ if (doubleDel) { DeleteColumn(serverPath, doubleIndex - delColumn); delColumn++; }
|
|
|
+ if (suiteDel) { DeleteColumn(serverPath, suiteIndex - delColumn); delColumn++; }
|
|
|
+ if (otherDel) { DeleteColumn(serverPath, otherIndex - delColumn); delColumn++; }
|
|
|
+ if (zcDel) { DeleteColumn(serverPath, zcIndex - delColumn); delColumn++; }
|
|
|
+ if (dsDel) { DeleteColumn(serverPath, dsIndex - delColumn); delColumn++; }
|
|
|
+ if (cssDel) { DeleteColumn(serverPath, cssIndex - delColumn); delColumn++; }
|
|
|
+ if (remarkDel) { DeleteColumn(serverPath, remarkIndex - delColumn); delColumn++; }
|
|
|
+ #endregion
|
|
|
+ //只保留第一个表格
|
|
|
+ DeleteSheet(serverPath);
|
|
|
+
|
|
|
return Ok(JsonView(true, "操作成功", url = rst));
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 删除指定列
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="file"></param>
|
|
|
+ /// <param name="columnIndex"></param>
|
|
|
+ /// <param name="totalColumns"></param>
|
|
|
+ /// <param name="sheetName"></param>
|
|
|
+ private void DeleteColumn(string file, int columnIndex)
|
|
|
+ {
|
|
|
+
|
|
|
+ Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
|
|
|
+ //wb.Save(file);
|
|
|
+ Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
|
|
|
+
|
|
|
+ if (sheet1 != null)
|
|
|
+ {
|
|
|
+ Cells cells = sheet1.Cells;
|
|
|
+ cells.DeleteColumn(columnIndex);
|
|
|
+ }
|
|
|
+ wb.Save(file);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 删除sheet
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="file"></param>
|
|
|
+ /// <param name="sheetName"></param>
|
|
|
+ private void DeleteSheet(string file, string sheetName="")
|
|
|
+ {
|
|
|
+ Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
|
|
|
+ //wb.Save(file);
|
|
|
+ List<string> sheets = new List<string>();
|
|
|
+ foreach (var item in wb.Worksheets)
|
|
|
+ {
|
|
|
+ sheets.Add(item.Name);
|
|
|
+ }
|
|
|
+ if (sheets.Count > 0)
|
|
|
+ {
|
|
|
+ sheets.RemoveAt(0);//不删除第一个sheet
|
|
|
+ foreach (var item in sheets)
|
|
|
+ {
|
|
|
+ wb.Worksheets.RemoveAt(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ wb.Save(file);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|