zhengyuxuan
2025-03-30 65e7b312659c358970262b027901bb55d764f0f9
fix:拉取收支流水
13个文件已修改
262 ■■■■ 已修改文件
LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayOrderService.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayService.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LifePayment/LifePayment.Application/LifePay/LifePayService.cs 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LifePayment/LifePayment.Domain.Shared/LifePaymentConstant.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
LifePayment/LifePayment.Domain.Shared/WeChat/WxPayPostBaseModel.cs 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LifePayment/LifePayment.Domain/WeChat/IWxPayApi.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
LifePayment/LifePayment.Domain/WeChat/WxPayApi.cs 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayOrderService.cs
@@ -14,5 +14,7 @@
    Task AddUpdatePayRechargeReceipts(AddUpdatePayRechargeReceiptsInput input);
    Task<LifePayExpensesReceiptsPageOutput<LifePayExpensesReceiptsListOutput>> GetLifePayExpensesReceiptsPage(LifePayExpensesReceiptsPageInput input);
    Task AddLifePayExpensesReceipts(AddLifePayExpensesReceiptsInput input);
}
LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayService.cs
@@ -298,7 +298,7 @@
    /// </summary>
    /// <param name="outTradeNo"></param>
    /// <returns></returns>
    Task WxPayTradeQuery(string outTradeNo);
    Task<WxPayTradeQueryReponse> WxPayTradeQuery(string outTradeNo);
    /// <summary>
    /// 设置生活缴费支付类型
LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs
@@ -683,12 +683,22 @@
    public string? KeyWord { get; set; }
    /// <summary>
    /// 记账开始时间
    /// 支付渠道
    /// </summary>
    public DateTime? CreationTimeBegin { get; set; }
    public LifePayTypeEnum? LifePayType { get; set; }
    /// <summary>
    /// 记账结束时间
    /// 收支类型
    /// </summary>
    public DateTime? CreationTimeEnd { get; set; }
    public ExpensesReceiptsTypeEnum? ExpensesReceiptsType { get; set; }
    /// <summary>
    /// 交易开始时间
    /// </summary>
    public DateTime? TimeBegin { get; set; }
    /// <summary>
    /// 交易结束时间
    /// </summary>
    public DateTime? TimeEnd { get; set; }
}
LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs
@@ -1182,6 +1182,11 @@
public class LifePayExpensesReceiptsListOutput
{
    /// <summary>
    /// 编号
    /// </summary>
    public Guid Id { get; set; }
    /// <summary>
    /// 平台订单号
    /// </summary>
    public string OrderNo { get; set; }
@@ -1217,7 +1222,17 @@
    public List<T> Data { get; set; } = new List<T>();
    /// <summary>
    /// 累计充值
    /// 累计收入
    /// </summary>
    public decimal TotalRechargeAmount { get; set; }
    public decimal TotalIncome { get; set; }
    /// <summary>
    /// 累计退款
    /// </summary>
    public decimal TotalRefund { get; set; }
    /// <summary>
    /// 实际收入
    /// </summary>
    public decimal RealIncome { get; set; }
}
LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs
@@ -101,28 +101,40 @@
            }
        }
        /// <summary>
        /// 获取收支流水
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        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()
                .WhereIf(input.KeyWord.IsNotNullOrEmpty(), x => x.OrderNo.Contains(input.KeyWord) || x.OutOrderNo.Contains(input.KeyWord))
                .WhereIf(input.LifePayType.HasValue, x => x.LifePayType == input.LifePayType)
                .WhereIf(input.ExpensesReceiptsType.HasValue, x => x.ExpensesReceiptsType == input.ExpensesReceiptsType)
                .WhereIf(input.TimeBegin.HasValue, x => x.FinishTime >= input.TimeBegin)
                .WhereIf(input.TimeEnd.HasValue, x => x.FinishTime <= input.TimeEnd)
                .Select(x => new LifePayExpensesReceiptsListOutput()
                {
                    Id = x.Id,
                    OrderNo = x.OrderNo,
                    //RechargeAmount = x.RechargeAmount,
                    //Remark = x.Remark,
                    //Voucher = x.Voucher.GetOssPath(),
                    CreationTime = x.CreationTime,
                    OutOrderNo = x.OutOrderNo,
                    LifePayType = x.LifePayType,
                    ExpensesReceiptsType = x.ExpensesReceiptsType,
                    Amount = x.Amount,
                    FinishTime = x.FinishTime
                })
                .GetPageResult(input.PageModel);
            var total = await _lifePayRechargeReceiptsRepository.Where(x => x.IsDeleted == false).SumAsync(x => x.RechargeAmount);
            var totalIncome = await _lifePayExpensesReceiptsRepository.Where(x => x.IsDeleted == false && x.ExpensesReceiptsType == ExpensesReceiptsTypeEnum.Expenses).SumAsync(x => x.Amount);
            var totalRefund = await _lifePayExpensesReceiptsRepository.Where(x => x.IsDeleted == false && x.ExpensesReceiptsType == ExpensesReceiptsTypeEnum.Receipts).SumAsync(x => x.Amount);
            LifePayExpensesReceiptsPageOutput<LifePayExpensesReceiptsListOutput> result = new LifePayExpensesReceiptsPageOutput<LifePayExpensesReceiptsListOutput>();
            //result.Data = list.Data;
            result.TotalRechargeAmount = total;
            result.Data = list.Data;
            result.TotalIncome = totalIncome;
            result.TotalRefund = totalRefund;
            result.RealIncome = totalIncome - totalRefund;
            return result;
        }
