Browse Source

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

yuanrf 11 months ago
parent
commit
c6f57a093b

+ 789 - 8
OASystem/OASystem.Api/Controllers/FinancialController.cs

@@ -16,6 +16,14 @@ using OASystem.Infrastructure.Repositories.Groups;
 using SqlSugar;
 using StackExchange.Redis;
 using System.Data;
+using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
+using System.Web;
+using Aspose.Words;
+using NPOI.HSSF.Util;
+using OASystem.Domain.Entities.Customer;
+using System.IO.Compression;
+using NPOI.SS.UserModel;
+using System.Net.Http;
 
 namespace OASystem.API.Controllers
 {
@@ -29,6 +37,7 @@ namespace OASystem.API.Controllers
         private readonly IMapper _mapper;
         private readonly IConfiguration _config;
         private readonly SqlSugarClient _sqlSugar;
+        private readonly HttpClient _httpClient;
         private readonly SetDataTypeRepository _setDataTypeRep;
         private readonly DailyFeePaymentRepository _daiRep;    //日付申请仓库
         private readonly TeamRateRepository _teamRateRep;      //团组汇率仓库
@@ -41,7 +50,7 @@ namespace OASystem.API.Controllers
         /// </summary>
         public FinancialController(IMapper mapper, IConfiguration configuration, DailyFeePaymentRepository daiRep, SqlSugarClient sqlSugar, SetDataTypeRepository setDataTypeRep,
             TeamRateRepository teamRateRep, ForeignReceivablesRepository ForForeignReceivablesRep, ProceedsReceivedRepository proceedsReceivedRep,
-            PaymentRefundAndOtherMoneyRepository paymentRefundAndOtherMoneyRep)
+            PaymentRefundAndOtherMoneyRepository paymentRefundAndOtherMoneyRep, HttpClient httpClient)
         {
             _mapper = mapper;
             _config = configuration;
@@ -52,6 +61,7 @@ namespace OASystem.API.Controllers
             _ForForeignReceivablesRep = ForForeignReceivablesRep;
             _proceedsReceivedRep = proceedsReceivedRep;
             _paymentRefundAndOtherMoneyRep = paymentRefundAndOtherMoneyRep;
+            _httpClient = httpClient;
         }
 
         #region 日付申请
@@ -656,7 +666,6 @@ namespace OASystem.API.Controllers
             catch (Exception ex)
             {
                 return Ok(JsonView(false, ex.Message));
-                throw;
             }
         }
 
@@ -682,7 +691,6 @@ namespace OASystem.API.Controllers
             catch (Exception ex)
             {
                 return Ok(JsonView(false, ex.Message));
-                throw;
             }
         }
 
@@ -738,7 +746,426 @@ namespace OASystem.API.Controllers
             }
         }
 
