2 Commits 7785fbfc2a ... fe5012b12f

Author SHA1 Message Date
  wangh fe5012b12f Merge branch 'develop' of http://132.232.92.186:3000/XinXiBu/OA2023 into develop 1 year ago
  wangh 00fc662c2a 保险接口编写 1 year ago

+ 2 - 1
OASystem/EntitySync/Program.cs

@@ -116,6 +116,7 @@ db.CodeFirst.SetStringDefaultLength(50).BackupTable().InitTables(new Type[]
     //typeof(Grp_VisaInfo)
     //typeof(Grp_CarTouristGuideGroundReservations),
     //typeof(Grp_CarTouristGuideGroundReservationsContent),//
-    typeof(Fin_PaymentRefundAndOtherMoney)
+    //typeof(Fin_PaymentRefundAndOtherMoney)
+    typeof(Grp_InsuranceCost)
 });
 Console.WriteLine("数据库结构同步完成!");

+ 167 - 1
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -3532,7 +3532,7 @@ namespace OASystem.API.Controllers
         }
 
         /// <summary>
-        /// 根据酒店费用操作(Status:1.新增,2.修改)
+        /// 酒店费用操作(Status:1.新增,2.修改)
         /// </summary>
         /// <param name="dto"></param>
         /// <returns></returns>
@@ -4144,6 +4144,172 @@ namespace OASystem.API.Controllers
                 return Ok(JsonView(false, ex.Message));
             }
         }
