Browse Source

OperationCountryFeeCost
更改 修改代码

leiy 10 months ago
parent
commit
759a74d850

+ 0 - 10
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -11376,11 +11376,9 @@ namespace OASystem.API.Controllers
         //                else {
         //                    temp.PassengerType = -1;
         //                }
-
         //                temp.VisaNumber = item.VisaNumber;
         //                temp.VisaFreeNumber = item.VisaFreeNumber;
         //                temp.CreateUserId = item.Operators;
-
         //                DateTime dt_ct;
         //                bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
         //                if (b_ct)
@@ -11391,31 +11389,25 @@ namespace OASystem.API.Controllers
         //                {
         //                    temp.CreateTime = DateTime.Now;
         //                }
-
         //                temp.DeleteTime = "";
         //                temp.DeleteUserId = 0;
         //                temp.Remark = item.Remark;
         //                if (string.IsNullOrEmpty(temp.Remark)) {
         //                    temp.Remark = "";
         //                }
-
         //                temp.IsDel = item.IsDel;
         //                temp.VisaDescription = item.VisaAttachment;
-
         //                string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
-
         //([Id]
         //           ,[DIId]
         //           ,[VisaClient]
         //           ,[VisaPrice]
         //           ,[VisaCurrency]
-
         //           ,[IsThird]
         //           ,[PassengerType]
         //           ,[VisaNumber]
         //           ,[VisaFreeNumber]
         //           ,[CreateUserId]
-
         //           ,[CreateTime]
         //           ,[DeleteTime]
         //           ,[DeleteUserId]
@@ -11431,8 +11423,6 @@ namespace OASystem.API.Controllers
         //);
         //               await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
         //            }
-
-
         //            return Ok(JsonView(true, "操作成功!"));
         //        }
 

+ 12 - 0
OASystem/OASystem.Domain/Entities/Groups/Grp_VisaFeeInfo.cs

@@ -33,12 +33,24 @@ namespace OASystem.Domain.Entities.Groups
         [SugarColumn(IsNullable = true,ColumnDataType = "int")]
         public int CountryVisaFeeId { get; set; }
 
+
+        /// <summary>
+        /// 代办费 - 公务 类型 1 大公务 2 小公务
+        /// 新增字段
+        /// 雷怡 2024-05-07 15:45:09
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
+        public int OBType { get; set; }
+
         /// <summary>
         /// 代办费
+        /// 新增字段
+        /// 雷怡 2024-05-07 15:45:09
         /// </summary>
         [SugarColumn(IsNullable = true, ColumnDataType = "decimal(10,2)")]
         public decimal AgencyFee { get; set; }
 
+
         /// <summary>
         /// 其他费用
         /// </summary>

+ 24 - 0
OASystem/OASystem.Domain/ViewModels/Groups/VisaFeeInfoView.cs

@@ -33,8 +33,32 @@ namespace OASystem.Domain.ViewModels.Groups
         /// </summary>
         public decimal VisaFee { get; set; }
 
+        /// <summary>
+        /// 代办费 - 公务 类型 1 大公务 2 小公务
+        /// 新增
+        /// 雷怡 2024-08-07 17:08:13
+        /// </summary>
+        public int OBType { get; set; }
+
+        /// <summary>
+        /// 代办费公务描述
+        /// 雷怡 2024-08-07 17:08:23
+        /// </summary>
+        public string OBTypeStr
+        {
+            get
+            {
+                string str = "Unknown";
+                if (OBType == 1) str = "大公务";
+                else if (OBType == 2) str = "小公务";
+                return str;
+            }
+        }
+
         /// <summary>
         /// 代办费
+        /// 新增
+        /// 雷怡 2024-05-07 15:45:09
         /// </summary>
         public decimal AgencyFee { get; set; }
 

+ 84 - 42
OASystem/OASystem.Infrastructure/Repositories/Groups/VisaFeeInfoRepository.cs