+        /// <summary>
+        /// 已收账单 
+        /// File Downloasd
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> PostReceivablesFeilDownload(ForeignReceivablesFeilDownloadDto dto)
+        {
+            try
+            {
+                if (dto.DiId < 1)
+                {
+                    return Ok(JsonView(false, "请传入有效DiId参数!"));
+                }
+                if (dto.FileType < 1 || dto.FileType > 3)
+                {
+                    return Ok(JsonView(false, "请传入有效FileType参数! 1 生成收款单(四川)  2 生成收款单(北京)  3 汇款账单"));
+                }
+
+                var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
+                if (_DelegationInfo == null)
+                {
+                    return Ok(JsonView(false, "暂无团组信息!!"));
+                }
+
+                if (dto.FileType == 1 || dto.FileType == 2)
+                {
+                    var _ForeignReceivables = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
+                    if (_ForeignReceivables.Count < 1)
+                    {
+                        return Ok(JsonView(false, "暂无收款信息!!"));
+                    }
+
+                    string tempName = "";
+                    if (dto.FileType == 1) tempName = $"收款账单(四川)模板.docx";
+                    else if (dto.FileType == 2) tempName = $"收款账单(北京)模板.docx";
+
+
+
+                    string tempPath = AppSettingsHelper.Get("WordBasePath") + $"ForeignReceivables/Temp/{tempName}";
+                    //载入模板
+                    Document doc = new Document(tempPath);
+                    DocumentBuilder builder = new DocumentBuilder(doc);
+
+                    #region 替换Word模板书签内容
 
+                    //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
+                    //付款方
+                    if (doc.Range.Bookmarks["To"] != null)
+                    {
+                        Bookmark mark = doc.Range.Bookmarks["To"];
+                        mark.Text = _ForeignReceivables[0].To == null ? "" : _ForeignReceivables[0].To.ToString();
+                    }
+                    //付款方电话
+                    if (doc.Range.Bookmarks["ToTel"] != null)
+                    {
+                        Bookmark mark = doc.Range.Bookmarks["ToTel"];
+                        mark.Text = _ForeignReceivables[0].ToTel == null ? "" : _ForeignReceivables[0].ToTel.ToString();
+                    }
+                    //导出时间
+                    if (doc.Range.Bookmarks["Date"] != null)
+                    {
+                        Bookmark mark = doc.Range.Bookmarks["Date"];
+                        mark.Text = DateTime.Now.ToString("yyyy-MM-dd");
+                    }
+                    //注
+                    if (doc.Range.Bookmarks["Attention"] != null)
+                    {
+                        Bookmark mark = doc.Range.Bookmarks["Attention"];
+                        mark.Text = _ForeignReceivables[0].Attention == null ? "" : _ForeignReceivables[0].Attention.ToString();
+                    }
+
+                    //团队名称
+                    if (doc.Range.Bookmarks["Team"] != null)
+                    {
+                        Bookmark mark = doc.Range.Bookmarks["Team"];
+                        mark.Text = _DelegationInfo.VisitCountry == null ? "" : _DelegationInfo.VisitCountry.ToString();
+                    }
+
+                    //付款日期
+                    if (doc.Range.Bookmarks["PayDate"] != null)
+                    {
+                        Bookmark mark = doc.Range.Bookmarks["PayDate"];
+                        mark.Text = _ForeignReceivables[0].PayDate == null ? "" : Convert.ToDateTime(_ForeignReceivables[0].PayDate).ToString("yyyy年MM月dd日");
+                    }
+
+                    decimal sumPrice = 0;
+                    //各项费用
+                    if (doc.Range.Bookmarks["PayItemContent"] != null)
+                    {
+                        string items = "";
+                        foreach (var fr in _ForeignReceivables)
+                        {
+                            items += fr.PriceName + "   " + fr.Currency + " " + fr.Price.ToString("#0.00") + " * " + fr.Count + " " + fr.Unit + " * " + fr.Rate + ".................. RMB " + fr.ItemSumPrice.ToString("#0.00") + "\n";
+                            sumPrice += fr.ItemSumPrice;
+                        }
+                        Bookmark mark = doc.Range.Bookmarks["PayItemContent"];
+                        mark.Text = items;
+                    }
+                    //合计
+                    if (doc.Range.Bookmarks["Total"] != null)
+                    {
+                        Bookmark mark = doc.Range.Bookmarks["Total"];
+                        mark.Text = sumPrice.ToString("#0.00");
+                    }
+
+                    #endregion
+
+                    //文件名
+                    string strFileName = _DelegationInfo.TeamName + "-收款账单.docx";
+
+                    doc.Save(AppSettingsHelper.Get("WordBasePath") + "ForeignReceivables/File/" + strFileName);
+                    string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/ForeignReceivables/File/" + strFileName;
+
+                    return Ok(JsonView(true, "成功", new { Url = url }));
+                }
+                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).ToList();
+                    if (_EnterExitCosts == null)
+                    {
+                        return Ok(JsonView(false, "该团组未填写出入境费用;"));
+                    }
+
+                    //数据源
+                    List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
+                    List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
+                    List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
+                    List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).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
+                                                  {
+                                                      Name = dc.LastName + 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, "暂无团组成员,请先填写团组成员!!!"));
+                    }
+                    var _ClientNames = DeleClientList.Select(x => x.Name).ToList();
+                    var _GroupClient = DeleClientList.GroupBy(x => x.Company).ToList();
+
+
+                    Dictionary<string, string> bookmarkArr = null;
+
+                    string tempPath = AppSettingsHelper.Get("WordBasePath") + $"ForeignReceivables/Temp/汇款通知.docx";
+                    //载入模板
+                    Document doc = new Document(tempPath);
+                    DocumentBuilder builder = null;
+
+
+                    List<string> filesToZip = new List<string>();
+
+                    foreach (var ClientItem in _GroupClient) //遍历单位
+                    {
+                        doc = new Document(tempPath);
+                        builder = new DocumentBuilder(doc);
+                        Paragraph paragraph = new Paragraph(doc);
+
+                        bookmarkArr = new Dictionary<string, string>();
+                        bookmarkArr.Add("titleClientUnit", ClientItem.Key); //title单位
+                        bookmarkArr.Add("ClientUnit", ClientItem.Key); //单位
+                        bookmarkArr.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));//出发日期
+                        bookmarkArr.Add("name", string.Join(",", ClientItem.Select(x => x.Name).ToArray()).TrimEnd(','));//全部人员信息
+                        bookmarkArr.Add("VisitCountry", _DelegationInfo.VisitCountry);//出访国家
+                        bookmarkArr.Add("dayTime", DateTime.Now.ToString("yyyy年MM月dd日"));//今天日期
+
+                        var ClientItemList = ClientItem.ToList();
+                        string UsersTop = string.Empty;//word中人员以及金额
+                        decimal WordAllPrice = 0.00M;
+
+                        //int[] infoColumn = new int[5] {dac1.Select(x=>x.Place.Length).ToList().Max(),2, dac1.Select(x => x.Cost.Length).Max() + dac1.Select(x => x.Currency.Length).Max(),
+                        //    6, 3 + dac1.Where(x=>!string.IsNullOrWhiteSpace(x.Place)).Select(x=>(Convert.ToDecimal(x.SubTotal) / Convert.ToDecimal(x.Cost)).ToString().Length).Max() };
+
+                        //遍历人员
+                        for (int i = 0; i < ClientItemList.Count(); i++)
+                        {
+                            Dictionary<string, string> TeableBookmarkArr = new Dictionary<string, string>();
+                            var client = ClientItemList[i]; //每个人员
+                            var firstName = ClientItemList[i].Name;
+
+                            //计算费用总和
+                            decimal airPrice = client.AirType == 460 ? _EnterExitCosts.AirJJ : _EnterExitCosts.AirGW;
+                            decimal AllPrice = airPrice + _EnterExitCosts.CityTranffic + dac1.Sum(x => x.SubTotal) + dac2.Sum(x => x.SubTotal) + 
+                                               dac3.Sum(x => x.SubTotal) + dac4.Sum(x => x.SubTotal) + _EnterExitCosts.Visa + _EnterExitCosts.Safe + 
+                                               _EnterExitCosts.Service;
+                            WordAllPrice += AllPrice;
+
+                            UsersTop += firstName + "出访费用为¥" + AllPrice.ToString("#0.00") + "元、";
+
+                            TeableBookmarkArr.Add("jp",(client.AirType == 460 ? _EnterExitCosts.AirJJ : _EnterExitCosts.AirGW).ToString("#0.00") + " 元"); //机票金额
+                            TeableBookmarkArr.Add("cs", _EnterExitCosts.CityTranffic.ToString("#0.00") + " 元"); //城市交通费用
+                            TeableBookmarkArr.Add("zs", dac1.Sum(x => Convert.ToDecimal(x.SubTotal)).ToString("#0.00") + " 元"); //住宿费
+                            string zsinfo = string.Empty;
+                            string hsinfo = string.Empty;
+                            string gzinfo = string.Empty;
+                            List<string> placeArr = new List<string>();
+
+                            Aspose.Words.Tables.Table FirstTable = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, 0, true);
+                            Aspose.Words.Tables.Table ChildTable = (Aspose.Words.Tables.Table)FirstTable.GetChild(NodeType.Table, 0, true);
+                            Aspose.Words.Tables.Table ChildTable1 = (Aspose.Words.Tables.Table)FirstTable.GetChild(NodeType.Table, 1, true);
+                            Aspose.Words.Tables.Table ChildTable2 = (Aspose.Words.Tables.Table)FirstTable.GetChild(NodeType.Table, 2, true);
+
+                            int rowIndex = 0;
+                            foreach (var item in dac1)
+                            {
+                                if (string.IsNullOrWhiteSpace(item.Place))
+                                {
+                                    continue;
+                                }
+
+                                if (placeArr.Contains(item.Place))
+                                {
+                                    continue;
+                                }
+                                else
+                                {
+                                    placeArr.Add(item.Place);
+                                }
+                                if (!string.IsNullOrWhiteSpace(item.Place))
+                                {
+                                    if (rowIndex > ChildTable.Rows.Count - 1)
+                                    {
+                                        var chitableRow = ChildTable.LastRow.Clone(true);
+                                        ChildTable.AppendChild(chitableRow);
+                                    }
+                                    int days = dac1.FindAll(x => x.Place == item.Place).Count();
+                                    SetCells(ChildTable, doc, rowIndex, 0, item.Place);
+                                    SetCells(ChildTable, doc, rowIndex, 1, days + "晚");
+                                    SetCells(ChildTable, doc, rowIndex, 2, item.Cost + item.Currency + "/晚");
+                                    SetCells(ChildTable, doc, rowIndex, 3, " 汇率" + (item.SubTotal / item.Cost).ToString("#0.00"));
+                                    SetCells(ChildTable, doc, rowIndex, 4, "CNY" + item.SubTotal * days + "\r\n");
+                                    rowIndex++;
+                                    zsinfo += item.Place + "  " + days + "晚 " + item.Cost + item.Currency + "/晚" + " 汇率" + (item.SubTotal /item.Cost).ToString("#0.00") + "   CNY" + item.SubTotal * days + "\r\n";
+                                }
+
+                            }
+                            placeArr.Clear();
+                            rowIndex = 0;
+                            foreach (var item in dac2)
+                            {
+                                if (string.IsNullOrWhiteSpace(item.Place))
+                                {
+                                    continue;
+                                }
+
+                                if (placeArr.Contains(item.Place))
+                                {
+                                    continue;
+                                }
+                                else
+                                {
+                                    placeArr.Add(item.Place);
+                                }
+                                if (!string.IsNullOrWhiteSpace(item.Place))
+                                {
+                                    if (rowIndex > ChildTable1.Rows.Count - 1)
+                                    {
+                                        var chitableRow = ChildTable1.LastRow.Clone(true);
+                                        ChildTable1.AppendChild(chitableRow);
+                                    }
+                                    int days = dac2.FindAll(x => x.Place == item.Place).Count();
+                                    SetCells(ChildTable1, doc, rowIndex, 0, item.Place);
+                                    SetCells(ChildTable1, doc, rowIndex, 1, days + "天");
+                                    SetCells(ChildTable1, doc, rowIndex, 2, item.Cost + item.Currency + "/天");
+                                    SetCells(ChildTable1, doc, rowIndex, 3, " 汇率" + (item.SubTotal / item.Cost).ToString("#0.00"));
+                                    SetCells(ChildTable1, doc, rowIndex, 4, "CNY" +item.SubTotal * days);
+                                    rowIndex++;
+                                    hsinfo += item.Place + "  " + days + "天 " + item.Cost + item.Currency + "/天" + " 汇率" + (item.SubTotal / item.Cost).ToString("#0.00") + "   CNY" +item.SubTotal * days + "\r\n";
+                                }
+
+                            }
+                            placeArr.Clear();
+                            rowIndex = 0;
+                            foreach (var item in dac3)
+                            {
+                                if (string.IsNullOrWhiteSpace(item.Place))
+                                {
+                                    continue;
+                                }
+
+                                if (placeArr.Contains(item.Place))
+                                {
+                                    continue;
+                                }
+                                else
+                                {
+                                    placeArr.Add(item.Place);
+                                }
+                                if (!string.IsNullOrWhiteSpace(item.Place))
+                                {
+                                    if (rowIndex > ChildTable2.Rows.Count - 1)
+                                    {
+                                        var chitableRow = ChildTable2.LastRow.Clone(true);
+                                        ChildTable2.AppendChild(chitableRow);
+                                    }
+                                    int days = dac3.FindAll(x => x.Place == item.Place).Count();
+                                    SetCells(ChildTable2, doc, rowIndex, 0, item.Place);
+                                    SetCells(ChildTable2, doc, rowIndex, 1, days + "天");
+                                    SetCells(ChildTable2, doc, rowIndex, 2, item.Cost + item.Currency + "/天");
+                                    SetCells(ChildTable2, doc, rowIndex, 3, " 汇率" + (item.SubTotal / item.Cost).ToString("#0.00"));
+                                    SetCells(ChildTable2, doc, rowIndex, 4, "CNY" + item.SubTotal * days + "\r\n");
+                                    rowIndex++;
+                                    gzinfo += item.Place + "  " + days + "天 " + item.Cost + item.Currency + "/天" + " 汇率" + (item.SubTotal / item.Cost).ToString("#0.00") + "   CNY" + item.SubTotal * days + "\r\n";
+                                }
+
+                            }
+                            placeArr.Clear();
+                            TeableBookmarkArr.Add("zsinfo", zsinfo); //住宿费详情
+                            TeableBookmarkArr.Add("hs", dac2.Sum(x => Convert.ToDecimal(x.SubTotal)).ToString("#0.00") + " 元"); //伙食费
+                            TeableBookmarkArr.Add("hsinfo", hsinfo); //伙食费详情
+                            TeableBookmarkArr.Add("gz", dac3.Sum(x => Convert.ToDecimal(x.SubTotal)).ToString("#0.00") + " 元"); //公杂费
+                            TeableBookmarkArr.Add("gzinfo", gzinfo); //公杂费详情
+                            TeableBookmarkArr.Add("qt", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00") + " 元");//其他费用
+                            TeableBookmarkArr.Add("qtinfo", $"(签证费{_EnterExitCosts.Visa.ToString("#0.00")}元、保险{_EnterExitCosts.Safe.ToString("#0.00")}元等费用)");//其他费用第二列
+                            TeableBookmarkArr.Add("fw", _EnterExitCosts.Service.ToString("#0.00") + "元/人");//服务费
+                            TeableBookmarkArr.Add("AllPrice", AllPrice.ToString("#0.00") + "元/人");//表格合计费用
+                            string airStr = client.AirType == 460 ? "经济舱" : client.AirType == 458 ? "公务舱" : "";
+                            TeableBookmarkArr.Add("title", $"费用清单-{airStr}({firstName})");
+                            foreach (var book in TeableBookmarkArr.Keys)
+                            {
+
+                                if (doc.Range.Bookmarks[book] != null)
+                                {
+                                    Bookmark mark = doc.Range.Bookmarks[book];
+                                    mark.Text = TeableBookmarkArr[book];
+                                }
+                            }
+                            if (i != ClientItemList.Count - 1)
+                            {
+                                builder.PageSetup.Orientation = Aspose.Words.Orientation.Portrait;
+                                Aspose.Words.Tables.Table table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, 0, true);
+                                table.ParentNode.InsertAfter(paragraph, table);
+                                var CloneTable = (Aspose.Words.Tables.Table)table.Clone(true);
+                                table.ParentNode.InsertAfter(CloneTable, paragraph);
+                            }
+
+                            TeableBookmarkArr.Clear();
+                        }
+
+
+                        bookmarkArr.Add("VisitPrice", WordAllPrice.ToString());//出访费用总额
+                        bookmarkArr.Add("CnAllPrice", WordAllPrice.ConvertCNYUpper());//出访费用总额中文
+                        bookmarkArr.Add("namesPrice", UsersTop.TrimEnd('、'));//各人员出访费用  付辰同志出访费用为¥73,604.8元
+
+                        foreach (var book in bookmarkArr.Keys)
+                        {
+
+                            if (doc.Range.Bookmarks[book] != null)
+                            {
+                                Bookmark mark = doc.Range.Bookmarks[book];
+                                mark.Text = bookmarkArr[book];
+                            }
+                        }
+                        //MemoryStream outSteam = new MemoryStream();
+                        string filsPath = AppSettingsHelper.Get("WordBasePath") + $"ForeignReceivables/File/{ClientItem.Key}.docx";
+                        doc.Save(filsPath);
+                        filesToZip.Add(filsPath);
+                        //streams.Add(ClientItem.Key + ".docx", outSteam.ToArray());
+                    }
+
+                    //文件名
+                    string zipFileName = _DelegationInfo.TeamName + "-收款账单.zip";
+                    string zipPath =  $"ForeignReceivables/File/{_DelegationInfo.TeamName}-收款账单{DateTime.Now.ToString("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, "操作失败!"));
+            }
+            catch (Exception ex)
+            {
+                return Ok(JsonView(false, ex.Message));
+            }
+        }
+
+        private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
+        {
+            //获取table中的某个单元格,从0开始
+            Aspose.Words.Tables.Cell lshCell = table.Rows[rows].Cells[cells];
+            //将单元格中的第一个段落移除
+            lshCell.FirstParagraph.Remove();
+            //新建一个段落
+            Paragraph p = new Paragraph(doc);
+            var r = new Run(doc, val);
+            r.Font.Size = 8;
+            //把设置的值赋给之前新建的段落
+            p.AppendChild(r);
+
+            //将此段落加到单元格内
+            lshCell.AppendChild(p);
+        }
         #endregion
 
         #region 已收款项
