新增小程序一键支付

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.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace GDZZ.Application.Enum namespace GDZZ.Application
{ {
/// <summary> /// <summary>
/// ///

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

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

@ -421,6 +421,21 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </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"> <member name="F:GDZZ.Application.Service.Auth.AuthService._oauthConfig">
<summary> <summary>
获取配置文件 获取配置文件
@ -438,6 +453,19 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </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"> <member name="T:GDZZ.Application.Service.Auth.IAuthService">
<summary> <summary>
业务权限控制 业务权限控制
@ -477,6 +505,19 @@
微信支付 微信支付
</summary> </summary>
</member> </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"> <member name="P:GDZZ.Application.AuthUserOut.UserId">
<summary> <summary>
用户ID 用户ID

@ -1,32 +1,25 @@
using Furion.DataEncryption; using Furion;
using Furion.EventBus; using System;
using Furion.FriendlyException;
using Furion;
using GDZZ.Application.Entity;
using GDZZ.Core; using GDZZ.Core;
using GDZZ.Core.OAuth;
using Furion.EventBus;
using GDZZ.Core.Entity; using GDZZ.Core.Entity;
using GDZZ.Core.Service; using Furion.DataEncryption;
using Microsoft.AspNetCore.Authorization; using GDZZ.Application.Entity;
using Furion.FriendlyException;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using Microsoft.Extensions.Options;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GDZZ.Core.OAuth;
using Furion.DependencyInjection; using Furion.DependencyInjection;
using Furion.DynamicApiController; using Furion.DynamicApiController;
using System.Linq.Dynamic.Core.Tokenizer;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using GDZZ.Application.Help; using GDZZ.Application.Help;
using Mapster; using Microsoft.AspNetCore.Authorization;
namespace GDZZ.Application.Service.Auth namespace GDZZ.Application.Service.Auth
{ {
public class AuthService : IAuthService, IDynamicApiController, ITransient public class AuthService : IAuthService, IDynamicApiController, ITransient
{ {
#region 仓储 #region 仓储
@ -34,6 +27,9 @@ namespace GDZZ.Application.Service.Auth
private readonly SqlSugarRepository<SysUser> _sysUserRep; // 用户表仓储 private readonly SqlSugarRepository<SysUser> _sysUserRep; // 用户表仓储
private readonly SqlSugarRepository<SysTenant> _sysTenantRep; //租户仓储 private readonly SqlSugarRepository<SysTenant> _sysTenantRep; //租户仓储
private readonly SqlSugarRepository<SeIF> Self; //职业仓储 private readonly SqlSugarRepository<SeIF> Self; //职业仓储
private readonly SqlSugarRepository<MiniRecharge> rechargeRep; //充值仓储
private readonly SqlSugarRepository<MiniPayTake> payTakeRep; //支付仓储
#endregion #endregion
#region 服务 #region 服务
@ -42,13 +38,13 @@ namespace GDZZ.Application.Service.Auth
private readonly IHttpContextAccessor _httpContextAccessor; //http服务 private readonly IHttpContextAccessor _httpContextAccessor; //http服务
private readonly IEventPublisher _eventPublisher; //事件写入服务 private readonly IEventPublisher _eventPublisher; //事件写入服务
#endregion #endregion
/// <summary> /// <summary>
/// 获取配置文件 /// 获取配置文件
/// </summary> /// </summary>
private readonly ThirdParty _oauthConfig; private readonly ThirdParty _oauthConfig;
public AuthService( public AuthService(
IOptions<OAuthOptions> options, IOptions<OAuthOptions> options,
SqlSugarRepository<BaseUser> Baseuser, SqlSugarRepository<BaseUser> Baseuser,
@ -71,8 +67,6 @@ namespace GDZZ.Application.Service.Auth
_oauthConfig = options.Value.Wechat; _oauthConfig = options.Value.Wechat;
} }
/// <summary> /// <summary>
/// 手机端登录 /// 手机端登录
/// </summary> /// </summary>
@ -205,66 +199,19 @@ namespace GDZZ.Application.Service.Auth
return await this.cacheService.GetUserInfoAsync(UserManager.UserId); return await this.cacheService.GetUserInfoAsync(UserManager.UserId);
} }
///// <summary> /// <summary>
///// 微信支付 /// 微信支付
///// </summary> /// </summary>
///// <param name="productId"></param> /// <param name="productId"></param>
///// <returns></returns> /// <returns></returns>
//[Transaction] [HttpGet("Mini/WxPay")]
//public async Task<IResponseOutput> WxPay(long productId) public async Task<dynamic> WxPay(AuthUserInput authUserInput)
//{ {
// //ProductInfoEntity entity = await _productInfoRepository.GetAsync(productId);
// RechargeIntroEntity entity = await _rechargeIntroRepository.GetAsync(productId); return null;
// 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("商品信息不存在");
//}
} }
} }

@ -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 long sendTime { get; set; }
public string content { get; set; } public string content { get; set; }
public long toContactId { get; set; } public long toContactId { get; set; }
public string FileName { get; set; }
public Fromuser fromUser { get; set; } public Fromuser fromUser { get; set; }
} }

@ -202,6 +202,7 @@ namespace GDZZ.Application
{ {
id = live.Id.ToString(), id = live.Id.ToString(),
type = live.Type, type = live.Type,
FileName = live.FileName,
content = live.Content, content = live.Content,
sendTime = new DateTimeOffset((DateTime)live.CreatedTime).ToUnixTimeSeconds(), sendTime = new DateTimeOffset((DateTime)live.CreatedTime).ToUnixTimeSeconds(),
status = "succeed", status = "succeed",
@ -213,8 +214,6 @@ namespace GDZZ.Application
id = UserManager.UserId id = UserManager.UserId
} }
}; };
//await this.cacheService.SetUnreadAsync(UserManager.UserId);
//await this.cacheService.SetUnreadAsync(entity.OtherUserID);
var livejson = livemes.ToJsonString(); var livejson = livemes.ToJsonString();
await _chatHubContext.Clients.Client(user.ConnectionId).SendMessage(livejson, "SendMessage"); 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.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Senparc.Weixin;
using Senparc.Weixin.Exceptions;
using Senparc.Weixin.Helpers;
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; 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 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.CodeFirst;
using GDZZ.Core; using GDZZ.Core;
using GDZZ.Core.Entity; using GDZZ.Core.Entity;
using Microsoft.Extensions.Configuration;
using SqlSugar; using SqlSugar;
using System.Collections; using System.Collections;
using System.Data; using System.Data;

@ -52,6 +52,11 @@ public class OAuthOptions : IConfigurableOptions
///微信 ///微信
/// </summary> /// </summary>
public ThirdParty Wechat { get; set; } public ThirdParty Wechat { get; set; }
/// <summary>
/// 微信支付
/// </summary>
public SenparcWeixinSetting SenparcWeixin { get; set; }
} }
/// <summary> /// <summary>
/// 上传文件 /// 上传文件
@ -208,3 +213,28 @@ public class ThirdParty
public string scope { get; set; } 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> </summary>
</member> </member>
<member name="P:GDZZ.Core.OAuthOptions.SenparcWeixin">
<summary>
微信支付
</summary>
</member>
<member name="T:GDZZ.Core.UploadFileOptions"> <member name="T:GDZZ.Core.UploadFileOptions">
<summary> <summary>
上传文件 上传文件

@ -294,4 +294,66 @@ public class AuthService : IAuthService, IDynamicApiController, ITransient
{ {
return await Task.FromResult(_captchaHandle.CheckCode(input)); 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 public interface IAuthService
{ {
//Task<dynamic> WxPay(long productId);
Task<dynamic> GetCaptcha(); Task<dynamic> GetCaptcha();
Task<bool> GetCaptchaOpen(); Task<bool> GetCaptchaOpen();
Task<LoginOutput> GetLoginUserAsync(); Task<LoginOutput> GetLoginUserAsync();

@ -1867,5 +1867,16 @@
<param name="input"></param> <param name="input"></param>
<returns></returns> <returns></returns>
</member> </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> </members>
</doc> </doc>

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

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

@ -1,34 +1,41 @@
using Furion; using Furion;
using GDZZ.Core; using GDZZ.Core;
using GDZZ.Core.Service;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Server.Kestrel.Core; using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System; using System;
using System.Net; using System.Net;
using System.Net.Http; 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 Yitter.IdGenerator;
using Furion.Templates;
using Furion.Logging;
using System.Collections.Generic;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
using Newtonsoft.Json; using Newtonsoft.Json;
using Microsoft.Extensions.FileProviders; using Senparc.Weixin.RegisterServices;
using Google.Protobuf.WellKnownTypes;
using Microsoft.Extensions.Configuration;
using System.IO; 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; namespace GDZZ.Web.Core;
[AppStartup(9)] [AppStartup(9)]
public class Startup : AppStartup public class Startup : AppStartup
{ {
//public Startup(IConfiguration configuration)
//{
// Configuration = configuration;
//}
//public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
services.AddBStyle(m => m.UseDefault()); services.AddBStyle(m => m.UseDefault());
@ -55,6 +62,11 @@ public class Startup : AppStartup
{ {
o.MultipartBodyLengthLimit = maxRequestBodySize; o.MultipartBodyLengthLimit = maxRequestBodySize;
}); });
//services.Configure<SenparcWeixinSetting>(o =>
//{
// o.
//});
#endregion #endregion
services.AddResponseCompression(); services.AddResponseCompression();
@ -65,9 +77,6 @@ public class Startup : AppStartup
services.AddCorsAccessor(); services.AddCorsAccessor();
// 配置远程请求 // 配置远程请求
services.AddRemoteRequest(option => services.AddRemoteRequest(option =>
{ {
@ -110,9 +119,13 @@ public class Startup : AppStartup
// 注册 Log 日志订阅者 // 注册 Log 日志订阅者
builder.AddSubscriber<LogEventSubscriber>(); 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()) if (env.IsDevelopment())
{ {
@ -153,6 +166,11 @@ public class Startup : AppStartup
pattern: "{controller=Home}/{action=Index}/{id?}"); 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" "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": { "UploadFile": {
// OSS // OSS
"Aliyun": { "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