浏览代码

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

LEIYI 5 月之前
父节点
当前提交
3c87d68808

+ 88 - 5
OASystem/OASystem.Api/Controllers/FinancialController.cs

@@ -26,6 +26,7 @@ using System.Diagnostics;
 using System.Globalization;
 using System.IO.Compression;
 using NPOI.SS.Formula.Functions;
+using Org.BouncyCastle.Asn1.X509.Qualified;
 
 namespace OASystem.API.Controllers
 {
@@ -48,13 +49,15 @@ namespace OASystem.API.Controllers
         private readonly ProceedsReceivedRepository _proceedsReceivedRep;  //已收款项仓库
         private readonly PaymentRefundAndOtherMoneyRepository _paymentRefundAndOtherMoneyRep; //收款退还与其他款项 仓库
         private readonly DelegationInfoRepository _delegationInfoRep; //团组信息 仓库
+        private readonly ForeignReceivablesRepository _foreignReceivablesRepository;
 
         /// <summary>
         /// 初始化
         /// </summary>
         public FinancialController(IMapper mapper, IConfiguration configuration, DailyFeePaymentRepository daiRep, SqlSugarClient sqlSugar, SetDataTypeRepository setDataTypeRep,
             TeamRateRepository teamRateRep, ForeignReceivablesRepository ForForeignReceivablesRep, ProceedsReceivedRepository proceedsReceivedRep,
-            PaymentRefundAndOtherMoneyRepository paymentRefundAndOtherMoneyRep, HttpClient httpClient, DelegationInfoRepository delegationInfoRep, SetDataRepository setDataRep)
+            PaymentRefundAndOtherMoneyRepository paymentRefundAndOtherMoneyRep, HttpClient httpClient, DelegationInfoRepository delegationInfoRep, SetDataRepository setDataRep,
+            ForeignReceivablesRepository foreignReceivablesRepository)
         {
             _mapper = mapper;
             _config = configuration;
@@ -68,6 +71,7 @@ namespace OASystem.API.Controllers
             _httpClient = httpClient;
             _delegationInfoRep = delegationInfoRep;
             _setDataRep = setDataRep;
+            _foreignReceivablesRepository = foreignReceivablesRepository;
         }
 
         #region 日付申请
@@ -3151,6 +3155,8 @@ namespace OASystem.API.Controllers
             _entity.Remark = dto.remark;
             _entity.PriceCount = dto.PriceCount;
             _entity.Area = dto.Area;
+            _entity.SupervisorConfirm = dto.SupervisorConfirm;
+            _entity.ManagerConfirm = dto.ManagerConfirm;
 
             DateTime dt_PriceDt;
             bool b_PriceDt = DateTime.TryParse(dto.PriceDt, out dt_PriceDt);
@@ -3226,8 +3232,14 @@ namespace OASystem.API.Controllers
                 return Ok(JsonView(false, "ccp操作失败"));
             }
 
+            //同步修改收款账单
+            _foreignReceivablesRepository.OverSpSeteceivables(new OverSpSeteceivablesDto
+            {
+                CreateUserId = dto.createUser,
+                DiId = dto.diId,
+            });
 
-            _daiRep.CommitTran();
+        _daiRep.CommitTran();
             return Ok(JsonView(true, "操作成功"));
         }
 
@@ -3457,7 +3469,8 @@ namespace OASystem.API.Controllers
             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.PriceType,f.PriceDetailType,CAST(f.Price as varchar)+' '+s.[Name] as PriceStr,f.PriceCount,CAST(f.PriceSum as varchar)+' '+s.[Name] as PriceSumStr,
-                                                f.CreateUserId,f.PriceDt,c.IsAuditGM												
+                                                f.CreateUserId,f.PriceDt,c.IsAuditGM,f.ManagerConfirm,f.SupervisorConfirm,
+                                                CASE  ManagerConfirm WHEN 1 THEN '已确认' ELSE '未确认' END as 'ManagerConfirmStr' , CASE  SupervisorConfirm WHEN 1 THEN '已确认' ELSE '未确认' END  as 'SupervisorConfirmStr'														
                                                 From Fin_GroupExtraCost f
                                                 Inner Join Grp_CreditCardPayment c On f.Id = c.CId
                                                 Inner Join Sys_SetData s On f.PriceCurrency = s.Id