@@ -1175,7 +1602,8 @@ namespace OASystem.API.Controllers
                     decimal sum_fr = 0M;
                     decimal sum_pr = 0M;
                     string str_client = string.Empty;
-                    decimal sum_other = 0M;
+                    decimal sum_other = 0M; //收款退还
+                    decimal sum_extra = 0M; //超支费用
                     decimal balance = 0M;
                     string str_schedule = string.Empty;
 
@@ -1207,17 +1635,24 @@ namespace OASystem.API.Controllers
                     List<Fin_OtherPrice> list_other = _sqlSugar.SqlQueryable<Fin_OtherPrice>(sql_other).ToList();
                     sum_other = list_other.Sum(s => s.Price);
 
-                    item_rst.frPrice = sum_fr.ToString("#0.00");
+                    //4.
+                    string sql_extra = string.Format(@" Select c.* From Fin_GroupExtraCost f 
+Inner join Grp_CreditCardPayment c On f.Id = c.CId 
+Where c.CTable = 1015 And c.IsPay = 1 And f.IsDel = 0 And c.IsDel = 0 And f.DiId = {0} ", diId);
+                    List<Grp_CreditCardPayment> list_extra = _sqlSugar.SqlQueryable<Grp_CreditCardPayment>(sql_extra).ToList();
+                    sum_extra = list_extra.Sum(s => s.RMBPrice);
+
+                    item_rst.frPrice = (sum_fr + sum_extra).ToString("#0.00");
                     item_rst.prPrice = (sum_pr - sum_other).ToString("#0.00");
-                    item_rst.balPrice = (sum_fr - (sum_pr - sum_other)).ToString("#0.00");
+                    item_rst.balPrice = ((sum_fr + sum_extra) - (sum_pr - sum_other)).ToString("#0.00");
                     item_rst.prClient = str_client;
                     item_rst.schedule = str_schedule;
 
                     string tempVisitDate = Convert.ToDateTime(item_rst.visitDate).ToString("yyyy-MM-dd");
 
-                    sumAll_fr += sum_fr;
+                    sumAll_fr += (sum_fr + sum_extra);
                     sumAll_pr += (sum_pr - sum_other);
-                    sumAll_balance += (sum_fr - (sum_pr - sum_other));
+                    sumAll_balance += ((sum_fr + sum_extra) - (sum_pr - sum_other));
 
                 }
 
@@ -1396,5 +1831,351 @@ namespace OASystem.API.Controllers
         }
 
         #endregion
+
+        #region 超支费用
+
+        /// <summary>
+        /// 超支费用
+        /// 1增、2改、3删
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> PostGroupExtraCost_Operator(Fin_GroupExtraCostDto_OP dto)
+        {
+            #region 验证
+
+            #endregion
+
+            Fin_GroupExtraCost _entity = new Fin_GroupExtraCost();
+            _entity.DiId = dto.diId;
+            _entity.PriceName = dto.priceName;
+            _entity.Price = dto.price;
+            _entity.PriceCurrency = dto.currency;
+            _entity.PriceType = dto.priceType;
+            _entity.Coefficient = dto.coefficient;
+            _entity.PriceDetailType = dto.priceDetailType;
+            _entity.FilePath = dto.filePath;
+            _entity.Remark = dto.remark;
+
+            _daiRep.BeginTran();
+            if (dto.editType == 1)
+            {
+                _entity.CreateUserId = dto.createUser;
+                _entity.CreateTime = DateTime.Now;
+                _entity.IsDel = 0;
+
+                int returnId = await _daiRep.AddAsyncReturnId<Fin_GroupExtraCost>(_entity);
+                if (returnId > 0)
+                {
+                    dto.Id = returnId;
+                }
+            }
+            else if (dto.editType == 2)
+            {
+                bool res = await _daiRep.UpdateAsync<Fin_GroupExtraCost>(s => s.Id == dto.Id, s => new Fin_GroupExtraCost
+                {
+                    PriceName = dto.priceName,
+                    Price = dto.price,
+                    PriceCurrency = dto.currency,
+                    PriceType = dto.priceType,
+                    PriceDetailType = dto.priceDetailType,
+                    Coefficient = dto.coefficient,
+                    FilePath = dto.filePath,
+                    Remark = dto.remark
+                });
+                if (!res)
+                {
+                    _daiRep.RollbackTran();
+                    return Ok(JsonView(false, "2操作失败!"));
+                }
+            }
+            else if (dto.editType == 3)
+            {
+                string delTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
+                bool res = await _daiRep.UpdateAsync<Fin_GroupExtraCost>(s => s.Id == dto.Id, s => new Fin_GroupExtraCost
+                {
+                    IsDel = 1,
+                    DeleteTime = delTime,
+                    DeleteUserId = dto.createUser
+                });
+                if (!res)
+                {
+                    _daiRep.RollbackTran();
+                    return Ok(JsonView(false, "3操作失败!"));
+                }
+            }
+            else
+            {
+                _daiRep.RollbackTran();
+                return Ok(JsonView(false, "未知的editType"));
+            }
+
+            if (!extraCost_editCreditCardPayment(dto))
+            {
+                return Ok(JsonView(false, "ccp操作失败"));
+            }
+
+
+            _daiRep.CommitTran();
+            return Ok(JsonView(false, "操作成功"));
+        }
+
+        private bool extraCost_editCreditCardPayment(Fin_GroupExtraCostDto_OP costDto)
+        {
+            //设置团组汇率
+            decimal dcm_dayrate = 1M;
+            decimal dcm_rmbPrice = costDto.price;
+            int ispay = costDto.payType == 72 ? 1 : 0;
+
+            if (costDto.costSign != 3)
+            {
+                Grp_TeamRate tr = _daiRep.Query<Grp_TeamRate>(s => s.DiId == costDto.diId && s.CTable == 1015).First();
+
+                if (tr != null)
+                {
+                    if (costDto.currency == 49)
+                    {
+                        dcm_dayrate = tr.RateU;
+                        dcm_rmbPrice = dcm_rmbPrice * tr.RateU;
+                    }
+                    else if (costDto.currency == 51)
+                    {
+                        dcm_dayrate = tr.RateE;
+                        dcm_rmbPrice = dcm_rmbPrice * tr.RateE;
+                    }
+                }
+            }
+
+            Grp_CreditCardPayment ccp = _daiRep.Query<Grp_CreditCardPayment>(s => s.CId == costDto.Id && s.CTable == 1015).First();
+            if (ccp == null)
+            {
+                ccp = new Grp_CreditCardPayment();
+
+                ccp.PayDId = costDto.payType;// dto
+                ccp.ConsumptionPatterns = "";
+                ccp.ConsumptionDate = "";
+                ccp.CTDId = costDto.payCardId;// dto
+                ccp.BankNo = "";
+
+                ccp.CardholderName = "";
+                ccp.PayMoney = costDto.price;// dto
+                ccp.PaymentCurrency = costDto.currency;// dto
+                ccp.CompanyBankNo = "";
+                ccp.OtherBankName = "";
+
+                ccp.OtherSideNo = "";
+                ccp.OtherSideName = "";
+                ccp.Remark = "";
+                ccp.CreateUserId = costDto.createUser;
+                ccp.CreateTime = DateTime.Now;
+
+                ccp.MFOperator = 0;
+                ccp.MFOperatorDate = "";
+                ccp.IsAuditDM = 0;
+                ccp.AuditDMOperate = 0;
+                ccp.AuditDMDate = "";
+
+                ccp.IsAuditMF = 0;
+                ccp.AuditMFOperate = 0;
+                ccp.AuditMFDate = "";
+                ccp.IsAuditGM = 0;
+                ccp.AuditGMOperate = 0;
+
+                ccp.AuditGMDate = "";
+                ccp.IsPay = ispay; // upd
+                ccp.DIId = costDto.diId;// dto
+                ccp.CId = costDto.Id;// dto
+                ccp.CTable = 1015; //超支费用指向id
+
+                ccp.IsDel = 0;
+                ccp.PayPercentage = 100M;
+                ccp.PayThenMoney = 0M;
+                ccp.PayPercentageOld = 100M;
+                ccp.PayThenMoneyOld = 0M;
+
+                ccp.UpdateDate = "";
+                ccp.Payee = costDto.payee;// dto
+                ccp.OrbitalPrivateTransfer = costDto.costSign;// dto
+                ccp.ExceedBudget = 0;
+                ccp.DayRate = dcm_dayrate; //upd
+
+                ccp.RMBPrice = dcm_rmbPrice; //upd
+
+                int ccpInsertId = _daiRep.AddReturnId<Grp_CreditCardPayment>(ccp);
+                if (ccpInsertId > 0)
+                {
+                    return true;
+                }
+            }
+            else
+            {
+                if (costDto.editType == 2)
+                {
+                    bool res = _daiRep.Update<Grp_CreditCardPayment>(s => s.Id == ccp.Id, s => new Grp_CreditCardPayment
+                    {
+                        PayDId = costDto.payType,
+                        CTDId = costDto.payCardId,
+                        PayMoney = costDto.price,
+                        PaymentCurrency = costDto.currency,
+                        IsPay = ispay,
+
+                        Payee = costDto.payee,
+                        OrbitalPrivateTransfer = costDto.costSign,
+                        DayRate = dcm_dayrate,
+                        RMBPrice = dcm_rmbPrice
+                    });
+                    return res;
+                }
+                else if (costDto.editType == 3)
+                {
+                    string delTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
+                    bool res2 = _daiRep.Update<Grp_CreditCardPayment>(s => s.Id == ccp.Id, s => new Grp_CreditCardPayment
+                    {
+                        IsDel = 1,
+                        DeleteTime = delTime,
+                        DeleteUserId = costDto.createUser
+                    });
+                    return res2;
+                }
+            }
+
+
+            return false;
+        }
+
+        /// <summary>
+        /// 超支费用
+        /// 列表查询
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> PostGroupExtraCost_Search(Fin_GroupExtraCostDto_Search dto)
+        {
+            string sqlWhere = string.Format(@" And f.DiId = {0} ", dto.diId);
+            int startIndex = (dto.PageIndex - 1) * dto.PageSize + 1;
+            int endIndex = startIndex + dto.PageSize - 1;
+            string sql_data = string.Format(@"Select * From (	
+                                                Select row_number() over (order by f.Id Desc) as RowNumber,f.Id,f.DiId,
+												f.PriceName,f.Price,f.FilePath,f.CreateUserId,f.CreateTime,c.IsAuditGM
+                                                From Fin_GroupExtraCost f
+                                                Inner Join Grp_CreditCardPayment c On f.Id = c.CId
+                                                Left Join Sys_Users u On f.CreateUserId = u.Id
+                                                Where f.IsDel=0 And c.CTable = 1015 {0}
+                                                ) temp Where RowNumber Between {1} and {2}", sqlWhere, startIndex, endIndex);
+            string sql_count = string.Format(@"Select Count(1) as DataCount From (	
+                                                Select row_number() over (order by f.Id Desc) as RowNumber,f.Id,f.DiId,
+												f.PriceName,f.PriceType,f.Price,f.FilePath,f.CreateUserId,f.CreateTime,c.IsAuditGM
+                                                From Fin_GroupExtraCost f
+                                                Inner Join Grp_CreditCardPayment c On f.Id = c.CId
+                                                Left Join Sys_Users u On f.CreateUserId = u.Id
+                                                Where f.IsDel=0 And c.CTable = 1015 {0}
+                                                ) temp ", sqlWhere);
+            if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
+            {
+                //Fin_DailyFeePaymentPageCount
+                var count = await _sqlSugar.SqlQueryable<Fin_GroupExtraCostViewDataCount>(sql_count).FirstAsync();
+                List<Fin_GroupExtraCostView> dataList = await _sqlSugar.SqlQueryable<Fin_GroupExtraCostView>(sql_data).ToListAsync();
+
+                Dictionary<int, string> dic_setData = new Dictionary<int, string>();
+                Dictionary<int, string> dic_user = new Dictionary<int, string>();
+
+                foreach (var item in dataList)
+                {
+                    //费用详细类型
+                    if (dic_setData.ContainsKey(item.PriceType))
+                    {
+                        item.PriceTypeStr = dic_setData[item.PriceType];
+                    }
+                    else
+                    {
+                        Sys_SetData sd_priceTypeDetail = _daiRep.Query<Sys_SetData>(s => s.Id == item.PriceType).First();
+                        if (sd_priceTypeDetail != null)
+                        {
+                            string tempName = sd_priceTypeDetail.Name.Replace("n", "");
+                            item.PriceTypeStr = tempName;
+                            dic_setData.Add(item.PriceType, tempName);
+                        }
+                    }
+
+                    //系统用户
+                    if (dic_user.ContainsKey(item.CreateUserId))
+                    {
+                        item.CreateUserIdStr = dic_setData[item.CreateUserId];
+                    }
+                    else
+                    {
+                        Sys_Users users = _daiRep.Query<Sys_Users>(s => s.Id == item.CreateUserId).First();
+                        if (users != null)
+                        {
+                            item.CreateUserIdStr = users.CnName;
+                            dic_setData.Add(item.CreateUserId, users.CnName);
+                        }
+                    }
+
+                    switch (item.IsAuditGM)
+                    {
+                        case 0: item.IsAuditGMStr = "未审核"; break;
+                        case 1: item.IsAuditGMStr = "已通过"; break;
+                        case 2: item.IsAuditGMStr = "未通过"; break;
+                        default: item.IsAuditGMStr = "未知状态"; break;
+                    }
+                }
+
+
+                var result = new ListViewBase<Fin_GroupExtraCostView>
+                {
+                    CurrPageIndex = dto.PageIndex,
+                    CurrPageSize = dto.PageSize,
+                    DataCount = count.DataCount,
+                    DataList = dataList
+                };
+
+                return Ok(JsonView(true, "查询成功", result));
+
+            }
+
+
+            return Ok(JsonView(false, "查询成功"));
+        }
+
+        /// <summary>
+        /// 超支费用
+        /// 数据集合配置
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> PostGroupExtraCost_ListDataInit(Fin_GroupExtraCostDto_DataListInit dto)
+        {
+            //支付方式
+            List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
+            List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
+
+            //超支费用类型
+            List<Sys_SetData> PriceType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 79 && a.IsDel == 0).ToList();
+            List<SetDataInfoView> _PriceType = _mapper.Map<List<SetDataInfoView>>(PriceType);
+
+            //超支费用详细类型
+            List<Sys_SetData> PriceDetailType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 80 && a.IsDel == 0).ToList();
+            PriceDetailType.ForEach(a => { a.Name = a.Name.Replace("n", ""); });
+            List<SetDataInfoView> _PriceDetailType = _mapper.Map<List<SetDataInfoView>>(PriceDetailType);
+
+            var data = new
+            {
+                Payment = _Payment,
+                PriceType = _PriceType,
+                PriceDetailType = _PriceDetailType
+            };
+
+
+            return Ok(JsonView(true, "", data));
+        }
+
+        #endregion
     }
 }

