Browse Source

三公费用明细 -> 新增字段存储”境外用车费用明细“、境外用车 CURD、API代码编写,本地测试;

Lyyyi 20 hours ago
parent
commit
20c1be0772

+ 85 - 5
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -11039,10 +11039,11 @@ FROM
         /// 团组模块 - 出入境费用 - 境外用车计算详细信息
         /// </summary>
         /// <param name="groupId"></param>
+        /// <param name="currUserId"></param>
         /// <returns></returns>
         [HttpGet("{groupId}")]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> GetEnterExitCostOVFeeDetails(int groupId)
+        public async Task<IActionResult> GetEnterExitCostOVFeeDetails(int groupId,int currUserId)
         {
             var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.Id == groupId).FirstAsync();
             if (groupInfo == null)
@@ -11061,17 +11062,96 @@ FROM
                 return Ok(JsonView(true, "查询成功!", info));
             }
 
+            var userInfo = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0 && x.Id == currUserId).FirstAsync();
+            var userName = userInfo?.CnName ?? "-";
+            var nowTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+
             //返回默认数据
             info = new CityIntervalInfo()
             {
-                APTFeeDetails = new List<RoundTripTransferInfo>() { new() { Coefficient = Def_AirportTransferCoeff, ServiceCount = Def_ServiceCount } },
-                PullCartFeeDetails = new List<PullCartInfo>() { new() { Coefficient = Def_PullCartCoeff } },
-                TrainFeeDetails = new List<TrainInfo>() { new() { Coefficient = Def_TrainCoeff } },
-                CityAirTicketFeeDetails = new List<CityAirTicketInfo>() { new() { Coefficient = Def_CityFlightCoeff } }
+                APTFeeDetails = new List<RoundTripTransferInfo>() { new() { No = 1, Coefficient = Def_AirportTransferCoeff, ServiceCount = Def_ServiceCount } },
+                PullCartFeeDetails = new List<PullCartInfo>() { new() { No = 1, Coefficient = Def_PullCartCoeff } },
+                TrainFeeDetails = new List<TrainInfo>() { new() { No = 1, Coefficient = Def_TrainCoeff } },
+                CityAirTicketFeeDetails = new List<CityAirTicketInfo>() { new() { No = 1, Coefficient = Def_CityFlightCoeff } },
+                LastUpdateUserName = userName,
+                LastUpdateTime = nowTime,
+                CreateUserName = userName,
+                Currencies = await GeneralMethod.EnterExitCostOVFeeUsedCurrencyAsync(groupId),
+                CreateTime = nowTime
             };
 
             return Ok(JsonView(true, "查询成功!", info));
         }
+
+        /// <summary>
+        /// 团组模块 - 出入境费用 - 境外用车计算 保存
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> GetEnterExitCostOVFeeSave(GetEnterExitCostOVFeeSaveDto dto)
+        {
+            var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.Id == dto.GroupId).FirstAsync();
+            if (groupInfo == null)
+            {
+                return Ok(JsonView(false, "团组信息为空"));
+            }
+
+            var userInfo = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0 && x.Id == dto.CurrUserId).FirstAsync();
+            if (userInfo == null)
+            {
+                return Ok(JsonView(false, "员工信息为空"));
+            }
+
+            var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.GroupId).FirstAsync();
+
+            if (eecInfo == null)
+            {
+                return Ok(JsonView(false, "出入境费用信息为空"));
+            }
+            var oldData = new CityIntervalInfo();
+            if (!string.IsNullOrEmpty(eecInfo.CityIntervalFeeDetails))
+            {
+                oldData = JsonConvert.DeserializeObject<CityIntervalInfo>(eecInfo.CityIntervalFeeDetails);
+            }
+
+            var userName = userInfo?.CnName ?? "-";
+            var nowTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+
+            var info = new CityIntervalInfo()
+            {
+                APTFeeTotal = dto.APTFeeTotal,
+                APTFeeDetails = dto.APTFeeDetails,
+                PullCartFeeTotal = dto.PullCartFeeTotal,
+                PullCartFeeDetails = dto.PullCartFeeDetails,
+                TrainFeeTotal = dto.TrainFeeTotal,
+                TrainFeeDetails = dto.TrainFeeDetails,
+                CityAirTicketFeeTotal = dto.CityAirTicketFeeTotal,
+                CityAirTicketFeeDetails = dto.CityAirTicketFeeDetails,
+                Currencies = dto.Currencies,
+                LastUpdateUserName = userName,
+                LastUpdateTime = nowTime,
+                CreateUserName = oldData?.CreateUserName ?? userName,
+                CreateTime = oldData?.CreateTime ?? nowTime
+            };
+
+            eecInfo.CityIntervalFeeDetails = JsonConvert.SerializeObject(info);
+
+            var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
+                .SetColumns(it => it.CityIntervalFeeDetails == eecInfo.CityIntervalFeeDetails)
+                .SetColumns(it => it.LastUpdateUserId == dto.CurrUserId)
+                .SetColumns(it => it.LastUpdateTime == nowTime)
+                .Where(x => x.Id == eecInfo.Id)
+                .ExecuteCommandAsync();
+            if (upd < 1)
+            {
+                return Ok(JsonView(false));
+            }
+
+            return Ok(JsonView(true));
+        }
+
         #endregion
 
         /// <summary>