@@ -3466,7 +3479,8 @@ namespace OASystem.API.Controllers
                                                 ) 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
+												f.PriceName,f.PriceType,f.Price,f.FilePath,f.CreateUserId,f.CreateTime,c.IsAuditGM,f.ManagerConfirm,f.SupervisorConfirm,
+                                                CASE  ManagerConfirm WHEN 1 THEN '已确认' ELSE '未确认' END as 'ManagerConfirmStr' , CASE  SupervisorConfirm WHEN 1 THEN '已确认' ELSE '未确认' END  as 'SupervisorConfirmStr'
                                                 From Fin_GroupExtraCost f
                                                 Inner Join Grp_CreditCardPayment c On f.Id = c.CId
                                                 Inner Join Sys_SetData s On f.PriceCurrency = s.Id
@@ -3905,7 +3919,8 @@ Group by PriceType ", dto.diId);
                     JoinType.Left, s1.Id == l.toCurr && s1.IsDel == 0,
                     JoinType.Left, i.Id == l.DiId && i.IsDel == 0
                 ))
-                .Where((f, c, s, g) => f.IsDel == 0 && f.DiId == dto.diId)
+                .Where((f, c, s, g) => f.IsDel == 0 && f.DiId == dto.diId && 
+                    (f.ManagerConfirm == 1 ||  f.ManagerConfirm == null || f.SupervisorConfirm == 1 || f.SupervisorConfirm == null))
                 .Select((f, c, s, g, r, l, s1, i) => new
                 {
                     c.PaymentCurrency,
@@ -4178,6 +4193,74 @@ Group by PriceType ", dto.diId);
             return Ok(JsonView(true, "获取成功!", resultArr));
         }
 
+        /// <summary>
+        /// 退费确认
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost]
+        public IActionResult ReturnPremiumConfirm(ReturnPremiumConfirmDto dto)
+        {
+            var jw = JsonView(false);
+            var confirmStatusArr = new Dictionary<int, string>()
+            {
+                {1 ,"ManagerConfirm" },
+                {2 ,"SupervisorConfirm" },
+            };
+            if (dto.DataId < 1 || confirmStatusArr.Keys.Contains(dto.ConfirmId) == false)
+            {
+                jw.Msg = "参数有误!";
+                return Ok(jw);
+            }
+
+            Fin_GroupExtraCost fge = _sqlSugar.Queryable<Fin_GroupExtraCost>().First(it => it.Id == dto.DataId && it.IsDel == 0);
+
+            try
+            {
+                if (fge == null)
+                    throw new Exception("数据不存在!");
+
+                fge.GetType().GetProperty(confirmStatusArr[dto.ConfirmId]).SetValue(fge, dto.status);
+
+                var isSaveCollectionStatement = true;
+
+                //确认后,同步修改收款账单
+                foreach (var item in confirmStatusArr.Keys)
+                {
+                    var value = fge.GetType().GetProperty(confirmStatusArr[item]).GetValue(fge).ObjToInt();
+                    //if (value == 0)
+                    //{
+                    //    isSaveCollectionStatement = false;
+                    //    break;
+                    //}
+                }
+
+                _sqlSugar.BeginTran();
+
+                _sqlSugar.Updateable<Fin_GroupExtraCost>(fge).ExecuteCommand();
+
+                if (isSaveCollectionStatement)
+                {
+                    //同步修改收款账单
+                    _foreignReceivablesRepository.OverSpSeteceivables(new OverSpSeteceivablesDto
+                    {
+                        CreateUserId = fge.CreateUserId,
+                        DiId = fge.DiId,
+                    });
+                }
+            }
+            catch (Exception ex)
+            {
+                _sqlSugar.RollbackTran();
+                jw.Msg = "Error! " + ex.Message;
+                return Ok(jw);
+            }
+
+            _sqlSugar.CommitTran();
+            jw = JsonView(true, "操作成功!");
+
+            return Ok(jw);
+        }
+
         #endregion
 
         #region 信用卡对账

+ 8 - 0
OASystem/OASystem.Api/Controllers/ResourceController.cs

@@ -1525,6 +1525,9 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> QueryInvitationOfficialActivityData(QueryInvitationOfficialActivityDataDto dto)
         {
+
+            var ExcludedKeyStr = new string[] { "快递费" };
+
             try
             {
                 #region 参数验证
@@ -1549,6 +1552,11 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
                 }
                 sqlWhere += string.Format(@"And i.Isdel={0}", 0);
 
+                foreach (var item in ExcludedKeyStr)
+                {
+                    sqlWhere += $" And i.UnitName not like '%{item}%' ";
+                }
+
                 if (!string.IsNullOrEmpty(sqlWhere.Trim()))
                 {
                     Regex r = new Regex("And");

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

@@ -96,6 +96,16 @@ namespace OASystem.Domain.Dtos.Financial
         /// 地区
         /// </summary>
         public int? Area { get; set; }
+
+        /// <summary>
+        /// 主管确认
+        /// </summary>
+        public int SupervisorConfirm { get; set; }
+
+        /// <summary>
+        /// 经理确认
+        /// </summary>
+        public int ManagerConfirm { get; set; }
     }
 
     public class Fin_GroupExtraCostDto_Search : DtoBase
@@ -124,4 +134,12 @@ namespace OASystem.Domain.Dtos.Financial
         public double columnWidth { get; set; }
         public int rowCount { get; set; } = 1;
     }
+
+    public class ReturnPremiumConfirmDto
+    {
+        public int ConfirmId { get; set; }
+        public int DataId { get; set; }
+
+        public int status { get; set; }
+    }
 }

+ 9 - 1
OASystem/OASystem.Domain/Dtos/Financial/ForForeignReceivablesNewDto.cs

@@ -91,7 +91,7 @@ namespace OASystem.Domain.Dtos.Financial
 
         /// <summary>
         /// 添加方式   
-        /// 0 - 账单模块 1 - 成本预算模块 2 - 实际报价
+        /// 0 - 账单模块 1 - 成本预算模块 2 - 实际报价 3 - 超支费用
         /// </summary>
         public int AddingWay { get; set; }
 
@@ -137,6 +137,14 @@ namespace OASystem.Domain.Dtos.Financial
 
     }
 
+    public class OverSpSeteceivablesDto
+    {
+        public int DiId { get; set; }
+
+        public int CreateUserId { get; set; }
+
+    }
+
     /// <summary>
     /// 文件下载 Dto
     /// </summary>

+ 1 - 1
OASystem/OASystem.Domain/Entities/Financial/Fin_ForeignReceivables.cs

@@ -88,7 +88,7 @@ namespace OASystem.Domain.Entities.Financial
         /// <summary>
         /// 添加方式   
         /// 0 - 账单模块   1 - 成本预算模块 2 - 分摊费用 3 - 其他费用
-        /// 0 - 账单模块   1 - 成本预算模块 2 - 实际报价
+        /// 0 - 账单模块   1 - 成本预算模块 2 - 实际报价 3 - 超支费用
         /// TODO:增加费用类型
         /// </summary>
         [SugarColumn(IsNullable = true, ColumnDataType = "int")]

+ 10 - 0
OASystem/OASystem.Domain/Entities/Financial/Fin_GroupExtraCost.cs

@@ -84,5 +84,15 @@ namespace OASystem.Domain.Entities.Financial
         /// 地区
         /// </summary>
         public int? Area { get; set; }
+
+        /// <summary>
+        /// 经理确认
+        /// </summary>
+        public int? ManagerConfirm { get; set; }
+
+        /// <summary>
+        /// 主管确认
+        /// </summary>
+        public int? SupervisorConfirm { get; set; }
     }
 }

