| | |
| | | using ZeroD.Util; |
| | | using LifePayment.Domain; |
| | | using static LifePayment.Domain.Shared.LifePaymentConstant; |
| | | using Newtonsoft.Json; |
| | | |
| | | namespace LifePayment.Application.LifePay |
| | | { |
| | |
| | | } |
| | | |
| | | |
| | | //public async Task<LifePayExpensesReceiptsPageOutput<LifePayExpensesReceiptsListOutput>> GetLifePayExpensesReceiptsPage(LifePayExpensesReceiptsPageInput input) |
| | | //{ |
| | | // var list = await _lifePayExpensesReceiptsRepository.Where(x => x.IsDeleted == false) |
| | | // .WhereIf(input.KeyWord.IsNotNullOrEmpty(), x => x.OrderNo.Contains(input.KeyWord)) |
| | | // .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.GetOssPath(), |
| | | // CreationTime = x.CreationTime, |
| | | // }) |
| | | // .GetPageResult(input.PageModel); |
| | | public async Task<LifePayExpensesReceiptsPageOutput<LifePayExpensesReceiptsListOutput>> GetLifePayExpensesReceiptsPage(LifePayExpensesReceiptsPageInput input) |
| | | { |
| | | var list = await _lifePayExpensesReceiptsRepository.Where(x => x.IsDeleted == false) |
| | | .WhereIf(input.KeyWord.IsNotNullOrEmpty(), x => x.OrderNo.Contains(input.KeyWord)) |
| | | .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.GetOssPath(), |
| | | CreationTime = x.CreationTime, |
| | | }) |
| | | .GetPageResult(input.PageModel); |
| | | |
| | | // var total = await _lifePayRechargeReceiptsRepository.Where(x => x.IsDeleted == false).SumAsync(x => x.RechargeAmount); |
| | | // LifePayRechargeReceiptsPageOutput<LifePayRechargeReceiptsListOutput> result = new LifePayRechargeReceiptsPageOutput<LifePayRechargeReceiptsListOutput>(); |
| | | // result.Data = list.Data; |
| | | // result.TotalRechargeAmount = total; |
| | | // return result; |
| | | //} |
| | | var total = await _lifePayRechargeReceiptsRepository.Where(x => x.IsDeleted == false).SumAsync(x => x.RechargeAmount); |
| | | LifePayRechargeReceiptsPageOutput<LifePayRechargeReceiptsListOutput> result = new LifePayRechargeReceiptsPageOutput<LifePayRechargeReceiptsListOutput>(); |
| | | result.Data = list.Data; |
| | | result.TotalRechargeAmount = total; |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 插入收支流水 |
| | |
| | | OutOrderNo = input.OutOrderNo, |
| | | LifePayType = input.LifePayType, |
| | | ExpensesReceiptsType = input.ExpensesReceiptsType, |
| | | Amount = input.Amount |
| | | Amount = input.Amount, |
| | | }; |
| | | |
| | | switch (input.LifePayType) |
| | |
| | | var query = await _aliPayApi.OrderInQuiry(new OrderInQuiryInput() { OutTradeNo = input.OrderNo }); |
| | | if (query.Code == AlipayResultCode.Success && query.TradeStatus == AlipayStatus.TRADESUCCESS) |
| | | { |
| | | data.ExtraProperties = JsonConvert.SerializeObject(query); |
| | | data.FinishTime = Convert.ToDateTime(query.SendPayDate); |
| | | await _lifePayExpensesReceiptsRepository.InsertAsync(data); |
| | | } |
| | | } |
| | |
| | | var query = await _aliPayApi.QueryAlipayTradeRefund(new OrderInQuiryInput() { OutTradeNo = input.OrderNo }); |
| | | if (query.Code == AlipayResultCode.Success && query.RefundStatus == AlipayRefundStatus.Success) |
| | | { |
| | | data.ExtraProperties = JsonConvert.SerializeObject(query); |
| | | //data.FinishTime = Convert.ToDateTime(query.SendPayDate); |
| | | await _lifePayExpensesReceiptsRepository.InsertAsync(data); |
| | | } |
| | | } |
| | |
| | | var query = await _wxPayApi.WxPayTradeQuery(input.OrderNo); |
| | | if (query.Code == AlipayResultCode.Success && query.Status == WxPayStatus.支付成功) |
| | | { |
| | | data.ExtraProperties = JsonConvert.SerializeObject(query); |
| | | data.FinishTime = Convert.ToDateTime(query.SuccessTime); |
| | | await _lifePayExpensesReceiptsRepository.InsertAsync(data); |
| | | } |
| | | } |
| | |
| | | var query = await _wxPayApi.WxPayDomesticRefundsQuery(input.OrderNo); |
| | | if (query.Code == AlipayResultCode.Success && query.RefundStatus == WxPayRefundStatus.退款成功) |
| | | { |
| | | data.ExtraProperties = JsonConvert.SerializeObject(query); |
| | | data.FinishTime = Convert.ToDateTime(query.SuccessTime); |
| | | await _lifePayExpensesReceiptsRepository.InsertAsync(data); |
| | | } |
| | | } |
| | | break; |
| | | default: break; |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | } |