Przeglądaj źródła

Merge branch 'develop' of http://132.232.92.186:3000/XinXiBu/OA2023 into develop

yuanrf 2 dni temu
rodzic
commit
2a238ee61e

+ 522 - 9
OASystem/OASystem.Api/Controllers/FinancialController.cs

@@ -899,13 +899,13 @@ namespace OASystem.API.Controllers
             return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
         }
 
-
         private readonly static Dictionary<int, string> _receivablesFeilDownloadType = new Dictionary<int, string>()
         {
             { 1,"生成收款单(四川)"},
             { 2,"生成收款单(北京)"},
             { 3,"汇款账单"},
-            { 4,"实际报价明细"}
+            { 4,"实际报价明细"},
+            { 5,"汇款账单(表格版本)"},
         };
 
         /// <summary>
@@ -1051,7 +1051,7 @@ namespace OASystem.API.Controllers
 
                     return Ok(JsonView(true, "成功", new { Url = url }));
                 }
-                else if (dto.FileType == 3) //汇款通知
+                else if (dto.FileType == 3) // 汇款通知
                 {
                     var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
                     var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId && it.NationalTravelFeeId > 0).ToList();
@@ -1482,7 +1482,7 @@ namespace OASystem.API.Controllers
 
                     return Ok(JsonView(true, "成功", new { Url = url }));
                 }
-                else if (dto.FileType == 4) //实际报价明细
+                else if (dto.FileType == 4) // 实际报价明细
                 {
                     try
                     {
@@ -1604,6 +1604,497 @@ namespace OASystem.API.Controllers
                         return Ok(JsonView(false, $"系统错误: {ex.Message}"));
                     }
                 }
