yuanrf 1 month ago
parent
commit
07725a7da1

+ 5 - 0
OASystem/OASystem.Domain/Dtos/Groups/DecreasePaymentsDto.cs

@@ -152,6 +152,11 @@ namespace OASystem.Domain.Dtos.Groups
         /// OTA订单号NO
         /// </summary>
         public string OTAOrderNo { get; set; }
+
+        /// <summary>
+        /// 是否为选择的费用
+        /// </summary>
+        public int IsSelect { get; set; } 
     }
     public class DecreasePaymentsByIdDto
     {

+ 5 - 0
OASystem/OASystem.Domain/Entities/Groups/Grp_DecreasePayments.cs

@@ -109,5 +109,10 @@ namespace OASystem.Domain.Entities.Groups
         /// </summary>
         [SugarColumn(IsNullable = true, ColumnDataType = "varchar(200)")]
         public string OTAOrderNo { get; set; }
+
+        /// <summary>
+        /// 是否为选择的费用
+        /// </summary>
+        public int IsSelect { get; set; }
     }
 }

+ 5 - 0
OASystem/OASystem.Domain/ViewModels/Financial/Fin_ForeignReceivablesView.cs

@@ -201,6 +201,11 @@ namespace OASystem.Domain.ViewModels.Financial
         /// </summary>
         public int Currency { get; set; }
 
+        /// <summary>
+        /// 币种Str
+        /// </summary>
+        public int CurrencyStr { get; set; }
+
         /// <summary>
         /// 添加方式   
         /// 0 - 账单模块   1 - 预算成本页面添加

+ 3 - 2
OASystem/OASystem.Infrastructure/Repositories/Financial/ForeignReceivablesRepository.cs

@@ -408,9 +408,10 @@ namespace OASystem.Infrastructure.Repositories.Financial
 
 
             //应收款项
-            string groupReceivedSql = string.Format(@"Select *,su.CnName As AuditorName From Fin_ForeignReceivables  ffr
+            string groupReceivedSql = string.Format(@"Select *,su.CnName As AuditorName, ssd.Name  as 'CurrencyStr'  From Fin_ForeignReceivables  ffr
 Left Join Sys_Users su On  ffr.Auditor = su.Id
-Where ffr.IsDel=0 And ffr.Diid={0}", dto.DiId);
+Where ffr.IsDel=0 And ffr.Diid={0}
+LEFT JOIN  Sys_SetData ssd  on ffr.Currency  = ssd.Id  AND  ssd.IsDel  = 0", dto.DiId);
             var groupReceivedList = await _sqlSugar.SqlQueryable<ProceedsReceivedNewView>(groupReceivedSql).ToListAsync();
 
             result.Code = 200;

+ 69 - 3
OASystem/OASystem.Infrastructure/Repositories/Groups/DecreasePaymentsRepository.cs

@@ -23,11 +23,13 @@ namespace OASystem.Infrastructure.Repositories.Groups
     {
         private readonly IMapper _mapper;
         private readonly TeamRateRepository _teamRateRep;
-        public DecreasePaymentsRepository(SqlSugarClient sqlSugar, IMapper mapper, TeamRateRepository teamRateRep)
+        private readonly SetDataRepository _setDataRepository;
+        public DecreasePaymentsRepository(SqlSugarClient sqlSugar, IMapper mapper, TeamRateRepository teamRateRep, SetDataRepository setDataRepository )
             : base(sqlSugar)
         {
             this._mapper = mapper;
             _teamRateRep = teamRateRep;
+            this._setDataRepository = setDataRepository;
         }
         /// <summary>
         /// 根据团组Id查询数据
@@ -159,6 +161,70 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 grp_Decrease.FeeTotal = grp_Decrease.Price * grp_Decrease.Price;
             }
 
+            //根据成本判断自动审核
+            #region 根据成本判断自动审核
+
+            var auto = false;
+            if (dto.IsSelect == 1)
+            {
+                var costInfo = _sqlSugar.Queryable<Grp_GroupCostParameter>()
+                                .LeftJoin<Grp_DelegationInfo>((a, b) => b.IsDel == 0 && b.Id == a.DiId)
+                                .Where((a, b) => a.DiId == dto.DiId && a.IsDel == 0 && a.CostType == "A")
+                                .Select((a,b) => new
+                                {
+                                   a.Currency,
+                                   a.CostType,
+                                   a.Rate,
+                                   b.VisitPNumber,
+                                })
+                                .First();
+
+                if (costInfo != null)
+                {
+                    //获取团组成本
+                    var groupCostPrice_Decimal = _sqlSugar.Queryable<Grp_GroupCost>()
+                            .Where(x => x.Diid == dto.DiId && x.IsDel == 0 && x.TE != 0)
+                            .Sum(x => x.TE);
+                    groupCostPrice_Decimal *= costInfo.VisitPNumber;
+
+                    var costPrice_Decimal = groupCostPrice_Decimal;
+                    var dtoPrice_Decimal = dto.FeeTotal;
+                    var costInfoCurr_Bool = int.TryParse(costInfo.Currency, out int costInfoCurr_Int);
+
+                    if(costInfoCurr_Int != dto.Currency)
+                    {
+                        if (costInfoCurr_Bool)
+                        {
+                            costPrice_Decimal *= costInfo.Rate;
+
+                            //获取其他款项汇率
+                            var rate_Object = await _setDataRepository.PostCurrencyByDiid(dto.DiId, 98, dto.Currency);
+                            if (rate_Object != null && rate_Object.Code == 0) {
+                                var currInfo = (rate_Object.Data as CurrencyInfo);
+                                if (currInfo != null)
+                                {
+                                    dtoPrice_Decimal *= currInfo.Rate;
+                                    if (costPrice_Decimal > dtoPrice_Decimal)
+                                    {
+                                        auto = true;
+                                    }
+                                }
+                            }
+                        }
+                    }
+                    else
+                    {
+                        if (costPrice_Decimal > dtoPrice_Decimal)
+                        {
+                            auto = true;
+                        }
+                    }
+                    
+                }
+
+            }
+            #endregion
+
             List<TeamRateDescAddCurrencyIdView> teamRates = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, dto.DiId, 98);
             if (dto.Status == 1)//添加
             {
@@ -207,7 +273,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     C.IsAuditMF = 0;
                     C.AuditMFOperate = 0;
                     C.AuditMFDate = "";
-                    C.IsAuditGM = 0;
+                    C.IsAuditGM = auto ? 3 : 0;
                     C.AuditGMOperate = 21;
                     C.AuditGMDate = "";
 
@@ -331,7 +397,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                                                         OrbitalPrivateTransfer = dto.OrbitalPrivateTransfer,
                                                         DayRate = grp_CreditCardPayment.DayRate,
                                                         RMBPrice = grp_CreditCardPayment.RMBPrice,
-
+                                                        IsAuditGM = auto ? 3 : grp_CreditCardPayment.IsAuditGM
                                                     })
                                                     .ExecuteCommandAsync();
                         if (CTable > 0)