@@ -153,7 +165,8 @@
                        if (input.ExpensesReceiptsType == ExpensesReceiptsTypeEnum.Expenses)
                        {
                            var query = await _aliPayApi.OrderInQuiry(new OrderInQuiryInput() { OutTradeNo = input.OrderNo });
                            if (query.Code == AlipayResultCode.Success && query.TradeStatus == AlipayStatus.TRADESUCCESS)
                            if (query.Code == AlipayResultCode.Success && (query.TradeStatus == AlipayStatus.TRADESUCCESS
                                || query.TradeStatus == AlipayStatus.TRADECLOSED))
                            {
                                data.ExtraProperties = JsonConvert.SerializeObject(query);
                                data.FinishTime = Convert.ToDateTime(query.SendPayDate);
@@ -175,7 +188,7 @@
                        if (input.ExpensesReceiptsType == ExpensesReceiptsTypeEnum.Expenses)
                        {
                            var query = await _wxPayApi.WxPayTradeQuery(input.OrderNo);
                            if (query.Code == AlipayResultCode.Success && query.Status == WxPayStatus.支付成功)
                            if (query.TradeState == WxPayStatus.支付成功 || query.TradeState == WxPayStatus.转入退款)
                            {
                                data.ExtraProperties = JsonConvert.SerializeObject(query);
                                data.FinishTime = Convert.ToDateTime(query.SuccessTime);
LifePayment/LifePayment.Application/LifePay/LifePayService.cs
@@ -829,6 +829,7 @@
    public async Task<AlipayTradeQueryResponse> QueryAlipayTrade(OrderInQuiryInput input)
    {
        var result = await _aliPayApi.OrderInQuiry(input);
        return result;
    }
@@ -858,9 +859,9 @@
    /// </summary>
    /// <param name="outTradeNo"></param>
    /// <returns></returns>
    public async Task WxPayTradeQuery(string outTradeNo)
    public async Task<WxPayTradeQueryReponse> WxPayTradeQuery(string outTradeNo)
    {
        await _wxPayApi.WxPayTradeQuery(outTradeNo);
        return await _wxPayApi.WxPayTradeQuery(outTradeNo);
    }
    #endregion
LifePayment/LifePayment.Domain.Shared/LifePaymentConstant.cs
@@ -53,7 +53,7 @@
        public const string PayTransactionsH5 = "/v3/pay/transactions/h5";
        public const string WxPayTradeQyery = "/v3/pay/transactions/out-trade-no/{0}";
        public const string WxPayTradeQyery = "/v3/pay/transactions/out-trade-no/{0}?mchid={1}";
        public const string WxPayDomesticRefunds = "/v3/refund/domestic/refunds";
LifePayment/LifePayment.Domain.Shared/WeChat/WxPayPostBaseModel.cs
@@ -882,4 +882,59 @@
        public Model_WxPayDomesticRefunds_Amount Amount { get; set; }
    }
    
    public class WxPayTradeQueryReponse
    {
        /// <summary>
        /// 返回结果
        /// </summary>
        [JsonProperty("code")]
        public string Code { get; set; }
        /// <summary>
        /// 返回信息
        /// </summary>
        [JsonProperty("message")]
        public string Message { get; set; }
        /// <summary>
        /// 商户订单号
        /// </summary>
        [JsonProperty("out_trade_no")]
        public string OutTradeNo { get; set; }
        /// <summary>
        /// 微信支付订单号
        /// </summary>
        [JsonProperty("transaction_id")]
        public string TransactionId { get; set; }
        /// <summary>
        /// 交易类型
        /// </summary>
        [JsonProperty("trade_type")]
        public string TradeType { get; set; }
        /// <summary>
        /// 交易状态
        /// </summary>
        [JsonProperty("trade_state")]
        public string TradeState { get; set; }
        /// <summary>
        /// 交易状态描述
        /// </summary>
        [JsonProperty("trade_state_desc")]
        public string TradeStateDesc { get; set; }
        [JsonProperty("success_time ")]
        public string SuccessTime { get; set; }
        // <summary>
        /// 金额信息
        /// </summary>
        [JsonProperty("amount")]
        public Model_WxPayDomesticRefunds_Amount Amount { get; set; }
    }
}
LifePayment/LifePayment.Domain/WeChat/IWxPayApi.cs
@@ -26,7 +26,7 @@
        Task<WxPayDomesticRefundsQueryReponse> WxPayDomesticRefundsQuery(string outTradeNo);
        Task<WxPayDomesticRefundsQueryReponse> WxPayTradeQuery(string outTradeNo);
        Task<WxPayTradeQueryReponse> WxPayTradeQuery(string outTradeNo);
        Task<WxPayTradeBillApplyReponse> WxPayTradeBillApply(WxPayTradeBillApplyRequest input);
LifePayment/LifePayment.Domain/WeChat/WxPayApi.cs
@@ -1,4 +1,5 @@
using LifePayment.Domain.Shared;
using Microsoft.Extensions.Options;
using System.Threading.Tasks;
using ZeroD.Util.Fadd;
@@ -6,6 +7,13 @@
{
    public class WxPayApi : WxClient, IWxPayApi
    {
        private readonly WxPayOption _wxPayOptions;
        public WxPayApi(IOptions<WxPayOption> wxPayOptions)
        {
            _wxPayOptions = wxPayOptions.Value;
        }
        public async Task<PayTransactionsNativeReponse> PayTransactionsNative(PayTransactionsNativeInput input)
        {
            var result = await PostAsync<PayTransactionsNativeInput, PayTransactionsNativeReponse>(input, LifePaymentConstant.PayTransactionsNative);
@@ -43,10 +51,10 @@
            return result;
        }
        public async Task<WxPayDomesticRefundsQueryReponse> WxPayTradeQuery(string outTradeNo)
        public async Task<WxPayTradeQueryReponse> WxPayTradeQuery(string outTradeNo)
        {
            var url = $"{string.Format(LifePaymentConstant.WxPayTradeQyery, outTradeNo)}";
            var result = await Certificates<WxPayDomesticRefundsQueryReponse>(url);
            var url = $"{string.Format(LifePaymentConstant.WxPayTradeQyery, outTradeNo, _wxPayOptions.Mchid)}";
            var result = await Certificates<WxPayTradeQueryReponse>(url);
            return result;
        }
LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml
@@ -267,6 +267,13 @@
            <param name="input"></param>
            <returns></returns>
        </member>
        <member name="M:LifePayment.HttpApi.LifePayController.GetLifePayExpensesReceiptsPage(LifePayment.Application.Contracts.LifePayExpensesReceiptsPageInput)">
            <summary>
            获取收支流水分页数据
            </summary>
            <param name="input"></param>
            <returns></returns>
        </member>
        <member name="M:LifePayment.HttpApi.LifePayController.QueryAlipayTrade(LifePayment.Domain.Shared.OrderInQuiryInput)">
            <summary>
            查询支付宝支付订单信息
@@ -288,6 +295,13 @@
            <param name="outTradeNo"></param>
            <returns></returns>
        </member>
        <member name="M:LifePayment.HttpApi.LifePayController.WxPayTradeQuery(System.String)">
            <summary>
            查询微信订单信息
            </summary>
            <param name="outTradeNo"></param>
            <returns></returns>
        </member>
        <member name="M:LifePayment.HttpApi.LifePayController.CreateLifePayPhoneOrder(LifePayment.Application.Contracts.CreateLifePayOrderInput{LifePayment.Application.Contracts.LifePhoneData})">
            <summary>
            创建生活缴费话费订单
LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
@@ -781,6 +781,31 @@
            拓展属性
            </summary>
        </member>
        <member name="P:LifePayment.Application.Contracts.LifePayExpensesReceiptsPageInput.KeyWord">
            <summary>
            查询条件
            </summary>
        </member>
        <member name="P:LifePayment.Application.Contracts.LifePayExpensesReceiptsPageInput.LifePayType">
            <summary>
            支付渠道
            </summary>
        </member>
        <member name="P:LifePayment.Application.Contracts.LifePayExpensesReceiptsPageInput.ExpensesReceiptsType">
            <summary>
            收支类型
            </summary>
        </member>
        <member name="P:LifePayment.Application.Contracts.LifePayExpensesReceiptsPageInput.TimeBegin">
            <summary>
            交易开始时间
            </summary>
        </member>
        <member name="P:LifePayment.Application.Contracts.LifePayExpensesReceiptsPageInput.TimeEnd">
            <summary>
            交易结束时间
            </summary>
        </member>
        <member name="P:LifePayment.Application.Contracts.LifePayIntroInfoInput.LifePayType">
            <summary>
            生活缴费类型
@@ -1676,6 +1701,11 @@
            渠道号
            </summary>
        </member>
        <member name="P:LifePayment.Application.Contracts.LifePayExpensesReceiptsListOutput.Id">
            <summary>
            编号
            </summary>
        </member>
        <member name="P:LifePayment.Application.Contracts.LifePayExpensesReceiptsListOutput.OrderNo">
            <summary>
            平台订单号
@@ -1706,6 +1736,21 @@
            交易时间
            </summary>
        </member>
        <member name="P:LifePayment.Application.Contracts.LifePayExpensesReceiptsPageOutput`1.TotalIncome">
            <summary>
            累计收入
            </summary>
        </member>
        <member name="P:LifePayment.Application.Contracts.LifePayExpensesReceiptsPageOutput`1.TotalRefund">
            <summary>
            累计退款
            </summary>
        </member>
        <member name="P:LifePayment.Application.Contracts.LifePayExpensesReceiptsPageOutput`1.RealIncome">
            <summary>
            实际收入
            </summary>
        </member>
        <member name="P:LifePayment.Application.Contracts.RecordOperateHistoryEto.RelationId">
            <summary>
            关联关系ID
LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs
@@ -443,6 +443,17 @@
        }
        /// <summary>
        /// 获取收支流水分页数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<LifePayExpensesReceiptsPageOutput<LifePayExpensesReceiptsListOutput>> GetLifePayExpensesReceiptsPage(LifePayExpensesReceiptsPageInput input)
        {
            return await _lifePayOrderService.GetLifePayExpensesReceiptsPage(input);
        }
        /// <summary>
        /// 查询支付宝支付订单信息
        /// </summary>
        /// <param name="input"></param>
@@ -451,7 +462,16 @@
        [AllowAnonymous]
        public async Task<Alipay.EasySDK.Payment.Common.Models.AlipayTradeQueryResponse> QueryAlipayTrade(OrderInQuiryInput input)
        {
            return await _lifePayService.QueryAlipayTrade(input);
            var res = await _lifePayService.QueryAlipayTrade(input);
            //await _lifePayOrderService.AddLifePayExpensesReceipts(new AddLifePayExpensesReceiptsInput()
            //{
            //    OrderNo = input.OutTradeNo,
            //    OutOrderNo = res.TradeNo,
            //    LifePayType = LifePayTypeEnum.AliPay,
            //    ExpensesReceiptsType = ExpensesReceiptsTypeEnum.Expenses,
            //    Amount = Convert.ToDecimal(res.ReceiptAmount)
            //});
            return res;
        }
        /// <summary>
@@ -478,6 +498,27 @@
            return await _lifePayService.WxPayDomesticRefundsQuery(outTradeNo);
        }
        /// <summary>
        /// 查询微信订单信息
        /// </summary>
        /// <param name="outTradeNo"></param>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<WxPayTradeQueryReponse> WxPayTradeQuery(string outTradeNo)
        {
            var res = await _lifePayService.WxPayTradeQuery(outTradeNo);
            await _lifePayOrderService.AddLifePayExpensesReceipts(new AddLifePayExpensesReceiptsInput()
            {
                OrderNo = res.OutTradeNo,
                OutOrderNo = res.TransactionId,
                LifePayType = LifePayTypeEnum.WxPay,
                ExpensesReceiptsType = ExpensesReceiptsTypeEnum.Expenses,
                Amount = Convert.ToDecimal(res.Amount.Total)
            });
            return res;
        }
        #endregion
        #region 操作