Browse Source

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

yuanrf 8 months ago
parent
commit
b86505935f

+ 233 - 182
OASystem/OASystem.Api/Controllers/FinancialController.cs

@@ -5824,13 +5824,19 @@ Group by PriceType ", dto.diId);
             _DailyFeePaymentResult.gz = _paymentDatas.Where(it => it.OrbitalPrivateTransfer == 0).Sum(it => ((it.PayMoney * it.DayRate) / 100) * it.PayPercentage); //公转
             _DailyFeePaymentResult.sz = _paymentDatas.Where(it => it.OrbitalPrivateTransfer == 1).Sum(it => ((it.PayMoney * it.DayRate) / 100) * it.PayPercentage); ; //私转
 
+
             #region 相关基础数据源
             var userDatas = _sqlSugar.Queryable<Sys_Users>().ToList();
             var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0).ToList();
             var countryFeeDatas = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
 
+            //76	酒店预订
             var hotelDatas = _sqlSugar.Queryable<Grp_HotelReservations>()
-                                      .Where(it => it.IsDel == 0 && _groupIds.Contains(it.DiId))
+                                      .InnerJoin<Grp_CreditCardPayment>((hr,ccp) => hr.Id == ccp.CId && 
+                                                                                    ccp.CTable == 76 &&
+                                                                                    ccp.IsDel == 0
+                                                                        )
+                                      .Where((hr, ccp) => hr.IsDel == 0 && _groupIds.Contains(hr.DiId) && ccp.IsAuditGM == 0)
                                       .ToList();
             var hotelContentDatas = _sqlSugar.Queryable<Grp_HotelReservationsContent>()
                                              .Where(it => it.IsDel == 0 && 
@@ -5839,29 +5845,69 @@ Group by PriceType ", dto.diId);
                                                           _groupIds.Contains(it.DiId)
                                                     )
                                              .ToList();
+            //79	车/导游地接
             var opDatas = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
-                                   .Where(it => it.IsDel == 0 && _groupIds.Contains(it.DiId))
+                                   .InnerJoin<Grp_CreditCardPayment>((ctggr, ccp) => ctggr.Id == ccp.CId &&
+                                                                                     ccp.CTable == 79 &&
+                                                                                     ccp.IsDel == 0
+                                                                    )
+                                   .Where((ctggr, ccp) => ctggr.IsDel == 0 && _groupIds.Contains(ctggr.DiId) && ccp.IsAuditGM == 0)
                                    .ToList();
+            // 80   签证
             var visaDatas = _sqlSugar.Queryable<Grp_VisaInfo>()
-                                     .Where(it => it.IsDel == 0 && _groupIds.Contains(it.DIId))
+                                     .InnerJoin<Grp_CreditCardPayment>((vi, ccp) => vi.Id == ccp.CId &&
+                                                                                    ccp.CTable == 80 &&
+                                                                                    ccp.IsDel == 0
+                                                                    )
+                                     .Where((vi, ccp) => vi.IsDel == 0 && _groupIds.Contains(vi.DIId) && ccp.IsAuditGM == 0)
                                      .ToList();
+            // 81	邀请/公务活动
             var ioaDatas = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>()
-                                    .Where(it => it.IsDel == 0 && _groupIds.Contains(it.DiId))
+                                    .InnerJoin<Grp_CreditCardPayment>((ioa, ccp) => ioa.Id == ccp.CId &&
+                                                                                    ccp.CTable == 81 &&
+                                                                                    ccp.IsDel == 0
+                                                                    )
+                                    .Where((ioa, ccp) => ioa.IsDel == 0 && _groupIds.Contains(ioa.DiId) && ccp.IsAuditGM == 0)
                                     .ToList();
+            // 82	团组客户保险
             var insureDatas = _sqlSugar.Queryable<Grp_Customers>()
-                                       .Where(it => it.IsDel == 0 && _groupIds.Contains(it.DiId))
+                                       .InnerJoin<Grp_CreditCardPayment>((c, ccp) => c.Id == ccp.CId &&
+                                                                                    ccp.CTable == 82 &&
+                                                                                    ccp.IsDel == 0
+                                                                         )
+                                       .Where((c, ccp) => c.IsDel == 0 && _groupIds.Contains(c.DiId) && ccp.IsAuditGM == 0)
                                        .ToList();
+            // 85	机票预订
             var airDatas = _sqlSugar.Queryable<Grp_AirTicketReservations>()
-                                    .Where(it => it.IsDel == 0 && _groupIds.Contains(it.DIId))
+                                    .InnerJoin<Grp_CreditCardPayment>((atr, ccp) => atr.Id == ccp.CId &&
+                                                                                    ccp.CTable == 85 &&
+                                                                                    ccp.IsDel == 0
+                                                                      )
+                                    .Where((atr, ccp) => atr.IsDel == 0 && _groupIds.Contains(atr.DIId) && ccp.IsAuditGM == 0)
                                     .ToList();
+            // 98	其他款项
             var otherMoneyDatas = _sqlSugar.Queryable<Grp_DecreasePayments>()
