新增小程序一键支付

development
温天培 2 years ago
parent e1db0d512c
commit b2516f8014

@ -0,0 +1,31 @@
using System;
using SqlSugar;
using System.ComponentModel;
using GDZZ.Core.Entity;
namespace GDZZ.Application.Entity
{
/// <summary>
/// 支付记录
/// </summary>
[SugarTable("mini_paytake")]
[Description("支付记录")]
public class MiniPayTake : DEntityBase
{
/// <summary>
/// 订单ID
/// </summary>
public long OrderId { get; set; }
/// <summary>
/// 流水号
/// </summary>
public string PaySn { get; set; }
/// <summary>
/// 支付状态
/// </summary>
public int PayStatus { get; set; }
/// <summary>
/// 金额
/// </summary>
public decimal PaymentMoney { get; set; }
}
}

@ -0,0 +1,27 @@
using System;
using SqlSugar;
using System.ComponentModel;
using GDZZ.Core.Entity;
namespace GDZZ.Application.Entity
{
/// <summary>
/// 充值表
/// </summary>
[SugarTable("mini_recharge")]
[Description("充值表")]
public class MiniRecharge : DEntityBase
{
/// <summary>
/// 总价格
/// </summary>
public decimal TotalPrice { get; set; }
/// <summary>
/// 支付金额
/// </summary>
public decimal PaymentMoney { get; set; }
/// <summary>
/// 充值状态
/// </summary>
public int Status { get; set; }
}
}

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GDZZ.Application
{
public enum PayStatusEnum
{
/// <summary>
/// 已取消
/// </summary>
[Description("已取消")] Cancel = 0,
/// <summary>
/// 未成功
/// </summary>
[Description("未成功")] NotPaying = 10,
/// <summary>
/// 已成功
/// </summary>
[Description("已成功")] Paying = 20
}
}

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GDZZ.Application
{
public enum RechargeEnum
{
/// <summary>
/// 取消
/// </summary>
[Description("取消")] Cancel = 0,
/// <summary>
/// 未完成
/// </summary>
[Description("未完成")] NoFinis = 10,
/// <summary>
/// 完成
/// </summary>
[Description("完成")] Finish = 20,
}
}

