Browse Source

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

yuanrf 3 weeks ago
parent
commit
92cccaecbf

+ 194 - 179
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -11,11 +11,13 @@ using MySqlX.XDevAPI.Relational;
 using NetUV.Core.Handles;
 using NPOI.HSSF.UserModel;
 using NPOI.POIFS.Crypt.Dsig;
+using NPOI.POIFS.Properties;
 using NPOI.SS.Format;
 using NPOI.SS.Formula.Functions;
 using NPOI.SS.UserModel;
 using NPOI.SS.Util;
 using NPOI.XSSF.UserModel;
+using OASystem.API.Middlewares;
 using OASystem.API.OAMethodLib;
 using OASystem.API.OAMethodLib.APNs;
 using OASystem.API.OAMethodLib.File;
@@ -1714,106 +1716,80 @@ FROM
                 if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
                 if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
 
-                PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
-
                 #region 页面操作权限验证
-                pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
+                var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
 
                 if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
                 #endregion
 
                 #endregion
 
-                Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
+                var _view = new Grp_CreditCardPaymentView();
 
-                List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
+                var clientNameList = getSimplClientList(_dto.DiId);
 
                 #region 费用清单
                 var exp = Expressionable.Create<Grp_CreditCardPayment>();
                 exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
                 exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
 
-                List<Grp_CreditCardPayment> entityList = _groupRepository
-                    .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
-                    .Where(exp.ToExpression())
-                    .ToList();
+                var entityList = _groupRepository .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
 
+                var detailList = new List<Grp_CreditCardPaymentDetailView>();
 
-                List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
-
-                List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
+                var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
 
                 /*
                  * 76://酒店预订
                  */
-
-                List<Grp_HotelReservations> _HotelReservations = await _groupRepository
-                                                                       .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
-                                                                       .ToListAsync();
-                List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
-                                                                       .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
-                                                                       .ToListAsync();
+                var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
+                var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
 
                 /*
                  * 79://车/导游地接
                  */
-                List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
-                                                                                                       .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
-                                                                                                       .ToListAsync();
-                List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
-                                                                     .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
-                                                                     .ToListAsync();
+                var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
+                var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
 
                 /*
                  * 80: //签证
                  */
-                List<Grp_VisaInfo> _VisaInfos = await _groupRepository
-                                                      .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
-                                                      .ToListAsync();
+                var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
 
                 /*
                  *81: //邀请/公务活动
                  */
-                List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
-                                                                                             .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
-                                                                                             .ToListAsync();
+                var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
 
                 /*
                  * 82: //团组客户保险
                  */
-                List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
-
+                var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
 
                 /*
                  *  Lable = 85 机票预订
                  */
-                List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
-                                                                                .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
-                                                                                .ToListAsync();
+                var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
 
                 /*
                  * 85 机票预定
                  */
-                List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
+                var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
 
                 /*
                 *  98 其他款项
                 */
-                List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
-                                                                    .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
-                                                                    .ToListAsync();
+                var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
 
                 /*
                  *  285:收款退还
                  */
-                List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
-                                                                                .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
-                                                                                .ToListAsync();
+                var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
+
                 /*
                  * 1015: //超支费用
                  */
-                List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
-
+                var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
 
                 /*
                  * 币种信息
@@ -1823,16 +1799,13 @@ FROM
                 /*
                  * 车/导游地接 费用类型
                  */
-
                 var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
 
-
                 /*
                  * 车/导游地接 费用类型
                  */
                 var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
 
-
                 var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
 
                 var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
@@ -1840,13 +1813,12 @@ FROM
                 /*
                  * 用户信息
                  */
-
                 var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
 
                 /*
                  * 费用模块
                  */
-                Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
+                var sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
                 string priceModule = string.Empty;
                 if (sdPriceName != null)
                 {
@@ -1881,7 +1853,7 @@ FROM
                  */
                 foreach (var entity in entityList)
                 {
-                    Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
+                    var _detail = new Grp_CreditCardPaymentDetailView();
 
                     _detail.Id = entity.Id;
 
@@ -1901,13 +1873,12 @@ FROM
                             entity.PayMoney = czInfo.Price * czInfo.PriceCount;
                             entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
                         }
-
                     }
 
                     /*
                      * 应付款金额	
                      */
