Просмотр исходного кода

酒店添加逻辑代码更改,消费日期格式处理

leiy месяцев назад: 10
Родитель
Сommit
2bb6882a3c

+ 35 - 10
OASystem/OASystem.Api/Controllers/FinancialController.cs

@@ -2723,10 +2723,42 @@ namespace OASystem.API.Controllers
 
             if (groupIds.Count > 0)
             {
-                var groupStatus = _sqlSugar.Updateable<Grp_CreditCardPayment>()
+
+                var ccpInfos = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && groupIds.Contains(it.Id)).ToList();
+                var otherTypeCcpIds = ccpInfos.Where(it => it.CTable != 76).Select(it => it.Id).ToList();
+                var hotelTyprCcpIds = ccpInfos.Where(it => it.CTable == 76).Select(it => it.Id).ToList();
+                int groupStatus = 0;
+                if (otherTypeCcpIds.Count > 0) //其他费用类型 正常付款
+                {
+                    groupStatus = _sqlSugar.Updateable<Grp_CreditCardPayment>()
                                            .SetColumns(it => it.IsPay == 1)
-                                           .Where(it => groupIds.Contains(it.Id))
+                                           .Where(it => otherTypeCcpIds.Contains(it.Id))
                                            .ExecuteCommand();
+                }
+
+                if (hotelTyprCcpIds.Count > 1) //酒店费用子项逻辑付款,酒店子项费用全部付完款,c表ispay=1
+                {
+                    if (hotelSubIds.Count > 0)
+                    {
+                        var hrIspayStatus = _sqlSugar.Updateable<Grp_HotelReservationsContent>()
+                                                   .SetColumns(it => it.IsPay == 1)
+                                                   .Where(it => hotelSubIds.Contains(it.Id))
+                                                   .ExecuteCommand();
+                        //酒店子项是否全部付完款
+                        
+                        List<int> hrIds = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && hotelSubIds.Contains(it.Id)).Select(it => it.HrId).Distinct().ToList();
+                        if (hrIds.Count > 0 )
+                        {
+                            var hotelSubFeeData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && hrIds.Contains(it.HrId)).ToList();
+                            var hotelSubFeeGroupData = hotelSubFeeData.GroupBy(it => it.HrId).ToList();
+                            
+
+                        }
+
+
+                    }
+                }
+
                 if (groupStatus > 0)
                 {
                     changeStatus = true;
@@ -2737,14 +2769,7 @@ namespace OASystem.API.Controllers
                                            .Where(it => groupIds.Contains(it.Id) && it.CTable == 76)
                                            .ToList();
                     List<int> hrIds = ccps.Select(it => it.CId).ToList();
-                    if (hrIds.Count > 0)
-                    {
-                        var hrIspayStatus = _sqlSugar.Updateable<Grp_HotelReservationsContent>()
-                                                   .SetColumns(it => it.IsPay == 1)
-                                                   .Where(it => hrIds.Contains(it.Id))
-                                                   .ExecuteCommand();
-
-                    }
+                    
                 }
             }
 

+ 36 - 8
OASystem/OASystem.Infrastructure/Repositories/Groups/HotelPriceRepository.cs

@@ -304,10 +304,23 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     it.CreateUserId = _dto.UserId;
                     it.DiId = _dto.DiId;
                     it.IsPay = 0;
+                    it.HrId = _HotelReservations.Id;
+
+                    if (!string.IsNullOrEmpty(it.ConsumptionDate))
+                    {
+                        if (DateTime.TryParse(it.ConsumptionDate, out DateTime dt))
+                        { 
+                            it.ConsumptionDate = dt.ToString("yyyy-MM-dd");
+                        }
+                    }
+
+
                     //var currCode = currData.Find(x => x.Id == it.Currency)?.Name;
                     //decimal? currRate = teamRateDescViews.Find(x => x.CurrencyCode == currCode)?.Rate;
                     //it.Rate = currRate ?? 0.00M;
                 });
+                _HotelReservationsContents = _HotelReservationsContents.OrderBy(x => x.PriceType).ToList();
+
 
                 if (portType == 2 || portType == 3)
                 {
@@ -443,18 +456,33 @@ namespace OASystem.Infrastructure.Repositories.Groups
                         return _view;
                     }
 
-                    int hotelSubStatus  = await _sqlSugar.Updateable<Grp_HotelReservationsContent>(_HotelReservationsContents)
+                    var hotelSubStatus = false;
+                    var addHotelSubData = _HotelReservationsContents.Where(it => it.Id == 0).ToList();
+                    var updateHotelSubData = _HotelReservationsContents.Where(it => it.Id != 0).ToList();
+
+                    if (addHotelSubData.Count > 0)
+                    {
+                        int hotelSubAdd = await _sqlSugar.Insertable<Grp_HotelReservationsContent>(addHotelSubData).ExecuteCommandAsync();
+                        if (hotelSubAdd > 0) hotelSubStatus = true;
+
+                    }
+                    if (updateHotelSubData.Count > 0)
+                    {
+                        int hotelSubUpdate = await _sqlSugar.Updateable<Grp_HotelReservationsContent>(updateHotelSubData)
                                                          .IgnoreColumns(it => new {
-                                                            it.DiId,
-                                                            it.HrId,
-                                                            it.CreateUserId,
-                                                            it.CreateTime,
-                                                            it.DeleteUserId,
-                                                            it.DeleteTime
+                                                             it.DiId,
+                                                             it.HrId,
+                                                             it.CreateUserId,
+                                                             it.CreateTime,
+                                                             it.DeleteUserId,
+                                                             it.DeleteTime
                                                          })
                                                          .WhereColumns(it => it.Id)
                                                          .ExecuteCommandAsync();
-                    if (hotelSubStatus < 1)
+                        if (hotelSubUpdate > 0) hotelSubStatus = true;
+                    }
+                    
+                    if (!hotelSubStatus)
                     {
                         _view.Msg = "酒店预定子表信息修改失败!";
                         _sqlSugar.RollbackTran(); //回滚