@ -5,7 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GDZZ.Application.Enum
namespace GDZZ.Application
{
/// <summary>
///

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GDZZ.Application.Enum
namespace GDZZ.Application
{
/// <summary>
/// redis枚举配置

@ -23,11 +23,11 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<Folder Include="Service\WXPay\Dto\" />
</ItemGroup>
<ItemGroup>
<Folder Include="Service\WXPay\Dto\" />
<PackageReference Include="Senparc.Weixin.TenPayV3" Version="0.6.8.13" />
</ItemGroup>
</Project>

@ -421,6 +421,21 @@
</summary>
<returns></returns>
</member>
<member name="T:GDZZ.Application.Help.TenPayHelper">
<summary>
微信支付帮助
</summary>
</member>
<member name="M:GDZZ.Application.Help.TenPayHelper.UniOrderAsync(System.String,System.String,System.Int32,System.Int64)">
<summary>
小程序统一支付
</summary>
<param name="openId"></param>
<param name="body"></param>
<param name="price">//单位:分</param>
<param name="paymentId"></param>
<returns></returns>
</member>
<member name="F:GDZZ.Application.Service.Auth.AuthService._oauthConfig">
<summary>
获取配置文件
@ -438,6 +453,19 @@
</summary>
<returns></returns>
</member>
<member name="M:GDZZ.Application.Service.Auth.AuthService.WxPay(System.Int64)">
<summary>
微信支付
</summary>
<param name="productId"></param>
<returns></returns>
</member>
<member name="M:GDZZ.Application.Service.Auth.AuthService.PayNotifyUrl">
<summary>
JS-SDK支付回调地址在下单接口中设置的 notify_url
</summary>
<returns></returns>
</member>
<member name="T:GDZZ.Application.Service.Auth.IAuthService">
<summary>
业务权限控制
@ -477,6 +505,19 @@
微信支付
</summary>
</member>
<member name="M:GDZZ.Application.Service.WXPay.WXPayService.WxPay(System.Int64)">
<summary>
微信小程序支付
</summary>
<param name="productId">商品Id</param>
<returns></returns>
</member>
<member name="M:GDZZ.Application.Service.WXPay.WXPayService.NotifyUrl">
<summary>
微信小程序支付回调
</summary>
<returns></returns>
</member>
<member name="P:GDZZ.Application.AuthUserOut.UserId">
<summary>
用户ID

@ -1,32 +1,25 @@
using Furion.DataEncryption;
using Furion.EventBus;
using Furion.FriendlyException;
using Furion;
using GDZZ.Application.Entity;
using Furion;
using System;
using GDZZ.Core;
using GDZZ.Core.OAuth;
using Furion.EventBus;
using GDZZ.Core.Entity;
using GDZZ.Core.Service;
using Microsoft.AspNetCore.Authorization;
using Furion.DataEncryption;
using GDZZ.Application.Entity;
using Furion.FriendlyException;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GDZZ.Core.OAuth;
using Microsoft.Extensions.Options;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using System.Linq.Dynamic.Core.Tokenizer;
using Microsoft.AspNetCore.Http;
using GDZZ.Application.Help;
using Mapster;
using Microsoft.AspNetCore.Authorization;
namespace GDZZ.Application.Service.Auth
{
public class AuthService : IAuthService, IDynamicApiController, ITransient
{
#region 仓储
@ -34,6 +27,9 @@ namespace GDZZ.Application.Service.Auth
private readonly SqlSugarRepository<SysUser> _sysUserRep; // 用户表仓储
private readonly SqlSugarRepository<SysTenant> _sysTenantRep; //租户仓储
private readonly SqlSugarRepository<SeIF> Self; //职业仓储
private readonly SqlSugarRepository<MiniRecharge> rechargeRep; //充值仓储
private readonly SqlSugarRepository<MiniPayTake> payTakeRep; //支付仓储
#endregion
#region 服务
@ -42,13 +38,13 @@ namespace GDZZ.Application.Service.Auth
private readonly IHttpContextAccessor _httpContextAccessor; //http服务
private readonly IEventPublisher _eventPublisher; //事件写入服务
#endregion
/// <summary>
/// 获取配置文件
/// </summary>
private readonly ThirdParty _oauthConfig;
public AuthService(
IOptions<OAuthOptions> options,
SqlSugarRepository<BaseUser> Baseuser,
@ -71,8 +67,6 @@ namespace GDZZ.Application.Service.Auth
_oauthConfig = options.Value.Wechat;
}
/// <summary>
/// 手机端登录
/// </summary>
@ -205,66 +199,19 @@ namespace GDZZ.Application.Service.Auth
return await this.cacheService.GetUserInfoAsync(UserManager.UserId);
}
///// <summary>
///// 微信支付
///// </summary>
///// <param name="productId"></param>
///// <returns></returns>
//[Transaction]
//public async Task<IResponseOutput> WxPay(long productId)
//{
// //ProductInfoEntity entity = await _productInfoRepository.GetAsync(productId);
// RechargeIntroEntity entity = await _rechargeIntroRepository.GetAsync(productId);
// if (entity.IsNotNull())
// {
// //订单信息
// OrderEntity order = await _orderRepository.InsertAsync(new OrderEntity
// {
// OrderSn = StringHelper.GetOrderSn(productId),
// UserId = _user.Id,
// ShippingUser = "",
// Province = 0,
// City = 0,
// District = 0,
// Address = "",
// PaymentMethod = (int)PaymentMethodEnum.WX,
// OrderMoney = entity.Price,
// DistrictMoney = 0,
// PaymentMoney = entity.Price,
// ShippingCompName = "",
// ShippingSn = "",
// ShippingTime = null,
// PayTime = DateTime.Now,
// ReceiveTime = null,
// OrderStatus = (int)OrderStatusEnum.NotPaying,
// OrderPoint = 0,
// InvoiceTitle = ""
// });
// //明细
// await _orderDetailRepository.InsertAsync(new OrderDetailEntity
// {
// OrderId = order.Id,
// ProductId = productId,
// ProductName = entity.ProductName,
// ProductPrice = entity.Price
// });
// //付款记录
// PaymentRecordEntity paymentRecord = await _paymentRecordRepository.InsertAsync(new PaymentRecordEntity
// {
// UserId = _user.Id,
// OrderId = order.Id,
// PaySn = "",
// PayStatus = (int)PayStatusEnum.NotPaying,
// PayPlatform = (int)PaymentMethodEnum.WX,
// PaymentMoney = order.PaymentMoney
// });
// return await TenPayHelper.UniOrderAsync(_user.OpenId, entity.ProductName, order.PaymentMoney.ToInt(),
// paymentRecord.Id);
// }
// return ResponseOutput.Fail("商品信息不存在");
//}
/// <summary>
/// 微信支付
/// </summary>
/// <param name="productId"></param>
/// <returns></returns>
[HttpGet("Mini/WxPay")]
public async Task<dynamic> WxPay(AuthUserInput authUserInput)
{
return null;
}
}
}

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GDZZ.Application
{
public class AuthUserInput
{
public long OpenID { get; set; }
public decimal Money { get; set; }
/// <summary>
/// 折扣
/// </summary>
public decimal Discount { get; set; }
}
}

@ -15,6 +15,8 @@ namespace GDZZ.Application.Service.LiveHistoryContacts.Dto
public long sendTime { get; set; }
public string content { get; set; }
public long toContactId { get; set; }
public string FileName { get; set; }
public Fromuser fromUser { get; set; }
}

