Browse Source

Merge branch 'develop' of http://132.232.92.186:3000/XinXiBu/OA2023 into develop

leiy 1 year ago
parent
commit
f1c0935b08

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

@@ -30,6 +30,10 @@ using NPOI.HPSF;
 using SqlSugar;
 using SqlSugar;
 using System.Collections;
 using System.Collections;
 using Org.BouncyCastle.Ocsp;
 using Org.BouncyCastle.Ocsp;
+using System.Globalization;
+using static QRCoder.PayloadGenerator;
+using Bookmark = Aspose.Words.Bookmark;
+using Aspose.Words.Fields;
 
 
 namespace OASystem.API.Controllers
 namespace OASystem.API.Controllers
 {
 {
@@ -68,7 +72,7 @@ namespace OASystem.API.Controllers
         public GroupsController(IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
         public GroupsController(IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
             TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
             TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
             InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
             InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
-            , DelegationVisaRepository delegationVisaRep, MessageRepository message,VisaPriceRepository visaPriceRep,CarTouristGuideGroundRepository carTouristGuideGroundRep,CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
+            , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep, CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
             GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep)
             GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep)
         {
         {
             _mapper = mapper;
             _mapper = mapper;
@@ -89,8 +93,8 @@ namespace OASystem.API.Controllers
             _enterExitCostRep = enterExitCostRep;
             _enterExitCostRep = enterExitCostRep;
             _delegationVisaRep = delegationVisaRep;
             _delegationVisaRep = delegationVisaRep;
             _message = message;
             _message = message;
-            _visaPriceRep= visaPriceRep;
-            _carTouristGuideGroundRep= carTouristGuideGroundRep;
+            _visaPriceRep = visaPriceRep;
+            _carTouristGuideGroundRep = carTouristGuideGroundRep;
             _checkBoxs = checkBoxs;
             _checkBoxs = checkBoxs;
             _GroupCostRepository = GroupCostRepository;
             _GroupCostRepository = GroupCostRepository;
             _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
             _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
@@ -98,7 +102,7 @@ namespace OASystem.API.Controllers
             _hotelPriceRep = hotelPriceRep;
             _hotelPriceRep = hotelPriceRep;
         }
         }
 
 
-        
+
         #region 流程管控
         #region 流程管控
 
 
         /// <summary>
         /// <summary>
@@ -298,17 +302,17 @@ namespace OASystem.API.Controllers
                 RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
                 RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
                 var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
                 var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
 
 
-                return Ok(JsonView(true,"查询成功!",_DelegationList, total));
+                return Ok(JsonView(true, "查询成功!", _DelegationList, total));
 
 
             }
             }
             else
             else
             {
             {
                 return Ok(JsonView(false, "查询失败"));
                 return Ok(JsonView(false, "查询失败"));
             }
             }
-               
-           
 
 
-            
+
+
+
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -444,10 +448,10 @@ namespace OASystem.API.Controllers
 
 
             GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
             GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
 
 
-            return Ok(JsonView(true,"操作成功!",groupData.Data));
+            return Ok(JsonView(true, "操作成功!", groupData.Data));
         }
         }
 
 
-        
+
 
 
         /// <summary>
         /// <summary>
         /// 获取团组名称data  And 签证国别Data
         /// 获取团组名称data  And 签证国别Data
@@ -702,10 +706,11 @@ namespace OASystem.API.Controllers
                         .SetColumns(it => it.WorkStatus == dto.visaStatus)
                         .SetColumns(it => it.WorkStatus == dto.visaStatus)
                         .Where(s => s.Id == dto.visaProgressCustomerId)
                         .Where(s => s.Id == dto.visaProgressCustomerId)
                         .ExecuteCommandAsync();
                         .ExecuteCommandAsync();
-                    if (updCount > 0 && dto.publishCode == 1) {
+                    if (updCount > 0 && dto.publishCode == 1)
+                    {
 
 
                         _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
                         _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
-                        
+
                         string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
                         string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
                         OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
                         OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
                         //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
                         //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
@@ -731,7 +736,8 @@ namespace OASystem.API.Controllers
                             }
                             }
                         });
                         });
 
 
-                        if (rst) {
+                        if (rst)
+                        {
                             return Ok(JsonView(true, "发送通知成功"));
                             return Ok(JsonView(true, "发送通知成功"));
                         }
                         }
                     }
                     }
@@ -2795,14 +2801,14 @@ namespace OASystem.API.Controllers
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> GetNationalTravelFeePageDataSource()
         public async Task<IActionResult> GetNationalTravelFeePageDataSource()
         {
         {
-           
+
             string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0  ");
             string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0  ");
 
 
             var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
             var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
 
 
             List<string> countryData = new List<string>();
             List<string> countryData = new List<string>();
 
 
-            countryData.AddRange( nationalTravelFeeData.Select(it => it.Country ).ToList());
+            countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
             countryData = countryData.Distinct().ToList();
             countryData = countryData.Distinct().ToList();
 
 
             List<dynamic> dataSource = new List<dynamic>();
             List<dynamic> dataSource = new List<dynamic>();
@@ -2815,7 +2821,7 @@ namespace OASystem.API.Controllers
                     CountryName = item,
                     CountryName = item,
                     CityData = cityData1
                     CityData = cityData1
                 };
                 };
-                
+
                 dataSource.Add(countryData2);
                 dataSource.Add(countryData2);
             }
             }
 
 
@@ -2831,9 +2837,9 @@ namespace OASystem.API.Controllers
         public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
         public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
         {
         {
             int portId = dto.PortType;
             int portId = dto.PortType;
-            if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS")); 
+            if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
 
 
-            if (dto.PageIndex == 0)  return Ok(JsonView(false, "当前页码数不能为0!"));
+            if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
             if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
             if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
 
 
             string whereSql = string.Empty;
             string whereSql = string.Empty;
@@ -2887,7 +2893,7 @@ namespace OASystem.API.Controllers
                 whereSql = string.Format(@"And City = '{0}' ", dto.City);
                 whereSql = string.Format(@"And City = '{0}' ", dto.City);
             }
             }
 
 
-            
+
             string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode, 
             string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode, 
 	                                                ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
 	                                                ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
 	                                                gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime 
 	                                                gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime 