+        /// <summary>
+        /// 酒店预订页面初始化绑定
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
+        {
+            try
+            {
+                Result groupData = await _customersRep.CustomersInitialize(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>
+        /// 保险费用操作(Status:1.新增,2.修改)
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
+        {
+            try
+            {
+                Result groupData = await _customersRep.OpCustomers(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>
+        /// <param name="file"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> UploadCus(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> DelFileCus(DelFileDto dto)
+        {
+            try
+            {
+                string filePath = "";
+                var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
+                // 返回与指定虚拟路径相对应的物理路径即绝对路径
+                //int id = 0;
+                filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
+                // 删除该文件
+                System.IO.File.Delete(filePath);
+                var result = await _sqlSugar.Updateable<Grp_Customers>().Where(a => a.Id == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_Customers()
+                {
+                    Attachment = "",
+                }).ExecuteCommandAsync();
+                if (result != 0)
+                {
+                    return Ok(JsonView(true, "成功!"));
+                }
+                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> DelCustomers(DelBaseDto dto)
+        {
+            try
+            {
+                var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
+                if (!res)
+                {
+                    return Ok(JsonView(false, "删除失败"));
+                }
+                var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
+                {
+                    IsDel = 1,
+                    DeleteUserId = dto.DeleteUserId,
+                    DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
+                }).ExecuteCommandAsync();
+                return Ok(JsonView(true, "删除成功!"));
+            }
+            catch (Exception ex)
+            {
+                return Ok(JsonView(false, "程序错误!"));
+                throw;
+            }
+        }
         #endregion
     }
 }

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

@@ -146,8 +146,10 @@ namespace OASystem.Domain.AutoMappers
             CreateMap<OpHotelReservationsData, Grp_HotelReservations>();
             CreateMap<OpHotelReservationsData, Grp_CreditCardPayment>();
             #endregion
-            CreateMap<Grp_HotelReservations, CustomersByIdView>();
-            CreateMap<Grp_CreditCardPayment, CustomersByIdView>();
+            CreateMap<Grp_Customers, CustomersByIdView>();
+            CreateMap<Grp_CreditCardPayment, CreditCardView>();
+            CreateMap<OpCustomersDto, Grp_Customers>();
+            CreateMap<OpCustomersDto, Grp_CreditCardPayment>();
             #region 保险费用
 
             #endregion

+ 127 - 0
OASystem/OASystem.Domain/Dtos/Groups/CustomersDto.cs

@@ -9,6 +9,7 @@ namespace OASystem.Domain.Dtos.Groups
     public class CustomersByDiIdDto : DtoBase
     {
         public int DiId { get; set; }
+        public string ClientName { get; set; }
     }
     /// <summary>
     /// 根据Id查询单条数据和c表数据
@@ -17,4 +18,130 @@ namespace OASystem.Domain.Dtos.Groups
     {
         public int Id { get; set; }
     }
+    /// <summary>
+    /// 保险下拉框初始化
+    /// </summary>
+    public class CustomersInitializeDto
+    {
+        /// <summary>
+        /// 请求端口分类
+        /// 1 Web 2 Android 3 IOS
+        /// </summary>
+        public int PortType { get; set; } = 1;
+        public int DiId { get; set; }
+    }
+    /// <summary>
+    /// 保险操作参数
+    /// </summary>
+    public class OpCustomersDto 
+    {
+        /// <summary>
+        /// 操作状态
+        /// 1 添加 
+        /// 2 修改 
+        /// </summary>
+        public int Status { get; set; }
+        public int Id { get; set; }
+        /// <summary>
+        /// 团组Id
+        /// </summary>
+        public int DiId { get; set; }
+        /// <summary>
+        /// 保险名称
+        /// </summary>
+        public int Iid { get; set; }
+
+        /// <summary>
+        /// 客户名称
+        /// </summary>
+        public string ClientName { get; set; }
+
+        /// <summary>
+        /// 保险费用
+        /// </summary>
+        public decimal InsuranceCosts { get; set; }
+
+        /// <summary>
+        /// 币种
+        /// </summary>
+        public int Currency { get; set; }
+
+        /// <summary>
+        /// 保险附件
+        /// </summary>
+        public string Attachment { get; set; }
+        /// <summary>
+        /// 创建者Id
+        /// </summary>
+        public int CreateUserId { get; set; }
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string Remark { get; set; }
+
+        //C表参数
+        /// <summary>
+        /// 付款金额
+        /// </summary>
+        public decimal PayMoney { get; set; }
+        /// <summary>
+        /// 付款币种 数据类型Id
+        /// </summary>
+        public int PaymentCurrency { get; set; }
+        /// <summary>
+        /// 支付方式
+        /// </summary>
+        public int PayDId { get; set; }
+        /// <summary>
+        /// 消费方式
+        /// </summary>
+        public string ConsumptionPatterns { get; set; }
+        /// <summary>
+        /// 消费日期
+        /// </summary>
+        public String ConsumptionDate { get; set; }
+        /// <summary>
+        /// 卡类型
+        /// </summary>
+        public int CTDId { get; set; }
+
+        /// <summary>
+        /// 公司银行卡号
+        /// </summary>
+        public string CompanyBankNo { get; set; }
+        /// <summary>
+        /// 对方开户行
+        /// </summary>
+        public string OtherBankName { get; set; }
+        /// <summary>
+        /// 对方银行账号
+        /// </summary>
+        public string OtherSideNo { get; set; }
+        /// <summary>
+        /// 对方姓名
+        /// </summary>
+        public string OtherSideName { get; set; }
+
+        /// <summary>
+        /// 银行卡号
+        /// </summary>
+        public string BankNo { get; set; }
+        /// <summary>
+        /// 持卡人姓名
+        /// </summary>
+        public string CardholderName { get; set; }
+        /// <summary>
+        /// 收款方
+        /// </summary>
+        public string Payee { get; set; }
+        /// <summary>
+        /// 费用标识
+        /// </summary>
+        public int OrbitalPrivateTransfer { get; set; }
+
+        /// <summary>
+        /// C表备注
+        /// </summary>
+        public string CRemark { get; set; }
+    }
 }

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

@@ -14,6 +14,7 @@ namespace OASystem.Domain.Dtos.Groups
         /// </summary>
         public int PortType { get; set; } = 1;
         public int UserId { get; set; }
+        public int DiId { get; set; }
     }
     /// <summary>
     /// 根据团组查询酒店预订列表数据

+ 25 - 0
OASystem/OASystem.Domain/Entities/Groups/Grp_InsuranceCost.cs

@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Entities.Groups
+{
+    [SugarTable("Grp_InsuranceCost")]
+    public class Grp_InsuranceCost: EntityBase
+    {
+        /// <summary>
+        /// 保险名称
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(100)")]
+        public string GName { get; set; }
+
+        /// <summary>
+        /// 充值费用
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "decimal(18,2)")]
+        public decimal RechargeCost { get; set; }
+
+    }
+}

+ 36 - 5
OASystem/OASystem.Domain/ViewModels/Groups/CustomersView.cs

@@ -58,7 +58,7 @@ namespace OASystem.Domain.ViewModels.Groups
         public string IsAuditGMStr { get; set; }
     }
 