@ -202,6 +202,7 @@ namespace GDZZ.Application
{
id = live.Id.ToString(),
type = live.Type,
FileName = live.FileName,
content = live.Content,
sendTime = new DateTimeOffset((DateTime)live.CreatedTime).ToUnixTimeSeconds(),
status = "succeed",
@ -213,8 +214,6 @@ namespace GDZZ.Application
id = UserManager.UserId
}
};
//await this.cacheService.SetUnreadAsync(UserManager.UserId);
//await this.cacheService.SetUnreadAsync(entity.OtherUserID);
var livejson = livemes.ToJsonString();
await _chatHubContext.Clients.Client(user.ConnectionId).SendMessage(livejson, "SendMessage");

@ -1,18 +1,197 @@
using GDZZ.Core.Service;
using GDZZ.Application.Entity;
using GDZZ.Core.Entity;
using GDZZ.Core;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Senparc.Weixin;
using Senparc.Weixin.Exceptions;
using Senparc.Weixin.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Furion.EventBus;
using Microsoft.Extensions.Options;
using Senparc.CO2NET.Extensions;
using Microsoft.AspNetCore.Http;
using Senparc.Weixin.TenPay.V3;
using Senparc.Weixin.TenPay;
namespace GDZZ.Application.Service.WXPay
{
public class WXPayService
public class WXPayService:IWXPayService
{
private readonly IAuthService _authService;
private readonly SqlSugarRepository<BaseUser> Baseuser; // wx用户仓储
private readonly SqlSugarRepository<SysUser> _sysUserRep; // 用户表仓储
private readonly SqlSugarRepository<SysTenant> _sysTenantRep; //租户仓储
private readonly SqlSugarRepository<SeIF> Self; //职业仓储
private readonly SqlSugarRepository<MiniRecharge> rechargeRep; //充值仓储
private readonly SqlSugarRepository<MiniPayTake> payTakeRep; //支付仓储
private readonly WechatOAuth _wechatOAuth; //微信权限服务
private readonly IEventPublisher _eventPublisher; //事件写入服务
private readonly IHttpContextAccessor _httpContextAccessor; //http服务
private static TenPayV3Info _tenPayV3Info;
public static TenPayV3Info TenPayV3Info
{
get
{
if (_tenPayV3Info == null)
{
var key = TenPayHelper.GetRegisterKey(Config.SenparcWeixinSetting);
_tenPayV3Info =
TenPayV3InfoCollection.Data[key];
}
return _tenPayV3Info;
}
}
/// <summary>
/// 获取配置文件
/// </summary>
private readonly ThirdParty _oauthConfig;
public WXPayService(
IOptions<OAuthOptions> options,
SqlSugarRepository<BaseUser> Baseuser,
SqlSugarRepository<SysTenant> sysTenantRep,
SqlSugarRepository<SysUser> sysUserRep,
SqlSugarRepository<SeIF> Self,
SqlSugarRepository<MiniRecharge> rechargeRep,
SqlSugarRepository<MiniPayTake> payTakeRep,
WechatOAuth wechatOAuth,
IHttpContextAccessor _httpContextAccessor,
IEventPublisher eventPublisher)
{
this.Baseuser= Baseuser;
this._sysUserRep= sysUserRep;
this._sysTenantRep= sysTenantRep;
this.Self= Self;
this.rechargeRep = rechargeRep;
this.payTakeRep= payTakeRep;
this._wechatOAuth= wechatOAuth;
this._oauthConfig =options.Value.Wechat;
this._httpContextAccessor = _httpContextAccessor;
}
/// <summary>
///微信小程序支付
/// </summary>
/// <param name="productId">商品Id</param>
/// <returns></returns>
[HttpGet]
[AllowAnonymous]
[Route("api/v1/wxpay/{productId}")]
public async Task<dynamic> WxPay(AuthUserInput authUserInput)
{
var recharge = await this.rechargeRep.InsertReturnEntityAsync(new MiniRecharge()
{
PaymentMoney = authUserInput.Money / authUserInput.Discount,
Status = (int)RechargeEnum.NoFinis,
TotalPrice = authUserInput.Money
});
var payTake = await this.payTakeRep.InsertReturnEntityAsync(new MiniPayTake()
{
PaymentMoney = authUserInput.Money / authUserInput.Discount,
OrderId = recharge.Id,
PaySn = "",
PayStatus = (int)PayStatusEnum.NotPaying
});
//序列号
string sp_billno =
$"{Config.SenparcWeixinSetting.TenPayV3_MchId}{SystemTime.Now:yyyyMMddHHmmss}{TenPayV3Util.BuildRandomStr(6)}";
string timeStamp = TenPayV3Util.GetTimestamp();
string nonceStr = TenPayV3Util.GetNoncestr();
TenPayV3UnifiedorderRequestData xmlDataInfo = new TenPayV3UnifiedorderRequestData(this._oauthConfig.app_id,
Config.SenparcWeixinSetting.TenPayV3_MchId, "充值金额", sp_billno,
(int)authUserInput.Money * 100,
"127.0.0.1",
Config.SenparcWeixinSetting.TenPayV3_WxOpenTenpayNotify, TenPayV3Type.JSAPI, authUserInput.OpenID.ToString(),
Config.SenparcWeixinSetting.TenPayV3_Key, nonceStr, null, null, null, null, payTake.Id.ToString());
UnifiedorderResult result = await TenPayV3.UnifiedorderAsync(xmlDataInfo); //调用统一订单接口
string packageStr = "prepay_id=" + result.prepay_id;
return new
{
success = true,
result.prepay_id,
appId = Config.SenparcWeixinSetting.WxOpenAppId,
timeStamp,
nonceStr,
package = packageStr,
signType = "MD5",
paySign = TenPayV3.GetJsPaySign(Config.SenparcWeixinSetting.WxOpenAppId, timeStamp, nonceStr,
packageStr, Config.SenparcWeixinSetting.TenPayV3_Key)
};
}
/// <summary>
/// 微信小程序支付回调
/// </summary>
/// <returns></returns>
[HttpPost]
[AllowAnonymous]
[Route("v1/wxpay/NotifyUrl")]
public async Task<string> NotifyUrl()
{
try
{
_logger.LogError("NotifyUrl");
ResponseHandler resHandler = new ResponseHandler(_httpContextAccessor.HttpContext);
string returnCode = resHandler.GetParameter("return_code");
resHandler.SetKey(TenPayKey);
if (resHandler.IsTenpaySign() && returnCode.ToUpper() == "SUCCESS")
{
//attach
string paymentId = resHandler.GetParameter("attach");
//业务处理
PaymentRecordEntity paymentRecord = await _paymentRecordRepository.GetAsync(paymentId.ToLong());
if (paymentRecord.IsNotNull())
{
paymentRecord.PayStatus = (int)PayStatusEnum.Paying;
await _paymentRecordRepository.UpdateAsync(paymentRecord);
//order
OrderEntity order = await _orderRepository.GetAsync(paymentRecord.OrderId);
if (order.IsNotNull())
{
order.OrderStatus = (int)OrderStatusEnum.Paying;
await _orderRepository.UpdateAsync(order);
//积分操作
OrderDetailEntity orderDetail = await _orderDetailRepository.Select.Where(x => x.OrderId == order.Id)
.ToOneAsync();
//ProductInfoEntity productInfo = await _productInfoRepository.GetAsync(orderDetail.ProductId);
RechargeIntroEntity entity = await _rechargeIntroRepository.GetAsync(orderDetail.ProductId);
await _currencyService.AddCurrencyByCharge(order.UserId, order.Id,
entity.AllValue);
}
}
}
string xml = "<xml>"
+ "<return_code>SUCCESS</return_code>"
+ "<return_msg>OK</return_msg>"
+ "</xml>";
return xml;
}
catch (Exception ex)
{
_logger.LogError(ex, ex.Message);
string xml = "<xml>"
+ "<return_code>FAIL</return_code>"
+ "<return_msg>支付通知失败</return_msg>"
+ "</xml>";
return xml;
}
}
}
}