@@ -40,8 +40,6 @@ namespace OASystem.Infrastructure.Repositories.Groups
         /// <returns></returns>
         public async Task<Result> _Init()
         {
-            
-
             var data = await _sqlSugar.Queryable<Res_CountryFeeCost>().Where(it => it.IsDel == 0).ToListAsync();
             _result.Code = 0;
             _result.Data = data;
@@ -62,10 +60,10 @@ namespace OASystem.Infrastructure.Repositories.Groups
             if (portType < 1  || portType > 3) return _result = new Result() { Code = -1, Msg = "请传入有效的portType参数" };
 
             string sql = string.Format($@"Select vfi.Id,vfi.IsChecked,cfc.VisaCountry AS Country,cfc.VisaPrice As VisaFee,
-                                            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}");
+                                          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();
             _result.Code = 0;
             _result.Data = data;
@@ -88,17 +86,32 @@ namespace OASystem.Infrastructure.Repositories.Groups
 
             BeginTran();
             bool visaFeeUpdate = false;
-            foreach (var item in dto.VisaFeeInfos)
+
+            var countrys = dto.VisaFeeInfos.GroupBy(x => x.Country);
+
+            foreach (var country in countrys)
             {
                 int countryVisaFeeId = 0;
-                var info =await _countryFeeRep._InfoByCountryName(item.Country);
+                decimal _grandBusinessAgencyFee = 0;
+                decimal _pettyBusinessAgencyFee = 0;
+                decimal _visaFee = 0;
+                foreach (var item in country.ToList())
+                {
+                    _visaFee = item.VisaFee;
+                    if (item.OBType == 1) _grandBusinessAgencyFee = item.AgencyFee;
+                    else if (item.OBType == 2) _pettyBusinessAgencyFee = item.AgencyFee;
+                }
+
+                var info = await _countryFeeRep._InfoByCountryName(country.Key);
                 if (info == null) //添加
                 {
                     int addId = _sqlSugar.Insertable(
                         new Res_CountryFeeCost()
                         {
-                            VisaCountry = item.Country,
-                            VisaPrice = item.VisaFee,
+                            VisaCountry = country.Key,
+                            VisaPrice = _visaFee,
+                            GrandBusinessAgencyFee = _grandBusinessAgencyFee,
+                            PettyBusinessAgencyFee = _pettyBusinessAgencyFee,
                             LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                             CreateUserId = dto.OpUserId,
                         }).ExecuteReturnIdentity();
@@ -107,12 +120,14 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 else //修改
                 {
                     countryVisaFeeId = info.Id;
-                    if (item.VisaFee != info.VisaPrice) //价格不同的时候执行修改
+                    if (_visaFee != info.VisaPrice) //价格不同的时候执行修改
                     {
                         Res_CountryFeeCost _CountryFeeCost = new Res_CountryFeeCost()
                         {
                             Id = info.Id,
-                            VisaPrice = item.VisaFee,
+                            VisaPrice = _visaFee,
+                            GrandBusinessAgencyFee = _grandBusinessAgencyFee,
+                            PettyBusinessAgencyFee = _pettyBusinessAgencyFee,
                             LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                         };
                         int update1 = _sqlSugar.Updateable(_CountryFeeCost).UpdateColumns(it => new { it.VisaPrice, it.LastUpdateTime }).WhereColumns(it => it.Id).ExecuteCommand();
@@ -120,21 +135,25 @@ namespace OASystem.Infrastructure.Repositories.Groups
                         {
                             visaFeeUpdate = true;
                         }
-                       
                     }
                 }
 
-                visaInfos.Add(new Grp_VisaFeeInfo()
+                foreach (var item in country.ToList())
                 {
-                    Id = item.Id,
-                    DiId = dto.DiId,
-                    IsChecked = item.IsChecked,
-                    CountryVisaFeeId = countryVisaFeeId,
-                    AgencyFee = item.AgencyFee,
-                    OtherFee = item.OtherFee
-                });
+                    visaInfos.Add(new Grp_VisaFeeInfo()
+                    {
+                        Id = item.Id,
+                        DiId = dto.DiId,
+                        IsChecked = item.IsChecked,
+                        CountryVisaFeeId = countryVisaFeeId,
+                        OBType = item.OBType,
+                        AgencyFee = item.AgencyFee,
+                        OtherFee = item.OtherFee
+                    });
+                }
             }
 
+
             //执行删除
             var update = _sqlSugar.Updateable<Grp_VisaFeeInfo>().SetColumns(it => new Grp_VisaFeeInfo()
             {
@@ -172,32 +191,55 @@ namespace OASystem.Infrastructure.Repositories.Groups
             List<dynamic> datas = new List<dynamic>();
             string remark = "";
             decimal feeTotal = 0.00M;
-            foreach (var item in visaData)
+
+            visaData = visaData.Where(it => it.IsChecked == 1).ToList();
+            var visaData1 = visaData.GroupBy(it => it.CountryVisaFeeId);
+
+            foreach (var kvp in visaData1)
             {
-                if (item.IsChecked == 1)
+                var countryData = visaCountryDatas.Find(it => it.Id == kvp.Key);
+                decimal _otherFee = kvp.FirstOrDefault()?.OtherFee ?? 0;
+                decimal visaFeeTotal = Convert.ToDecimal(countryData?.VisaPrice ?? 0.00M) + _otherFee;
+                decimal _agencyFee = 0;
+                decimal _GrandBusinessAgencyFee = 0;
+                decimal _PettyBusinessAgencyFee = 0;
+                remark += $@"{countryData?.VisaCountry ?? ""}:签证总费用:{visaFeeTotal}元/人 其中(";
+                foreach (var item in kvp.ToList())
                 {
-                    var countryData = visaCountryDatas.Find(it => it.Id == item.CountryVisaFeeId);
-
-                    decimal visaFeeTotal = Convert.ToDecimal( countryData?.VisaPrice ?? 0.00M) + item.AgencyFee + item.OtherFee;
-                    remark += $@"{countryData?.VisaCountry ?? ""}:签证总费用:{visaFeeTotal}元/人 其中(";
-                    if (countryData?.VisaPrice > 0) remark += $@"签证费用:{countryData?.VisaPrice.ToString("#0.00")}元、";
-                    if (item.AgencyFee > 0) remark += $@"代办费:{item.AgencyFee.ToString("#0.00")}元、";
-                    if (item.OtherFee > 0) remark += $@"其他费用:{item.OtherFee.ToString("#0.00")}元";
+                    if (item.OBType == 1)
+                    {
+                        if (item.AgencyFee > 0)
+                        {
+                            remark += $@"大公务代办费:{item.AgencyFee.ToString("#0.00")}元、";
+                            _agencyFee += item.AgencyFee;
+                            _GrandBusinessAgencyFee = item.AgencyFee;
+                        }
+                    }
+                    else if (item.OBType == 1)
+                    {
+                        if (item.AgencyFee > 0)
+                        {
+                            remark += $@"小公务代办费:{item.AgencyFee.ToString("#0.00")}元、";
+                            _agencyFee += item.AgencyFee;
+                            _PettyBusinessAgencyFee = item.AgencyFee;
+                        }
+                    }
+                }
 
-                    if (visaFeeTotal > 0) remark = remark.Substring(0,remark.Length -1);
+                if (_otherFee > 0) remark += $@"其他费用:{_otherFee.ToString("#0.00")}元";
 
-                    remark += ");";
-                    feeTotal += visaFeeTotal;
-                    datas.Add(new
-                    {
-                        Country = countryData?.VisaCountry ?? "",
-                        visaFeeTotal = visaFeeTotal,
-                        VisaFee = countryData?.VisaPrice ?? 0.00M,
-                        item.AgencyFee,
-                        item.OtherFee
+                remark += ");";
+                feeTotal += visaFeeTotal;
 
-                    });
-                }
+                datas.Add(new
+                {
+                    Country = countryData?.VisaCountry ?? "",
+                    visaFeeTotal = visaFeeTotal,
+                    VisaFee = countryData?.VisaPrice ?? 0.00M,
+                    GrandBusinessAgencyFee = _GrandBusinessAgencyFee,
+                    PettyBusinessAgencyFee = _PettyBusinessAgencyFee,
+                    OtherFee = _otherFee
+                });
             }
 
             _result.Code = 0;

+ 7 - 3
OASystem/OASystem.Infrastructure/Repositories/Resource/CountryFeeRepository.cs

@@ -38,6 +38,7 @@ namespace OASystem.Infrastructure.Repositories.Resource
 
             Res_CountryFeeCost _CountryFeeCost = _mapper.Map<Res_CountryFeeCost>(dto);
 
+            _CountryFeeCost.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
             if (dto.Status == 1)//添加
             {
                 string selectSql = string.Format(@"select * from Res_CountryFeeCost where VisaContinent='{0}' and VisaCountry='{1}' and IsDel='{2}'"
@@ -62,9 +63,12 @@ namespace OASystem.Infrastructure.Repositories.Resource
             }
             else if (dto.Status == 2)//修改
             {
-                _CountryFeeCost.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
-                bool res = await UpdateAsync(a => a.Id == dto.Id, a => _CountryFeeCost);
-                if (!res)
+                var update = await _sqlSugar.Updateable(_CountryFeeCost)
+                                            .IgnoreColumns(it => new { it.Id, it.DeleteUserId, it.DeleteTime, it.CreateUserId, it.CreateTime, it.IsDel })
+                                            .Where(it => it.Id == _CountryFeeCost.Id)
+                                            .ExecuteCommandAsync();
+                //bool res = await UpdateAsync(a => a.Id == dto.Id, a => _CountryFeeCost);
+                if (update < 1)
                 {
                     return result = new Result() { Code = -1, Msg = "修改失败!" };
                 }