Skip to content

Commit

Permalink
update packages
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorTzeng committed Jan 8, 2019
1 parent 0f3abdf commit c8dd5b8
Show file tree
Hide file tree
Showing 11 changed files with 570 additions and 14 deletions.
12 changes: 0 additions & 12 deletions Zxw.Framework.NetCore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ VisualStudioVersion = 15.0.27004.2002
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Zxw.Framework.NetCore", "Zxw.Framework.NetCore\Zxw.Framework.NetCore.csproj", "{3CA31344-BC8F-47A2-B23F-A6CDB3DEC255}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Zxw.Framework.Pay", "Zxw.Framework.Pay\Zxw.Framework.Pay.csproj", "{1510B606-A91B-4490-9525-BC5C64B20732}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Zxw.Framework.UnitTest", "Zxw.Framework.UnitTest\Zxw.Framework.UnitTest.csproj", "{0E7B2942-A74D-4297-B2A8-7F7C5955C476}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Zxw.Framework.Wechat", "Zxw.Framework.Wechat\Zxw.Framework.Wechat.csproj", "{E8F030C5-7D5D-43D5-9A39-777DDD7CFEC6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -21,18 +17,10 @@ Global
{3CA31344-BC8F-47A2-B23F-A6CDB3DEC255}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3CA31344-BC8F-47A2-B23F-A6CDB3DEC255}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3CA31344-BC8F-47A2-B23F-A6CDB3DEC255}.Release|Any CPU.Build.0 = Release|Any CPU
{1510B606-A91B-4490-9525-BC5C64B20732}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1510B606-A91B-4490-9525-BC5C64B20732}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1510B606-A91B-4490-9525-BC5C64B20732}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1510B606-A91B-4490-9525-BC5C64B20732}.Release|Any CPU.Build.0 = Release|Any CPU
{0E7B2942-A74D-4297-B2A8-7F7C5955C476}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0E7B2942-A74D-4297-B2A8-7F7C5955C476}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0E7B2942-A74D-4297-B2A8-7F7C5955C476}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0E7B2942-A74D-4297-B2A8-7F7C5955C476}.Release|Any CPU.Build.0 = Release|Any CPU
{E8F030C5-7D5D-43D5-9A39-777DDD7CFEC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E8F030C5-7D5D-43D5-9A39-777DDD7CFEC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E8F030C5-7D5D-43D5-9A39-777DDD7CFEC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E8F030C5-7D5D-43D5-9A39-777DDD7CFEC6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
4 changes: 2 additions & 2 deletions Zxw.Framework.NetCore/Zxw.Framework.NetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
<PackageReference Include="AspectCore.Extensions.DependencyInjection" Version="1.1.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.3.1" />
<PackageReference Include="Blueshift.EntityFrameworkCore.MongoDB" Version="2.1.0-preview2-t006f54f83" />
<PackageReference Include="Caching.CSRedis" Version="3.0.27" />
<PackageReference Include="Caching.CSRedis" Version="3.0.31" />
<PackageReference Include="DotNetCore.NPOI" Version="1.2.0" />
<PackageReference Include="Citms.EntityFrameworkCore.Oracle" Version="1.0.3" />
<PackageReference Include="CSRedisCore" Version="3.0.30" />
<PackageReference Include="CSRedisCore" Version="3.0.31" />
<PackageReference Include="DotNetCore.NPOI" Version="1.2.1" />
<PackageReference Include="EntityFrameworkCore.Triggers" Version="1.1.1" />
<PackageReference Include="Jil" Version="2.16.0" />
Expand Down
69 changes: 69 additions & 0 deletions Zxw.Framework.Pay/AliPay/AliPay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System;
using ICanPay.Alipay;
using ICanPay.Core;

namespace Zxw.Framework.Pay.AliPay
{
/// <summary>
/// 支付宝支付
/// </summary>
public class AliPay:PayBase<AlipayGateway>
{
public AliPay(IGateways getGateways) : base(getGateways)
{
}

public void BillDownload(string billType, string billDate)
{
base.BillDownload(new Auxiliary() {BillDate = billDate, BillType = billType});
}

public string CreateOrder(Order order, GatewayTradeType tradeType,
Action<object, PaymentSucceedEventArgs> succeed = null,
Action<object, PaymentFailedEventArgs> failed = null)
{
return base.CreateOrder(order, tradeType, succeed, failed);
}

public Notify Cancel(string orderNo)
{
return (Notify)base.Cancel(new Auxiliary()
{
OutTradeNo = orderNo
});
}

public Notify Close(string orderNo)
{
return (Notify)base.Close(new Auxiliary()
{
OutTradeNo = orderNo
});
}

public Notify Query(string orderNo)
{
return (Notify)base.Query(new Auxiliary()
{
OutTradeNo = orderNo
});
}

public Notify Refund(string orderNo)
{
return (Notify)base.Refund(new Auxiliary()
{
OutTradeNo = orderNo
});
}

public Notify RefundQuery(string orderNo, string refundNo)
{
return (Notify)base.RefundQuery(new Auxiliary()
{
OutTradeNo = orderNo,
OutRefundNo = refundNo
});
}
}
}
24 changes: 24 additions & 0 deletions Zxw.Framework.Pay/IPay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using ICanPay.Core;

namespace Zxw.Framework.Pay
{
public interface IPay
{
void BillDownload(IAuxiliary auxiliary);

string CreateOrder(IOrder order, GatewayTradeType tradeType,
Action<object, PaymentSucceedEventArgs> succeed = null,
Action<object, PaymentFailedEventArgs> failed = null);

INotify Cancel(IAuxiliary auxiliary);

INotify Close(IAuxiliary auxiliary);

INotify Query(IAuxiliary auxiliary);

INotify Refund(IAuxiliary auxiliary);

INotify RefundQuery(IAuxiliary auxiliary);
}
}
65 changes: 65 additions & 0 deletions Zxw.Framework.Pay/PayBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System;
using ICanPay.Core;

namespace Zxw.Framework.Pay
{
public abstract class PayBase<TGateWay> :IPay
where TGateWay : GatewayBase
{
private IGateways _gateways;

public virtual GatewayBase Gateway => _gateways.Get<TGateWay>();

protected PayBase(IGateways getGateways)
{
_gateways = getGateways;
}
public virtual void BillDownload(IAuxiliary auxiliary)
{
Gateway.BillDownload(auxiliary);
}

public virtual string CreateOrder(IOrder order, GatewayTradeType tradeType, Action<object, PaymentSucceedEventArgs> succeed = null, Action<object, PaymentFailedEventArgs> failed = null)
{
if (tradeType == GatewayTradeType.Barcode)
{
if (succeed == null)
{
throw new ArgumentNullException(nameof(succeed));
}
if (failed == null)
{
throw new ArgumentNullException(nameof(failed));
}
Gateway.PaymentSucceed += succeed;
Gateway.PaymentFailed += failed;
}
return Gateway.Payment(order);
}

public virtual INotify Cancel(IAuxiliary auxiliary)
{
return Gateway.Cancel(auxiliary);
}

public virtual INotify Close(IAuxiliary auxiliary)
{
return Gateway.Close(auxiliary);
}

public virtual INotify Query(IAuxiliary auxiliary)
{
return Gateway.Query(auxiliary);
}

public virtual INotify Refund(IAuxiliary auxiliary)
{
return Gateway.Refund(auxiliary);
}

public virtual INotify RefundQuery(IAuxiliary auxiliary)
{
return Gateway.RefundQuery(auxiliary);
}
}
}
38 changes: 38 additions & 0 deletions Zxw.Framework.Pay/PayExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using ICanPay.Core;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Zxw.Framework.NetCore.IoC;

namespace Zxw.Framework.Pay
{
public static class PayExtensions
{
public static IServiceCollection RegisterPayMerchant<TGateway, TMerchant>(this IServiceCollection services,
TMerchant merchant)
where TGateway : GatewayBase, new()
where TMerchant : class, IMerchant
{
if (services == null)
throw new ArgumentNullException(nameof(services));
if (merchant == null)
throw new ArgumentNullException(nameof(merchant));
services.AddICanPay(m =>
{
var gateways = AspectCoreContainer.Resolve<IGateways>() ?? new Gateways();
var gateway = (TGateway) Activator.CreateInstance(typeof(TGateway), (object) merchant);
gateways.Add(gateway);

return gateways;
});
return services;
}

public static IApplicationBuilder UsePay(this IApplicationBuilder app)
{
if (app == null)
throw new ArgumentNullException(nameof(app));
return app.UseICanPay();
}
}
}
98 changes: 98 additions & 0 deletions Zxw.Framework.Pay/UnionPay/UnionPay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
using System;
using ICanPay.Core;
using ICanPay.Unionpay;

namespace Zxw.Framework.Pay.UnionPay
{
/// <summary>
/// 银联支付
/// </summary>
public class UnionPay:PayBase<UnionpayGateway>
{
public UnionPay(IGateways getGateways) : base(getGateways)
{
}

/// <summary>
/// 银联对账单下载
/// </summary>
/// <param name="billType"></param>
/// <param name="billDate"></param>
public void BillDownload(string billType, string billDate)
{
base.BillDownload(new Auxiliary() { BillDate = billDate, TxnTime = billType });
}

/// <summary>
/// 下单
/// </summary>
/// <param name="order"></param>
/// <param name="tradeType"></param>
/// <param name="succeed"></param>
/// <param name="failed"></param>
/// <returns></returns>
public string CreateOrder(Order order, GatewayTradeType tradeType,
Action<object, PaymentSucceedEventArgs> succeed = null,
Action<object, PaymentFailedEventArgs> failed = null)
{
return base.CreateOrder(order, tradeType, succeed, failed);
}

/// <summary>
/// 取消订单
/// </summary>
/// <param name="tradeNo"></param>
/// <param name="outRefundNo"></param>
/// <param name="refundAmount"></param>
/// <returns></returns>
public Notify Cancel(string tradeNo, string outRefundNo, double? refundAmount)
{
return (Notify)base.Cancel(new Auxiliary()
{
TradeNo = tradeNo,
OutRefundNo = outRefundNo,
TxnTime = DateTime.Now.ToString("yyyyMMddHHmmss"),
RefundAmount = refundAmount
});
}

/// <summary>
/// 查询订单
/// </summary>
/// <param name="orderNo"></param>
/// <returns></returns>
public Notify Query(string orderNo)
{
return (Notify)base.Query(new Auxiliary()
{
OutTradeNo = orderNo
});
}
/// <summary>
/// 订单退款
/// </summary>
/// <param name="orderNo"></param>
/// <returns></returns>
public Notify Refund(string orderNo)
{
return (Notify)base.Refund(new Auxiliary()
{
OutTradeNo = orderNo
});
}
/// <summary>
/// 订单退款查询
/// </summary>
/// <param name="orderNo"></param>
/// <param name="refundNo"></param>
/// <returns></returns>
public Notify RefundQuery(string orderNo, string refundNo)
{
return (Notify)base.RefundQuery(new Auxiliary()
{
OutTradeNo = orderNo,
OutRefundNo = refundNo
});
}
}
}
Loading

0 comments on commit c8dd5b8

Please sign in to comment.