Explorar el Código

会务成本审核添加

yuanrf hace 5 días
padre
commit
67f1e242bd

+ 32 - 4
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -5520,9 +5520,13 @@ FROM
             int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
             int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
             int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
+            bool recheck = Convert.ToBoolean(groupData.Data.GetType().GetProperty("recheck").GetValue(groupData.Data, null) ?? "True");
 
-            //自动审核
-            var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
+            if (recheck)
+            {
+                //自动审核
+                var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
+            }
 
             await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
 
@@ -26583,6 +26587,12 @@ ORDER BY
             _sqlSugar.BeginTran();
             var data = _mapper.Map<Grp_ConferenceAffairsCost>(Dto.ConferenceAffairsCost);
 
+            var childResult = new
+            {
+                success = 0,
+                error = 0
+            };
+
             try
             {
                 if (data.Id == 0)
@@ -26609,18 +26619,27 @@ ORDER BY
                     data.Id = data.Id;
                 }
 
+                
 
                 if (Dto.ConferenceAffairsCostChild.Any())
                 {
                     var datas = _mapper.Map<List<Grp_ConferenceAffairsCostChild>>(Dto.ConferenceAffairsCostChild);
                     var insertArr = datas.Where(x => x.Id == 0).ToList();
-                    var updateArr = datas.Where(x => x.Id != 0).ToList();
+                    var updateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus != 1).ToList();
+                    var notUpdateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus == 1).ToList();
+
                     insertArr.ForEach(x => { x.Diid = Dto.GroupId; x.ConferenceAffairsCostId = data.Id; });
 
                     var inrsetCount = insertArr.Any() ? _sqlSugar.Insertable<Grp_ConferenceAffairsCostChild>(insertArr).ExecuteCommand() : 0;
                     var updateCount = updateArr.Any() ? _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>(updateArr)
                         .IgnoreColumns(x=> new { x.ConferenceAffairsCostId })
                         .ExecuteCommand() : 0;
+
+                    childResult = childResult with
+                    {
+                         error = notUpdateArr.Count(),
+                         success = inrsetCount + updateCount
+                    };
                 }
 
                 _sqlSugar.CommitTran();
@@ -26631,7 +26650,7 @@ ORDER BY
                 return Ok(JsonView(false, "失败!" + ex.Message));
             }
 
-            return Ok(JsonView(true,"操作成功!"));
+            return Ok(JsonView(true,"操作成功!", childResult));
         }
 
         [HttpPost]
@@ -26900,6 +26919,15 @@ ORDER BY
 
             return Ok(jw);
         }
+
+        [HttpPost]
+        public async Task<IActionResult> QueryConferenceAffairsChild(QueryConferenceAffairsChildDto Dto)
+        {
+            return Ok(JsonView(true,"SUCCESS", _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && x.Diid == Dto.GroupId)
+                .Select(x=>x.PriceName).ToList()));
+        }
+
+
         #endregion
 
         #region 团组签证流程

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

@@ -80,6 +80,11 @@ namespace OASystem.Domain.Dtos.Groups
         //public List<CurrList> CurrLists { get; set; }
     }
 
+    public class QueryConferenceAffairsChildDto
+    {
+        public int GroupId { get; set; }
+    }
+
     public class CurrList
     {
         public string CurrName { get; set; }

+ 137 - 17
OASystem/OASystem.Infrastructure/Repositories/Groups/DecreasePaymentsRepository.cs

@@ -157,6 +157,8 @@ namespace OASystem.Infrastructure.Repositories.Groups
             BeginTran();
             int id = 0;
             var grp_Decrease = _mapper.Map<Grp_DecreasePayments>(dto);
+            var recheck = true;
+
 
             //处理费用总计
             if (grp_Decrease.FeeTotal == 0.00M)
@@ -174,6 +176,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
             if (dto.Status == 1)//添加
             {
                 id = await AddAsyncReturnId(grp_Decrease);
+                grp_Decrease.Id = id;
 
                 #region C表赋值
 
@@ -335,7 +338,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
 
                         if (isAuto)
                         {
-                            _sqlSugar.Updateable<Grp_CreditCardPayment>()
+                            var execCount = _sqlSugar.Updateable<Grp_CreditCardPayment>()
                                 .SetColumns(a => new Grp_CreditCardPayment
                                 {
                                     IsAuditGM = 3, //自动审核通过
@@ -344,21 +347,29 @@ namespace OASystem.Infrastructure.Repositories.Groups
                                 })
                                 .Where(a => a.CId == id && a.CTable == 98 && a.DIId == 2590)
                                 .ExecuteCommand();
+                            recheck = false;
                         }
 
                     }
                     #endregion
 
                     #region 会务成本自动审核处理
+                    var hwids = _sqlSugar.Queryable<Sys_SetData>()
+                        .Where(x => x.IsDel == 0 && x.STid == 10 && x.Name.Contains("会务活动"))
+                        .Select(x => x.Id)
+                        .ToList();
+
+                    var groupTypeIsTrue = _sqlSugar.Queryable<Grp_DelegationInfo>()
+                        .Where(x => x.Id == dto.DiId && x.IsDel == 0)
+                        .Any(x => hwids.Contains(x.TeamDid));
 
-                    if (false)
+                    if (groupTypeIsTrue)
                     {
                         var main = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
                                             .First(x => x.Diid == dto.DiId && x.IsDel == 0);
 
                         if (main != null)
                         {
-
                             var chiArr = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>()
                                 .Where(x => x.Diid == dto.DiId && x.ConferenceAffairsCostId == main.Id && x.IsDel == 0)
                                 .ToList();
@@ -369,40 +380,64 @@ namespace OASystem.Infrastructure.Repositories.Groups
                             if (find != null)
                             {
 
+                                //检索历史金额
+                                var histyPrice = _sqlSugar.Queryable<Grp_DecreasePayments>()
+                                    .LeftJoin<Grp_CreditCardPayment>((x, a) => a.IsDel == 0 && a.CTable == 98 && a.CId == x.Id )
+                                    .Where((x, a) => x.IsDel == 0 && x.PriceName == dto.PriceName && x.Id != grp_Decrease.Id)
+                                    .Select((x, a) => new
+                                    {
+                                        x.FeeTotal,
+                                        x.Currency,
+                                        a.DayRate,
+                                        a.RMBPrice,
+                                        x.DiId,
+                                        x.PriceName,
+                                        x.Price,
+                                        x.Quantity,
+                                    })
+                                    .ToList();
+
                                 //币种不同情况
-                                if (find.Currency != dto.Currency)
+                                if (true)
                                 {
                                     //币种全转换为人民币
                                     var rate = teamRates.Where(it => it.CurrencyId == grp_Decrease.Currency).FirstOrDefault();
                                     if (rate != null)
                                     {
-                                        //dto.Price *= rate.Rate;
                                         grp_Decrease.FeeTotal *= rate.Rate;
                                     }
 
                                     var ConferenceAffairsCostFeeTotal = 0.00M;
-                                    var ConferenceAffairsCostRate = teamRates.Where(it => it.CurrencyId == find.Currency).FirstOrDefault();
-                                    if (rate != null)
+                                    ConferenceAffairsCostFeeTotal = find.Count * find.CostPrice * find.Rate;
+
+                                    var histyPriceValue = histyPrice.Sum(x => x.FeeTotal * x.DayRate);
+                                    if (ConferenceAffairsCostFeeTotal > histyPriceValue)
                                     {
-                                        //dto.Price *= rate.Rate;
-                                        ConferenceAffairsCostFeeTotal = rate.Rate * find.CostPrice * find.Count;
+                                        isAuto = ConferenceAffairsCostFeeTotal - histyPriceValue >= grp_Decrease.FeeTotal;
                                     }
-
-                                }
-                                else
-                                {
-                                    isAuto = find.CostPrice >= dto.Price && find.Count >= dto.Quantity;
                                 }
                             }
 
-                            if (isAuto) { }
+                            if (isAuto) {
+
+                                var execCount =  _sqlSugar.Updateable<Grp_CreditCardPayment>()
+                                      .SetColumns(a => new Grp_CreditCardPayment
+                                      {
+                                          IsAuditGM = 3, //自动审核通过
+                                          AuditGMOperate = 4,
+                                          AuditGMDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
+                                      })
+                                      .Where(a => a.CId == grp_Decrease.Id && a.CTable == 98 && a.DIId == grp_Decrease.DiId)
+                                      .ExecuteCommand();
+                                recheck = false;
+                            }
                         }
                     }
 
                     #endregion
 
                     CommitTran();
-                    var data = new { ccpId = cId, sign = 1, dataId = id };
+                    var data = new { ccpId = cId, sign = 1, dataId = id, recheck };
                     return new JsonView() { Code = 200, Msg = "添加成功!", Data = data };
                 }
 
@@ -559,13 +594,98 @@ namespace OASystem.Infrastructure.Repositories.Groups
                                     })
                                     .Where(a => a.CId == dto.Id && a.CTable == 98 && a.DIId == 2590)
                                     .ExecuteCommand();
+                                recheck = false; 
+                            }
+                        }
+                        #endregion
+
+                        #region 会务成本自动审核处理
+                        var hwids = _sqlSugar.Queryable<Sys_SetData>()
+                            .Where(x => x.IsDel == 0 && x.STid == 10 && x.Name.Contains("会务活动"))
+                            .Select(x => x.Id)
+                            .ToList();
+
+                        var groupTypeIsTrue = _sqlSugar.Queryable<Grp_DelegationInfo>()
+                            .Where(x => x.Id == dto.DiId && x.IsDel == 0)
+                            .Any(x => hwids.Contains(x.TeamDid));
+
+                        if (groupTypeIsTrue)
+                        {
+                            var main = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
+                                                .First(x => x.Diid == dto.DiId && x.IsDel == 0);
+
+                            if (main != null)
+                            {
+                                var chiArr = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>()
+                                    .Where(x => x.Diid == dto.DiId && x.ConferenceAffairsCostId == main.Id && x.IsDel == 0)
+                                    .ToList();
+                                var find = chiArr.FirstOrDefault(x => x.PriceName == dto.PriceName && x.ReviewStatus == 1);
+                                var isAuto = false;
+
+                                //存在已审的会务成本
+                                if (find != null)
+                                {
+
+                                    //检索历史金额
+                                    var histyPrice = _sqlSugar.Queryable<Grp_DecreasePayments>()
+                                        .LeftJoin<Grp_CreditCardPayment>((x, a) => a.IsDel == 0 && a.CTable == 98 && a.CId == x.Id)
+                                        .Where((x, a) => x.IsDel == 0 && x.PriceName == dto.PriceName && x.Id != grp_Decrease.Id)
+                                        .Select((x, a) => new
+                                        {
+                                            x.FeeTotal,
+                                            x.Currency,
+                                            a.DayRate,
+                                            a.RMBPrice,
+                                            x.DiId,
+                                            x.PriceName,
+                                            x.Price,
+                                            x.Quantity,
+                                        })
+                                        .ToList();
+
+                                    if (true)
+                                    {
+                                        //币种全转换为人民币
+                                        var rate = teamRates.Where(it => it.CurrencyId == grp_Decrease.Currency).FirstOrDefault();
+                                        if (rate != null)
+                                        {
+                                            grp_Decrease.FeeTotal *= rate.Rate;
+                                        }
+
+                                        var ConferenceAffairsCostFeeTotal = 0.00M;
+                                        ConferenceAffairsCostFeeTotal = find.Count * find.CostPrice * find.Rate;
+
+                                        var histyPriceValue = histyPrice.Sum(x => x.FeeTotal * x.DayRate);
+                                        if (ConferenceAffairsCostFeeTotal > histyPriceValue)
+                                        {
+                                            isAuto = ConferenceAffairsCostFeeTotal - histyPriceValue >= grp_Decrease.FeeTotal;
+                                        }
+
+                                    }
+                                }
+
+                                if (isAuto)
+                                {
+
+                                    var execCount = _sqlSugar.Updateable<Grp_CreditCardPayment>()
+                                    .SetColumns(a => new Grp_CreditCardPayment
+                                    {
+                                        IsAuditGM = 3, //自动审核通过
+                                        AuditGMOperate = 4,
+                                        AuditGMDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
+                                    })
+                                    .Where(a => a.CId == grp_Decrease.Id && a.CTable == 98 && a.DIId == grp_Decrease.DiId)
+                                    .ExecuteCommand();
+                                    recheck = false;
+                                }
                             }
                         }
+
                         #endregion
 
                         CommitTran();
 
-                        var data = new { ccpId = grp_CreditCardPayment.Id, sign = 2, dataId = grp_Decrease.Id };
+                        var data = new { ccpId = grp_CreditCardPayment.Id, sign = 2, dataId = grp_Decrease.Id  ,recheck };
 
                         return new JsonView() { Code = 200, Msg = "修改成功!", Data = data };
                     }