| | |
| | | using ZeroD.Util; |
| | | using ZeroD.Util.Fadd; |
| | | using static LifePayment.Domain.Shared.LifePaymentConstant; |
| | | using static IdentityServer4.Models.IdentityResources; |
| | | using Volo.Abp.Data; |
| | | using Z.EntityFramework.Plus; |
| | | using LifePayment.Domain.LifePay; |
| | | using pingan.openbank.api.sdk.enums; |
| | | |
| | | namespace LifePayment.Application; |
| | | |
| | |
| | | private readonly ILogger<LifePayService> _logger; |
| | | |
| | | private readonly IRepository<LifePayRate, Guid> _lifePayRateRepository; |
| | | private readonly IRepository<LifePayPremium, Guid> _lifePayPremiumRepository; |
| | | private readonly IRepository<LifePayOrder, Guid> _lifePayOrderRepository; |
| | | private readonly IRepository<LifePayUser, Guid> _lifePayUserRepository; |
| | | private readonly IRepository<LifePayIntroInfo, Guid> _lifePayIntroInfoRepository; |
| | | private readonly IRepository<LifePayChannles, Guid> _lifePayChannlesRep; |
| | | private readonly IRepository<LifePayAccount, Guid> _lifePayAccount; |
| | | private readonly IDataFilter dataFilter; |
| | |
| | | IRepository<LifePayRate, Guid> lifePayRateRepository, |
| | | IRepository<LifePayOrder, Guid> lifePayOrderRepository, |
| | | IRepository<LifePayUser, Guid> lifePayUserRepository, |
| | | IRepository<LifePayPremium, Guid> lifePayPremiumRepository, |
| | | IRepository<LifePayIntroInfo, Guid> lifePayIntroInfoRepository, |
| | | IAliPayApi aliPayApi, |
| | | IWxPayApi wxPayApi, |
| | | IOptions<WxPayOption> wxPayOptions, |
| | |
| | | _lifePayRateRepository = lifePayRateRepository; |
| | | _lifePayOrderRepository = lifePayOrderRepository; |
| | | _lifePayUserRepository = lifePayUserRepository; |
| | | _lifePayPremiumRepository = lifePayPremiumRepository; |
| | | _lifePayIntroInfoRepository = lifePayIntroInfoRepository; |
| | | _aliPayApi = aliPayApi; |
| | | _wxPayApi = wxPayApi; |
| | | _wxPayOptions = wxPayOptions.Value; |
| | |
| | | public async Task<List<LifePayRateListOutput>> GetRate() |
| | | { |
| | | return await _lifePayRateRepository.Where(x => x.IsDeleted == false).Select(x => new LifePayRateListOutput() { Id = x.Id, Rate = x.Rate, RateType = x.RateType }) |
| | | .ToListAsync(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取手续费费率 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public async Task<List<LifePayPremiumListOutput>> GetPremium() |
| | | { |
| | | return await _lifePayPremiumRepository.Where(x => x.IsDeleted == false).Select(x => new LifePayPremiumListOutput() { Id = x.Id, Rate = x.Rate, PremiumType = x.PremiumType }) |
| | | .ToListAsync(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 须知配置 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public async Task<List<LifePayIntroInfoOutput>> GetIntroInfo(LifePayOrderTypeEnum lifePayType) |
| | | { |
| | | return await _lifePayIntroInfoRepository.Where(x => x.IsDeleted == false && x.LifePayType == lifePayType).OrderBy(x => x.Sequence) |
| | | .Select(x => new LifePayIntroInfoOutput() { Type = x.Type, ContentSummary = x.ContentSummary, Content = x.Content, LifePayType = x.LifePayType,Path = x.Path,Sequence = x.Sequence }) |
| | | .ToListAsync(); |
| | | } |
| | | |
| | |
| | | CheckExtensions.IfTrueThrowUserFriendlyException(dto.Status == LifePayChannelsStatsEnum.禁用, "当前渠道商已禁用"); |
| | | return true; |
| | | } |
| | | |
| | | public async Task CreateEditLifePayRate(List<LifePayRateInput> input) |
| | | { |
| | | CheckExtensions.IfTrueThrowUserFriendlyException(input.Where(r => r.Rate <= 0).Any(), "折扣不得小于等于0"); |
| | |
| | | { |
| | | await _lifePayRateRepository.InsertManyAsync(listData); |
| | | } |
| | | |
| | | } |
| | | |
| | | public async Task CreateEditLifePayPremium(List<LifePayPremiumInput> input) |
| | | { |
| | | CheckExtensions.IfTrueThrowUserFriendlyException(input.Where(r => r.Rate < 0).Any(), "折扣不得小于0"); |
| | | var listData = new List<LifePayPremium>(); |
| | | foreach (var item in input) |
| | | { |
| | | var tmpDto = await _lifePayPremiumRepository.FirstOrDefaultAsync(r => r.PremiumType == item.PremiumType); |
| | | if (tmpDto != null) |
| | | { |
| | | tmpDto.Rate = item.Rate; |
| | | } |
| | | else |
| | | { |
| | | listData.Add(new LifePayPremium |
| | | { |
| | | CreationTime = DateTime.Now, |
| | | Rate = item.Rate, |
| | | PremiumType = item.PremiumType, |
| | | Id = Guid.NewGuid(), |
| | | }); |
| | | } |
| | | } |
| | | |
| | | if (listData.Any()) |
| | | { |
| | | await _lifePayPremiumRepository.InsertManyAsync(listData); |
| | | } |
| | | } |
| | | |
| | | public async Task EditIntroInfo(LifePayIntroInfoInput input) |
| | | { |
| | | var listData = new List<LifePayIntroInfo>(); |
| | | foreach (var item in input.Data) |
| | | { |
| | | var tmpDto = await _lifePayIntroInfoRepository.Where(r => r.LifePayType == input.LifePayType).DeleteAsync(); |
| | | |
| | | listData.Add(new LifePayIntroInfo |
| | | { |
| | | LifePayType = input.LifePayType, |
| | | CreationTime = DateTime.Now, |
| | | Type = item.Type, |
| | | ContentSummary = item.ContentSummary, |
| | | Content = item.Content, |
| | | Path = item.Path, |
| | | Sequence = item.Sequence, |
| | | Id = Guid.NewGuid(), |
| | | }); |
| | | } |
| | | |
| | | if (listData.Any()) |
| | | { |
| | | await _lifePayIntroInfoRepository.InsertManyAsync(listData); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 私有 |