+                else if (dto.FileType == 5) // 汇款通知(表格模式)
+                {
+                    var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
+                    var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId && it.NationalTravelFeeId > 0).ToList();
+                    if (_EnterExitCosts == null)
+                    {
+                        return Ok(JsonView(false, "该团组未填写出入境费用;"));
+                    }
+
+                    var _EnterExitCostCurrencys = new List<EnterExitCostCurrency>();
+
+                    if (!string.IsNullOrEmpty(_EnterExitCosts.CurrencyRemark))
+                    {
+                        var currency1 = _EnterExitCosts.CurrencyRemark.Split("|");
+                        foreach (var item in currency1)
+                        {
+                            var currency2 = item.Split(":");
+                            var currency3 = currency2[0].Split("(");
+                            var currencyName = currency3[0].ToString();
+                            var currencyCode = currency3[1].Split(")")[0].ToString();
+
+                            _EnterExitCostCurrencys.Add(new EnterExitCostCurrency
+                            {
+                                Name = currencyName,
+                                Code = currencyCode,
+                                Rate = Convert.ToDecimal(currency2[1] ?? "0")
+                            });
+                        }
+                    }
+
+                    var _cityFee = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
+
+                    foreach (var item in _DayAndCosts)
+                    {
+                        var cityInfo = _cityFee.Where(it => it.Id == item.NationalTravelFeeId).FirstOrDefault();
+                        if (cityInfo != null)
+                        {
+                            if (cityInfo.City.Contains("全部城市") || cityInfo.City.Contains("其他城市") || cityInfo.City.Contains("所有城市"))
+                            {
+                                item.Place = cityInfo.Country;
+                            }
+                            else item.Place = cityInfo.City;
+                        }
+                    }
+
+                    var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
+                    var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
+
+                    //数据源
+                    //住宿费 伙食费 公杂费 培训费 选中才计算出费用
+
+                    //住宿费 选中赋值
+                    List<Grp_DayAndCost> dac1 = new List<Grp_DayAndCost>();
+                    if (_EnterExitCosts.ChoiceThree == 1) dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList();
+
+                    //伙食费 选中赋值
+                    List<Grp_DayAndCost> dac2 = new List<Grp_DayAndCost>();
+                    if (_EnterExitCosts.ChoiceFour == 1) dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); 
+
+                    //公杂费 选中赋值
+                    List<Grp_DayAndCost> dac3 = new List<Grp_DayAndCost>();
+                    if (_EnterExitCosts.ChoiceFour == 1) dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); 
+
+                    //培训费 选中赋值
+                    List<Grp_DayAndCost> dac4 = new List<Grp_DayAndCost>();
+                    if (_EnterExitCosts.ChoiceFour == 1) dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList();
+
+                    // 其他款项费
+                    var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
+                        .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
+                        .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
+                        .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
+                        .Select((x, a, b) => new
+                        {
+                            x.Index,
+                            itemName = a.Name,
+                            CurrencyStr = b.Name,
+                            x.Cost,
+                            x.SubTotal,
+                            x.Remark
+                        })
+                        .OrderBy((x) => x.Index)
+                        .ToList();
+
+                    // 数据整理
+                    // 住宿费
+                    var accomFees = dac1.GroupBy(x => x.NationalTravelFeeId)
+                        .Select(group =>
+                        {
+                            var currData = group.FirstOrDefault();
+
+                            // 币种信息
+                            var currencyInfo = currDatas.Where(x => x.Id == currData.Currency).FirstOrDefault();
+                            // 币种名称
+                            string currencyName = currencyInfo?.Remark ?? "";
+                            // 币种Code
+                            string currencyCode = currencyInfo?.Name ?? "";
+                            // 币种汇率信息
+                            var currencyRateInfo = enterExitCostCurrencys.Where(x => x.CurrencyName.Equals(currencyName)).FirstOrDefault();
+                            // 币种汇率
+                            decimal currencyRate = currencyRateInfo != null ? currencyRateInfo.Rate : 1.00M;
+
+                            // 城市信息 Grp_NationalTravelFee
+                            var placeName = GetEnterExitCostExportCity(_cityFee, group.Key);
+
+                            // 天数
+                            int totalDays = group.Count();
+
+                            // 原始币种小计
+                            decimal totalAmount = group.Sum(x => x.Cost);
+
+                            // 人名币金额
+                            decimal totalCNY = totalDays * totalAmount * currencyRate;
+
+                            return new
+                            {
+                                TravelFeeId = group.Key,
+                                PlaceName = placeName,
+                                TotalDays = totalDays,
+                                currData.Cost,
+                                TotalAmount = totalAmount,
+                                currData.Currency,
+                                CurrencyCode = currencyCode,
+                                CurrencyName = currencyName,
+                                CurrencyRate = currencyRate,
+                                TotalCNY = totalCNY,
+                                Details = group.ToList()
+                            };
+                        })
+                        .ToList();
+
+                    // 合并伙食费和公杂费数据
+                    var foodSundCost = new List<Grp_DayAndCost>();
+                    foodSundCost.AddRange(dac2);
+                    foodSundCost.AddRange(dac3);
+
+                    // 伙食费和公杂费
+                    var foodSundCosts = foodSundCost
+                        .GroupBy(x => x.NationalTravelFeeId)
+                        .Select(group =>
+                        {
+                            var currData = group.FirstOrDefault();
+
+                            // 币种信息
+                            var currencyInfo = currDatas.Where(x => x.Id == currData.Currency).FirstOrDefault();
+                            // 币种名称
+                            string currencyName = currencyInfo?.Remark ?? "";
+                            // 币种Code
+                            string currencyCode = currencyInfo?.Name ?? "";
+                            // 币种汇率信息
+                            var currencyRateInfo = enterExitCostCurrencys.Where(x => x.CurrencyName.Equals(currencyName)).FirstOrDefault();
+                            // 币种汇率
+                            decimal currencyRate = currencyRateInfo != null ? currencyRateInfo.Rate : 1.00M;
+
+                            // 城市信息 Grp_NationalTravelFee
+                            var placeName = GetEnterExitCostExportCity(_cityFee, group.Key);
+
+                            // 天数
+                            int totalDays = group.Count() / 2;
+
+                            // 原始币种小计
+                            decimal totalAmount = group.Sum(x => x.Cost);
+
+                            // 原始币种单价
+                            decimal cost = group.Sum(x => x.Cost) / totalDays;
+
+                            // 人名币金额
+                            decimal totalCNY = totalDays * totalAmount * currencyRate;
+
+                            return new
+                            {
+                                TravelFeeId = group.Key,
+                                PlaceName = placeName,
+                                TotalDays = totalDays,
+                                Cost = cost,
+                                TotalAmount = totalAmount,
+                                currData.Currency,
+                                CurrencyCode = currencyCode,
+                                CurrencyName = currencyName,
+                                CurrencyRate = currencyRate,
+                                TotalCNY = totalCNY,
+                                Details = group.ToList()
+                            };
+                        })
+                        .ToList();
+
+                    //币种Data
+                    var currData = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
+
+                    var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
+                        .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
+                        .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
+                        .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
+                        .Select((tcl, dc, cc) => new ClientAirInfo
+                        {
+                            LastName = dc.LastName,
+                            FirstName = dc.FirstName,
+                            Sex = dc.Sex,
+                            Birthday = dc.BirthDay,
+                            Company = cc.CompanyFullName,
+                            Job = dc.Job,
+                            AirType = tcl.ShippingSpaceTypeId
+                        })
+                        .ToList();
+                    if (DeleClientList.Count < 1)
+                    {
+                        return Ok(JsonView(false, "暂无团组成员,请先填写团组成员!!!"));
+                    }
+
+                    foreach (var item in DeleClientList)
+                    {
+                        EncryptionProcessor.DecryptProperties(item);
+                        item.Company = item.Company.Replace("\n", "");
+                    }
+
+                    var _ClientNames = DeleClientList.Select(x => x.Name).ToList();
+                    var _GroupClient = DeleClientList.GroupBy(x => x.Company).ToList();
+                    var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
+                    var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
+
+                    string tempPath = AppSettingsHelper.Get("WordBasePath") + $"ForeignReceivables/Temp/省级单位出国经费报销单.xls";
+                    var filesToZip = new List<string>();
+
+                    foreach (var clientItem in _GroupClient) //遍历单位
+                    {
+                        var clientItems = clientItem.ToList();
+
+                        //载入模板
+                        var designer = new WorkbookDesigner
+                        {
+                            Workbook = new Workbook(tempPath)
+                        };
+                        Workbook workbook = designer.Workbook;
+                        Worksheet worksheet = workbook.Worksheets[0];
+
+                        // 日期格式化
+                        var dateFormat = "yyyy年MM月dd日";
+
+                        designer.SetDataSource("DeptOffice", "");   // 处室
+                                                                    // 报销日期
+                        var currDateStr = DateTime.Now.ToString(dateFormat);
+                        designer.SetDataSource("ReimbDate", currDateStr);
+
+                        // 国家和地区(含经停) 
+                        string countryRegionStops = _delegationInfoRep.FormartTeamName(_DelegationInfo.VisitCountry);
+                        designer.SetDataSource("CountryRegionStops", countryRegionStops);
+                        // 具体线路
+                        string specificLine = "";
+                        if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
+                        {
+                            var list = new List<string>();
+                            try
+                            {
+                                var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
+                                foreach (var item in spilitArr)
+                                {
+                                    var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
+                                    var depCode = spDotandEmpty[2].Substring(0, 3);
+                                    var arrCode = spDotandEmpty[2].Substring(3, 3);
+                                    string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City;
+                                    string arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
+
+                                    list.Add(depName);
+                                    list.Add(arrName);
+                                }
+
+                                list = list.Distinct().ToList();
+                                specificLine = string.Join("-", list);
+                            }
+                            catch (Exception)
+                            {
+                                specificLine = "行程录入不正确!";
+                            }
+                        }
+                        else
+                        {
+                            specificLine = "未录入行程!";
+                        }
+                        designer.SetDataSource("SpecRoute", specificLine);
+
+                        // 出国时间
+                        string overseasTime = $"{_DelegationInfo.VisitStartDate.ToString(dateFormat)} - {_DelegationInfo.VisitEndDate.ToString(dateFormat)}";
+                        designer.SetDataSource("OverseasTime", overseasTime);
+                        // 实际天数
+                        TimeSpan overseasActualDays_ts = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
+                        designer.SetDataSource("OverseasActualDays", $"{overseasActualDays_ts.Days}天");
+
+                        // 人数
+                        int personCount = clientItems.Count;
+                        if (personCount == 0) personCount = 1;
+
+                        // 组团单位
+                        designer.SetDataSource("GroupUnit", clientItem.Key); 
+
+                        // 出国人员姓名
+                        var overseasName = string.Join("、", clientItems.Select(it => it.LastName + it.FirstName).ToList()).TrimEnd('、');
+                        if (string.IsNullOrEmpty(overseasName)) overseasName = "-";
+                        designer.SetDataSource("OverseasName", overseasName);
+
+                        // 住宿费合计
+                        decimal accomFeeTotalCny = 0.00m;
+                        // 伙食费和公杂费合计
+                        decimal foodSundTotalCny = 0.00m;
+                        #region 设置 住宿费、伙食费和公杂显示值
+                        // 开始行
+                        int startRow = 8;
+                        // 开始列
+                        int startColumn = 1;
+                        // 数据展示默认行 含小计行
+                        int defualtRow = 4;
+                        // 设置住宿费
+                        for (int i = 0; i < accomFees.Count; i++)
+                        {
+                            var accomFeeData = accomFees[i];
+                            int startRow1 = startRow + i;
+
+                            // 插入数据到对应列
+                            worksheet.Cells[startRow1, startColumn].PutValue(accomFeeData.PlaceName);        // 国家(地区)/城市
+                            worksheet.Cells[startRow1, startColumn + 1].PutValue(accomFeeData.CurrencyName); // 币种
+                            worksheet.Cells[startRow1, startColumn + 2].PutValue(accomFeeData.Cost);         // 标准
+                            worksheet.Cells[startRow1, startColumn + 3].PutValue(personCount);               // 人数
+                            worksheet.Cells[startRow1, startColumn + 4].PutValue(accomFeeData.TotalDays);    // 天数
+                            decimal totalAmount = accomFeeData.TotalAmount * personCount;                    
+                            worksheet.Cells[startRow1, startColumn + 5].PutValue(totalAmount);               // 小计
+                            worksheet.Cells[startRow1, startColumn + 6].PutValue(accomFeeData.CurrencyRate); // 汇率
+                            decimal totalCNY = totalAmount * accomFeeData.CurrencyRate;                      
+                            accomFeeTotalCny += totalCNY;
+                            worksheet.Cells[startRow1, startColumn + 7].PutValue(totalCNY);                  // 折合人民币(元)
+                        }
+
+                        //设置小计行 合计金额 固定单元格
+                        worksheet.Cells[11, startColumn + 7].PutValue(accomFeeTotalCny);                     // 折合人民币(元)
+
+                        //  新增小计行
+                        if (accomFees.Count == (defualtRow - 1)) startRow += 1;
+                        else startRow += defualtRow;
+
+                        // 设置伙食费和公杂费行
+                        for (int i = 0; i < foodSundCosts.Count; i++)
+                        {
+                            var foodSundData = foodSundCosts[i];
+                            int startRow2 = startRow + i;
+
+                            // 插入数据到对应列
+                            worksheet.Cells[startRow2, startColumn].PutValue(foodSundData.PlaceName);        // 国家(地区)/城市
+                            worksheet.Cells[startRow2, startColumn + 1].PutValue(foodSundData.CurrencyName); // 币种
+                            worksheet.Cells[startRow2, startColumn + 2].PutValue(foodSundData.Cost);         // 标准
+                            worksheet.Cells[startRow2, startColumn + 3].PutValue(personCount);               // 人数
+                            worksheet.Cells[startRow2, startColumn + 4].PutValue(foodSundData.TotalDays);    // 天数
+                            decimal totalAmount = foodSundData.TotalAmount * personCount;
+                            worksheet.Cells[startRow2, startColumn + 5].PutValue(totalAmount);               // 小计
+                            worksheet.Cells[startRow2, startColumn + 6].PutValue(foodSundData.CurrencyRate); // 汇率
+                            decimal totalCNY = totalAmount * foodSundData.CurrencyRate;                      
+                            foodSundTotalCny += totalCNY;
+                            worksheet.Cells[startRow2, startColumn + 7].PutValue(totalCNY);                  // 折合人民币(元)
+                        }
+
+                        //设置小计行 合计金额 固定单元格
+                        worksheet.Cells[15, startColumn + 7].PutValue(foodSundTotalCny);                     // 折合人民币(元)
+                        #endregion
+
+                        // 舱位费用合计
+                        decimal airTotal = 0.00M;
+                        // 舱位费用说明
+                        var airTotalLable = new StringBuilder();
+                        // 舱位人数说明
+                        var airPersonCountLable = new StringBuilder();
+                        airPersonCountLable.Append("人数:");
+                        #region 舱位费计算
+                        /*
+                         *  457	头等舱
+                         *  458	公务舱
+                         *  460	经济舱
+                         */
+
+                        var clientGroupBy = clientItems.GroupBy(x => x.AirType);
+
+                        foreach (var client in clientGroupBy)
+                        {
+                            if (client.Key == 457)
+                            {
+                                airTotal += (_EnterExitCosts.AirTD + _EnterExitCosts.CityTranffic2) * personCount;
+                                airTotalLable.Append($"头等舱:{_EnterExitCosts.AirTD:0.00}/人;城市间交通费:{_EnterExitCosts.CityTranffic2:0.00}/人;");
+                                airPersonCountLable.Append($"头等舱:{client.Count()} 人;");
+                            }
+                            else if (client.Key == 458)
+                            {
+                                airTotal += (_EnterExitCosts.AirGW + _EnterExitCosts.CityTranffic1) * personCount;
+                                airTotalLable.Append($"公务舱:{_EnterExitCosts.AirGW:0.00}/人;城市间交通费:{_EnterExitCosts.CityTranffic1:0.00}/人;");
+                                airPersonCountLable.Append($"公务舱:{client.Count()} 人;");
+                            }
+                            else if (client.Key == 460)
+                            {
+                                airTotal += (_EnterExitCosts.AirJJ + _EnterExitCosts.CityTranffic) * personCount;
+                                airTotalLable.Append($"经济舱:{_EnterExitCosts.AirJJ:0.00}/人;城市间交通费:{_EnterExitCosts.CityTranffic:0.00}/人;");
+                                airPersonCountLable.Append($"经济舱:{client.Count()} 人;");
+                            }
+                        }
+
+                        #endregion
+                        designer.SetDataSource("TotalAirLabel", $"4.国际旅费({airTotalLable}({airPersonCountLable}))");
+                        designer.SetDataSource("TotalAir", airTotal);
+
+                        // 其他费用合计
+                        decimal otherFeeTotal = 0.00M;
+                        // 其他费用说明
+                        var otherFeeTotalLabel = new StringBuilder();
+                        #region 其他费用
+                        if (_EnterExitCosts.Visa > 0)
+                        {
+                            otherFeeTotalLabel.Append($"签证费:{_EnterExitCosts.Visa:#0.00}元/人;");
+                            otherFeeTotal += _EnterExitCosts.Visa;
+                        }
+                        if (_EnterExitCosts.YiMiao > 0)
+                        {
+                            otherFeeTotalLabel.Append($"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元/人;");
+                            otherFeeTotal += _EnterExitCosts.YiMiao;
+                        }
+                        if (_EnterExitCosts.HeSuan > 0)
+                        {
+                            otherFeeTotalLabel.Append($"核酸费:{_EnterExitCosts.HeSuan:#0.00}元/人;");
+                            otherFeeTotal += _EnterExitCosts.HeSuan;
+                        }
+                        if (_EnterExitCosts.Safe > 0)
+                        {
+                            otherFeeTotalLabel.Append($"保险费:{_EnterExitCosts.Safe:#0.00}元/人;");
+                            otherFeeTotal += _EnterExitCosts.Safe;
+                        }
+                        if (_EnterExitCosts.Ticket > 0)
+                        {
+                            otherFeeTotalLabel.Append($"参展门票费:{_EnterExitCosts.Ticket:#0.00}元/人;");
+                            otherFeeTotal += _EnterExitCosts.Ticket;
+                        }
+                        if (_EnterExitCosts.Service > 0)
+                        {
+                            otherFeeTotalLabel.Append($"服务费:{_EnterExitCosts.Service:#0.00}元/人;");
+                            otherFeeTotal += _EnterExitCosts.Service;
+                        }
+
+                        #region 其他款项费用 选中时设置值
+
+                        if (_EnterExitCosts.ChoiceSix == 1)
+                        {
+                            foreach (var otherInfo in dac5)
+                            {
+                                otherFeeTotalLabel.Append($"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00}元/人;");
+                                otherFeeTotal += otherInfo.SubTotal;
+                            }
+                        }
+                        #endregion
+
+                        #endregion
+
+                        otherFeeTotal *= personCount;
+                        designer.SetDataSource("TotalOtherFeeLabel", $"5.其他费用({otherFeeTotalLabel}(人数:{personCount} 人;))");
+                        designer.SetDataSource("TotalOtherFee", otherFeeTotal);
+
+                        decimal total = accomFeeTotalCny + foodSundTotalCny + airTotal + otherFeeTotal;
+                        designer.SetDataSource("TotalFeeLabel", $"大写:{CommonFun.ToChinese(total)}整");
+                        designer.SetDataSource("TotalFee", total);
+                        designer.SetDataSource("ActualAmount", total);
+                        designer.Process();
+
+                        string filsPath = AppSettingsHelper.Get("WordBasePath") + $"ForeignReceivables/File/{clientItem.Key.Replace("\n", "")}_{_DelegationInfo.VisitCountry.Replace("|", "、")}_{DateTime.Now:yyyyMMddHHmmss}.xls";
+                        
+                        designer.Workbook.Save(filsPath);
+                        filesToZip.Add(filsPath);
+                    }
+
+                    //文件名
+                    string zipFileName = _DelegationInfo.TeamName + "-收款账单.zip";
+                    string zipPath = $"ForeignReceivables/File/{_DelegationInfo.TeamName}_收款账单_{DateTime.Now:yyyyMMddHHmmss}.zip";
+                    try
+                    {
+                        using (var zip = ZipFile.Open(AppSettingsHelper.Get("WordBasePath") + zipPath, ZipArchiveMode.Create))
+                        {
+                            foreach (var file in filesToZip)
+                            {
+                                zip.CreateEntryFromFile(file, Path.GetFileName(file));
+                            }
+                        }
+                    }
+                    catch (Exception ex)
+                    {
+                        return Ok(JsonView(false, ex.Message));
+                    }
+
+                    string url = AppSettingsHelper.Get("WordBaseUrl") + $"Office/Word/{zipPath}";
+
+                    return Ok(JsonView(true, "成功", new { Url = url }));
+                }
 
                 return Ok(JsonView(false));
             }
