LEIYI 5 月之前
父節點
當前提交
736872f3a3
共有 1 個文件被更改,包括 450 次插入173 次删除
  1. 450 173
      OASystem/OASystem.Api/Controllers/GroupsController.cs

+ 450 - 173
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -42,6 +42,7 @@ using System.IO;
 using System.IO.Compression;
 using System.Net.Http;
 using System.Reflection.PortableExecutable;
+using System.Security.Cryptography;
 using Ubiety.Dns.Core;
 using static NPOI.POIFS.Crypt.CryptoFunctions;
 using static OASystem.API.OAMethodLib.JWTHelper;
@@ -12262,215 +12263,491 @@ ORDER by  gctggrc.id DESC
             var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
             
             var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
-            //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
-            //if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
-            //{
-            //    return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
-            //}
-            //_currency = _GroupCostParameter.Currency;
-
-            bool isIntType = int.TryParse(_currency, out int currId);
-            if (isIntType)
+            if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
+            if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
             {
-                _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
-            }
-
-            var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
+                //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
+                bool isIntType = int.TryParse(_currency, out int currId);
+                if (isIntType)
+                {
+                    _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
+                }
 
-            var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
-            if (currInfo == null)
-            {
-                //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
+                var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
 
-            }else _rate = currInfo.Rate;
+                var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
+                if (currInfo == null)
+                {
 
-            if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
-            {
-                _rate = _GroupCostParameter.Rate;
-            }
+                    //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
 
-            
-            hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
-            string strFileName = "HotelStatement/";
+                }
+                else _rate = currInfo.Rate;
 
-            string guestNames = ""; //格式Mr.xxx Ms.xxx
-            List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
-            #region 数据处理
+                if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
+                {
+                    _rate = _GroupCostParameter.Rate;
+                }
 
-            foreach (var item in hrDtas)
-            {
-                var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
 
-                var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
-                var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
-                var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
-                var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
+                hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
+                string strFileName = "HotelStatement/";
 
+                string guestNames = ""; //格式Mr.xxx Ms.xxx
+                List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
+                #region 数据处理
 
-                if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
+                foreach (var item in hrDtas)
                 {
-                    continue;
-                }
+                    var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
 
-                string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
-                if (string.IsNullOrEmpty(_currency)) _currency = roomCurr;
+                    var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
+                    var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
+                    var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
+                    var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
 
-                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 * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
-                    doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
-                    suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
-                    otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
-                    payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
-                    cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
+
+                    if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
+                    {
+                        continue;
+                    }
+
+                    string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
+                    if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
+
+                    string singleRoomFeeStr = string.Empty,
+                           doubleRoomFeeStr = string.Empty,
+                           suiteRoomFeeStr = string.Empty,
+                           otherRoomFeeStr = string.Empty,
+                           payMoneyStr = string.Empty,
+                           cardPriceStr = string.Empty;
+                    if (roomCurr.Equals("CNY"))
+                    {
+                        singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
+                        doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
+                        suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
+                        otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
+                        payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
+                        cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
+                    }
+                    else
+                    {
+                        //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
+                        //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
+                        //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
+                        //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
+                        //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
+                        //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
+                        singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
+                        doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
+                        suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
+                        otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
+
+                        var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
+                        if (ccpPaymentCurrency.Equals("CNY"))
+                        {
+                            payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
+                            cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
+                        }
+                        else
+                        {
+                            payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
+                        }
+
+                        var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
+                        if (hotelcardPriceCurrency.Equals("CNY"))
+                        {
+                            cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
+                        }
+                        else
+                        {
+                            cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
+                        }
+
+
+
+                    }
+                    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 ?? "",
+                           cityTaxStr = string.Empty,
+                           cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
+
+                    var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
+                    if (!string.IsNullOrEmpty(breakfastCurrency1))
+                    {
+                        if (breakfastCurrency1.Equals("CNY"))
+                        {
+                            breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
+                        }
+                        else
+                        {
+                            var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
+                            breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
+                        }
+
+                    }
+                    else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
+
+                    var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
+                    if (!string.IsNullOrEmpty(governmentRentCurrency1))
+                    {
+                        if (governmentRentCurrency.Equals("CNY"))
+                        {
+                            governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
+                        }
+                        else
+                        {
+                            var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
+                            governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
+                        }
+                    }
+                    else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
+
+                    var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
+                    if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
+                    {
+                        if (cityTaxStrCurrency1.Equals("CNY"))
+                        {
+                            cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
+                        }
+                        else
+                        {
+                            var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
+                            cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
+                        }
+                    }
+                    else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
+
+
+
+                    int payDId = roomInfo?.PayDId ?? 0;
+                    pcfds.Add(new HotelReservations_PCFD_View()
+                    {
+                        City = item.City,
+                        HotelName = item.HotelName,
+                        Date = $"{item.CheckInDate} - {item.CheckOutDate}",
+                        // 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 = cityTaxStr,
+
+                        RoomExplanation = item.RoomExplanation,
+                        PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
+                        PayTime = roomInfo?.ConsumptionDate,
+                        BankNo = roomInfo?.BankNo,
+                        PayMoney = payMoneyStr,
+                        //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
+                        ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
+                        CardPrice = cardPriceStr,
+                        Remark = ccpInfo.Remark
+
+                    });
                 }
-                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 ?? "";
 
-                breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
-                governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
-                cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
+                #endregion
 
-                int payDId = roomInfo?.PayDId ?? 0;
-                pcfds.Add(new HotelReservations_PCFD_View()
-                {
-                    City = item.City,
-                    HotelName = item.HotelName,
-                    Date = $"{item.CheckInDate} - {item.CheckOutDate}",
-                    // 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 == payDId).First()?.Name ?? "",
-                    PayTime = roomInfo?.ConsumptionDate,
-                    BankNo = roomInfo?.BankNo,
-                    PayMoney = payMoneyStr,
-                    //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
-                    ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
-                    CardPrice = cardPriceStr,
-                    Remark = ccpInfo.Remark
+                //载入模板
+                WorkbookDesigner designer = new WorkbookDesigner();
+                designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
+
+                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}  团组成本币种:{_currency}  团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
+                designer.SetDataSource("Opertor", userInfo.CnName);
+
+                DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
+                dt.TableName = "ViewMyHotelReservations";
+                designer.SetDataSource(dt);
+                designer.Process();
+
+                string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
+                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, cpDel = 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,
+                    cpIndex = dt.Columns["ConsumptionPatterns"].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 cpStr = item["ConsumptionPatterns"].ToString();
+                    if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
+
+                    string remarkStr = item["Remark"].ToString();
+                    if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
+
+                }
+
+                DeleteColumn(serverPath, remarkIndex, remarkDel);
+                DeleteColumn(serverPath, cpIndex, cpDel);
+                DeleteColumn(serverPath, dsIndex, dsDel);
+                DeleteColumn(serverPath, cssIndex, cssDel);
+                DeleteColumn(serverPath, zcIndex, zcDel);
+                DeleteColumn(serverPath, otherIndex, otherDel);
+                DeleteColumn(serverPath, suiteIndex, suiteDel);
+                DeleteColumn(serverPath, doubleIndex, doubleDel);
+                DeleteColumn(serverPath, singleIndex, singleDel);
+                #endregion
+                //只保留第一个表格
+                DeleteSheet(serverPath);
 
-                });
+                return Ok(JsonView(true, "操作成功", url = rst));
             }
+            else
+            {
+                _currency = _GroupCostParameter.Currency;
+                bool isIntType = int.TryParse(_currency, out int currId);
+                if (isIntType)
+                {
+                    _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
 
-            #endregion
+                }
 
-            //载入模板
-            WorkbookDesigner designer = new WorkbookDesigner();
-            designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
+                var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
 
-            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}  团组成本币种:{_currency}  团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
-            designer.SetDataSource("Opertor", userInfo.CnName);
+                var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
+                if (currInfo == null)
+                {
+                    return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
 
-            DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
-            dt.TableName = "ViewMyHotelReservations";
-            designer.SetDataSource(dt);
-            designer.Process();
+                }
 
-            string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
-            string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
+                if (!_currency.ToUpper().Equals("CNY"))
+                {
+                    _rate = _GroupCostParameter.Rate;
+                }
 
-            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, cpDel = 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,
-                cpIndex = dt.Columns["ConsumptionPatterns"].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;
+                _rate = currInfo.Rate;
+                hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
+                string strFileName = "HotelStatement/";
 