+ 93 - 13
OASystem/OASystem.Api/OAMethodLib/GeneralMethod.cs

@@ -4,11 +4,10 @@ using Aspose.Words;
 using Aspose.Words.Layout;
 using Aspose.Words.Saving;
 using Aspose.Words.Tables;
-using Dm.util;
+using Humanizer;
 using Microsoft.AspNetCore.SignalR;
 using Microsoft.International.Converters.PinYinConverter;
 using NodaTime;
-using NPOI.OpenXmlFormats.Vml;
 using OASystem.API.OAMethodLib.File;
 using OASystem.API.OAMethodLib.Hub.HubClients;
 using OASystem.API.OAMethodLib.Hub.Hubs;
@@ -17,20 +16,19 @@ using OASystem.API.OAMethodLib.KiMiApi;
 using OASystem.API.OAMethodLib.SignalR.Hubs;
 using OASystem.Domain.AesEncryption;
 using OASystem.Domain.Dtos.Groups;
+using OASystem.Domain.Dtos.PersonnelModule;
 using OASystem.Domain.Entities.Customer;
 using OASystem.Domain.Entities.Financial;
 using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.ViewModels.Financial;
 using OASystem.Domain.ViewModels.Groups;
 using OASystem.Domain.ViewModels.JuHeExchangeRate;
-using OASystem.Domain.ViewModels.Statistics;
+using OASystem.Domain.ViewModels.PersonnelModule;
 using OASystem.Infrastructure.Repositories.CRM;
 using OASystem.Infrastructure.Repositories.Groups;
 using System.Data;
 using System.IdentityModel.Tokens.Jwt;
 using System.Security.Claims;
-using OASystem.Domain.ViewModels.PersonnelModule;
-using OASystem.Domain.Dtos.PersonnelModule;
 
 namespace OASystem.API.OAMethodLib
 {
@@ -4297,6 +4295,88 @@ namespace OASystem.API.OAMethodLib
         /// </summary>
         private readonly static decimal _fxRateRise = 1.0350M;
 
+        #region 城市区间费用详情
+
+        /// <summary>
+        /// 城市区间费用详情 使用的币种及汇率
+        /// </summary>
+        /// <param name="groupId"></param>
+        /// <returns></returns>
+        public static async Task<List<CurrencyInfo>> EnterExitCostOVFeeUsedCurrencyAsync(int groupId = 0)
+        {
+            var infos = new List<CurrencyInfo>();
+
+            bool isUsedGroup = false;
+            var countryies = new List<string>();
+
+            var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.Id == groupId).FirstAsync();
+            if (groupInfo != null)
+            {
+                countryies = _dirRep.GroupSplitCountry(groupInfo.VisitCountry);
+                if (countryies.Any())
+                {
+                    isUsedGroup = true;
+                }
+            }
+
+            infos = await _sqlSugar.Queryable<Res_OverseaVehicle>()
+                .LeftJoin<Sys_SetData>((ov, sd) => ov.Currency == sd.Id)
+                .Where((ov, sd) => ov.IsDel == 0)
+                .WhereIF(isUsedGroup, (ov, sd) => countryies.Contains(ov.CountryName))
+                .Select((ov, sd) => new CurrencyInfo()
+                {
+                    CurrencyCode = sd.Name.ToUpper(),
+                    CurrencyName = sd.Remark
+                })
+                .ToListAsync();
+
+            //出入境费用存储的币种及汇率
+            var eexCurrencyInfos = new List<CurrencyInfo>();
+            if (infos.Any())
+            {
+                var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).FirstAsync();
+                if (eecInfo != null)
+                {
+                    eexCurrencyInfos = CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark);
+                }
+            }
+
+            //合并已使用币种及汇率
+            infos.ForEach(x =>
+            {
+                var eexCurrencyInfo = eexCurrencyInfos.Where(y => y.CurrencyCode == x.CurrencyCode).FirstOrDefault();
+                if (eexCurrencyInfo != null)
+                {
+                    x.Rate = eexCurrencyInfo.Rate;
+                }
+            });
+
+            //未存储费用集合
+            var unSaveCurrInfos = infos.Where(x => !eexCurrencyInfos.Any(y => y.CurrencyCode == x.CurrencyCode)).ToList();
+            if (unSaveCurrInfos.Any())
+            {
+                var currencyRate = await _juHeApi.PostItemRateAsync(unSaveCurrInfos.Select(it => it.CurrencyCode!).ToArray());
+                if (currencyRate.Count > 0)
+                {
+                    foreach (var item in infos)
+                    {
+                        var rateInfo = currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
+                        if (rateInfo != null)
+                        {
+                            decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
+                            rate1 *= _fxRateRise;
+
+                            item.Rate = rate1.TruncDecimals(4) + _xchgRateAdj;
+                        }
+                    }
+                }
+            }
+
+            return infos;
+        }
+
+        #endregion
+
         /// <summary>
         /// 出入境费用 初始化汇率
         /// </summary>