@@ -2939,7 +2945,8 @@ namespace OASystem.API.Controllers
         {
         {
             try
             try
             {
             {
-                Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee() { 
+                Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
+                {
                     Id = dto.Id,
                     Id = dto.Id,
                     DeleteUserId = dto.DeleteUserId,
                     DeleteUserId = dto.DeleteUserId,
                     DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
                     DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
@@ -3077,7 +3084,7 @@ namespace OASystem.API.Controllers
                     PassengerType = _PassengerType,
                     PassengerType = _PassengerType,
                     BankCard = _BankCard
                     BankCard = _BankCard
                 };
                 };
-                return Ok(JsonView(true, "查询成功!",data));
+                return Ok(JsonView(true, "查询成功!", data));
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
@@ -3146,8 +3153,8 @@ namespace OASystem.API.Controllers
         {
         {
             try
             try
             {
             {
-                Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a=>a.Id==dto.Id && a.IsDel==0);
-                Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable==79 && a.IsDel == 0);
+                Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
+                Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
                 var data = new
                 var data = new
                 {
                 {
                     CarTouristGuideGround = _groupData,
                     CarTouristGuideGround = _groupData,
@@ -3308,9 +3315,9 @@ namespace OASystem.API.Controllers
                 ELSE 'False' END as isTrue  from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
                 ELSE 'False' END as isTrue  from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
                  Where TeamName != '' And IsDel = 0  Order By a.Id Desc
                  Where TeamName != '' And IsDel = 0  Order By a.Id Desc
             ").ToList(); //团组列表
             ").ToList(); //团组列表
-            int diid = dto.Diid == - 1 ? groupList.First().Id : dto.Diid;
-            var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType =  1 , Id = diid }); //团组信息
-            var groupChecks =   _checkBoxs.GetCheckBoxsByDiid(diid);  //团组选中信息  可枚举
+            int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
+            var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
+            var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid);  //团组选中信息  可枚举
             var groupCost = _GroupCostRepository.GetAllByDiid(diid);  //团组列表信息  
             var groupCost = _GroupCostRepository.GetAllByDiid(diid);  //团组列表信息  
             var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
             var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
             var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
             var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
@@ -3320,7 +3327,8 @@ namespace OASystem.API.Controllers
             //     Grp_GroupCostParameter());
             //     Grp_GroupCostParameter());
             var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
             var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
 
 
-            return Ok(JsonView(new {
+            return Ok(JsonView(new
+            {
                 groupList,
                 groupList,
                 groupInfo,
                 groupInfo,
                 groupChecks,
                 groupChecks,
@@ -3341,7 +3349,7 @@ namespace OASystem.API.Controllers
             JsonView jw = null;
             JsonView jw = null;
             bool isTrue = false;
             bool isTrue = false;
             var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
             var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
-            Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now;}); //.ToString("yyyy-MM-dd HH:mm:ss")
+            Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
             var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
             var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
             Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
             Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
             var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
             var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
@@ -3350,13 +3358,13 @@ namespace OASystem.API.Controllers
             try
             try
             {
             {
                 _sqlSugar.BeginTran();
                 _sqlSugar.BeginTran();
-                isTrue = await _GroupCostRepository.SaveGroupCostList(Grp_groups,dto.Diid); //列表
-                isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs,dto.Diid); //选中项
-                isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber,dto.Diid); //酒店房间数量
+                isTrue = await _GroupCostRepository.SaveGroupCostList(Grp_groups, dto.Diid); //列表
+                isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
+                isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Diid); //酒店房间数量
                 isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Diid); //系数
                 isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Diid); //系数
 
 
                 _sqlSugar.CommitTran();
                 _sqlSugar.CommitTran();
-                jw = JsonView(true,"保存成功!",isTrue);
+                jw = JsonView(true, "保存成功!", isTrue);
             }
             }
             catch (Exception)
             catch (Exception)
             {
             {
@@ -3502,6 +3510,30 @@ namespace OASystem.API.Controllers
                 return Ok(JsonView(false, ex.Message));
                 return Ok(JsonView(false, ex.Message));
             }
             }
         }
         }
+        /// <summary>
+        /// 计算酒店付款总金额
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> HotelConversionAmounts(HotelReservationsCNYDto dto)
+        {
+            try
+            {
+                Result groupData = await _hotelPriceRep.HotelConversionAmounts(dto);
+                if (groupData.Code != 0)
+                {
+                    return Ok(JsonView(false, groupData.Msg));
+                }
+                return Ok(JsonView(true, groupData.Msg, groupData.Data));
+            }
+            catch (Exception ex)
+            {
+                return Ok(JsonView(false, ex.Message));
+            }
+        }
+
         /// <summary>
         /// <summary>
         /// 根基酒店费用操作(Status:1.新增,2.修改)
         /// 根基酒店费用操作(Status:1.新增,2.修改)
         /// </summary>
         /// </summary>
@@ -3525,8 +3557,417 @@ namespace OASystem.API.Controllers
                 return Ok(JsonView(false, ex.Message));
                 return Ok(JsonView(false, ex.Message));
             }
             }
         }
         }
+
+        /// <summary>
+        /// region 文件上传  可以带参数
+        /// </summary>
+        /// <param name="file"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> UploadHotel(IFormFile file)
+        {
+            try
+            {
+                if (file != null)
+                {
+                    var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
+                    //文件名称
+                    string projectFileName = file.FileName;
+
+                    //上传的文件的路径
+                    string filePath = "";
+
+
+                    if (!Directory.Exists(fileDir))
+                    {
+                        Directory.CreateDirectory(fileDir);
+                    }
+
+                    //上传的文件的路径
+                    filePath = fileDir + $@"\酒店费用录入相关文件\{projectFileName}";
+
+
+                    using (FileStream fs = System.IO.File.Create(filePath))
+                    {
+                        file.CopyTo(fs);
+                        fs.Flush();
+                    }
+                    return Ok(JsonView(true, "上传成功!", projectFileName));
+                }
+                else
+                {
+                    return Ok(JsonView(false, "上传失败!"));
+                }
+            }
+            catch (Exception ex)
+            {
+                return Ok(JsonView(false, "程序错误!"));
+                throw;
+            }
+
+        }
+        /// <summary>
+        /// 删除指定文件
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> DelFileHotel(DelFileDto dto)
+        {
+            try
+            {
+                string filePath = "";
+                var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
+                // 返回与指定虚拟路径相对应的物理路径即绝对路径
+                int id = 0;
+                filePath = fileDir + "/酒店费用录入相关文件/" + dto.fileName;
+                // 删除该文件
+                System.IO.File.Delete(filePath);
+                id = await _sqlSugar.Updateable<Grp_HotelReservations>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_HotelReservations { Attachment = "" }).ExecuteCommandAsync();
+
+                if (id != 0)
+                {
+                    return Ok(JsonView(true, "成功!"));
+                }
+                else
+                {
+                    return Ok(JsonView(false, "失败!"));
+                }
+            }
+            catch (Exception ex)
+            {
+                return Ok(JsonView(false, "程序错误!"));
+                throw;
+            }
+
+        }
+        /// <summary>
+        /// 生成VOUCHER
+        /// </summary>
+        /// <param name=""></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> HotelGenerate(HotelReservationsByIdDto dto)
+        {
+
+            Grp_HotelReservations h = _sqlSugar.Queryable<Grp_HotelReservations>().First(a => a.Id == dto.Id && a.IsDel == 0);
+
+            //判断数据是否完整
+            if (h != null)
+            {
+                if (!string.IsNullOrEmpty(h.DetermineNo))
+                {
+                    string strFileName = "HotelStatement/";
+                    Grp_DelegationInfo dele= _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == h.DiId && a.IsDel == 0);
+                    if (dele != null)
+                        strFileName += dele.TourCode;
+
+                    
+                     //载入模板
+                    string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
+
+                    Document doc = new Document(sss);
+                    DocumentBuilder builder = new DocumentBuilder(doc);
+                    try
+                    {
+                        #region 替换Word模板书签内容
+
+                        //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
+                        //入住卷预定号码
+                       
+                        if (doc.Range.Bookmarks["VNO"] != null)
+                        {
+                            Bookmark mark = doc.Range.Bookmarks["VNO"];
+                            mark.Text = h.CheckNumber;
+                        }
+                        //酒店时间
+                        if (doc.Range.Bookmarks["Date"] != null)
+                        {
+                            Bookmark mark = doc.Range.Bookmarks["Date"];
+                            mark.Text = Convert.ToDateTime(h.CreateTime).ToString("yyyy-MM-dd");
+                        }
+                        //团号
+                        if (doc.Range.Bookmarks["TNo"] != null)
+                        {
+                            Bookmark mark = doc.Range.Bookmarks["TNo"];
+                            mark.Text = dele.TourCode;
+                        }
+                        //预定号码
+                        if (doc.Range.Bookmarks["BookingId"] != null)
+                        {
+                            Bookmark mark = doc.Range.Bookmarks["BookingId"];
+                            mark.Text = h.ReservationsNo;
+                        }
+
+                        if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
+                        {
+                            Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
+                            mark.Text = h.DetermineNo;
+                        }
+
+                        //酒店城市
+                        if (doc.Range.Bookmarks["City"] != null)
+                        {
+                            Bookmark mark = doc.Range.Bookmarks["City"];
+                            mark.Text = h.City;
+                        }
+                        //酒店名称
+                        if (doc.Range.Bookmarks["HName"] != null)
+                        {
+                            Bookmark mark = doc.Range.Bookmarks["HName"];
+                            mark.Text = h.HotelName;
+                        }
+                        //酒店地址
+                        if (doc.Range.Bookmarks["Address"] != null)
+                        {
+                            Bookmark mark = doc.Range.Bookmarks["Address"];
+                            mark.Text = h.HotelAddress;
+                        }
+                        //酒店电话
+                        if (doc.Range.Bookmarks["Tel"] != null)
+                        {
+                            Bookmark mark = doc.Range.Bookmarks["Tel"];
+                            mark.Text = h.HotelTel;
+                        }
+                        //酒店传真
+                        if (doc.Range.Bookmarks["Fax"] != null)
+                        {
+                            Bookmark mark = doc.Range.Bookmarks["Fax"];
+                            if (!string.IsNullOrWhiteSpace(h.HotelFax))
+                            {
+                                mark.Text = h.HotelFax;
+                            }
+                            
+                        }
+                        //入住时间
+                        if (doc.Range.Bookmarks["CIn"] != null)
+                        {
+                            DateTime dtCheckIn = Convert.ToDateTime(h.CheckInDate);
+                            Bookmark mark = doc.Range.Bookmarks["CIn"];
+                            mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
+                        }
+                        //退房时间
+                        if (doc.Range.Bookmarks["COut"] != null)
+                        {
+                            DateTime dtCheckOut = Convert.ToDateTime(h.CheckOutDate);
+                            Bookmark mark = doc.Range.Bookmarks["COut"];
+                            mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
+                        }
+                        //客户名称
+                        if (doc.Range.Bookmarks["GName"] != null)
+                        {
+                            Bookmark mark = doc.Range.Bookmarks["GName"];
+                            mark.Text = h.GuestName;
+                        }
+
+                        //房间介绍
+                        if (doc.Range.Bookmarks["ROOM"] != null)
+                        {
+                            Bookmark mark = doc.Range.Bookmarks["ROOM"];
+                            mark.Text = h.RoomExplanation;
+                        }
+
+                        //报价描述
+                        if (doc.Range.Bookmarks["NOTE"] != null)
+                        {
+                            Bookmark mark = doc.Range.Bookmarks["NOTE"];
+                            Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a=>a.Id==h.ReservationsWebsite);
+                            if (ss != null)
+                                mark.Text = ss.Name;
+                        }
+                        //入住时间
+                        if (doc.Range.Bookmarks["CheckIn"] != null)
+                        {
+                            DateTime dtCheckIn = Convert.ToDateTime(h.CheckInDate);
+                            Bookmark mark = doc.Range.Bookmarks["CheckIn"];
+                            mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
+                        }
+                        //退房时间
+                        if (doc.Range.Bookmarks["CheckOut"] != null)
+                        {
+                            DateTime dtCheckOut = Convert.ToDateTime(h.CheckOutDate);
+                            Bookmark mark = doc.Range.Bookmarks["CheckOut"];
+                            mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
+                        }
+                        //日期
+                        if (doc.Range.Bookmarks["DT"] != null)
+                        {
+                            Bookmark mark = doc.Range.Bookmarks["DT"];
+                            mark.Text = Convert.ToDateTime(h.CreateTime).ToString("yyyy-MM-dd");
+                        }
+                        //名称
+                        if (doc.Range.Bookmarks["VName"] != null)
+                        {
+                            Bookmark mark = doc.Range.Bookmarks["VName"];
+                            mark.Text = h.HotelName;
+                        }
+                        //号码
+                        if (doc.Range.Bookmarks["VOUCHERNO"] != null)
+                        {
+                            Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
+                            mark.Text = h.CheckNumber;
+                        }
+
+                        #endregion
+                        //string fileName = "HotelStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
+
+                        strFileName += "VOUCHER.doc";
+
+                        var fileDir = AppSettingsHelper.Get("WordBasePath")+ strFileName;
+                        doc.Save(fileDir);
+                        string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word" + strFileName;
+                        return Ok(JsonView(true, "成功!", Url));
+
+                        //保存为doc,并打开 
+                        
+                    }
+                    catch (Exception ex)
+                    {
+
+                        throw;
+                    }
+                    
+                }
+                else
+                {
+                    return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
+                }
+            }
+            else
+            {
+                return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
+            }
+            
+        }
+
+
         #endregion
         #endregion
+        /// <summary>
+        /// 导出确认单
+        /// </summary>
+        /// <param name=""></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> ConfirmWord(HotelReservationsByIdDto dto)
+        {
+            //团组信息
+
+            Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == dto.Id);
+
+            //酒店数据
+            List<Grp_HotelReservations> listhoteldata = _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == dto.Id && a.IsDel==0).ToList();
+
+            //利datatable存储
+            DataTable dt = new DataTable();
+            dt.Columns.Add("CheckInDate", typeof(string));
+            dt.Columns.Add("City", typeof(string));
+            dt.Columns.Add("Hotel", typeof(string));
+            dt.Columns.Add("Room", typeof(string));
+
+            for (int i = 0; i < listhoteldata.Count; i++)
+            {
+                DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
+                DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
+                while (dayStart < dayEnd)
+                {
+                    string temp = "";
+                    DataRow row = dt.NewRow();
+                    row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
+                    row["City"] = listhoteldata[i].City;
+                    row["Hotel"] = listhoteldata[i].HotelName;
+                    if (listhoteldata[i].SingleRoomCount > 0)
+                    {
+                        temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
+                    }
+                    if (listhoteldata[i].DoubleRoomCount > 0)
+                    {
+                        temp = temp + listhoteldata[i].DoubleRoomCount + "个表间" + "\r\n";
+                    }
+                    if (listhoteldata[i].SuiteRoomCount > 0)
+                    {
+                        temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
+                    }
+                    if (listhoteldata[i].OtherRoomCount > 0)
+                    {
+                        temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
+                    }
+                    row["Room"] = temp;
+                    dt.Rows.Add(row);
+                    dayStart = dayStart.AddDays(1);
+                }
+            }
+
+
+            Dictionary<string, string> dic = new Dictionary<string, string>();
+            dic.Add("Dele", di.TeamName);
+            dic.Add("City", di.VisitCountry);
+
+
+            //模板路径
+            //string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
+            string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
+            //载入模板
+            Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
+            DocumentBuilder builder = new DocumentBuilder(doc);
+
+            foreach (var key in dic.Keys)
+            {
+                builder.MoveToBookmark(key);
+                builder.Write(dic[key]);
+            }
 
 
+            //获取word里所有表格
+            NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
+            //获取所填表格的序数
+            Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
+            var rowStart = tableOne.Rows[0]; //获取第1行
+            try
+            {
+                //循环赋值
+                for (int i = 0; i < dt.Rows.Count; i++)
+                {
+                    builder.MoveToCell(0, i + 1, 0, 0);
+                    builder.Write(dt.Rows[i]["CheckInDate"].ToString());
+
+                    builder.MoveToCell(0, i + 1, 1, 0);
+                    builder.Write(dt.Rows[i]["City"].ToString());
+
+                    builder.MoveToCell(0, i + 1, 2, 0);
+                    builder.Write(dt.Rows[i]["Hotel"].ToString());
+
+                    builder.MoveToCell(0, i + 1, 3, 0);
+                    builder.Write(dt.Rows[i]["Room"].ToString());
+                }
+            }
+            catch
+            {
+            }
+            //删除多余行
+
+            while (tableOne.Rows.Count > dt.Rows.Count + 1)
+            {
+                tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
+            }
+            string strFileName = di.TeamName + "酒店确认单.doc";
+            try
+            {
+                doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
+                string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
+                return Ok(JsonView(true, "成功", Url));
+            }
+            catch (Exception)
+            {
+                return Ok(JsonView(false, "当前文档已打开,请先关闭!"));
+                throw;
+            }
+            
+            //doc.Save(HttpUtility.UrlEncode(strFileName, Encoding.UTF8), Aspose.Words.SaveFormat.Doc, Aspose.Words.SaveType.OpenInWord, Response);
+            
+        }
 
 
 
 
     }
     }

+ 4 - 0
OASystem/OASystem.Domain/AutoMappers/_baseMappingProfile.cs

@@ -128,6 +128,8 @@ namespace OASystem.Domain.AutoMappers
 
 
             #region op费用
             #region op费用
             CreateMap<OpCarTouristGuideGroundDto, Grp_CarTouristGuideGroundReservations>();
             CreateMap<OpCarTouristGuideGroundDto, Grp_CarTouristGuideGroundReservations>();
+            CreateMap<Grp_CreditCardPayment, CarTouristCreditCardPaymentView>();
+            CreateMap<Grp_CarTouristGuideGroundReservationsContent, CarTouristGuideGroundReservationsContentView>();
             #endregion
             #endregion
             #region 成本
             #region 成本
             CreateMap<Grp_GroupCostDto, Grp_GroupCost>();
             CreateMap<Grp_GroupCostDto, Grp_GroupCost>();
@@ -141,6 +143,8 @@ namespace OASystem.Domain.AutoMappers
             #region 酒店预订
             #region 酒店预订
             CreateMap<Grp_HotelReservations, HotelReservationsByIdView>();
             CreateMap<Grp_HotelReservations, HotelReservationsByIdView>();
             CreateMap<Grp_CreditCardPayment, Grp_CreditCardView>();
             CreateMap<Grp_CreditCardPayment, Grp_CreditCardView>();
+            CreateMap<OpHotelReservationsData, Grp_HotelReservations>();
+            CreateMap<OpHotelReservationsData, Grp_CreditCardPayment>();
             #endregion
             #endregion
 
 
             #endregion
             #endregion

+ 1 - 1
OASystem/OASystem.Domain/Dtos/Groups/CarTouristGuideGroundDto.cs

@@ -114,7 +114,7 @@ namespace OASystem.Domain.Dtos.Groups
         /// </summary>
         /// </summary>
         public int CTGGRId { get; set; }
         public int CTGGRId { get; set; }
         /// <summary>
         /// <summary>
-        /// 费用表示
+        /// 费用标识
         /// </summary>
         /// </summary>
         public int OrbitalPrivateTransfer { get; set; }
         public int OrbitalPrivateTransfer { get; set; }
         /// <summary>
         /// <summary>

