Browse Source

更新签证费用相关的代码逻辑
三公签证费用 大小公务更新数据源(Res_VisaFeeStandard)代码编写。

Lyyyi 2 days ago
parent
commit
73945716bc

+ 1 - 2
OASystem/OASystem.Infrastructure/Repositories/Groups/DelegationInfoRepository.cs

@@ -99,7 +99,6 @@ namespace OASystem.Infrastructure.Repositories.Groups
             }
             }
         }
         }
 
 
-
         /// <summary>
         /// <summary>
         /// 团组信息 团组预览详情共享Api
         /// 团组信息 团组预览详情共享Api
         /// </summary>
         /// </summary>
@@ -259,7 +258,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
         /// 团组国家分割字符
         /// 团组国家分割字符
         /// 返回 国家数组
         /// 返回 国家数组
         /// </summary>
         /// </summary>
-        /// <param name="teamName"></param>
+        /// <param name="visitCountry"></param>
         /// <returns></returns>
         /// <returns></returns>
         public List<string> GroupSplitCountry(string visitCountry)
         public List<string> GroupSplitCountry(string visitCountry)
         {
         {

+ 89 - 39
OASystem/OASystem.Infrastructure/Repositories/Groups/VisaFeeInfoRepository.cs

@@ -4,6 +4,7 @@ using OASystem.Domain.Dtos.Groups;
 using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.Entities.Resource;
 using OASystem.Domain.Entities.Resource;
 using OASystem.Domain.ViewModels.Groups;
 using OASystem.Domain.ViewModels.Groups;
+using OASystem.Domain.ViewModels.Resource;
 using OASystem.Infrastructure.Repositories.Resource;
 using OASystem.Infrastructure.Repositories.Resource;
 namespace OASystem.Infrastructure.Repositories.Groups
 namespace OASystem.Infrastructure.Repositories.Groups
 {
 {
@@ -52,63 +53,113 @@ namespace OASystem.Infrastructure.Repositories.Groups
         /// <returns></returns>
         /// <returns></returns>
         public async Task<JsonView> List(int portType, int diId)
         public async Task<JsonView> List(int portType, int diId)
         {
         {
-            if (diId < 0) return new JsonView() { Code = StatusCodes.Status400BadRequest, Msg = "请传入有效的DiId参数" };
-            if (portType < 1  || portType > 3) return new JsonView() { Code = StatusCodes.Status400BadRequest, Msg = "请传入有效的portType参数" };
+            if (diId < 0)
+                return new JsonView() { Code = StatusCodes.Status400BadRequest, Msg = "请传入有效的DiId参数" };
+            if (portType < 1 || portType > 3)
+                return new JsonView() { Code = StatusCodes.Status400BadRequest, Msg = "请传入有效的portType参数" };
+
+            //防SQL注入
+            string sql = @"Select vfi.Id,vfi.IsChecked,cfc.VisaCountry AS Country,cfc.VisaPrice As VisaFee,
+                   vfi.OBType,vfi.AgencyFee,vfi.OtherFee,vfi.Remark 
+                   From Grp_VisaFeeInfo vfi
+                   Left Join Res_CountryFeeCost cfc On vfi.CountryVisaFeeId = cfc.Id
+                   Where vfi.Isdel = 0  And vfi.Diid = @diId";
+            var data = await _sqlSugar.SqlQueryable<VisaFeeInfosView>(sql)
+                .AddParameters(new { diId })
+                .ToListAsync();
 
 
-            string sql = string.Format($@"Select vfi.Id,vfi.IsChecked,cfc.VisaCountry AS Country,cfc.VisaPrice As VisaFee,
-                                          vfi.OBType,vfi.AgencyFee,vfi.OtherFee,vfi.Remark 
-                                          From Grp_VisaFeeInfo vfi
-                                          Left Join Res_CountryFeeCost cfc On vfi.CountryVisaFeeId = cfc.Id
-                                          Where vfi.Isdel = 0  And vfi.Diid = {diId}");
-            var data = await _sqlSugar.SqlQueryable<VisaFeeInfosView>(sql).ToListAsync();
-
-            //默认十行 雷怡 2024-26-08 11:26:40 
             if (data.Count == 0)
             if (data.Count == 0)
             {
             {
-                var groupInfo = await _groupRep.PostShareGroupInfo(new ShareGroupInfoDto() { PortType = 1, Id = diId });
+                var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>()
+                    .FirstAsync(x => x.IsDel == 0 && x.Id == diId);
 
 
-                if (groupInfo.Code != 200)
+                if (groupInfo == null)
                 {
                 {
                     return new JsonView() { Code = StatusCodes.Status200OK, Data = data, Msg = "团组信息不存在!" };
                     return new JsonView() { Code = StatusCodes.Status200OK, Data = data, Msg = "团组信息不存在!" };
                 }
                 }
 
 
-                var countrys = _groupRep.GroupSplitCountry((groupInfo.Data as Web_ShareGroupInfoView)?.VisitCountry ?? "");
-
-                if (countrys.Any())
+                var countrys = _groupRep.GroupSplitCountry(groupInfo.VisitCountry ?? "");
+                if (countrys.Count > 0)
                 {
                 {
-                    //int dataRow = 0;
-                    foreach (var country in countrys)
-                    {
-                        var countryInfo = await _sqlSugar.Queryable<Res_CountryFeeCost>().Where(it => it.IsDel == 0 && it.VisaCountry.Equals(country)).FirstAsync();
-                        if (countryInfo != null)
+                    var visaFeeCountrys = await _sqlSugar.Queryable<Res_VisaFeeStandard>()
+                        .Where(x => x.IsDel == 0 && x.FeeType == 0 && countrys.Contains(x.Country))
+                        .Select(x => new VisaFeeStandardInfoView
                         {
                         {
-                            data.Add(new VisaFeeInfosView()
-                            {
-                                IsChecked = 0,
-                                Country = country,
-                                VisaFee = countryInfo.VisaPrice,
-                                OBType = 1,
-                                AgencyFee = countryInfo.GrandBusinessAgencyFee
-                            });
+                            Id = x.Id,
+                            Continent = x.Continent,
+                            Country = x.Country,
+                            FeeType = x.FeeType,
+                        })
+                        .ToListAsync();
+
+                    if (visaFeeCountrys.Count > 0)
+                    {
+                        var visaFeeCountryIds = visaFeeCountrys.Select(x => x.Id).ToList();
+                        var visaFeeDetails = await _sqlSugar.Queryable<Res_VisaFeeStandardDetails>()
+                            .Where(x => x.IsDel == 0 && visaFeeCountryIds.Contains(x.ParentId))
+                            .ToListAsync();
 
 
-                            data.Add(new VisaFeeInfosView()
+                        // 建立ParentId到Details的字典,避免多次Where查找
+                        var detailsDict = visaFeeDetails
+                            .GroupBy(x => x.ParentId)
+                            .ToDictionary(g => g.Key, g => g.ToList());
+
+                        foreach (var countryInfo in visaFeeCountrys)
+                        {
+                            if (detailsDict.TryGetValue(countryInfo.Id, out var details))
                             {
                             {
-                                IsChecked = 0,
-                                Country = country,
-                                VisaFee = countryInfo.VisaPrice,
-                                OBType = 2,
-                                AgencyFee = countryInfo.PettyBusinessAgencyFee
-                            });
+                                // 只做映射,无副作用可省略变量
+                                countryInfo.VisaFees = _mapper.Map<List<VisaFeeStandardDetails>>(details);
+                            }
                         }
                         }
-                        else
+
+                        var provCityDatas = await _groupRep.ProvinceCityBasicSource();
+                        int provinceId = _groupRep.FindParentIdByChildId(provCityDatas, groupInfo.CityId) ?? 0;
+
+                        foreach (var country in countrys)
                         {
                         {
+                            var countryInfo = visaFeeCountrys.FirstOrDefault(x => x.Country == country);
+                            if (countryInfo != null && countryInfo.VisaFees != null)
+                            {
+                                //如果未找到对应的城市则默认四川的费用标准
+                                var cityVisaFeeInfo = countryInfo.VisaFees.FirstOrDefault(x => x.ProvinceId == provinceId)
+                                    ?? countryInfo.VisaFees.FirstOrDefault(x => x.ProvinceId == 122); // 122 四川省ID
+
+                                if (cityVisaFeeInfo != null)
+                                {
+                                    data.Add(new VisaFeeInfosView()
+                                    {
+                                        IsChecked = 0,
+                                        Country = country,
+                                        //大公务签证费用为0时,使用小公务签证费用
+                                        VisaFee = cityVisaFeeInfo.LargeVisaPrice == 0.00M 
+                                                  ? cityVisaFeeInfo.SmallVisaPrice 
+                                                  : cityVisaFeeInfo.LargeVisaPrice,
+                                        OBType = 1,
+                                        AgencyFee = cityVisaFeeInfo.LargeAgencyFee
+                                    });
+
+                                    data.Add(new VisaFeeInfosView()
+                                    {
+                                        IsChecked = 0,
+                                        Country = country,
+                                        //小公务签证费用为0时,使用大公务签证费用
+                                        VisaFee = cityVisaFeeInfo.SmallVisaPrice == 0.00M
+                                                  ? cityVisaFeeInfo.LargeVisaPrice
+                                                  : cityVisaFeeInfo.SmallVisaPrice,
+                                        OBType = 2,
+                                        AgencyFee = cityVisaFeeInfo.SmallAgencyFee
+                                    });
+                                    continue;
+                                }
+                            }
+                            // 没有费用信息时补空行
                             data.Add(new VisaFeeInfosView()
                             data.Add(new VisaFeeInfosView()
                             {
                             {
                                 IsChecked = 0,
                                 IsChecked = 0,
                                 Country = country,
                                 Country = country,
                                 OBType = 1,
                                 OBType = 1,
                             });
                             });
-
                             data.Add(new VisaFeeInfosView()
                             data.Add(new VisaFeeInfosView()
                             {
                             {
                                 IsChecked = 0,
                                 IsChecked = 0,
@@ -117,7 +168,6 @@ namespace OASystem.Infrastructure.Repositories.Groups
                             });
                             });
                         }
                         }
                     }
                     }
-
                     AddDefaultRows(data, 10);
                     AddDefaultRows(data, 10);
                 }
                 }
                 else
                 else
@@ -130,7 +180,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 AddDefaultRows(data, 10);
                 AddDefaultRows(data, 10);
             }
             }
 
 
-            return new JsonView() { Code = StatusCodes.Status200OK, Data =data, Msg = "请传入有效的DiId参数" };
+            return new JsonView() { Code = StatusCodes.Status200OK, Data = data, Msg = "操作成功!" };
         }
         }
 
 
         /// <summary>
         /// <summary>

+ 55 - 5
OASystem/OASystem.Infrastructure/Repositories/Resource/CountryFeeRepository.cs

@@ -1,5 +1,4 @@
 using AutoMapper;
 using AutoMapper;
-using MathNet.Numerics.Distributions;
 using OASystem.Domain.Dtos.Resource;
 using OASystem.Domain.Dtos.Resource;
 using OASystem.Domain.Entities.Resource;
 using OASystem.Domain.Entities.Resource;
 using OASystem.Domain.ViewModels.Resource;
 using OASystem.Domain.ViewModels.Resource;
@@ -129,7 +128,7 @@ namespace OASystem.Infrastructure.Repositories.Resource
             var ids = pageList.Select(x => x.Id).ToList();
             var ids = pageList.Select(x => x.Id).ToList();
             var detailsList = await _sqlSugar.Queryable<Res_VisaFeeStandardDetails>()
             var detailsList = await _sqlSugar.Queryable<Res_VisaFeeStandardDetails>()
                  .LeftJoin<Sys_Cities>((x, y) => x.ProvinceId == y.Id && (y.Level == 1 || y.Level == 4))
                  .LeftJoin<Sys_Cities>((x, y) => x.ProvinceId == y.Id && (y.Level == 1 || y.Level == 4))
-                 .Where((x, y) => ids.Contains( x.ParentId ) && x.IsDel == 0)
+                 .Where((x, y) => ids.Contains(x.ParentId) && x.IsDel == 0)
                  .Select((x, y) => new VisaFeeStandardDetails
                  .Select((x, y) => new VisaFeeStandardDetails
                  {
                  {
                      Id = x.Id,
                      Id = x.Id,
@@ -204,7 +203,8 @@ namespace OASystem.Infrastructure.Repositories.Resource
             var detailsList = await _sqlSugar.Queryable<Res_VisaFeeStandardDetails>()
             var detailsList = await _sqlSugar.Queryable<Res_VisaFeeStandardDetails>()
                 .LeftJoin<Sys_Cities>((x, y) => x.ProvinceId == y.Id && (y.Level == 1 || y.Level == 4))
                 .LeftJoin<Sys_Cities>((x, y) => x.ProvinceId == y.Id && (y.Level == 1 || y.Level == 4))
                 .Where((x, y) => x.ParentId == view.Id && x.IsDel == 0)
                 .Where((x, y) => x.ParentId == view.Id && x.IsDel == 0)
-                .Select((x, y) => new VisaFeeStandardDetails {
+                .Select((x, y) => new VisaFeeStandardDetails
+                {
                     Id = x.Id,
                     Id = x.Id,
                     ParentId = x.ParentId,
                     ParentId = x.ParentId,
                     ProvinceId = x.ProvinceId,
                     ProvinceId = x.ProvinceId,
@@ -231,7 +231,7 @@ namespace OASystem.Infrastructure.Repositories.Resource
 
 
             // 指定的省份顺序
             // 指定的省份顺序
             var specifiedOrder = new List<string> { "四川", "重庆", "贵州", "云南" };
             var specifiedOrder = new List<string> { "四川", "重庆", "贵州", "云南" };
-            if (detailsList.Any()) 
+            if (detailsList.Any())
                 detailsList = VisaFeeStandardDetails.SortByProvinces(detailsList, specifiedOrder);
                 detailsList = VisaFeeStandardDetails.SortByProvinces(detailsList, specifiedOrder);
 
 
             view.VisaFees = detailsList;
             view.VisaFees = detailsList;
@@ -318,7 +318,7 @@ namespace OASystem.Infrastructure.Repositories.Resource
                 _sqlSugar.CommitTran();
                 _sqlSugar.CommitTran();
                 return new JsonView { Code = StatusCodes.Status200OK, Msg = "操作成功!" };
                 return new JsonView { Code = StatusCodes.Status200OK, Msg = "操作成功!" };
             }
             }
-            catch(Exception ex)
+            catch (Exception ex)
             {
             {
                 _sqlSugar.RollbackTran();
                 _sqlSugar.RollbackTran();
                 return new JsonView { Code = StatusCodes.Status400BadRequest, Msg = ex.Message };
                 return new JsonView { Code = StatusCodes.Status400BadRequest, Msg = ex.Message };
@@ -369,6 +369,56 @@ namespace OASystem.Infrastructure.Repositories.Resource
         }
         }
 
 
 
 
+        /// <summary>
+        /// 签证费用报价计算 Async
+        /// </summary>
+        /// <param name="provinceId"></param>
+        /// <param name="countryName"></param>
+        /// <returns></returns>
+        public async Task<JsonView> VisaFeeQuoteAsync(int provinceId, string countryName)
+        {
+            var info = await _sqlSugar.Queryable<Res_VisaFeeStandard>()
+                .FirstAsync(x => x.IsDel == 0 && x.Country.Contains(countryName));
+
+            if (info == null)
+                return new JsonView { Code = StatusCodes.Status400BadRequest, Msg = $"{countryName} 该国家签证费用信息不存在" };
+
+            var details = await _sqlSugar.Queryable<Res_VisaFeeStandardDetails>()
+                .FirstAsync(x => x.IsDel == 0 && x.ParentId == info.Id && x.ProvinceId == provinceId);
+
+            if (details == null)
+                return new JsonView { Code = StatusCodes.Status400BadRequest, Msg = $"{countryName} 该国家签证费用信息不存在" };
+
+
+            decimal largeVisaQuote = 0.00M,  // 公务签证报价
+                    smallVisaQuote = 0.00M,  // 公务普通签证报价
+                    quotePrice1 = 0.00M;     // 报价费用1
+            var visaFeeLabel = new StringBuilder(); //签证费用描述
+
+            // 103  重庆
+            // 108  贵州
+            // 122  四川
+            // 132  云南
+            if (provinceId == 103) //重庆
+            {
+
+            }
+            else if (provinceId == 108) //贵州
+            {
+
+            }
+            else if (provinceId == 122) //四川
+            {
+
+            }
+            else if (provinceId == 132) //云南
+            {
+
+            }
+
+            return new JsonView { Code = StatusCodes.Status400BadRequest, Msg = "-" };
+        }
+
         #endregion
         #endregion
     }
     }
 }
 }