-                    Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
+                    var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
                     string PaymentCurrency_WaitPay = "Unknown";
                     string hotelCurrncyCode = "Unknown";
                     string hotelCurrncyName = "Unknown";
@@ -1940,27 +1911,36 @@ FROM
                         {
                             CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
                         }
-
                     }
-                    if (_dto.Label == 79)
-                    {
-                        string original = string.Empty;
-                        if (hotelCurrncyCode.Equals("CNY"))
-                        {
-                            OriginalCurrPay = CurrPayStr;
-                            _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
-                        }
-                        else
-                        {
-                            OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
-                            //760 EUR(7600.00 CNY)
-                            _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
-                        }
+                    //if (_dto.Label == 79)
+                    //{
+                    //    string original = string.Empty;
+                    //    if (hotelCurrncyCode.Equals("CNY"))
+                    //    {
+                    //        OriginalCurrPay = CurrPayStr;
+                    //        _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
+                    //    }
+                    //    else
+                    //    {
+                    //        OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
+                    //        //760 EUR(7600.00 CNY)
+                    //        _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
+                    //    }
+
+                    //}
+                    //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
 
+                    string original = string.Empty;
+                    if (hotelCurrncyCode.Equals("CNY"))
+                    {
+                        OriginalCurrPay = CurrPayStr;
+                        _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
                     }
                     else
                     {
-                        _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
+                        OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
+                        //760 EUR(7600.00 CNY)
+                        _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
                     }
 
 
@@ -2151,7 +2131,7 @@ FROM
                                 string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
                                 _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
                                                           $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
-                                                          $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
+                                                          $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
                                                           $"房间说明: {hotelReservations.Remark} <br/>" +
                                                           $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr}  <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
                                                           $"{hotelBreakfastStr}" +
@@ -2398,7 +2378,7 @@ FROM
                      * 申请人
                      */
                     string operatorName = " - ";
-                    Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
+                    var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
                     if (_opUser != null)
                     {
                         operatorName = _opUser.CnName;
@@ -2409,13 +2389,11 @@ FROM
                     * 审核人
                     */
                     string auditOperatorName = "Unknown";
-                    if (entity.AuditGMOperate == 0)
-                        auditOperatorName = " - ";
-                    else if (entity.AuditGMOperate == 4)
-                        auditOperatorName = "自动审核";
+                    if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
+                    else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
                     else
                     {
-                        Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
+                        var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
                         if (_adUser != null)
                         {
                             auditOperatorName = _adUser.CnName;
@@ -2428,8 +2406,7 @@ FROM
                      */
                     string overBudgetStr = "";
 
-                    if (entity.ExceedBudget == -1)
-                        overBudgetStr = sdPriceName.Name + "尚无预算";
+                    if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
                     else if (entity.ExceedBudget == 0)
                     {
                         if (entity.CTable == 76 || entity.CTable == 79)
@@ -2442,17 +2419,26 @@ FROM
                             overBudgetStr = "未超预算";
                         }
                     }
-                    else
-                        overBudgetStr = entity.ExceedBudget.ToString("P");
-                    _detail.OverBudget = overBudgetStr;
+                    else overBudgetStr = entity.ExceedBudget.ToString("P");
 
+                    _detail.OverBudget = overBudgetStr;
 
-                    /*
-                     * 已审核金额
-                     */
-                    decimal auditFee = 0.00M;
-                    if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3) auditFee = CurrPayStr;
 
+                    decimal auditFee = 0.00M; //已审核金额 人名币
+                    decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
+                    decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
+                    decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
+                    if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
+                    {
+                        auditedFeeOriginal = entity.PayMoney;
+                        auditFee = CurrPayStr;
+                    }
+                    else if (entity.IsAuditGM == 0)
+                    {
+                        unAuditFeeCNY = CurrPayStr;
+                        unAuditFeeOriginal = OriginalCurrPay;
+                        OriginalCurrPay = 0.00M;
+                    }
                     /*
                      * 费用总计
                      */
@@ -2463,7 +2449,10 @@ FROM
                         AmountPayable = entity.PayMoney,
                         ThisPayment = OriginalCurrPay,
                         BalancePayment = BalanceStr,
-                        AuditedFunds = auditFee
+                        AuditedFunds = auditFee,
+                        AuditedFundsOriginal = auditedFeeOriginal,
+                        UnAuditFundsCNY = unAuditFeeCNY,
+                        UnAuditFundsOriginal = unAuditFeeOriginal
                     });
 
                     _detail.IsAuditGM = entity.IsAuditGM;