-                                           .Where(it => it.IsDel == 0 && _groupIds.Contains(it.DiId))
+                                           .InnerJoin<Grp_CreditCardPayment>((dp, ccp) => dp.Id == ccp.CId &&
+                                                                                          ccp.CTable == 98 &&
+                                                                                          ccp.IsDel == 0
+                                                                            )
+                                           .Where((dp, ccp) => dp.IsDel == 0 && _groupIds.Contains(dp.DiId) && ccp.IsAuditGM == 0)
                                            .ToList();
+            // 285 收款退还
             var refundPaymentDatas = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>()
-                                              .Where(it => it.IsDel == 0 && _groupIds.Contains(it.DiId))
+                                              .InnerJoin<Grp_CreditCardPayment>((prom, ccp) => prom.Id == ccp.CId &&
+                                                                                               ccp.CTable == 285 &&
+                                                                                               ccp.IsDel == 0
+                                                                               )
+                                              .Where((prom, ccp) => prom.IsDel == 0 && _groupIds.Contains(prom.DiId) && ccp.IsAuditGM == 0)
                                               .ToList();
+            // 1015	超支费用
             var extraCostDatas = _sqlSugar.Queryable<Fin_GroupExtraCost>()
-                                          .Where(it => it.IsDel == 0 && _groupIds.Contains(it.DiId))
+                                          .InnerJoin<Grp_CreditCardPayment>((gec, ccp) => gec.Id == ccp.CId &&
+                                                                                          ccp.CTable == 1015 &&
+                                                                                          ccp.IsDel == 0
+                                                                           )
+                                          .Where((gec, ccp) => gec.IsDel == 0 && _groupIds.Contains(gec.DiId) && ccp.IsAuditGM == 0)
                                           .ToList();
             #endregion
             //Expense company
@@ -5870,220 +5916,225 @@ Group by PriceType ", dto.diId);
                 var childList = new List<Group_DailyFeePaymentContentInfolView>();
 
                 var groupPaymentDatas = _paymentDatas.Where(it => groupInfo.Id == it.DIId).ToList();