+ 23 - 0
OASystem/OASystem.Domain/Entities/Financial/Fin_LocalGuideRelevancyOverspend.cs

@@ -11,4 +11,27 @@ namespace OASystem.Domain.Entities.Financial
         public int LocalGuideId { get; set; }
         public int OverspendId { get; set; }
     }
+
+    public class Fin_OverSpendRelevancyCollectionStatement : EntityBase
+    {
+        /// <summary>
+        /// 超支id
+        /// </summary>
+        public int OverSpendId { get; set; }
+
+        /// <summary>
+        /// 收款id
+        /// </summary>
+        public int CollectionStatementId { get; set; }
+
+
+        public int Diid { get; set; }
+
+        /// <summary>
+        /// 地接id
+        /// </summary>
+        public int LocalGuideId { get; set; }
+
+        public decimal savePrice { get; set; }
+    }
 }

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

@@ -25,6 +25,14 @@ namespace OASystem.Domain.ViewModels.Financial
         public int IsAuditGM { get; set; }
         public string IsAuditGMStr { get; set; }
 
+        public int ManagerConfirm { get; set; }
+
+        public int SupervisorConfirm { get; set; }
+
+        public string ManagerConfirmStr { get; set; }
+
+        public string SupervisorConfirmStr { get; set; }
+
     }
 
     public class Fin_GroupExtraCostDetailView

+ 5 - 0
OASystem/OASystem.Domain/ViewModels/Groups/DelegationInfoView.cs

@@ -178,6 +178,11 @@ namespace OASystem.Domain.ViewModels.Groups
         /// </summary>
         public int VisitPNumber { get; set; }
 
+        /// <summary>
+        /// 团名
+        /// </summary>
+        public string? TeamName { get; set; }
+
     }
 
     /// <summary>

+ 117 - 0
OASystem/OASystem.Infrastructure/Repositories/Financial/ForeignReceivablesRepository.cs

@@ -5,6 +5,7 @@ using OASystem.Domain;
 using OASystem.Domain.Dtos.Financial;
 using OASystem.Domain.Dtos.Groups;
 using OASystem.Domain.Entities.Financial;
+using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.ViewModels.Financial;
 using OASystem.Domain.ViewModels.Groups;
 using OASystem.Infrastructure.Repositories.Groups;
@@ -511,6 +512,122 @@ Where ffr.IsDel=0 And ffr.Diid={0}", dto.DiId);
             return result;
         }
 