@@ -2499,35 +2488,43 @@ FROM
 
                 foreach (var item in nonDuplicat)
                 {
+                    var currencyName = item.CurrencyName;
                     var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
                     if (strs.Count > 0)
                     {
                         decimal amountPayable = strs.Sum(it => it.AmountPayable);
                         decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
                         decimal balancePayment = strs.Sum(it => it.BalancePayment);
-                        amountPayableStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", amountPayable.ToString("#0.00"), item.CurrencyName);
+                        amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
 
                         //单独处理此次付款金额
-                        if (item.CurrencyId == 836) //人民币
-                        {
-                            thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
-                        }
-                        else
-                        {
-                            thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
-                        }
+                        thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
 
-                        balancePaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", balancePayment.ToString("#0.00"), item.CurrencyName);
+                        balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
 
                         //单独处理已审核费用
-                        if (item.CurrencyId == 836) //人民币
+                        //if (item.CurrencyId == 836) //人民币
+                        //{
+                        //    decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
+                        //    auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
+                        //}
+                        //else
+                        //{
+                        //    auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
+                        //}
+                        if (currencyName.Equals("CNY"))
                         {
-                            decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
-                            auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
+                            //已审核费用
+                            auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AuditedFundsOriginal).ToString("#0.00"), currencyName);
+                            //未审核费用
+                            unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
                         }
                         else
                         {
-                            auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
+                            //已审核费用
+                            auditedFundsStr += string.Format(@"{0}{1}({2}CNY)&nbsp;|", strs.Sum(x => x.AuditedFundsOriginal).ToString("#0.00"), currencyName, strs.Sum(x => x.AuditedFunds).ToString("#0.00"));
+                            //未审核费用
+                            unAuditedFundsStr += string.Format(@"{0}{1}({2}CNY)&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName, strs.Sum(x => x.UnAuditFundsCNY).ToString("#0.00"));
                         }
                     }
                 }
@@ -2535,8 +2532,8 @@ FROM
                 _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
                 _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
                 _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
-                _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
-                _view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
+                _view.TotalStr4 = $"{auditedFundsStr.Substring(0, auditedFundsStr.Length - 1)}<br/>{unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1)}";
+                //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
 
 
                 var _view1 = new