@ -6,7 +6,6 @@
using GDZZ.CodeFirst;
using GDZZ.Core;
using GDZZ.Core.Entity;
using Microsoft.Extensions.Configuration;
using SqlSugar;
using System.Collections;
using System.Data;

@ -52,6 +52,11 @@ public class OAuthOptions : IConfigurableOptions
///微信
/// </summary>
public ThirdParty Wechat { get; set; }
/// <summary>
/// 微信支付
/// </summary>
public SenparcWeixinSetting SenparcWeixin { get; set; }
}
/// <summary>
/// 上传文件
@ -208,3 +213,28 @@ public class ThirdParty
public string scope { get; set; }
}
public class SenparcWeixinSetting
{
public bool IsDebug { get; set; }
public string Token { get; set; }
public string EncodingAESKey { get; set; }
public string WeixinAppId { get; set; }
public string WeixinAppSecret { get; set; }
public string TenPayV3_AppId { get; set; }
public string TenPayV3_AppSecret { get; set; }
public string TenPayV3_SubAppId { get; set; }
public string TenPayV3_SubAppSecret { get; set; }
public string TenPayV3_MchId { get; set; }
public string TenPayV3_SubMchId { get; set; }
public string TenPayV3_Key { get; set; }
public string TenPayV3_CertPath { get; set; }
public string TenPayV3_CertSecret { get; set; }
public string TenPayV3_TenpayNotify { get; set; }
public string TenPayV3_PrivateKey { get; set; }
public string TenPayV3_SerialNumber { get; set; }
public string TenPayV3_ApiV3Key { get; set; }
public string TenPayV3_WxOpenTenpayNotify { get; set; }
}