+        public void OverSpSeteceivables(OverSpSeteceivablesDto dto)
+        {
+            var querySaveReceivables = _sqlSugar.Queryable<Fin_ForeignReceivables>()
+    .First(x => x.Diid == dto.DiId && x.AddingWay == 3 && x.IsDel == 0);
+
+            //获取所有超支数据
+            //整理超支数据
+            //币种不同则计算rmb值
+            var overspList = _sqlSugar.Queryable<Fin_GroupExtraCost, Grp_CreditCardPayment>
+                ((e, c) => c.CTable == 1015 && c.CId == e.Id && c.IsDel == 0).
+                Where((e, c) => e.IsDel == 0 && e.DiId == dto.DiId && (e.SupervisorConfirm == 1 || e.ManagerConfirm == 1)).
+                Select((e, c) => new
+                {
+                    e.Price,
+                    e.PriceCount,
+                    e.Coefficient,
+                    e.PriceSum,
+                    c.RMBPrice,
+                    c.DayRate,
+                    e.PriceCurrency,
+                    e.Remark,
+                })
+                .ToList();
+            var overspListGroup = overspList.GroupBy(x => x.PriceCurrency).ToList();
+            string foreignReceivablesRemake = string.Empty;
+            int count = 1;
+            overspList.ForEach(x =>
+            {
+                foreignReceivablesRemake += $"{count}.{x.Remark}";
+                count++;
+            });
+
+            if (querySaveReceivables != null)
+            {
+                if (overspList.Count() > 0)
+                {
+                    if (overspListGroup.Count() > 1)
+                    {
+
+                        querySaveReceivables.Currency = 836; //人民币
+                        querySaveReceivables.Rate = 1;
+                        querySaveReceivables.Price = overspListGroup.Sum(x => x.Sum(y => y.PriceSum * y.Coefficient * y.DayRate));
+                        querySaveReceivables.ItemSumPrice = overspListGroup.Sum(x => x.Sum(y => y.PriceSum * y.Coefficient * y.DayRate));
+                        querySaveReceivables.Remark = foreignReceivablesRemake;
+                        querySaveReceivables.CreateTime = DateTime.Now;
+                    }
+                    else
+                    {
+                        querySaveReceivables.Currency = overspList[0].PriceCurrency;
+                        querySaveReceivables.Rate = overspList[0].DayRate;
+                        querySaveReceivables.Price = overspListGroup[0].Sum(x => x.PriceSum * x.Coefficient);
+                        querySaveReceivables.ItemSumPrice = overspListGroup[0].Sum(x => x.PriceSum * x.Coefficient);
+                        querySaveReceivables.Remark = foreignReceivablesRemake;
+                        querySaveReceivables.AddingWay = 3;
+                        querySaveReceivables.CreateTime = DateTime.Now;
+                    }
+                }
+                else
+                {
+                    querySaveReceivables.Currency = 836; //人民币
+                    querySaveReceivables.Rate = 1;
+                    querySaveReceivables.Price = 0;
+                    querySaveReceivables.ItemSumPrice = 0;
+                    querySaveReceivables.Remark = "";
+                    querySaveReceivables.CreateTime = DateTime.Now;
+                    querySaveReceivables.Count = 1;
+                }
+                _sqlSugar.Updateable(querySaveReceivables).ExecuteCommand();
+            }
+            else
+            {
+                if (overspList.Count() > 0)
+                {
+                    if (overspListGroup.Count() > 1)
+                    {
+                        querySaveReceivables = new Fin_ForeignReceivables
+                        {
+                            CreateTime = DateTime.Now,
+                            CreateUserId = dto.CreateUserId,
+                            Diid = dto.DiId,
+                            PriceName = "超支费用",
+                            AddingWay = 3,
+                            Count = 1,
+                            Currency = 836,
+                            ItemSumPrice = overspList.Sum(x => x.PriceSum * x.Coefficient * x.DayRate),
+                            Price = overspList.Sum(x => x.PriceSum * x.Coefficient * x.DayRate),
+                            Rate = 1,
+                            IsDel = 0,
+                            Remark = foreignReceivablesRemake,
+                            Unit = "团",
+                        };
+                    }
+                    else
+                    {
+                        querySaveReceivables = new Fin_ForeignReceivables
+                        {
+                            CreateTime = DateTime.Now,
+                            CreateUserId = dto.CreateUserId,
+                            Diid = dto.DiId,
+                            PriceName = "超支费用",
+                            AddingWay = 3,
+                            Count = 1,
+                            Currency = overspList[0].PriceCurrency,
+                            ItemSumPrice = overspList.Sum(x => x.PriceSum * x.Coefficient),
+                            Price = overspList.Sum(x => x.PriceSum * x.Coefficient),
+                            Rate = overspList[0].DayRate,
+                            IsDel = 0,
+                            Remark = foreignReceivablesRemake,
+                            Unit = "团",
+                        };
+                    }
+                }
+                _sqlSugar.Insertable(querySaveReceivables).ExecuteCommand();
+            }
+        }
+
         #endregion
 
     }

+ 21 - 5
OASystem/OASystem.Infrastructure/Repositories/Groups/CarTouristGuideGroundRepository.cs

@@ -29,8 +29,9 @@ namespace OASystem.Infrastructure.Repositories.Groups
         private readonly SetDataRepository _setDataRep;
         private readonly DailyFeePaymentRepository _daiRep;    //日付申请仓库
         private readonly GroupCostParameterRepository _groupCostParameterRepository;