+ 16 - 13
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -3582,7 +3582,6 @@ namespace OASystem.API.Controllers
                     return Ok(JsonView(false, "该团组未填写出入境费用;"));
                 }
 
-
                 //数据源
                 List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
                 List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
@@ -3670,7 +3669,7 @@ namespace OASystem.API.Controllers
                             builder.Write("第" + dac1[i].Days.ToString() + "晚:");
 
                             builder.MoveToCell(0, i + 1, 1, 0);
-                            builder.Write(dac1[i].Place);
+                            builder.Write(dac1[i].Place == null ? "" : dac1[i].Place);
 
                             builder.MoveToCell(0, i + 1, 2, 0);
                             builder.Write("费用标准:");
@@ -3706,7 +3705,7 @@ namespace OASystem.API.Controllers
                             builder.Write("第" + dac2[i].Days.ToString() + "天:");
 
                             builder.MoveToCell(1, i + 1, 1, 0);
-                            builder.Write(dac2[i].Place);
+                            builder.Write(dac2[i].Place == null ? "" : dac1[i].Place);
 
                             builder.MoveToCell(1, i + 1, 2, 0);
                             builder.Write("费用标准:");
@@ -3742,7 +3741,7 @@ namespace OASystem.API.Controllers
                             builder.Write("第" + dac3[i].Days.ToString() + "天:");
 
                             builder.MoveToCell(2, i + 1, 1, 0);
