diff --git a/EOM.TSHotelManagement.Application/Business/Cash/CashService.cs b/EOM.TSHotelManagement.Application/Business/Asset/AssetService.cs
similarity index 39%
rename from EOM.TSHotelManagement.Application/Business/Cash/CashService.cs
rename to EOM.TSHotelManagement.Application/Business/Asset/AssetService.cs
index d039526a6caa06fa713641c5c1ed5ffcd0692109..c039351590f8a6025f005dd6dac20139c8a37d93 100644
--- a/EOM.TSHotelManagement.Application/Business/Cash/CashService.cs
+++ b/EOM.TSHotelManagement.Application/Business/Asset/AssetService.cs
@@ -21,114 +21,138 @@
*SOFTWARE.
*
*/
+using EOM.TSHotelManagement.Common.Contract;
using EOM.TSHotelManagement.Common.Core;
+using EOM.TSHotelManagement.Common.Util;
using EOM.TSHotelManagement.EntityFramework;
+using SqlSugar;
namespace EOM.TSHotelManagement.Application
{
///
/// 资产信息接口实现类
///
- public class CashService : ICashService
+ public class AssetService : IAssetService
{
///
/// 资产信息
///
- private readonly GenericRepository cashRepository;
+ private readonly GenericRepository assetRepository;
///
/// 部门
///
- private readonly GenericRepository deptRepository;
+ private readonly GenericRepository deptRepository;
///
/// 员工
///
- private readonly GenericRepository workerRepository;
+ private readonly GenericRepository employeeRepository;
///
///
///
- ///
+ ///
///
- ///
- public CashService(GenericRepository cashRepository, GenericRepository deptRepository, GenericRepository workerRepository)
+ ///
+ public AssetService(GenericRepository assetRepository, GenericRepository deptRepository, GenericRepository employeeRepository)
{
- this.cashRepository = cashRepository;
+ this.assetRepository = assetRepository;
this.deptRepository = deptRepository;
- this.workerRepository = workerRepository;
+ this.employeeRepository = employeeRepository;
}
///
/// 添加资产信息
///
- ///
+ ///
///
- public bool AddCashInfo(Cash cash)
+ public BaseOutputDto AddAssetInfo(CreateAssetInputDto asset)
{
- return cashRepository.Insert(cash);
+ try
+ {
+ var result = assetRepository.Insert(EntityMapper.Map(asset));
+ }
+ catch (Exception ex)
+ {
+ return new BaseOutputDto() { Message = LocalizationHelper.GetLocalizedString(ex.Message,ex.Message),StatusCode = StatusCodeConstants.InternalServerError };
+ }
+ return new BaseOutputDto();
}
///
/// 查询资产信息
///
///
- public List SelectCashInfoAll()
+ public ListOutputDto SelectAssetInfoAll(ReadAssetInputDto asset)
{
//查询所有部门信息
- List depts = new List();
+ List depts = new List();
depts = deptRepository.GetList(a => a.IsDelete != 1);
//查询所有员工信息
- List workers = new List();
- workers = workerRepository.GetList(a => a.IsDelete != 1);
- List cs = new List();
- cs = cashRepository.GetList(a => a.IsDelete != 1);
- cs.ForEach(source =>
+ List employees = new List();
+ employees = employeeRepository.GetList(a => a.IsDelete != 1);
+
+ ListOutputDto cs = new ListOutputDto();
+
+ var where = Expressionable.Create();
+
+ int totalCount = 0;
+ if (asset.Page != 0 && asset.PageSize != 0)
{
- var dept = depts.FirstOrDefault(a => a.dept_no.Equals(source.CashClub));
- source.DeptName = dept == null ? "" : dept.dept_name;
- var worker = workers.FirstOrDefault(a => a.WorkerId.Equals(source.CashPerson));
- source.PersonName = worker == null ? "" : worker.WorkerName;
+ cs.listSource = EntityMapper.MapList(assetRepository.AsQueryable().Where(where.ToExpression()).OrderBy(a => a.AssetNumber)
+ .ToPageList((int)asset.Page, (int)asset.PageSize, ref totalCount));
+ cs.total = totalCount;
+ }
- source.CashPriceStr = source.CashPrice == 0 ? "" : Decimal.Parse(source.CashPrice.ToString()).ToString("#,##0.00").ToString();
+ cs.listSource.ForEach(source =>
+ {
+ var dept = depts.FirstOrDefault(a => a.DepartmentNumber.Equals(source.DepartmentCode));
+ source.DepartmentName = dept == null ? "" : dept.DepartmentName;
+ var worker = employees.FirstOrDefault(a => a.EmployeeId.Equals(source.AcquiredByEmployeeId));
+ source.AcquiredByEmployeeName = worker == null ? "" : worker.EmployeeName;
+
+ source.AssetValueFormatted = source.AssetValue == 0 ? "" : Decimal.Parse(source.AssetValue.ToString()).ToString("#,##0.00").ToString();
});
+
return cs;
}
///
/// 更新资产信息
///
- ///
+ ///
///
- public bool UpdCashInfo(Cash cash)
+ public BaseOutputDto UpdAssetInfo(UpdateAssetInputDto asset)
{
- return cashRepository.Update(a => new Cash()
+ try
{
- CashName = cash.CashName,
- CashClub = cash.CashClub,
- CashSource = cash.CashSource,
- CashPrice = cash.CashPrice,
- CashTime = cash.CashTime,
- CashPerson = cash.CashPerson,
- IsDelete = cash.IsDelete,
- DataChgUsr = cash.DataChgUsr,
- DataChgDate = cash.DataChgDate
- }, a => a.CashNo == cash.CashNo);
+ assetRepository.Update(EntityMapper.Map(asset));
+ }
+ catch (Exception ex)
+ {
+ return new BaseOutputDto() { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError };
+ }
+ return new BaseOutputDto();
}
///
/// 删除资产信息
///
- ///
+ ///
///
- public bool DelCashInfo(Cash cash)
+ public BaseOutputDto DelAssetInfo(DeleteAssetInputDto asset)
{
- return cashRepository.Update(a => new Cash()
+ try
+ {
+ assetRepository.Update(EntityMapper.Map(asset));
+ }
+ catch (Exception ex)
{
- IsDelete = 1,
- DataChgUsr = cash.DataChgUsr
- }, a => a.CashNo == cash.CashNo);
+ return new BaseOutputDto() { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError };
+ }
+ return new BaseOutputDto();
}
}
}
diff --git a/EOM.TSHotelManagement.Application/Business/Cash/ICashService.cs b/EOM.TSHotelManagement.Application/Business/Asset/IAssetService.cs
similarity index 83%
rename from EOM.TSHotelManagement.Application/Business/Cash/ICashService.cs
rename to EOM.TSHotelManagement.Application/Business/Asset/IAssetService.cs
index 8774b9fe34ca20e5edcf044e6ad277e1b4174fea..bb66f3e87fc67e40022010665f11d11d0b79854d 100644
--- a/EOM.TSHotelManagement.Application/Business/Cash/ICashService.cs
+++ b/EOM.TSHotelManagement.Application/Business/Asset/IAssetService.cs
@@ -21,6 +21,7 @@
*SOFTWARE.
*
*/
+using EOM.TSHotelManagement.Common.Contract;
using EOM.TSHotelManagement.Common.Core;
namespace EOM.TSHotelManagement.Application
@@ -28,33 +29,33 @@ namespace EOM.TSHotelManagement.Application
///
/// 资产信息接口
///
- public interface ICashService
+ public interface IAssetService
{
///
/// 添加资产信息
///
///
///
- bool AddCashInfo(Cash cash);
+ BaseOutputDto AddAssetInfo(CreateAssetInputDto cash);
///
/// 查询资产信息
///
///
- List SelectCashInfoAll();
+ ListOutputDto SelectAssetInfoAll(ReadAssetInputDto asset);
///
/// 更新资产信息
///
///
///
- bool UpdCashInfo(Cash cash);
+ BaseOutputDto UpdAssetInfo(UpdateAssetInputDto cash);
///
/// 删除资产信息
///
///
///
- bool DelCashInfo(Cash cash);
+ BaseOutputDto DelAssetInfo(DeleteAssetInputDto cash);
}
}
\ No newline at end of file
diff --git a/EOM.TSHotelManagement.Application/Business/Customer/CustoService.cs b/EOM.TSHotelManagement.Application/Business/Customer/CustomerService.cs
similarity index 30%
rename from EOM.TSHotelManagement.Application/Business/Customer/CustoService.cs
rename to EOM.TSHotelManagement.Application/Business/Customer/CustomerService.cs
index 7a80320d456b15c4699b5454c691ee44e2941858..ec12ff0883d0bbf8c1766bb576a60598628555be 100644
--- a/EOM.TSHotelManagement.Application/Business/Customer/CustoService.cs
+++ b/EOM.TSHotelManagement.Application/Business/Customer/CustomerService.cs
@@ -30,45 +30,37 @@ using System.ComponentModel;
using EOM.TSHotelManagement.Common;
using Microsoft.AspNetCore.DataProtection;
using jvncorelib.EncryptorLib;
-using NPOI.SS.Formula.Functions;
+using EOM.TSHotelManagement.Common.Contract;
+using EOM.TSHotelManagement.Common.Util;
+using System.Linq;
namespace EOM.TSHotelManagement.Application
{
///
/// 客户信息接口实现类
///
- public class CustoService : ICustoService
+ public class CustomerService : ICustomerService
{
///
/// 客户信息
///
- private readonly GenericRepository custoRepository;
+ private readonly GenericRepository custoRepository;
///
/// 消费情况
///
private readonly GenericRepository spendRepository;
- ///
- /// 性别类型
- ///
- private readonly GenericRepository sexTypeRepository;
-
///
/// 证件类型
///
- private readonly GenericRepository passPortTypeRepository;
+ private readonly GenericRepository passPortTypeRepository;
///
/// 客户类型
///
private readonly GenericRepository custoTypeRepository;
- ///
- /// 加密
- ///
- private readonly jvncorelib.EncryptorLib.EncryptLib encrypt;
-
///
/// 数据保护
///
@@ -79,62 +71,71 @@ namespace EOM.TSHotelManagement.Application
///
///
///
- ///
///
///
///
///
- public CustoService(GenericRepository custoRepository, GenericRepository spendRepository, GenericRepository sexTypeRepository, GenericRepository passPortTypeRepository, GenericRepository custoTypeRepository, EncryptLib encrypt, IDataProtectionProvider dataProtectionProvider)
+ public CustomerService(GenericRepository custoRepository, GenericRepository spendRepository, GenericRepository passPortTypeRepository, GenericRepository custoTypeRepository, IDataProtectionProvider dataProtectionProvider)
{
this.custoRepository = custoRepository;
this.spendRepository = spendRepository;
- this.sexTypeRepository = sexTypeRepository;
this.passPortTypeRepository = passPortTypeRepository;
this.custoTypeRepository = custoTypeRepository;
- this.encrypt = encrypt;
this.dataProtector = dataProtectionProvider.CreateProtector("CustomerInfoProtector");
}
- #region 添加客户信息
///
/// 添加客户信息
///
///
- ///
- public bool InsertCustomerInfo(Custo custo)
+ public BaseOutputDto InsertCustomerInfo(CreateCustomerInputDto custo)
{
- string NewID = dataProtector.Protect(custo.CustoID);
- string NewTel = dataProtector.Protect(custo.CustoTel);
- custo.CustoID = NewID;
- custo.CustoTel = NewTel;
- return custoRepository.Insert(custo);
+ string NewID = dataProtector.Protect(custo.IdCardNumber);
+ string NewTel = dataProtector.Protect(custo.CustomerPhoneNumber);
+ custo.IdCardNumber = NewID;
+ custo.CustomerPhoneNumber = NewTel;
+ try
+ {
+ var result = custoRepository.Insert(EntityMapper.Map(custo));
+ }
+ catch (Exception ex)
+ {
+ LogHelper.LogError(LocalizationHelper.GetLocalizedString("Insert Customer Failed", "客户信息添加失败"), ex);
+ return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Insert Customer Failed", "客户信息添加失败"));
+ }
+
+ return new BaseOutputDto(StatusCodeConstants.Success, LocalizationHelper.GetLocalizedString("Insert Customer Success", "客户信息添加成功"));
}
- #endregion
///
/// 更新客户信息
///
///
///
- public bool UpdCustomerInfo(Custo custo)
+ public BaseOutputDto UpdCustomerInfo(UpdateCustomerInputDto custo)
{
- string NewID = dataProtector.Protect(custo.CustoID);
- string NewTel = dataProtector.Protect(custo.CustoTel);
- custo.CustoID = NewID;
- custo.CustoTel = NewTel;
- return custoRepository.Update(a => new Custo()
+ string NewID = dataProtector.Protect(custo.IdCardNumber);
+ string NewTel = dataProtector.Protect(custo.CustomerPhoneNumber);
+ custo.IdCardNumber = NewID;
+ custo.CustomerPhoneNumber = NewTel;
+ try
{
- CustoName = custo.CustoName,
- CustoSex = custo.CustoSex,
- CustoType = custo.CustoType,
- CustoBirth = custo.CustoBirth,
- CustoAddress = custo.CustoAddress,
- CustoID = custo.CustoID,
- CustoTel = custo.CustoTel,
- PassportType = custo.PassportType,
- DataChgUsr = custo.DataChgUsr,
- DataChgDate = custo.DataChgDate
- }, a => a.CustoNo == custo.CustoNo);
+ var result = custoRepository.Update(EntityMapper.Map(custo));
+
+ if (result)
+ {
+ return new BaseOutputDto(StatusCodeConstants.Success, LocalizationHelper.GetLocalizedString("Update Customer Success", "客户信息更新成功"));
+ }
+ else
+ {
+ return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Update Customer Failed", "客户信息更新失败"));
+ }
+ }
+ catch (Exception ex)
+ {
+ LogHelper.LogError(LocalizationHelper.GetLocalizedString("Update Customer Failed", "客户信息更新失败"), ex);
+ return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Update Customer Failed", "客户信息更新失败"));
+ }
}
///
@@ -142,58 +143,80 @@ namespace EOM.TSHotelManagement.Application
///
///
///
- public bool DelCustomerInfo(Custo custo)
+ public BaseOutputDto DelCustomerInfo(DeleteCustomerInputDto custo)
{
- var occupied = Convert.ToInt32(RoomStateConstant.Occupied.Code);
- var isOccupied = custoRepository.Change().IsAny(a => a.CustoNo == custo.CustoNo && a.RoomStateId == occupied);
- var haveUnSettle = custoRepository.Change().IsAny(a => a.CustoNo == custo.CustoNo && a.MoneyState == SpendConsts.UnSettle);
+ var occupied = Convert.ToInt32(RoomState.Occupied);
+ var isOccupied = custoRepository.Change().IsAny(a => a.CustomerNumber == custo.CustomerNumber && a.RoomStateId == occupied);
+ var haveUnSettle = custoRepository.Change().IsAny(a => a.CustomerNumber == custo.CustomerNumber && a.SettlementStatus == SpendConsts.UnSettle);
if (isOccupied)
- return false;
+ return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Customer is currently occupying a room", "客户当前正在占用房间"));
if (haveUnSettle)
- return false;
+ return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Customer has unsettled bills", "客户有未结算的账单"));
- return custoRepository.Update(a => new Custo()
+ var result = custoRepository.Update(a => new Customer()
{
IsDelete = custo.IsDelete,
DataChgUsr = custo.DataChgUsr,
DataChgDate = custo.DataChgDate
- }, a => a.CustoNo == custo.CustoNo);
+ }, a => a.CustomerNumber == custo.CustomerNumber);
+
+ if (result)
+ {
+ return new BaseOutputDto(StatusCodeConstants.Success, LocalizationHelper.GetLocalizedString("Delete Customer Success", "客户信息删除成功"));
+ }
+ else
+ {
+ return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Customer Failed", "客户信息删除失败"));
+ }
}
///
/// 更新客户类型(即会员等级)
///
- ///
- ///
+ ///
///
- public bool UpdCustomerTypeByCustoNo(string custoNo, int userType)
+ public BaseOutputDto UpdCustomerTypeByCustoNo(UpdateCustomerInputDto updateCustomerInputDto)
{
- return custoRepository.Update(a => new Custo()
+ try
+ {
+ var result = custoRepository.Update(EntityMapper.Map(updateCustomerInputDto));
+
+ if (result)
+ {
+ return new BaseOutputDto(StatusCodeConstants.Success, LocalizationHelper.GetLocalizedString("Update Customer Type Success", "客户类型更新成功"));
+ }
+ else
+ {
+ return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Update Customer Type Failed", "客户类型更新失败"));
+ }
+ }
+ catch (Exception ex)
{
- CustoType = userType
- }, a => a.CustoNo.Equals(custoNo));
+ LogHelper.LogError(LocalizationHelper.GetLocalizedString("Update Customer Type Failed", "客户类型更新失败"), ex);
+ return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Update Customer Type Failed", "客户类型更新失败"));
+ }
}
///
- /// 查询酒店盈利情况
+ /// 查询酒店盈利情况(用于报表)
///
///
public List SelectAllMoney()
{
List custoSpends = new List();
- var listSource = spendRepository.GetList(a => a.MoneyState.Equals(SpendConsts.Settled)).OrderBy(a => a.SpendTime).ToList();
+ var listSource = spendRepository.GetList(a => a.SettlementStatus.Equals(SpendConsts.Settled)).OrderBy(a => a.ConsumptionTime).ToList();
var listDates = new List();
listSource.ForEach(source =>
{
- var year = Convert.ToDateTime(source.SpendTime).ToString("yyyy");
+ var year = Convert.ToDateTime(source.ConsumptionTime).ToString("yyyy");
if (!custoSpends.Select(a => a.Years).ToList().Contains(year))
{
- var startDate = new DateTime(Convert.ToDateTime(source.SpendTime).Year, 1, 1, 0, 0, 0);
- var endDate = new DateTime(Convert.ToDateTime(source.SpendTime).Year, 12, 31, 23, 59, 59);
+ var startDate = new DateTime(Convert.ToDateTime(source.ConsumptionTime).Year, 1, 1, 0, 0, 0);
+ var endDate = new DateTime(Convert.ToDateTime(source.ConsumptionTime).Year, 12, 31, 23, 59, 59);
custoSpends.Add(new CustoSpend
{
Years = year,
- Money = listSource.Where(a => a.SpendTime >= startDate && a.SpendTime <= endDate).Sum(a => a.SpendMoney)
+ Money = listSource.Where(a => a.ConsumptionTime >= startDate && a.ConsumptionTime <= endDate).Sum(a => a.ConsumptionAmount)
});
}
});
@@ -206,200 +229,253 @@ namespace EOM.TSHotelManagement.Application
/// 查询所有客户信息
///
///
- public OSelectAllDto SelectCustoAll(int? pageIndex, int? pageSize, bool onlyVip = false)
+ public ListOutputDto SelectCustomers(ReadCustomerInputDto readCustomerInputDto)
{
- OSelectAllDto oSelectCustoAllDto = new OSelectAllDto();
+ ListOutputDto oSelectCustoAllDto = new ListOutputDto();
//查询出所有性别类型
- List sexTypes = new List();
- sexTypes = sexTypeRepository.GetList();
+ var helper = new EnumHelper();
+ var genders = Enum.GetValues(typeof(GenderType))
+ .Cast()
+ .Select(e => new EnumDto
+ {
+ Id = (int)e,
+ Name = e.ToString(),
+ Description = helper.GetEnumDescription(e)
+ })
+ .ToList();
//查询出所有证件类型
- List passPortTypes = new List();
+ List passPortTypes = new List();
passPortTypes = passPortTypeRepository.GetList();
//查询出所有客户类型
List custoTypes = new List();
custoTypes = custoTypeRepository.GetList();
//查询出所有客户信息
- List custos = new List();
+ List custos = new List();
- var count = 0;
+ var where = Expressionable.Create();
- if (pageIndex != 0 && pageSize != 0)
- {
- custos = custoRepository.AsQueryable().ToPageList((int)pageIndex, (int)pageSize, ref count);
- if (onlyVip)
- {
- custos = custoRepository.AsQueryable().Where(a => a.CustoType != 0).ToPageList((int)pageIndex, (int)pageSize, ref count);
- }
- }
- else
- {
- custos = custoRepository.AsQueryable().ToList();
- }
+ where = where.And(a => a.IsDelete == readCustomerInputDto.IsDelete);
- custos.ForEach(source =>
+ if (!readCustomerInputDto.CustomerNumber.IsNullOrEmpty())
{
- try
- {
- //解密身份证号码
- var sourceStr = source.CustoID.Contains('·') ? encrypt.Decryption(source.CustoID) : dataProtector.Unprotect(source.CustoID);
- source.CustoID = sourceStr;
- //解密联系方式
- var sourceTelStr = source.CustoTel.Contains('·') ? encrypt.Decryption(source.CustoTel) : dataProtector.Unprotect(source.CustoTel);
- source.CustoTel = sourceTelStr;
- }
- catch (Exception)
- {
- source.CustoID = source.CustoID;
- source.CustoTel = source.CustoTel;
- }
- //性别类型
- var sexType = sexTypes.FirstOrDefault(a => a.sexId == source.CustoSex);
- source.SexName = sexType.sexName.IsNullOrEmpty() ? "" : sexType.sexName;
- //证件类型
- var passPortType = passPortTypes.FirstOrDefault(a => a.PassportId == source.PassportType);
- source.PassportName = passPortType.PassportName.IsNullOrEmpty() ? "" : passPortType.PassportName;
- //客户类型
- var custoType = custoTypes.FirstOrDefault(a => a.UserType == source.CustoType);
- source.typeName = custoType.TypeName.IsNullOrEmpty() ? "" : custoType.TypeName;
- });
-
- oSelectCustoAllDto.listSource = custos;
- oSelectCustoAllDto.total = count;
-
- return oSelectCustoAllDto;
- }
-
- ///
- /// 查询指定客户信息
- ///
- ///
- public OSelectAllDto SelectCustomers(Custo custo)
- {
- var customers = new OSelectAllDto();
-
- var where = Expressionable.Create();
-
- //查询出所有性别类型
- List sexTypes = new List();
- sexTypes = sexTypeRepository.GetList();
- //查询出所有证件类型
- List passPortTypes = new List();
- passPortTypes = passPortTypeRepository.GetList();
- //查询出所有客户类型
- List custoTypes = new List();
- custoTypes = custoTypeRepository.GetList();
- //查询出所有客户信息
- List custos = new List();
-
- if (!custo.CustoNo.IsNullOrEmpty())
- {
- where = where.And(a => a.CustoNo.Equals(custo.CustoNo));
+ where = where.And(a => a.CustomerNumber.Equals(readCustomerInputDto.CustomerNumber));
}
- if (!custo.CustoName.IsNullOrEmpty())
+ if (!readCustomerInputDto.CustomerName.IsNullOrEmpty())
{
- where = where.And(a => a.CustoName.Contains(custo.CustoName));
+ where = where.And(a => a.CustomerName.Contains(readCustomerInputDto.CustomerName));
}
- if (!custo.CustoTel.IsNullOrEmpty())
+ if (!readCustomerInputDto.CustomerPhoneNumber.IsNullOrEmpty())
{
- where = where.And(a => a.CustoTel.Contains(custo.CustoTel));
+ where = where.And(a => a.CustomerPhoneNumber.Contains(readCustomerInputDto.CustomerPhoneNumber));
}
- if (!custo.CustoAddress.IsNullOrEmpty())
+ if (!readCustomerInputDto.IdCardNumber.IsNullOrEmpty())
{
- where = where.And(a => a.CustoAddress.Contains(custo.CustoAddress));
+ where = where.And(a => a.IdCardNumber.Contains(readCustomerInputDto.IdCardNumber));
}
- if (!custo.CustoID.IsNullOrEmpty())
+
+ var count = 0;
+
+ if (!readCustomerInputDto.IgnorePaging && readCustomerInputDto.Page != 0 && readCustomerInputDto.PageSize != 0)
{
- where = where.And(a => a.CustoID.Contains(custo.CustoID));
+ custos = custoRepository.AsQueryable().Where(where.ToExpression()).OrderBy(a => a.CustomerNumber)
+ .ToPageList((int)readCustomerInputDto.Page, (int)readCustomerInputDto.PageSize, ref count);
}
- if (!custo.IsDelete.IsNullOrEmpty())
+ else
{
- where = where.And(a => a.IsDelete == custo.IsDelete);
+ custos = custoRepository.AsQueryable().Where(where.ToExpression()).OrderBy(a => a.CustomerNumber).ToList();
}
- int totalCount = 0;
- if (custo.Page != 0 && custo.PageSize != 0)
- {
- customers.listSource = custoRepository.AsQueryable().Where(where.ToExpression()).OrderBy(a => a.CustoNo)
- .ToPageList((int)custo.Page, (int)custo.PageSize, ref totalCount);
- customers.total = totalCount;
- }
+ var customerOutputDtos = EntityMapper.MapList(custos);
- customers.listSource.ForEach(source =>
+ customerOutputDtos.ForEach(source =>
{
try
{
//解密身份证号码
- var sourceStr = source.CustoID.Contains('·') ? encrypt.Decryption(source.CustoID) : dataProtector.Unprotect(source.CustoID);
- source.CustoID = sourceStr;
+ var sourceStr = dataProtector.Unprotect(source.IdCardNumber);
+ source.IdCardNumber = sourceStr;
//解密联系方式
- var sourceTelStr = source.CustoTel.Contains('·') ? encrypt.Decryption(source.CustoTel) : dataProtector.Unprotect(source.CustoTel);
- source.CustoTel = sourceTelStr;
+ var sourceTelStr = dataProtector.Unprotect(source.CustomerPhoneNumber);
+ source.CustomerPhoneNumber = sourceTelStr;
}
catch (Exception)
{
- source.CustoID = source.CustoID;
- source.CustoTel = source.CustoTel;
+ source.IdCardNumber = source.IdCardNumber;
+ source.CustomerPhoneNumber = source.CustomerPhoneNumber;
}
+
//性别类型
- var sexType = sexTypes.FirstOrDefault(a => a.sexId == source.CustoSex);
- source.SexName = sexType.sexName.IsNullOrEmpty() ? "" : sexType.sexName;
+ var sexType = genders.FirstOrDefault(a => a.Id == source.CustomerGender);
+ source.GenderName = sexType?.Description ?? "";
+
//证件类型
- var passPortType = passPortTypes.FirstOrDefault(a => a.PassportId == source.PassportType);
- source.PassportName = passPortType.PassportName.IsNullOrEmpty() ? "" : passPortType.PassportName;
+ var passPortType = passPortTypes.FirstOrDefault(a => a.PassportId == source.PassportId);
+ source.PassportName = passPortType?.PassportName ?? "";
+
//客户类型
- var custoType = custoTypes.FirstOrDefault(a => a.UserType == source.CustoType);
- source.typeName = custoType.TypeName.IsNullOrEmpty() ? "" : custoType.TypeName;
+ var custoType = custoTypes.FirstOrDefault(a => a.CustomerType == source.CustomerType);
+ source.CustomerTypeName = custoType?.CustomerTypeName ?? "";
});
- return customers;
+ oSelectCustoAllDto.listSource = customerOutputDtos;
+ oSelectCustoAllDto.total = count;
+ return oSelectCustoAllDto;
}
///
/// 查询指定客户信息
///
///
- public List SelectCustoByInfo(Custo custo)
+ //public ListOutputDto SelectCustomers(Customer custo)
+ //{
+ // var customers = new ListOutputDto();
+
+ // var where = Expressionable.Create();
+
+ // //查询出所有性别类型
+ // List sexTypes = new List();
+ // sexTypes = sexTypeRepository.GetList();
+ // //查询出所有证件类型
+ // List passPortTypes = new List();
+ // passPortTypes = passPortTypeRepository.GetList();
+ // //查询出所有客户类型
+ // List custoTypes = new List();
+ // custoTypes = custoTypeRepository.GetList();
+ // //查询出所有客户信息
+ // List custos = new List();
+
+ // if (!custo.CustomerNumber.IsNullOrEmpty())
+ // {
+ // where = where.And(a => a.CustomerNumber.Equals(custo.CustomerNumber));
+ // }
+ // if (!custo.CustomerName.IsNullOrEmpty())
+ // {
+ // where = where.And(a => a.CustomerName.Contains(custo.CustomerName));
+ // }
+ // if (!custo.CustomerPhoneNumber.IsNullOrEmpty())
+ // {
+ // where = where.And(a => a.CustomerPhoneNumber.Contains(custo.CustomerPhoneNumber));
+ // }
+ // if (!custo.CustomerAddress.IsNullOrEmpty())
+ // {
+ // where = where.And(a => a.CustomerAddress.Contains(custo.CustomerAddress));
+ // }
+ // if (!custo.PassportID.IsNullOrEmpty())
+ // {
+ // where = where.And(a => a.PassportID.Contains(custo.PassportID));
+ // }
+ // if (!custo.IsDelete.IsNullOrEmpty())
+ // {
+ // where = where.And(a => a.IsDelete == custo.IsDelete);
+ // }
+
+ // int totalCount = 0;
+ // if (custo.Page != 0 && custo.PageSize != 0)
+ // {
+ // customers.listSource = custoRepository.AsQueryable().Where(where.ToExpression()).OrderBy(a => a.CustomerNumber)
+ // .ToPageList((int)custo.Page, (int)custo.PageSize, ref totalCount);
+ // customers.total = totalCount;
+ // }
+
+ // customers.listSource.ForEach(source =>
+ // {
+ // try
+ // {
+ // //解密身份证号码
+ // var sourceStr = source.PassportID.Contains('·') ? encrypt.Decryption(source.PassportID) : dataProtector.Unprotect(source.PassportID);
+ // source.PassportID = sourceStr;
+ // //解密联系方式
+ // var sourceTelStr = source.CustomerPhoneNumber.Contains('·') ? encrypt.Decryption(source.CustomerPhoneNumber) : dataProtector.Unprotect(source.CustomerPhoneNumber);
+ // source.CustomerPhoneNumber = sourceTelStr;
+ // }
+ // catch (Exception)
+ // {
+ // source.PassportID = source.PassportID;
+ // source.CustomerPhoneNumber = source.CustomerPhoneNumber;
+ // }
+ // //性别类型
+ // var sexType = sexTypes.FirstOrDefault(a => a.GenderId == source.CustomerGender);
+ // source.GenderName = sexType.GenderName.IsNullOrEmpty() ? "" : sexType.GenderName;
+ // //证件类型
+ // var passPortType = passPortTypes.FirstOrDefault(a => a.PassportId == source.PassportType);
+ // source.PassportTypeName = passPortType.PassportName.IsNullOrEmpty() ? "" : passPortType.PassportName;
+ // //客户类型
+ // var custoType = custoTypes.FirstOrDefault(a => a.CustomerType == source.CustomerType);
+ // source.CustomerTypeName = custoType.CustomerTypeName.IsNullOrEmpty() ? "" : custoType.CustomerTypeName;
+ // });
+
+ // return customers;
+
+ //}
+
+ ///
+ /// 查询指定客户信息
+ ///
+ ///
+ public SingleOutputDto SelectCustoByInfo(ReadCustomerInputDto custo)
{
//查询出所有性别类型
- List sexTypes = new List();
- sexTypes = sexTypeRepository.GetList();
+ var helper = new EnumHelper();
+ var genders = Enum.GetValues(typeof(GenderType))
+ .Cast()
+ .Select(e => new EnumDto
+ {
+ Id = (int)e,
+ Name = e.ToString(),
+ Description = helper.GetEnumDescription(e)
+ })
+ .ToList();
//查询出所有证件类型
- List passPortTypes = new List();
+ List passPortTypes = new List();
passPortTypes = passPortTypeRepository.GetList();
//查询出所有客户类型
List custoTypes = new List();
custoTypes = custoTypeRepository.GetList();
//查询出所有客户信息
- List custos = new List();
- if (!custo.CustoNo.IsNullOrEmpty())
+ SingleOutputDto singleOutputDto = new SingleOutputDto();
+
+ var where = Expressionable.Create();
+
+ if (!custo.CustomerNumber.IsNullOrEmpty())
{
- custos = custoRepository.GetList(a => a.CustoNo.Contains(custo.CustoNo)).OrderBy(a => a.CustoNo).ToList();
+ where = where.And(a => a.CustomerNumber.Contains(custo.CustomerNumber));
}
- if (!custo.CustoName.IsNullOrEmpty())
+ if (!custo.CustomerName.IsNullOrEmpty())
{
- custos = custoRepository.GetList(a => a.CustoName.Contains(custo.CustoName)).OrderBy(a => a.CustoNo).ToList();
+ where = where.And(a => a.CustomerName.Contains(custo.CustomerName));
}
- custos.ForEach(source =>
+
+ var customer = custoRepository.AsQueryable().Where(where.ToExpression()).Single();
+
+ try
{
//解密身份证号码
- var sourceStr = source.CustoID.Contains("·") ? encrypt.Decryption(source.CustoID) : source.CustoID;
- source.CustoID = sourceStr;
+ var sourceStr = dataProtector.Unprotect(customer.IdCardNumber);
+ customer.IdCardNumber = sourceStr;
//解密联系方式
- var sourceTelStr = source.CustoTel.Contains("·") ? encrypt.Decryption(source.CustoTel) : source.CustoTel;
- source.CustoTel = sourceTelStr;
- //性别类型
- var sexType = sexTypes.FirstOrDefault(a => a.sexId == source.CustoSex);
- source.SexName = sexType.sexName.IsNullOrEmpty() ? "" : sexType.sexName;
- //证件类型
- var passPortType = passPortTypes.FirstOrDefault(a => a.PassportId == source.PassportType);
- source.PassportName = passPortType.PassportName.IsNullOrEmpty() ? "" : passPortType.PassportName;
- //客户类型
- var custoType = custoTypes.FirstOrDefault(a => a.UserType == source.CustoType);
- source.typeName = custoType.TypeName.IsNullOrEmpty() ? "" : custoType.TypeName;
- });
- return custos;
+ var sourceTelStr = dataProtector.Unprotect(customer.CustomerPhoneNumber);
+ customer.CustomerPhoneNumber = sourceTelStr;
+ }
+ catch (Exception)
+ {
+ customer.IdCardNumber = customer.IdCardNumber;
+ customer.CustomerPhoneNumber = customer.CustomerPhoneNumber;
+ }
+ //性别类型
+ var sexType = genders.FirstOrDefault(a => a.Id == customer.CustomerGender);
+ customer.GenderName = sexType.Description.IsNullOrEmpty() ? "" : sexType.Description;
+ //证件类型
+ var passPortType = passPortTypes.FirstOrDefault(a => a.PassportId == customer.PassportId);
+ customer.PassportName = passPortType.PassportName.IsNullOrEmpty() ? "" : passPortType.PassportName;
+ //客户类型
+ var custoType = custoTypes.FirstOrDefault(a => a.CustomerType == customer.CustomerType);
+ customer.CustomerTypeName = custoType.CustomerTypeName.IsNullOrEmpty() ? "" : custoType.CustomerTypeName;
+
+ singleOutputDto.Source = EntityMapper.Map(customer);
+
+ return singleOutputDto;
}
///
@@ -407,30 +483,30 @@ namespace EOM.TSHotelManagement.Application
///
///
///
- public Custo SelectCardInfoByCustoNo(string CustoNo)
- {
- Custo c = custoRepository.GetSingle(a => a.CustoNo.Equals(CustoNo));
- if (c.IsNullOrEmpty())
- {
- return null;
- }
- //性别类型
- var sexType = sexTypeRepository.GetSingle(a => a.sexId == c.CustoSex);
- c.SexName = sexType.sexName.IsNullOrEmpty() ? "" : sexType.sexName;
- //证件类型
- var passPortType = passPortTypeRepository.GetSingle(a => a.PassportId == c.PassportType);
- c.PassportName = passPortType.PassportName.IsNullOrEmpty() ? "" : passPortType.PassportName;
- //客户类型
- var custoType = custoTypeRepository.GetSingle(a => a.UserType == c.CustoType);
- c.typeName = custoType.TypeName.IsNullOrEmpty() ? "" : custoType.TypeName;
- //解密身份证号码
- var sourceStr = c.CustoID.Contains("·") ? encrypt.Decryption(c.CustoID) : c.CustoID;
- c.CustoID = sourceStr;
- //解密联系方式
- var sourceTelStr = c.CustoTel.Contains("·") ? encrypt.Decryption(c.CustoTel) : c.CustoTel;
- c.CustoTel = sourceTelStr;
- return c;
- }
+ //public Customer SelectCardInfoByCustoNo(string CustoNo)
+ //{
+ // Customer c = custoRepository.GetSingle(a => a.CustomerNumber.Equals(CustoNo));
+ // if (c.IsNullOrEmpty())
+ // {
+ // return null;
+ // }
+ // //性别类型
+ // var sexType = sexTypeRepository.GetSingle(a => a.GenderId == c.CustomerGender);
+ // c.GenderName = sexType.GenderName.IsNullOrEmpty() ? "" : sexType.GenderName;
+ // //证件类型
+ // var passPortType = passPortTypeRepository.GetSingle(a => a.PassportId == c.PassportType);
+ // c.PassportTypeName = passPortType.PassportName.IsNullOrEmpty() ? "" : passPortType.PassportName;
+ // //客户类型
+ // var custoType = custoTypeRepository.GetSingle(a => a.CustomerType == c.CustomerType);
+ // c.CustomerTypeName = custoType.CustomerTypeName.IsNullOrEmpty() ? "" : custoType.CustomerTypeName;
+ // //解密身份证号码
+ // var sourceStr = c.PassportID.Contains("·") ? encrypt.Decryption(c.PassportID) : c.PassportID;
+ // c.PassportID = sourceStr;
+ // //解密联系方式
+ // var sourceTelStr = c.CustomerPhoneNumber.Contains("·") ? encrypt.Decryption(c.CustomerPhoneNumber) : c.CustomerPhoneNumber;
+ // c.CustomerPhoneNumber = sourceTelStr;
+ // return c;
+ //}
}
}
diff --git a/EOM.TSHotelManagement.Application/Business/Customer/ICustoService.cs b/EOM.TSHotelManagement.Application/Business/Customer/ICustomerService.cs
similarity index 75%
rename from EOM.TSHotelManagement.Application/Business/Customer/ICustoService.cs
rename to EOM.TSHotelManagement.Application/Business/Customer/ICustomerService.cs
index 2afc7429309e327acde87368795a980d932d3bcd..081e48547edb5188f5845c13b40022a9af2d25f2 100644
--- a/EOM.TSHotelManagement.Application/Business/Customer/ICustoService.cs
+++ b/EOM.TSHotelManagement.Application/Business/Customer/ICustomerService.cs
@@ -21,6 +21,7 @@
*SOFTWARE.
*
*/
+using EOM.TSHotelManagement.Common.Contract;
using EOM.TSHotelManagement.Common.Core;
namespace EOM.TSHotelManagement.Application
@@ -28,39 +29,37 @@ namespace EOM.TSHotelManagement.Application
///
/// 客户信息接口
///
- public interface ICustoService
+ public interface ICustomerService
{
///
/// 添加客户信息
///
///
///
- bool InsertCustomerInfo(Custo custo);
+ BaseOutputDto InsertCustomerInfo(CreateCustomerInputDto custo);
///
/// 更新客户信息
///
///
///
- bool UpdCustomerInfo(Custo custo);
+ BaseOutputDto UpdCustomerInfo(UpdateCustomerInputDto custo);
///
/// 删除客户信息
///
///
///
- bool DelCustomerInfo(Custo custo);
+ BaseOutputDto DelCustomerInfo(DeleteCustomerInputDto custo);
///
/// 更新客户类型(即会员等级)
///
- ///
- ///
///
- bool UpdCustomerTypeByCustoNo(string custoNo, int userType);
+ BaseOutputDto UpdCustomerTypeByCustoNo(UpdateCustomerInputDto updateCustomerInputDto);
///
- /// 查询酒店盈利情况
+ /// 查询酒店盈利情况(用于报表)
///
///
List SelectAllMoney();
@@ -69,26 +68,26 @@ namespace EOM.TSHotelManagement.Application
/// 查询所有客户信息
///
///
- OSelectAllDto SelectCustoAll(int? pageIndex, int? pageSize, bool onlyVip = false);
+ //ListOutputDto SelectCustoAll(int? pageIndex, int? pageSize, bool onlyVip = false);
///
/// 查询所有客户信息
///
///
- OSelectAllDto SelectCustomers(Custo custo);
+ ListOutputDto SelectCustomers(ReadCustomerInputDto custo);
///
/// 查询指定客户信息
///
///
- List SelectCustoByInfo(Custo custo);
+ SingleOutputDto SelectCustoByInfo(ReadCustomerInputDto custo);
///
/// 根据客户编号查询客户信息
///
///
///
- Custo SelectCardInfoByCustoNo(string CustoNo);
+ //SingleOutputDto SelectCardInfoByCustoNo(string CustoNo);
}
}
\ No newline at end of file
diff --git a/EOM.TSHotelManagement.Application/Business/Hydroelectricity/HydroelectricityService.cs b/EOM.TSHotelManagement.Application/Business/EnergyManagement/EnergyManagementService.cs
similarity index 32%
rename from EOM.TSHotelManagement.Application/Business/Hydroelectricity/HydroelectricityService.cs
rename to EOM.TSHotelManagement.Application/Business/EnergyManagement/EnergyManagementService.cs
index 517f3a95f4384c176ab00c083209f38bff0e367a..bb4610c7939b21233fb29083bed7a5a424bfca28 100644
--- a/EOM.TSHotelManagement.Application/Business/Hydroelectricity/HydroelectricityService.cs
+++ b/EOM.TSHotelManagement.Application/Business/EnergyManagement/EnergyManagementService.cs
@@ -21,8 +21,11 @@
*SOFTWARE.
*
*/
+using EOM.TSHotelManagement.Common.Contract;
using EOM.TSHotelManagement.Common.Core;
+using EOM.TSHotelManagement.Common.Util;
using EOM.TSHotelManagement.EntityFramework;
+using jvncorelib.EntityLib;
using SqlSugar;
using System.Linq.Expressions;
@@ -31,106 +34,132 @@ namespace EOM.TSHotelManagement.Application
///
/// 水电信息接口实现类
///
- public class HydroelectricityService : IHydroelectricityService
+ public class EnergyManagementService : IEnergyManagementService
{
///
/// 水电信息
///
- private readonly GenericRepository wtiRepository;
+ private readonly GenericRepository wtiRepository;
///
///
///
///
- public HydroelectricityService(GenericRepository wtiRepository)
+ public EnergyManagementService(GenericRepository wtiRepository)
{
this.wtiRepository = wtiRepository;
}
- #region 查询水电费信息
-
///
/// 根据条件查询水电费信息
///
- /// 房间号(可选)
- /// 使用开始时间(可选)
- /// 使用结束时间(可选)
+ /// Dto
/// 符合条件的水电费信息列表
- public List SelectWtiInfo(string roomNo = null, DateTime? useDate = null, DateTime? endDate = null)
+ public ListOutputDto SelectEnergyManagementInfo(ReadEnergyManagementInputDto readEnergyManagementInputDto)
{
- var repository = wtiRepository;
-
- var where = Expressionable.Create();
+ var where = Expressionable.Create();
- where = where.And(a => a.IsDelete != 1);
+ if (!string.IsNullOrEmpty(readEnergyManagementInputDto.RoomNo))
+ {
+ where = where.And(a => a.RoomNumber.Equals(readEnergyManagementInputDto.RoomNo));
+ }
- if (!string.IsNullOrEmpty(roomNo))
+ if (!readEnergyManagementInputDto.UseDate.IsNullOrEmpty())
{
- where = where.And(a => a.RoomNo.Equals(roomNo));
+ where = where.And(a => a.StartDate >= readEnergyManagementInputDto.UseDate.Value);
}
- if (useDate.HasValue)
+ if (!readEnergyManagementInputDto.EndDate.IsNullOrEmpty())
{
- where = where.And(a => a.UseDate >= useDate.Value);
+ where = where.And(a => a.EndDate >= readEnergyManagementInputDto.EndDate.Value);
}
- if (endDate.HasValue)
+ if (!readEnergyManagementInputDto.IsDelete.IsNullOrEmpty())
{
- where = where.And(a => a.EndDate >= endDate.Value);
+ where = where.And(a => a.IsDelete == readEnergyManagementInputDto.IsDelete);
}
- var listSource = repository.GetList(where.ToExpression());
+ var count = 0;
+
+ var listSource = wtiRepository.AsQueryable()
+ .Where(where.ToExpression()).ToPageList(readEnergyManagementInputDto.Page,readEnergyManagementInputDto.PageSize,ref count);
- return listSource;
+ var readEnergies = EntityMapper.MapList(listSource);
+
+ return new ListOutputDto { listSource = readEnergies, total = count };
}
- #endregion
- #region 添加水电费信息
///
/// 添加水电费信息
///
///
///
- public bool InsertWtiInfo(Hydroelectricity w)
+ public BaseOutputDto InsertEnergyManagementInfo(CreateEnergyManagementInputDto w)
{
- return wtiRepository.Insert(w);
+ try
+ {
+ var result = wtiRepository.Insert(EntityMapper.Map(w));
+ }
+ catch (Exception ex)
+ {
+ LogHelper.LogError(LocalizationHelper.GetLocalizedString("Insert Energy Management Failed", "水电信息添加失败"), ex);
+ return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Insert Energy Management Failed", "水电信息添加失败"));
+ }
+
+ return new BaseOutputDto(StatusCodeConstants.Success, LocalizationHelper.GetLocalizedString("Insert Energy Management Success", "水电信息添加成功"));
}
- #endregion
- #region 修改水电费信息
///
/// 修改水电费信息
///
- /// 包含要修改的数据,以及WtiNo作为查询条件
+ /// 包含要修改的数据,以及EnergyManagementNo作为查询条件
///
- public bool UpdateWtiInfo(Hydroelectricity w)
+ public BaseOutputDto UpdateEnergyManagementInfo(UpdateEnergyManagementInputDto w)
{
- return wtiRepository.Update(a => new Hydroelectricity()
+ try
+ {
+ var result = wtiRepository.Update(EntityMapper.Map(w));
+
+ if (result)
+ {
+ return new BaseOutputDto(StatusCodeConstants.Success, LocalizationHelper.GetLocalizedString("Update Energy Management Success", "水电费信息更新成功"));
+ }
+ else
+ {
+ return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Update Energy Management Failed", "水电费信息更新失败"));
+ }
+ }
+ catch (Exception ex)
{
- UseDate = w.UseDate,
- EndDate = w.EndDate,
- WaterUse = w.WaterUse,
- PowerUse = w.PowerUse,
- Record = w.Record,
- CustoNo = w.CustoNo,
- DataChgUsr = w.DataChgUsr,
- RoomNo = w.RoomNo
- }, a => a.WtiNo == w.WtiNo);
+ LogHelper.LogError(LocalizationHelper.GetLocalizedString("Update Energy Management Failed", "水电费信息更新失败"), ex);
+ return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Update Energy Management Failed", "水电费信息更新失败"));
+ }
}
- #endregion
- #region 根据房间编号、使用时间删除水电费信息
///
/// 根据房间编号、使用时间删除水电费信息
///
///
- public bool DeleteWtiInfo(Hydroelectricity hydroelectricity)
+ public BaseOutputDto DeleteEnergyManagementInfo(DeleteEnergyManagementInputDto hydroelectricity)
{
- return wtiRepository.Update(a => new Hydroelectricity()
+ try
+ {
+ var result = wtiRepository.Update(EntityMapper.Map(hydroelectricity));
+
+ if (result)
+ {
+ return new BaseOutputDto(StatusCodeConstants.Success, LocalizationHelper.GetLocalizedString("Delete Energy Management Success", "水电费信息删除成功"));
+ }
+ else
+ {
+ return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Energy Management Failed", "水电费信息删除失败"));
+ }
+ }
+ catch (Exception ex)
{
- IsDelete = 1
- }, a => a.WtiNo == hydroelectricity.WtiNo);
+ LogHelper.LogError(LocalizationHelper.GetLocalizedString("Delete Energy Management Failed", "水电费信息删除失败"), ex);
+ return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Energy Management Failed", "水电费信息删除失败"));
+ }
}
- #endregion
}
}
diff --git a/EOM.TSHotelManagement.Application/Business/Hydroelectricity/IHydroelectricityService.cs b/EOM.TSHotelManagement.Application/Business/EnergyManagement/IEnergyManagementService.cs
similarity index 77%
rename from EOM.TSHotelManagement.Application/Business/Hydroelectricity/IHydroelectricityService.cs
rename to EOM.TSHotelManagement.Application/Business/EnergyManagement/IEnergyManagementService.cs
index 5f6a89abeb62b924f54626dba7e6e41447625867..ba981f7778c52cd9b1a216e75924cf28c640d985 100644
--- a/EOM.TSHotelManagement.Application/Business/Hydroelectricity/IHydroelectricityService.cs
+++ b/EOM.TSHotelManagement.Application/Business/EnergyManagement/IEnergyManagementService.cs
@@ -21,22 +21,21 @@
*SOFTWARE.
*
*/
+using EOM.TSHotelManagement.Common.Contract;
using EOM.TSHotelManagement.Common.Core;
///
/// 水电信息接口
///
-public interface IHydroelectricityService
+public interface IEnergyManagementService
{
///
/// 根据条件查询水电费信息
/// 替换了 SelectWtiInfoByRoomNo, SelectWtiInfoByRoomNoAndTime, ListWtiInfoByRoomNo, SelectWtiInfoAll
///
- /// 房间号(可选)
- /// 使用开始时间(可选)
- /// 使用结束时间(可选)
+ /// Dto
/// 符合条件的水电费信息列表
- List SelectWtiInfo(string roomNo = null, DateTime? useDate = null, DateTime? endDate = null);
+ ListOutputDto SelectEnergyManagementInfo(ReadEnergyManagementInputDto readEnergyManagementInputDto);
///
/// 添加水电费信息
@@ -44,7 +43,7 @@ public interface IHydroelectricityService
///
///
///
- bool InsertWtiInfo(Hydroelectricity w);
+ BaseOutputDto InsertEnergyManagementInfo(CreateEnergyManagementInputDto w);
///
/// 修改水电费信息
@@ -52,13 +51,13 @@ public interface IHydroelectricityService
///
/// 包含要修改的数据,以及WtiNo作为查询条件
///
- bool UpdateWtiInfo(Hydroelectricity w);
+ BaseOutputDto UpdateEnergyManagementInfo(UpdateEnergyManagementInputDto w);
///
/// 根据房间编号、使用时间删除水电费信息
/// 替换了 DeleteWtiInfoByRoomNoAndDateTime
///
- ///
+ ///
///
- bool DeleteWtiInfo(Hydroelectricity hydroelectricity);
+ BaseOutputDto DeleteEnergyManagementInfo(DeleteEnergyManagementInputDto deleteEnergyManagementInputDto);
}
diff --git a/EOM.TSHotelManagement.Application/Business/Fonts/IFontsService.cs b/EOM.TSHotelManagement.Application/Business/PromotionContent/IPromotionContentService.cs
similarity index 76%
rename from EOM.TSHotelManagement.Application/Business/Fonts/IFontsService.cs
rename to EOM.TSHotelManagement.Application/Business/PromotionContent/IPromotionContentService.cs
index e6a2146eefc77118c1701db7778887fba1c1f6d6..fe52c39a86f1ce18fd0f59ce50d850efd45be7e0 100644
--- a/EOM.TSHotelManagement.Application/Business/Fonts/IFontsService.cs
+++ b/EOM.TSHotelManagement.Application/Business/PromotionContent/IPromotionContentService.cs
@@ -21,6 +21,7 @@
*SOFTWARE.
*
*/
+using EOM.TSHotelManagement.Common.Contract;
using EOM.TSHotelManagement.Common.Core;
namespace EOM.TSHotelManagement.Application
@@ -28,12 +29,18 @@ namespace EOM.TSHotelManagement.Application
///
/// 酒店宣传联动内容接口
///
- public interface IFontsService
+ public interface IPromotionContentService
{
+ ///
+ /// 查询所有宣传联动内容
+ ///
+ ///
+ ListOutputDto SelectPromotionContentAll(ReadPromotionContentInputDto readPromotionContentInputDto);
+
///
/// 查询所有宣传联动内容(跑马灯)
///
///
- List SelectFontAll();
+ ListOutputDto SelectPromotionContents();
}
}
\ No newline at end of file
diff --git a/EOM.TSHotelManagement.Application/Business/Fonts/FontsService.cs b/EOM.TSHotelManagement.Application/Business/PromotionContent/PromotionContentService.cs
similarity index 54%
rename from EOM.TSHotelManagement.Application/Business/Fonts/FontsService.cs
rename to EOM.TSHotelManagement.Application/Business/PromotionContent/PromotionContentService.cs
index e872c9cb7d6367a54fd51e20b60f8707f787d0c4..82d4b402935c6d312c66e9d5369fc09ed16d74ab 100644
--- a/EOM.TSHotelManagement.Application/Business/Fonts/FontsService.cs
+++ b/EOM.TSHotelManagement.Application/Business/PromotionContent/PromotionContentService.cs
@@ -21,7 +21,9 @@
*SOFTWARE.
*
*/
+using EOM.TSHotelManagement.Common.Contract;
using EOM.TSHotelManagement.Common.Core;
+using EOM.TSHotelManagement.Common.Util;
using EOM.TSHotelManagement.EntityFramework;
namespace EOM.TSHotelManagement.Application
@@ -29,30 +31,47 @@ namespace EOM.TSHotelManagement.Application
///
/// 酒店宣传联动内容接口实现类
///
- public class FontsService : IFontsService
+ public class PromotionContentService : IPromotionContentService
{
///
/// 跑马灯
///
- private readonly GenericRepository fontsRepository;
+ private readonly GenericRepository fontsRepository;
///
///
///
///
- public FontsService(GenericRepository fontsRepository)
+ public PromotionContentService(GenericRepository fontsRepository)
{
this.fontsRepository = fontsRepository;
}
+ ///
+ /// 查询所有宣传联动内容
+ ///
+ ///
+ public ListOutputDto SelectPromotionContentAll(ReadPromotionContentInputDto readPromotionContentInputDto)
+ {
+ ListOutputDto fonts = new ListOutputDto();
+ var count = 0;
+
+ var listSource = fontsRepository.AsQueryable().ToPageList(readPromotionContentInputDto.Page, readPromotionContentInputDto.PageSize, ref count);
+
+ fonts.listSource = EntityMapper.MapList(listSource);
+ fonts.total = count;
+ return fonts;
+ }
+
///
/// 查询所有宣传联动内容(跑马灯)
///
///
- public List SelectFontAll()
+ public ListOutputDto SelectPromotionContents()
{
- List fonts = new List();
- fonts = fontsRepository.GetList();
+ ListOutputDto fonts = new ListOutputDto();
+ var listSource = fontsRepository.AsQueryable().ToList();
+ fonts.listSource = EntityMapper.MapList(listSource);
return fonts;
}
}
diff --git a/EOM.TSHotelManagement.Application/Business/Reser/IReserService.cs b/EOM.TSHotelManagement.Application/Business/Reser/IReserService.cs
index 0405446d05ad3d59fedd93dd0a4891e3ab689c4f..636e6134f7e073a539a536bc406751512a501025 100644
--- a/EOM.TSHotelManagement.Application/Business/Reser/IReserService.cs
+++ b/EOM.TSHotelManagement.Application/Business/Reser/IReserService.cs
@@ -21,6 +21,7 @@
*SOFTWARE.
*
*/
+using EOM.TSHotelManagement.Common.Contract;
using EOM.TSHotelManagement.Common.Core;
namespace EOM.TSHotelManagement.Application
@@ -35,28 +36,35 @@ namespace EOM.TSHotelManagement.Application
/// 获取所有预约信息
///
///
- List SelectReserAll();
+ ListOutputDto SelectReserAll(ReadReserInputDto readReserInputDto);
///
/// 根据房间编号获取预约信息
///
- ///
+ ///
///
- Reser SelectReserInfoByRoomNo(string no);
+ SingleOutputDto SelectReserInfoByRoomNo(ReadReserInputDto readReserInputDto);
///
/// 删除预约信息
///
///
///
- bool DeleteReserInfo(Reser reser);
+ BaseOutputDto DeleteReserInfo(DeleteReserInputDto reser);
+
+ ///
+ /// 更新预约信息
+ ///
+ ///
+ ///
+ BaseOutputDto UpdateReserInfo(UpdateReserInputDto reser);
///
/// 添加预约信息
///
///
///
- bool InserReserInfo(Reser r);
+ BaseOutputDto InserReserInfo(CreateReserInputDto r);
}
}
\ 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 3b7be81d682d9820f0f59862c340bcb51379b781..b083496517e201abb6ee0ebcefb6cb7ea8383070 100644
--- a/EOM.TSHotelManagement.Application/Business/Reser/ReserService.cs
+++ b/EOM.TSHotelManagement.Application/Business/Reser/ReserService.cs
@@ -21,9 +21,14 @@
*SOFTWARE.
*
*/
+using EOM.TSHotelManagement.Common.Contract;
using EOM.TSHotelManagement.Common.Core;
+using EOM.TSHotelManagement.Common.Util;
using EOM.TSHotelManagement.EntityFramework;
+using EOM.TSHotelManagement.Shared;
using jvncorelib.EncryptorLib;
+using Microsoft.AspNetCore.DataProtection;
+using SqlSugar;
namespace EOM.TSHotelManagement.Application
{
@@ -38,51 +43,88 @@ namespace EOM.TSHotelManagement.Application
private readonly GenericRepository reserRepository;
///
- /// 加密
+ /// 房间信息
///
- private readonly jvncorelib.EncryptorLib.EncryptLib encrypt;
+ private readonly GenericRepository roomRepository;
+
+ ///
+ /// 数据保护
+ ///
+ private readonly IDataProtector dataProtector;
///
///
///
///
- ///
- public ReserService(GenericRepository reserRepository, jvncorelib.EncryptorLib.EncryptLib encrypt)
+ ///
+ ///
+ public ReserService(GenericRepository reserRepository, GenericRepository roomRepository, IDataProtectionProvider dataProtectionProvider)
{
this.reserRepository = reserRepository;
- this.encrypt = encrypt;
+ this.roomRepository = roomRepository;
+ this.dataProtector = dataProtectionProvider.CreateProtector("ReserInfoProtector");
}
///
/// 获取所有预约信息
///
///
- public List SelectReserAll()
+ public ListOutputDto SelectReserAll(ReadReserInputDto readReserInputDto)
{
- List rss = new List();
- rss = reserRepository.GetList(a => a.IsDelete == 0);
- rss.ForEach(source =>
+ ListOutputDto rss = new ListOutputDto();
+
+ var where = Expressionable.Create();
+
+ where = where.And(a => a.IsDelete == readReserInputDto.IsDelete);
+
+ var count = 0;
+
+ var listSource = new List();
+
+ if (!readReserInputDto.IgnorePaging && readReserInputDto.Page != 0 && readReserInputDto.PageSize != 0)
{
- //解密联系方式
- var sourceTelStr = source.CustoTel.Contains("·") ? encrypt.Decryption(source.CustoTel) : source.CustoTel;
- source.CustoTel = sourceTelStr;
+ listSource = reserRepository.AsQueryable().Where(where.ToExpression()).ToPageList(readReserInputDto.Page, readReserInputDto.PageSize, ref count);
+ }
+ else
+ {
+ listSource = reserRepository.AsQueryable().Where(where.ToExpression()).ToList();
+ }
+
+ listSource.ForEach(source =>
+ {
+ try
+ {
+ //解密联系方式
+ var sourceTelStr = dataProtector.Unprotect(source.ReservationPhoneNumber);
+ source.ReservationPhoneNumber = sourceTelStr;
+ }
+ catch (Exception)
+ {
+ source.ReservationPhoneNumber = source.ReservationPhoneNumber;
+ }
});
+
+ rss.listSource = EntityMapper.MapList(listSource);
+ rss.total = count;
return rss;
}
///
/// 根据房间编号获取预约信息
///
- ///
+ ///
///
- public Reser SelectReserInfoByRoomNo(string no)
+ public SingleOutputDto SelectReserInfoByRoomNo(ReadReserInputDto readReserInputDt)
{
Reser res = null;
- res = reserRepository.GetSingle(a => a.ReserRoom == no && a.IsDelete != 1);
+ res = reserRepository.GetSingle(a => a.ReservationRoomNumber == readReserInputDt.ReservationRoomNumber && a.IsDelete != 1);
//解密联系方式
- var sourceTelStr = res.CustoTel.Contains("·") ? encrypt.Decryption(res.CustoTel) : res.CustoTel;
- res.CustoTel = sourceTelStr;
- return res;
+ var sourceTelStr = dataProtector.Unprotect(res.ReservationPhoneNumber);
+ res.ReservationPhoneNumber = sourceTelStr;
+
+ var outputReser = EntityMapper.Map(res);
+
+ return new SingleOutputDto { Source = outputReser};
}
///
@@ -90,28 +132,87 @@ namespace EOM.TSHotelManagement.Application
///
///
///
- public bool DeleteReserInfo(Reser reser)
+ public BaseOutputDto DeleteReserInfo(DeleteReserInputDto reser)
{
- return reserRepository.Update(a => new Reser()
+ var result = reserRepository.Update(a => new Reser()
{
- IsDelete = 1,
- DataChgUsr = string.Empty
- }, a => a.ReserId == reser.ReserId);
+ IsDelete = reser.IsDelete,
+ DataChgUsr = reser.DataChgUsr,
+ DataChgDate = reser.DataChgDate
+ }, a => a.ReservationId == reser.ReservationId);
+ if (result)
+ {
+ return new BaseOutputDto(StatusCodeConstants.Success, LocalizationHelper.GetLocalizedString("Delete Reser Success", "预约信息删除成功"));
+ }
+ else
+ {
+ return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Reser Failed", "预约信息删除失败"));
+ }
}
///
- /// 添加预约信息
+ /// 更新预约信息
///
- ///
+ ///
///
- public bool InserReserInfo(Reser r)
+ public BaseOutputDto UpdateReserInfo(UpdateReserInputDto reser)
{
- var cryStr = encrypt.Encryption(r.CustoTel, EncryptionLevel.Enhanced);
- r.CustoTel = cryStr;
- return reserRepository.Insert(r);
+ string NewTel = dataProtector.Protect(reser.ReservationPhoneNumber);
+ reser.ReservationPhoneNumber = NewTel;
+ try
+ {
+ var result = reserRepository.Update(EntityMapper.Map(reser));
+
+ if (result)
+ {
+ return new BaseOutputDto(StatusCodeConstants.Success, LocalizationHelper.GetLocalizedString("Update Customer Success", "预约信息更新成功"));
+ }
+ else
+ {
+ return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Update Customer Failed", "预约信息更新失败"));
+ }
+ }
+ catch (Exception ex)
+ {
+ LogHelper.LogError(LocalizationHelper.GetLocalizedString("Update Customer Failed", "预约信息添加失败"), ex);
+ return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Update Customer Failed", "预约信息更新失败"));
+ }
}
+ ///
+ /// 添加预约信息
+ ///
+ ///
+ ///
+ public BaseOutputDto InserReserInfo(CreateReserInputDto r)
+ {
+ string NewTel = dataProtector.Protect(r.ReservationPhoneNumber);
+ r.ReservationPhoneNumber = NewTel;
+ try
+ {
+ var result = reserRepository.Insert(EntityMapper.Map(r));
+ if (result)
+ {
+ roomRepository.Update(a => new Room()
+ {
+ RoomStateId = new EnumHelper().GetEnumValue(RoomState.Reserved),
+ DataChgUsr = r.DataChgUsr,
+ DataChgDate = r.DataChgDate
+ }, a => a.RoomNumber == r.ReservationRoomNumber);
+ return new BaseOutputDto(StatusCodeConstants.Success, LocalizationHelper.GetLocalizedString("Add Customer Success", "预约信息添加成功"));
+ }
+ else
+ {
+ return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Add Customer Failed", "预约信息添加失败"));
+ }
+ }
+ catch (Exception ex)
+ {
+ LogHelper.LogError(LocalizationHelper.GetLocalizedString("Add Customer Failed", "预约信息添加失败"), ex);
+ return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Add Customer Failed", "预约信息添加失败"));
+ }
+ }
}
}
diff --git a/EOM.TSHotelManagement.Application/Business/Room/IRoomService.cs b/EOM.TSHotelManagement.Application/Business/Room/IRoomService.cs
index a326b9cbef6efbee5a1ec5d2446960d9b4b3881f..a0a4c2083781fd055e2aa7a8aa0b3a80c25e54fc 100644
--- a/EOM.TSHotelManagement.Application/Business/Room/IRoomService.cs
+++ b/EOM.TSHotelManagement.Application/Business/Room/IRoomService.cs
@@ -21,6 +21,7 @@
*SOFTWARE.
*
*/
+using EOM.TSHotelManagement.Common.Contract;
using EOM.TSHotelManagement.Common.Core;
namespace EOM.TSHotelManagement.Application
@@ -34,9 +35,9 @@ namespace EOM.TSHotelManagement.Application
///
/// 根据房间状态获取相应状态的房间信息
///
- ///
+ ///
///
- List SelectRoomByRoomState(int stateid);
+ ListOutputDto SelectRoomByRoomState(ReadRoomInputDto readRoomInputDto);
#endregion
#region 根据房间状态来查询可使用的房间
@@ -44,7 +45,7 @@ namespace EOM.TSHotelManagement.Application
/// 根据房间状态来查询可使用的房间
///
///
- List SelectCanUseRoomAll();
+ ListOutputDto SelectCanUseRoomAll();
#endregion
#region 获取所有房间信息
@@ -52,7 +53,7 @@ namespace EOM.TSHotelManagement.Application
/// 获取所有房间信息
///
///
- List SelectRoomAll();
+ ListOutputDto SelectRoomAll(ReadRoomInputDto readRoomInputDto);
#endregion
#region 获取房间分区的信息
@@ -60,34 +61,34 @@ namespace EOM.TSHotelManagement.Application
/// 获取房间分区的信息
///
///
- List SelectRoomByTypeName(string TypeName);
+ ListOutputDto SelectRoomByTypeName(ReadRoomInputDto TypeName);
#endregion
#region 根据房间编号查询房间信息
///
/// 根据房间编号查询房间信息
///
- ///
+ ///
///
- Room SelectRoomByRoomNo(string no);
+ SingleOutputDto SelectRoomByRoomNo(ReadRoomInputDto readRoomInputDto);
#endregion
#region 根据房间编号退房(退房)
///
/// 根据房间编号退房(退房)
///
- ///
+ ///
///
- bool UpdateRoomByRoomNo(string room);
+ BaseOutputDto UpdateRoomByRoomNo(ReadRoomInputDto readRoomInputDto);
#endregion
#region 根据房间编号查询截止到今天住了多少天
///
/// 根据房间编号查询截止到今天住了多少天
///
- ///
+ ///
///
- object DayByRoomNo(string roomno);
+ SingleOutputDto DayByRoomNo(ReadRoomInputDto readRoomInputDto);
#endregion
#region 根据房间编号修改房间信息(入住)
@@ -96,7 +97,7 @@ namespace EOM.TSHotelManagement.Application
///
///
///
- bool UpdateRoomInfo(Room r);
+ BaseOutputDto UpdateRoomInfo(UpdateRoomInputDto r);
#endregion
#region 根据房间编号修改房间信息(预约)
@@ -105,7 +106,7 @@ namespace EOM.TSHotelManagement.Application
///
///
///
- bool UpdateRoomInfoWithReser(Room r);
+ BaseOutputDto UpdateRoomInfoWithReser(UpdateRoomInputDto r);
#endregion
#region 查询可入住房间数量
@@ -113,7 +114,7 @@ namespace EOM.TSHotelManagement.Application
/// 查询可入住房间数量
///
///
- object SelectCanUseRoomAllByRoomState();
+ SingleOutputDto SelectCanUseRoomAllByRoomState();
#endregion
#region 查询已入住房间数量
@@ -121,7 +122,7 @@ namespace EOM.TSHotelManagement.Application
/// 查询已入住房间数量
///
///
- object SelectNotUseRoomAllByRoomState();
+ SingleOutputDto SelectNotUseRoomAllByRoomState();
#endregion
#region 根据房间编号查询房间价格
@@ -129,7 +130,7 @@ namespace EOM.TSHotelManagement.Application
/// 根据房间编号查询房间价格
///
///
- object SelectRoomByRoomPrice(string r);
+ object SelectRoomByRoomPrice(ReadRoomInputDto readRoomInputDto);
#endregion
#region 查询脏房数量
@@ -137,7 +138,7 @@ namespace EOM.TSHotelManagement.Application
/// 查询脏房数量
///
///
- object SelectNotClearRoomAllByRoomState();
+ SingleOutputDto SelectNotClearRoomAllByRoomState();
#endregion
#region 查询维修房数量
@@ -145,7 +146,7 @@ namespace EOM.TSHotelManagement.Application
/// 查询维修房数量
///
///
- object SelectFixingRoomAllByRoomState();
+ SingleOutputDto SelectFixingRoomAllByRoomState();
#endregion
#region 查询预约房数量
@@ -153,17 +154,16 @@ namespace EOM.TSHotelManagement.Application
/// 查询预约房数量
///
///
- object SelectReseredRoomAllByRoomState();
+ SingleOutputDto SelectReservedRoomAllByRoomState();
#endregion
#region 根据房间编号更改房间状态
///
/// 根据房间编号更改房间状态
///
- ///
- ///
+ ///
///
- bool UpdateRoomStateByRoomNo(string roomno, int stateid);
+ BaseOutputDto UpdateRoomStateByRoomNo(ReadRoomInputDto readRoomInputDto);
#endregion
#region 添加房间
@@ -172,7 +172,7 @@ namespace EOM.TSHotelManagement.Application
///
///
///
- bool InsertRoom(Room rn);
+ BaseOutputDto InsertRoom(CreateRoomInputDto rn);
#endregion
#region 更新房间
@@ -181,7 +181,7 @@ namespace EOM.TSHotelManagement.Application
///
///
///
- bool UpdateRoom(Room rn);
+ BaseOutputDto UpdateRoom(UpdateRoomInputDto rn);
#endregion
#region 删除房间
@@ -190,7 +190,7 @@ namespace EOM.TSHotelManagement.Application
///
///
///
- bool DeleteRoom(Room rn);
+ BaseOutputDto DeleteRoom(DeleteRoomInputDto rn);
#endregion
#region 查询所有可消费(已住)房间
@@ -198,24 +198,16 @@ namespace EOM.TSHotelManagement.Application
/// 查询所有可消费(已住)房间
///
///
- List SelectRoomByStateAll();
- #endregion
-
- #region 获取所有房间状态
- ///
- /// 获取所有房间状态
- ///
- ///
- List SelectRoomStateAll();
+ ListOutputDto SelectRoomByStateAll();
#endregion
#region 根据房间编号查询房间状态编号
///
/// 根据房间编号查询房间状态编号
///
- ///
+ ///
///
- object SelectRoomStateIdByRoomNo(string roomno);
+ object SelectRoomStateIdByRoomNo(ReadRoomInputDto readRoomInputDto);
#endregion
}
}
\ No newline at end of file
diff --git a/EOM.TSHotelManagement.Application/Business/Room/IRoomTypeService.cs b/EOM.TSHotelManagement.Application/Business/Room/IRoomTypeService.cs
index 73393b1560746f6ed197c32b80018d8d6e2d5761..173c0c7cb02cfc45cc91a590348a5356019af713 100644
--- a/EOM.TSHotelManagement.Application/Business/Room/IRoomTypeService.cs
+++ b/EOM.TSHotelManagement.Application/Business/Room/IRoomTypeService.cs
@@ -21,6 +21,7 @@
*SOFTWARE.
*
*/
+using EOM.TSHotelManagement.Common.Contract;
using EOM.TSHotelManagement.Common.Core;
namespace EOM.TSHotelManagement.Application
@@ -34,41 +35,41 @@ namespace EOM.TSHotelManagement.Application
/// 获取所有房间类型
///
///
- List SelectRoomTypesAll(int? isDelete);
+ ListOutputDto SelectRoomTypesAll(ReadRoomTypeInputDto readRoomTypeInputDto);
///
/// 根据房间编号查询房间类型名称
///
- ///
+ ///
///
- RoomType SelectRoomTypeByRoomNo(string no);
+ SingleOutputDto SelectRoomTypeByRoomNo(ReadRoomTypeInputDto readRoomTypeInputDto);
///
/// 根据房间类型查询类型配置
///
- ///
+ ///
///
- RoomType SelectRoomTypeByType(int roomTypeId);
+ ReadRoomTypeOutputDto SelectRoomTypeByType(ReadRoomTypeInputDto readRoomTypeInputDto);
///
/// 添加房间状态
///
- ///
+ ///
///
- bool InsertRoomType(RoomType roomType);
+ BaseOutputDto InsertRoomType(CreateRoomTypeInputDto readRoomTypeInputDto);
///
/// 更新房间状态
///
///
///
- bool UpdateRoomType(RoomType roomType);
+ BaseOutputDto UpdateRoomType(UpdateRoomTypeInputDto roomType);
///
/// 删除房间状态
///
///
///
- bool DeleteRoomType(RoomType roomType);
+ BaseOutputDto DeleteRoomType(DeleteRoomTypeInputDto roomType);
}
}
\ No newline at end of file
diff --git a/EOM.TSHotelManagement.Application/Business/Room/RoomService.cs b/EOM.TSHotelManagement.Application/Business/Room/RoomService.cs
index fce77bcdb44060cbb81a5053054e6c82ba42053e..77bfdc77299cc1d760a733b465a07ddb987a160e 100644
--- a/EOM.TSHotelManagement.Application/Business/Room/RoomService.cs
+++ b/EOM.TSHotelManagement.Application/Business/Room/RoomService.cs
@@ -21,9 +21,13 @@
*SOFTWARE.
*
*/
+using EOM.TSHotelManagement.Common.Contract;
using EOM.TSHotelManagement.Common.Core;
+using EOM.TSHotelManagement.Common.Util;
using EOM.TSHotelManagement.EntityFramework;
+using EOM.TSHotelManagement.Shared;
using jvncorelib.EntityLib;
+using SqlSugar;
namespace EOM.TSHotelManagement.Application
{
@@ -37,11 +41,6 @@ namespace EOM.TSHotelManagement.Application
///
private readonly GenericRepository roomRepository;
- ///
- /// 客房状态
- ///
- private readonly GenericRepository roomStateRepository;
-
///
/// 客房类型
///
@@ -50,428 +49,574 @@ namespace EOM.TSHotelManagement.Application
///
/// 客户信息
///
- private readonly GenericRepository custoRepository;
+ private readonly GenericRepository custoRepository;
///
///
///
///
- ///
///
///
- public RoomService(GenericRepository roomRepository, GenericRepository roomStateRepository, GenericRepository roomTypeRepository, GenericRepository custoRepository)
+ public RoomService(GenericRepository roomRepository, GenericRepository roomTypeRepository, GenericRepository custoRepository)
{
this.roomRepository = roomRepository;
- this.roomStateRepository = roomStateRepository;
this.roomTypeRepository = roomTypeRepository;
this.custoRepository = custoRepository;
}
- #region 根据房间状态获取相应状态的房间信息
///
/// 根据房间状态获取相应状态的房间信息
///
- ///
+ ///
///
- public List SelectRoomByRoomState(int stateid)
+ public ListOutputDto SelectRoomByRoomState(ReadRoomInputDto readRoomInputDto)
{
- List roomStates = new List();
- roomStates = roomStateRepository.GetList(a => a.IsDelete != 1);
+ List roomStates = new List();
+ var helper = new EnumHelper();
+ roomStates = Enum.GetValues(typeof(RoomState))
+ .Cast()
+ .Select(e => new EnumDto
+ {
+ Id = (int)e,
+ Name = e.ToString(),
+ Description = helper.GetEnumDescription(e)
+ })
+ .ToList();
List roomTypes = new List();
roomTypes = roomTypeRepository.GetList(a => a.IsDelete != 1);
List rooms = new List();
- rooms = roomRepository.GetList(a => a.IsDelete != 1 && a.RoomStateId == stateid).OrderBy(a => a.RoomNo).ToList();
+ rooms = roomRepository.GetList(a => a.IsDelete != 1 && a.RoomStateId == readRoomInputDto.RoomStateId).OrderBy(a => a.RoomNumber).ToList();
rooms.ForEach(source =>
{
- var roomState = roomStates.FirstOrDefault(a => a.RoomStateId == source.RoomStateId);
- source.RoomState = roomState.RoomStateName.IsNullOrEmpty() ? "" : roomState.RoomStateName;
- var roomType = roomTypes.FirstOrDefault(a => a.Roomtype == source.RoomType);
- source.RoomName = roomType.RoomName.IsNullOrEmpty() ? "" : roomType.RoomName;
+ var roomState = roomStates.FirstOrDefault(a => a.Id == source.RoomStateId);
+ source.RoomState = roomState.Description.IsNullOrEmpty() ? "" : roomState.Description;
+ var roomType = roomTypes.FirstOrDefault(a => a.RoomTypeId == source.RoomTypeId);
+ source.RoomName = roomType.RoomTypeName.IsNullOrEmpty() ? "" : roomType.RoomTypeName;
});
- return rooms;
+
+ var listSource = EntityMapper.MapList(rooms);
+
+ return new ListOutputDto { listSource = listSource };
}
- #endregion
- #region 根据房间状态来查询可使用的房间
///
/// 根据房间状态来查询可使用的房间
///
///
- public List SelectCanUseRoomAll()
+ public ListOutputDto SelectCanUseRoomAll()
{
- List roomStates = new List();
- roomStates = roomStateRepository.GetList();
+ List roomStates = new List();
+ var helper = new EnumHelper();
+ roomStates = Enum.GetValues(typeof(RoomState))
+ .Cast()
+ .Select(e => new EnumDto
+ {
+ Id = (int)e,
+ Name = e.ToString(),
+ Description = helper.GetEnumDescription(e)
+ })
+ .ToList();
List roomTypes = new List();
roomTypes = roomTypeRepository.GetList();
List rooms = new List();
- rooms = roomRepository.GetList(a => a.IsDelete != 1 && a.RoomStateId == 0).OrderBy(a => a.RoomNo).ToList();
+ rooms = roomRepository.GetList(a => a.IsDelete != 1 && a.RoomStateId == 0).OrderBy(a => a.RoomNumber).ToList();
rooms.ForEach(source =>
{
- var roomState = roomStates.FirstOrDefault(a => a.RoomStateId == source.RoomStateId);
- source.RoomState = roomState.RoomStateName.IsNullOrEmpty() ? "" : roomState.RoomStateName;
- var roomType = roomTypes.FirstOrDefault(a => a.Roomtype == source.RoomType);
- source.RoomName = roomType.RoomName.IsNullOrEmpty() ? "" : roomType.RoomName;
+ var roomState = roomStates.FirstOrDefault(a => a.Id == source.RoomStateId);
+ source.RoomState = roomState.Description.IsNullOrEmpty() ? "" : roomState.Description;
+ var roomType = roomTypes.FirstOrDefault(a => a.RoomTypeId == source.RoomTypeId);
+ source.RoomName = roomType.RoomTypeName.IsNullOrEmpty() ? "" : roomType.RoomTypeName;
});
- return rooms;
+
+ var listSource = EntityMapper.MapList(rooms);
+
+ return new ListOutputDto { listSource = listSource };
}
- #endregion
- #region 获取所有房间信息
///
/// 获取所有房间信息
///
///
- public List SelectRoomAll()
+ public ListOutputDto SelectRoomAll(ReadRoomInputDto readRoomInputDto)
{
- List roomStates = new List();
- roomStates = roomStateRepository.GetList();
+ var where = Expressionable.Create();
+
+ where = where.And(a => a.IsDelete == readRoomInputDto.IsDelete);
+
+ if (readRoomInputDto.RoomStateId > 0)
+ {
+ where = where.And(a => a.RoomStateId == readRoomInputDto.RoomStateId);
+ }
+
+ List roomStates = new List();
+ var helper = new EnumHelper();
+ roomStates = Enum.GetValues(typeof(RoomState))
+ .Cast()
+ .Select(e => new EnumDto
+ {
+ Id = (int)e,
+ Name = e.ToString(),
+ Description = helper.GetEnumDescription(e)
+ })
+ .ToList();
List roomTypes = new List();
roomTypes = roomTypeRepository.GetList();
List rooms = new List();
- rooms = roomRepository.GetList(a => a.IsDelete != 1).OrderBy(a => a.RoomNo).ToList();
- var listCustoNo = rooms.Select(a => a.CustoNo).Distinct().ToList();
- List custos = new List