sunpengfei
9 天以前 10760c944ad47ef9e27aebd88c45bebf23521792
FlexJobApi.UserServer.Application/EnterpriseWallets/Commands/GetAlipayNotifyCommandHandler.cs
@@ -1,5 +1,12 @@
using FlexJobApi.Core;
using Azure;
using FlexJobApi.Core;
using Furion;
using Furion.DatabaseAccessor;
using Furion.FriendlyException;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Org.BouncyCastle.Ocsp;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -11,9 +18,16 @@
    /// <summary>
    /// 支付宝通知回传
    /// </summary>
    public class GetAlipayNotifyCommandHandler :
        IRequestHandler<GetAlipayNotifyCommand, bool>
    public class GetAlipayNotifyCommandHandler(
            IRepository<EnterpriseWallet> rep,
            IMediator mediator
        ) :
        IRequestHandler<GetAlipayNotifyCommand, bool>,
        IRequestHandler<AlipayUserAgreementPageSignNotifyCommand, bool>
    {
        private readonly IRepository<EnterpriseWallet> rep = rep;
        private readonly IMediator mediator = mediator;
        /// <summary>
        /// 支付宝通知回传
        /// </summary>
@@ -24,5 +38,25 @@
        {
            return Task.FromResult(true);
        }
        /// <summary>
        /// 支付宝用户授权协议签约通知
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<bool> Handle(AlipayUserAgreementPageSignNotifyCommand request, CancellationToken cancellationToken)
        {
            var entity = await rep.AsQueryable()
                .Where(it => it.Code == request.external_agreement_no)
                .FirstOrDefaultAsync();
            if (entity == null) throw Oops.Oh(EnumErrorCodeType.s404, "企业钱包");
            await mediator.Send(new GetEnterpriseWalletQuery
            {
                EnterpriseId = entity.EnterpriseId,
                Access = EnumEnterpriseWalletAccess.Alipay
            });
            return true;
        }
    }
}