-                            builder.Write(dac3[i].Place);
+                            builder.Write(dac3[i].Place == null ? "" : dac1[i].Place);
 
                             builder.MoveToCell(2, i + 1, 2, 0);
                             builder.Write("费用标准:");
@@ -3861,7 +3860,7 @@ namespace OASystem.API.Controllers
                             //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
                             //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name); 
                             builder.MoveToCell(0, accommodationStartIndex, 1, 0);
-                            builder.Write(dac.Place);//城市
+                            builder.Write(dac.Place == null ? "" : dac.Place);//城市
                             builder.MoveToCell(0, accommodationStartIndex, 2, 0);
 
                             string currency = _CurrDatas.Find(it => it.Id == dac.Currency).Name;
@@ -3883,12 +3882,12 @@ namespace OASystem.API.Controllers
                             builder.MoveToCell(0, accommodationStartIndex, 8, 0);
 
                             decimal rbmPrice = rate * dac.SubTotal;
-                            builder.Write(rbmPrice.ToString());//折合人民币
+                            builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
                             accommodationStartIndex++;
                             dac1totalPrice += rbmPrice;
                         }
 
-                        dic.Add("dac1totalPrice", dac1totalPrice.ToString());
+                        dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
 
                         for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
                         {
@@ -3915,7 +3914,7 @@ namespace OASystem.API.Controllers
                             }
 
                             builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
-                            builder.Write(dac.Place);//城市
+                            builder.Write(dac.Place == null ? "" : dac.Place);//城市
                             builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
                             string currency = _CurrDatas.Find(it => it.Id == dac.Currency).Name;
                             builder.Write(currency);//币种
@@ -4007,7 +4006,6 @@ namespace OASystem.API.Controllers
                             dic.Add("ReturnCode", "未录入行程!");
                         }
 
-                        dic.Add("ReturnCodeAir", dic["ReturnCode"]);
                         dic.Add("ReturnCodeAir", dic["ReturnCode"]);
                         dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
                         dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