@@ -5316,30 +5313,16 @@ FROM
         {
             try
             {
-                if (dto.DiId < 1)
-                {
-                    return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
-                }
-
-                if (dto.ExportType < 1)
-                {
-                    return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
-                }
-
-                if (dto.SubTypeId < 1)
-                {
-                    return Ok(JsonView(400, @"请传入有效的SubTypeId参数; 
+                if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
+                if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
+                if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数; 
                                                 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)  
                                                 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
                                                 3 团组成员名单 1 团组成员名单", ""));
-                }
 
                 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(400, "该团组未填写出入境费用;", ""));
-                }
+                if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
 
                 //数据源
                 var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
@@ -5347,37 +5330,37 @@ FROM
                 var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
                 var 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();                                       //其他款项费用
+                    .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 _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
                 var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
                 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 ClientInfo
-                                                      {
-                                                          LastName = dc.LastName,
-                                                          FirstName = dc.FirstName,
-                                                          Sex = dc.Sex,
-                                                          Birthday = dc.BirthDay,
-                                                          Company = cc.CompanyFullName,
-                                                          Job = dc.Job
-                                                      })
-                                                      .ToList();
+                    .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 ClientInfo
+                    {
+                        LastName = dc.LastName,
+                        FirstName = dc.FirstName,
+                        Sex = dc.Sex,
+                        Birthday = dc.BirthDay,
+                        Company = cc.CompanyFullName,
+                        Job = dc.Job
+                    })
+                    .ToList();
                 foreach (var item in DeleClientList)
                 {
                     EncryptionProcessor.DecryptProperties(item);
@@ -6723,10 +6706,7 @@ FROM
                 {
                     if (dto.SubTypeId == 1) //团组成员名单
                     {
-                        if (DeleClientList.Count < 1)
-                        {
-                            return Ok(JsonView(false, "团组成员暂未录入!!!", ""));
-                        }
+                        if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
 
                         //获取模板
                         string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
@@ -7146,7 +7126,7 @@ FROM
                 x.CreateUserId = _currUserInfo.UserId;
             });
 
-            if (data.Count > 0)
+            if (data.Any())
             {
                 var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
                 if (add > 0)
@@ -7424,9 +7404,10 @@ FROM
             if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
             if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
 
-            var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
+            var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
 
             var mobileInfo = new EnterExitCostMobileParentInfoView();
+            mobileInfo.DiId = dto.DiId;
             if (eecInfo == null) return Ok(mobileInfo);
 
             mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
@@ -7454,7 +7435,7 @@ FROM
             mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
             mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
             mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
-            mobileInfo.Currencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark);
+            mobileInfo.Currencys = CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark);
             mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
             mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal);  //伙食费 2
             mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal);  //公杂费 3
@@ -7534,7 +7515,6 @@ FROM
                     AirGW = eecInfo.AirGW,
                     AirTD = eecInfo.AirTD,
                     CityTranffic = eecInfo.CityTranffic
-
                 };
                 return Ok(JsonView(twoData));
             }
@@ -7730,6 +7710,29 @@ FROM
             }
         }
 
+        /// <summary>
+        /// 验证出入境费用数据是否存在
+        /// 不存在添加
+        /// </summary>
+        /// <param name="diId"></param>
+        /// <param name="currUserId"></param>
+        /// <returns></returns>
+        /// <exception cref="CustomException"></exception>
+        private async Task<int> EnterExitCostVerifyIsNull(int diId,int currUserId)
+        {
+            var parentId = 0;
+
+            var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
+            if (info != null) parentId = info.Id;
+            else
+            {
+                int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId }).ExecuteReturnIdentityAsync();
+                if (addId < 1) throw new CustomException("出入境费用添加失败!");
+                parentId = addId;
+            }
+
+            return parentId;
+        }
 
         /// <summary>
         /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
@@ -7843,7 +7846,7 @@ FROM
             //汇率信息记录
             await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
 
-            return Ok(JsonView(true));
+            return Ok(JsonView(new { parentId = id }));
         }
 
         /// <summary>
@@ -7888,7 +7891,7 @@ FROM
                 if (upd < 1) return Ok(JsonView(false));
             }
 
-            return Ok(JsonView(true));
+            return Ok(JsonView(new { parentId = id }));
         }
 
         /// <summary>
@@ -7940,7 +7943,7 @@ FROM
                 if (upd < 1) return Ok(JsonView(false));
             }
 
-            return Ok(JsonView(true));
+            return Ok(JsonView(new { parentId = id }));
         }
 
         /// <summary>
@@ -7957,12 +7960,12 @@ FROM
 
             var info = _mapper.Map<Grp_EnterExitCost>(dto);
             info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
-            
+
             int id = dto.Id;
             if (id <= 0) //add 
             {
                 info.CreateUserId = dto.CurrUserId;
-                var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
+                var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
 
                 if (add < 1) return Ok(JsonView(false));
                 id = add;
@@ -7990,7 +7993,7 @@ FROM
             //消息通知
             await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
 
-            return Ok(JsonView(new { itemTotal = info.InsidePay }));
+            return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
         }
 
         /// <summary>