-    public class CustomersByIdView 
+    public class CustomersByIdView
     {
         /// <summary>
         /// 主键Id
@@ -86,7 +86,6 @@ namespace OASystem.Domain.ViewModels.Groups
         /// 保险费用
         /// </summary>
         public decimal InsuranceCosts { get; set; }
-
         /// <summary>
         /// 币种
         /// </summary>
@@ -104,7 +103,14 @@ namespace OASystem.Domain.ViewModels.Groups
         /// </summary>
         public string Remark { get; set; }
 
-        //c表dto参数
+        /// <summary>
+        /// 余额
+        /// </summary>
+        public decimal InsuranceBalance { get; set; }
+
+    }
+    public class CreditCardView
+    {
         /// <summary>
         /// 支付方式
         /// </summary>
@@ -114,6 +120,18 @@ namespace OASystem.Domain.ViewModels.Groups
         /// </summary>
         public string PayDIdStr { get; set; }
         /// <summary>
+        /// 付款金额
+        /// </summary>
+        public decimal PayMoney { get; set; }
+        /// <summary>
+        /// 付款币种 数据类型Id
+        /// </summary>
+        public int PaymentCurrency { get; set; }
+        /// <summary>
+        /// 付款币种 数据类型Str
+        /// </summary>
+        public string PaymentCurrencyStr { get; set; }
+        /// <summary>
         /// 消费方式
         /// </summary>
         public string ConsumptionPatterns { get; set; }
@@ -146,7 +164,6 @@ namespace OASystem.Domain.ViewModels.Groups
         /// 对方姓名
         /// </summary>
         public string OtherSideName { get; set; }
-
         /// <summary>
         /// 银行卡号
         /// </summary>
@@ -174,6 +191,20 @@ namespace OASystem.Domain.ViewModels.Groups
         /// <summary>
         /// C表备注
         /// </summary>
-        public string CRemark { get; set; }
+        public string Remark { get; set; }
+    }
+
+    public class InsuranceCostView
+    {
+        public int Id { get; set; }
+        /// <summary>
+        /// 保险名称
+        /// </summary>
+        public string GName { get; set; }
+
+        /// <summary>
+        /// 余额
+        /// </summary>
+        public decimal Balance { get; set; }
     }
 }

+ 5 - 0
OASystem/OASystem.Domain/ViewModels/ViewBase.cs

@@ -40,6 +40,11 @@
         public int Count { get; set; }
     }
 
+    public class DataCountCost
+    {
+        public decimal CountCost { get; set; }
+    }
+
     /// <summary>
     /// 页面功能权限
     /// </summary>

+ 246 - 13
OASystem/OASystem.Infrastructure/Repositories/Groups/CustomersRepository.cs

@@ -1,8 +1,15 @@
 using AutoMapper;
+using NPOI.POIFS.Crypt.Dsig;
 using OASystem.Domain;
+using OASystem.Domain.Dtos.Financial;
 using OASystem.Domain.Dtos.Groups;
+using OASystem.Domain.Entities.Financial;
 using OASystem.Domain.Entities.Groups;
+using OASystem.Domain.ViewModels.Financial;
 using OASystem.Domain.ViewModels.Groups;