-                int rouNumber = 1;
-                foreach (var payInfo in groupPaymentDatas)
-                {
-                    string priName = "-";
 
-                    string orbitalPrivateTransfer = payInfo.OrbitalPrivateTransfer == 0 ? "公转" : payInfo.OrbitalPrivateTransfer == 1 ? "私转" : "-";
-                    switch (payInfo.CTable)
+                if (groupPaymentDatas.Count > 0)
+                {
+                    int rouNumber = 1;
+                    foreach (var payInfo in groupPaymentDatas)
                     {
-                        case 76:  //76	酒店预订
-                            priName = $"[费用名称:{hotelDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.HotelName ?? ""}]";
-                            break;
-                        case 79:  //79	车/导游地接
-                            var opData = opDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id);
-                            if (opData != null)
-                            {
-                                string area = "";
-                                bool b = int.TryParse(opData.Area, out int areaId);
-                                if (b)
+                        string priName = "-";
+
+                        string orbitalPrivateTransfer = payInfo.OrbitalPrivateTransfer == 0 ? "公转" : payInfo.OrbitalPrivateTransfer == 1 ? "私转" : "-";
+                        switch (payInfo.CTable)
+                        {
+                            case 76:  //76	酒店预订
+                                priName = $"[费用名称:{hotelDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.HotelName ?? ""}]";
+                                break;
+                            case 79:  //79	车/导游地接
+                                var opData = opDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id);
+                                if (opData != null)
                                 {
-                                    string area1 = countryFeeDatas.Find(it => it.Id == areaId)?.Country ?? "-";
-                                    area = $"{area1}({setDatas.Find(it => it.Id == opData.PriceType)?.Name ?? "-"})";
-                                }
-                                else area = opData.Area;
+                                    string area = "";
+                                    bool b = int.TryParse(opData.Area, out int areaId);
+                                    if (b)
+                                    {
+                                        string area1 = countryFeeDatas.Find(it => it.Id == areaId)?.Country ?? "-";
+                                        area = $"{area1}({setDatas.Find(it => it.Id == opData.PriceType)?.Name ?? "-"})";
+                                    }
+                                    else area = opData.Area;
 
-                                string opPriName = "-";
-                                if (!string.IsNullOrEmpty(opData.PriceName)) opPriName = opData.PriceName;
+                                    string opPriName = "-";
+                                    if (!string.IsNullOrEmpty(opData.PriceName)) opPriName = opData.PriceName;
 
-                                area += $"({opPriName})";
+                                    area += $"({opPriName})";
 
-                                if (payInfo.OrbitalPrivateTransfer == 0) //公转
-                                {
-                                    priName = $"【{orbitalPrivateTransfer}】【导游: {opData.ServiceGuide} 】[费用名称:{area}]";
-                                }
-                                else if (payInfo.OrbitalPrivateTransfer == 1) //私转
-                                {
-                                    priName = $"【{orbitalPrivateTransfer}】【导游:{opData.ServiceGuide}】[费用名称:{area}]";
+                                    if (payInfo.OrbitalPrivateTransfer == 0) //公转
+                                    {
+                                        priName = $"【{orbitalPrivateTransfer}】【导游: {opData.ServiceGuide} 】[费用名称:{area}]";
+                                    }
+                                    else if (payInfo.OrbitalPrivateTransfer == 1) //私转
+                                    {
+                                        priName = $"【{orbitalPrivateTransfer}】【导游:{opData.ServiceGuide}】[费用名称:{area}]";
+                                    }
                                 }
-                            }
-                            break;
-                        case 80:  // 80   签证
+                                break;
+                            case 80:  // 80   签证
 
-                            string sql = string.Format("select b.Id,b.Pinyin,b.lastName,b.firstName,b.phone from  Grp_TourClientList a, Crm_DeleClient b where a.clientid = b.id and a.isdel = 0 and a.diid = {0}", groupInfo.Id);
-                            List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
+                                string sql = string.Format("select b.Id,b.Pinyin,b.lastName,b.firstName,b.phone from  Grp_TourClientList a, Crm_DeleClient b where a.clientid = b.id and a.isdel = 0 and a.diid = {0}", groupInfo.Id);
+                                List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
 
-                            string visaClientName = visaDatas.Find(it => payInfo.DIId == it.DIId && payInfo.CId == it.Id)?.VisaClient ?? "";
-                            string clientName = "-";
-                            if (Regex.Match(visaClientName, @"\d+,?").Value.Length > 0)
-                            {
-                                string[] temparr = visaClientName.Split(',');
-                                string fistrStr = temparr[0];
-                                int count = temparr.Count();
-
-                                int tempId;
-                                bool success = int.TryParse(fistrStr, out tempId);
-                                if (success)
+                                string visaClientName = visaDatas.Find(it => payInfo.DIId == it.DIId && payInfo.CId == it.Id)?.VisaClient ?? "";
+                                string clientName = "-";
+                                if (Regex.Match(visaClientName, @"\d+,?").Value.Length > 0)
                                 {
-                                    SimplClientInfo tempInfo = arr.FirstOrDefault(s => s.Id == tempId);
-                                    if (tempInfo != null)
+                                    string[] temparr = visaClientName.Split(',');
+                                    string fistrStr = temparr[0];
+                                    int count = temparr.Count();
+
+                                    int tempId;
+                                    bool success = int.TryParse(fistrStr, out tempId);
+                                    if (success)
                                     {
-                                        if (count > 1)
+                                        SimplClientInfo tempInfo = arr.FirstOrDefault(s => s.Id == tempId);
+                                        if (tempInfo != null)
                                         {
-                                            clientName = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
-                                        }
-                                        else
-                                        {
-                                            clientName = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
+                                            if (count > 1)
+                                            {
+                                                clientName = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
+                                            }
+                                            else
+                                            {
+                                                clientName = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
+                                            }
                                         }
                                     }
+                                    else
+                                    {
+                                        clientName = fistrStr;
+                                    }
                                 }
-                                else
-                                {
-                                    clientName = fistrStr;
-                                }
-                            }
 
-                            priName = $"[费用名称:{clientName}]";
-                            break;
-                        case 81:  // 81	邀请/公务活动
-                            priName = $"[费用名称:{ioaDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.Inviter ?? " -"}]";
-                            break;
-                        case 82:  // 82	团组客户保险
-                            priName = $"[费用名称:{insureDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.ClientName ?? " -"}]";
-                            break;
-                        case 85:  // 85	机票预订
-                            string flightsCode = airDatas.Find(it => payInfo.DIId == it.DIId && payInfo.CId == it.Id)?.FlightsCode ?? "-";
-                            string airPayType = setDatas.Find(it => it.Id == payInfo.PayDId)?.Name ?? "-";
-                            priName = $"{flightsCode}【{airPayType}】";
-                            break;
-                        case 98:  //  98	其他款项
-                            priName = $"[费用名称:{otherMoneyDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.PriceName ?? " -"}]";
-                            break;
-                        case 285:  //  285 收款退还
-                            priName = $"[费用名称:{refundPaymentDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.PriceName ?? " -"}]";
-                            break;
-                        case 1015:  //  1015	超支费用
-                            priName = $"[费用名称:{extraCostDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.PriceName ?? " -"}]";
-                            break;
-                        default:
-                            priName = "";
-                            break;
-                    }
+                                priName = $"[费用名称:{clientName}]";
+                                break;
+                            case 81:  // 81	邀请/公务活动
+                                priName = $"[费用名称:{ioaDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.Inviter ?? " -"}]";
+                                break;
+                            case 82:  // 82	团组客户保险
+                                priName = $"[费用名称:{insureDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.ClientName ?? " -"}]";
+                                break;
+                            case 85:  // 85	机票预订
+                                string flightsCode = airDatas.Find(it => payInfo.DIId == it.DIId && payInfo.CId == it.Id)?.FlightsCode ?? "-";
+                                string airPayType = setDatas.Find(it => it.Id == payInfo.PayDId)?.Name ?? "-";
+                                priName = $"{flightsCode}【{airPayType}】";
+                                break;
+                            case 98:  //  98	其他款项
+                                priName = $"[费用名称:{otherMoneyDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.PriceName ?? " -"}]";
+                                break;
+                            case 285:  //  285 收款退还
+                                priName = $"[费用名称:{refundPaymentDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.PriceName ?? " -"}]";
+                                break;
+                            case 1015:  //  1015	超支费用
+                                priName = $"[费用名称:{extraCostDatas.Find(it => payInfo.DIId == it.DiId && payInfo.CId == it.Id)?.PriceName ?? " -"}]";
+                                break;
+                            default:
+                                priName = "";
+                                break;
+                        }
 