@@ -1613,6 +2104,28 @@ namespace OASystem.API.Controllers
             }
         }
 
+        /// <summary>
+        /// 获取三公费用标准city
+        /// </summary>
+        /// <param name="placeData"></param>
+        /// <param name="nationalTravelFeeId"></param>
+        /// <returns></returns>
+        private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
+        {
+            string _city = string.Empty;
+
+            if (placeData.Count < 1) return _city;
+
+            var data = placeData.Find(it => it.Id == nationalTravelFeeId);
+            if (data == null) return _city;
+
+            string country = data.Country;
+            string city = data.City;
+            if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
+            else _city = city;
+            return _city;
+        }
+
         /// <summary>
         /// decimal保留指定位数小数
         /// </summary>
@@ -2280,12 +2793,12 @@ namespace OASystem.API.Controllers
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> PostAmountReceivedAddOrEdit(AmountReceivedAddOrEditDto dto)
         {
-            if (dto == null || dto._ProceedsReceivedInfos == null || dto._ProceedsReceivedInfos.Count < 1)
-            {
-                return Ok(JsonView(false, "参数不能为空!"));
-            }
+            //if (dto == null || dto._ProceedsReceivedInfos == null || dto._ProceedsReceivedInfos.Count < 1)
+            //{
+            //    return Ok(JsonView(false, "参数不能为空!"));
+            //}
 
-            Result ffrData = await _proceedsReceivedRep.PostAmountReceivedAddOrEditDto(dto);
+            Result ffrData = await _proceedsReceivedRep.PostAmountReceivedAddOrEdit(dto);
 
             #region 判断金额是否收完
 

+ 8 - 5
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -13978,13 +13978,13 @@ FROM
 
                 //数据源
                 // 住宿费
-                var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList();
+                var dac1 = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).ToList() : new List<Grp_DayAndCost>();
                 // 伙食费