@ -317,6 +317,11 @@
微信
</summary>
</member>
<member name="P:GDZZ.Core.OAuthOptions.SenparcWeixin">
<summary>
微信支付
</summary>
</member>
<member name="T:GDZZ.Core.UploadFileOptions">
<summary>
上传文件

@ -294,4 +294,66 @@ public class AuthService : IAuthService, IDynamicApiController, ITransient
{
return await Task.FromResult(_captchaHandle.CheckCode(input));
}
///// <summary>
///// 微信支付
///// </summary>
///// <param name="productId"></param>
///// <returns></returns>
//public async Task<dynamic> WxPay(long productId)
//{
// ////ProductInfoEntity entity = await _productInfoRepository.GetAsync(productId);
// //RechargeIntroEntity entity = await _rechargeIntroRepository.GetAsync(productId);
// //if (entity.IsNotNull())
// //{
// // //订单信息
// // OrderEntity order = await _orderRepository.InsertAsync(new OrderEntity
// // {
// // OrderSn = StringHelper.GetOrderSn(productId),
// // UserId = _user.Id,
// // ShippingUser = "",
// // Province = 0,
// // City = 0,
// // District = 0,
// // Address = "",
// // PaymentMethod = (int)PaymentMethodEnum.WX,
// // OrderMoney = entity.Price,
// // DistrictMoney = 0,
// // PaymentMoney = entity.Price,
// // ShippingCompName = "",
// // ShippingSn = "",
// // ShippingTime = null,
// // PayTime = DateTime.Now,
// // ReceiveTime = null,
// // OrderStatus = (int)OrderStatusEnum.NotPaying,
// // OrderPoint = 0,
// // InvoiceTitle = ""
// // });
// // //明细
// // await _orderDetailRepository.InsertAsync(new OrderDetailEntity
// // {
// // OrderId = order.Id,
// // ProductId = productId,
// // ProductName = entity.ProductName,
// // ProductPrice = entity.Price
// // });
// // //付款记录
// // PaymentRecordEntity paymentRecord = await _paymentRecordRepository.InsertAsync(new PaymentRecordEntity
// // {
// // UserId = _user.Id,
// // OrderId = order.Id,
// // PaySn = "",
// // PayStatus = (int)PayStatusEnum.NotPaying,
// // PayPlatform = (int)PaymentMethodEnum.WX,
// // PaymentMoney = order.PaymentMoney
// // });
// // return await TenPayHelper.UniOrderAsync(_user.OpenId, entity.ProductName, order.PaymentMoney.ToInt(),
// // paymentRecord.Id);
// //}
// //return ResponseOutput.Fail("商品信息不存在");
//}
}