@@ -8006,29 +8009,37 @@ FROM
             if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
 
             var info = _mapper.Map<Grp_EnterExitCost>(dto);
-            info.AirJJC_Checked = dto.ChoiceTwoJJ;
-            info.AirGWC_Checked = dto.ChoiceTwoGW;
-            info.AirTDC_Checked = dto.ChoiceTwoTD;
+
+            info.OutsideJJPay = dto.OutsideJJPay;
+            info.OutsideGWPay = dto.OutsideGWPay;
+            info.OutsideTDPay = dto.OutsideTDPay;
+            info.AirJJ = dto.AirJJ;
+            info.AirGW = dto.AirGW;
+            info.AirTD = dto.AirTD;
+            info.CityTranffic = dto.CityTranffic;
+            info.SumJJC = dto.ChoiceTwoJJ;
+            info.SumGWC = dto.ChoiceTwoGW;
+            info.SumTDC = dto.ChoiceTwoTD;
 
             int id = dto.Id;
             decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
             if (id <= 0) //add 
             {
                 info.CreateUserId = dto.CurrUserId;
-                var addInfo = await _sqlSugar.Insertable(info).ExecuteReturnEntityAsync();
+                var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
 
-                if (addInfo == null) return Ok(JsonView(false));
-                id = addInfo.Id;
+                if (addId <= 0) return Ok(JsonView(false));
+                id = addId;
             }
             else //update
             {
                 var upd = await _sqlSugar.Updateable(info)
                     .UpdateColumns(x => new {
-                        x.AirJJC_Checked,
+                        x.SumJJC,
                         x.OutsideJJPay,
-                        x.AirGWC_Checked,
+                        x.SumGWC,
                         x.OutsideGWPay,
-                        x.AirTDC_Checked,
+                        x.SumTDC,
                         x.OutsideTDPay,
                         x.AirJJ,
                         x.AirGW,
@@ -8050,6 +8061,7 @@ FROM
 
             return Ok(JsonView(new
             {
+                parentId = id,
                 choiceTwoJJ = dto.ChoiceTwoJJ,
                 jjcItemTotal = jjcItemTotal,
                 choiceTwoGW = dto.ChoiceTwoGW,
@@ -8146,12 +8158,15 @@ FROM
             subInfo.DiId = dto.DiId;
 
             if (feeType == 3) subInfo.Type = 1;
-            else if (feeType == 4) subInfo.Type = 1;
-            else if (feeType == 5) subInfo.Type = 1;
-            else if (feeType == 6) subInfo.Type = 1;
+            else if (feeType == 4) subInfo.Type = 2;
+            else if (feeType == 5) subInfo.Type = 3;
+            else if (feeType == 6) subInfo.Type = 4;
 
             subInfo.CreateUserId = dto.CurrUserId;
 
+            int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
+            if (parentId < 1) return Ok(JsonView(false));
+
             //子表op
             if (subId < 1)
             {
@@ -8176,11 +8191,9 @@ FROM
            
             var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
 
-            //消息通知
-            var parentId = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First().Id;
             await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
 
-            return Ok(JsonView(new { itemTotal = itemTotal }));
+            return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
         }
 
         /// <summary>
@@ -8261,6 +8274,9 @@ FROM
             subInfo.Diid = dto.Diid;
             subInfo.CreateUserId = dto.CurrUserId;
 
+            int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
+            if (parentId < 1) return Ok(JsonView(false));
+
             #region 子表op
             if (subId < 1)//add
             {
@@ -8288,10 +8304,9 @@ FROM
             var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
 
             //消息通知
-            var parentId = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).First().Id;
             await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
 
-            return Ok(JsonView(new { itemTotal = itemTotal }));
+            return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
         }
 
         /// <summary>

+ 1 - 2
OASystem/OASystem.Api/Controllers/ResourceController.cs

@@ -1362,7 +1362,6 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
 
         #region 商邀资料
 
-
         /// <summary>
         /// 商邀资料 基础数据源
         /// </summary>
@@ -1920,7 +1919,7 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
         }
 
         /// <summary>
-        /// 商邀资料 导入文件(Excel)模板下载 
+        /// 商邀资料 上传Excel文件添加 
         /// </summary>
         /// <param name="file"></param>
         /// <param name="currUserId"></param>

+ 1 - 2
OASystem/OASystem.Api/Controllers/StatisticsController.cs

@@ -2200,7 +2200,6 @@ ORDER BY
             return Ok(JsonView(true, "成功", url));
         }
 
-
         private void StatementExportExcelSetCell(WorkbookDesigner designer, Worksheet sheet,DataTable dt, Style style,string judgeLable,  int startIndex, string startRange,string endRange)
         {
             if (designer == null) return;
@@ -6173,7 +6172,7 @@ WHERE
         ///  团组数据统计
         ///  当前时间团组所在城市   
         /// </summary>
-        /// <param name="_dto"></param>
+        /// <param name="dto"></param>
         /// <returns></returns>
         [HttpPost("StatisticsNowCityOfGroup")]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]

+ 12 - 0
OASystem/OASystem.Api/Middlewares/CustomException.cs

@@ -0,0 +1,12 @@
+namespace OASystem.API.Middlewares
+{
+    /// <summary>
+    /// 自定义异常
+    /// </summary>
+    public class CustomException : Exception
+    {
+        public CustomException(string message) : base(message)
+        {
+        }
+    }
+}

+ 1 - 1
OASystem/OASystem.Api/OAMethodLib/GeneralMethod.cs

@@ -913,7 +913,7 @@ namespace OASystem.API.OAMethodLib
                                                      SpaceName = sd.Name
                                                  })
                                                  .ToListAsync();
-            if (groupClientList.Count < 1) return data;
+            if (!groupClientList.Any()) return data;
 
             decimal domesticFeeTotal = 0.00M,        //境内费用
                     economyClassFeeTotal = 0.00M,    //经济舱费用

+ 1 - 1
OASystem/OASystem.Domain/ViewModels/Groups/EnterExitCostView.cs

@@ -844,7 +844,7 @@ namespace OASystem.Domain.ViewModels.Groups
         ///  多个币种存储
         ///  存储方式: 美元(USD):6.2350|.......|墨西哥比索(MXN):1.0000
         /// </summary>
-        public List<CurrencyInfo>? Currencys { get; set; }
+        public List<CurrencyInfo> Currencys { get; set; } = new List<CurrencyInfo> { };
 
         #endregion
 

+ 16 - 2
OASystem/OASystem.Domain/ViewModels/Groups/Grp_CreditCardPaymentView.cs

@@ -101,7 +101,7 @@ namespace OASystem.Domain.ViewModels.Groups
         public string TotalStr2 { get; set; }
         public string TotalStr3 { get; set; }
         public string TotalStr4 { get; set; }
-        public string TotalStr5 { get; set; }
+        //public string TotalStr5 { get; set; }
     }
 
     public class Grp_CreditCardPaymentDetailView
@@ -209,8 +209,22 @@ namespace OASystem.Domain.ViewModels.Groups
         public decimal BalancePayment { get; set; }
 
         /// <summary>
-        /// 已审款项
+        /// 已审款项-人名币币种
         /// </summary>
         public decimal AuditedFunds { get; set; }
+
+        /// <summary>
+        /// 已审款项-原始币种
+        /// </summary>
+        public decimal AuditedFundsOriginal { get; set; }
+
+        /// <summary>
+        /// 未审核款项-原始金额
+        /// </summary>
+        public decimal UnAuditFundsOriginal { get; set; }
+        /// <summary>
+        /// 未审核款项-人名币
+        /// </summary>
+        public decimal UnAuditFundsCNY { get; set; }
     }
 }

+ 1 - 1
OASystem/OASystem.Infrastructure/Repositories/Groups/EnterExitCostRepository.cs

@@ -72,7 +72,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
         {
             var result = new JsonView() { Code = 400 , Msg = "暂无数据" };
 
-            var enterExitCostData = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
+            var enterExitCostData = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
 
             //Sys_PageFunctionPermission Function = _mapper.Map<Sys_PageFunctionPermission>(dto);