-                var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList();
+                var dac2 = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).ToList() : new List<Grp_DayAndCost>();
                 // 公杂费
-                var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList();
+                var dac3 = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).ToList() : new List<Grp_DayAndCost>();
                 // 培训费
-                var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList();
+                var dac4 = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).ToList() : new List<Grp_DayAndCost>();
                 // 其他款项费
                 var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
                     .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
@@ -15596,6 +15596,9 @@ FROM
                                 // 原始币种小计
                                 decimal totalAmount = group.Sum(x => x.Cost);
 
+                                // 原始伙食费、公杂费单价合计
+                                decimal cost = totalAmount / totalDays;
+
                                 // 人名币金额
                                 decimal totalCNY = totalDays * totalAmount * currencyRate;
 
@@ -15604,7 +15607,7 @@ FROM
                                     TravelFeeId = group.Key,
                                     PlaceName = placeName,
                                     TotalDays = totalDays,
-                                    currData.Cost,
+                                    Cost = cost,
                                     TotalAmount = totalAmount,
                                     currData.Currency,
                                     CurrencyCode = currencyCode,

+ 118 - 4
OASystem/OASystem.Api/Controllers/SearchController.cs

@@ -1,4 +1,5 @@
 using EyeSoft.Collections.Generic;
+using Humanizer;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using NPOI.SS.Formula.Functions;
@@ -9,8 +10,10 @@ using OASystem.Domain.AesEncryption;
 using OASystem.Domain.Entities.Customer;
 using OASystem.Domain.Entities.Financial;
 using OASystem.Domain.Entities.Groups;