+                        if (payInfo.CTable == 76) //酒店单独处理
+                        {
+                            var hotelContents = hotelContentDatas.Where(it => it.HrId == payInfo.CId);
+                            List<Group_DailyFeePaymentContentInfolView> childInfos = new List<Group_DailyFeePaymentContentInfolView>();
+                            foreach (var hotelContent in hotelContents)
+                            {
+                                string subPriceName = "";
+                                if (hotelContent.PriceType == 1) subPriceName = "房费";
+                                else if (hotelContent.PriceType == 2) subPriceName = "早餐";
+                                else if (hotelContent.PriceType == 3) subPriceName = "地税";
+                                else if (hotelContent.PriceType == 4) subPriceName = "城市税";
 
-                    bool status1 = false;
-                    if (_groupIds != null)
-                    {
-                        status1 = _groupIds.Contains(payInfo.Id);
-                    }
+                                if (string.IsNullOrEmpty(subPriceName)) subPriceName = priName;
+                                else subPriceName = $"{priName.Replace("]", "")}-{subPriceName}]";
 
-                    if (payInfo.CTable == 76) //酒店单独处理
-                    {
-                        var hotelContents = hotelContentDatas.Where(it => it.HrId == payInfo.CId);
-                        List<Group_DailyFeePaymentContentInfolView> childInfos = new List<Group_DailyFeePaymentContentInfolView>();
-                        foreach (var hotelContent in hotelContents)
-                        {
-                            string subPriceName = "";
-                            if (hotelContent.PriceType == 1) subPriceName = "房费";
-                            else if (hotelContent.PriceType == 2) subPriceName = "早餐";
-                            else if (hotelContent.PriceType == 3) subPriceName = "地税";
-                            else if (hotelContent.PriceType == 4) subPriceName = "城市税";
+                                string payeeStr1 = string.Format(@" {0},开户行:{1},银行卡号:{2} ",
+                                string.IsNullOrEmpty(hotelContent.Payee) ? "-" : hotelContent.Payee,
+                                string.IsNullOrEmpty(hotelContent.OtherBankName) ? "-" : hotelContent.OtherBankName,
+                                string.IsNullOrEmpty(hotelContent.OtherSideNo) ? "-" : hotelContent.OtherSideNo);
 
-                            if (string.IsNullOrEmpty(subPriceName)) subPriceName = priName;
-                            else subPriceName = $"{priName.Replace("]", "")}-{subPriceName}]";
+                                decimal _PaymentAmount1 = hotelContent.Price;//此次付款金额
+                                decimal _CNYSubTotalAmount1 = _PaymentAmount1 * hotelContent.Rate;//此次付款金额
+                                _CNYSubTotalAmount1 = Convert.ToDecimal(_CNYSubTotalAmount1.ToString("#0.00"));
 
-                            string payeeStr1 = string.Format(@" {0},开户行:{1},银行卡号:{2} ",
-                            string.IsNullOrEmpty(hotelContent.Payee) ? "-" : hotelContent.Payee,
-                            string.IsNullOrEmpty(hotelContent.OtherBankName) ? "-" : hotelContent.OtherBankName,
-                            string.IsNullOrEmpty(hotelContent.OtherSideNo) ? "-" : hotelContent.OtherSideNo);
+                                var childInfo1 = new Group_DailyFeePaymentContentInfolView()
+                                {
+                                    Id = payInfo.Id,
+                                    HotelSubId = hotelContent.Id,
+                                    Payee = payeeStr1,
+                                    RowNumber = rouNumber,
+                                    Applicant = userDatas.Find(it => it.Id == payInfo.CreateUserId)?.CnName ?? "",
+                                    ApplicantDt = payInfo.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
+                                    PayType = setDatas.Find(it => it.Id == hotelContent.PayDId)?.Name ?? "",
+                                    TransferMark = orbitalPrivateTransfer,
+                                    PriceName = subPriceName,
+                                    ModuleName = setDatas.Find(it => it.Id == payInfo.CTable)?.Name ?? "",
+                                    PayCurrCode = setDatas.Find(it => it.Id == hotelContent.Currency)?.Name ?? "",
+                                    PaymentAmount = _PaymentAmount1,
+                                    PayRate = hotelContent.Rate,
+                                    CNYSubTotalAmount = _CNYSubTotalAmount1,
+                                    AuditStatus = payInfo.IsAuditGM
+
+                                };
+                                string remaksDescription1 = $"【{childInfo1.PayType}】【{childInfo1.ModuleName}】{rouNumber}、[申请人:{childInfo1.Applicant}]{subPriceName}[收款方:{childInfo1.Payee}] {childInfo1.PayCurrCode} {_PaymentAmount1.ToString("#0.00")}、CNY:{childInfo1.CNYSubTotalAmount.ToString("#0.00")}(团组:{groupInfo.TeamName})";
+
+                                childInfo1.RemaksDescription = remaksDescription1;
+                                childInfos.Add(childInfo1);
+                                rouNumber++;
+                            }
 
-                            decimal _PaymentAmount1 = hotelContent.Price;//此次付款金额
-                            decimal _CNYSubTotalAmount1 = _PaymentAmount1 * hotelContent.Rate;//此次付款金额
-                            _CNYSubTotalAmount1 = Convert.ToDecimal(_CNYSubTotalAmount1.ToString("#0.00"));
+                            childList.AddRange(childInfos);
+                        }
+                        else
+                        {
+                            string payeeStr = string.Format(@" {0},开户行:{1},银行卡号:{2} ",
+                                string.IsNullOrEmpty(payInfo.Payee) ? "-" : payInfo.Payee,
+                                string.IsNullOrEmpty(payInfo.OtherBankName) ? "-" : payInfo.OtherBankName,
+                                string.IsNullOrEmpty(payInfo.OtherSideNo) ? "-" : payInfo.OtherSideNo);
 
-                            var childInfo1 = new Group_DailyFeePaymentContentInfolView()
+
+                            decimal _PaymentAmount = (payInfo.PayMoney / 100) * payInfo.PayPercentage;//此次付款金额
+                            decimal _CNYSubTotalAmount = _PaymentAmount * payInfo.DayRate;//此次付款金额
+                            _CNYSubTotalAmount = Convert.ToDecimal(_CNYSubTotalAmount.ToString("#0.00"));
+                            var childInfo = new Group_DailyFeePaymentContentInfolView()
                             {
-                                IsChecked = status1,
                                 Id = payInfo.Id,
-                                HotelSubId = hotelContent.Id,
-                                Payee = payeeStr1,
+                                Payee = payeeStr,
                                 RowNumber = rouNumber,
                                 Applicant = userDatas.Find(it => it.Id == payInfo.CreateUserId)?.CnName ?? "",
                                 ApplicantDt = payInfo.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
-                                PayType = setDatas.Find(it => it.Id == hotelContent.PayDId)?.Name ?? "",
+                                PayType = setDatas.Find(it => it.Id == payInfo.PayDId)?.Name ?? "",
                                 TransferMark = orbitalPrivateTransfer,
-                                PriceName = subPriceName,
+                                PriceName = priName,
                                 ModuleName = setDatas.Find(it => it.Id == payInfo.CTable)?.Name ?? "",
-                                PayCurrCode = setDatas.Find(it => it.Id == hotelContent.Currency)?.Name ?? "",
-                                PaymentAmount = _PaymentAmount1,
-                                PayRate = hotelContent.Rate,
-                                CNYSubTotalAmount = _CNYSubTotalAmount1,
+                                PayCurrCode = setDatas.Find(it => it.Id == payInfo.PaymentCurrency)?.Name ?? "",
+                                PaymentAmount = _PaymentAmount,
+                                PayRate = payInfo.DayRate,
+                                CNYSubTotalAmount = _CNYSubTotalAmount,
                                 AuditStatus = payInfo.IsAuditGM
-
                             };
-                            string remaksDescription1 = $"【{childInfo1.PayType}】【{childInfo1.ModuleName}】{rouNumber}、[申请人:{childInfo1.Applicant}]{subPriceName}[收款方:{childInfo1.Payee}] {childInfo1.PayCurrCode} {_PaymentAmount1.ToString("#0.00")}、CNY:{childInfo1.CNYSubTotalAmount.ToString("#0.00")}(团组:{groupInfo.TeamName})";
 
-                            childInfo1.RemaksDescription = remaksDescription1;
-                            childInfos.Add(childInfo1);
+                            string remaksDescription = $"【{childInfo.PayType}】【{childInfo.ModuleName}】{rouNumber}、[申请人:{childInfo.Applicant}]{priName}[收款方:{childInfo.Payee}] {childInfo.PayCurrCode} {_PaymentAmount.ToString("#0.00")}、CNY:{childInfo.CNYSubTotalAmount.ToString("#0.00")}(团组:{groupInfo.TeamName})";
+
+                            childInfo.RemaksDescription = remaksDescription;
+                            childList.Add(childInfo);
                             rouNumber++;
                         }
-
-                        childList.AddRange(childInfos);
                     }
-                    else
-                    {
-                        string payeeStr = string.Format(@" {0},开户行:{1},银行卡号:{2} ",
-                            string.IsNullOrEmpty(payInfo.Payee) ? "-" : payInfo.Payee,
-                            string.IsNullOrEmpty(payInfo.OtherBankName) ? "-" : payInfo.OtherBankName,
-                            string.IsNullOrEmpty(payInfo.OtherSideNo) ? "-" : payInfo.OtherSideNo);
 
-
-                        decimal _PaymentAmount = (payInfo.PayMoney / 100) * payInfo.PayPercentage;//此次付款金额
-                        decimal _CNYSubTotalAmount = _PaymentAmount * payInfo.DayRate;//此次付款金额
-                        _CNYSubTotalAmount = Convert.ToDecimal(_CNYSubTotalAmount.ToString("#0.00"));
-                        var childInfo = new Group_DailyFeePaymentContentInfolView()
-                        {
-                            IsChecked = status1,
-                            Id = payInfo.Id,
-                            Payee = payeeStr,
-                            RowNumber = rouNumber,
-                            Applicant = userDatas.Find(it => it.Id == payInfo.CreateUserId)?.CnName ?? "",
-                            ApplicantDt = payInfo.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
-                            PayType = setDatas.Find(it => it.Id == payInfo.PayDId)?.Name ?? "",
-                            TransferMark = orbitalPrivateTransfer,
-                            PriceName = priName,
-                            ModuleName = setDatas.Find(it => it.Id == payInfo.CTable)?.Name ?? "",
-                            PayCurrCode = setDatas.Find(it => it.Id == payInfo.PaymentCurrency)?.Name ?? "",
-                            PaymentAmount = _PaymentAmount,
-                            PayRate = payInfo.DayRate,
-                            CNYSubTotalAmount = _CNYSubTotalAmount,
-                            AuditStatus = payInfo.IsAuditGM
-                        };
-
-                        string remaksDescription = $"【{childInfo.PayType}】【{childInfo.ModuleName}】{rouNumber}、[申请人:{childInfo.Applicant}]{priName}[收款方:{childInfo.Payee}] {childInfo.PayCurrCode} {_PaymentAmount.ToString("#0.00")}、CNY:{childInfo.CNYSubTotalAmount.ToString("#0.00")}(团组:{groupInfo.TeamName})";
-
-                        childInfo.RemaksDescription = remaksDescription;
-                        //childList.Add(childInfo);
-                        rouNumber++;
-                    }
+                    CompanyInfo companyInfo = new CompanyInfo();
+                    companyInfo = ExpenseCompanyByTeamId(groupInfo.TeamDid);
+                    dataList.Add(new tree_Group_DailyFeePaymentPageListView()
+                    {
+                        Id = Guid.NewGuid().ToString("N"),
+                        GroupName = groupInfo.TeamName,
+                        CompanyId = companyInfo.Id,
+                        ConpanyName = companyInfo.ConpanyName,
+                        CNYTotalAmount = childList.Sum(it => it.CNYSubTotalAmount),
+                        ChildList = childList,
+                    });
                 }