-                string doubleStr = item["DoubleRoomPrice"].ToString();
-                bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
-                if (containsDigitButNotZero2) doubleDel = false;
+                string guestNames = ""; //格式Mr.xxx Ms.xxx
+                List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
+                #region 数据处理
 
-                string suiteStr = item["SuiteRoomPrice"].ToString();
-                bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
-                if (containsDigitButNotZero3) suiteDel = false;
+                foreach (var item in hrDtas)
+                {
+                    var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
 
-                string otherStr = item["OtherRoomPrice"].ToString();
-                bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
-                if (containsDigitButNotZero4) otherDel = false;
+                    var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
+                    var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
+                    var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
+                    var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
 
-                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 roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
 
-                string cssStr = item["CityTax"].ToString();
-                bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
-                if (containsDigitButNotZero7) cssDel = false;
+                    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 * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
+                        doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
+                        suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
+                        otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
+                        payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
+                        cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _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 ?? "";
+
+                    breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
+                    governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
+                    cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
+
+                    int payDId = roomInfo?.PayDId ?? 0;
+                    pcfds.Add(new HotelReservations_PCFD_View()
+                    {
+                        City = item.City,
+                        HotelName = item.HotelName,
+                        Date = $"{item.CheckInDate} - {item.CheckOutDate}",
+                        // 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 == payDId).First()?.Name ?? "",
+                        PayTime = roomInfo?.ConsumptionDate,
+                        BankNo = roomInfo?.BankNo,
+                        PayMoney = payMoneyStr,
+                        //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
+                        ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
+                        CardPrice = cardPriceStr,
+                        Remark = ccpInfo.Remark
 
-                string cpStr = item["ConsumptionPatterns"].ToString();
-                if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
+                    });
+                }
 
-                string remarkStr = item["Remark"].ToString();
-                if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
+                #endregion
 
+                //载入模板
+                WorkbookDesigner designer = new WorkbookDesigner();
+                designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
+
+                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}  团组成本币种:{_currency}  团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
+                designer.SetDataSource("Opertor", userInfo.CnName);
+
+                DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
+                dt.TableName = "ViewMyHotelReservations";
+                designer.SetDataSource(dt);
+                designer.Process();
+
+                string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
+                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, cpDel = 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,
+                    cpIndex = dt.Columns["ConsumptionPatterns"].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 cpStr = item["ConsumptionPatterns"].ToString();
+                    if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
+
+                    string remarkStr = item["Remark"].ToString();
+                    if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
+
+                }
+
+                DeleteColumn(serverPath, remarkIndex, remarkDel);
+                DeleteColumn(serverPath, cpIndex, cpDel);
+                DeleteColumn(serverPath, dsIndex, dsDel);
+                DeleteColumn(serverPath, cssIndex, cssDel);
+                DeleteColumn(serverPath, zcIndex, zcDel);
+                DeleteColumn(serverPath, otherIndex, otherDel);
+                DeleteColumn(serverPath, suiteIndex, suiteDel);
+                DeleteColumn(serverPath, doubleIndex, doubleDel);
+                DeleteColumn(serverPath, singleIndex, singleDel);
+                #endregion
+                //只保留第一个表格
+                DeleteSheet(serverPath);
+
+                return Ok(JsonView(true, "操作成功", url = rst));
             }
 
-            DeleteColumn(serverPath, remarkIndex, remarkDel);
-            DeleteColumn(serverPath, cpIndex, cpDel);
-            DeleteColumn(serverPath, dsIndex, dsDel);
-            DeleteColumn(serverPath, cssIndex, cssDel);
-            DeleteColumn(serverPath, zcIndex, zcDel);
-            DeleteColumn(serverPath, otherIndex, otherDel);
-            DeleteColumn(serverPath, suiteIndex, suiteDel);
-            DeleteColumn(serverPath, doubleIndex, doubleDel);
-            DeleteColumn(serverPath, singleIndex, singleDel);
-            #endregion
-            //只保留第一个表格
-            DeleteSheet(serverPath);
 
-            return Ok(JsonView(true, "操作成功", url = rst));
+            return Ok(JsonView(false));
         }
 
         /// <summary>