+using OASystem.Domain.ViewModels.QiYeWeChat;
+using OASystem.Infrastructure.Tools;
+using SqlSugar;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -14,9 +21,11 @@ namespace OASystem.Infrastructure.Repositories.Groups
     public class CustomersRepository : BaseRepository<Grp_Customers, Grp_Ommission>
     {
         private readonly IMapper _mapper;
-        public CustomersRepository(SqlSugarClient sqlSugar, IMapper mapper) : base(sqlSugar)
+        private readonly HotelPriceRepository _hotel;
+        public CustomersRepository(SqlSugarClient sqlSugar, IMapper mapper, HotelPriceRepository hotel) : base(sqlSugar)
         {
             _mapper = mapper;
+            _hotel= hotel;
         }
         /// <summary>
         /// 根据团组Id查询保险费用列表
@@ -41,7 +50,16 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 {
                     UserId = "0";
                 }
-                string sqlWhere = string.Format(@"Where h.DiId={0} and h.IsDel={1} And h.CreateUserId in ({2})", dto.DiId, 0, UserId);
+                string sqlWhere = string.Empty;
+                if (!string.IsNullOrWhiteSpace(dto.ClientName))
+                {
+                    sqlWhere = string.Format(@"Where h.DiId={0} and h.IsDel={1} And h.CreateUserId in ({2}) and h.ClientName like '%{3}%'", dto.DiId, 0, UserId,dto.ClientName);
+                }
+                else
+                {
+                    sqlWhere = string.Format(@"Where h.DiId={0} and h.IsDel={1} And h.CreateUserId in ({2})", dto.DiId, 0, UserId);
+                }
+                
 
                 int startIndex = (dto.PageIndex - 1) * dto.PageSize + 1;
                 int endIndex = startIndex + dto.PageSize - 1;
@@ -129,32 +147,247 @@ namespace OASystem.Infrastructure.Repositories.Groups
             {
                 Grp_Customers grp_Customers = _sqlSugar.Queryable<Grp_Customers>().First(a=>a.Id==dto.Id && a.IsDel==0);
                 CustomersByIdView customersById = _mapper.Map<CustomersByIdView>(grp_Customers);
-                Grp_CreditCardPayment creditCardPayment = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable==82);
-                customersById = _mapper.Map<CustomersByIdView>(creditCardPayment);
+
                 if (customersById != null)
                 {
-                    Sys_SetData Iid = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == customersById.Iid);
-                    if (Iid != null) customersById.IidStr = Iid.Name;
+                    Grp_CreditCardPayment creditCardPayment = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82);
+                    CreditCardView creditCardView = _mapper.Map<CreditCardView>(creditCardPayment);
+                    Grp_InsuranceCost Iid = _sqlSugar.Queryable<Grp_InsuranceCost>().First(a => a.IsDel == 0 && a.Id == customersById.Iid);
+                    if (Iid != null) customersById.IidStr = Iid.GName;
+
+                    
+                    string CountSql = string.Format(@"select sum(InsuranceCosts) as CountCost from Grp_Customers where isdel=0 and Iid=" + customersById.Iid);
+                    DataCountCost dataCount = _sqlSugar.SqlQueryable<DataCountCost>(CountSql).First();
+                    customersById.InsuranceBalance = Math.Round(Iid.RechargeCost - dataCount.CountCost, 2);
 
                     Sys_SetData Currency = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == customersById.Currency);
                     if (Currency != null) customersById.CurrencyStr = Currency.Name;
 