+ 48 - 0
OASystem/OASystem.Domain/Dtos/Groups/HotelReservationsDto.cs

@@ -21,6 +21,10 @@ namespace OASystem.Domain.Dtos.Groups
     {
     {
         public int Id { get; set; }
         public int Id { get; set; }
     }
     }
+
+    /// <summary>
+    /// 编辑,新增参数
+    /// </summary>
     public class OpHotelReservationsData
     public class OpHotelReservationsData
     {
     {
         /// <summary>
         /// <summary>
@@ -181,6 +185,14 @@ namespace OASystem.Domain.Dtos.Groups
         public string Remark { get; set; }
         public string Remark { get; set; }
         //C表参数
         //C表参数
         /// <summary>
         /// <summary>
+        /// 付款金额
+        /// </summary>
+        public decimal PayMoney { get; set; }
+        /// <summary>
+        /// 付款币种 数据类型Id
+        /// </summary>
+        public int PaymentCurrency { get; set; }
+        /// <summary>
         /// 支付方式
         /// 支付方式
         /// </summary>
         /// </summary>
         public int PayDId { get; set; }
         public int PayDId { get; set; }
@@ -236,4 +248,40 @@ namespace OASystem.Domain.Dtos.Groups
         /// </summary>
         /// </summary>
         public string CRemark { get; set; }
         public string CRemark { get; set; }
     }
     }
+
+    public class HotelReservationsCNYDto 
+    {
+        /// <summary>
+        /// 类型ID
+        /// </summary>
+        public int CTable { get; set; }
+        /// <summary>
+        /// 团组Id
+        /// </summary>
+        public int DiId { get; set; }
+        /// <summary>
+        /// 信用卡金额
+        /// </summary>
+        public decimal CardPrice { get; set; }
+        /// <summary>
+        /// 信用卡金额币种
+        /// </summary>
+        public int CardPriceCurrency { get; set; }
+        /// <summary>
+        /// 地税
+        /// </summary>
+        public decimal GovernmentRent { get; set; }
+        /// <summary>
+        /// 地税币种
+        /// </summary>
+        public int GovernmentRentCurrency { get; set; }
+        /// <summary>
+        /// 城市税
+        /// </summary>
+        public decimal CityTax { get; set; }
+        /// <summary>
+        /// 城市税币种
+        /// </summary>
+        public int CityTaxCurrency { get; set; }
+    }
 }
 }

+ 71 - 0
OASystem/OASystem.Domain/ViewModels/Groups/CarTouristCreditCardPaymentView.cs

@@ -0,0 +1,71 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.ViewModels.Groups
+{
+    public class CarTouristCreditCardPaymentView
+    {
+        /// <summary>
+        /// 支付方式
+        /// </summary>
+        public int PayDId { get; set; }
+        /// <summary>
+        /// 支付方式
+        /// </summary>
+        public string PayName { get; set; }
+        /// <summary>
+        /// 付款金额
+        /// </summary>
+        public decimal PayMoney { get; set; }
+        /// <summary>
+        /// 付款币种 数据类型Id
+        /// </summary>
+        public int PaymentCurrency { get; set; }
+        /// <summary>
+        /// 付款币种 文本
+        /// </summary>
+        public string PaymentCurrencyName { get; set; }
+        /// <summary>
+        /// 此次付款百分比
+        /// </summary>
+        public decimal PayPercentage { get; set; }
+        /// <summary>
+        /// 收款方
+        /// </summary>
+        public string Payee { get; set; }
+
+        /// <summary>
+        /// 费用标识
+        /// </summary>
+        public int OrbitalPrivateTransfer { get; set; }
+
+        /// <summary>
+        /// 费用标识文本
+        /// </summary>
+        public string OrbitalPrivateTransferStr { get; set; }
+    }
+
+    public class CarTouristGuideGroundReservationsContentView
+    {
+        public int Id { get; set; }
+        /// <summary>
+        /// 费用项目明细Id
+        /// </summary>
+        public int SId { get; set; }
+        /// <summary>
+        /// 费用项目明细
+        /// </summary>
+        public string SidName { get; set; }
+        /// <summary>
+        /// 金额
+        /// </summary>
+        public decimal Price { get; set; }
+        /// <summary>
+        /// 费用明细
+        /// </summary>
+        public string PriceContent { get; set; }
+    }
+}

+ 13 - 0
OASystem/OASystem.Domain/ViewModels/Groups/HotelReservationsByDiIdView.cs

@@ -330,6 +330,19 @@ namespace OASystem.Domain.ViewModels.Groups
         /// 费用标识文本
         /// 费用标识文本
         /// </summary>
         /// </summary>
         public int OrbitalPrivateTransferStr { get; set; }
         public int OrbitalPrivateTransferStr { get; set; }
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string Remark { get; set; }
 
 
     }
     }
+    /// <summary>
+    /// 返回付款金额
+    /// </summary>
+    public class HotelReservationsView
+    {
+        public decimal Price { get; set; }
+        public int CurrencyId { get; set; }
+        public string CurrencyName { get; set; }
+    }
 }
 }

+ 23 - 10
OASystem/OASystem.Infrastructure/Repositories/Groups/CarTouristGuideGroundRepository.cs

@@ -6,6 +6,7 @@ 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.Infrastructure.Tools;
 using OASystem.Infrastructure.Tools;
+using System.Collections.Generic;
 
 
 namespace OASystem.Infrastructure.Repositories.Groups
 namespace OASystem.Infrastructure.Repositories.Groups
 {
 {
@@ -132,7 +133,8 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 string sql = string.Format(@"select * from Grp_DelegationInfo where Id in({0}) and IsDel={1}", DiId, 0);
                 string sql = string.Format(@"select * from Grp_DelegationInfo where Id in({0}) and IsDel={1}", DiId, 0);
 
 
                 //团组下拉框
                 //团组下拉框
-                List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.SqlQueryable<Grp_DelegationInfo>(sql).ToList();
+                List<Grp_DelegationInfo> _Delegations = _sqlSugar.SqlQueryable<Grp_DelegationInfo>(sql).ToList();
+                List<ShareGroupInfoIIView> grp_Delegations = _mapper.Map<List<ShareGroupInfoIIView>>(_Delegations);
                 //支付方式
                 //支付方式
                 List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
                 List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
                 List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
                 List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
@@ -170,12 +172,23 @@ namespace OASystem.Infrastructure.Repositories.Groups
             {
             {
                
                
                 List<Grp_CarTouristGuideGroundReservationsContent> grp_CarTouristsContent = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>().Where(a=>a.IsDel==0 && a.CTGGRId==dto.Id).ToList();
                 List<Grp_CarTouristGuideGroundReservationsContent> grp_CarTouristsContent = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>().Where(a=>a.IsDel==0 && a.CTGGRId==dto.Id).ToList();
-                Grp_CreditCardPayment _CreditCardPayment = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79);
-                Grp_CarTouristGuideGroundReservations grp_CarTouristGuideGround= _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().First(a => a.Id == dto.Id && a.IsDel == 0);
+                List<CarTouristGuideGroundReservationsContentView> carTouristGuides = _mapper.Map<List<CarTouristGuideGroundReservationsContentView>>(grp_CarTouristsContent);
+                foreach (var item in carTouristGuides)
+                {
+                    item.SidName= _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == item.SId).Name;
+                }
+                Grp_CreditCardPayment CreditCardPayment = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79);
+                CarTouristCreditCardPaymentView _CreditCardPayment = _mapper.Map<CarTouristCreditCardPaymentView>(CreditCardPayment);
+                if (_CreditCardPayment!=null)
+                {
+                    _CreditCardPayment.PayName = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == _CreditCardPayment.PayDId).Name;
+                    _CreditCardPayment.PaymentCurrencyName = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == _CreditCardPayment.PaymentCurrency).Name;
+                    if (_CreditCardPayment.OrbitalPrivateTransfer==0) _CreditCardPayment.OrbitalPrivateTransferStr = "公转";
+                    else _CreditCardPayment.OrbitalPrivateTransferStr = "私转";
+                }
                 var data = new
                 var data = new
                 {
                 {
-                    CarTouristsContent = grp_CarTouristsContent,
-                    CarTourists = grp_CarTouristGuideGround,
+                    CarTouristsContent = carTouristGuides,
                     CreditCardPayment = _CreditCardPayment,
                     CreditCardPayment = _CreditCardPayment,
                 };
                 };
                 return result = new Result() { Code = 0, Msg = "查询成功", Data = data };
                 return result = new Result() { Code = 0, Msg = "查询成功", Data = data };
@@ -233,9 +246,9 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 {
                 {
                     string sql = string.Format(@"select t.*,s.Name as CurrencyStr,c.IsAuditGM,c.PayPercentage,c.PayMoney from 
                     string sql = string.Format(@"select t.*,s.Name as CurrencyStr,c.IsAuditGM,c.PayPercentage,c.PayMoney from 
                                                 Grp_CarTouristGuideGroundReservations t
                                                 Grp_CarTouristGuideGroundReservations t
-                                                left Join Grp_CreditCardPayment c on CTable=79 and c.CId=t.Id
+                                                left Join Grp_CreditCardPayment c on CTable=79 and c.CId=t.Id  and c.isdel=0
                                                 left Join Sys_SetData s on s.Id=c.PaymentCurrency {0}
                                                 left Join Sys_SetData s on s.Id=c.PaymentCurrency {0}
-                                                order by CreateTime desc", sqlWhere);
+                                                order by c.IsAuditGM,c.PayPercentage desc", sqlWhere);
                     List<Grp_CarTouristGuideGroundView> infoViews = _sqlSugar.SqlQueryable<Grp_CarTouristGuideGroundView>(sql).ToList();
                     List<Grp_CarTouristGuideGroundView> infoViews = _sqlSugar.SqlQueryable<Grp_CarTouristGuideGroundView>(sql).ToList();
                     foreach (var item in infoViews)
                     foreach (var item in infoViews)
                     {
                     {
@@ -248,10 +261,10 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 else if (dto.PortType == 2 || dto.PortType == 3)
                 else if (dto.PortType == 2 || dto.PortType == 3)
                 {
                 {
                     string sql = string.Format(@"Select * From (	
                     string sql = string.Format(@"Select * From (	
-                                            Select row_number() over (order by t.Id Desc) as RowNumber,t.*,s.Name as CurrencyStr,c.IsAuditGM,c.PayPercentage
+                                            Select row_number() over (order by c.IsAuditGM,c.PayPercentage desc) as RowNumber,t.*,s.Name as CurrencyStr,c.IsAuditGM,c.PayPercentage
                                             from 
                                             from 
                                             Grp_CarTouristGuideGroundReservations t
                                             Grp_CarTouristGuideGroundReservations t
-                                            left Join Grp_CreditCardPayment c on CTable=79 and c.CId=t.Id
+                                            Join Grp_CreditCardPayment c on CTable=79 and c.CId=t.Id  and c.isdel=0
                                             left Join Sys_SetData s on s.Id=c.PaymentCurrency {0}
                                             left Join Sys_SetData s on s.Id=c.PaymentCurrency {0}
                                             ) temp Where RowNumber Between {1} and {2}", sqlWhere, startIndex, endIndex);
                                             ) temp Where RowNumber Between {1} and {2}", sqlWhere, startIndex, endIndex);
 
 
@@ -264,7 +277,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     string CountSql = string.Format(@"Select COUNT(1) as Count From (	
                     string CountSql = string.Format(@"Select COUNT(1) as Count From (	
                                                         select t.*,s.Name as CurrencyStr,c.IsAuditGM,c.PayPercentage from 
                                                         select t.*,s.Name as CurrencyStr,c.IsAuditGM,c.PayPercentage from 
                                                         Grp_CarTouristGuideGroundReservations t
                                                         Grp_CarTouristGuideGroundReservations t
-                                                        left Join Grp_CreditCardPayment c on CTable=79 and c.CId=t.Id
+                                                        Join Grp_CreditCardPayment c on CTable=79 and c.CId=t.Id  and c.isdel=0
                                                         left Join Sys_SetData s on s.Id=t.CId {0}
                                                         left Join Sys_SetData s on s.Id=t.CId {0}
                                                         ) temp ", sqlWhere);
                                                         ) temp ", sqlWhere);
                     DataCount dataCount = _sqlSugar.SqlQueryable<DataCount>(CountSql).First();
                     DataCount dataCount = _sqlSugar.SqlQueryable<DataCount>(CountSql).First();

+ 310 - 22
OASystem/OASystem.Infrastructure/Repositories/Groups/HotelPriceRepository.cs

@@ -1,8 +1,10 @@
 using AutoMapper;
 using AutoMapper;
 using OASystem.Domain;
 using OASystem.Domain;
 using OASystem.Domain.Dtos.Groups;
 using OASystem.Domain.Dtos.Groups;
+using OASystem.Domain.Entities.Financial;
 using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.ViewModels.Groups;
 using OASystem.Domain.ViewModels.Groups;
+using OASystem.Infrastructure.Tools;
 using SqlSugar;
 using SqlSugar;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
@@ -20,7 +22,110 @@ namespace OASystem.Infrastructure.Repositories.Groups
         {
         {
             this._mapper = mapper;
             this._mapper = mapper;
         }
         }
+        /// <summary>
+        /// 付款金额计算
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        public async Task<Result> HotelConversionAmounts(HotelReservationsCNYDto dto)
+        {
+            Result result = new Result() { Code = -2, Msg = "未知错误" };
+            try
+            {
+                HotelReservationsView reservationsView=new HotelReservationsView();
+                if ((dto.CardPriceCurrency == dto.GovernmentRentCurrency || dto.GovernmentRent == 0)
+                 && (dto.CardPriceCurrency == dto.CityTaxCurrency || dto.CityTax== 0))
+                {
+                    reservationsView.CurrencyId = dto.CardPriceCurrency;
+                    reservationsView.Price=Convert.ToDecimal((dto.CardPrice+dto.GovernmentRent+dto.CityTax).ToString("F2"));
+                    reservationsView.CurrencyName = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == dto.CardPriceCurrency).Name;
+                    return result = new Result() { Code = 0, Msg = "查询成功", Data = reservationsView };
+                }
+                else
+                {
+                    Grp_TeamRate _TeamRate = _sqlSugar.Queryable<Grp_TeamRate>().First(a => a.DiId == dto.DiId && a.IsDel == 0 && a.CTable == 76);
+                    List<CurrencyInfo> currencyInfos = new List<CurrencyInfo>();
+                    decimal CardPrice = 0.00M;
+                    decimal GovernmentRent = 0.00M;
+                    decimal CityTax = 0.00M;
+                    if (_TeamRate != null)
+                    {
+                        Sys_SetData _SetData = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == dto.CardPriceCurrency);
+                        if (_SetData != null)
+                        {
+                            if (_SetData.Name=="CNY")
+                            {
+                                CardPrice = dto.CardPrice;
+                            }
+                            else
+                            {
+                                currencyInfos = CommonFun.GetCurrencyChinaToList(_TeamRate.Remark);
+                                CurrencyInfo CurrencyRate = currencyInfos.FirstOrDefault(a => a.CurrencyCode == _SetData.Name);
+                                if (CurrencyRate != null) CardPrice = dto.CardPrice * Convert.ToDecimal(CurrencyRate.Rate);
+                                else return result = new Result() { Code = -1, Msg = "暂未设置团组汇率,请前往设置!", Data = reservationsView };
+                            }
+                        }
+                        else return result = new Result() { Code = -1, Msg = "暂未设置团组汇率,请前往设置!", Data = reservationsView };
+
+                        Sys_SetData _SetData1 = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == dto.GovernmentRentCurrency);
+                        if (_SetData1 != null)
+                        {
+                            if (_SetData1.Name == "CNY")
+                            {
+                                GovernmentRent = dto.GovernmentRent;
+                            }
+                            else {
+                                currencyInfos = CommonFun.GetCurrencyChinaToList(_TeamRate.Remark);
+                                CurrencyInfo CurrencyRate = currencyInfos.FirstOrDefault(a => a.CurrencyCode == _SetData1.Name);
+                                if (CurrencyRate != null) GovernmentRent = dto.GovernmentRent * Convert.ToDecimal(CurrencyRate.Rate);
+                                else return result = new Result() { Code = -1, Msg = "暂未设置团组汇率,请前往设置!", Data = reservationsView };
+                            }
+                                
+                        }
+                        else return result = new Result() { Code = -1, Msg = "暂未设置团组汇率,请前往设置!", Data = reservationsView };
 
 
+                        Sys_SetData _SetData2 = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == dto.CityTaxCurrency);
+                        if (_SetData2 != null)
+                        {
+                            if (_SetData2.Name == "CNY")
+                            {
+                                CityTax = dto.CityTax;
+                            }
+                            else
+                            {
+                                currencyInfos = CommonFun.GetCurrencyChinaToList(_TeamRate.Remark);
+                                CurrencyInfo CurrencyRate = currencyInfos.FirstOrDefault(a => a.CurrencyCode == _SetData2.Name);
+                                if (CurrencyRate != null) CityTax = dto.CityTax * Convert.ToDecimal(CurrencyRate.Rate);
+                                else return result = new Result() { Code = -1, Msg = "暂未设置团组汇率,请前往设置!", Data = reservationsView };
+                            }
+                        }
+                        else return result = new Result() { Code = -1, Msg = "暂未设置团组汇率,请前往设置!", Data = reservationsView };
+                       
+                        reservationsView.CurrencyId = 836;
+                        reservationsView.Price = Convert.ToDecimal((CardPrice + GovernmentRent + CityTax).ToString("F2"));
+                        reservationsView.CurrencyName ="CNY";
+
+                        return result = new Result() { Code = 0, Msg = "查询成功", Data = reservationsView };
+                    }
+                    else
+                    {
+                       return result = new Result() { Code = -1, Msg = "暂未设置团组汇率,请前往设置!", Data= reservationsView };
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+                return result = new Result() { Code = -2, Msg = "未知错误" };
+                throw;
+            }
+        }
+
+       
+        /// <summary>
+        /// 根据团组id查询酒店数据
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
         public async Task<Result> HotelReservationsByDiId(HotelReservationsByDiIdDto dto)
         public async Task<Result> HotelReservationsByDiId(HotelReservationsByDiIdDto dto)
         {
         {
             Result result = new Result() { Code = -2, Msg = "未知错误" };
             Result result = new Result() { Code = -2, Msg = "未知错误" };
@@ -48,10 +153,10 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     string sql = string.Format(@"select h.Id,s1.Name as GuestType,h.ReservationsNo,h.HotelName,h.CheckInDate,
                     string sql = string.Format(@"select h.Id,s1.Name as GuestType,h.ReservationsNo,h.HotelName,h.CheckInDate,
                                                 h.CheckOutDate,c.PayMoney,s.Name as PaymentCurrency,u.CnName as CreateUserName,c.IsAuditGM,h.CreateTime,h.Attachment
                                                 h.CheckOutDate,c.PayMoney,s.Name as PaymentCurrency,u.CnName as CreateUserName,c.IsAuditGM,h.CreateTime,h.Attachment
                                                 From Grp_HotelReservations h 
                                                 From Grp_HotelReservations h 
-                                                Join Grp_CreditCardPayment c on h.Id=c.CId and c.CTable=76 and c.IsDel=0
-                                                left Join Sys_SetData s on  c.PaymentCurrency=s.Id and s.IsDel=0
-                                                left Join Sys_SetData s1 on h.GTId=s1.Id and s1.IsDel=0
-                                                left Join Sys_Users u on u.Id=h.CreateUserId and u.isdel=0 {0}", sqlWhere);
+                                                Join Grp_CreditCardPayment c on h.Id=c.CId and c.CTable=76 and c.isdel=0
+                                                left Join Sys_SetData s on  c.PaymentCurrency=s.Id  
+                                                left Join Sys_SetData s1 on h.GTId=s1.Id 
+                                                left Join Sys_Users u on u.Id=h.CreateUserId {0} order by c.IsAuditGM,c.PayPercentage desc", sqlWhere);
                     List<HotelReservationsByDiIdView> hotelDataList = _sqlSugar.SqlQueryable<HotelReservationsByDiIdView>(sql).ToList();
                     List<HotelReservationsByDiIdView> hotelDataList = _sqlSugar.SqlQueryable<HotelReservationsByDiIdView>(sql).ToList();
                     foreach (var item in hotelDataList)
                     foreach (var item in hotelDataList)
                     {
                     {
@@ -60,19 +165,22 @@ namespace OASystem.Infrastructure.Repositories.Groups
                         else if (item.IsAuditGM == 2) item.IsAuditGMStr = "未通过";
                         else if (item.IsAuditGM == 2) item.IsAuditGMStr = "未通过";
                         else if (item.IsAuditGM == 3) item.IsAuditGMStr = "自动审核";
                         else if (item.IsAuditGM == 3) item.IsAuditGMStr = "自动审核";
 
 
+                        item.CheckInDate=DateTime.Parse(item.CheckInDate).ToString("yyyy-MM-dd");
+                        item.CheckOutDate = DateTime.Parse(item.CheckOutDate).ToString("yyyy-MM-dd");
+
                     }
                     }
                     return result = new Result() { Code = 0, Msg = "查询成功!", Data = hotelDataList };
                     return result = new Result() { Code = 0, Msg = "查询成功!", Data = hotelDataList };
                 }
                 }
                 else if (dto.PortType == 2 || dto.PortType == 3)
                 else if (dto.PortType == 2 || dto.PortType == 3)
                 {
                 {
                     string sql = string.Format(@"Select * From (	
                     string sql = string.Format(@"Select * From (	
-                                                Select row_number() over (order by h.Id Desc) as RowNumber,h.Id,s1.Name as GuestType,h.ReservationsNo,h.HotelName,h.CheckInDate,
+                                                Select row_number() over (order by c.IsAuditGM,c.PayPercentage desc) as RowNumber,h.Id,s1.Name as GuestType,h.ReservationsNo,h.HotelName,h.CheckInDate,
                                                 h.CheckOutDate,c.PayMoney,s.Name as PaymentCurrency,u.CnName as CreateUserName,c.IsAuditGM,h.CreateTime,h.Attachment
                                                 h.CheckOutDate,c.PayMoney,s.Name as PaymentCurrency,u.CnName as CreateUserName,c.IsAuditGM,h.CreateTime,h.Attachment
                                                  From Grp_HotelReservations h 
                                                  From Grp_HotelReservations h 
-                                                Join Grp_CreditCardPayment c on h.Id=c.CId and c.CTable=76 and c.IsDel=0
-                                                left Join Sys_SetData s on  c.PaymentCurrency=s.Id and s.IsDel=0
-                                                left Join Sys_SetData s1 on h.GTId=s1.Id and s1.IsDel=0
-                                                left Join Sys_Users u on u.Id=h.CreateUserId and u.isdel=0  {0}
+                                                Join Grp_CreditCardPayment c on h.Id=c.CId and c.CTable=76 and c.isdel=0
+                                                left Join Sys_SetData s on  c.PaymentCurrency=s.Id 
+                                                left Join Sys_SetData s1 on h.GTId=s1.Id 
+                                                left Join Sys_Users u on u.Id=h.CreateUserId   {0}
                                                 ) temp Where RowNumber Between {1} and {2}", sqlWhere, startIndex, endIndex);
                                                 ) temp Where RowNumber Between {1} and {2}", sqlWhere, startIndex, endIndex);
 
 
                     List<HotelReservationsByDiIdView> hotelDataList = _sqlSugar.SqlQueryable<HotelReservationsByDiIdView>(sql).ToList();
                     List<HotelReservationsByDiIdView> hotelDataList = _sqlSugar.SqlQueryable<HotelReservationsByDiIdView>(sql).ToList();
@@ -82,16 +190,17 @@ namespace OASystem.Infrastructure.Repositories.Groups
                         else if (item.IsAuditGM == 1) item.IsAuditGMStr = "已通过";
                         else if (item.IsAuditGM == 1) item.IsAuditGMStr = "已通过";
                         else if (item.IsAuditGM == 2) item.IsAuditGMStr = "未通过";
                         else if (item.IsAuditGM == 2) item.IsAuditGMStr = "未通过";
                         else if (item.IsAuditGM == 3) item.IsAuditGMStr = "自动审核";
                         else if (item.IsAuditGM == 3) item.IsAuditGMStr = "自动审核";
-
+                        item.CheckInDate = DateTime.Parse(item.CheckInDate).ToString("yyyy-MM-dd");
+                        item.CheckOutDate = DateTime.Parse(item.CheckOutDate).ToString("yyyy-MM-dd");
                     }
                     }
                     string CountSql = string.Format(@"Select COUNT(1) as Count From (	
                     string CountSql = string.Format(@"Select COUNT(1) as Count From (	
                                                         Select h.Id,s1.Name as GuestType,h.ReservationsNo,h.HotelName,h.CheckInDate,
                                                         Select h.Id,s1.Name as GuestType,h.ReservationsNo,h.HotelName,h.CheckInDate,
                                                         h.CheckOutDate,c.PayMoney,s.Name as PaymentCurrency,u.CnName as CreateUserName,c.IsAuditGM,h.CreateTime,h.Attachment
                                                         h.CheckOutDate,c.PayMoney,s.Name as PaymentCurrency,u.CnName as CreateUserName,c.IsAuditGM,h.CreateTime,h.Attachment
                                                         From Grp_HotelReservations h 
                                                         From Grp_HotelReservations h 
-                                                        Join Grp_CreditCardPayment c on h.Id=c.CId and c.CTable=76 and c.IsDel=0
-                                                        left Join Sys_SetData s on  c.PaymentCurrency=s.Id and s.IsDel=0
-                                                        left Join Sys_SetData s1 on h.GTId=s1.Id and s1.IsDel=0
-                                                        left Join Sys_Users u on u.Id=h.CreateUserId and u.isdel=0  {0}
+                                                        Join Grp_CreditCardPayment c on h.Id=c.CId and c.CTable=76 and c.isdel=0
+                                                        left Join Sys_SetData s on  c.PaymentCurrency=s.Id 
+                                                        left Join Sys_SetData s1 on h.GTId=s1.Id 
+                                                        left Join Sys_Users u on u.Id=h.CreateUserId  {0}
                                                         ) temp", sqlWhere);
                                                         ) temp", sqlWhere);
                     DataCount dataCount = _sqlSugar.SqlQueryable<DataCount>(CountSql).First();
                     DataCount dataCount = _sqlSugar.SqlQueryable<DataCount>(CountSql).First();
                    
                    
@@ -119,7 +228,11 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 throw;
                 throw;
             }
             }
         }
         }
-
+        /// <summary>
+        /// 根据酒店费用Id查询详细数据
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
         public async Task<Result> HotelReservationsById(HotelReservationsByIdDto dto)
         public async Task<Result> HotelReservationsById(HotelReservationsByIdDto dto)
         {
         {
             Result result = new Result() { Code = -2, Msg = "未知错误" };
             Result result = new Result() { Code = -2, Msg = "未知错误" };
@@ -129,7 +242,6 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 HotelReservationsByIdView _hotelReservations = _mapper.Map<HotelReservationsByIdView>(hotelReservationsById);
                 HotelReservationsByIdView _hotelReservations = _mapper.Map<HotelReservationsByIdView>(hotelReservationsById);
                 if (_hotelReservations!=null)
                 if (_hotelReservations!=null)
                 {
                 {
-                    
                     Sys_SetData GTId = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == hotelReservationsById.GTId);
                     Sys_SetData GTId = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == hotelReservationsById.GTId);
                     if (GTId != null) _hotelReservations.GtIdStr = GTId.Name;
                     if (GTId != null) _hotelReservations.GtIdStr = GTId.Name;
                     
                     
@@ -154,11 +266,11 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 string Sql = string.Format(@"select c.PayDId, s.Name asPayDIdStr,c.ConsumptionPatterns,c.ConsumptionDate,c.CTDId,
                 string Sql = string.Format(@"select c.PayDId, s.Name asPayDIdStr,c.ConsumptionPatterns,c.ConsumptionDate,c.CTDId,
                                             s1.Name as CTDIdStr,c.BankNo,c.CardholderName,c.PayMoney,c.PaymentCurrency,s2.Name
                                             s1.Name as CTDIdStr,c.BankNo,c.CardholderName,c.PayMoney,c.PaymentCurrency,s2.Name
                                             as PaymentCurrencyStr,c.DayRate,c.CompanyBankNo,c.OtherBankName,c.OtherSideNo,c.OtherSideName,
                                             as PaymentCurrencyStr,c.DayRate,c.CompanyBankNo,c.OtherBankName,c.OtherSideNo,c.OtherSideName,
-                                            c.IsAuditGM,c.Payee,c.RMBPrice,c.OrbitalPrivateTransfer from Grp_CreditCardPayment c
+                                            c.IsAuditGM,c.Payee,c.RMBPrice,c.OrbitalPrivateTransfer,c.Remark from Grp_CreditCardPayment c
                                             left join Sys_SetData s on c.PayDId=s.Id
                                             left join Sys_SetData s on c.PayDId=s.Id
                                             left join Sys_SetData s1 on c.CTDId=s1.Id
                                             left join Sys_SetData s1 on c.CTDId=s1.Id
                                             left join Sys_SetData s2 on c.PaymentCurrency=s2.Id
                                             left join Sys_SetData s2 on c.PaymentCurrency=s2.Id
-                                            where c.CId ={0} and c.IsDel = 0 and c.CTable = 76",dto.Id);
+                                            where c.CId ={0} and c.IsDel = 0 and c.CTable = 76", dto.Id);
                 Grp_CreditCardView _CreditCardPayment = _sqlSugar.SqlQueryable<Grp_CreditCardView>(Sql).First();
                 Grp_CreditCardView _CreditCardPayment = _sqlSugar.SqlQueryable<Grp_CreditCardView>(Sql).First();
                 if (_CreditCardPayment!=null)
                 if (_CreditCardPayment!=null)
                 {
                 {
@@ -177,7 +289,11 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 throw;
                 throw;
             }
             }
         }
         }
-
+        /// <summary>
+        /// 酒店页面下拉框等初始化
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
         public async Task<Result> HotelReservationsInitialize(HotelReservationsDto dto)
         public async Task<Result> HotelReservationsInitialize(HotelReservationsDto dto)
         {
         {
             Result result = new Result() { Code = -2, Msg = "未知错误" };
             Result result = new Result() { Code = -2, Msg = "未知错误" };
@@ -239,10 +355,182 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 throw;
                 throw;
             }
             }
         }
         }
-
-        public Task<Result> OpHotelReservations(OpHotelReservationsData dto)
+        /// <summary>
+        /// 酒店操作
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        /// <exception cref="NotImplementedException"></exception>
+        public async Task<Result> OpHotelReservations(OpHotelReservationsData dto)
         {
         {
-            throw new NotImplementedException();
+            Result result = new Result() { Code = -2, Msg = "未知错误" };
+            try
+            {
+                BeginTran();
+                int id = dto.Id;
+                Grp_HotelReservations hotelPrice = _mapper.Map<Grp_HotelReservations>(dto);
+                hotelPrice.IsCardPrice = hotelPrice.CardPrice!=0 ? 1:0;
+                hotelPrice.CboOne=hotelPrice.SingleRoomCount !=0 ? 1 : 0;
+                hotelPrice.CboTwo = hotelPrice.DoubleRoomCount != 0 ? 1 : 0;
+                hotelPrice.CboThree = hotelPrice.SuiteRoomCount != 0 ? 1 : 0;
+                hotelPrice.CboFour = hotelPrice.SuiteRoomCount != 0 ? 1 : 0;
+
+                Grp_CreditCardPayment c = _mapper.Map<Grp_CreditCardPayment>(dto);
+                c.Remark = dto.CRemark;
+                c.PayPercentage = 100;
+                c.CTable = 76;
+                c.CId = id;
+                c.IsAuditGM = 0;
+                if (c.PayDId == 72)
+                {
+                    c.IsPay = 1;
+                }
+                c.RMBPrice = c.PayMoney;
+                c.DayRate = 1;
+                Grp_TeamRate _TeamRate = _sqlSugar.Queryable<Grp_TeamRate>().First(a => a.DiId == dto.DiId && a.IsDel == 0 && a.CTable == 76);
+                List<CurrencyInfo> currencyInfos = new List<CurrencyInfo>();
+                if (_TeamRate != null)
+                {
+                    Sys_SetData _SetData = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == c.PaymentCurrency);
+                    if (_SetData != null)
+                    {
+                        currencyInfos = CommonFun.GetCurrencyChinaToList(_TeamRate.Remark);
+                        CurrencyInfo CurrencyRate = currencyInfos.FirstOrDefault(a => a.CurrencyCode == _SetData.Name);
+                        if (CurrencyRate != null)
+                        {
+                            c.RMBPrice = c.PayMoney * Convert.ToDecimal(CurrencyRate.Rate);
+                            c.DayRate = CurrencyRate.Rate;
+                        }
+                    }
+                }
+
+                if (dto.Status == 1)//添加
+                {
+                    Grp_HotelReservations grp_Hotel = _sqlSugar.Queryable<Grp_HotelReservations>().First(a => a.IsDel == 0 && a.HotelName == dto.HotelName && a.GuestName == dto.GuestName &&
+                    a.CheckInDate == dto.CheckInDate && a.CheckOutDate==dto.CheckOutDate && a.City==dto.City);
+                    if (grp_Hotel != null)
+                    {
+                        return result = new Result() { Code = -1, Msg = "该笔费用已存在,请勿重复添加!" };
+                    }
+                    else
+                    {
+                        id = await AddAsyncReturnId(hotelPrice);
+                        if (id != 0)
+                        {
+                            c.CId = id;
+                            int cId = await _sqlSugar.Insertable(c).ExecuteReturnIdentityAsync();
+                            if (cId != 0)
+                            {
+                                result = new Result() { Code = 0, Msg = "添加成功!" };
+
+                            }
+                            else
+                            {
+                                RollbackTran();
+                                result = new Result() { Code = -1, Msg = "添加失败!" };
+                            }
+                        }
+                        else
+                        {
+                            RollbackTran();
+                            result = new Result() { Code = -1, Msg = "添加失败,请稍后重试!" };
+                        }
+                    }
+
+                }
+                else if (dto.Status == 2)//修改
+                {
+                    bool res = await UpdateAsync(a => a.Id == dto.Id, a => new Grp_HotelReservations
+                    {
+                        GTId=hotelPrice.GTId,
+                        CheckNumber=hotelPrice.CheckNumber,
+                        ReservationsWebsite=hotelPrice.ReservationsWebsite,
+                        ReservationsNo=hotelPrice.ReservationsNo,
+                        DetermineNo=hotelPrice.DetermineNo,
+                        City=hotelPrice.City,
+                        HotelName=hotelPrice.HotelName,
+                        HotelAddress=hotelPrice.HotelAddress,
+                        HotelTel=hotelPrice.HotelTel,
+                        GuestName=hotelPrice.GuestName,
+                        CheckInDate=hotelPrice.CheckInDate,
+                        BudgetCurrency=hotelPrice.BudgetCurrency,
+                        CheckOutDate=hotelPrice.CheckOutDate,
+                        SingleRoomCount=hotelPrice.SingleRoomCount,
+                        SingleRoomPrice=hotelPrice.SingleRoomPrice,
+                        DoubleRoomCount=hotelPrice.DoubleRoomCount,
+                        DoubleRoomPrice=hotelPrice.DoubleRoomPrice,
+                        SuiteRoomCount=hotelPrice.SuiteRoomCount,
+                        SuiteRoomPrice=hotelPrice.SuiteRoomPrice,
+                        OtherRoomCount=hotelPrice.OtherRoomCount,
+                        OtherRoomPrice=hotelPrice.OtherRoomPrice,
+                        RoomExplanation=hotelPrice.RoomExplanation,
+                        Attachment=hotelPrice.Attachment,
+                        CardPrice=hotelPrice.CardPrice,
+                        IsCardPrice=hotelPrice.IsCardPrice,
+                        PredictSingleRoom=hotelPrice.PredictSingleRoom,
+                        PredictDoubleRoom=hotelPrice.PredictDoubleRoom,
+                        PredictSuiteRoom=hotelPrice.PredictSuiteRoom,
+                        PredictOtherRoom=hotelPrice.PredictOtherRoom,
+                        GovernmentRent=hotelPrice.GovernmentRent,
+                        GovernmentRentCurrency=hotelPrice.GovernmentRentCurrency,
+                        CityTax=hotelPrice.CityTax,
+                        CityTaxCurrency=hotelPrice.CityTaxCurrency,
+                        CheckType=hotelPrice.CheckType,
+                        CboOne=hotelPrice.SingleRoomCount,
+                        CboTwo=hotelPrice.DoubleRoomCount,
+                        CboThree=hotelPrice.SuiteRoomCount,
+                        CboFour=hotelPrice.SuiteRoomCount,
+                        CreateUserId=hotelPrice.CreateUserId,
+                        Remark=hotelPrice.Remark
+                    });
+                    if (res)
+                    {
+                        int CTable = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == hotelPrice.Id && a.CTable == 76).SetColumns(a => new Grp_CreditCardPayment
+                        {
+                            PayDId = dto.PayDId,
+                            PayMoney = c.PayMoney,
+                            PaymentCurrency = c.PaymentCurrency,
+                            Payee = c.Payee,
+                            OrbitalPrivateTransfer = c.OrbitalPrivateTransfer,
+                            DayRate = c.DayRate,
+                            RMBPrice = c.RMBPrice,
+                            ConsumptionPatterns = c.ConsumptionPatterns,
+                            ConsumptionDate = c.ConsumptionDate,
+                            CTDId = c.CTDId,
+                            CompanyBankNo = c.CompanyBankNo,
+                            OtherBankName = c.OtherBankName,
+                            OtherSideNo = c.OtherSideNo,
+                            OtherSideName = c.OtherSideName,
+                            BankNo = c.BankNo,
+                            CardholderName = c.CardholderName,
+                            Remark = c.Remark,
+
+                        }).ExecuteCommandAsync();
+                        if (CTable==0)
+                        {
+                            result = new Result() { Code = -1, Msg = "修改失败!" };
+                            RollbackTran();
+                        }
+                        else
+                        {
+                            result = new Result() { Code = 0, Msg = "修改成功!" };
+                        }
+                        
+                    }
+                    else
+                    {
+                        RollbackTran();
+                        result = new Result() { Code = -1, Msg = "修改失败,请稍后重试!" };
+                    }
+                }
+                CommitTran();
+            }
+            catch (Exception ex)
+            {
+                return result = new Result() { Code = -2, Msg = "未知错误" };
+                throw;
+            }
+            return result;
         }
         }
     }
     }
 }
 }

+ 3 - 3
OASystem/OASystem.Infrastructure/Repositories/Groups/VisaPriceRepository.cs

@@ -79,7 +79,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 int endIndex = startIndex + dto.PageSize - 1;
                 int endIndex = startIndex + dto.PageSize - 1;
                 if (dto.PortType==1)
                 if (dto.PortType==1)
                 {
                 {
-                    string sql = string.Format(@"select *,(select IsAuditGM from Grp_CreditCardPayment where CTable=80 and CId=v.Id) IsAuditGM,
+                    string sql = string.Format(@"select *,(select IsAuditGM from Grp_CreditCardPayment where CTable=80 and CId=v.Id and IsDel=0) IsAuditGM,
                                                 (select Name from Sys_SetData where isdel=0 and v.VisaCurrency=Id) VisaCurrencyStr from
                                                 (select Name from Sys_SetData where isdel=0 and v.VisaCurrency=Id) VisaCurrencyStr from
                                                 Grp_VisaInfo v {0} order by CreateTime desc",sqlWhere);
                                                 Grp_VisaInfo v {0} order by CreateTime desc",sqlWhere);
                     List<VisaInfoView> infoViews = _sqlSugar.SqlQueryable<VisaInfoView>(sql).ToList();
                     List<VisaInfoView> infoViews = _sqlSugar.SqlQueryable<VisaInfoView>(sql).ToList();
@@ -90,7 +90,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     string sql = string.Format(@"Select * From (	
                     string sql = string.Format(@"Select * From (	
                                             Select row_number() over (order by v.Id Desc) as RowNumber,v.*,c.IsAuditGM,s.Name as VisaCurrencyStr
                                             Select row_number() over (order by v.Id Desc) as RowNumber,v.*,c.IsAuditGM,s.Name as VisaCurrencyStr
                                             From Grp_VisaInfo v
                                             From Grp_VisaInfo v
-                                            left Join Grp_CreditCardPayment c On v.Id = c.CId and CTable=80
+                                            left Join Grp_CreditCardPayment c On v.Id = c.CId and CTable=80 and c.isdel=0
                                             Left Join Sys_SetData s On v.VisaCurrency = s.Id {0}
                                             Left Join Sys_SetData s On v.VisaCurrency = s.Id {0}
                                             ) temp Where RowNumber Between {1} and {2}", sqlWhere, startIndex, endIndex);
                                             ) temp Where RowNumber Between {1} and {2}", sqlWhere, startIndex, endIndex);
 
 
@@ -99,7 +99,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     string CountSql = string.Format(@"Select COUNT(1) as Count From (	
                     string CountSql = string.Format(@"Select COUNT(1) as Count From (	
                                             Select v.*,c.IsAuditGM,s.Name as VisaCurrencyStr
                                             Select v.*,c.IsAuditGM,s.Name as VisaCurrencyStr
                                             From Grp_VisaInfo v
                                             From Grp_VisaInfo v
-                                            left Join Grp_CreditCardPayment c On v.Id = c.CId and CTable=80
+                                            left Join Grp_CreditCardPayment c On v.Id = c.CId and CTable=80  and c.isdel=0
                                             Left Join Sys_SetData s On v.VisaCurrency = s.Id {0}
                                             Left Join Sys_SetData s On v.VisaCurrency = s.Id {0}
                                             ) temp", sqlWhere);
                                             ) temp", sqlWhere);
                     DataCount dataCount = _sqlSugar.SqlQueryable<DataCount>(CountSql).First();
                     DataCount dataCount = _sqlSugar.SqlQueryable<DataCount>(CountSql).First();