-
-        public CarTouristGuideGroundRepository(SqlSugarClient sqlSugar, IMapper mapper, CheckBoxsRepository checkRep, SetDataRepository setDataRep, DailyFeePaymentRepository daiRep, GroupCostParameterRepository groupCostParameterRepository)
+        private readonly ForeignReceivablesRepository _foreignReceivablesRepository;
+        public CarTouristGuideGroundRepository(SqlSugarClient sqlSugar, IMapper mapper, CheckBoxsRepository checkRep, SetDataRepository setDataRep,
+            DailyFeePaymentRepository daiRep, GroupCostParameterRepository groupCostParameterRepository, ForeignReceivablesRepository foreignReceivablesRepository)
             : base(sqlSugar)
         {
             _mapper = mapper;
@@ -38,6 +39,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
             _setDataRep = setDataRep;
             _daiRep = daiRep;
             _groupCostParameterRepository = groupCostParameterRepository;
+            _foreignReceivablesRepository = foreignReceivablesRepository;
         }
 
         public async Task<Result> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
@@ -885,7 +887,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                             PriceName = di.TeamName + "-" + priceCity + "-" + $"{item.Item2}(地接导入)",
                             PriceType = 1028,
                             PriceDetailType = item.Item3,
-                            Remark = x.Remark,
+                            Remark = x.PriceContent,
                             Area = opSingleCityId
                         
                         }).ToList();
@@ -973,7 +975,11 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     {
                         foreach (var item in groupExtraCostsArr)
                         {
-                            var QuerySgin = _sqlSugar.Queryable<Fin_GroupExtraCost>().Where(x => x.PriceName == item.PriceName && x.DiId == item.DiId && x.IsDel == 0 && x.PriceDt.ToString("yyyy-MM-dd") == item.PriceDt.ToString("yyyy-MM-dd")).First();
+                            var ManagerConfirm = item.PriceDetailType == 1088 ? 0 : 1;
+                            var SupervisorConfirm = item.PriceDetailType == 1088 ? 0 : 1;
+                            var QuerySgin = _sqlSugar.Queryable<Fin_GroupExtraCost>()
+                                .Where(x => x.PriceName == item.PriceName && x.DiId == item.DiId && x.IsDel == 0 && x.PriceDt.ToString("yyyy-MM-dd") == item.PriceDt.ToString("yyyy-MM-dd"))
+                                .First();
                             if (QuerySgin == null)
                             {
                                 var resultId = await PostGroupExtraCost_Operator(new Fin_GroupExtraCostDto_OP
@@ -995,7 +1001,9 @@ namespace OASystem.Infrastructure.Repositories.Groups
                                     PriceDt = item.PriceDt.ToString("yyyy-MM-dd"),
                                     payType = dto.PayDId,
                                     costSign = dto.OrbitalPrivateTransfer,
-                                    Area = item.Area
+                                    Area = item.Area,
+                                    ManagerConfirm = ManagerConfirm,
+                                    SupervisorConfirm = SupervisorConfirm
                                 });
                                 _sqlSugar.Insertable<Fin_LocalGuideRelevancyOverspend>(new Fin_LocalGuideRelevancyOverspend
                                 {
@@ -1033,6 +1041,12 @@ namespace OASystem.Infrastructure.Repositories.Groups
                                 });
                             }
                         }
+
+                        _foreignReceivablesRepository.OverSpSeteceivables(new OverSpSeteceivablesDto
+                        {
+                             CreateUserId = dto.CreateUserId,
+                             DiId = dto.DiId,
+                        });
                     }
 
                     #endregion
@@ -1275,6 +1289,8 @@ namespace OASystem.Infrastructure.Repositories.Groups
             _entity.PriceDt = DateTime.Parse(dto.PriceDt);
             _entity.PriceSum = dto.price * dto.PriceCount;
             _entity.Area = dto.Area;
+            _entity.SupervisorConfirm = dto.SupervisorConfirm;
+            _entity.ManagerConfirm = dto.ManagerConfirm;
 
             _daiRep.BeginTran();
             if (dto.editType == 1)