-                    Sys_SetData PayDId = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == customersById.PayDId);
-                    if (PayDId != null) customersById.PayDIdStr = PayDId.Name;
+                    Sys_SetData PayDId = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == creditCardView.PayDId);
+                    if (PayDId != null) creditCardView.PayDIdStr = PayDId.Name;
+
+                    Sys_SetData CTDId = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == creditCardView.CTDId);
+                    if (CTDId != null) creditCardView.CTDIdStr = CTDId.Name;
+                    creditCardView.OrbitalPrivateTransferStr= creditCardView.OrbitalPrivateTransfer== 0 ? "公转" : "私转";
+                    
+                    Sys_SetData PaymentCurrency= _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == creditCardView.PaymentCurrency);
+                    if (PaymentCurrency != null) creditCardView.PaymentCurrencyStr = PaymentCurrency.Name;
+
+                    
+                   
+                    var data = new
+                    {
+                        customers = customersById,
+                        creditCard = creditCardView
+                    };
+                    return result = new Result() { Code = 0, Msg = "查询成功!", Data = data };
+                }
+                var dataN = new
+                {
+                    customers = new CustomersView(),
+                    creditCard = new CreditCardView()
+                };
+                return result = new Result() { Code = 0, Msg = "暂无数据!", Data = dataN };
+
+            }
+            catch (Exception ex)
+            {
+                return result = new Result() { Code = -2, Msg = "未知错误" };
+                throw;
+            }
+        }
+
+        public async Task<Result> CustomersInitialize(CustomersInitializeDto dto)
+        {
+            Result result = new Result() { Code = -2, Msg = "未知错误" };
+            try
+            {
+                
+                
+                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<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
+                List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
+
+                //保险名称
+                List<Grp_InsuranceCost> _InsuranceCosts=_sqlSugar.Queryable<Grp_InsuranceCost>().Where(a=>a.IsDel==0).ToList();
+                List<InsuranceCostView> insuranceCostViews = new List<InsuranceCostView>();
+                foreach (var item in _InsuranceCosts)
+                {
+                    InsuranceCostView costView=new InsuranceCostView();
+                    costView.Id=item.Id;
+                    costView.GName=item.GName;
+                    costView.Balance = 0.00M;
+                    string CountSql = string.Format(@"select sum(InsuranceCosts) as CountCost from Grp_Customers where isdel=0 and Iid=" + item.Id);
+                    DataCountCost dataCount = _sqlSugar.SqlQueryable<DataCountCost>(CountSql).First();
+                    costView.Balance = Math.Round(item.RechargeCost - dataCount.CountCost, 2);
+                    insuranceCostViews.Add(costView);
+                }
+                //币种
+                GeneralTeamRateInfoDto PostGroupTeamRatedto = new GeneralTeamRateInfoDto();
+                PostGroupTeamRatedto.DiId = dto.DiId;
+                PostGroupTeamRatedto.CTbale = 82;
+                PostGroupTeamRatedto.PortType = dto.PortType;
+                Result teamRateDescAddCurrencyIdViews = _hotel.PostGroupTeamRateByDiIdAndCTableId(PostGroupTeamRatedto);
+                List<TeamRateDescAddCurrencyIdView> Currency = new List<TeamRateDescAddCurrencyIdView>();
+                if (teamRateDescAddCurrencyIdViews.Code == 0)
+                {
+                    Currency = teamRateDescAddCurrencyIdViews.Data;
+                }
+                
+                    var data = new
+                    {
+                        insuranceCost= insuranceCostViews,
+                        Payment = _Payment,
+                        CurrencyList = Currency,
+                        BankCard = _BankCard,
+                    };
+                    return result = new Result() { Code = 0, Msg = "查询成功", Data = data };
+                
+            }
+            catch (Exception ex)
+            {
+                return result = new Result() { Code = -2, Msg = "未知错误" };
+                throw;
+            }
+        }
+
+        public async Task<Result> OpCustomers(OpCustomersDto dto)
+        {
+            Result result = new Result() { Code = -2, Msg = "未知错误" };
+            try
+            {
+                BeginTran();
+                int id = dto.Id;
+                Grp_Customers cus = _mapper.Map<Grp_Customers>(dto);
+
+                Grp_CreditCardPayment c = _mapper.Map<Grp_CreditCardPayment>(dto);
+                c.Remark = dto.CRemark;
+                c.PayPercentage = 100;
+                c.CTable = 82;
+                c.CId = id;
+                c.IsAuditGM = 0;
+                c.PayMoney = cus.InsuranceCosts;
+                c.PaymentCurrency = cus.Currency;
+                if (c.PayDId == 72)
+                {
+                    c.IsPay = 1;
+                }
+                c.RMBPrice = cus.InsuranceCosts;
+                c.DayRate = 1;
+                Grp_TeamRate _TeamRate = _sqlSugar.Queryable<Grp_TeamRate>().First(a => a.DiId == dto.DiId && a.IsDel == 0 && a.CTable == 82);
+                List<CurrencyInfo> currencyInfos = new List<CurrencyInfo>();
+                if (_TeamRate != null)
+                {
+                    Sys_SetData _SetData = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == cus.Currency);
+                    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_Customers customers = _sqlSugar.Queryable<Grp_Customers>().First(a => a.IsDel == 0 && a.ClientName == dto.ClientName && a.InsuranceCosts == dto.InsuranceCosts);
+                    if (customers != null)
+                    {
+                        return result = new Result() { Code = -1, Msg = "该笔费用已存在,请勿重复添加!" };
+                    }
+                    else
+                    {
+                        id = await AddAsyncReturnId(cus);
+                        if (id != 0)
+                        {
+                            c.CId = id;
+                            int cId = await _sqlSugar.Insertable(c).ExecuteReturnIdentityAsync();
+                            if (cId != 0)
+                            {
+                                result = new Result() { Code = 0, Msg = "添加成功!" };
 
-                    Sys_SetData CTDId = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == customersById.CTDId);
-                    if (CTDId != null) customersById.CTDIdStr = CTDId.Name;
+                            }
+                            else
+                            {
+                                RollbackTran();
+                                result = new Result() { Code = -1, Msg = "添加失败!" };
+                            }
+                        }
+                        else
+                        {
+                            RollbackTran();
+                            result = new Result() { Code = -1, Msg = "添加失败,请稍后重试!" };
+                        }
+                    }
+
+                }
+                else if (dto.Status == 2)//修改
+                {
 
-                    customersById.OrbitalPrivateTransferStr=customersById.OrbitalPrivateTransfer== 0 ? "公转" : "私转";
-                    customersById.CRemark = creditCardPayment.Remark;
+
+                    bool res = await UpdateAsync(a => a.Id == dto.Id, a => new Grp_Customers
+                    {
+                        Iid = cus.Iid,
+                        ClientName = cus.ClientName,
+                        InsuranceCosts = cus.InsuranceCosts,
+                        Currency = cus.Currency,
+                        Attachment = cus.Attachment,
+                        Remark = cus.Remark
+                    });
+                    if (res)
+                    {
+                        int CTable = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == cus.Id && a.CTable == 82).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 = "修改失败,请稍后重试!" };
+                    }
                 }