+using OASystem.Domain.ViewModels.Groups;
 using OASystem.Domain.ViewModels.Search;
 using OASystem.Infrastructure.Repositories.CRM;
+using OASystem.Infrastructure.Repositories.Groups;
 using OASystem.Infrastructure.Repositories.System;
 using static iTextSharp.text.pdf.AcroFields;
 
@@ -24,18 +27,21 @@ namespace OASystem.API.Controllers
     public class SearchController : ControllerBase
     {
         private readonly SqlSugarClient _sqlSugar;
+        private readonly DelegationInfoRepository _groupRep;
         private readonly DynamicSearchService<Grp_DelegationInfo> _groupSearchService;
         private readonly DynamicSearchService<NewClientDataView> _clientSearchService;
-
         private readonly NewClientDataRepository _clientDataRepository;
+
         public SearchController(
             SqlSugarClient sqlSugar,
-           DynamicSearchService<Grp_DelegationInfo> groupSearchService,
-           DynamicSearchService<NewClientDataView> clientSearchService,
-           NewClientDataRepository clientDataRepository
+            DelegationInfoRepository groupRep,
+            DynamicSearchService<Grp_DelegationInfo> groupSearchService,
+            DynamicSearchService<NewClientDataView> clientSearchService,
+            NewClientDataRepository clientDataRepository
            )
         {
             _sqlSugar = sqlSugar;
+            _groupRep = groupRep;
             _groupSearchService = groupSearchService;
             _clientSearchService = clientSearchService;
             _clientDataRepository = clientDataRepository;
@@ -621,5 +627,113 @@ namespace OASystem.API.Controllers
                 return Ok(JsonView(false, "搜索服务暂时不可用,请稍后重试"));
             }
         }
+
+        /// <summary>
+        ///  三公-接团信息 关键字输入提示(单字段)
+        /// </summary>
+        /// <param name="currUserId">用户名称ID</param>
+        /// <param name="keyword">关键字</param>
+        /// <returns></returns>
+        [HttpGet("GroupEnterExitCostKeywordSearch/{currUserId}/{keyword}")]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> GroupEnterExitCostKeywordSearch(int currUserId,string keyword)
+        {
+            try
+            {
+                // 验证请求参数
+                if (currUserId < 1)
+                {
+                    return Ok(JsonView(true, $"请传入有效的用户ID!"));
+                }
+                if (string.IsNullOrEmpty(keyword))
+                {
+                    return Ok(JsonView(true, $"暂无数据!"));
+                }
+
+                var searchRequest = new DynamicSearchRequest
+                {
+                    Keyword = keyword,
+                    RequireAllSingleChars = true,
+                    PageIndex = 1,
+                    PageSize = 30,
+                    FieldWeights = new Dictionary<string, int>
+                    {
+                        { "TeamName", 10 },
+                        //{ "ClientUnit", 8 },
+                        //{ "ClientName", 6 }
+                    },
+                    Filters = new List<SearchFilter>()
+                    {
+                        new(){Field = "IsDel",Operator="eq",Value="0" }
+                    },
+                    OrderBy = "TeamName",
+                    ReturnFields = new List<string>() { "TeamName" }
+                };
+
+                // 验证字段配置
+                var validation = _groupSearchService.ValidateFieldConfig(
+                    searchRequest.FieldWeights,
+                    searchRequest.ReturnFields);
+
+                if (!validation.IsValid)
+                {
+                    return Ok(JsonView(true, $"暂无数据!{validation.Message}"));
+                }
+
+                var result = await _groupSearchService.SearchAsync(searchRequest);
+
+                if (result.Success)
+                {
+                    var groupIds = result.Items.Select(x => x.Data.Id).ToList();
+                    var isNullDatas = _sqlSugar.Queryable<Grp_EnterExitCost>()
+                        .Where(x => x.IsDel == 0 && groupIds.Contains(x.DiId))
+                        .Select(x => x.DiId)
+                        .Distinct()
+                        .ToList();
+                    var isViewDatas = _sqlSugar.Queryable<Grp_EnterExitCostPermission>()
+                        .Where(x1 => x1.IsDel == 0 && x1.UserId == currUserId && groupIds.Contains(x1.GroupId))
+                        .Select(x1 => x1.GroupId)
+                        .Distinct()
+                        .ToList();
+                    var provCityDatas = await _groupRep.ProvinceCityBasicSource();
+
+                    var data = result.Items.Select(x =>
+                    {
+                        int groupId = x.Data.Id;
+                        int cityId = x.Data.CityId;
+                        bool isNull = !isNullDatas.Where(x => x == groupId).Any();
+                        bool isView = isViewDatas.Where(x => x == groupId).Any();
+
+                        var provinceId = 122; //默认四川
+                        if (provinceId > 0)
+                        {
+                            var parentId = _groupRep.FindParentIdByChildId(provCityDatas, cityId);
+                            if (parentId != null)
+                            {
+                                provinceId = (int)parentId;
+                            }
+                        }
+
+                        return new
+                        {
+                            x.Data.Id,
+                            groupName = x.Data.TeamName,
+                            provinceId,
+                            isNull,
+                            isView,
+
+                        };
+                    }).ToList();
+
+                    return Ok(JsonView(true, result.Message, data, data.Count));
+                }
+
+                return Ok(JsonView(true, result.Message));
+            }
+            catch (Exception ex)
+            {
+                return Ok(JsonView(true, $"搜索服务暂时不可用!"));
+            }
+        }
     }
 }