@@ -4191,7 +4189,7 @@ namespace OASystem.API.Controllers
                     if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
                     {
                         //获取模板
-                        string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.xls");
+                        string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
                         //载入模板
                         Document doc = new Document(tempPath);
                         DocumentBuilder builder = new DocumentBuilder(doc);
@@ -4247,7 +4245,7 @@ namespace OASystem.API.Controllers
                     else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
                     {
                         //获取模板
-                        string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.xls");
+                        string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
                         //载入模板
                         Document doc = new Document(tempPath);
                         DocumentBuilder builder = new DocumentBuilder(doc);
@@ -4275,7 +4273,7 @@ namespace OASystem.API.Controllers
                             //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
                             //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name); 
                             builder.MoveToCell(0, accommodationStartIndex, 1, 0);
-                            builder.Write(dac.Place);//城市
+                            builder.Write(dac.Place == null ? "" : dac.Place);//城市
                             builder.MoveToCell(0, accommodationStartIndex, 2, 0);
 
                             string currency = _CurrDatas.Find(it => it.Id == dac.Currency).Name;
@@ -4320,7 +4318,7 @@ namespace OASystem.API.Controllers
                             }
 
                             builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
-                            builder.Write(dac.Place);//城市
+                            builder.Write(dac.Place == null ? "" : dac.Place);//城市
                             builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
 
                             string currency = _CurrDatas.Find(it => it.Id == dac.Currency).Name;
@@ -4369,6 +4367,11 @@ namespace OASystem.API.Controllers
                 {
                     if (dto.SubTypeId == 1) //团组成员名单
                     {
+                        if (DeleClientList.Count < 1)
+                        {
+                            return Ok(JsonView(false, "团组成员暂未录入!!!"));
+                        }
+
                         //获取模板
                         string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
                         //载入模板

+ 279 - 0
OASystem/OASystem.Api/OAMethodLib/GeneralMethod.cs

@@ -1,6 +1,7 @@
 
 using Microsoft.AspNetCore.SignalR;
 using Microsoft.International.Converters.PinYinConverter;
+using NPOI.HSSF.Util;
 using OASystem.API.OAMethodLib.Hub.HubClients;
 using OASystem.API.OAMethodLib.Hub.Hubs;
 using OASystem.API.OAMethodLib.JuHeAPI;
@@ -14,7 +15,9 @@ using OASystem.Domain.ViewModels.JuHeExchangeRate;
 using OASystem.Infrastructure.Repositories.CRM;
 using OASystem.Infrastructure.Repositories.Groups;
 using System.IdentityModel.Tokens.Jwt;
+using System.IO.Compression;
 using System.Security.Claims;
+using System.Web;
 
 namespace OASystem.API.OAMethodLib
 {
@@ -913,5 +916,281 @@ namespace OASystem.API.OAMethodLib
         }
 
         #endregion
+
+        #region 金额转大写
+        /// <summary>
+        /// 金额转换为大写数字
+        /// <para>1、支持的最大数字:999999999999.99(玖仟玖佰玖拾玖亿玖仟玖佰玖拾玖万玖仟玖佰玖拾玖元玖角玖分)</para>
+        /// <para>2、小数点后最多支持两位</para>
+        /// </summary>
+        /// <param name="num">数值</param>
+        /// <returns></returns>
+        public static string ConvertCNYUpper(this decimal num)
+        {
+            if (num == 0)
+            {
+                return "零元";
+            }
+            // 解决327000000转换后缺少单位万的问题
+            return ConvertToChinese(num);
+        }
+
+        #region 实例
+        /// <summary>
+        /// 要转换的数字
+        /// </summary>
+        private static decimal j;
+
+        /// <summary>
+        /// 
+        /// </summary>
+        private static string[] NumChineseCharacter = new string[] { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };
+
+        /// <summary>
+        /// 判断输入的数字是否大于double类型
+        /// </summary>
+        private static bool IsNumber
+        {
+            get
+            {
+                if (j > decimal.MaxValue || j <= 0)
+                    return false;
+                else
+                    return true;
+            }
+        }
+
+        /// <summary>
+        /// 数字转换成大写汉字主函数
+        /// </summary>
+        /// <returns>返回转换后的大写汉字</returns>
+        public static string ConvertToChinese(decimal m)
+        {
+            j = m;
+            string bb = "";
+            if (IsNumber)
+            {
+                string str = j.ToString();
+                string[] Num = str.Split('.');
+                if (Num.Length == 1)
+                {
+                    bb = NumberString(Num[0]) + "元整";
+                    bb = bb.Replace("零零", "零");
+                }
+                else
+                {
+                    bb = NumberString(Num[0]) + "元";
+                    bb += FloatString(Num[1]);
+                    bb = bb.Replace("零零", "零");
+                }
+            }
+            else
+            {
+                throw new FormatException("你输入的数字格式不正确或不是数字!");
+            }
+            return bb;
+        }
+        /// <summary>
+        /// 小数位转换只支持两位的小数
+        /// </summary>
+        /// <param name="Num">转换的小数</param>
+        /// <returns>小数转换成汉字</returns>
+        private static string FloatString(string Num)
+        {
+            string cc = "";
+            if (Num.Length > 2)
+            {
+                throw new FormatException("小数位数过多.");
+            }
+            else
+            {
+                string bb = ConvertString(Num);
+                int len = bb.IndexOf("零");
+                if (len != 0)
+                {
+                    bb = bb.Replace("零", "");
+                    if (bb.Length == 1)
+                    {
+                        cc = bb.Substring(0, 1) + "角";
+                    }
+                    else
+                    {
+                        cc = bb.Substring(0, 1) + "角";
+                        cc += bb.Substring(1, 1) + "分";
+                    }
+                }
+                else
+                    cc = bb + "分";
+            }
+            return cc;
+        }
+        /// <summary>
+        /// 判断数字位数以进行拆分转换
+        /// </summary>
+        /// <param name="Num">要进行拆分的数字</param>
+        /// <returns>转换成的汉字</returns>
+        private static string NumberString(string Num)
+        {
+            string bb = "";
+            if (Num.Length <= 4)
+            {
+                bb = Convert4(Num);
+            }
+            else if (Num.Length > 4 && Num.Length <= 8)
+            {
+                bb = Convert4(Num.Substring(0, Num.Length - 4)) + "万";
+                bb += Convert4(Num.Substring(Num.Length - 4, 4));
+            }
+            else if (Num.Length > 8 && Num.Length <= 12)
+            {
+                bb = Convert4(Num.Substring(0, Num.Length - 8)) + "亿";
+                if (Convert4(Num.Substring(Num.Length - 8, 4)) == "")
+                    if (Convert4(Num.Substring(Num.Length - 4, 4)) != "")
+                        bb += "零";
+                    else
+                        bb += "";
+                else
+                    bb += Convert4(Num.Substring(Num.Length - 8, 4)) + "万";
+                bb += Convert4(Num.Substring(Num.Length - 4, 4));
+            }
+            else
+            {
+                throw new Exception("整数部分最多支持12位");
+            }
+            return bb;
+        }
+        /// <summary>
+        /// 四位数字的转换
+        /// </summary>
+        /// <param name="Num">准备转换的四位数字</param>
+        /// <returns>转换以后的汉字</returns>
+        private static string Convert4(string Num)
+        {
+            string bb = "";
+            if (Num.Length == 1)
+            {
+                bb = ConvertString(Num);
+            }
+            else if (Num.Length == 2)
+            {
+                bb = ConvertString(Num);
+                bb = Convert2(bb);
+            }
+            else if (Num.Length == 3)
+            {
+                bb = ConvertString(Num);
+                bb = Convert3(bb);
+            }
+            else
+            {
+                bb = ConvertString(Num);
+                string cc = "";
+                string len = bb.Substring(0, 4);
+                if (len != "零零零零")
+                {
+                    len = bb.Substring(0, 3);
+                    if (len != "零零零")
+                    {
+                        bb = bb.Replace("零零零", "");
+                        if (bb.Length == 1)
+                        {
+                            bb = bb.Substring(0, 1) + "仟";
+                        }
+                        else
+                        {
+                            if (bb.Substring(0, 1) != "零" && bb.Substring(0, 2) != "零")
+                                cc = bb.Substring(0, 1) + "仟";
+                            else
+                                cc = bb.Substring(0, 1);
+                            bb = cc + Convert3(bb.Substring(1, 3));
+                        }
+                    }
+                    else
+                    {
+                        bb = bb.Replace("零零零", "零");
+                    }
+                }
+                else
+                {
+                    bb = bb.Replace("零零零零", "");
+                }
+            }
+            return bb;
+        }
+        /// <summary>
+        /// 将数字转换成汉字
+        /// </summary>
+        /// <param name="Num">需要转换的数字</param>
+        /// <returns>转换后的汉字</returns>
+        private static string ConvertString(string Num)
+        {
+            string bb = "";
+            for (int i = 0; i < Num.Length; i++)
+            {
+                bb += NumChineseCharacter[int.Parse(Num.Substring(i, 1))];
+            }
+            return bb;
+        }
+        /// <summary>
+        /// 两位数字的转换
+        /// </summary>
+        /// <param name="Num">两位数字</param>
+        /// <returns>转换后的汉字</returns>
+        private static string Convert2(string Num)
+        {
+            string bb = ""; string cc = "";
+            string len = Num.Substring(0, 1);
+            if (len != "零")
+            {
+                bb = Num.Replace("零", "");
+                if (bb.Length == 1)
+                {
+                    cc = bb.Substring(0, 1) + "拾";
+                }
+                else
+                {
+                    cc = bb.Substring(0, 1) + "拾";
+                    cc += bb.Substring(1, 1);
+                }
+            }
+            else
+                cc = Num;
+            return cc;
+        }
+        /// <summary>
+        /// 三位数字的转换
+        /// </summary>
+        /// <param name="Num">三位数字</param>
+        /// <returns>转换后的汉字</returns>
+        private static string Convert3(string Num)
+        {
+            string bb = ""; string cc = "";
+            string len = Num.Substring(0, 2);
+            if (len != "零零")
+            {
+                bb = Num.Replace("零零", "");
+                if (bb.Length == 1)
+                {
+                    bb = bb.Substring(0, 1) + "佰";
+                }
+                else
+                {
+                    if (bb.Substring(0, 1) != "零")
+                        cc = bb.Substring(0, 1) + "佰";
+                    else
+                        cc = bb.Substring(0, 1);
+                    bb = cc + Convert2(bb.Substring(1, 2));
+                }
+            }
+            else
+            {
+                bb = Num.Replace("零零", "零");
+            }
+            return bb;
+        }
+        #endregion
+
+        #endregion
+
     }
 }

+ 94 - 0
OASystem/OASystem.Domain/Dtos/Financial/Fin_GroupExtraCostDto.cs

@@ -0,0 +1,94 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Dtos.Financial
+{
+    public class Fin_GroupExtraCostDto_OP : PortDtoBase
+    {
+
+        /// <summary>
+        /// 1新增,2修改,3删除
+        /// </summary>
+        public int editType { get; set; }
+
+        public int Id { get; set; }
+        public int diId { get; set; }
+
+        /// <summary>
+        /// 费用名称
+        /// </summary>
+        public string priceName { get; set; }
+
+        /// <summary>
+        /// 金额
+        /// </summary>
+        public decimal price { get; set; }
+
+        /// <summary>
+        /// 费用类型Id
+        /// </summary>
+        public int priceType { get; set; }
+
+        /// <summary>
+        /// 费用详细类型Id
+        /// </summary>
+        public int priceDetailType { get; set; }
+
+        /// <summary>
+        /// 系数
+        /// </summary>
+        public decimal coefficient { get; set; }
+
+        /// <summary>
+        /// 费用币种
+        /// </summary>
+        public int currency { get; set; }
+
+        /// <summary>
+        /// 收款方
+        /// </summary>
+        public string payee { get; set; }
+
+        /// <summary>
+        /// 费用标识
+        /// </summary>
+        public int costSign { get; set; }
+
+        /// <summary>
+        /// 支付方式
+        /// </summary>
+        public int payType { get; set; }
+
+        /// <summary>
+        /// 卡类型,支付方式为刷卡时有效
+        /// </summary>
+        public int payCardId { get; set; }
+
+        /// <summary>
+        /// 附件路径
+        /// </summary>
+        public string filePath { get; set; }
+
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string remark { get; set; }
+
+        /// <summary>
+        /// 操作人员
+        /// </summary>
+        public int createUser { get; set; }
+    }
+
+    public class Fin_GroupExtraCostDto_Search : DtoBase
+    {
+        public int diId { get; set; }
+    }
+
+    public class Fin_GroupExtraCostDto_DataListInit : PortDtoBase
+    {
+    }
+}

+ 16 - 0
OASystem/OASystem.Domain/Dtos/Financial/ForForeignReceivablesNewDto.cs

@@ -118,4 +118,20 @@ namespace OASystem.Domain.Dtos.Financial
         public int Id { get; set; }
 
     }
+
+    /// <summary>
+    /// 文件下载 Dto
+    /// </summary>
+    public class ForeignReceivablesFeilDownloadDto
+    {
+        public int DiId { get; set; }
+
+        /// <summary>
+        /// 文件类型
+        /// 1 生成收款单(四川)
+        /// 2 生成收款单(北京)
+        /// 3 汇款账单
+        /// </summary>
+        public int FileType { get; set; }
+    }
 }

+ 35 - 0
OASystem/OASystem.Domain/ViewModels/Financial/Fin_GroupExtraCostView.cs

@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.ViewModels.Financial
+{
+    public class Fin_GroupExtraCostView
+    {
+        public int RowNumber { get; set; }
+        public int Id { get; set; }
+        public int DiId { get; set; }
+        public string PriceName { get; set; }
+        public int PriceType { get; set; }
+        public string PriceTypeStr { get; set; }
+        public decimal Price { get; set; }
+        public string FilePath { get; set; }
+        public int CreateUserId { get; set; }
+        public string CreateUserIdStr { get; set; }
+        public string CreateTime { get; set; }
+        public int IsAuditGM { get; set; }
+        public string IsAuditGMStr { get; set; }
+    }
+
+    public class Fin_GroupExtraCostViewDataCount
+    {
+        public int DataCount { get; set; }
+    }
+
+    public class Fin_GroupExtraCostView_List
+    {
+
+    }
+}

+ 26 - 0
OASystem/OASystem.Infrastructure/Repositories/BaseRepository.cs

@@ -132,6 +132,26 @@ namespace OASystem.Infrastructure.Repositories
             return _sqlSugar.Insertable(entity).ExecuteReturnIdentityAsync();
         }
 
+        /// <summary>
+        /// 添加返回主键Id(泛型)
+        /// </summary>
+        /// <param name="entity"></param>
+        /// <returns></returns>
+        public virtual Task<int> AddAsyncReturnId<T>(T entity) where T : EntityBase, new()
+        {
+            return _sqlSugar.Insertable<T>(entity).ExecuteReturnIdentityAsync();
+        }
+
+        /// <summary>
+        /// 添加返回主键Id(同步、泛型)
+        /// </summary>
+        /// <param name="entity"></param>
+        /// <returns></returns>
+        public virtual int AddReturnId<T>(T entity) where T : EntityBase, new()
+        {
+            return _sqlSugar.Insertable<T>(entity).ExecuteReturnIdentity();
+        }
+
         /// <summary>
         /// 删除单挑数据,加上删除者Id
         /// </summary>
@@ -262,6 +282,12 @@ namespace OASystem.Infrastructure.Repositories
             var result = await _sqlSugar.Updateable<T>().Where(wherexp).SetColumns(upexp).ExecuteCommandAsync();
             return result > 0;
         }
+
+        public virtual bool Update<T>(Expression<Func<T, bool>> wherexp, Expression<Func<T, T>> upexp) where T : EntityBase, new()
+        {
+            var result = _sqlSugar.Updateable<T>().Where(wherexp).SetColumns(upexp).ExecuteCommand();
+            return result > 0;
+        }
         public virtual async Task<bool> DeleteAsync<T>(Expression<Func<T, bool>> wherexp) where T : EntityBase, new()
         {
             var result = await _sqlSugar.Deleteable<T>().Where(wherexp).ExecuteCommandAsync();