7 changed files with 170 additions and 31 deletions
-
5src/Shentun.Peis.Application.Contracts/CardTypes/CreateCardTypeDto.cs
-
5src/Shentun.Peis.Application.Contracts/CardTypes/UpdateCardTypeDto.cs
-
24src/Shentun.Peis.Application/CardTypes/CardTypeAppService.cs
-
37src/Shentun.Peis.Application/PayModes/PayModeAppService.cs
-
2src/Shentun.Peis.Domain/CardTypes/CardType.cs
-
74src/Shentun.Peis.Domain/CardTypes/CardTypeManager.cs
-
54src/Shentun.Peis.Domain/PayModes/PayModeManager.cs
@ -0,0 +1,74 @@ |
|||||
|
using Shentun.Peis.Models; |
||||
|
using Shentun.Utilities; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using TencentCloud.Sqlserver.V20180328.Models; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Domain.Repositories; |
||||
|
using Volo.Abp.Domain.Services; |
||||
|
|
||||
|
namespace Shentun.Peis.CardTypes |
||||
|
{ |
||||
|
public class CardTypeManager : DomainService |
||||
|
{ |
||||
|
|
||||
|
private readonly IRepository<CardType, Guid> _repository; |
||||
|
|
||||
|
public CardTypeManager(IRepository<CardType, Guid> Repository) |
||||
|
{ |
||||
|
_repository = Repository; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 创建
|
||||
|
/// </summary>
|
||||
|
/// <param name="entity"></param>
|
||||
|
/// <returns></returns>
|
||||
|
public async Task<CardType> CreateAsync( |
||||
|
CardType entity |
||||
|
) |
||||
|
{ |
||||
|
Check.NotNullOrWhiteSpace(entity.DisplayName, nameof(entity.DisplayName)); |
||||
|
await EntityHelper.CheckSameName<CardType, Guid>(_repository, entity.DisplayName); |
||||
|
return new CardType |
||||
|
{ |
||||
|
DisplayName = entity.DisplayName, |
||||
|
DisplayOrder = await EntityHelper.CreateMaxDisplayOrder<CardType>(_repository), |
||||
|
CardModeId = entity.CardModeId, |
||||
|
Discount = entity.Discount, |
||||
|
ExpiryDay = entity.ExpiryDay, |
||||
|
Remark = entity.Remark |
||||
|
}; |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 更新
|
||||
|
/// </summary>
|
||||
|
/// <param name="sourceEntity"></param>
|
||||
|
/// <param name="targetEntity"></param>
|
||||
|
/// <returns></returns>
|
||||
|
public async Task UpdateAsync( |
||||
|
CardType sourceEntity, |
||||
|
CardType targetEntity |
||||
|
) |
||||
|
{ |
||||
|
Check.NotNullOrWhiteSpace(sourceEntity.DisplayName, nameof(sourceEntity.DisplayName)); |
||||
|
if (sourceEntity.DisplayName != targetEntity.DisplayName) |
||||
|
{ |
||||
|
await EntityHelper.CheckSameName<CardType, Guid>(_repository, sourceEntity.DisplayName, targetEntity); |
||||
|
targetEntity.DisplayName = sourceEntity.DisplayName; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
targetEntity.CardModeId = sourceEntity.CardModeId; |
||||
|
targetEntity.Discount = sourceEntity.Discount; |
||||
|
targetEntity.ExpiryDay = sourceEntity.ExpiryDay; |
||||
|
targetEntity.Remark = sourceEntity.Remark; |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,54 @@ |
|||||
|
using AutoMapper.Internal.Mappers; |
||||
|
using Shentun.Peis.Models; |
||||
|
using Shentun.Utilities; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Domain.Repositories; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Domain.Services; |
||||
|
|
||||
|
namespace Shentun.Peis.PayModes |
||||
|
{ |
||||
|
public class PayModeManager : DomainService |
||||
|
{ |
||||
|
|
||||
|
private readonly IRepository<PayMode> _repository; |
||||
|
|
||||
|
public PayModeManager(IRepository<PayMode> repository) |
||||
|
{ |
||||
|
_repository = repository; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 更新
|
||||
|
/// </summary>
|
||||
|
/// <param name="sourceEntity"></param>
|
||||
|
/// <param name="targetEntity"></param>
|
||||
|
/// <returns></returns>
|
||||
|
public async void UpdateAsync( |
||||
|
PayMode sourceEntity, |
||||
|
PayMode targetEntity |
||||
|
) |
||||
|
{ |
||||
|
Check.NotNullOrWhiteSpace(sourceEntity.DisplayName, nameof(sourceEntity.DisplayName)); |
||||
|
|
||||
|
PayMode existEntity = await _repository.FindAsync(o => o.Id != targetEntity.Id && o.DisplayName == sourceEntity.DisplayName); |
||||
|
if (existEntity != null) |
||||
|
{ |
||||
|
throw new UserFriendlyException($"名称:'{sourceEntity.DisplayName}'已存在"); |
||||
|
} |
||||
|
|
||||
|
if (sourceEntity.DisplayName != targetEntity.DisplayName) |
||||
|
{ |
||||
|
targetEntity.DisplayName = sourceEntity.DisplayName; |
||||
|
targetEntity.SimpleCode = LanguageConverter.GetPYSimpleCode(sourceEntity.DisplayName); |
||||
|
} |
||||
|
|
||||
|
targetEntity.IsActive = sourceEntity.IsActive; |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue