完成excel模块、wechat模块

This commit is contained in:
橙子
2023-01-16 23:24:59 +08:00
parent 034abb06ad
commit 617fbdf8f7
18 changed files with 1423 additions and 7 deletions

View File

@@ -0,0 +1,54 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.WeChatPay.Domain;
using Yi.Framework.WeChatPay.Domain.Config;
using Yi.Framework.WeChatPay.Domain.Notify;
using Yi.Framework.WeChatPay.Exceptions;
using Yi.Framework.WeChatPay.Helper;
using Yi.Framework.WeChatPay.Options;
namespace Yi.Framework.WeChatPay.Extensions
{
public static class PayServiceExtensions
{
public static IServiceCollection AddWeChatPayServer(this IServiceCollection services, Action<PayOptions> configure)
{
var option = new PayOptions();
configure(option);
if (option.IsFileConfig)
{
option = PayHelper.GetPayOptions(option.ConfigPath);
}
if (option.AppID == null)
{
throw new PayException("AppId为空值");
}
if (option.MchID == null)
{
throw new PayException("MchID为空值");
}
if (option.Key == null)
{
throw new PayException("Key为空值");
}
if (option.NotifyUrl == null)
{
throw new PayException("NotifyUrl为空值");
}
services.AddSingleton(option);
services.AddTransient<PayInvoker>();
services.AddTransient<IPayInvoker, PayInvoker>();
services.AddTransient<IPayConfig, PayConfig>();
services.AddTransient<PayHelper>();
services.AddTransient<PayApi>();
services.AddTransient<PayHttpService>();
services.AddTransient<AbstractNotify, ResultNotify>();
services.AddHttpContextAccessor();
return services;
}
}
}