-                return result = new Result() { Code = 0, Msg = "查询成功!",Data= customersById };
+                CommitTran();
             }
             catch (Exception ex)
             {
                 return result = new Result() { Code = -2, Msg = "未知错误" };
                 throw;
             }
+            return result;
         }
     }
 }

+ 124 - 1
OASystem/OASystem.Infrastructure/Repositories/Groups/HotelPriceRepository.cs

@@ -1,8 +1,12 @@
 using AutoMapper;
+using MathNet.Numerics.Statistics.Mcmc;
+using MySqlX.XDevAPI.Common;
 using OASystem.Domain;
+using OASystem.Domain.Dtos.Financial;
 using OASystem.Domain.Dtos.Groups;
 using OASystem.Domain.Entities.Financial;
 using OASystem.Domain.Entities.Groups;
+using OASystem.Domain.ViewModels.Financial;
 using OASystem.Domain.ViewModels.Groups;
 using OASystem.Infrastructure.Tools;
 using SqlSugar;
@@ -11,6 +15,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using Result = OASystem.Domain.Result;
 
 namespace OASystem.Infrastructure.Repositories.Groups
 {
@@ -359,11 +364,21 @@ namespace OASystem.Infrastructure.Repositories.Groups
                
                 if (dto.PortType==2 || dto.PortType==3)
                 {
+                    GeneralTeamRateInfoDto PostGroupTeamRatedto = new GeneralTeamRateInfoDto();
+                    PostGroupTeamRatedto.DiId= dto.DiId;
+                    PostGroupTeamRatedto.CTbale = 76;
+                    PostGroupTeamRatedto.PortType= dto.PortType;
+                    Result teamRateDescAddCurrencyIdViews = PostGroupTeamRateByDiIdAndCTableId(PostGroupTeamRatedto);
+                    List<TeamRateDescAddCurrencyIdView> Currency=new List<TeamRateDescAddCurrencyIdView>();
+                    if (teamRateDescAddCurrencyIdViews.Code==0)
+                    {
+                        Currency = teamRateDescAddCurrencyIdViews.Data;
+                    }
                     var data = new
                     {
                         GuestType = _GuestType,
                         Payment = _Payment,
-                        CurrencyList = _CurrencyList,
+                        CurrencyList = Currency,
                         BankCard = _BankCard,
                         BookingWebsite = _BookingWebsite,
                     };
@@ -391,6 +406,9 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 throw;
             }
         }
+
+        
+
         /// <summary>
         /// 酒店操作
         /// </summary>
@@ -569,5 +587,110 @@ namespace OASystem.Infrastructure.Repositories.Groups
             }
             return result;
         }