-
-                CompanyInfo companyInfo = new CompanyInfo();
-                companyInfo = ExpenseCompanyByTeamId(groupInfo.TeamDid);
-                dataList.Add(new tree_Group_DailyFeePaymentPageListView()
+            }
+            var dataList1 = new List<tree_Group_DailyFeePaymentPageListView>();
+            //移除没有数据的团
+            foreach (var item in dataList)
+            {
+                if (item.CNYTotalAmount > 0 && item.ChildList.Count >0)
                 {
-                    Id = Guid.NewGuid().ToString("N"),
-                    GroupName = groupInfo.TeamName,
-                    CompanyId = companyInfo.Id,
-                    ConpanyName = companyInfo.ConpanyName,
-                    CNYTotalAmount = childList.Sum(it => it.CNYSubTotalAmount),
-                    ChildList = childList,
-                });
+                    dataList1.Add(item);
+                }
             }
 
-            _DailyFeePaymentResult.dataList = dataList;
+
+            _DailyFeePaymentResult.dataList = dataList1;
 
             jw.Code = StatusCodes.Status200OK;
             jw.Msg = $"操作成功!";

+ 0 - 2
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -1567,7 +1567,6 @@ namespace OASystem.API.Controllers
                      */
                     switch (entity.CTable)
                     {
-
                         case 76://酒店预订
                             Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
                             if (hotelReservations != null)
@@ -6386,7 +6385,6 @@ namespace OASystem.API.Controllers
         }
         #endregion
 
-
         #region 签证提成录入
 
         /// <summary>

+ 56 - 41
OASystem/OASystem.Api/Controllers/StatisticsController.cs

@@ -416,24 +416,61 @@ namespace OASystem.API.Controllers
 
                 //ccp.RMBPrice As CNYPrice
                 //(((ccp.PayMoney * ccp.DayRate) / ccp.PayPercentage) * 100) As CNYPrice
