using LifePayment.Application.Contracts; using LifePayment.Domain.LifePay; using LifePayment.Domain.Models; using LifePayment.Domain.Shared; using LifePayment.Domain; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Volo.Abp.Application.Services; using Volo.Abp.Domain.Repositories; using Microsoft.EntityFrameworkCore; using ZeroD.Util; namespace LifePayment.Application.LifePay { public class LifePayOrderService : ApplicationService, ILifePayOrderService { private readonly IRepository _lifePayRechargeReceiptsRepository; public LifePayOrderService( IRepository lifePayRechargeReceiptsRepository) { _lifePayRechargeReceiptsRepository = lifePayRechargeReceiptsRepository; } /// /// 获取充值流水 /// /// /// public async Task> GetLifePayRechargeReceiptsPage(LifePayRechargeReceiptsPageInput input) { var list = await _lifePayRechargeReceiptsRepository.Where(x => x.IsDeleted == false) .WhereIf(input.OrderNo.IsNotNullOrEmpty(), x => x.OrderNo.Contains(input.OrderNo)) .WhereIf(input.CreationTimeBegin.HasValue, x => x.CreationTime >= input.CreationTimeBegin) .WhereIf(input.CreationTimeEnd.HasValue, x => x.CreationTime <= input.CreationTimeEnd) .Select(x => new LifePayRechargeReceiptsListOutput() { Id = x.Id, OrderNo = x.OrderNo, RechargeAmount = x.RechargeAmount, Remark = x.Remark, Voucher = x.Voucher, }) .GetPageResult(input.PageModel); return list; } //public async Task GetTotalLifePayRechargeReceipts() //{ //} /// /// 编辑充值流水 /// /// /// public async Task AddUpdatePayRechargeReceipts(AddUpdatePayRechargeReceiptsInput input) { CheckExtensions.IfTrueThrowUserFriendlyException(input.OrderNo == null, "请输入业务订单号"); CheckExtensions.IfTrueThrowUserFriendlyException(input.RechargeAmount <= 0, "充值金额应大于0"); CheckExtensions.IfTrueThrowUserFriendlyException(input.Voucher == null, "请提交充值凭证"); if (input.Id.HasValue) { var payRechargeReceipts = await _lifePayRechargeReceiptsRepository.Where(x => x.IsDeleted == false && x.Id == input.Id.Value).FirstOrDefaultAsync(); payRechargeReceipts.OrderNo = input.OrderNo; payRechargeReceipts.RechargeAmount = input.RechargeAmount; payRechargeReceipts.Remark = input.Remark; payRechargeReceipts.Voucher = input.Voucher; } else { LifePayRechargeReceipts payRechargeReceipts = new LifePayRechargeReceipts() { Id = Guid.NewGuid(), OrderNo = input.OrderNo, RechargeAmount = input.RechargeAmount, Remark = input.Remark, Voucher = input.Voucher, }; await _lifePayRechargeReceiptsRepository.InsertAsync(payRechargeReceipts); } } } }