+        public Result PostGroupTeamRateByDiIdAndCTableId(GeneralTeamRateInfoDto dto)
+        {
+            Result result = new Result() { Code = -2, Msg = "未知错误" };
+            try
+            {
+                if (dto == null)
+                {
+                    return result = new Result() { Code = -2, Msg = "请输入参数" };
+                }
+
+                if (dto.DiId == 0)
+                {
+                    return result = new Result() { Code = -2, Msg = "请输入正确的团组Id!" };
+                }
+                if (dto.CTbale == 0)
+                {
+                    return result = new Result() { Code = -2, Msg = "请输入正确的业务类型(CTable)Id!" };
+                }
+
+
+                if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3)
+                {
+                    string teamRateInfoSql = string.Format(@"Select sd.Name,tr.* From Grp_TeamRate tr 
+                                                     Left Join Sys_SetData  sd On sd.IsDel=0 And sd.STid=16  And tr.CTable = sd.Id 
+                                                     Where tr.IsDel = 0 And tr.DiId = {0} And tr.CTable = {1}", dto.DiId, dto.CTbale);
+
+                    var teamRateInfo =  _sqlSugar.SqlQueryable<TeamRateInfoView>(teamRateInfoSql).ToList();
+
+                    #region 团组汇率
+
+                    TeamRateModelGeneralView teamRateModels = new TeamRateModelGeneralView();
+
+
+                    List<SetDataInfoView> currencyDatas = new List<SetDataInfoView>();
+                    #region 获取所有币种
+
+                    string sql = string.Format(@"select * from Sys_SetData where STid = {0} and isdel = 0", 66);
+                    List<SetDataInfoView> DBdata = _sqlSugar.SqlQueryable<SetDataInfoView>(sql).ToList();
+                    if (DBdata == null || DBdata.Count == 0)
+                    {
+                        return result = new Result() { Code = -2, Msg = "所有币种获取失败!" };
+                    }
+
+                    currencyDatas = DBdata.Select(x => new SetDataInfoView
+                    {
+                        Name = x.Name,
+                        Id = x.Id,
+                        Remark = x.Remark,
+                    }).ToList();
+
+                    #endregion
+                    List<TeamRateDescAddCurrencyIdView> teamRateDescViews = new List<TeamRateDescAddCurrencyIdView>();
+                    foreach (TeamRateInfoView item in teamRateInfo)
+                    {
+
+                        #region 拆分remark里的汇率
+
+                        if (item.Remark.Contains("|"))
+                        {
+                            string[] currencyArr = item.Remark.Split("|");
+                            foreach (string currency in currencyArr)
+                            {
+                                string[] currency1 = currency.Split(":");
+                                string[] currency2 = currency1[0].Split("(");
+
+                                string currencyCode = currency2[1].Replace(")", "").TrimEnd();
+                                SetDataInfoView dataInfoView = new SetDataInfoView();
+                                dataInfoView = currencyDatas.Where(it => it.Name == currencyCode).FirstOrDefault();
+                                int currencyId = currencyDatas.Where(it => it.Name == currencyCode).FirstOrDefault().Id;
+                                TeamRateDescAddCurrencyIdView rateDescView = new TeamRateDescAddCurrencyIdView()
+                                {
+                                    CurrencyId = dataInfoView.Id,
+                                    CurrencyCode = currencyCode,
+                                    CurrencyName = currency2[0],
+                                    Rate = decimal.Parse(currency1[1]),
+                                };
+                                teamRateDescViews.Add(rateDescView);
+                            }
+                        }
+
+                        #endregion
+
+                        if (teamRateDescViews.Count > 0)
+                        {
+                            teamRateDescViews = teamRateDescViews.OrderBy(it => it.CurrencyId).ToList();
+                        }
+                    }
+
+                    #endregion
+                    return result = new Result() { Code = 0, Msg = "操作成功!",Data= teamRateDescViews };
+                    
+                }
+                else
+                {
+                    return result = new Result() { Code = -2, Msg = "请输入正确的端口号! 1 Web 2 Android 3 Ios;" };
+                }
+
+
+
+            }
+            catch (Exception ex)
+            {
+                return result = new Result() { Code = -2, Msg = "未知错误" };
+            }
+        }
     }
 }

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

@@ -154,8 +154,8 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 Grp_CreditCardPayment _CreditCardPayment = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(a=>a.CId==dto.Id && a.IsDel==0 && a.CTable==80);
                 var data = new
                 {
-                    _VisaInfo = _VisaInfo,
-                    _CreditCardPayment = _CreditCardPayment
+                    VisaInfo = _VisaInfo,
+                    CreditCardPayment = _CreditCardPayment
                 };
                 return result = new Result() { Code = 0, Msg = "暂无数据!", Data = data };
             }