-                string hotelFeeSql = string.Format(@"Select hr.Id As HrId,hr.DiId As HrDiId,hr.City,hr.HotelName,hr.CheckInDate,hr.CheckOutDate,hr.CardPrice As RoomPrice,
-                                                     sd1.Name As PaymentCurrency,hr.SingleRoomPrice,hr.SingleRoomCount,hr.DoubleRoomPrice,
-                                                     hr.DoubleRoomCount,hr.SuiteRoomPrice,hr.SuiteRoomCount,hr.OtherRoomPrice,hr.OtherRoomCount,
-                                                     hr.BreakfastPrice,sd4.Name As BreakfastCurrency,hr.Isoppay,hr.GovernmentRent,
-                                                     sd5.Name As GovernmentRentCurrency,hr.CityTax,sd6.Name As CityTaxCurrency,
-                                                     ccp.PayMoney,(((ccp.PayMoney * ccp.DayRate) / ccp.PayPercentage) * 100) As CNYPrice,ccp.DayRate,ccp.Payee,ccp.OrbitalPrivateTransfer,
-                                                     sd2.Name As PayWay,sd3.Name As CardType,ccp.IsPay,u.CnName As Applicant
-                                                     From Grp_HotelReservations  hr
-                                                     Left Join Grp_CreditCardPayment ccp On hr.Id = ccp.CId
-                                                     Left Join Sys_SetData sd1 On ccp.PaymentCurrency = sd1.Id
-                                                     Left Join Sys_SetData sd2 On ccp.PayDId = sd2.Id
-                                                     Left Join Sys_SetData sd3 On ccp.CTDId = sd3.Id
-                                                     Left Join Sys_Users u On ccp.CreateUserId = u.Id
-                                                     Left Join Sys_SetData sd4 On hr.BreakfastCurrency = sd4.Id
-                                                     Left Join Sys_SetData sd5 On hr.GovernmentRentCurrency = sd5.Id
-                                                     Left Join Sys_SetData sd6 On hr.CityTaxCurrency = sd6.Id
-                                                     Where hr.IsDel = 0 And ccp.IsDel = 0 And ccp.CTable = 76 {1} And ccp.PayMoney<> 0 And hr.DiId = {0} 
-                                                     Order By CheckInDate Asc", _dto.DiId, _dto.isAudit ? "And ccp.IsAuditGM = 1" : " ");
+                string hotelFeeSql = string.Format(@"
+SELECT
+  hr.Id AS HrId,
+  hr.DiId AS HrDiId,
+  hr.City,
+  hr.HotelName,
+  hr.CheckInDate,
+  hr.CheckOutDate,
+  hr.CardPrice AS RoomPrice,
+  sd1.Name AS PaymentCurrency,
+  hr.SingleRoomPrice,
+  hr.SingleRoomCount,
+  hr.DoubleRoomPrice,
+  hr.DoubleRoomCount,
+  hr.SuiteRoomPrice,
+  hr.SuiteRoomCount,
+  hr.OtherRoomPrice,
+  hr.OtherRoomCount,
+  hr.BreakfastPrice,
+  sd4.Name AS BreakfastCurrency,
+  hr.Isoppay,
+  hr.GovernmentRent,
+  sd5.Name AS GovernmentRentCurrency,
+  hr.CityTax,
+  sd6.Name AS CityTaxCurrency,
+  ccp.PayMoney,
+  (
+    ((ccp.PayMoney * ccp.DayRate) / ccp.PayPercentage) * 100
+  ) AS CNYPrice,
+  ccp.PayPercentage,
+  ccp.DayRate,
+  ccp.Payee,
+  ccp.OrbitalPrivateTransfer,
+  sd2.Name AS PayWay,
+  sd3.Name AS CardType,
+  ccp.IsPay,
+  u.CnName AS Applicant
+FROM
+  Grp_HotelReservations hr
+  INNER JOIN Grp_CreditCardPayment ccp ON hr.Id = ccp.CId
+  LEFT JOIN Sys_SetData sd1 ON ccp.PaymentCurrency = sd1.Id
+  LEFT JOIN Sys_SetData sd2 ON ccp.PayDId = sd2.Id
+  LEFT JOIN Sys_SetData sd3 ON ccp.CTDId = sd3.Id
+  LEFT JOIN Sys_Users u ON ccp.CreateUserId = u.Id
+  LEFT JOIN Sys_SetData sd4 ON hr.BreakfastCurrency = sd4.Id
+  LEFT JOIN Sys_SetData sd5 ON hr.GovernmentRentCurrency = sd5.Id
+  LEFT JOIN Sys_SetData sd6 ON hr.CityTaxCurrency = sd6.Id
+WHERE
+  hr.IsDel = 0
+  AND ccp.IsDel = 0
+  AND ccp.CTable = 76 {1}
+  AND ccp.PayMoney <> 0
+  AND hr.DiId = {0}
+ORDER BY
+  CheckInDate Asc", _dto.DiId, _dto.isAudit ? "AND (ccp.IsAuditGM = 1 Or ccp.IsAuditGM = 3)" : " ");
 
                 groupHotelFeeViews = await _sqlSugar.SqlQueryable<GroupHotelFeeView>(hotelFeeSql).ToListAsync();
 
@@ -559,28 +596,6 @@ namespace OASystem.API.Controllers
 
                 List<GroupCTGGRFeeView> groupCTGGRFeeViews = new List<GroupCTGGRFeeView>();
 
-                //string CTGGRFeeSql = string.Format(@"Select ctggr.Id As CTGGRId,ctggr.DiId As CTGGRDiId,ctggr.PriceName As Area,ctggrc.*,ctggrc.Price As PayMoney,
-                //                                     sd2.name As PaymentCurrency,ccp.PayPercentage,
-                //                                     (ctggrc.Price / (ccp.PayPercentage / 100)) As AmountPaid,
-                //                                     (ctggrc.Price / (ccp.PayPercentage / 100) - ctggrc.Price) As BalancePayment,
-                //                                     ccp.DayRate,(ctggrc.Price * ccp.DayRate)  As CNYPrice,ccp.Payee,ccp.AuditGMDate,
-                //                                     ccp.OrbitalPrivateTransfer,sd1.Name As PayWay,ccp.IsPay,u.CnName As Applicant,ctggr.CreateTime
-                //                                     From Grp_CarTouristGuideGroundReservations ctggr
-                //                                     Left Join ( Select cggrc.CTGGRId,sd1.Name As PriceName,cggrc.Price,sd2.Name As PriceCurrency,
-                //                                                        cggrc.DatePrice,cggrc.PriceContent
-                //                                             From Grp_CarTouristGuideGroundReservationsContent cggrc
-                //                                             Left Join Sys_SetData sd1 On cggrc.SId = sd1.Id
-                //                                             Left Join Sys_SetData sd2 On cggrc.Currency = sd2.Id
-                //                                             Where cggrc.ISdel = 0 And cggrc.Price != 0.00 
-                //                                             ) ctggrc On ctggr.Id = ctggrc.CTGGRId 
-                //                                     Left Join Grp_CreditCardPayment ccp On ccp.IsDel = 0  And ccp.CTable = 79 And ctggr.Id = ccp.CId
-                //                                     Left Join Sys_SetData sd1 On ccp.PayDId = sd1.Id
-                //                                     Left Join Sys_SetData sd2 On ccp.PaymentCurrency = sd2.Id
-                //                                     Left Join Sys_Users u On ccp.CreateUserId = u.Id
-                //                                     Where ctggr.IsDel = 0 And ccp.IsAuditGM = 1 And ctggr.DiId = {0}
-                //                                     Order By CreateTime", _dto.DiId);
-
-
                 string CTGGRFeeSql = string.Format(@"Select ctggr.Id As CTGGRId,ctggr.DiId As CTGGRDiId,ctggr.PriceName As Area,ctggrc.*,ctggrc.Price As PayMoney,
                                                      sd2.name As PaymentCurrency,ccp.PayPercentage,
                                                      (ctggrc.Price * (ccp.PayPercentage / 100)) As AmountPaid,
@@ -600,7 +615,7 @@ namespace OASystem.API.Controllers
                                                      Left Join Sys_SetData sd2 On ccp.PaymentCurrency = sd2.Id
                                                      Left Join Sys_Users u On ccp.CreateUserId = u.Id
                                                      Where ctggr.IsDel = 0 {1} And ctggr.DiId = {0}
-                                                     Order By CreateTime", _dto.DiId, _dto.isAudit ? "And ccp.IsAuditGM = 1" : " ");
+                                                     Order By CreateTime", _dto.DiId, _dto.isAudit ? "And (ccp.IsAuditGM = 1 OR ccp.IsAuditGM = 3)" : " ");
 
                 groupCTGGRFeeViews = await _sqlSugar.SqlQueryable<GroupCTGGRFeeView>(CTGGRFeeSql).ToListAsync();
 

+ 3 - 1
OASystem/OASystem.Infrastructure/Repositories/Groups/FeeAuditRepository.cs

@@ -164,7 +164,9 @@ namespace OASystem.Infrastructure.Repositories.Groups
             else if (feeType == 2)
             {
                 //1.基础数据参数验证
-                var priceType = new List<int>() { 1062 };
+                var priceType = new List<int>() {
+                    1062  //1062	尾款
+                };
                 var opinfos = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
                                        .Where(x => x.IsDel == 0 && x.DiId == diId && x.Id == dataId && !priceType.Contains(x.PriceType))
                                        .First();

+ 3 - 0
OASystem/OASystem.Infrastructure/Repositories/Groups/HotelPriceRepository.cs

@@ -342,6 +342,9 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 _CreditCardPayment.PayThenMoney = _CreditCardPayment.PayMoney;
                 _CreditCardPayment.PayMoney = _dto.CardPrice;
                 _CreditCardPayment.PaymentCurrency = _dto.CardPriceCurrency;
+                decimal ccpRate = 1.0000M;
+                if (_dto.CardPriceCurrency != 836) ccpRate = _dto.Contents.Find(x => x.PriceType == 1)?.Rate ?? 1.0000M;
+                _CreditCardPayment.DayRate = ccpRate;
 
                 _CreditCardPayment.RMBPrice = (_CreditCardPayment.DayRate * _CreditCardPayment.PayMoney).DecimalsKeepTwo();