@ -6,6 +6,7 @@ namespace GDZZ.Core.Service;
public interface IAuthService
{
//Task<dynamic> WxPay(long productId);
Task<dynamic> GetCaptcha();
Task<bool> GetCaptchaOpen();
Task<LoginOutput> GetLoginUserAsync();

@ -1867,5 +1867,16 @@
<param name="input"></param>
<returns></returns>
</member>
<member name="T:GDZZ.FlowCenter.Startup">
<summary>
启动配置
</summary>
</member>
<member name="M:GDZZ.FlowCenter.Startup.ConfigureServices(Microsoft.Extensions.DependencyInjection.IServiceCollection)">
<summary>
服务注册
</summary>
<param name="services"></param>
</member>
</members>
</doc>

@ -5,8 +5,15 @@ using System.Linq;
namespace GDZZ.FlowCenter;
/// <summary>
/// 启动配置
/// </summary>
public class Startup : AppStartup
{
/// <summary>
/// 服务注册
/// </summary>
/// <param name="services"></param>
public void ConfigureServices(IServiceCollection services)
{

@ -15,6 +15,10 @@
<Content Include="GDZZ.Web.Core.xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Senparc.Weixin.TenPayV3" Version="0.6.8.13" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GDZZ.Application\GDZZ.Application.csproj" />
<ProjectReference Include="..\GDZZ.FlowCenter\GDZZ.FlowCenter.csproj" />

@ -1,34 +1,41 @@
using Furion;
using GDZZ.Core;
using GDZZ.Core.Service;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Net;
using System.Net.Http;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.Unicode;
using Yitter.IdGenerator;
using Furion.Templates;
using Furion.Logging;
using System.Collections.Generic;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json;
using Microsoft.Extensions.FileProviders;
using Senparc.Weixin.RegisterServices;
using Google.Protobuf.WellKnownTypes;
using Microsoft.Extensions.Configuration;
using System.IO;
using Senparc.CO2NET.AspNet;
using Senparc.CO2NET;
using Senparc.Weixin.Entities;
using Microsoft.Extensions.Options;
using Senparc.Weixin;
using Senparc.CO2NET.RegisterServices;
namespace GDZZ.Web.Core;
[AppStartup(9)]
public class Startup : AppStartup
{
//public Startup(IConfiguration configuration)
//{
// Configuration = configuration;
//}
//public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddBStyle(m => m.UseDefault());
@ -55,6 +62,11 @@ public class Startup : AppStartup
{
o.MultipartBodyLengthLimit = maxRequestBodySize;
});
//services.Configure<SenparcWeixinSetting>(o =>
//{
// o.
//});
#endregion
services.AddResponseCompression();
@ -65,9 +77,6 @@ public class Startup : AppStartup
services.AddCorsAccessor();
// 配置远程请求
services.AddRemoteRequest(option =>
{
@ -110,9 +119,13 @@ public class Startup : AppStartup
// 注册 Log 日志订阅者
builder.AddSubscriber<LogEventSubscriber>();
});
services.AddMemoryCache();//注册本地缓存
services.AddSenparcWeixinServices(App.Configuration);//Senparc.Weixin 注册(必须)
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env,
IOptions<SenparcSetting> senparcSetting,
IOptions<Senparc.Weixin.Entities.SenparcWeixinSetting> senparcWeixinSetting)
{
if (env.IsDevelopment())
{
@ -153,6 +166,11 @@ public class Startup : AppStartup
pattern: "{controller=Home}/{action=Index}/{id?}");
});
//var registerService = app.UseSenparcGlobal(env, senparcSetting.Value, g => { })
// .UseSenparcWeixin(senparcWeixinSetting.Value, (register, weixinSetting) =>
// {
// register.RegisterTenpayApiV3(senparcWeixinSetting.Value,"纵智助手");
// });
}