@@ -4304,13 +4384,13 @@ namespace OASystem.API.OAMethodLib
         public static async Task<List<CurrencyInfo>> EnterExitCostInitRate()
         {
             //默认币种显示
-            List<CurrencyInfo> currencyInfos = new List<CurrencyInfo>()
+            var currencyInfos = new List<CurrencyInfo>()
                 {
-                    new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
-                    new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
-                    new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
-                    new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
-                    new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
+                    new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
+                    new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
+                    new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
+                    new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
+                    new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
                 };
 
             var currencyRate = await _juHeApi.PostItemRateAsync(currencyInfos.Select(it => it.CurrencyCode!).ToArray());
@@ -4433,8 +4513,8 @@ namespace OASystem.API.OAMethodLib
                     //if (cacheRate.Rate != currRate)
                     //{
                     //    isSendMsg = true;
-                        //>团组归属:<font color='info'>{groupName}</font>
-                        msgContent.AppendLine($">- {cacheRate.CurrencyName}汇率(页面保存):{cacheRate.Rate:#0.0000}  / 实时汇率(接口保存,已上浮1.0350):{currRate:#0.0000}【原接口输出汇率为:{liveRate.Rate:#0.0000}】");
+                    //>团组归属:<font color='info'>{groupName}</font>
+                    msgContent.AppendLine($">- {cacheRate.CurrencyName}汇率(页面保存):{cacheRate.Rate:#0.0000}  / 实时汇率(接口保存,已上浮1.0350):{currRate:#0.0000}【原接口输出汇率为:{liveRate.Rate:#0.0000}】");
                     //}
                 }
                 return (isSendMsg, msgContent.ToString(), liveRates);

+ 9 - 1
OASystem/OASystem.Domain/Dtos/Groups/EnterExitCostDto.cs

@@ -14,6 +14,7 @@ namespace OASystem.Domain.Dtos.Groups
     public class EnterExitCostDataSourceDto : PortDtoBase
     {
         //public int ProvinceId { get; set; } = 1408;
+
     }
 
     /// <summary>
@@ -478,7 +479,15 @@ namespace OASystem.Domain.Dtos.Groups
         public string? Remark { get; set; }
     }
 
+    #region 境外用车
+
+    public class GetEnterExitCostOVFeeSaveDto: CityIntervalInfo
+    {
+        public int GroupId { get; set; }
+        public int CurrUserId { get; set; }
+    }
 
+    #endregion
 
     #region Mobile Request Dto
 
@@ -893,7 +902,6 @@ namespace OASystem.Domain.Dtos.Groups
 
     #endregion
 
-
     #region Draft Mobile Request Dto
 
     //EnterExitCostDraftMobileNameData

+ 27 - 2
OASystem/OASystem.Domain/ViewModels/Groups/EnterExitCostView.cs

@@ -1337,6 +1337,31 @@ namespace OASystem.Domain.ViewModels.Groups
         /// 城市机票费用详情
         /// </summary>
         public List<CityAirTicketInfo> CityAirTicketFeeDetails { get; set; }
+
+        /// <summary>
+        /// 币种信息
+        /// </summary>
+        public List<CurrencyInfo> Currencies { get; set; }
+
+        /// <summary>
+        /// 最后操作人
+        /// </summary>
+        public string LastUpdateUserName  { get; set; }
+
+        /// <summary>
+        /// 最后操作时间
+        /// </summary>
+        public string LastUpdateTime { get; set; }
+
+        /// <summary>
+        /// 创建人
+        /// </summary>
+        public string CreateUserName { get; set; }
+
+        /// <summary>
+        /// 创建时间
+        /// </summary>
+        public string CreateTime { get; set; }
     }
 
     /// <summary>
@@ -1344,8 +1369,6 @@ namespace OASystem.Domain.ViewModels.Groups
     /// </summary>
     public class RoundTripTransferInfo : CityIntervalBase
     {
-        public int No { get; set; }
-
         /// <summary>
         /// 境外用车服务类型(接送机) Id
         /// </summary>
@@ -1386,6 +1409,8 @@ namespace OASystem.Domain.ViewModels.Groups
 
     public class CityIntervalBase
     {
+        public int No { get; set; }
+
         /// <summary>
         /// 成本
         /// </summary>