From 262921b1a156db667e93fa0834d6fdb74ec037dc Mon Sep 17 00:00:00 2001 From: ck_yeun9 Date: Sat, 16 Aug 2025 18:10:34 +0800 Subject: [PATCH 1/3] add reser type list controller. remove other database package, only include MariaDB Package. remove no use nuget package. --- .../Customer/CustomerAccountService.cs | 15 +++-- .../Business/Reser/ReserService.cs | 29 ++++++++- .../SystemManagement/Base/BaseService.cs | 31 +++++++++ .../SystemManagement/Base/IBaseService.cs | 10 +++ .../Business/Reser/Dto/ReadReserOutputDto.cs | 1 + .../Business/Reser/ReserType.cs | 24 +++++++ .../EOM.TSHotelManagement.Common.Util.csproj | 1 - .../DatabaseInitializer.cs | 63 +++++++++---------- ...M.TSHotelManagement.EntityFramework.csproj | 4 +- .../SystemManagement/Base/BaseController.cs | 14 +++++ .../EOM.TSHotelManagement.WebApi.csproj | 1 - 11 files changed, 148 insertions(+), 45 deletions(-) create mode 100644 EOM.TSHotelManagement.Common.Core/Business/Reser/ReserType.cs diff --git a/EOM.TSHotelManagement.Application/Business/Customer/CustomerAccountService.cs b/EOM.TSHotelManagement.Application/Business/Customer/CustomerAccountService.cs index 0a277bd..46cdde6 100644 --- a/EOM.TSHotelManagement.Application/Business/Customer/CustomerAccountService.cs +++ b/EOM.TSHotelManagement.Application/Business/Customer/CustomerAccountService.cs @@ -6,11 +6,12 @@ using jvncorelib.CodeLib; using jvncorelib.EntityLib; using System.Security.Claims; using System.Text.Json; +using System.Text.RegularExpressions; using System.Transactions; namespace EOM.TSHotelManagement.Application { - public class CustomerAccountService : ICustomerAccountService + public partial class CustomerAccountService : ICustomerAccountService { /// /// 客户账号 @@ -105,12 +106,10 @@ namespace EOM.TSHotelManagement.Application if (readCustomerAccountInputDto.Account.Length < 3 || readCustomerAccountInputDto.Account.Length > 20) return new SingleOutputDto() { Code = BusinessStatusCode.BadRequest, Message = LocalizationHelper.GetLocalizedString("Account length must be between 3 and 20 characters", "账号长度必须在3到20个字符之间"), Data = new ReadCustomerAccountOutputDto() }; - var accountRegex = new System.Text.RegularExpressions.Regex(@"^[a-zA-Z0-9_]+$"); - if (!accountRegex.IsMatch(readCustomerAccountInputDto.Account)) + if (!AccountRegex().IsMatch(readCustomerAccountInputDto.Account)) return new SingleOutputDto() { Code = BusinessStatusCode.BadRequest, Message = LocalizationHelper.GetLocalizedString("Account can only contain letters, numbers, and underscores", "账号只能包含字母、数字和下划线"), Data = new ReadCustomerAccountOutputDto() }; - var passwordRegex = new System.Text.RegularExpressions.Regex(@"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$"); - if (!passwordRegex.IsMatch(readCustomerAccountInputDto.Password)) + if (!PasswordRegex().IsMatch(readCustomerAccountInputDto.Password)) return new SingleOutputDto() { Code = BusinessStatusCode.BadRequest, Message = LocalizationHelper.GetLocalizedString("Password must be at least 8 characters long and contain at least one uppercase letter, one lowercase letter, and one number", "密码必须至少8个字符,并且包含至少一个大写字母、一个小写字母和一个数字"), Data = new ReadCustomerAccountOutputDto() }; var customerAccount = customerAccountRepository.AsQueryable().Single(x => x.Account == readCustomerAccountInputDto.Account); @@ -190,5 +189,11 @@ namespace EOM.TSHotelManagement.Application }; } } + + [GeneratedRegex(@"^[a-zA-Z0-9_]+$", RegexOptions.Compiled)] + private static partial Regex AccountRegex(); + + [GeneratedRegex(@"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$", RegexOptions.Compiled)] + private static partial Regex PasswordRegex(); } } diff --git a/EOM.TSHotelManagement.Application/Business/Reser/ReserService.cs b/EOM.TSHotelManagement.Application/Business/Reser/ReserService.cs index d174671..e31b95a 100644 --- a/EOM.TSHotelManagement.Application/Business/Reser/ReserService.cs +++ b/EOM.TSHotelManagement.Application/Business/Reser/ReserService.cs @@ -70,6 +70,17 @@ namespace EOM.TSHotelManagement.Application /// public ListOutputDto SelectReserAll(ReadReserInputDto readReserInputDto) { + var helper = new EnumHelper(); + var reserType = Enum.GetValues(typeof(ReserType)) + .Cast() + .Select(e => new EnumDto + { + Id = (int)e, + Name = e.ToString(), + Description = helper.GetEnumDescription(e) + }) + .ToList(); + var where = Expressionable.Create(); where = where.And(a => a.IsDelete == readReserInputDto.IsDelete); var count = 0; @@ -83,8 +94,10 @@ namespace EOM.TSHotelManagement.Application Data = reserRepository.AsQueryable().Where(where.ToExpression()).ToList(); count = Data.Count; } - Data.ForEach(source => + var mapped = EntityMapper.MapList(Data); + mapped.ForEach(source => { + source.ReservationChannelDescription = reserType.Where(a => a.Name == source.ReservationChannel).Single().Description; try { var sourceTelStr = dataProtector.DecryptReserData(source.ReservationPhoneNumber); @@ -95,7 +108,6 @@ namespace EOM.TSHotelManagement.Application source.ReservationPhoneNumber = source.ReservationPhoneNumber; } }); - var mapped = EntityMapper.MapList(Data); return new ListOutputDto { Data = new PagedData @@ -113,6 +125,17 @@ namespace EOM.TSHotelManagement.Application /// public SingleOutputDto SelectReserInfoByRoomNo(ReadReserInputDto readReserInputDt) { + var helper = new EnumHelper(); + var reserType = Enum.GetValues(typeof(ReserType)) + .Cast() + .Select(e => new EnumDto + { + Id = (int)e, + Name = e.ToString(), + Description = helper.GetEnumDescription(e) + }) + .ToList(); + Reser res = null; res = reserRepository.GetFirst(a => a.ReservationRoomNumber == readReserInputDt.ReservationRoomNumber && a.IsDelete != 1); //解密联系方式 @@ -121,6 +144,8 @@ namespace EOM.TSHotelManagement.Application var outputReser = EntityMapper.Map(res); + outputReser.ReservationChannelDescription = reserType.Where(a => a.Name == outputReser.ReservationChannel).Single().Description; + return new SingleOutputDto { Data = outputReser }; } diff --git a/EOM.TSHotelManagement.Application/SystemManagement/Base/BaseService.cs b/EOM.TSHotelManagement.Application/SystemManagement/Base/BaseService.cs index ed739fc..56a9f00 100644 --- a/EOM.TSHotelManagement.Application/SystemManagement/Base/BaseService.cs +++ b/EOM.TSHotelManagement.Application/SystemManagement/Base/BaseService.cs @@ -113,6 +113,37 @@ namespace EOM.TSHotelManagement.Application this.appointmentNoticeTypeRepository = appointmentNoticeTypeRepository; } + #region 预约类型模块 + + /// + /// 查询所有预约类型 + /// + /// + public ListOutputDto SelectReserTypeAll() + { + var helper = new EnumHelper(); + var enumList = Enum.GetValues(typeof(ReserType)) + .Cast() + .Select(e => new EnumDto + { + Id = (int)e, + Name = e.ToString(), + Description = helper.GetEnumDescription(e) + }) + .ToList(); + + return new ListOutputDto + { + Data = new PagedData + { + Items = enumList, + TotalCount = enumList.Count + } + }; + } + + #endregion + #region 性别模块 /// diff --git a/EOM.TSHotelManagement.Application/SystemManagement/Base/IBaseService.cs b/EOM.TSHotelManagement.Application/SystemManagement/Base/IBaseService.cs index 2ecafd4..0b59394 100644 --- a/EOM.TSHotelManagement.Application/SystemManagement/Base/IBaseService.cs +++ b/EOM.TSHotelManagement.Application/SystemManagement/Base/IBaseService.cs @@ -30,6 +30,16 @@ namespace EOM.TSHotelManagement.Application /// public interface IBaseService { + #region 预约类型模块 + + /// + /// 查询所有预约类型 + /// + /// + ListOutputDto SelectReserTypeAll(); + + #endregion + #region 性别模块 /// diff --git a/EOM.TSHotelManagement.Common.Contract/Business/Reser/Dto/ReadReserOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/Reser/Dto/ReadReserOutputDto.cs index b36b8dc..0f3bd0d 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/Reser/Dto/ReadReserOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/Reser/Dto/ReadReserOutputDto.cs @@ -15,6 +15,7 @@ namespace EOM.TSHotelManagement.Common.Contract public string ReservationRoomNumber { get; set; } [UIDisplay("ԤԼ")] public string ReservationChannel { get; set; } + public string ReservationChannelDescription { get; set; } [UIDisplay("ԤԼʼ")] public DateTime ReservationStartDate { get; set; } [UIDisplay("ԤԼֹ")] diff --git a/EOM.TSHotelManagement.Common.Core/Business/Reser/ReserType.cs b/EOM.TSHotelManagement.Common.Core/Business/Reser/ReserType.cs new file mode 100644 index 0000000..4baa453 --- /dev/null +++ b/EOM.TSHotelManagement.Common.Core/Business/Reser/ReserType.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EOM.TSHotelManagement.Common.Core +{ + public enum ReserType + { + [Description("线下")] + Offline = 1, + + [Description("应用程序")] + App = 2, + + [Description("小程序")] + Applet = 3, + + [Description("网页端")] + Website = 4, + } +} diff --git a/EOM.TSHotelManagement.Common.Util/EOM.TSHotelManagement.Common.Util.csproj b/EOM.TSHotelManagement.Common.Util/EOM.TSHotelManagement.Common.Util.csproj index a885042..04b9e23 100644 --- a/EOM.TSHotelManagement.Common.Util/EOM.TSHotelManagement.Common.Util.csproj +++ b/EOM.TSHotelManagement.Common.Util/EOM.TSHotelManagement.Common.Util.csproj @@ -10,7 +10,6 @@ - diff --git a/EOM.TSHotelManagement.EntityFramework/DatabaseInitializer/DatabaseInitializer.cs b/EOM.TSHotelManagement.EntityFramework/DatabaseInitializer/DatabaseInitializer.cs index baee303..57ea313 100644 --- a/EOM.TSHotelManagement.EntityFramework/DatabaseInitializer/DatabaseInitializer.cs +++ b/EOM.TSHotelManagement.EntityFramework/DatabaseInitializer/DatabaseInitializer.cs @@ -1,11 +1,8 @@ using EOM.TSHotelManagement.Common.Core; using EOM.TSHotelManagement.Migration; using EOM.TSHotelManagement.Shared; -using Microsoft.Data.SqlClient; using Microsoft.Extensions.Configuration; using MySqlConnector; -using Npgsql; -using Oracle.ManagedDataAccess.Client; using SqlSugar; namespace EOM.TSHotelManagement.EntityFramework @@ -104,15 +101,15 @@ namespace EOM.TSHotelManagement.EntityFramework case DbType.MySqlConnector: var builder = new MySqlConnectionStringBuilder(connectionString); return (builder.Database, dbType); - case DbType.SqlServer: - var sqlBuilder = new SqlConnectionStringBuilder(connectionString); - return (sqlBuilder.InitialCatalog, dbType); - case DbType.Oracle: - var oracleBuilder = new OracleConnectionStringBuilder(connectionString); - return (oracleBuilder.DataSource, dbType); - case DbType.PostgreSQL: - var pgsqlBuilder = new NpgsqlConnectionStringBuilder(connectionString); - return (pgsqlBuilder.Database, dbType); + //case DbType.SqlServer: //This project not include reference Package.Please manual install Microsoft.EntityFrameworkCore.SqlServer + // var sqlBuilder = new SqlConnectionStringBuilder(connectionString); + // return (sqlBuilder.InitialCatalog, dbType); + //case DbType.Oracle: //This project not include reference Package.Please manual install Oracle.ManagedDataAccess.Core + // var oracleBuilder = new OracleConnectionStringBuilder(connectionString); + // return (oracleBuilder.DataSource, dbType); + //case DbType.PostgreSQL: //This project not include reference Package.Please manual install Npgsql.EntityFrameworkCore.PostgreSQL + // var pgsqlBuilder = new NpgsqlConnectionStringBuilder(connectionString); + // return (pgsqlBuilder.Database, dbType); default: throw new NotSupportedException($"Unsupported DbType: {dbType}"); } @@ -133,27 +130,27 @@ namespace EOM.TSHotelManagement.EntityFramework Database = null, }; break; - case DbType.SqlServer: - builder = new SqlConnectionStringBuilder(connectionString) - { - InitialCatalog = "master", - ConnectTimeout = 30 - }; - break; - case DbType.Oracle: - builder = new OracleConnectionStringBuilder(connectionString) - { - UserID = "sys as sysdba", - }; - break; - case DbType.PostgreSQL: - builder = new NpgsqlConnectionStringBuilder(connectionString) - { - Database = "postgres", - Timeout = 30, - Pooling = false - }; - break; + //case DbType.SqlServer: //This project not include reference Package.Please manual install Microsoft.EntityFrameworkCore.SqlServer + // builder = new SqlConnectionStringBuilder(connectionString) + // { + // InitialCatalog = "master", + // ConnectTimeout = 30 + // }; + // break; + //case DbType.Oracle: //This project not include reference Package.Please manual install Oracle.ManagedDataAccess.Core + // builder = new OracleConnectionStringBuilder(connectionString) + // { + // UserID = "sys as sysdba", + // }; + // break; + //case DbType.PostgreSQL: //This project not include reference Package.Please manual install Npgsql.EntityFrameworkCore.PostgreSQL + // builder = new NpgsqlConnectionStringBuilder(connectionString) + // { + // Database = "postgres", + // Timeout = 30, + // Pooling = false + // }; + // break; } return new SqlSugarClient(new ConnectionConfig diff --git a/EOM.TSHotelManagement.EntityFramework/EOM.TSHotelManagement.EntityFramework.csproj b/EOM.TSHotelManagement.EntityFramework/EOM.TSHotelManagement.EntityFramework.csproj index 9251206..35ae5c0 100644 --- a/EOM.TSHotelManagement.EntityFramework/EOM.TSHotelManagement.EntityFramework.csproj +++ b/EOM.TSHotelManagement.EntityFramework/EOM.TSHotelManagement.EntityFramework.csproj @@ -9,10 +9,8 @@ - + - - diff --git a/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Base/BaseController.cs b/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Base/BaseController.cs index 666d018..cb722bb 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Base/BaseController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Base/BaseController.cs @@ -16,6 +16,20 @@ namespace EOM.TSHotelManagement.WebApi.Controllers this.baseService = baseService; } + #region 预约类型模块 + + /// + /// 查询所有预约类型 + /// + /// + [HttpGet] + public ListOutputDto SelectReserTypeAll() + { + return baseService.SelectReserTypeAll(); + } + + #endregion + #region 性别模块 /// diff --git a/EOM.TSHotelManagement.WebApi/EOM.TSHotelManagement.WebApi.csproj b/EOM.TSHotelManagement.WebApi/EOM.TSHotelManagement.WebApi.csproj index 6a750ef..1117457 100644 --- a/EOM.TSHotelManagement.WebApi/EOM.TSHotelManagement.WebApi.csproj +++ b/EOM.TSHotelManagement.WebApi/EOM.TSHotelManagement.WebApi.csproj @@ -36,7 +36,6 @@ - -- Gitee From 8d07e6522dab3b89d44ddb42b42d8a65f39ad085 Mon Sep 17 00:00:00 2001 From: ck_yeun9 Date: Sun, 31 Aug 2025 14:33:55 +0800 Subject: [PATCH 2/3] fix business logic. --- .../Customer/CustomerAccountService.cs | 11 +- .../Business/Room/RoomService.cs | 166 +++++++++--------- .../Business/Spend/SpendService.cs | 50 +++++- .../Repository/GenericRepository.cs | 135 ++++++++++++-- 4 files changed, 258 insertions(+), 104 deletions(-) diff --git a/EOM.TSHotelManagement.Application/Business/Customer/CustomerAccountService.cs b/EOM.TSHotelManagement.Application/Business/Customer/CustomerAccountService.cs index 46cdde6..7b2e09d 100644 --- a/EOM.TSHotelManagement.Application/Business/Customer/CustomerAccountService.cs +++ b/EOM.TSHotelManagement.Application/Business/Customer/CustomerAccountService.cs @@ -100,16 +100,17 @@ namespace EOM.TSHotelManagement.Application /// public SingleOutputDto Register(ReadCustomerAccountInputDto readCustomerAccountInputDto) { + if (readCustomerAccountInputDto.Account.IsNullOrEmpty() || readCustomerAccountInputDto.Password.IsNullOrEmpty()) return new SingleOutputDto() { Code = BusinessStatusCode.BadRequest, Message = LocalizationHelper.GetLocalizedString("Account or Password cannot be empty", "账号或密码不能为空"), Data = new ReadCustomerAccountOutputDto() }; if (readCustomerAccountInputDto.Account.Length < 3 || readCustomerAccountInputDto.Account.Length > 20) return new SingleOutputDto() { Code = BusinessStatusCode.BadRequest, Message = LocalizationHelper.GetLocalizedString("Account length must be between 3 and 20 characters", "账号长度必须在3到20个字符之间"), Data = new ReadCustomerAccountOutputDto() }; - if (!AccountRegex().IsMatch(readCustomerAccountInputDto.Account)) + if (!AccountRegex.IsMatch(readCustomerAccountInputDto.Account)) return new SingleOutputDto() { Code = BusinessStatusCode.BadRequest, Message = LocalizationHelper.GetLocalizedString("Account can only contain letters, numbers, and underscores", "账号只能包含字母、数字和下划线"), Data = new ReadCustomerAccountOutputDto() }; - if (!PasswordRegex().IsMatch(readCustomerAccountInputDto.Password)) + if (!PasswordRegex.IsMatch(readCustomerAccountInputDto.Password)) return new SingleOutputDto() { Code = BusinessStatusCode.BadRequest, Message = LocalizationHelper.GetLocalizedString("Password must be at least 8 characters long and contain at least one uppercase letter, one lowercase letter, and one number", "密码必须至少8个字符,并且包含至少一个大写字母、一个小写字母和一个数字"), Data = new ReadCustomerAccountOutputDto() }; var customerAccount = customerAccountRepository.AsQueryable().Single(x => x.Account == readCustomerAccountInputDto.Account); @@ -190,10 +191,8 @@ namespace EOM.TSHotelManagement.Application } } - [GeneratedRegex(@"^[a-zA-Z0-9_]+$", RegexOptions.Compiled)] - private static partial Regex AccountRegex(); + private readonly Regex AccountRegex = new Regex(@"^[a-zA-Z0-9_]+$", RegexOptions.Compiled); + private readonly Regex PasswordRegex = new Regex(@"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$", RegexOptions.Compiled); - [GeneratedRegex(@"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$", RegexOptions.Compiled)] - private static partial Regex PasswordRegex(); } } diff --git a/EOM.TSHotelManagement.Application/Business/Room/RoomService.cs b/EOM.TSHotelManagement.Application/Business/Room/RoomService.cs index 1c3b931..b3f2ea9 100644 --- a/EOM.TSHotelManagement.Application/Business/Room/RoomService.cs +++ b/EOM.TSHotelManagement.Application/Business/Room/RoomService.cs @@ -141,6 +141,31 @@ namespace EOM.TSHotelManagement.Application var result = EntityMapper.MapList(rooms); + var listRoomTypeIds = result.Select(a => a.RoomTypeId).ToList(); + var listRoomType = roomTypeRepository.AsQueryable().Where(a => listRoomTypeIds.Contains(a.RoomTypeId)).ToList(); + + var listCustomerNumbers = result.Select(a => a.CustomerNumber).ToList(); + var listCustomer = custoRepository.AsQueryable().Where(a => listCustomerNumbers.Contains(a.CustomerNumber)).ToList(); + + result.ForEach(r => + { + var roomType = listRoomType.SingleOrDefault(a => a.RoomTypeId == r.RoomTypeId); + r.RoomName = roomType?.RoomTypeName ?? string.Empty; + var customer = listCustomer.SingleOrDefault(a => a.CustomerNumber == r.CustomerNumber); + r.CustomerName = customer?.CustomerName ?? string.Empty; + var helper = new EnumHelper(); + var roomStates = Enum.GetValues(typeof(RoomState)) + .Cast() + .Select(e => new EnumDto + { + Id = (int)e, + Name = e.ToString(), + Description = helper.GetEnumDescription(e) + }) + .ToList(); + r.RoomState = roomStates.Where(a => a.Id == r.RoomStateId).Single().Description; + }); + return new ListOutputDto { Data = new PagedData @@ -195,8 +220,11 @@ namespace EOM.TSHotelManagement.Application count = rooms.Count; } + var customers = custoRepository.AsQueryable().Where(a => rooms.Select(a => a.CustomerNumber).ToList().Contains(a.CustomerNumber)); + var result = EntityMapper.MapList(rooms); var roomTypes = roomTypeRepository.AsQueryable().Where(a => a.IsDelete != 1).ToList(); + foreach (var item in result) { var helper = new EnumHelper(); @@ -212,6 +240,8 @@ namespace EOM.TSHotelManagement.Application item.RoomState = roomStates.Where(a => a.Id == item.RoomStateId).Single().Description; var roomType = roomTypes.Single(a => a.RoomTypeId == item.RoomTypeId); item.RoomName = roomType.RoomTypeName; + var customer = customers.Single(a => a.CustomerNumber == item.CustomerNumber); + item.CustomerName = customer?.CustomerName ?? string.Empty; } return new ListOutputDto { @@ -250,6 +280,17 @@ namespace EOM.TSHotelManagement.Application count = rooms.Count; } + var customerNumbers = custoRepository.AsQueryable().Where(a => rooms.Select(a => a.CustomerNumber).ToList().Contains(a.CustomerNumber)); + + var roomTypes = roomTypeRepository.AsQueryable().Where(a => a.IsDelete != 1).ToList(); + rooms.ForEach(room => + { + var customer = customerNumbers.Single(a => a.CustomerNumber == room.CustomerNumber); + room.CustomerName = customer?.CustomerName ?? string.Empty; + var roomType = roomTypes.Single(a => a.RoomTypeId == room.RoomTypeId); + room.RoomName = roomType.RoomTypeName; + }); + var result = EntityMapper.MapList(rooms); return new ListOutputDto @@ -324,16 +365,13 @@ namespace EOM.TSHotelManagement.Application { try { - roomRepository.Update(new Room() - { - Id = r.Id, - RoomNumber = r.RoomNumber, - LastCheckInTime = r.LastCheckInTime, - RoomStateId = r.RoomStateId, - CustomerNumber = r.CustomerNumber, - DataChgDate = r.DataChgDate, - DataChgUsr = r.DataChgUsr, - }); + var room = this.roomRepository.GetFirst(a => a.RoomNumber == r.RoomNumber); + room.RoomStateId = r.RoomStateId; + room.CustomerNumber = r.CustomerNumber; + room.LastCheckInTime = r.LastCheckInTime; + room.DataChgDate = r.DataChgDate; + room.DataChgUsr = r.DataChgUsr; + roomRepository.Update(room); } catch (Exception ex) { @@ -342,7 +380,7 @@ namespace EOM.TSHotelManagement.Application return new BaseResponse(); } - /// + /// /// 根据房间编号修改房间信息(预约) /// /// @@ -351,14 +389,11 @@ namespace EOM.TSHotelManagement.Application { try { - roomRepository.Update(new Room() - { - Id = r.Id, - RoomNumber = r.RoomNumber, - RoomStateId = r.RoomStateId, - DataChgUsr = r.DataChgUsr, - DataInsDate = r.DataInsDate, - }); + var room = this.roomRepository.GetFirst(a => a.RoomNumber == r.RoomNumber); + room.RoomStateId = r.RoomStateId; + room.DataChgDate = r.DataChgDate; + room.DataChgUsr = r.DataChgUsr; + roomRepository.Update(room); } catch (Exception ex) { @@ -506,12 +541,8 @@ namespace EOM.TSHotelManagement.Application try { var room = roomRepository.GetFirst(a => a.RoomNumber == updateRoomInputDto.RoomNumber); - roomRepository.Update(new Room() - { - Id = room.Id, - RoomNumber = room.RoomNumber, - RoomStateId = updateRoomInputDto.RoomStateId - }); + room.RoomStateId = updateRoomInputDto.RoomStateId; + roomRepository.Update(room); } catch (Exception ex) { @@ -650,9 +681,7 @@ namespace EOM.TSHotelManagement.Application { custoRepository.Update(a => new Customer { - CustomerType = newLevelId, - DataChgUsr = transferRoomDto.DataChgUsr, - DataChgDate = DateTime.Now + CustomerType = newLevelId }, a => a.CustomerNumber == transferRoomDto.CustomerNumber); } @@ -660,33 +689,23 @@ namespace EOM.TSHotelManagement.Application if (customerType.IsNullOrEmpty()) return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("The customer type does not exist", "客户类型不存在"), Code = BusinessStatusCode.InternalServerError }; - decimal discountFactor = customerType.Discount / 100M; - decimal originalRoomBill = originalRoom.RoomRent * stayDays * discountFactor; + decimal discount = (customerType != null && customerType.Discount > 0 && customerType.Discount < 100) + ? customerType.Discount / 100M + : 1M; + decimal originalRoomBill = originalRoom.RoomRent * stayDays * discount; //更新目标房间状态 - roomRepository.Update(new Room - { - Id = targetRoom.Id, - RoomNumber = targetRoom.RoomNumber, - CustomerNumber = originalRoom.CustomerNumber, - LastCheckInTime = DateOnly.FromDateTime(DateTime.Now), - RoomStateId = (int)RoomState.Occupied, - DataChgDate = transferRoomDto.DataChgDate, - DataChgUsr = transferRoomDto.DataChgUsr - }); + targetRoom.CustomerNumber = originalRoom.CustomerNumber; + targetRoom.RoomStateId = (int)RoomState.Occupied; + targetRoom.LastCheckInTime = DateOnly.FromDateTime(DateTime.Now); + roomRepository.Update(targetRoom); //更新原房间状态 - roomRepository.Update(new Room - { - Id = originalRoom.Id, - RoomNumber = originalRoom.RoomNumber, - CustomerNumber = string.Empty, - LastCheckInTime = DateOnly.MinValue, - LastCheckOutTime = DateOnly.FromDateTime(DateTime.Now), - RoomStateId = (int)RoomState.Dirty, - DataChgDate = transferRoomDto.DataChgDate, - DataChgUsr = transferRoomDto.DataChgUsr - }); + originalRoom.CustomerNumber = string.Empty; + originalRoom.RoomStateId = (int)RoomState.Dirty; + originalRoom.LastCheckInTime = DateOnly.MinValue; + originalRoom.LastCheckOutTime = DateOnly.MinValue; + roomRepository.Update(originalRoom); //转移原房间消费记录 if (originalSpendNumbers.Count > 0) @@ -706,7 +725,7 @@ namespace EOM.TSHotelManagement.Application //添加旧房间消费记录 var originalSpend = new Spend { - CustomerNumber = originalRoom.CustomerNumber, + CustomerNumber = transferRoomDto.CustomerNumber, RoomNumber = transferRoomDto.TargetRoomNumber, SpendNumber = uniqueCode.GetNewId("SP-"), ProductNumber = transferRoomDto.OriginalRoomNumber, @@ -717,9 +736,7 @@ namespace EOM.TSHotelManagement.Application ConsumptionQuantity = stayDays, ConsumptionAmount = originalRoomBill, ConsumptionType = SpendType.Room.Code, - IsDelete = 0, - DataInsDate = transferRoomDto.DataChgDate, - DataInsUsr = transferRoomDto.DataChgUsr + IsDelete = 0 }; spendRepository.Insert(originalSpend); @@ -751,17 +768,10 @@ namespace EOM.TSHotelManagement.Application var room = roomRepository.GetFirst(a => a.RoomNumber == checkoutRoomDto.RoomNumber); //更新房间状态 - roomRepository.Update(new Room - { - Id = room.Id, - RoomNumber = room.RoomNumber, - CustomerNumber = null, - LastCheckInTime = DateOnly.MinValue, - LastCheckOutTime = DateOnly.FromDateTime(DateTime.Now), - RoomStateId = (int)RoomState.Dirty, - DataChgDate = checkoutRoomDto.DataChgDate, - DataChgUsr = checkoutRoomDto.DataChgUsr - }); + room.CustomerNumber = string.Empty; + room.LastCheckOutTime = DateOnly.FromDateTime(DateTime.Now); + room.RoomStateId = (int)RoomState.Dirty; + roomRepository.Update(room); //添加能源使用记录 var energy = new EnergyManagement @@ -774,37 +784,21 @@ namespace EOM.TSHotelManagement.Application Recorder = checkoutRoomDto.DataChgUsr, CustomerNumber = room.CustomerNumber, RoomNumber = checkoutRoomDto.RoomNumber, - IsDelete = 0, - DataInsDate = checkoutRoomDto.DataChgDate, - DataInsUsr = checkoutRoomDto.DataChgUsr + IsDelete = 0 }; energyRepository.Insert(energy); //结算消费记录 var spendNumbers = spendRepository.GetList(a => a.RoomNumber == checkoutRoomDto.RoomNumber - && a.CustomerNumber.Equals(checkoutRoomDto.CustomerNumber) && a.SettlementStatus.Equals(ConsumptionConstant.UnSettle) + && a.CustomerNumber.Equals(checkoutRoomDto.CustomerNumber) && a.SettlementStatus == ConsumptionConstant.UnSettle.Code && a.IsDelete == 0).ToList(); if (spendNumbers.Count > 0) { var spends = new List(); foreach (var spend in spendNumbers) { - spends.Add(new Spend - { - SpendNumber = spend.SpendNumber, - RoomNumber = checkoutRoomDto.RoomNumber, - CustomerNumber = checkoutRoomDto.CustomerNumber, - ProductName = spend.ProductName, - ProductPrice = spend.ProductPrice, - ConsumptionQuantity = spend.ConsumptionQuantity, - ConsumptionAmount = spend.ConsumptionAmount, - ConsumptionTime = DateTime.Now, - SettlementStatus = ConsumptionConstant.Settled.Code, - ConsumptionType = spend.ConsumptionType, - IsDelete = 0, - DataInsDate = checkoutRoomDto.DataChgDate, - DataInsUsr = checkoutRoomDto.DataChgUsr - }); + spend.SettlementStatus = ConsumptionConstant.Settled.Code; + spends.Add(spend); } spendRepository.UpdateRange(spends); diff --git a/EOM.TSHotelManagement.Application/Business/Spend/SpendService.cs b/EOM.TSHotelManagement.Application/Business/Spend/SpendService.cs index 3d74451..0f8e939 100644 --- a/EOM.TSHotelManagement.Application/Business/Spend/SpendService.cs +++ b/EOM.TSHotelManagement.Application/Business/Spend/SpendService.cs @@ -116,6 +116,22 @@ namespace EOM.TSHotelManagement.Application count = spends.Count; } var result = EntityMapper.MapList(spends); + + result.ForEach(r => + { + r.SettlementStatusDescription = r.SettlementStatus.IsNullOrEmpty() ? "" + : r.SettlementStatus.Equals(ConsumptionConstant.Settled) ? "已结算" : "未结算"; + + r.ProductPriceFormatted = (r.ProductPrice + "").IsNullOrEmpty() ? "" + : Decimal.Parse(r.ProductPrice.ToString()).ToString("#,##0.00").ToString(); + + r.ConsumptionAmountFormatted = (r.ConsumptionAmount + "").IsNullOrEmpty() ? "" + : Decimal.Parse(r.ConsumptionAmount.ToString()).ToString("#,##0.00").ToString(); + + r.ConsumptionTypeDescription = r.ConsumptionType == SpendType.Product.Code ? SpendType.Product.Description : + r.ConsumptionType == SpendType.Room.Code ? SpendType.Room.Description : SpendType.Other.Description; + }); + return new ListOutputDto { Data = new PagedData @@ -152,6 +168,22 @@ namespace EOM.TSHotelManagement.Application count = spends.Count; } var result = EntityMapper.MapList(spends); + + result.ForEach(r => + { + r.SettlementStatusDescription = r.SettlementStatus.IsNullOrEmpty() ? "" + : r.SettlementStatus.Equals(ConsumptionConstant.Settled) ? "已结算" : "未结算"; + + r.ProductPriceFormatted = (r.ProductPrice + "").IsNullOrEmpty() ? "" + : Decimal.Parse(r.ProductPrice.ToString()).ToString("#,##0.00").ToString(); + + r.ConsumptionAmountFormatted = (r.ConsumptionAmount + "").IsNullOrEmpty() ? "" + : Decimal.Parse(r.ConsumptionAmount.ToString()).ToString("#,##0.00").ToString(); + + r.ConsumptionTypeDescription = r.ConsumptionType == SpendType.Product.Code ? SpendType.Product.Description : + r.ConsumptionType == SpendType.Room.Code ? SpendType.Room.Description : SpendType.Other.Description; + }); + return new ListOutputDto { Data = new PagedData @@ -183,6 +215,22 @@ namespace EOM.TSHotelManagement.Application count = spends.Count; } var result = EntityMapper.MapList(spends); + + result.ForEach(r => + { + r.SettlementStatusDescription = r.SettlementStatus.IsNullOrEmpty() ? "" + : r.SettlementStatus.Equals(ConsumptionConstant.Settled) ? "已结算" : "未结算"; + + r.ProductPriceFormatted = (r.ProductPrice + "").IsNullOrEmpty() ? "" + : Decimal.Parse(r.ProductPrice.ToString()).ToString("#,##0.00").ToString(); + + r.ConsumptionAmountFormatted = (r.ConsumptionAmount + "").IsNullOrEmpty() ? "" + : Decimal.Parse(r.ConsumptionAmount.ToString()).ToString("#,##0.00").ToString(); + + r.ConsumptionTypeDescription = r.ConsumptionType == SpendType.Product.Code ? SpendType.Product.Description : + r.ConsumptionType == SpendType.Room.Code ? SpendType.Room.Description : SpendType.Other.Description; + }); + return new ListOutputDto { Data = new PagedData @@ -248,7 +296,7 @@ namespace EOM.TSHotelManagement.Application /// public SingleOutputDto SumConsumptionAmount(ReadSpendInputDto readSpendInputDto) { - var TotalCountAmount = spendRepository.GetList(a => a.RoomNumber == readSpendInputDto.RoomNumber && a.CustomerNumber == readSpendInputDto.CustomerNumber && a.SettlementStatus.Equals(ConsumptionConstant.UnSettle)).Sum(a => a.ConsumptionAmount); + var TotalCountAmount = spendRepository.GetList(a => a.RoomNumber == readSpendInputDto.RoomNumber && a.CustomerNumber == readSpendInputDto.CustomerNumber && a.SettlementStatus == ConsumptionConstant.UnSettle.Code).Sum(a => a.ConsumptionAmount); return new SingleOutputDto { Data = new ReadSpendInputDto { ConsumptionAmount = TotalCountAmount } }; } #endregion diff --git a/EOM.TSHotelManagement.EntityFramework/Repository/GenericRepository.cs b/EOM.TSHotelManagement.EntityFramework/Repository/GenericRepository.cs index 0c7cdfe..5323170 100644 --- a/EOM.TSHotelManagement.EntityFramework/Repository/GenericRepository.cs +++ b/EOM.TSHotelManagement.EntityFramework/Repository/GenericRepository.cs @@ -2,6 +2,7 @@ using EOM.TSHotelManagement.Common.Util; using Microsoft.AspNetCore.Http; using SqlSugar; +using System.Linq.Expressions; namespace EOM.TSHotelManagement.EntityFramework { @@ -44,8 +45,10 @@ namespace EOM.TSHotelManagement.EntityFramework if (entity is BaseEntity baseEntity) { var currentUser = GetCurrentUser(); - baseEntity.DataInsDate = DateTime.Now; - baseEntity.DataInsUsr = currentUser; + if (!baseEntity.DataInsDate.HasValue) + baseEntity.DataInsDate = DateTime.Now; + if (string.IsNullOrEmpty(baseEntity.DataInsUsr)) + baseEntity.DataInsUsr = currentUser; } return base.Insert(entity); } @@ -55,10 +58,63 @@ namespace EOM.TSHotelManagement.EntityFramework if (entity is BaseEntity baseEntity) { var currentUser = GetCurrentUser(); - baseEntity.DataChgDate = DateTime.Now; - baseEntity.DataChgUsr = currentUser; + if (!baseEntity.DataChgDate.HasValue) + baseEntity.DataChgDate = DateTime.Now; + if (string.IsNullOrEmpty(baseEntity.DataChgUsr)) + baseEntity.DataChgUsr = currentUser; + } + + var primaryKeys = base.Context.EntityMaintenance.GetEntityInfo().Columns + .Where(it => it.IsPrimarykey) + .Select(it => it.PropertyName) + .ToList(); + + if (primaryKeys.Count <= 1) + { + return base.Context.Updateable(entity) + .IgnoreColumns(true, false) + .ExecuteCommand() > 0; } - return base.Context.Updateable(entity).IgnoreColumns(ignoreAllNullColumns: true, false, true).ExecuteCommand() > 0; + + var idProperty = entity.GetType().GetProperty("Id"); + if (idProperty != null) + { + var idValue = Convert.ToInt64(idProperty.GetValue(entity)); + + if (idValue == 0) + { + var otherPrimaryKeys = primaryKeys.Where(pk => pk != "Id").ToList(); + + var parameter = Expression.Parameter(typeof(T), "it"); + Expression whereExpression = null; + + foreach (var key in otherPrimaryKeys) + { + var property = Expression.Property(parameter, key); + var value = entity.GetType().GetProperty(key).GetValue(entity); + var constant = Expression.Constant(value); + var equal = Expression.Equal(property, constant); + + whereExpression = whereExpression == null + ? equal + : Expression.AndAlso(whereExpression, equal); + } + + if (whereExpression != null) + { + var lambda = Expression.Lambda>(whereExpression, parameter); + + return base.Context.Updateable(entity) + .Where(lambda) + .IgnoreColumns(true, false) + .ExecuteCommand() > 0; + } + } + } + + return base.Context.Updateable(entity) + .IgnoreColumns(true, false) + .ExecuteCommand() > 0; } public override bool UpdateRange(List updateObjs) @@ -68,12 +124,16 @@ namespace EOM.TSHotelManagement.EntityFramework if (entity is BaseEntity baseEntity) { var currentUser = GetCurrentUser(); - baseEntity.DataChgDate = DateTime.Now; - baseEntity.DataChgUsr = currentUser; + if (!baseEntity.DataChgDate.HasValue) + baseEntity.DataChgDate = DateTime.Now; + if (string.IsNullOrEmpty(baseEntity.DataChgUsr)) + baseEntity.DataChgUsr = currentUser; } } - return base.Context.Updateable(updateObjs).IgnoreColumns(ignoreAllNullColumns: true, false, true).ExecuteCommand() > 0; + return base.Context.Updateable(updateObjs) + .IgnoreColumns(ignoreAllNullColumns: true) + .ExecuteCommand() > 0; } public bool SoftDelete(T entity) @@ -81,10 +141,63 @@ namespace EOM.TSHotelManagement.EntityFramework if (entity is BaseEntity baseEntity) { var currentUser = GetCurrentUser(); - baseEntity.DataChgDate = DateTime.Now; - baseEntity.DataChgUsr = currentUser; + if (!baseEntity.DataChgDate.HasValue) + baseEntity.DataChgDate = DateTime.Now; + if (string.IsNullOrEmpty(baseEntity.DataChgUsr)) + baseEntity.DataChgUsr = currentUser; + } + + var primaryKeys = base.Context.EntityMaintenance.GetEntityInfo().Columns + .Where(it => it.IsPrimarykey) + .Select(it => it.PropertyName) + .ToList(); + + if (primaryKeys.Count <= 1) + { + return base.Context.Updateable(entity) + .IgnoreColumns(ignoreAllNullColumns: true, false, true) + .ExecuteCommand() > 0; } - return base.Context.Updateable(entity).IgnoreColumns(ignoreAllNullColumns: true, false, true).ExecuteCommand() > 0; + + var idProperty = entity.GetType().GetProperty("Id"); + if (idProperty != null) + { + var idValue = Convert.ToInt64(idProperty.GetValue(entity)); + + if (idValue == 0) + { + var otherPrimaryKeys = primaryKeys.Where(pk => pk != "Id").ToList(); + + var parameter = Expression.Parameter(typeof(T), "it"); + Expression whereExpression = null; + + foreach (var key in otherPrimaryKeys) + { + var property = Expression.Property(parameter, key); + var value = entity.GetType().GetProperty(key).GetValue(entity); + var constant = Expression.Constant(value); + var equal = Expression.Equal(property, constant); + + whereExpression = whereExpression == null + ? equal + : Expression.AndAlso(whereExpression, equal); + } + + if (whereExpression != null) + { + var lambda = Expression.Lambda>(whereExpression, parameter); + + return base.Context.Updateable(entity) + .Where(lambda) + .IgnoreColumns(ignoreAllNullColumns: true) + .ExecuteCommand() > 0; + } + } + } + + return base.Context.Updateable(entity) + .IgnoreColumns(ignoreAllNullColumns: true) + .ExecuteCommand() > 0; } } } -- Gitee From ccf133f885049974dd3cc5078406ba4d13eb42db Mon Sep 17 00:00:00 2001 From: ck_yeun9 Date: Sat, 6 Sep 2025 14:25:00 +0800 Subject: [PATCH 3/3] refactor repository logic. --- .../Application/NavBar/NavBarService.cs | 1 - .../Business/Asset/AssetService.cs | 7 +- .../Customer/CustomerAccountService.cs | 52 ++++--- .../Business/Customer/CustomerService.cs | 2 +- .../PromotionContentService.cs | 11 +- .../Business/Reser/IReserService.cs | 6 + .../Business/Reser/ReserService.cs | 38 +++-- .../Business/Room/RoomService.cs | 24 +--- .../Business/Room/RoomTypeService.cs | 9 +- .../Business/Sellthing/ISellService.cs | 2 +- .../Business/Sellthing/SellService.cs | 39 ++--- .../Business/Spend/SpendService.cs | 135 ++++++------------ .../Employee/EmployeeService.cs | 23 +-- .../Employee/Photo/EmployeePhotoService.cs | 17 +-- .../SupervisionStatisticsService.cs | 33 ++--- .../VipRule/VipRuleAppService.cs | 24 +--- .../BaseDto/BaseDto.cs | 2 +- .../Sellthing/Dto/CreateSellThingInputDto.cs | 2 +- .../Sellthing/Dto/ReadSellThingOutputDto.cs | 4 +- .../Sellthing/Dto/UpdateSellThingInputDto.cs | 2 +- .../CreateOperationLogInputDto.cs | 1 + .../Business/Sellthing/SellThing.cs | 2 +- .../Util/OperationLog.cs | 77 ---------- .../Repository/GenericRepository.cs | 1 - .../EntityBuilder.cs | 11 ++ .../Helper/DiscountHelper.cs | 21 --- .../Business/Reser/ReserController.cs | 11 ++ .../Business/Sellthing/SellthingController.cs | 4 +- EOM.TSHotelManagement.WebApi/Startup.cs | 1 + 29 files changed, 210 insertions(+), 352 deletions(-) diff --git a/EOM.TSHotelManagement.Application/Application/NavBar/NavBarService.cs b/EOM.TSHotelManagement.Application/Application/NavBar/NavBarService.cs index f509d22..78d4d8e 100644 --- a/EOM.TSHotelManagement.Application/Application/NavBar/NavBarService.cs +++ b/EOM.TSHotelManagement.Application/Application/NavBar/NavBarService.cs @@ -52,7 +52,6 @@ namespace EOM.TSHotelManagement.Application { var navBar = new NavBar { - Id = input.Id, NavigationBarEvent = input.NavigationBarEvent, NavigationBarImage = input.NavigationBarImage, NavigationBarName = input.NavigationBarName, diff --git a/EOM.TSHotelManagement.Application/Business/Asset/AssetService.cs b/EOM.TSHotelManagement.Application/Business/Asset/AssetService.cs index dffc2a4..8d6f799 100644 --- a/EOM.TSHotelManagement.Application/Business/Asset/AssetService.cs +++ b/EOM.TSHotelManagement.Application/Business/Asset/AssetService.cs @@ -25,6 +25,7 @@ using EOM.TSHotelManagement.Common.Contract; using EOM.TSHotelManagement.Common.Core; using EOM.TSHotelManagement.Common.Util; using EOM.TSHotelManagement.EntityFramework; +using jvncorelib.EntityLib; using SqlSugar; namespace EOM.TSHotelManagement.Application @@ -173,11 +174,13 @@ namespace EOM.TSHotelManagement.Application { try { - if (!assetRepository.IsAny(a => a.AssetNumber == asset.AssetNumber)) + var dbAsset = assetRepository.GetFirst(a => a.AssetNumber == asset.AssetNumber); + if (dbAsset.IsNullOrEmpty()) { return new BaseResponse() { Message = LocalizationHelper.GetLocalizedString("asset number does not exist.", "资产编号不存在"), Code = BusinessStatusCode.InternalServerError }; } - assetRepository.SoftDelete(new Asset { IsDelete = asset.IsDelete, AssetNumber = asset.AssetNumber, Id = asset.Id }); + dbAsset.IsDelete = asset.IsDelete; + assetRepository.SoftDelete(dbAsset); } catch (Exception ex) { diff --git a/EOM.TSHotelManagement.Application/Business/Customer/CustomerAccountService.cs b/EOM.TSHotelManagement.Application/Business/Customer/CustomerAccountService.cs index 7b2e09d..b2d15b1 100644 --- a/EOM.TSHotelManagement.Application/Business/Customer/CustomerAccountService.cs +++ b/EOM.TSHotelManagement.Application/Business/Customer/CustomerAccountService.cs @@ -4,6 +4,7 @@ using EOM.TSHotelManagement.Common.Util; using EOM.TSHotelManagement.EntityFramework; using jvncorelib.CodeLib; using jvncorelib.EntityLib; +using Microsoft.AspNetCore.Http; using System.Security.Claims; using System.Text.Json; using System.Text.RegularExpressions; @@ -33,12 +34,28 @@ namespace EOM.TSHotelManagement.Application /// private readonly JWTHelper jWTHelper; - public CustomerAccountService(GenericRepository customerAccountRepository, GenericRepository customerRepository, DataProtectionHelper dataProtector, JWTHelper jWTHelper) + + private readonly IHttpContextAccessor _httpContextAccessor; + + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public CustomerAccountService(GenericRepository customerAccountRepository, GenericRepository customerRepository, DataProtectionHelper dataProtector, JWTHelper jWTHelper, IHttpContextAccessor httpContextAccessor, Regex accountRegex, Regex passwordRegex) { this.customerAccountRepository = customerAccountRepository; this.customerRepository = customerRepository; this.dataProtector = dataProtector; this.jWTHelper = jWTHelper; + _httpContextAccessor = httpContextAccessor; + AccountRegex = accountRegex; + PasswordRegex = passwordRegex; } /// @@ -58,17 +75,18 @@ namespace EOM.TSHotelManagement.Application if (!dataProtector.CompareCustomerData(customerAccount.Password, readCustomerAccountInputDto.Password)) return new SingleOutputDto() { Code = BusinessStatusCode.Unauthorized, Message = LocalizationHelper.GetLocalizedString("Invalid account or password", "账号或密码错误"), Data = new ReadCustomerAccountOutputDto() }; - customerAccount.Password = null; + var copyCustomerAccount = customerAccount; - customerAccountRepository.Update(new CustomerAccount - { - Id = customerAccount.Id, - Account = customerAccount.Account, - LastLoginIp = customerAccount.LastLoginIp, - LastLoginTime = customerAccount.LastLoginTime - }); + var context = _httpContextAccessor.HttpContext; + var ipAddress = context.Connection.RemoteIpAddress?.ToString() ?? string.Empty; + + customerAccount.LastLoginIp = ipAddress; + customerAccount.LastLoginTime = DateTime.Now; + customerAccountRepository.Update(customerAccount); + + copyCustomerAccount.Password = null; - customerAccount.UserToken = jWTHelper.GenerateJWT(new ClaimsIdentity(new Claim[] + copyCustomerAccount.UserToken = jWTHelper.GenerateJWT(new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Name, customerAccount.Name), new Claim(ClaimTypes.SerialNumber, customerAccount.CustomerNumber), @@ -82,13 +100,13 @@ namespace EOM.TSHotelManagement.Application Message = LocalizationHelper.GetLocalizedString("Login successful", "登录成功"), Data = new ReadCustomerAccountOutputDto { - Account = customerAccount.Account, - EmailAddress = customerAccount.EmailAddress, - Name = customerAccount.Name, - LastLoginIp = customerAccount.LastLoginIp, - LastLoginTime = customerAccount.LastLoginTime, - Status = customerAccount.Status, - UserToken = customerAccount.UserToken + Account = copyCustomerAccount.Account, + EmailAddress = copyCustomerAccount.EmailAddress, + Name = copyCustomerAccount.Name, + LastLoginIp = copyCustomerAccount.LastLoginIp, + LastLoginTime = copyCustomerAccount.LastLoginTime, + Status = copyCustomerAccount.Status, + UserToken = copyCustomerAccount.UserToken }, }; } diff --git a/EOM.TSHotelManagement.Application/Business/Customer/CustomerService.cs b/EOM.TSHotelManagement.Application/Business/Customer/CustomerService.cs index c2f5f72..6f96b56 100644 --- a/EOM.TSHotelManagement.Application/Business/Customer/CustomerService.cs +++ b/EOM.TSHotelManagement.Application/Business/Customer/CustomerService.cs @@ -219,7 +219,7 @@ namespace EOM.TSHotelManagement.Application where = where.And(a => a.IsDelete == readCustomerInputDto.IsDelete); if (!readCustomerInputDto.CustomerNumber.IsNullOrEmpty()) { - where = where.And(a => a.CustomerNumber.Equals(readCustomerInputDto.CustomerNumber)); + where = where.And(a => a.CustomerNumber.Contains(readCustomerInputDto.CustomerNumber)); } if (!readCustomerInputDto.CustomerName.IsNullOrEmpty()) { diff --git a/EOM.TSHotelManagement.Application/Business/PromotionContent/PromotionContentService.cs b/EOM.TSHotelManagement.Application/Business/PromotionContent/PromotionContentService.cs index 074a652..fbe20ed 100644 --- a/EOM.TSHotelManagement.Application/Business/PromotionContent/PromotionContentService.cs +++ b/EOM.TSHotelManagement.Application/Business/PromotionContent/PromotionContentService.cs @@ -137,14 +137,9 @@ namespace EOM.TSHotelManagement.Application { try { - fontsRepository.SoftDelete(new PromotionContent - { - Id = deletePromotionContentInputDto.Id, - PromotionContentNumber = deletePromotionContentInputDto.PromotionContentNumber, - IsDelete = deletePromotionContentInputDto.IsDelete, - DataChgUsr = deletePromotionContentInputDto.DataChgUsr, - DataChgDate = deletePromotionContentInputDto.DataChgDate - }); + var font = fontsRepository.GetFirst(a => a.PromotionContentNumber == deletePromotionContentInputDto.PromotionContentNumber && a.IsDelete != 1); + font.IsDelete = deletePromotionContentInputDto.IsDelete; + fontsRepository.SoftDelete(font); } catch (Exception ex) { diff --git a/EOM.TSHotelManagement.Application/Business/Reser/IReserService.cs b/EOM.TSHotelManagement.Application/Business/Reser/IReserService.cs index 431543c..f6e1247 100644 --- a/EOM.TSHotelManagement.Application/Business/Reser/IReserService.cs +++ b/EOM.TSHotelManagement.Application/Business/Reser/IReserService.cs @@ -65,5 +65,11 @@ namespace EOM.TSHotelManagement.Application /// BaseResponse InserReserInfo(CreateReserInputDto r); + /// + /// 查询所有预约类型 + /// + /// + ListOutputDto SelectReserTypeAll(); + } } \ No newline at end of file diff --git a/EOM.TSHotelManagement.Application/Business/Reser/ReserService.cs b/EOM.TSHotelManagement.Application/Business/Reser/ReserService.cs index e31b95a..6a7a2e3 100644 --- a/EOM.TSHotelManagement.Application/Business/Reser/ReserService.cs +++ b/EOM.TSHotelManagement.Application/Business/Reser/ReserService.cs @@ -160,14 +160,8 @@ namespace EOM.TSHotelManagement.Application using (TransactionScope scope = new TransactionScope()) { - var result = reserRepository.SoftDelete(new Reser() - { - Id = reserInfo.Id, - ReservationId = reser.ReservationId, - IsDelete = reser.IsDelete, - DataChgUsr = reser.DataChgUsr, - DataChgDate = reser.DataChgDate - }); + reserInfo.IsDelete = reser.IsDelete; + var result = reserRepository.SoftDelete(reserInfo); if (result) { @@ -249,5 +243,33 @@ namespace EOM.TSHotelManagement.Application return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Add Customer Failed", "预约信息添加失败")); } } + + /// + /// 查询所有预约类型 + /// + /// + public ListOutputDto SelectReserTypeAll() + { + var helper = new EnumHelper(); + var enumList = Enum.GetValues(typeof(ReserType)) + .Cast() + .Select(e => new EnumDto + { + Id = (int)e, + Name = e.ToString(), + Description = helper.GetEnumDescription(e) + }) + .ToList(); + + return new ListOutputDto + { + Data = new PagedData + { + Items = enumList, + TotalCount = enumList.Count + } + }; + } + } } diff --git a/EOM.TSHotelManagement.Application/Business/Room/RoomService.cs b/EOM.TSHotelManagement.Application/Business/Room/RoomService.cs index b3f2ea9..082950b 100644 --- a/EOM.TSHotelManagement.Application/Business/Room/RoomService.cs +++ b/EOM.TSHotelManagement.Application/Business/Room/RoomService.cs @@ -847,16 +847,10 @@ namespace EOM.TSHotelManagement.Application } var room = roomRepository.GetFirst(a => a.RoomNumber == checkinRoomByReservationDto.RoomNumber && a.IsDelete != 1); - var roomUpdateResult = roomRepository.Update(new Room() - { - RoomNumber = room.RoomNumber, - Id = room.Id, - LastCheckInTime = DateOnly.FromDateTime(DateTime.Now), - CustomerNumber = customer.CustomerNumber, - RoomStateId = new EnumHelper().GetEnumValue(RoomState.Occupied), - DataChgDate = checkinRoomByReservationDto.DataChgDate, - DataChgUsr = checkinRoomByReservationDto.DataChgUsr - }); + room.LastCheckInTime = DateOnly.FromDateTime(DateTime.Now); + room.CustomerNumber = customer.CustomerNumber; + room.RoomStateId = new EnumHelper().GetEnumValue(RoomState.Occupied); + var roomUpdateResult = roomRepository.Update(room); if (!roomUpdateResult) { @@ -864,14 +858,8 @@ namespace EOM.TSHotelManagement.Application } var reser = reserRepository.GetFirst(a => a.ReservationId == checkinRoomByReservationDto.ReservationId && a.IsDelete != 1); - var reserUpdateResult = reserRepository.Update(new Reser - { - ReservationId = reser.ReservationId, - Id = reser.Id, - IsDelete = 1, - DataChgUsr = checkinRoomByReservationDto.DataChgUsr, - DataChgDate = checkinRoomByReservationDto.DataChgDate - }); + reser.IsDelete = 1; + var reserUpdateResult = reserRepository.Update(reser); if (!reserUpdateResult) { diff --git a/EOM.TSHotelManagement.Application/Business/Room/RoomTypeService.cs b/EOM.TSHotelManagement.Application/Business/Room/RoomTypeService.cs index 71006dc..c96c781 100644 --- a/EOM.TSHotelManagement.Application/Business/Room/RoomTypeService.cs +++ b/EOM.TSHotelManagement.Application/Business/Room/RoomTypeService.cs @@ -182,12 +182,9 @@ namespace EOM.TSHotelManagement.Application { try { - roomTypeRepository.SoftDelete(new RoomType - { - RoomTypeId = roomType.RoomTypeId, - Id = roomType.Id, - IsDelete = 1 - }); + var existRoomType = roomTypeRepository.GetFirst(a => a.RoomTypeId == roomType.RoomTypeId && a.IsDelete != 1); + existRoomType.IsDelete = roomType.IsDelete; + roomTypeRepository.SoftDelete(existRoomType); } catch (Exception ex) { diff --git a/EOM.TSHotelManagement.Application/Business/Sellthing/ISellService.cs b/EOM.TSHotelManagement.Application/Business/Sellthing/ISellService.cs index 6d778f4..c5b2a38 100644 --- a/EOM.TSHotelManagement.Application/Business/Sellthing/ISellService.cs +++ b/EOM.TSHotelManagement.Application/Business/Sellthing/ISellService.cs @@ -48,7 +48,7 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseResponse UpdateSellthingInfo(UpdateSellThingInputDto sellThing); + BaseResponse UpdateSellthing(UpdateSellThingInputDto sellThing); /// /// 撤回客户消费信息 diff --git a/EOM.TSHotelManagement.Application/Business/Sellthing/SellService.cs b/EOM.TSHotelManagement.Application/Business/Sellthing/SellService.cs index 0a9c788..0281fd2 100644 --- a/EOM.TSHotelManagement.Application/Business/Sellthing/SellService.cs +++ b/EOM.TSHotelManagement.Application/Business/Sellthing/SellService.cs @@ -76,7 +76,7 @@ namespace EOM.TSHotelManagement.Application //商品名称 if (!sellThing.ProductName.IsNullOrEmpty()) { - exp = exp.Or(a => a.ProductName.Contains(sellThing.ProductName)); + exp = exp.And(a => a.ProductName.Contains(sellThing.ProductName)); } //商品规格 @@ -124,16 +124,11 @@ namespace EOM.TSHotelManagement.Application try { var product = sellThingRepository.GetFirst(a => a.ProductNumber == updateSellThingInputDto.ProductNumber); - sellThingRepository.Update(new SellThing() - { - Id = updateSellThingInputDto.Id, - Specification = updateSellThingInputDto.Specification, - ProductPrice = updateSellThingInputDto.ProductPrice, - ProductName = updateSellThingInputDto.ProductName, - ProductNumber = product.ProductNumber, - Stock = Convert.ToInt32(updateSellThingInputDto.Stock), - DataChgDate = DateTime.Now - }); + product.Stock = updateSellThingInputDto.Stock; + product.Specification = updateSellThingInputDto.Specification; + product.ProductPrice = updateSellThingInputDto.ProductPrice; + product.ProductName = updateSellThingInputDto.ProductName; + sellThingRepository.Update(product); } catch (Exception ex) { @@ -147,18 +142,16 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseResponse UpdateSellthingInfo(UpdateSellThingInputDto sellThing) + public BaseResponse UpdateSellthing(UpdateSellThingInputDto sellThing) { try { var product = sellThingRepository.GetFirst(a => a.ProductNumber == sellThing.ProductNumber); - sellThingRepository.Update(new SellThing() - { - ProductName = product.ProductName, - ProductPrice = product.ProductPrice, - Stock = sellThing.Stock, - Specification = sellThing.Specification, - }); + product.ProductName = product.ProductName; + product.ProductPrice = product.ProductPrice; + product.Stock = sellThing.Stock; + product.Specification = sellThing.Specification; + sellThingRepository.Update(product); } catch (Exception ex) { @@ -177,12 +170,8 @@ namespace EOM.TSHotelManagement.Application try { var product = sellThingRepository.GetFirst(a => a.ProductNumber == deleteSellThingInputDto.ProductNumber); - sellThingRepository.SoftDelete(new SellThing() - { - Id = product.Id, - ProductNumber = deleteSellThingInputDto.ProductNumber, - IsDelete = deleteSellThingInputDto.IsDelete, - }); + product.IsDelete = deleteSellThingInputDto.IsDelete; + sellThingRepository.SoftDelete(product); } catch (Exception ex) { diff --git a/EOM.TSHotelManagement.Application/Business/Spend/SpendService.cs b/EOM.TSHotelManagement.Application/Business/Spend/SpendService.cs index 0f8e939..61870d6 100644 --- a/EOM.TSHotelManagement.Application/Business/Spend/SpendService.cs +++ b/EOM.TSHotelManagement.Application/Business/Spend/SpendService.cs @@ -28,6 +28,7 @@ using EOM.TSHotelManagement.EntityFramework; using EOM.TSHotelManagement.Shared; using jvncorelib.CodeLib; using jvncorelib.EntityLib; +using Microsoft.AspNetCore.Http; using SqlSugar; using System.Transactions; @@ -72,16 +73,9 @@ namespace EOM.TSHotelManagement.Application private readonly GenericRepository operationLogRepository; - /// - /// - /// - /// - /// - /// - /// - /// - /// - public SpendService(GenericRepository spendRepository, GenericRepository sellThingRepository, GenericRepository roomRepository, GenericRepository customerRepository, GenericRepository custoTypeRepository, GenericRepository operationLogRepository) + private readonly IHttpContextAccessor _httpContextAccessor; + + public SpendService(GenericRepository spendRepository, GenericRepository sellThingRepository, GenericRepository roomRepository, GenericRepository customerRepository, GenericRepository custoTypeRepository, GenericRepository operationLogRepository, IHttpContextAccessor httpContextAccessor) { this.spendRepository = spendRepository; this.sellThingRepository = sellThingRepository; @@ -89,6 +83,7 @@ namespace EOM.TSHotelManagement.Application this.customerRepository = customerRepository; this.custoTypeRepository = custoTypeRepository; this.operationLogRepository = operationLogRepository; + _httpContextAccessor = httpContextAccessor; } #region 根据客户编号查询历史消费信息 @@ -120,7 +115,7 @@ namespace EOM.TSHotelManagement.Application result.ForEach(r => { r.SettlementStatusDescription = r.SettlementStatus.IsNullOrEmpty() ? "" - : r.SettlementStatus.Equals(ConsumptionConstant.Settled) ? "已结算" : "未结算"; + : r.SettlementStatus.Equals(ConsumptionConstant.Settled.Code) ? "已结算" : "未结算"; r.ProductPriceFormatted = (r.ProductPrice + "").IsNullOrEmpty() ? "" : Decimal.Parse(r.ProductPrice.ToString()).ToString("#,##0.00").ToString(); @@ -152,10 +147,27 @@ namespace EOM.TSHotelManagement.Application public ListOutputDto SelectSpendByRoomNo(ReadSpendInputDto readSpendInputDto) { var where = Expressionable.Create(); + + if (!readSpendInputDto.CustomerNumber.IsNullOrEmpty()) + { + where = where.And(a => a.CustomerNumber == readSpendInputDto.CustomerNumber); + } + + if (!readSpendInputDto.SettlementStatus.IsNullOrEmpty()) + { + where = where.And(a => a.SettlementStatus == readSpendInputDto.SettlementStatus); + } + if (!readSpendInputDto.RoomNumber.IsNullOrEmpty()) { where = where.And(a => a.RoomNumber == readSpendInputDto.RoomNumber); } + + if (!readSpendInputDto.SpendNumber.IsNullOrEmpty()) + { + where = where.And(a => a.SpendNumber.Contains(readSpendInputDto.SpendNumber)); + } + var count = 0; List spends = new List(); if (!readSpendInputDto.IgnorePaging && readSpendInputDto.Page != 0 && readSpendInputDto.PageSize != 0) @@ -172,7 +184,7 @@ namespace EOM.TSHotelManagement.Application result.ForEach(r => { r.SettlementStatusDescription = r.SettlementStatus.IsNullOrEmpty() ? "" - : r.SettlementStatus.Equals(ConsumptionConstant.Settled) ? "已结算" : "未结算"; + : r.SettlementStatus.Equals(ConsumptionConstant.Settled.Code) ? "已结算" : "未结算"; r.ProductPriceFormatted = (r.ProductPrice + "").IsNullOrEmpty() ? "" : Decimal.Parse(r.ProductPrice.ToString()).ToString("#,##0.00").ToString(); @@ -219,7 +231,7 @@ namespace EOM.TSHotelManagement.Application result.ForEach(r => { r.SettlementStatusDescription = r.SettlementStatus.IsNullOrEmpty() ? "" - : r.SettlementStatus.Equals(ConsumptionConstant.Settled) ? "已结算" : "未结算"; + : r.SettlementStatus.Equals(ConsumptionConstant.Settled.Code) ? "已结算" : "未结算"; r.ProductPriceFormatted = (r.ProductPrice + "").IsNullOrEmpty() ? "" : Decimal.Parse(r.ProductPrice.ToString()).ToString("#,##0.00").ToString(); @@ -242,52 +254,6 @@ namespace EOM.TSHotelManagement.Application } #endregion - #region 根据房间号查询消费的所有信息 - /// - /// 根据房间号查询消费的所有信息 - /// - /// - public ListOutputDto SelectSpendInfoRoomNo(ReadSpendInputDto readSpendInputDto) - { - List ls = spendRepository.GetList(a => a.RoomNumber == readSpendInputDto.RoomNumber && a.IsDelete != 1 && a.SettlementStatus.Equals(ConsumptionConstant.UnSettle)); - var spendNames = ls.Select(a => a.ProductName).ToList(); - var spendInfos = sellThingRepository.AsQueryable().Where(a => spendNames.Contains(a.ProductName)).ToList(); - ls.ForEach(source => - { - if (source.ProductNumber.IsNullOrEmpty()) - { - var spendInfo = spendInfos.SingleOrDefault(a => a.ProductName.Equals(source.ProductName)); - if (spendInfo != null) - { - source.ProductNumber = spendInfo.ProductNumber; - } - } - - source.SettlementStatusDescription = source.SettlementStatus.IsNullOrEmpty() ? "" - : source.SettlementStatus.Equals(ConsumptionConstant.Settled) ? "已结算" : "未结算"; - - source.ProductPriceFormatted = (source.ProductPrice + "").IsNullOrEmpty() ? "" - : Decimal.Parse(source.ProductPrice.ToString()).ToString("#,##0.00").ToString(); - - source.ConsumptionAmountFormatted = (source.ConsumptionAmount + "").IsNullOrEmpty() ? "" - : Decimal.Parse(source.ConsumptionAmount.ToString()).ToString("#,##0.00").ToString(); - - source.ConsumptionTypeDescription = source.ConsumptionType == SpendType.Product.Code ? SpendType.Product.Description : - source.ConsumptionType == SpendType.Room.Code ? SpendType.Room.Description : SpendType.Other.Description; - }); - - var mapped = EntityMapper.MapList(ls); - return new ListOutputDto - { - Data = new PagedData - { - Items = mapped, - TotalCount = mapped.Count - } - }; - } - #endregion - #region 根据房间编号、入住时间到当前时间查询消费总金额 /// /// 根据房间编号、入住时间到当前时间查询消费总金额 @@ -310,15 +276,9 @@ namespace EOM.TSHotelManagement.Application { try { - var existingSpend = spendRepository.AsQueryable().Where(a => a.SpendNumber == updateSpendInputDto.SpendNumber && a.IsDelete != 1).Single(); - spendRepository.Update(new Spend() - { - Id = existingSpend.Id, - SpendNumber = existingSpend.SpendNumber, - IsDelete = 1, - DataChgDate = updateSpendInputDto.DataChgDate, - DataChgUsr = updateSpendInputDto.DataChgUsr - }); + var existingSpend = spendRepository.GetFirst(a => a.SpendNumber == updateSpendInputDto.SpendNumber && a.IsDelete != 1); + existingSpend.IsDelete = 1; + spendRepository.Update(existingSpend); } catch (Exception ex) { @@ -356,10 +316,11 @@ namespace EOM.TSHotelManagement.Application } var customerType = custoTypeRepository.AsQueryable().Single(a => a.CustomerType == customer.CustomerType); - decimal discountPercent = customerType?.Discount ?? 100m; + decimal discount = (customerType != null && customerType.Discount > 0 && customerType.Discount < 100) + ? customerType.Discount / 100M + : 1M; - decimal originalAmount = addCustomerSpendInputDto.Price * addCustomerSpendInputDto.Quantity; - decimal realAmount = DiscountHelper.RealAmount(discountPercent, originalAmount); + decimal realAmount = addCustomerSpendInputDto.Price * addCustomerSpendInputDto.Quantity * discount; var existingSpend = spendRepository.AsQueryable().Single(a => a.RoomNumber == addCustomerSpendInputDto.RoomNumber && a.ProductNumber == addCustomerSpendInputDto.ProductNumber && a.IsDelete != 1 && a.SettlementStatus == ConsumptionConstant.UnSettle.Code); @@ -404,12 +365,8 @@ namespace EOM.TSHotelManagement.Application } var product = sellThingRepository.AsQueryable().Single(a => a.ProductNumber == addCustomerSpendInputDto.ProductNumber); - var updateResult = sellThingRepository.Update(new SellThing - { - ProductNumber = product.ProductNumber, - Id = product.Id, - Stock = product.Stock - addCustomerSpendInputDto.Quantity - }); + product.Stock = product.Stock - addCustomerSpendInputDto.Quantity; + var updateResult = sellThingRepository.Update(product); if (!updateResult) { return new BaseResponse() { Message = "商品库存更新失败", Code = BusinessStatusCode.InternalServerError }; @@ -421,11 +378,14 @@ namespace EOM.TSHotelManagement.Application $"数量 {addCustomerSpendInputDto.Quantity}, " + $"金额 {realAmount.ToString("#,##0.00")}"; + var context = _httpContextAccessor.HttpContext; var log = new OperationLog { + OperationId = new UniqueCode().GetNewId("OP-"), OperationTime = Convert.ToDateTime(DateTime.Now), LogContent = logContent, + LoginIpAddress = context.Connection.RemoteIpAddress?.ToString() ?? string.Empty, OperationAccount = addCustomerSpendInputDto.WorkerNo, LogLevel = LogLevel.Warning, SoftwareVersion = addCustomerSpendInputDto.SoftwareVersion, @@ -458,19 +418,14 @@ namespace EOM.TSHotelManagement.Application { try { - spendRepository.Update(new Spend() - { - Id = spend.Id, - SpendNumber = spend.SpendNumber, - SettlementStatus = ConsumptionConstant.UnSettle.Code, - RoomNumber = spend.RoomNumber, - CustomerNumber = spend.CustomerNumber, - ProductName = spend.ProductName, - ConsumptionQuantity = spend.ConsumptionQuantity, - ConsumptionAmount = spend.ConsumptionAmount, - DataChgDate = spend.DataChgDate, - DataChgUsr = spend.DataChgUsr - }); + var dbSpend = spendRepository.GetFirst(a => a.SpendNumber == spend.SpendNumber && a.IsDelete != 1); + dbSpend.SettlementStatus = spend.SettlementStatus; + dbSpend.RoomNumber = spend.RoomNumber; + dbSpend.CustomerNumber = spend.CustomerNumber; + dbSpend.ProductName = spend.ProductName; + dbSpend.ConsumptionQuantity = spend.ConsumptionQuantity; + dbSpend.ConsumptionAmount = spend.ConsumptionAmount; + spendRepository.Update(dbSpend); } catch (Exception ex) { diff --git a/EOM.TSHotelManagement.Application/Employee/EmployeeService.cs b/EOM.TSHotelManagement.Application/Employee/EmployeeService.cs index 71f7d88..601cd33 100644 --- a/EOM.TSHotelManagement.Application/Employee/EmployeeService.cs +++ b/EOM.TSHotelManagement.Application/Employee/EmployeeService.cs @@ -458,15 +458,9 @@ namespace EOM.TSHotelManagement.Application mailHelper.SendMail(new List { employee.EmailAddress }, mailTemplate.Subject, mailTemplate.Body, new List { employee.EmailAddress }); } - workerRepository.Update(new Employee() - { - Id = employee.Id, - EmployeeId = employee.EmployeeId, - Password = encrypted, - IsInitialize = 1, - DataChgUsr = updateEmployeeInputDto.DataChgUsr, - DataChgDate = updateEmployeeInputDto.DataChgDate - }); + employee.Password = encrypted; + employee.IsInitialize = 1; + workerRepository.Update(employee); } catch (Exception ex) { @@ -512,14 +506,9 @@ namespace EOM.TSHotelManagement.Application return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("E-Mail Config Invaild, Reset Password Faild", "电子邮件配置无效,重置密码失败"), Code = BusinessStatusCode.InternalServerError }; } - workerRepository.Update(new Employee() - { - Id = employee.Id, - EmployeeId = employee.EmployeeId, - Password = encrypted, - DataChgUsr = updateEmployeeInputDto.DataChgUsr, - DataChgDate = updateEmployeeInputDto.DataChgDate - }); + employee.Password = encrypted; + + workerRepository.Update(employee); } catch (Exception ex) { diff --git a/EOM.TSHotelManagement.Application/Employee/Photo/EmployeePhotoService.cs b/EOM.TSHotelManagement.Application/Employee/Photo/EmployeePhotoService.cs index 5fb53cd..72ab902 100644 --- a/EOM.TSHotelManagement.Application/Employee/Photo/EmployeePhotoService.cs +++ b/EOM.TSHotelManagement.Application/Employee/Photo/EmployeePhotoService.cs @@ -124,12 +124,9 @@ namespace EOM.TSHotelManagement.Application } else { - workerPicRepository.Update(new EmployeePhoto - { - Id = workerPicData.Id, - EmployeeId = workerPicData.EmployeeId, - PhotoPath = imageUrl - }); + workerPicData = workerPicRepository.GetFirst(a => a.EmployeeId.Equals(createEmployeePhotoInputDto.EmployeeId)); + workerPicData.PhotoPath = imageUrl; + workerPicRepository.Update(workerPicData); } return new SingleOutputDto @@ -176,12 +173,8 @@ namespace EOM.TSHotelManagement.Application try { var workerPicData = workerPicRepository.GetFirst(a => a.EmployeeId.Equals(updateEmployeePhotoInputDto.EmployeeId)); - workerPicRepository.Update(new EmployeePhoto - { - Id = workerPicData.Id, - EmployeeId = workerPicData.EmployeeId, - PhotoPath = updateEmployeePhotoInputDto.PhotoUrl - }); + workerPicData.PhotoPath = updateEmployeePhotoInputDto.PhotoUrl; + workerPicRepository.Update(workerPicData); } catch (Exception ex) { diff --git a/EOM.TSHotelManagement.Application/SystemManagement/SupervisionStatistics/SupervisionStatisticsService.cs b/EOM.TSHotelManagement.Application/SystemManagement/SupervisionStatistics/SupervisionStatisticsService.cs index 772e270..b4dd1f6 100644 --- a/EOM.TSHotelManagement.Application/SystemManagement/SupervisionStatistics/SupervisionStatisticsService.cs +++ b/EOM.TSHotelManagement.Application/SystemManagement/SupervisionStatistics/SupervisionStatisticsService.cs @@ -110,20 +110,14 @@ namespace EOM.TSHotelManagement.Application try { var supervisionStatistics = checkInfoRepository.GetFirst(a => a.StatisticsNumber == checkInfo.StatisticsNumber); - checkInfoRepository.Update(new SupervisionStatistics - { - Id = supervisionStatistics.Id, - StatisticsNumber = supervisionStatistics.StatisticsNumber, - SupervisingDepartment = checkInfo.SupervisingDepartment, - SupervisionLoss = checkInfo.SupervisionLoss, - SupervisionScore = checkInfo.SupervisionScore, - SupervisionAdvice = checkInfo.SupervisionAdvice, - SupervisionStatistician = checkInfo.SupervisionStatistician, - SupervisionProgress = checkInfo.SupervisionProgress, - IsDelete = 0, - DataChgUsr = checkInfo.DataChgUsr, - DataChgDate = checkInfo.DataChgDate - }); + supervisionStatistics.SupervisingDepartment = checkInfo.SupervisingDepartment; + supervisionStatistics.SupervisionLoss = checkInfo.SupervisionLoss; + supervisionStatistics.SupervisionScore = checkInfo.SupervisionScore; + supervisionStatistics.SupervisionAdvice = checkInfo.SupervisionAdvice; + supervisionStatistics.SupervisionStatistician = checkInfo.SupervisionStatistician; + supervisionStatistics.SupervisionProgress = checkInfo.SupervisionProgress; + + checkInfoRepository.Update(supervisionStatistics); } catch (Exception ex) { @@ -141,14 +135,9 @@ namespace EOM.TSHotelManagement.Application { try { - checkInfoRepository.SoftDelete(new SupervisionStatistics - { - StatisticsNumber = checkInfo.StatisticsNumber, - Id = checkInfo.Id, - IsDelete = 1, - DataChgUsr = checkInfo.DataChgUsr, - DataChgDate = checkInfo.DataChgDate - }); + var existing = checkInfoRepository.GetFirst(a => a.StatisticsNumber == checkInfo.StatisticsNumber && a.IsDelete == 0); + existing.IsDelete = 1; + checkInfoRepository.SoftDelete(existing); } catch (Exception ex) { diff --git a/EOM.TSHotelManagement.Application/SystemManagement/VipRule/VipRuleAppService.cs b/EOM.TSHotelManagement.Application/SystemManagement/VipRule/VipRuleAppService.cs index 6ae5a6c..6a67a39 100644 --- a/EOM.TSHotelManagement.Application/SystemManagement/VipRule/VipRuleAppService.cs +++ b/EOM.TSHotelManagement.Application/SystemManagement/VipRule/VipRuleAppService.cs @@ -148,13 +148,9 @@ namespace EOM.TSHotelManagement.Application { try { - vipRuleRepository.SoftDelete(new VipLevelRule - { - Id = vipRule.Id, - RuleSerialNumber = vipRule.RuleSerialNumber, - IsDelete = vipRule.IsDelete, - DataChgUsr = vipRule.DataChgUsr, - }); + var dbVipRule = vipRuleRepository.GetFirst(a => a.RuleSerialNumber == vipRule.RuleSerialNumber && a.IsDelete != 1); + dbVipRule.IsDelete = vipRule.IsDelete; + vipRuleRepository.SoftDelete(dbVipRule); } catch (Exception ex) { @@ -172,16 +168,10 @@ namespace EOM.TSHotelManagement.Application { try { - vipRuleRepository.Update(new VipLevelRule - { - Id = vipRule.Id, - RuleSerialNumber = vipRule.RuleSerialNumber, - RuleName = vipRule.RuleName, - RuleValue = vipRule.RuleValue, - IsDelete = vipRule.IsDelete, - DataChgUsr = vipRule.DataChgUsr, - DataChgDate = vipRule.DataChgDate - }); + var dbVipRule = vipRuleRepository.GetFirst(a => a.RuleSerialNumber == vipRule.RuleSerialNumber && a.IsDelete != 1); + dbVipRule.RuleName = vipRule.RuleName; + dbVipRule.RuleValue = vipRule.RuleValue; + vipRuleRepository.Update(dbVipRule); } catch (Exception ex) { diff --git a/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseDto.cs b/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseDto.cs index b937dca..6a9c066 100644 --- a/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseDto.cs @@ -2,7 +2,7 @@ { public class BaseDto { - public int Id { get; set; } + public int Id { get; set; } = 0; /// /// Token /// diff --git a/EOM.TSHotelManagement.Common.Contract/Business/Sellthing/Dto/CreateSellThingInputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/Sellthing/Dto/CreateSellThingInputDto.cs index 5e08c59..7dbcbc7 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/Sellthing/Dto/CreateSellThingInputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/Sellthing/Dto/CreateSellThingInputDto.cs @@ -6,7 +6,7 @@ namespace EOM.TSHotelManagement.Common.Contract public string ProductName { get; set; } public decimal ProductPrice { get; set; } public string Specification { get; set; } - public decimal Stock { get; set; } + public int Stock { get; set; } } } diff --git a/EOM.TSHotelManagement.Common.Contract/Business/Sellthing/Dto/ReadSellThingOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/Sellthing/Dto/ReadSellThingOutputDto.cs index 2863127..78bd59c 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/Sellthing/Dto/ReadSellThingOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/Sellthing/Dto/ReadSellThingOutputDto.cs @@ -13,8 +13,8 @@ namespace EOM.TSHotelManagement.Common.Contract public decimal ProductPrice { get; set; } [UIDisplay("ͺ")] public string Specification { get; set; } - [UIDisplay("")] - public decimal Stock { get; set; } + [UIDisplay("",true,true)] + public int Stock { get; set; } } } diff --git a/EOM.TSHotelManagement.Common.Contract/Business/Sellthing/Dto/UpdateSellThingInputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/Sellthing/Dto/UpdateSellThingInputDto.cs index 35ec42a..e9c6ce8 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/Sellthing/Dto/UpdateSellThingInputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/Sellthing/Dto/UpdateSellThingInputDto.cs @@ -6,7 +6,7 @@ namespace EOM.TSHotelManagement.Common.Contract public string ProductName { get; set; } public decimal ProductPrice { get; set; } public string Specification { get; set; } - public decimal Stock { get; set; } + public int Stock { get; set; } } } diff --git a/EOM.TSHotelManagement.Common.Contract/Util/Dto/OperationLog/CreateOperationLogInputDto.cs b/EOM.TSHotelManagement.Common.Contract/Util/Dto/OperationLog/CreateOperationLogInputDto.cs index 7ec26aa..03becf9 100644 --- a/EOM.TSHotelManagement.Common.Contract/Util/Dto/OperationLog/CreateOperationLogInputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Util/Dto/OperationLog/CreateOperationLogInputDto.cs @@ -4,6 +4,7 @@ namespace EOM.TSHotelManagement.Common.Contract { public class CreateOperationLogInputDto : BaseInputDto { + public string OperationId { get; set; } public DateTime OperationTime { get; set; } public string LogContent { get; set; } public string OperationAccount { get; set; } diff --git a/EOM.TSHotelManagement.Common.Core/Business/Sellthing/SellThing.cs b/EOM.TSHotelManagement.Common.Core/Business/Sellthing/SellThing.cs index d212278..e407204 100644 --- a/EOM.TSHotelManagement.Common.Core/Business/Sellthing/SellThing.cs +++ b/EOM.TSHotelManagement.Common.Core/Business/Sellthing/SellThing.cs @@ -102,7 +102,7 @@ namespace EOM.TSHotelManagement.Common.Core DecimalDigits = 0, DefaultValue = "0" )] - public decimal Stock { get; set; } + public int Stock { get; set; } } } diff --git a/EOM.TSHotelManagement.Common.Core/Util/OperationLog.cs b/EOM.TSHotelManagement.Common.Core/Util/OperationLog.cs index ba84ed7..33a9ba1 100644 --- a/EOM.TSHotelManagement.Common.Core/Util/OperationLog.cs +++ b/EOM.TSHotelManagement.Common.Core/Util/OperationLog.cs @@ -141,82 +141,5 @@ namespace EOM.TSHotelManagement.Common.Core /// [SugarColumn(IsIgnore = true)] public string LogLevelName { get; set; } - - /// - /// 请求路径 (Request Path) - /// - [SugarColumn( - ColumnName = "request_path", - ColumnDescription = "请求路径 (Request Path)", - IsNullable = false, - Length = 500 - )] - public string RequestPath { get; set; } - - /// - /// 查询字符串 (Query String) - /// - [SugarColumn( - ColumnName = "query_string", - ColumnDescription = "查询参数 (Query String)", - IsNullable = true, - Length = 2000 - )] - public string QueryString { get; set; } - - /// - /// 响应时间 (Elapsed Time) - /// - [SugarColumn( - ColumnName = "elapsed_time", - ColumnDescription = "响应时间(毫秒) (Elapsed Time in ms)", - IsNullable = false, - DefaultValue = "0" - )] - public long ElapsedTime { get; set; } - - /// - /// 请求方法 (Http Method) - /// - [SugarColumn( - ColumnName = "http_method", - ColumnDescription = "HTTP请求方法 (HTTP Method)", - IsNullable = false, - Length = 10 - )] - public string HttpMethod { get; set; } - - /// - /// 状态码 (Status Code) - /// - [SugarColumn( - ColumnName = "status_code", - ColumnDescription = "HTTP状态码 (HTTP Status Code)", - IsNullable = false, - DefaultValue = "200" - )] - public int StatusCode { get; set; } - - /// - /// 异常消息 (Exception Message) - /// - [SugarColumn( - ColumnName = "exception_message", - ColumnDescription = "异常消息内容 (Exception Message)", - IsNullable = true, - Length = 2000 - )] - public string ExceptionMessage { get; set; } - - /// - /// 异常堆栈 (Exception Stack Trace) - /// - [SugarColumn( - ColumnName = "exception_stacktrace", - ColumnDescription = "异常堆栈信息 (Exception Stack Trace)", - IsNullable = true, - Length = 4000 - )] - public string ExceptionStackTrace { get; set; } } } diff --git a/EOM.TSHotelManagement.EntityFramework/Repository/GenericRepository.cs b/EOM.TSHotelManagement.EntityFramework/Repository/GenericRepository.cs index 5323170..3fb2db8 100644 --- a/EOM.TSHotelManagement.EntityFramework/Repository/GenericRepository.cs +++ b/EOM.TSHotelManagement.EntityFramework/Repository/GenericRepository.cs @@ -8,7 +8,6 @@ namespace EOM.TSHotelManagement.EntityFramework { public class GenericRepository : SimpleClient where T : class, new() { - /// /// HTTP上下文访问器 /// diff --git a/EOM.TSHotelManagement.Migration/EntityBuilder.cs b/EOM.TSHotelManagement.Migration/EntityBuilder.cs index 65be0a2..80713ad 100644 --- a/EOM.TSHotelManagement.Migration/EntityBuilder.cs +++ b/EOM.TSHotelManagement.Migration/EntityBuilder.cs @@ -476,6 +476,17 @@ namespace EOM.TSHotelManagement.Migration DataInsUsr = "System", DataInsDate = DateTime.Now, }, + new Menu // 38 + { + Key = "requestlog", + Title = "请求日志", + Path = "/requestlog", + Parent = 29, + Icon = "SolutionOutlined", + IsDelete = 0, + DataInsUsr = "System", + DataInsDate = DateTime.Now, + }, new NavBar { NavigationBarName = "客房管理", diff --git a/EOM.TSHotelManagement.Shared/Helper/DiscountHelper.cs b/EOM.TSHotelManagement.Shared/Helper/DiscountHelper.cs index 1e171f7..0ac1084 100644 --- a/EOM.TSHotelManagement.Shared/Helper/DiscountHelper.cs +++ b/EOM.TSHotelManagement.Shared/Helper/DiscountHelper.cs @@ -57,26 +57,5 @@ 9 => "九", _ => throw new ArgumentOutOfRangeException(nameof(num), "仅支持0-9数字转换") }; - - public static decimal RealAmount(decimal discountPercent, decimal itemAmount) - { - decimal discountedAmount; - - if (discountPercent == 0) - { - discountedAmount = 0; - } - else if (discountPercent == 100) - { - discountedAmount = itemAmount; - } - else - { - decimal discountRate = discountPercent / 100M; - discountedAmount = itemAmount * discountRate; - } - - return discountedAmount; - } } } diff --git a/EOM.TSHotelManagement.WebApi/Controllers/Business/Reser/ReserController.cs b/EOM.TSHotelManagement.WebApi/Controllers/Business/Reser/ReserController.cs index 85c0894..a284922 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/Business/Reser/ReserController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/Business/Reser/ReserController.cs @@ -76,5 +76,16 @@ namespace EOM.TSHotelManagement.WebApi.Controllers { return reserService.InserReserInfo(r); } + + /// + /// 查询所有预约类型 + /// + /// + [HttpGet] + public ListOutputDto SelectReserTypeAll() + { + return reserService.SelectReserTypeAll(); + } + } } diff --git a/EOM.TSHotelManagement.WebApi/Controllers/Business/Sellthing/SellthingController.cs b/EOM.TSHotelManagement.WebApi/Controllers/Business/Sellthing/SellthingController.cs index 2965edf..3e2ee06 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/Business/Sellthing/SellthingController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/Business/Sellthing/SellthingController.cs @@ -44,9 +44,9 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseResponse UpdateSellthingInfo([FromBody] UpdateSellThingInputDto sellThing) + public BaseResponse UpdateSellthing([FromBody] UpdateSellThingInputDto sellThing) { - return sellService.UpdateSellthingInfo(sellThing); + return sellService.UpdateSellthing(sellThing); } /// diff --git a/EOM.TSHotelManagement.WebApi/Startup.cs b/EOM.TSHotelManagement.WebApi/Startup.cs index 3fcf99c..7dea910 100644 --- a/EOM.TSHotelManagement.WebApi/Startup.cs +++ b/EOM.TSHotelManagement.WebApi/Startup.cs @@ -126,6 +126,7 @@ namespace EOM.TSHotelManagement.WebApi { options.Conventions.Add(new AuthorizeAllControllersConvention()); options.RespectBrowserAcceptHeader = true; + options.SuppressImplicitRequiredAttributeForNonNullableReferenceTypes = true; }).AddJsonOptions(options => { options.JsonSerializerOptions.PropertyNamingPolicy = null; -- Gitee