@ -65,6 +65,38 @@
"scope": "snsapi_userinfo"
}
},
"SenparcWeixinSetting": {
//
//
"IsDebug": true,
//使key
//
"Token": "微信支付不需要",
"EncodingAESKey": "微信支付不需要",
"WeixinAppId": "wx422d9d8b4939f68c",
"WeixinAppSecret": "3d9a78ee2808836e63311cc5fa1ee317",
//V3
"TenPayV3_AppId": "wx422d9d8b4939f68c",
"TenPayV3_AppSecret": "3d9a78ee2808836e63311cc5fa1ee317",
"TenPayV3_SubAppId": "",
"TenPayV3_SubAppSecret": "",
"TenPayV3_MchId": "xxxxxxxx",
"TenPayV3_SubMchId": "", //
"TenPayV3_Key": "79xxxxxxxxxxxxxxxxxxxxxxxxxxx",
"TenPayV3_CertPath": "可留空", //D:\\cert\\apiclient_cert.p12
"TenPayV3_CertSecret": "可留空", // MchId
"TenPayV3_TenpayNotify": "http://sdk.weixin.senparc.com/TenpayV3/PayNotifyUrl", //http://YourDomainName/TenpayV3/PayNotifyUrl
"TenPayV3_PrivateKey": "MIIExxxxxxxxxxxxxxxxx", //
"TenPayV3_SerialNumber": "5Bxxxxxxxxxxxxxxxxxxxxxx", //
"TenPayV3_ApiV3Key": "xxxxxxxxxxxxxxxxxxxxxxxx", //APIv3
//TenPayV3_WxOpenTenpayNotify TenPayV3_TenpayNotify "WxOpen"
"TenPayV3_WxOpenTenpayNotify": "http://sdk.weixin.senparc.com/TenpayV3/PayNotifyUrlWxOpen" //http://YourDomainName/TenpayV3/PayNotifyUrlWxOpen
},
"UploadFile": {
// OSS
"Aliyun": {

Binary file not shown.

After

Width:  |  Height:  |  Size: 785 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save