+ 6 - 14
OASystem/OASystem.Infrastructure/Repositories/Financial/ProceedsReceivedRepository.cs

@@ -251,15 +251,15 @@ namespace OASystem.Infrastructure.Repositories.Financial
         /// </summary>
         /// <param name="diid"></param>
         /// <returns></returns>
-        public async Task<Result> PostAmountReceivedAddOrEditDto(AmountReceivedAddOrEditDto dto)
+        public async Task<Result> PostAmountReceivedAddOrEdit(AmountReceivedAddOrEditDto dto)
         {
             Result result = new() { Code = -2 };
 
-            if (dto._ProceedsReceivedInfos.Count <= 0)
-            {
-                result.Msg = "已收款项没有信息,不能进行,添加或修改操作!!!";
-                return result;
-            }
+            //if (dto._ProceedsReceivedInfos.Count <= 0)
+            //{
+            //    result.Msg = "已收款项没有信息,不能进行,添加或修改操作!!!";
+            //    return result;
+            //}
 
             int addCount = 0, updateCount = 0;
             if (dto.PortType == 1)
@@ -348,14 +348,6 @@ namespace OASystem.Infrastructure.Repositories.Financial
 
                 decimal balance = ((sum_fr + sum_extra) - (sum_pr - sum_refund));
 
-                if (balance <= 0)
-                {
-                    bool res = await UpdateAsync<Grp_DelegationInfo>(s => s.Id == dto.DiId, s => new Grp_DelegationInfo
-                    {
-                        IsSure = 1
-                    });
-                }
-
                 var updateGroup = await _sqlSugar.Updateable<Grp_DelegationInfo>()
                     .SetColumnsIF(balance <= 0, x => x.IsSure == 1)
                     .SetColumns( x => x.PrUnSettleReason == dto.UnSettleReason)