diff --git a/CoreCms.Net.Configuration/AppSettingsConstVars.cs b/CoreCms.Net.Configuration/AppSettingsConstVars.cs index 3bbfffb1..dc79b8b8 100644 --- a/CoreCms.Net.Configuration/AppSettingsConstVars.cs +++ b/CoreCms.Net.Configuration/AppSettingsConstVars.cs @@ -121,26 +121,6 @@ namespace CoreCms.Net.Configuration public static readonly int MiddlewareConcurrencyLimiterRequestQueueLimit = AppSettingsHelper.GetContent("Middleware", "ConcurrencyLimiter", "RequestQueueLimit").ObjToInt(100); #endregion - #region 支付================================================================================ - - /// - /// 微信支付回调 - /// - public static readonly string PayCallBackWeChatPayUrl = AppSettingsHelper.GetContent("PayCallBack", "WeChatPayUrl"); - /// - /// 微信退款回调 - /// - public static readonly string PayCallBackWeChatRefundUrl = AppSettingsHelper.GetContent("PayCallBack", "WeChatRefundUrl"); - /// - /// 支付宝支付回调 - /// - public static readonly string PayCallBackAlipayUrl = AppSettingsHelper.GetContent("PayCallBack", "AlipayUrl"); - /// - /// 支付宝退款回调 - /// - public static readonly string PayCallBackAlipayRefundUrl = AppSettingsHelper.GetContent("PayCallBack", "AlipayRefundUrl"); - #endregion - #region HangFire定时任务================================================================================ /// /// 登录账号 diff --git a/CoreCms.Net.IRepository/Pay/IAlipayConfigRepository.cs b/CoreCms.Net.IRepository/Pay/IAlipayConfigRepository.cs new file mode 100644 index 00000000..94000e60 --- /dev/null +++ b/CoreCms.Net.IRepository/Pay/IAlipayConfigRepository.cs @@ -0,0 +1,98 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2023/4/20 23:33:03 + * Description: 暂无 + ***********************************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Threading.Tasks; +using CoreCms.Net.Model.Entities; +using CoreCms.Net.Model.ViewModels.Basics; +using CoreCms.Net.Model.ViewModels.UI; +using SqlSugar; + + +namespace CoreCms.Net.IRepository +{ + /// + /// 支付宝支付配置 工厂接口 + /// + public interface IAlipayConfigRepository : IBaseRepository + { + #region 重写增删改查操作=========================================================== + + /// + /// 重写异步插入方法 + /// + /// + /// + Task InsertAsync(CoreCmsAlipayConfig entity); + + + /// + /// 重写异步更新方法 + /// + /// + /// + Task UpdateAsync(CoreCmsAlipayConfig entity); + + + /// + /// 重写异步更新方法 + /// + /// + /// + Task UpdateAsync(List entity); + + + /// + /// 重写删除指定ID的数据 + /// + /// + /// + Task DeleteByIdAsync(object id); + + + /// + /// 重写删除指定ID集合的数据(批量删除) + /// + /// + /// + Task DeleteByIdsAsync(int[] ids); + + #endregion + + #region 获取缓存的所有数据========================================================== + + /// + /// 获取缓存的所有数据 + /// + /// + Task> GetCaChe(); + + #endregion + + + /// + /// 重写根据条件查询分页数据 + /// + /// 判断集合 + /// 排序方式 + /// 当前页面索引 + /// 分布大小 + /// + /// 是否使用WITH(NOLOCK) + /// + Task> QueryPageAsync( + Expression> predicate, + Expression> orderByExpression, OrderByType orderByType, int pageIndex = 1, + int pageSize = 20, bool blUseNoLock = false); + + } +} diff --git a/CoreCms.Net.IRepository/Pay/IWeChatPayConfigRepository.cs b/CoreCms.Net.IRepository/Pay/IWeChatPayConfigRepository.cs new file mode 100644 index 00000000..be5b9984 --- /dev/null +++ b/CoreCms.Net.IRepository/Pay/IWeChatPayConfigRepository.cs @@ -0,0 +1,98 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2023/4/20 23:42:07 + * Description: 暂无 + ***********************************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Threading.Tasks; +using CoreCms.Net.Model.Entities; +using CoreCms.Net.Model.ViewModels.Basics; +using CoreCms.Net.Model.ViewModels.UI; +using SqlSugar; + + +namespace CoreCms.Net.IRepository +{ + /// + /// 微信支付配置 工厂接口 + /// + public interface IWeChatPayConfigRepository : IBaseRepository + { + #region 重写增删改查操作=========================================================== + + /// + /// 重写异步插入方法 + /// + /// + /// + Task InsertAsync(CoreCmsWeChatPayConfig entity); + + + /// + /// 重写异步更新方法 + /// + /// + /// + Task UpdateAsync(CoreCmsWeChatPayConfig entity); + + + /// + /// 重写异步更新方法 + /// + /// + /// + Task UpdateAsync(List entity); + + + /// + /// 重写删除指定ID的数据 + /// + /// + /// + Task DeleteByIdAsync(object id); + + + /// + /// 重写删除指定ID集合的数据(批量删除) + /// + /// + /// + Task DeleteByIdsAsync(int[] ids); + + #endregion + + #region 获取缓存的所有数据========================================================== + + /// + /// 获取缓存的所有数据 + /// + /// + Task> GetCaChe(); + + #endregion + + + /// + /// 重写根据条件查询分页数据 + /// + /// 判断集合 + /// 排序方式 + /// 当前页面索引 + /// 分布大小 + /// + /// 是否使用WITH(NOLOCK) + /// + Task> QueryPageAsync( + Expression> predicate, + Expression> orderByExpression, OrderByType orderByType, int pageIndex = 1, + int pageSize = 20, bool blUseNoLock = false); + + } +} diff --git a/CoreCms.Net.IServices/Pay/IAlipayConfigServices.cs b/CoreCms.Net.IServices/Pay/IAlipayConfigServices.cs new file mode 100644 index 00000000..2415085f --- /dev/null +++ b/CoreCms.Net.IServices/Pay/IAlipayConfigServices.cs @@ -0,0 +1,94 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2023/4/20 23:33:03 + * Description: 暂无 + ***********************************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Threading.Tasks; +using CoreCms.Net.Model.Entities; +using CoreCms.Net.Model.ViewModels.Basics; +using CoreCms.Net.Model.ViewModels.UI; +using SqlSugar; + +namespace CoreCms.Net.IServices +{ + /// + /// 支付宝支付配置 服务工厂接口 + /// + public interface IAlipayConfigServices : IBaseServices + { + #region 重写增删改查操作=========================================================== + + /// + /// 重写异步插入方法 + /// + /// + /// + Task InsertAsync(CoreCmsAlipayConfig entity); + + /// + /// 重写异步更新方法 + /// + /// + /// + Task UpdateAsync(CoreCmsAlipayConfig entity); + + /// + /// 重写异步更新方法 + /// + /// + /// + Task UpdateAsync(List entity); + + /// + /// 重写删除指定ID的数据 + /// + /// + /// + Task DeleteByIdAsync(object id); + + /// + /// 重写删除指定ID集合的数据(批量删除) + /// + /// + /// + Task DeleteByIdsAsync(int[] ids); + + #endregion + + + #region 获取缓存的所有数据========================================================== + + /// + /// 获取缓存的所有数据 + /// + /// + Task> GetCaChe(); + + #endregion + + #region 重写根据条件查询分页数据 + /// + /// 重写根据条件查询分页数据 + /// + /// 判断集合 + /// 排序方式 + /// 当前页面索引 + /// 分布大小 + /// + /// 是否使用WITH(NOLOCK) + /// + Task> QueryPageAsync( + Expression> predicate, + Expression> orderByExpression, OrderByType orderByType, int pageIndex = 1, + int pageSize = 20, bool blUseNoLock = false); + #endregion + } +} diff --git a/CoreCms.Net.IServices/Pay/IWeChatPayConfigServices.cs b/CoreCms.Net.IServices/Pay/IWeChatPayConfigServices.cs new file mode 100644 index 00000000..00073081 --- /dev/null +++ b/CoreCms.Net.IServices/Pay/IWeChatPayConfigServices.cs @@ -0,0 +1,94 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2023/4/20 23:42:07 + * Description: 暂无 + ***********************************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Threading.Tasks; +using CoreCms.Net.Model.Entities; +using CoreCms.Net.Model.ViewModels.Basics; +using CoreCms.Net.Model.ViewModels.UI; +using SqlSugar; + +namespace CoreCms.Net.IServices +{ + /// + /// 微信支付配置 服务工厂接口 + /// + public interface IWeChatPayConfigServices : IBaseServices + { + #region 重写增删改查操作=========================================================== + + /// + /// 重写异步插入方法 + /// + /// + /// + Task InsertAsync(CoreCmsWeChatPayConfig entity); + + /// + /// 重写异步更新方法 + /// + /// + /// + Task UpdateAsync(CoreCmsWeChatPayConfig entity); + + /// + /// 重写异步更新方法 + /// + /// + /// + Task UpdateAsync(List entity); + + /// + /// 重写删除指定ID的数据 + /// + /// + /// + Task DeleteByIdAsync(object id); + + /// + /// 重写删除指定ID集合的数据(批量删除) + /// + /// + /// + Task DeleteByIdsAsync(int[] ids); + + #endregion + + + #region 获取缓存的所有数据========================================================== + + /// + /// 获取缓存的所有数据 + /// + /// + Task> GetCaChe(); + + #endregion + + #region 重写根据条件查询分页数据 + /// + /// 重写根据条件查询分页数据 + /// + /// 判断集合 + /// 排序方式 + /// 当前页面索引 + /// 分布大小 + /// + /// 是否使用WITH(NOLOCK) + /// + Task> QueryPageAsync( + Expression> predicate, + Expression> orderByExpression, OrderByType orderByType, int pageIndex = 1, + int pageSize = 20, bool blUseNoLock = false); + #endregion + } +} diff --git a/CoreCms.Net.Model/CoreCms.Net.Model.xml b/CoreCms.Net.Model/CoreCms.Net.Model.xml index 5df591ae..12274dd0 100644 --- a/CoreCms.Net.Model/CoreCms.Net.Model.xml +++ b/CoreCms.Net.Model/CoreCms.Net.Model.xml @@ -4666,6 +4666,176 @@ 类型说明 + + + 支付宝支付配置 + + + + + 构造函数 + + + + + 序列 + + + + + 支付宝开放平台AppId + + + + + 支付宝公钥 + + + + + 应用私钥 + + + + + 服务网关地址 + + + + + 签名类型 + + + + + 应用公钥证书 + + + + + 支付宝公钥证书 + + + + + 支付宝根证书 + + + + + 应用类型 + + + + + 支付宝支付回调通知 + + + + + 支付宝退款回调 + + + + + 支付跳转地址 + + + + + 是否启用 + + + + + 当前多端默认 + + + + + 微信支付配置 + + + + + 构造函数 + + + + + 序列 + + + + + 应用号 + + + + + 商户号 + + + + + API秘钥 + + + + + APIv3密钥 + + + + + p12证书base64 + + + + + RSA公钥 + + + + + 子商户应用号 + + + + + 子商户号 + + + + + 支付回调通知 + + + + + 退款回调 + + + + + 跳转地址 + + + + + 是否开启 + + + + + 是否本类默认 + + + + + 应用类型 + + 拼团商品表 diff --git a/CoreCms.Net.Model/Entities/Pay/CoreCmsAlipayConfig.cs b/CoreCms.Net.Model/Entities/Pay/CoreCmsAlipayConfig.cs new file mode 100644 index 00000000..8b7d67e9 --- /dev/null +++ b/CoreCms.Net.Model/Entities/Pay/CoreCmsAlipayConfig.cs @@ -0,0 +1,212 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2023/4/20 23:33:03 + * Description: 暂无 + ***********************************************************************/ + +using SqlSugar; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; + +namespace CoreCms.Net.Model.Entities +{ + /// + /// 支付宝支付配置 + /// + public partial class CoreCmsAlipayConfig + { + /// + /// 构造函数 + /// + public CoreCmsAlipayConfig() + { + } + + /// + /// 序列 + /// + [Display(Name = "序列")] + + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + + [Required(ErrorMessage = "请输入{0}")] + + + + public System.Int32 id { get; set; } + + + /// + /// 支付宝开放平台AppId + /// + [Display(Name = "支付宝开放平台AppId")] + + [Required(ErrorMessage = "请输入{0}")] + + [StringLength(maximumLength:50,ErrorMessage = "{0}不能超过{1}字")] + + public System.String appId { get; set; } + + + /// + /// 支付宝公钥 + /// + [Display(Name = "支付宝公钥")] + + [Required(ErrorMessage = "请输入{0}")] + + [StringLength(maximumLength:500,ErrorMessage = "{0}不能超过{1}字")] + + public System.String publicKey { get; set; } + + + /// + /// 应用私钥 + /// + [Display(Name = "应用私钥")] + + [Required(ErrorMessage = "请输入{0}")] + + [StringLength(maximumLength:2000,ErrorMessage = "{0}不能超过{1}字")] + + public System.String privateKey { get; set; } + + + /// + /// 服务网关地址 + /// + [Display(Name = "服务网关地址")] + + + + [StringLength(maximumLength:100,ErrorMessage = "{0}不能超过{1}字")] + + public System.String serverUrl { get; set; } + + + /// + /// 签名类型 + /// + [Display(Name = "签名类型")] + + + + [StringLength(maximumLength:10,ErrorMessage = "{0}不能超过{1}字")] + + public System.String signType { get; set; } + + + /// + /// 应用公钥证书 + /// + [Display(Name = "应用公钥证书")] + + + + [StringLength(maximumLength:5000,ErrorMessage = "{0}不能超过{1}字")] + + public System.String appPublicCert { get; set; } + + + /// + /// 支付宝公钥证书 + /// + [Display(Name = "支付宝公钥证书")] + + + + [StringLength(maximumLength:5000,ErrorMessage = "{0}不能超过{1}字")] + + public System.String alipayPublicCert { get; set; } + + + /// + /// 支付宝根证书 + /// + [Display(Name = "支付宝根证书")] + + + + [StringLength(maximumLength:5000,ErrorMessage = "{0}不能超过{1}字")] + + public System.String alipayRootCert { get; set; } + + + /// + /// 应用类型 + /// + [Display(Name = "应用类型")] + + [Required(ErrorMessage = "请输入{0}")] + + [StringLength(maximumLength:10,ErrorMessage = "{0}不能超过{1}字")] + + public System.String appType { get; set; } + + + /// + /// 支付宝支付回调通知 + /// + [Display(Name = "支付宝支付回调通知")] + + + + [StringLength(maximumLength:500,ErrorMessage = "{0}不能超过{1}字")] + + public System.String notifyUrl { get; set; } + + + /// + /// 支付宝退款回调 + /// + [Display(Name = "支付宝退款回调")] + + + + [StringLength(maximumLength:500,ErrorMessage = "{0}不能超过{1}字")] + + public System.String refundUrl { get; set; } + + + /// + /// 支付跳转地址 + /// + [Display(Name = "支付跳转地址")] + + + + [StringLength(maximumLength:500,ErrorMessage = "{0}不能超过{1}字")] + + public System.String jumpUrl { get; set; } + + + /// + /// 是否启用 + /// + [Display(Name = "是否启用")] + + + + + + public System.Boolean isEnable { get; set; } + + + /// + /// 当前多端默认 + /// + [Display(Name = "当前多端默认")] + + + + + + public System.Boolean isDefault { get; set; } + + + } +} diff --git a/CoreCms.Net.Model/Entities/Pay/CoreCmsWeChatPayConfig.cs b/CoreCms.Net.Model/Entities/Pay/CoreCmsWeChatPayConfig.cs new file mode 100644 index 00000000..ce7f315b --- /dev/null +++ b/CoreCms.Net.Model/Entities/Pay/CoreCmsWeChatPayConfig.cs @@ -0,0 +1,212 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2023/4/22 23:40:15 + * Description: 暂无 + ***********************************************************************/ + +using SqlSugar; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; + +namespace CoreCms.Net.Model.Entities +{ + /// + /// 微信支付配置 + /// + public partial class CoreCmsWeChatPayConfig + { + /// + /// 构造函数 + /// + public CoreCmsWeChatPayConfig() + { + } + + /// + /// 序列 + /// + [Display(Name = "序列")] + + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + + [Required(ErrorMessage = "请输入{0}")] + + + + public System.Int32 id { get; set; } + + + /// + /// 应用号 + /// + [Display(Name = "应用号")] + + [Required(ErrorMessage = "请输入{0}")] + + [StringLength(maximumLength:50,ErrorMessage = "{0}不能超过{1}字")] + + public System.String appId { get; set; } + + + /// + /// 商户号 + /// + [Display(Name = "商户号")] + + [Required(ErrorMessage = "请输入{0}")] + + [StringLength(maximumLength:50,ErrorMessage = "{0}不能超过{1}字")] + + public System.String mchId { get; set; } + + + /// + /// API秘钥 + /// + [Display(Name = "API秘钥")] + + + + [StringLength(maximumLength:50,ErrorMessage = "{0}不能超过{1}字")] + + public System.String apiKey { get; set; } + + + /// + /// APIv3密钥 + /// + [Display(Name = "APIv3密钥")] + + + + [StringLength(maximumLength:50,ErrorMessage = "{0}不能超过{1}字")] + + public System.String apiV3Key { get; set; } + + + /// + /// p12证书base64 + /// + [Display(Name = "p12证书base64")] + + + + [StringLength(maximumLength:8000,ErrorMessage = "{0}不能超过{1}字")] + + public System.String certificate { get; set; } + + + /// + /// RSA公钥 + /// + [Display(Name = "RSA公钥")] + + + + [StringLength(maximumLength:1000,ErrorMessage = "{0}不能超过{1}字")] + + public System.String rsaPublicKey { get; set; } + + + /// + /// 子商户应用号 + /// + [Display(Name = "子商户应用号")] + + + + [StringLength(maximumLength:50,ErrorMessage = "{0}不能超过{1}字")] + + public System.String subAppId { get; set; } + + + /// + /// 子商户号 + /// + [Display(Name = "子商户号")] + + + + [StringLength(maximumLength:50,ErrorMessage = "{0}不能超过{1}字")] + + public System.String subMchId { get; set; } + + + /// + /// 支付回调通知 + /// + [Display(Name = "支付回调通知")] + + + + [StringLength(maximumLength:200,ErrorMessage = "{0}不能超过{1}字")] + + public System.String notifyUrl { get; set; } + + + /// + /// 退款回调 + /// + [Display(Name = "退款回调")] + + + + [StringLength(maximumLength:200,ErrorMessage = "{0}不能超过{1}字")] + + public System.String refundUrl { get; set; } + + + /// + /// 跳转地址 + /// + [Display(Name = "跳转地址")] + + + + [StringLength(maximumLength:200,ErrorMessage = "{0}不能超过{1}字")] + + public System.String jumpUrl { get; set; } + + + /// + /// 是否开启 + /// + [Display(Name = "是否开启")] + + [Required(ErrorMessage = "请输入{0}")] + + + + public System.Boolean isEnable { get; set; } + + + /// + /// 是否本类默认 + /// + [Display(Name = "是否本类默认")] + + [Required(ErrorMessage = "请输入{0}")] + + + + public System.Boolean isDefault { get; set; } + + + /// + /// 应用类型 + /// + [Display(Name = "应用类型")] + + + + [StringLength(maximumLength:50,ErrorMessage = "{0}不能超过{1}字")] + + public System.String appType { get; set; } + + + } +} diff --git a/CoreCms.Net.Repository/Pay/AlipayConfigRepository.cs b/CoreCms.Net.Repository/Pay/AlipayConfigRepository.cs new file mode 100644 index 00000000..b3b30e11 --- /dev/null +++ b/CoreCms.Net.Repository/Pay/AlipayConfigRepository.cs @@ -0,0 +1,232 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2023/4/20 23:33:03 + * Description: 暂无 + ***********************************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Threading.Tasks; +using CoreCms.Net.Caching.Manual; +using CoreCms.Net.Configuration; +using CoreCms.Net.Model.Entities; +using CoreCms.Net.Model.ViewModels.Basics; +using CoreCms.Net.IRepository; +using CoreCms.Net.IRepository.UnitOfWork; +using CoreCms.Net.Model.ViewModels.UI; +using SqlSugar; + +namespace CoreCms.Net.Repository +{ + /// + /// 支付宝支付配置 接口实现 + /// + public class AlipayConfigRepository : BaseRepository, IAlipayConfigRepository + { + private readonly IUnitOfWork _unitOfWork; + public AlipayConfigRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + _unitOfWork = unitOfWork; + } + + #region 实现重写增删改查操作========================================================== + + /// + /// 重写异步插入方法 + /// + /// 实体数据 + /// + public async Task InsertAsync(CoreCmsAlipayConfig entity) + { + var jm = new AdminUiCallBack(); + + var bl = await DbClient.Insertable(entity).ExecuteReturnIdentityAsync() > 0; + jm.code = bl ? 0 : 1; + jm.msg = bl ? GlobalConstVars.CreateSuccess : GlobalConstVars.CreateFailure; + + return jm; + } + + /// + /// 重写异步更新方法 + /// + /// + /// + public async Task UpdateAsync(CoreCmsAlipayConfig entity) + { + var jm = new AdminUiCallBack(); + + var oldModel = await DbClient.Queryable().In(entity.id).SingleAsync(); + if (oldModel == null) + { + jm.msg = "不存在此信息"; + return jm; + } + //事物处理过程开始 + oldModel.id = entity.id; + oldModel.appId = entity.appId; + oldModel.publicKey = entity.publicKey; + oldModel.privateKey = entity.privateKey; + oldModel.serverUrl = entity.serverUrl; + oldModel.signType = entity.signType; + oldModel.appPublicCert = entity.appPublicCert; + oldModel.alipayPublicCert = entity.alipayPublicCert; + oldModel.alipayRootCert = entity.alipayRootCert; + oldModel.appType = entity.appType; + oldModel.notifyUrl = entity.notifyUrl; + oldModel.refundUrl = entity.refundUrl; + oldModel.jumpUrl = entity.jumpUrl; + oldModel.isEnable = entity.isEnable; + oldModel.isDefault = entity.isDefault; + + //事物处理过程结束 + var bl = await DbClient.Updateable(oldModel).ExecuteCommandHasChangeAsync(); + jm.code = bl ? 0 : 1; + jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure; + + return jm; + } + + /// + /// 重写异步更新方法 + /// + /// + /// + public async Task UpdateAsync(List entity) + { + var jm = new AdminUiCallBack(); + + var bl = await DbClient.Updateable(entity).ExecuteCommandHasChangeAsync(); + jm.code = bl ? 0 : 1; + jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure; + + return jm; + } + + /// + /// 重写删除指定ID的数据 + /// + /// + /// + public async Task DeleteByIdAsync(object id) + { + var jm = new AdminUiCallBack(); + + var bl = await DbClient.Deleteable(id).ExecuteCommandHasChangeAsync(); + jm.code = bl ? 0 : 1; + jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure; + + return jm; + } + + /// + /// 重写删除指定ID集合的数据(批量删除) + /// + /// + /// + public async Task DeleteByIdsAsync(int[] ids) + { + var jm = new AdminUiCallBack(); + + var bl = await DbClient.Deleteable().In(ids).ExecuteCommandHasChangeAsync(); + jm.code = bl ? 0 : 1; + jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure; + + return jm; + } + + #endregion + + #region 获取缓存的所有数据========================================================== + + /// + /// 获取缓存的所有数据 + /// + /// + public async Task> GetCaChe() + { + var list = await DbClient.Queryable().With(SqlWith.NoLock).WithCache().ToListAsync(); + return list; + } + + #endregion + + + #region 重写根据条件查询分页数据 + /// + /// 重写根据条件查询分页数据 + /// + /// 判断集合 + /// 排序方式 + /// 当前页面索引 + /// 分布大小 + /// + /// 是否使用WITH(NOLOCK) + /// + public async Task> QueryPageAsync(Expression> predicate, + Expression> orderByExpression, OrderByType orderByType, int pageIndex = 1, + int pageSize = 20, bool blUseNoLock = false) + { + RefAsync totalCount = 0; + List page; + if (blUseNoLock) + { + page = await DbClient.Queryable() + .OrderByIF(orderByExpression != null, orderByExpression, orderByType) + .WhereIF(predicate != null, predicate).Select(p => new CoreCmsAlipayConfig + { + id = p.id, + appId = p.appId, + publicKey = p.publicKey, + privateKey = p.privateKey, + serverUrl = p.serverUrl, + signType = p.signType, + appPublicCert = p.appPublicCert, + alipayPublicCert = p.alipayPublicCert, + alipayRootCert = p.alipayRootCert, + appType = p.appType, + notifyUrl = p.notifyUrl, + refundUrl = p.refundUrl, + jumpUrl = p.jumpUrl, + isEnable = p.isEnable, + isDefault = p.isDefault, + + }).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount); + } + else + { + page = await DbClient.Queryable() + .OrderByIF(orderByExpression != null, orderByExpression, orderByType) + .WhereIF(predicate != null, predicate).Select(p => new CoreCmsAlipayConfig + { + id = p.id, + appId = p.appId, + publicKey = p.publicKey, + privateKey = p.privateKey, + serverUrl = p.serverUrl, + signType = p.signType, + appPublicCert = p.appPublicCert, + alipayPublicCert = p.alipayPublicCert, + alipayRootCert = p.alipayRootCert, + appType = p.appType, + notifyUrl = p.notifyUrl, + refundUrl = p.refundUrl, + jumpUrl = p.jumpUrl, + isEnable = p.isEnable, + isDefault = p.isDefault, + + }).ToPageListAsync(pageIndex, pageSize, totalCount); + } + var list = new PageList(page, pageIndex, pageSize, totalCount); + return list; + } + + #endregion + + } +} diff --git a/CoreCms.Net.Repository/Pay/WeChatPayConfigRepository.cs b/CoreCms.Net.Repository/Pay/WeChatPayConfigRepository.cs new file mode 100644 index 00000000..de01564d --- /dev/null +++ b/CoreCms.Net.Repository/Pay/WeChatPayConfigRepository.cs @@ -0,0 +1,232 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2023/4/22 23:40:15 + * Description: 暂无 + ***********************************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Threading.Tasks; +using CoreCms.Net.Caching.Manual; +using CoreCms.Net.Configuration; +using CoreCms.Net.Model.Entities; +using CoreCms.Net.Model.ViewModels.Basics; +using CoreCms.Net.IRepository; +using CoreCms.Net.IRepository.UnitOfWork; +using CoreCms.Net.Model.ViewModels.UI; +using SqlSugar; + +namespace CoreCms.Net.Repository +{ + /// + /// 微信支付配置 接口实现 + /// + public class WeChatPayConfigRepository : BaseRepository, IWeChatPayConfigRepository + { + private readonly IUnitOfWork _unitOfWork; + public WeChatPayConfigRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + _unitOfWork = unitOfWork; + } + + #region 实现重写增删改查操作========================================================== + + /// + /// 重写异步插入方法 + /// + /// 实体数据 + /// + public async Task InsertAsync(CoreCmsWeChatPayConfig entity) + { + var jm = new AdminUiCallBack(); + + var bl = await DbClient.Insertable(entity).ExecuteReturnIdentityAsync() > 0; + jm.code = bl ? 0 : 1; + jm.msg = bl ? GlobalConstVars.CreateSuccess : GlobalConstVars.CreateFailure; + + return jm; + } + + /// + /// 重写异步更新方法 + /// + /// + /// + public async Task UpdateAsync(CoreCmsWeChatPayConfig entity) + { + var jm = new AdminUiCallBack(); + + var oldModel = await DbClient.Queryable().In(entity.id).SingleAsync(); + if (oldModel == null) + { + jm.msg = "不存在此信息"; + return jm; + } + //事物处理过程开始 + oldModel.id = entity.id; + oldModel.appId = entity.appId; + oldModel.mchId = entity.mchId; + oldModel.apiKey = entity.apiKey; + oldModel.apiV3Key = entity.apiV3Key; + oldModel.certificate = entity.certificate; + oldModel.rsaPublicKey = entity.rsaPublicKey; + oldModel.subAppId = entity.subAppId; + oldModel.subMchId = entity.subMchId; + oldModel.notifyUrl = entity.notifyUrl; + oldModel.refundUrl = entity.refundUrl; + oldModel.jumpUrl = entity.jumpUrl; + oldModel.isEnable = entity.isEnable; + oldModel.isDefault = entity.isDefault; + oldModel.appType = entity.appType; + + //事物处理过程结束 + var bl = await DbClient.Updateable(oldModel).ExecuteCommandHasChangeAsync(); + jm.code = bl ? 0 : 1; + jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure; + + return jm; + } + + /// + /// 重写异步更新方法 + /// + /// + /// + public async Task UpdateAsync(List entity) + { + var jm = new AdminUiCallBack(); + + var bl = await DbClient.Updateable(entity).ExecuteCommandHasChangeAsync(); + jm.code = bl ? 0 : 1; + jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure; + + return jm; + } + + /// + /// 重写删除指定ID的数据 + /// + /// + /// + public async Task DeleteByIdAsync(object id) + { + var jm = new AdminUiCallBack(); + + var bl = await DbClient.Deleteable(id).ExecuteCommandHasChangeAsync(); + jm.code = bl ? 0 : 1; + jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure; + + return jm; + } + + /// + /// 重写删除指定ID集合的数据(批量删除) + /// + /// + /// + public async Task DeleteByIdsAsync(int[] ids) + { + var jm = new AdminUiCallBack(); + + var bl = await DbClient.Deleteable().In(ids).ExecuteCommandHasChangeAsync(); + jm.code = bl ? 0 : 1; + jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure; + + return jm; + } + + #endregion + + #region 获取缓存的所有数据========================================================== + + /// + /// 获取缓存的所有数据 + /// + /// + public async Task> GetCaChe() + { + var list = await DbClient.Queryable().With(SqlWith.NoLock).WithCache().ToListAsync(); + return list; + } + + #endregion + + + #region 重写根据条件查询分页数据 + /// + /// 重写根据条件查询分页数据 + /// + /// 判断集合 + /// 排序方式 + /// 当前页面索引 + /// 分布大小 + /// + /// 是否使用WITH(NOLOCK) + /// + public async Task> QueryPageAsync(Expression> predicate, + Expression> orderByExpression, OrderByType orderByType, int pageIndex = 1, + int pageSize = 20, bool blUseNoLock = false) + { + RefAsync totalCount = 0; + List page; + if (blUseNoLock) + { + page = await DbClient.Queryable() + .OrderByIF(orderByExpression != null, orderByExpression, orderByType) + .WhereIF(predicate != null, predicate).Select(p => new CoreCmsWeChatPayConfig + { + id = p.id, + appId = p.appId, + mchId = p.mchId, + apiKey = p.apiKey, + apiV3Key = p.apiV3Key, + certificate = p.certificate, + rsaPublicKey = p.rsaPublicKey, + subAppId = p.subAppId, + subMchId = p.subMchId, + notifyUrl = p.notifyUrl, + refundUrl = p.refundUrl, + jumpUrl = p.jumpUrl, + isEnable = p.isEnable, + isDefault = p.isDefault, + appType = p.appType, + + }).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount); + } + else + { + page = await DbClient.Queryable() + .OrderByIF(orderByExpression != null, orderByExpression, orderByType) + .WhereIF(predicate != null, predicate).Select(p => new CoreCmsWeChatPayConfig + { + id = p.id, + appId = p.appId, + mchId = p.mchId, + apiKey = p.apiKey, + apiV3Key = p.apiV3Key, + certificate = p.certificate, + rsaPublicKey = p.rsaPublicKey, + subAppId = p.subAppId, + subMchId = p.subMchId, + notifyUrl = p.notifyUrl, + refundUrl = p.refundUrl, + jumpUrl = p.jumpUrl, + isEnable = p.isEnable, + isDefault = p.isDefault, + appType = p.appType, + + }).ToPageListAsync(pageIndex, pageSize, totalCount); + } + var list = new PageList(page, pageIndex, pageSize, totalCount); + return list; + } + + #endregion + + } +} diff --git a/CoreCms.Net.Services/Pay/AliPayServices.cs b/CoreCms.Net.Services/Pay/AliPayServices.cs index 20c9aa33..b43ec8ee 100644 --- a/CoreCms.Net.Services/Pay/AliPayServices.cs +++ b/CoreCms.Net.Services/Pay/AliPayServices.cs @@ -37,14 +37,15 @@ namespace CoreCms.Net.Services { private readonly IAlipayClient _client; private readonly IServiceProvider _serviceProvider; - private readonly IOptions _optionsAccessor; + private readonly IAlipayConfigServices _alipayConfigServices; - public AliPayServices(IWeChatPayRepository dal, IServiceProvider serviceProvider, IAlipayClient client, IOptions optionsAccessor) + + public AliPayServices(IWeChatPayRepository dal, IServiceProvider serviceProvider, IAlipayClient client, IAlipayConfigServices alipayConfigServices) { _serviceProvider = serviceProvider; _client = client; - _optionsAccessor = optionsAccessor; + _alipayConfigServices = alipayConfigServices; BaseDal = dal; } @@ -58,24 +59,46 @@ namespace CoreCms.Net.Services var jm = new WebApiCallBack(); using var container = _serviceProvider.CreateScope(); var billPaymentsServices = container.ServiceProvider.GetService(); - var payment = await billPaymentsServices.QueryByClauseAsync(p => p.paymentId == entity.paymentId); - var allPayUrl = AppSettingsConstVars.PayCallBackAlipayUrl; - var allPayReturnUrl = AppSettingsConstVars.PayCallBackAlipayRefundUrl; - if (string.IsNullOrEmpty(allPayUrl)) - { - jm.msg = "未获取到配置的回调地址"; - return jm; - } - + //var payment = await billPaymentsServices.QueryByClauseAsync(p => p.paymentId == entity.paymentId); var tradeType = GlobalEnumVars.AliPayPayTradeType.ScanQRCodes.ToString(); if (!string.IsNullOrEmpty(entity.parameters)) { - var jobj = (JObject)JsonConvert.DeserializeObject(entity.parameters); - if (jobj != null && jobj.ContainsKey("trade_type")) - tradeType = GetTradeType(jobj["trade_type"].ObjectToString()); + var jObj = (JObject)JsonConvert.DeserializeObject(entity.parameters); + if (jObj != null && jObj.TryGetValue("trade_type", out var value)) + tradeType = GetTradeType(value.ObjectToString()); } + + + var config = await _alipayConfigServices.QueryByClauseAsync(p => + p.isDefault == true && p.isEnable == true && p.appType == tradeType); + if (config == null) + { + jm.msg = "支付配置信息获取失败"; + return jm; + } + + if (string.IsNullOrEmpty(config.notifyUrl)) + { + jm.msg = "未获取到配置的通知地址"; + return jm; + } + + //构建linkPay请求配置实体 + var payOptions = new AlipayOptions + { + AppId = config.appId, + AlipayPublicKey = config.publicKey, + AppPrivateKey = config.privateKey, + ServerUrl = config.serverUrl, + SignType = config.signType, + AppPublicCert = config.appPublicCert, + AlipayPublicCert = config.alipayPublicCert, + AlipayRootCert = config.alipayRootCert + }; + + //扫码支付 if (tradeType == GlobalEnumVars.AliPayPayTradeType.ScanQRCodes.ToString()) { @@ -89,11 +112,11 @@ namespace CoreCms.Net.Services }; var req = new AlipayTradePrecreateRequest(); req.SetBizModel(model); - req.SetNotifyUrl(allPayUrl); - req.SetReturnUrl(allPayReturnUrl); + req.SetNotifyUrl(config.notifyUrl); + //req.SetReturnUrl("https://pc.pro.demo.corecms.cn/order/payment/result"); Loging.NLogUtil.WriteAll(LogLevel.Trace, Loging.LogType.Order, "支付宝ScanQRCodes支付拼接APP入参", JsonConvert.SerializeObject(model)); - var response = await _client.ExecuteAsync(req, _optionsAccessor.Value); + var response = await _client.ExecuteAsync(req, payOptions); Loging.NLogUtil.WriteAll(LogLevel.Trace, Loging.LogType.Order, "支付宝ScanQRCodes支付返回数据", JsonConvert.SerializeObject(response)); @@ -116,12 +139,11 @@ namespace CoreCms.Net.Services }; var req = new AlipayTradePagePayRequest(); req.SetBizModel(model); - req.SetNotifyUrl(allPayUrl); - req.SetReturnUrl(allPayReturnUrl); - + req.SetNotifyUrl(config.notifyUrl); + req.SetReturnUrl(config.jumpUrl); Loging.NLogUtil.WriteAll(LogLevel.Trace, Loging.LogType.Order, "支付宝JSAPI_PC支付拼接APP入参", JsonConvert.SerializeObject(model)); - var response = await _client.PageExecuteAsync(req, _optionsAccessor.Value); + var response = await _client.PageExecuteAsync(req, payOptions); Loging.NLogUtil.WriteAll(LogLevel.Trace, Loging.LogType.Order, "支付宝JSAPI_PC支付返回数据", JsonConvert.SerializeObject(response)); @@ -144,12 +166,11 @@ namespace CoreCms.Net.Services }; var req = new AlipayTradeAppPayRequest(); req.SetBizModel(model); - req.SetNotifyUrl(allPayUrl); - req.SetReturnUrl(allPayReturnUrl); - + req.SetNotifyUrl(config.notifyUrl); + //req.SetReturnUrl(config.jumpUrl); Loging.NLogUtil.WriteAll(LogLevel.Trace, Loging.LogType.Order, "支付宝APP支付拼接APP入参", JsonConvert.SerializeObject(model)); - var response = await _client.SdkExecuteAsync(req, _optionsAccessor.Value); + var response = await _client.SdkExecuteAsync(req, payOptions); Loging.NLogUtil.WriteAll(LogLevel.Trace, Loging.LogType.Order, "支付宝APP支付返回数据", JsonConvert.SerializeObject(response)); @@ -172,12 +193,11 @@ namespace CoreCms.Net.Services }; var req = new AlipayTradeWapPayRequest(); req.SetBizModel(model); - req.SetNotifyUrl(allPayUrl); - req.SetReturnUrl(allPayReturnUrl); - + req.SetNotifyUrl(config.notifyUrl); + req.SetReturnUrl(config.jumpUrl); Loging.NLogUtil.WriteAll(LogLevel.Trace, Loging.LogType.Order, "支付宝MWEB支付拼接APP入参", JsonConvert.SerializeObject(model)); - var response = await _client.PageExecuteAsync(req, _optionsAccessor.Value); + var response = await _client.PageExecuteAsync(req, payOptions); Loging.NLogUtil.WriteAll(LogLevel.Trace, Loging.LogType.Order, "支付宝MWEB支付返回数据", JsonConvert.SerializeObject(response)); diff --git a/CoreCms.Net.Services/Pay/AlipayConfigServices.cs b/CoreCms.Net.Services/Pay/AlipayConfigServices.cs new file mode 100644 index 00000000..5ef384eb --- /dev/null +++ b/CoreCms.Net.Services/Pay/AlipayConfigServices.cs @@ -0,0 +1,129 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2023/4/20 23:33:03 + * Description: 暂无 + ***********************************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Threading.Tasks; +using CoreCms.Net.Configuration; +using CoreCms.Net.IRepository; +using CoreCms.Net.IRepository.UnitOfWork; +using CoreCms.Net.IServices; +using CoreCms.Net.Model.Entities; +using CoreCms.Net.Model.ViewModels.Basics; +using CoreCms.Net.Model.ViewModels.UI; +using SqlSugar; + + +namespace CoreCms.Net.Services +{ + /// + /// 支付宝支付配置 接口实现 + /// + public class AlipayConfigServices : BaseServices, IAlipayConfigServices + { + private readonly IAlipayConfigRepository _dal; + private readonly IUnitOfWork _unitOfWork; + + public AlipayConfigServices(IUnitOfWork unitOfWork, IAlipayConfigRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + _unitOfWork = unitOfWork; + } + + #region 实现重写增删改查操作========================================================== + + /// + /// 重写异步插入方法 + /// + /// 实体数据 + /// + public async Task InsertAsync(CoreCmsAlipayConfig entity) + { + return await _dal.InsertAsync(entity); + } + + /// + /// 重写异步更新方法方法 + /// + /// + /// + public async Task UpdateAsync(CoreCmsAlipayConfig entity) + { + return await _dal.UpdateAsync(entity); + } + + /// + /// 重写异步更新方法方法 + /// + /// + /// + public async Task UpdateAsync(List entity) + { + return await _dal.UpdateAsync(entity); + } + + /// + /// 重写删除指定ID的数据 + /// + /// + /// + public async Task DeleteByIdAsync(object id) + { + return await _dal.DeleteByIdAsync(id); + } + + /// + /// 重写删除指定ID集合的数据(批量删除) + /// + /// + /// + public async Task DeleteByIdsAsync(int[] ids) + { + return await _dal.DeleteByIdsAsync(ids); + } + + #endregion + + #region 获取缓存的所有数据========================================================== + + /// + /// 获取缓存的所有数据 + /// + /// + public async Task> GetCaChe() + { + return await _dal.GetCaChe(); + } + + #endregion + + #region 重写根据条件查询分页数据 + /// + /// 重写根据条件查询分页数据 + /// + /// 判断集合 + /// 排序方式 + /// 当前页面索引 + /// 分布大小 + /// + /// 是否使用WITH(NOLOCK) + /// + public async Task> QueryPageAsync(Expression> predicate, + Expression> orderByExpression, OrderByType orderByType, int pageIndex = 1, + int pageSize = 20, bool blUseNoLock = false) + { + return await _dal.QueryPageAsync(predicate, orderByExpression, orderByType, pageIndex, pageSize, blUseNoLock); + } + #endregion + + } +} diff --git a/CoreCms.Net.Services/Pay/WeChatPayConfigServices.cs b/CoreCms.Net.Services/Pay/WeChatPayConfigServices.cs new file mode 100644 index 00000000..bbf16942 --- /dev/null +++ b/CoreCms.Net.Services/Pay/WeChatPayConfigServices.cs @@ -0,0 +1,129 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2023/4/20 23:42:07 + * Description: 暂无 + ***********************************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Threading.Tasks; +using CoreCms.Net.Configuration; +using CoreCms.Net.IRepository; +using CoreCms.Net.IRepository.UnitOfWork; +using CoreCms.Net.IServices; +using CoreCms.Net.Model.Entities; +using CoreCms.Net.Model.ViewModels.Basics; +using CoreCms.Net.Model.ViewModels.UI; +using SqlSugar; + + +namespace CoreCms.Net.Services +{ + /// + /// 微信支付配置 接口实现 + /// + public class WeChatPayConfigServices : BaseServices, IWeChatPayConfigServices + { + private readonly IWeChatPayConfigRepository _dal; + private readonly IUnitOfWork _unitOfWork; + + public WeChatPayConfigServices(IUnitOfWork unitOfWork, IWeChatPayConfigRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + _unitOfWork = unitOfWork; + } + + #region 实现重写增删改查操作========================================================== + + /// + /// 重写异步插入方法 + /// + /// 实体数据 + /// + public async Task InsertAsync(CoreCmsWeChatPayConfig entity) + { + return await _dal.InsertAsync(entity); + } + + /// + /// 重写异步更新方法方法 + /// + /// + /// + public async Task UpdateAsync(CoreCmsWeChatPayConfig entity) + { + return await _dal.UpdateAsync(entity); + } + + /// + /// 重写异步更新方法方法 + /// + /// + /// + public async Task UpdateAsync(List entity) + { + return await _dal.UpdateAsync(entity); + } + + /// + /// 重写删除指定ID的数据 + /// + /// + /// + public async Task DeleteByIdAsync(object id) + { + return await _dal.DeleteByIdAsync(id); + } + + /// + /// 重写删除指定ID集合的数据(批量删除) + /// + /// + /// + public async Task DeleteByIdsAsync(int[] ids) + { + return await _dal.DeleteByIdsAsync(ids); + } + + #endregion + + #region 获取缓存的所有数据========================================================== + + /// + /// 获取缓存的所有数据 + /// + /// + public async Task> GetCaChe() + { + return await _dal.GetCaChe(); + } + + #endregion + + #region 重写根据条件查询分页数据 + /// + /// 重写根据条件查询分页数据 + /// + /// 判断集合 + /// 排序方式 + /// 当前页面索引 + /// 分布大小 + /// + /// 是否使用WITH(NOLOCK) + /// + public async Task> QueryPageAsync(Expression> predicate, + Expression> orderByExpression, OrderByType orderByType, int pageIndex = 1, + int pageSize = 20, bool blUseNoLock = false) + { + return await _dal.QueryPageAsync(predicate, orderByExpression, orderByType, pageIndex, pageSize, blUseNoLock); + } + #endregion + + } +} diff --git a/CoreCms.Net.Services/Pay/WeChatPayServices.cs b/CoreCms.Net.Services/Pay/WeChatPayServices.cs index 180005ff..bc5381cf 100644 --- a/CoreCms.Net.Services/Pay/WeChatPayServices.cs +++ b/CoreCms.Net.Services/Pay/WeChatPayServices.cs @@ -9,7 +9,6 @@ ***********************************************************************/ using System; -using System.Collections.Generic; using System.Threading.Tasks; using CoreCms.Net.Auth.HttpContextUser; using CoreCms.Net.Caching.AccressToken; @@ -20,12 +19,10 @@ using CoreCms.Net.Model.Entities; using CoreCms.Net.Model.ViewModels.UI; using CoreCms.Net.Utility.Extensions; using CoreCms.Net.WeChat.Service.HttpClients; -using Essensoft.Paylink.Alipay.Domain; using Essensoft.Paylink.WeChatPay; using Essensoft.Paylink.WeChatPay.V2; using Essensoft.Paylink.WeChatPay.V2.Request; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using QRCoder; @@ -40,12 +37,11 @@ namespace CoreCms.Net.Services public class WeChatPayServices : BaseServices, IWeChatPayServices { private readonly IWeChatPayClient _client; - private readonly IOptions _optionsAccessor; private readonly IHttpContextUser _user; private readonly IServiceProvider _serviceProvider; - private readonly WeChat.Service.HttpClients.IWeChatApiHttpClientFactory _weChatApiHttpClientFactory; - + private readonly IWeChatApiHttpClientFactory _weChatApiHttpClientFactory; + private readonly IWeChatPayConfigServices _weChatPayConfigServices; private readonly ICoreCmsUserServices _userServices; private readonly ICoreCmsUserWeChatInfoServices _userWeChatInfoServices; @@ -53,18 +49,17 @@ namespace CoreCms.Net.Services public WeChatPayServices(IHttpContextUser user , IWeChatPayClient client - , IOptions optionsAccessor , ICoreCmsUserServices userServices - , ICoreCmsUserWeChatInfoServices userWeChatInfoServices, IServiceProvider serviceProvider, IWeChatApiHttpClientFactory weChatApiHttpClientFactory) + , ICoreCmsUserWeChatInfoServices userWeChatInfoServices, IServiceProvider serviceProvider, IWeChatApiHttpClientFactory weChatApiHttpClientFactory, IWeChatPayConfigServices weChatPayConfigServices) { _client = client; - _optionsAccessor = optionsAccessor; _user = user; _userServices = userServices; _userWeChatInfoServices = userWeChatInfoServices; _serviceProvider = serviceProvider; _weChatApiHttpClientFactory = weChatApiHttpClientFactory; + _weChatPayConfigServices = weChatPayConfigServices; } /// @@ -92,12 +87,13 @@ namespace CoreCms.Net.Services var accessToken = WeChatCacheAccessTokenHelper.GetWxOpenAccessToken(); var client = _weChatApiHttpClientFactory.CreateWxOpenClient(); - var getPaymentParameters = new ShopOrderGetPaymentParametersRequest(); - - getPaymentParameters.AccessToken = accessToken; - getPaymentParameters.OpenId = order.openid; - getPaymentParameters.OrderId = order.orderId; - getPaymentParameters.OutOrderId = order.outOrderId; + var getPaymentParameters = new ShopOrderGetPaymentParametersRequest + { + AccessToken = accessToken, + OpenId = order.openid, + OrderId = order.orderId, + OutOrderId = order.outOrderId + }; var shopOrderGetPayment = await client.ExecuteShopOrderGetPaymentParametersAsync(getPaymentParameters); if (shopOrderGetPayment.IsSuccessful()) @@ -121,20 +117,42 @@ namespace CoreCms.Net.Services } else { - var weChatPayUrl = AppSettingsConstVars.PayCallBackWeChatPayUrl; - if (string.IsNullOrEmpty(weChatPayUrl)) + + var tradeType = GlobalEnumVars.WeiChatPayTradeType.JSAPI.ToString(); + if (!string.IsNullOrEmpty(entity.parameters)) + { + var jObj = (JObject)JsonConvert.DeserializeObject(entity.parameters); + if (jObj != null && jObj.TryGetValue("trade_type", out var value)) + tradeType = GetTradeType(value.ObjectToString()); + } + + + var config = await _weChatPayConfigServices.QueryByClauseAsync(p => + p.isDefault == true && p.isEnable == true && p.appType == tradeType); + if (config == null) + { + jm.msg = "支付配置信息获取失败"; + return jm; + } + + if (string.IsNullOrEmpty(config.notifyUrl)) { jm.msg = "未获取到配置的通知地址"; return jm; } - var tradeType = GlobalEnumVars.WeiChatPayTradeType.JSAPI.ToString(); - if (!string.IsNullOrEmpty(entity.parameters)) + //构建linkPay请求配置实体 + var payOptions = new WeChatPayOptions { - var jobj = (JObject)JsonConvert.DeserializeObject(entity.parameters); - if (jobj != null && jobj.ContainsKey("trade_type")) - tradeType = GetTradeType(jobj["trade_type"].ObjectToString()); - } + AppId = config.appId, + MchId = config.mchId, + APIKey = config.apiKey, + APIv3Key = config.apiV3Key, + Certificate = config.certificate, + RsaPublicKey = config.rsaPublicKey, + SubAppId = config.subAppId, + SubMchId = config.subMchId + }; var openId = string.Empty; if (tradeType == GlobalEnumVars.WeiChatPayTradeType.JSAPI.ToString()) @@ -168,14 +186,14 @@ namespace CoreCms.Net.Services OutTradeNo = entity.paymentId, TotalFee = Convert.ToInt32(entity.money * 100), SpBillCreateIp = entity.ip, - NotifyUrl = weChatPayUrl, + NotifyUrl = config.notifyUrl, TradeType = tradeType, //OpenId = openId }; if (tradeType == GlobalEnumVars.WeiChatPayTradeType.JSAPI.ToString()) { - if (!string.IsNullOrEmpty(_optionsAccessor.Value.SubMchId)) + if (!string.IsNullOrEmpty(payOptions.SubMchId)) { orderRequest.SubOpenId = openId; } @@ -185,7 +203,7 @@ namespace CoreCms.Net.Services } } - var response = await _client.ExecuteAsync(orderRequest, _optionsAccessor.Value); + var response = await _client.ExecuteAsync(orderRequest, payOptions); if (response.ReturnCode == WeChatPayCode.Success && response.ResultCode == WeChatPayCode.Success) { //App微信支付 @@ -195,7 +213,7 @@ namespace CoreCms.Net.Services { PrepayId = response.PrepayId }; - var parameter = await _client.ExecuteAsync(reqApp, _optionsAccessor.Value); + var parameter = await _client.ExecuteAsync(reqApp, payOptions); parameter.Add("paymentId", entity.paymentId); jm.status = true; jm.msg = "创建微信APP支付环境成功"; @@ -210,7 +228,7 @@ namespace CoreCms.Net.Services { Package = "prepay_id=" + response.PrepayId }; - var parameter = await _client.ExecuteAsync(req, _optionsAccessor.Value); + var parameter = await _client.ExecuteAsync(req, payOptions); parameter.Add("paymentId", entity.paymentId); jm.status = true; jm.msg = "创建JSAPI支付环境成功"; @@ -268,13 +286,42 @@ namespace CoreCms.Net.Services { var jm = new WebApiCallBack(); - var weChatRefundUrl = AppSettingsConstVars.PayCallBackWeChatRefundUrl; - if (string.IsNullOrEmpty(weChatRefundUrl)) + var tradeType = GlobalEnumVars.WeiChatPayTradeType.JSAPI.ToString(); + if (!string.IsNullOrEmpty(paymentInfo.parameters)) { - jm.msg = "未获取到配置的通知地址"; + var jObj = (JObject)JsonConvert.DeserializeObject(paymentInfo.parameters); + if (jObj != null && jObj.TryGetValue("trade_type", out var value)) + tradeType = GetTradeType(value.ObjectToString()); + } + + var config = await _weChatPayConfigServices.QueryByClauseAsync(p => + p.isDefault == true && p.isEnable == true && p.appType == tradeType); + if (config == null) + { + jm.msg = "支付配置信息获取失败"; return jm; } + if (string.IsNullOrEmpty(config.refundUrl)) + { + jm.msg = "未获取到配置的退款通知地址"; + return jm; + } + + //构建linkPay请求配置实体 + var payOptions = new WeChatPayOptions + { + AppId = config.appId, + MchId = config.mchId, + APIKey = config.apiKey, + APIv3Key = config.apiV3Key, + Certificate = config.certificate, + RsaPublicKey = config.rsaPublicKey, + SubAppId = config.subAppId, + SubMchId = config.subMchId + }; + + var request = new WeChatPayRefundRequest { OutRefundNo = refundInfo.refundId, @@ -282,9 +329,9 @@ namespace CoreCms.Net.Services OutTradeNo = paymentInfo.paymentId, TotalFee = Convert.ToInt32(paymentInfo.money * 100), RefundFee = Convert.ToInt32(refundInfo.money * 100), - NotifyUrl = weChatRefundUrl + NotifyUrl = config.refundUrl }; - var response = await _client.ExecuteAsync(request, _optionsAccessor.Value); + var response = await _client.ExecuteAsync(request, payOptions); if (response.ReturnCode == WeChatPayCode.Success && response.ResultCode == WeChatPayCode.Success) { diff --git a/CoreCms.Net.Web.Admin/Controllers/Pay/CoreCmsAlipayConfigController.cs b/CoreCms.Net.Web.Admin/Controllers/Pay/CoreCmsAlipayConfigController.cs new file mode 100644 index 00000000..0c8811ef --- /dev/null +++ b/CoreCms.Net.Web.Admin/Controllers/Pay/CoreCmsAlipayConfigController.cs @@ -0,0 +1,403 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2023/4/20 23:33:03 + * Description: 暂无 + ***********************************************************************/ + + +using System; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Linq.Expressions; +using System.Threading.Tasks; +using CoreCms.Net.Configuration; +using CoreCms.Net.Model.Entities; +using CoreCms.Net.Model.Entities.Expression; +using CoreCms.Net.Model.FromBody; +using CoreCms.Net.Model.ViewModels.UI; +using CoreCms.Net.Filter; +using CoreCms.Net.Loging; +using CoreCms.Net.IServices; +using CoreCms.Net.Utility.Helper; +using CoreCms.Net.Utility.Extensions; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using NPOI.HSSF.UserModel; +using SqlSugar; + +namespace CoreCms.Net.Web.Admin.Controllers +{ + /// + /// 支付宝支付配置 + /// + [Description("支付宝支付配置")] + [Route("api/[controller]/[action]")] + [ApiController] + [RequiredErrorForAdmin] + [Authorize(Permissions.Name)] + public class CoreCmsAlipayConfigController : ControllerBase + { + private readonly IWebHostEnvironment _webHostEnvironment; + private readonly IAlipayConfigServices _coreCmsAlipayConfigServices; + + /// + /// 构造函数 + /// + public CoreCmsAlipayConfigController(IWebHostEnvironment webHostEnvironment + ,IAlipayConfigServices coreCmsAlipayConfigServices + ) + { + _webHostEnvironment = webHostEnvironment; + _coreCmsAlipayConfigServices = coreCmsAlipayConfigServices; + } + + #region 获取列表============================================================ + // POST: Api/CoreCmsAlipayConfig/GetPageList + /// + /// 获取列表 + /// + /// + [HttpPost] + [Description("获取列表")] + public async Task GetPageList() + { + var jm = new AdminUiCallBack(); + var pageCurrent = Request.Form["page"].FirstOrDefault().ObjectToInt(1); + var pageSize = Request.Form["limit"].FirstOrDefault().ObjectToInt(30); + var where = PredicateBuilder.True(); + //获取排序字段 + var orderField = Request.Form["orderField"].FirstOrDefault(); + + Expression> orderEx = orderField switch + { + "id" => p => p.id,"appId" => p => p.appId,"publicKey" => p => p.publicKey,"privateKey" => p => p.privateKey,"serverUrl" => p => p.serverUrl,"signType" => p => p.signType,"appPublicCert" => p => p.appPublicCert,"alipayPublicCert" => p => p.alipayPublicCert,"alipayRootCert" => p => p.alipayRootCert,"appType" => p => p.appType,"notifyUrl" => p => p.notifyUrl,"refundUrl" => p => p.refundUrl,"jumpUrl" => p => p.jumpUrl,"isEnable" => p => p.isEnable,"isDefault" => p => p.isDefault, + _ => p => p.id + }; + + //设置排序方式 + var orderDirection = Request.Form["orderDirection"].FirstOrDefault(); + var orderBy = orderDirection switch + { + "asc" => OrderByType.Asc, + "desc" => OrderByType.Desc, + _ => OrderByType.Desc + }; + //查询筛选 + + //序列 int + var id = Request.Form["id"].FirstOrDefault().ObjectToInt(0); + if (id > 0) + { + where = where.And(p => p.id == id); + } + //支付宝开放平台AppId varchar + var appId = Request.Form["appId"].FirstOrDefault(); + if (!string.IsNullOrEmpty(appId)) + { + where = where.And(p => p.appId.Contains(appId)); + } + //支付宝公钥 varchar + var publicKey = Request.Form["publicKey"].FirstOrDefault(); + if (!string.IsNullOrEmpty(publicKey)) + { + where = where.And(p => p.publicKey.Contains(publicKey)); + } + //应用私钥 varchar + var privateKey = Request.Form["privateKey"].FirstOrDefault(); + if (!string.IsNullOrEmpty(privateKey)) + { + where = where.And(p => p.privateKey.Contains(privateKey)); + } + //服务网关地址 varchar + var serverUrl = Request.Form["serverUrl"].FirstOrDefault(); + if (!string.IsNullOrEmpty(serverUrl)) + { + where = where.And(p => p.serverUrl.Contains(serverUrl)); + } + //签名类型 varchar + var signType = Request.Form["signType"].FirstOrDefault(); + if (!string.IsNullOrEmpty(signType)) + { + where = where.And(p => p.signType.Contains(signType)); + } + //应用公钥证书 varchar + var appPublicCert = Request.Form["appPublicCert"].FirstOrDefault(); + if (!string.IsNullOrEmpty(appPublicCert)) + { + where = where.And(p => p.appPublicCert.Contains(appPublicCert)); + } + //支付宝公钥证书 varchar + var alipayPublicCert = Request.Form["alipayPublicCert"].FirstOrDefault(); + if (!string.IsNullOrEmpty(alipayPublicCert)) + { + where = where.And(p => p.alipayPublicCert.Contains(alipayPublicCert)); + } + //支付宝根证书 varchar + var alipayRootCert = Request.Form["alipayRootCert"].FirstOrDefault(); + if (!string.IsNullOrEmpty(alipayRootCert)) + { + where = where.And(p => p.alipayRootCert.Contains(alipayRootCert)); + } + //应用类型 varchar + var appType = Request.Form["appType"].FirstOrDefault(); + if (!string.IsNullOrEmpty(appType)) + { + where = where.And(p => p.appType.Contains(appType)); + } + //支付宝支付回调通知 varchar + var notifyUrl = Request.Form["notifyUrl"].FirstOrDefault(); + if (!string.IsNullOrEmpty(notifyUrl)) + { + where = where.And(p => p.notifyUrl.Contains(notifyUrl)); + } + //支付宝退款回调 varchar + var refundUrl = Request.Form["refundUrl"].FirstOrDefault(); + if (!string.IsNullOrEmpty(refundUrl)) + { + where = where.And(p => p.refundUrl.Contains(refundUrl)); + } + //支付跳转地址 varchar + var jumpUrl = Request.Form["jumpUrl"].FirstOrDefault(); + if (!string.IsNullOrEmpty(jumpUrl)) + { + where = where.And(p => p.jumpUrl.Contains(jumpUrl)); + } + //是否启用 bit + var isEnable = Request.Form["isEnable"].FirstOrDefault(); + if (!string.IsNullOrEmpty(isEnable) && isEnable.ToLowerInvariant() == "true") + { + where = where.And(p => p.isEnable == true); + } + else if (!string.IsNullOrEmpty(isEnable) && isEnable.ToLowerInvariant() == "false") + { + where = where.And(p => p.isEnable == false); + } + //当前多端默认 bit + var isDefault = Request.Form["isDefault"].FirstOrDefault(); + if (!string.IsNullOrEmpty(isDefault) && isDefault.ToLowerInvariant() == "true") + { + where = where.And(p => p.isDefault == true); + } + else if (!string.IsNullOrEmpty(isDefault) && isDefault.ToLowerInvariant() == "false") + { + where = where.And(p => p.isDefault == false); + } + //获取数据 + var list = await _coreCmsAlipayConfigServices.QueryPageAsync(where, orderEx, orderBy, pageCurrent, pageSize, true); + //返回数据 + jm.data = list; + jm.code = 0; + jm.count = list.TotalCount; + jm.msg = "数据调用成功!"; + return jm; + } + #endregion + + #region 首页数据============================================================ + // POST: Api/CoreCmsAlipayConfig/GetIndex + /// + /// 首页数据 + /// + /// + [HttpPost] + [Description("首页数据")] + public AdminUiCallBack GetIndex() + { + //返回数据 + var jm = new AdminUiCallBack { code = 0 }; + return jm; + } + #endregion + + #region 创建数据============================================================ + // POST: Api/CoreCmsAlipayConfig/GetCreate + /// + /// 创建数据 + /// + /// + [HttpPost] + [Description("创建数据")] + public AdminUiCallBack GetCreate() + { + //返回数据 + var jm = new AdminUiCallBack { code = 0 }; + return jm; + } + #endregion + + #region 创建提交============================================================ + // POST: Api/CoreCmsAlipayConfig/DoCreate + /// + /// 创建提交 + /// + /// + /// + [HttpPost] + [Description("创建提交")] + public async Task DoCreate([FromBody]CoreCmsAlipayConfig entity) + { + var jm = await _coreCmsAlipayConfigServices.InsertAsync(entity); + return jm; + } + #endregion + + #region 编辑数据============================================================ + // POST: Api/CoreCmsAlipayConfig/GetEdit + /// + /// 编辑数据 + /// + /// + /// + [HttpPost] + [Description("编辑数据")] + public async Task GetEdit([FromBody]FMIntId entity) + { + var jm = new AdminUiCallBack(); + + var model = await _coreCmsAlipayConfigServices.QueryByIdAsync(entity.id, false); + if (model == null) + { + jm.msg = "不存在此信息"; + return jm; + } + jm.code = 0; + jm.data = model; + + return jm; + } + #endregion + + #region 编辑提交============================================================ + // POST: Api/CoreCmsAlipayConfig/Edit + /// + /// 编辑提交 + /// + /// + /// + [HttpPost] + [Description("编辑提交")] + public async Task DoEdit([FromBody]CoreCmsAlipayConfig entity) + { + var jm = await _coreCmsAlipayConfigServices.UpdateAsync(entity); + return jm; + } + #endregion + + #region 删除数据============================================================ + // POST: Api/CoreCmsAlipayConfig/DoDelete/10 + /// + /// 单选删除 + /// + /// + /// + [HttpPost] + [Description("单选删除")] + public async Task DoDelete([FromBody]FMIntId entity) + { + var jm = new AdminUiCallBack(); + + var model = await _coreCmsAlipayConfigServices.ExistsAsync(p => p.id == entity.id, true); + if (!model) + { + jm.msg = GlobalConstVars.DataisNo; + return jm; + } + jm = await _coreCmsAlipayConfigServices.DeleteByIdAsync(entity.id); + + return jm; + } + #endregion + + #region 预览数据============================================================ + // POST: Api/CoreCmsAlipayConfig/GetDetails/10 + /// + /// 预览数据 + /// + /// + /// + [HttpPost] + [Description("预览数据")] + public async Task GetDetails([FromBody]FMIntId entity) + { + var jm = new AdminUiCallBack(); + + var model = await _coreCmsAlipayConfigServices.QueryByIdAsync(entity.id, false); + if (model == null) + { + jm.msg = "不存在此信息"; + return jm; + } + jm.code = 0; + jm.data = model; + + return jm; + } + #endregion + + #region 设置是否启用============================================================ + // POST: Api/CoreCmsAlipayConfig/DoSetisEnable/10 + /// + /// 设置是否启用 + /// + /// + /// + [HttpPost] + [Description("设置是否启用")] + public async Task DoSetisEnable([FromBody]FMUpdateBoolDataByIntId entity) + { + var jm = new AdminUiCallBack(); + + var oldModel = await _coreCmsAlipayConfigServices.QueryByIdAsync(entity.id, false); + if (oldModel == null) + { + jm.msg = "不存在此信息"; + return jm; + } + oldModel.isEnable = (bool)entity.data; + + var bl = await _coreCmsAlipayConfigServices.UpdateAsync(p => new CoreCmsAlipayConfig() { isEnable = oldModel.isEnable }, p => p.id == oldModel.id); + jm.code = bl ? 0 : 1; + jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure; + + return jm; + } + #endregion + + #region 设置当前多端默认============================================================ + // POST: Api/CoreCmsAlipayConfig/DoSetisDefault/10 + /// + /// 设置当前多端默认 + /// + /// + /// + [HttpPost] + [Description("设置当前多端默认")] + public async Task DoSetisDefault([FromBody]FMUpdateBoolDataByIntId entity) + { + var jm = new AdminUiCallBack(); + + var oldModel = await _coreCmsAlipayConfigServices.QueryByIdAsync(entity.id, false); + if (oldModel == null) + { + jm.msg = "不存在此信息"; + return jm; + } + oldModel.isDefault = (bool)entity.data; + + var bl = await _coreCmsAlipayConfigServices.UpdateAsync(p => new CoreCmsAlipayConfig() { isDefault = oldModel.isDefault }, p => p.id == oldModel.id); + jm.code = bl ? 0 : 1; + jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure; + + return jm; + } + #endregion + + + } +} diff --git a/CoreCms.Net.Web.Admin/Controllers/Pay/CoreCmsWeChatPayConfigController.cs b/CoreCms.Net.Web.Admin/Controllers/Pay/CoreCmsWeChatPayConfigController.cs new file mode 100644 index 00000000..8fb06068 --- /dev/null +++ b/CoreCms.Net.Web.Admin/Controllers/Pay/CoreCmsWeChatPayConfigController.cs @@ -0,0 +1,438 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2023/4/22 23:40:15 + * Description: 暂无 + ***********************************************************************/ + + +using System; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Linq.Expressions; +using System.Threading.Tasks; +using CoreCms.Net.Configuration; +using CoreCms.Net.Model.Entities; +using CoreCms.Net.Model.Entities.Expression; +using CoreCms.Net.Model.FromBody; +using CoreCms.Net.Model.ViewModels.UI; +using CoreCms.Net.Filter; +using CoreCms.Net.Loging; +using CoreCms.Net.IServices; +using CoreCms.Net.Utility.Helper; +using CoreCms.Net.Utility.Extensions; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using NPOI.HSSF.UserModel; +using SqlSugar; +using static CoreCms.Net.Configuration.GlobalEnumVars; + +namespace CoreCms.Net.Web.Admin.Controllers +{ + /// + /// 微信支付配置 + /// + [Description("微信支付配置")] + [Route("api/[controller]/[action]")] + [ApiController] + [RequiredErrorForAdmin] + [Authorize(Permissions.Name)] + public class CoreCmsWeChatPayConfigController : ControllerBase + { + private readonly IWebHostEnvironment _webHostEnvironment; + private readonly IWeChatPayConfigServices _coreCmsWeChatPayConfigServices; + + /// + /// 构造函数 + /// + public CoreCmsWeChatPayConfigController(IWebHostEnvironment webHostEnvironment + , IWeChatPayConfigServices coreCmsWeChatPayConfigServices + ) + { + _webHostEnvironment = webHostEnvironment; + _coreCmsWeChatPayConfigServices = coreCmsWeChatPayConfigServices; + } + + #region 获取列表============================================================ + // POST: Api/CoreCmsWeChatPayConfig/GetPageList + /// + /// 获取列表 + /// + /// + [HttpPost] + [Description("获取列表")] + public async Task GetPageList() + { + var jm = new AdminUiCallBack(); + var pageCurrent = Request.Form["page"].FirstOrDefault().ObjectToInt(1); + var pageSize = Request.Form["limit"].FirstOrDefault().ObjectToInt(30); + var where = PredicateBuilder.True(); + //获取排序字段 + var orderField = Request.Form["orderField"].FirstOrDefault(); + + Expression> orderEx = orderField switch + { + "id" => p => p.id, + "appId" => p => p.appId, + "mchId" => p => p.mchId, + "apiKey" => p => p.apiKey, + "apiV3Key" => p => p.apiV3Key, + "certificate" => p => p.certificate, + "rsaPublicKey" => p => p.rsaPublicKey, + "subAppId" => p => p.subAppId, + "subMchId" => p => p.subMchId, + "notifyUrl" => p => p.notifyUrl, + "refundUrl" => p => p.refundUrl, + "jumpUrl" => p => p.jumpUrl, + "isEnable" => p => p.isEnable, + "isDefault" => p => p.isDefault, + "appType" => p => p.appType, + _ => p => p.id + }; + + //设置排序方式 + var orderDirection = Request.Form["orderDirection"].FirstOrDefault(); + var orderBy = orderDirection switch + { + "asc" => OrderByType.Asc, + "desc" => OrderByType.Desc, + _ => OrderByType.Desc + }; + //查询筛选 + + //序列 int + var id = Request.Form["id"].FirstOrDefault().ObjectToInt(0); + if (id > 0) + { + where = where.And(p => p.id == id); + } + //应用号 varchar + var appId = Request.Form["appId"].FirstOrDefault(); + if (!string.IsNullOrEmpty(appId)) + { + where = where.And(p => p.appId.Contains(appId)); + } + //商户号 varchar + var mchId = Request.Form["mchId"].FirstOrDefault(); + if (!string.IsNullOrEmpty(mchId)) + { + where = where.And(p => p.mchId.Contains(mchId)); + } + //API秘钥 varchar + var apiKey = Request.Form["apiKey"].FirstOrDefault(); + if (!string.IsNullOrEmpty(apiKey)) + { + where = where.And(p => p.apiKey.Contains(apiKey)); + } + //APIv3密钥 varchar + var apiV3Key = Request.Form["apiV3Key"].FirstOrDefault(); + if (!string.IsNullOrEmpty(apiV3Key)) + { + where = where.And(p => p.apiV3Key.Contains(apiV3Key)); + } + //p12证书base64 varchar + var certificate = Request.Form["certificate"].FirstOrDefault(); + if (!string.IsNullOrEmpty(certificate)) + { + where = where.And(p => p.certificate.Contains(certificate)); + } + //RSA公钥 varchar + var rsaPublicKey = Request.Form["rsaPublicKey"].FirstOrDefault(); + if (!string.IsNullOrEmpty(rsaPublicKey)) + { + where = where.And(p => p.rsaPublicKey.Contains(rsaPublicKey)); + } + //子商户应用号 varchar + var subAppId = Request.Form["subAppId"].FirstOrDefault(); + if (!string.IsNullOrEmpty(subAppId)) + { + where = where.And(p => p.subAppId.Contains(subAppId)); + } + //子商户号 varchar + var subMchId = Request.Form["subMchId"].FirstOrDefault(); + if (!string.IsNullOrEmpty(subMchId)) + { + where = where.And(p => p.subMchId.Contains(subMchId)); + } + //支付回调通知 varchar + var notifyUrl = Request.Form["notifyUrl"].FirstOrDefault(); + if (!string.IsNullOrEmpty(notifyUrl)) + { + where = where.And(p => p.notifyUrl.Contains(notifyUrl)); + } + //退款回调 varchar + var refundUrl = Request.Form["refundUrl"].FirstOrDefault(); + if (!string.IsNullOrEmpty(refundUrl)) + { + where = where.And(p => p.refundUrl.Contains(refundUrl)); + } + //跳转地址 varchar + var jumpUrl = Request.Form["jumpUrl"].FirstOrDefault(); + if (!string.IsNullOrEmpty(jumpUrl)) + { + where = where.And(p => p.jumpUrl.Contains(jumpUrl)); + } + //是否开启 bit + var isEnable = Request.Form["isEnable"].FirstOrDefault(); + if (!string.IsNullOrEmpty(isEnable) && isEnable.ToLowerInvariant() == "true") + { + where = where.And(p => p.isEnable == true); + } + else if (!string.IsNullOrEmpty(isEnable) && isEnable.ToLowerInvariant() == "false") + { + where = where.And(p => p.isEnable == false); + } + //是否本类默认 bit + var isDefault = Request.Form["isDefault"].FirstOrDefault(); + if (!string.IsNullOrEmpty(isDefault) && isDefault.ToLowerInvariant() == "true") + { + where = where.And(p => p.isDefault == true); + } + else if (!string.IsNullOrEmpty(isDefault) && isDefault.ToLowerInvariant() == "false") + { + where = where.And(p => p.isDefault == false); + } + //应用类型 varchar + var appType = Request.Form["appType"].FirstOrDefault(); + if (!string.IsNullOrEmpty(appType)) + { + where = where.And(p => p.appType.Contains(appType)); + } + //获取数据 + var list = await _coreCmsWeChatPayConfigServices.QueryPageAsync(where, orderEx, orderBy, pageCurrent, pageSize, true); + //返回数据 + jm.data = list; + jm.code = 0; + jm.count = list.TotalCount; + jm.msg = "数据调用成功!"; + return jm; + } + #endregion + + #region 首页数据============================================================ + // POST: Api/CoreCmsWeChatPayConfig/GetIndex + /// + /// 首页数据 + /// + /// + [HttpPost] + [Description("首页数据")] + public AdminUiCallBack GetIndex() + { + //返回数据 + var jm = new AdminUiCallBack { code = 0 }; + + var weiChatPayTradeType = EnumHelper.EnumToList(); + jm.data = new + { + weiChatPayTradeType + }; + + return jm; + } + #endregion + + #region 创建数据============================================================ + // POST: Api/CoreCmsWeChatPayConfig/GetCreate + /// + /// 创建数据 + /// + /// + [HttpPost] + [Description("创建数据")] + public AdminUiCallBack GetCreate() + { + //返回数据 + var jm = new AdminUiCallBack { code = 0 }; + + var weiChatPayTradeType = EnumHelper.EnumToList(); + jm.data = new + { + weiChatPayTradeType + }; + + return jm; + } + #endregion + + #region 创建提交============================================================ + // POST: Api/CoreCmsWeChatPayConfig/DoCreate + /// + /// 创建提交 + /// + /// + /// + [HttpPost] + [Description("创建提交")] + public async Task DoCreate([FromBody] CoreCmsWeChatPayConfig entity) + { + var jm = await _coreCmsWeChatPayConfigServices.InsertAsync(entity); + return jm; + } + #endregion + + #region 编辑数据============================================================ + // POST: Api/CoreCmsWeChatPayConfig/GetEdit + /// + /// 编辑数据 + /// + /// + /// + [HttpPost] + [Description("编辑数据")] + public async Task GetEdit([FromBody] FMIntId entity) + { + var jm = new AdminUiCallBack(); + + var model = await _coreCmsWeChatPayConfigServices.QueryByIdAsync(entity.id, false); + if (model == null) + { + jm.msg = "不存在此信息"; + return jm; + } + jm.code = 0; + + var weiChatPayTradeType = EnumHelper.EnumToList(); + jm.data = new + { + model, + weiChatPayTradeType + }; + + return jm; + } + #endregion + + #region 编辑提交============================================================ + // POST: Api/CoreCmsWeChatPayConfig/Edit + /// + /// 编辑提交 + /// + /// + /// + [HttpPost] + [Description("编辑提交")] + public async Task DoEdit([FromBody] CoreCmsWeChatPayConfig entity) + { + var jm = await _coreCmsWeChatPayConfigServices.UpdateAsync(entity); + return jm; + } + #endregion + + #region 删除数据============================================================ + // POST: Api/CoreCmsWeChatPayConfig/DoDelete/10 + /// + /// 单选删除 + /// + /// + /// + [HttpPost] + [Description("单选删除")] + public async Task DoDelete([FromBody] FMIntId entity) + { + var jm = new AdminUiCallBack(); + + var model = await _coreCmsWeChatPayConfigServices.ExistsAsync(p => p.id == entity.id, true); + if (!model) + { + jm.msg = GlobalConstVars.DataisNo; + return jm; + } + jm = await _coreCmsWeChatPayConfigServices.DeleteByIdAsync(entity.id); + + return jm; + } + #endregion + + #region 预览数据============================================================ + // POST: Api/CoreCmsWeChatPayConfig/GetDetails/10 + /// + /// 预览数据 + /// + /// + /// + [HttpPost] + [Description("预览数据")] + public async Task GetDetails([FromBody] FMIntId entity) + { + var jm = new AdminUiCallBack(); + + var model = await _coreCmsWeChatPayConfigServices.QueryByIdAsync(entity.id, false); + if (model == null) + { + jm.msg = "不存在此信息"; + return jm; + } + jm.code = 0; + jm.data = model; + + return jm; + } + #endregion + + #region 设置是否开启============================================================ + // POST: Api/CoreCmsWeChatPayConfig/DoSetisEnable/10 + /// + /// 设置是否开启 + /// + /// + /// + [HttpPost] + [Description("设置是否开启")] + public async Task DoSetisEnable([FromBody] FMUpdateBoolDataByIntId entity) + { + var jm = new AdminUiCallBack(); + + var oldModel = await _coreCmsWeChatPayConfigServices.QueryByIdAsync(entity.id, false); + if (oldModel == null) + { + jm.msg = "不存在此信息"; + return jm; + } + oldModel.isEnable = (bool)entity.data; + + var bl = await _coreCmsWeChatPayConfigServices.UpdateAsync(p => new CoreCmsWeChatPayConfig() { isEnable = oldModel.isEnable }, p => p.id == oldModel.id); + jm.code = bl ? 0 : 1; + jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure; + + return jm; + } + #endregion + + #region 设置是否本类默认============================================================ + // POST: Api/CoreCmsWeChatPayConfig/DoSetisDefault/10 + /// + /// 设置是否本类默认 + /// + /// + /// + [HttpPost] + [Description("设置是否本类默认")] + public async Task DoSetisDefault([FromBody] FMUpdateBoolDataByIntId entity) + { + var jm = new AdminUiCallBack(); + + var oldModel = await _coreCmsWeChatPayConfigServices.QueryByIdAsync(entity.id, false); + if (oldModel == null) + { + jm.msg = "不存在此信息"; + return jm; + } + oldModel.isDefault = (bool)entity.data; + + var bl = await _coreCmsWeChatPayConfigServices.UpdateAsync(p => new CoreCmsWeChatPayConfig() { isDefault = oldModel.isDefault }, p => p.id == oldModel.id); + jm.code = bl ? 0 : 1; + jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure; + + return jm; + } + #endregion + + + } +} diff --git a/CoreCms.Net.Web.Admin/CoreCms.Net.Web.Admin.xml b/CoreCms.Net.Web.Admin/CoreCms.Net.Web.Admin.xml index af2b2539..8c29e789 100644 --- a/CoreCms.Net.Web.Admin/CoreCms.Net.Web.Admin.xml +++ b/CoreCms.Net.Web.Admin/CoreCms.Net.Web.Admin.xml @@ -2727,6 +2727,160 @@ + + + 支付宝支付配置 + + + + + 构造函数 + + + + + 获取列表 + + + + + + 首页数据 + + + + + + 创建数据 + + + + + + 创建提交 + + + + + + + 编辑数据 + + + + + + + 编辑提交 + + + + + + + 单选删除 + + + + + + + 预览数据 + + + + + + + 设置是否启用 + + + + + + + 设置当前多端默认 + + + + + + + 微信支付配置 + + + + + 构造函数 + + + + + 获取列表 + + + + + + 首页数据 + + + + + + 创建数据 + + + + + + 创建提交 + + + + + + + 编辑数据 + + + + + + + 编辑提交 + + + + + + + 单选删除 + + + + + + + 预览数据 + + + + + + + 设置是否开启 + + + + + + + 设置是否本类默认 + + + + 拼团记录表 diff --git a/CoreCms.Net.Web.Admin/Program.cs b/CoreCms.Net.Web.Admin/Program.cs index 7aa24ece..5c8cd435 100644 --- a/CoreCms.Net.Web.Admin/Program.cs +++ b/CoreCms.Net.Web.Admin/Program.cs @@ -54,10 +54,6 @@ builder.Services.AddAutoMapper(typeof(AutoMapperConfiguration)); builder.Services.AddAlipay(); builder.Services.AddWeChatPay(); -// 在 appsettings.json 中 配置选项 -builder.Services.Configure(builder.Configuration.GetSection("WeChatPay")); -builder.Services.Configure(builder.Configuration.GetSection("Alipay")); - //注册自定义微信接口配置文件 builder.Services.Configure(builder.Configuration.GetSection(nameof(CoreCms.Net.WeChat.Service.Options.WeChatOptions))); diff --git a/CoreCms.Net.Web.Admin/appsettings.json b/CoreCms.Net.Web.Admin/appsettings.json index 7b6b15fb..5b4d7dd5 100644 --- a/CoreCms.Net.Web.Admin/appsettings.json +++ b/CoreCms.Net.Web.Admin/appsettings.json @@ -138,87 +138,6 @@ } }, "AllowedHosts": "*", - // 微信支付 - // 更多配置,请查看WeChatPayOptions类 - "WeChatPay": { - // 应用号 - // 如:微信公众平台AppId、微信开放平台AppId、微信小程序AppId、企业微信CorpId等 - "AppId": "", - // 商户号 - // 为微信支付商户平台的商户号 - "MchId": "", - // API密钥 - // 为微信支付商户平台的API密钥,请注意不是APIv3密钥 - "APIKey": "", - // APIv3密钥 - // 为微信支付商户平台的APIv3密钥,请注意不是API密钥,v3接口必填 - "APIv3Key": "", - // API证书(.p12) - // 为微信支付商户平台的API证书(.p12),v3接口必填 - // 可为证书文件(.p12)路径 / 证书文件(.p12)的base64字符串 - //以下格式为windows服务器下路径格式,linux下格式为 WxPayCert/apiclient_cert.p12 - "Certificate": "WxPayCert\\apiclient_cert.p12", - // RSA公钥 - // 目前仅调用"企业付款到银行卡API"时使用,执行本示例中的"获取RSA加密公钥API"即可获取。 - "RsaPublicKey": "", - // 子商户应用号(目前仅调用服务商API时使用,子商户的公众号、移动应用AppId。) - "SubAppId": "", - // 子商户号(目前仅调用服务商API时使用,子商户的商户号。) - "SubMchId": "" - }, - // 支付宝(暂未开通) - // 更多配置,请查看AlipayOptions类 - "Alipay": { - // 注意: - // 若涉及资金类支出接口(如转账、红包等)接入,必须使用“公钥证书”方式。不涉及到资金类接口,也可以使用“普通公钥”方式进行加签。 - // 本示例默认的加签方式为“公钥证书”方式,并调用 CertificateExecuteAsync 方法 执行API。 - // 若使用“普通公钥”方式,除了遵守下方注释的规则外,调用 CertificateExecuteAsync 也需改成 ExecuteAsync。 - // 支付宝后台密钥/证书官方配置教程:https://opendocs.alipay.com/open/291/105971 - // 密钥格式:请选择 PKCS1(非JAVA适用),切记 切记 切记 - // 应用Id - // 为支付宝开放平台-APPID - "AppId": "", - // 支付宝公钥 RSA公钥 - // 为支付宝开放平台-支付宝公钥 - // “公钥证书”方式时,留空 - // “普通公钥”方式时,必填 - "AlipayPublicKey": "", - // 应用私钥 RSA私钥 - // 为“支付宝开放平台开发助手”所生成的应用私钥 - "AppPrivateKey": "", - // 服务网关地址 - // 默认为正式环境地址 - "ServerUrl": "https://openapi.alipay.com/gateway.do", - // 签名类型 - // 支持:RSA2(SHA256WithRSA)、RSA1(SHA1WithRSA) - // 默认为RSA2 - "SignType": "RSA2", - // 应用公钥证书 - // 可为证书文件路径 / 证书文件的base64字符串 - // “公钥证书”方式时,必填 - // “普通公钥”方式时,留空 - "AppPublicCert": "", - // 支付宝公钥证书 - // 可为证书文件路径 / 证书文件的base64字符串 - // “公钥证书”方式时,必填 - // “普通公钥”方式时,留空 - "AlipayPublicCert": "", - // 支付宝根证书 - // 可为证书文件路径 / 证书文件的base64字符串 - // “公钥证书”方式时,必填 - // “普通公钥”方式时,留空 - "AlipayRootCert": "" - }, - "PayCallBack": { - //微信支付回调 - "WeChatPayUrl": "https://api.test.pro.coreshop.cn/Notify/WeChatPay/Unifiedorder", - //微信退款回调 - "WeChatRefundUrl": "https://api.test.pro.coreshop.cn/Notify/WeChatPay/Refund", - //支付宝支付回调 - "AlipayUrl": "https://api.test.pro.coreshop.cn/Notify/AliPay/Unifiedorder", - //支付宝退款回调 - "AlipayRefundUrl": "" - }, "WeChatOptions": { //公众号 "WeiXinAppId": "", diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/shop/pay/alipayconfig/create.html b/CoreCms.Net.Web.Admin/wwwroot/views/shop/pay/alipayconfig/create.html new file mode 100644 index 00000000..926f6a58 --- /dev/null +++ b/CoreCms.Net.Web.Admin/wwwroot/views/shop/pay/alipayconfig/create.html @@ -0,0 +1,208 @@ + + diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/shop/pay/alipayconfig/details.html b/CoreCms.Net.Web.Admin/wwwroot/views/shop/pay/alipayconfig/details.html new file mode 100644 index 00000000..ba9c7106 --- /dev/null +++ b/CoreCms.Net.Web.Admin/wwwroot/views/shop/pay/alipayconfig/details.html @@ -0,0 +1,162 @@ + + \ No newline at end of file diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/shop/pay/alipayconfig/edit.html b/CoreCms.Net.Web.Admin/wwwroot/views/shop/pay/alipayconfig/edit.html new file mode 100644 index 00000000..c40f0a25 --- /dev/null +++ b/CoreCms.Net.Web.Admin/wwwroot/views/shop/pay/alipayconfig/edit.html @@ -0,0 +1,186 @@ + + diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/shop/pay/alipayconfig/index.html b/CoreCms.Net.Web.Admin/wwwroot/views/shop/pay/alipayconfig/index.html new file mode 100644 index 00000000..521a7071 --- /dev/null +++ b/CoreCms.Net.Web.Admin/wwwroot/views/shop/pay/alipayconfig/index.html @@ -0,0 +1,368 @@ +支付宝支付配置 + +
+
+ +
+
+ + + +
+
+
+ + + + + + + + + + + + + + + diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/shop/pay/wechatpayconfig/create.html b/CoreCms.Net.Web.Admin/wwwroot/views/shop/pay/wechatpayconfig/create.html new file mode 100644 index 00000000..98588058 --- /dev/null +++ b/CoreCms.Net.Web.Admin/wwwroot/views/shop/pay/wechatpayconfig/create.html @@ -0,0 +1,173 @@ + + diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/shop/pay/wechatpayconfig/details.html b/CoreCms.Net.Web.Admin/wwwroot/views/shop/pay/wechatpayconfig/details.html new file mode 100644 index 00000000..a5253f13 --- /dev/null +++ b/CoreCms.Net.Web.Admin/wwwroot/views/shop/pay/wechatpayconfig/details.html @@ -0,0 +1,161 @@ + + \ No newline at end of file diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/shop/pay/wechatpayconfig/edit.html b/CoreCms.Net.Web.Admin/wwwroot/views/shop/pay/wechatpayconfig/edit.html new file mode 100644 index 00000000..919ccabe --- /dev/null +++ b/CoreCms.Net.Web.Admin/wwwroot/views/shop/pay/wechatpayconfig/edit.html @@ -0,0 +1,154 @@ + + diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/shop/pay/wechatpayconfig/index.html b/CoreCms.Net.Web.Admin/wwwroot/views/shop/pay/wechatpayconfig/index.html new file mode 100644 index 00000000..fee080c6 --- /dev/null +++ b/CoreCms.Net.Web.Admin/wwwroot/views/shop/pay/wechatpayconfig/index.html @@ -0,0 +1,364 @@ +微信支付配置 + +
+
+ +
+
+ + + +
+
+
+ + + + + + + + + + + + + + + diff --git a/CoreCms.Net.Web.WebApi/Program.cs b/CoreCms.Net.Web.WebApi/Program.cs index 1f195463..2661463d 100644 --- a/CoreCms.Net.Web.WebApi/Program.cs +++ b/CoreCms.Net.Web.WebApi/Program.cs @@ -64,10 +64,6 @@ builder.Services.AddRedisMessageQueueSetup(); builder.Services.AddAlipay(); builder.Services.AddWeChatPay(); -// 在 appsettings.json 中 配置选项 -builder.Services.Configure(builder.Configuration.GetSection("WeChatPay")); -builder.Services.Configure(builder.Configuration.GetSection("Alipay")); - //注册自定义微信接口配置文件 builder.Services.Configure(builder.Configuration.GetSection(nameof(CoreCms.Net.WeChat.Service.Options.WeChatOptions))); diff --git a/CoreCms.Net.Web.WebApi/appsettings.json b/CoreCms.Net.Web.WebApi/appsettings.json index a0040fad..bd56011b 100644 --- a/CoreCms.Net.Web.WebApi/appsettings.json +++ b/CoreCms.Net.Web.WebApi/appsettings.json @@ -138,87 +138,6 @@ } }, "AllowedHosts": "*", - // 微信支付 - // 更多配置,请查看WeChatPayOptions类 - "WeChatPay": { - // 应用号 - // 如:微信公众平台AppId、微信开放平台AppId、微信小程序AppId、企业微信CorpId等 - "AppId": "", - // 商户号 - // 为微信支付商户平台的商户号 - "MchId": "", - // API密钥 - // 为微信支付商户平台的API密钥,请注意不是APIv3密钥 - "APIKey": "", - // APIv3密钥 - // 为微信支付商户平台的APIv3密钥,请注意不是API密钥,v3接口必填 - "APIv3Key": "", - // API证书(.p12) - // 为微信支付商户平台的API证书(.p12),v3接口必填 - // 可为证书文件(.p12)路径 / 证书文件(.p12)的base64字符串 - //以下格式为windows服务器下路径格式,linux下格式为 WxPayCert/apiclient_cert.p12 - "Certificate": "WxPayCert\\apiclient_cert.p12", - // RSA公钥 - // 目前仅调用"企业付款到银行卡API"时使用,执行本示例中的"获取RSA加密公钥API"即可获取。 - "RsaPublicKey": "", - // 子商户应用号(目前仅调用服务商API时使用,子商户的公众号、移动应用AppId。) - "SubAppId": "", - // 子商户号(目前仅调用服务商API时使用,子商户的商户号。) - "SubMchId": "" - }, - // 支付宝(暂未开通) - // 更多配置,请查看AlipayOptions类 - "Alipay": { - // 注意: - // 若涉及资金类支出接口(如转账、红包等)接入,必须使用“公钥证书”方式。不涉及到资金类接口,也可以使用“普通公钥”方式进行加签。 - // 本示例默认的加签方式为“公钥证书”方式,并调用 CertificateExecuteAsync 方法 执行API。 - // 若使用“普通公钥”方式,除了遵守下方注释的规则外,调用 CertificateExecuteAsync 也需改成 ExecuteAsync。 - // 支付宝后台密钥/证书官方配置教程:https://opendocs.alipay.com/open/291/105971 - // 密钥格式:请选择 PKCS1(非JAVA适用),切记 切记 切记 - // 应用Id - // 为支付宝开放平台-APPID - "AppId": "", - // 支付宝公钥 RSA公钥 - // 为支付宝开放平台-支付宝公钥 - // “公钥证书”方式时,留空 - // “普通公钥”方式时,必填 - "AlipayPublicKey": "", - // 应用私钥 RSA私钥 - // 为“支付宝开放平台开发助手”所生成的应用私钥 - "AppPrivateKey": "", - // 服务网关地址 - // 默认为正式环境地址 - "ServerUrl": "https://openapi.alipay.com/gateway.do", - // 签名类型 - // 支持:RSA2(SHA256WithRSA)、RSA1(SHA1WithRSA) - // 默认为RSA2 - "SignType": "RSA2", - // 应用公钥证书 - // 可为证书文件路径 / 证书文件的base64字符串 - // “公钥证书”方式时,必填 - // “普通公钥”方式时,留空 - "AppPublicCert": "", - // 支付宝公钥证书 - // 可为证书文件路径 / 证书文件的base64字符串 - // “公钥证书”方式时,必填 - // “普通公钥”方式时,留空 - "AlipayPublicCert": "", - // 支付宝根证书 - // 可为证书文件路径 / 证书文件的base64字符串 - // “公钥证书”方式时,必填 - // “普通公钥”方式时,留空 - "AlipayRootCert": "" - }, - "PayCallBack": { - //微信支付回调 - "WeChatPayUrl": "https://api.test.pro.coreshop.cn/Notify/WeChatPay/Unifiedorder", - //微信退款回调 - "WeChatRefundUrl": "https://api.test.pro.coreshop.cn/Notify/WeChatPay/Refund", - //支付宝支付回调 - "AlipayUrl": "https://api.test.pro.coreshop.cn/Notify/AliPay/Unifiedorder", - //支付宝退款回调 - "AlipayRefundUrl": "" - }, "WeChatOptions": { //公众号 "WeiXinAppId": "", diff --git a/数据库/MySql/20230424/升级脚本/1、创建表.txt b/数据库/MySql/20230424/升级脚本/1、创建表.txt new file mode 100644 index 00000000..49b7422c --- /dev/null +++ b/数据库/MySql/20230424/升级脚本/1、创建表.txt @@ -0,0 +1,43 @@ +create table CoreCmsAlipayConfig +( + id int auto_increment comment '序列' + primary key, + appId varchar(50) charset utf8 not null comment '支付宝开放平台AppId', + publicKey varchar(500) charset utf8 not null comment '支付宝公钥', + privateKey varchar(2000) charset utf8 not null comment '应用私钥', + serverUrl varchar(100) charset utf8 null comment '服务网关地址', + signType varchar(10) charset utf8 null comment '签名类型', + appPublicCert varchar(5000) charset utf8 null comment '应用公钥证书', + alipayPublicCert varchar(5000) charset utf8 null comment '支付宝公钥证书', + alipayRootCert varchar(5000) charset utf8 null comment '支付宝根证书', + appType varchar(10) charset utf8 not null comment '应用类型', + notifyUrl varchar(500) null comment '支付宝支付回调通知', + refundUrl varchar(500) null comment '支付宝退款回调', + jumpUrl varchar(500) null comment '支付跳转地址', + isEnable bit not null comment '是否启用', + isDefault bit not null comment '当前多端默认' +) + comment '支付宝支付配置'; + + +create table CoreCmsWeChatPayConfig +( + id int auto_increment comment '序列' + primary key, + appId varchar(50) not null comment '应用号', + mchId varchar(50) not null comment '商户号', + apiKey varchar(50) null comment 'API秘钥', + apiV3Key varchar(50) null comment 'APIv3密钥', + certificate varchar(8000) null comment 'p12证书base64', + rsaPublicKey varchar(1000) null comment 'RSA公钥', + subAppId varchar(50) null comment '子商户应用号', + subMchId varchar(50) null comment '子商户号', + notifyUrl varchar(200) null comment '支付回调通知', + refundUrl varchar(200) null comment '退款回调', + jumpUrl varchar(200) null comment '跳转地址', + isEnable bit not null comment '是否开启', + isDefault bit not null comment '是否本类默认', + appType varchar(50) null comment '应用类型' +) + comment '微信支付配置'; + diff --git a/数据库/MySql/数据库更新日志.txt b/数据库/MySql/数据库更新日志.txt index 16ad9787..746fccbb 100644 --- a/数据库/MySql/数据库更新日志.txt +++ b/数据库/MySql/数据库更新日志.txt @@ -1,3 +1,7 @@ +2023-04-24 +【新增】表【CoreCmsAlipayConfig】支付宝支付配置表 +【新增】表【CoreCmsWeChatPayConfig】微信支付配置表 + 2023-03-27 【新增】表【CoreCmsTopUpType】充值规则类型表 diff --git a/数据库/SqlServer/20230424/升级脚本/1、创建表.sql b/数据库/SqlServer/20230424/升级脚本/1、创建表.sql new file mode 100644 index 00000000..38c93956 Binary files /dev/null and b/数据库/SqlServer/20230424/升级脚本/1、创建表.sql differ diff --git a/数据库/SqlServer/数据库更新日志.txt b/数据库/SqlServer/数据库更新日志.txt index 577780ae..c420dfce 100644 --- a/数据库/SqlServer/数据库更新日志.txt +++ b/数据库/SqlServer/数据库更新日志.txt @@ -1,3 +1,7 @@ +2023-04-24 +【新增】表【CoreCmsAlipayConfig】支付宝支付配置表 +【新增】表【CoreCmsWeChatPayConfig】微信支付配置表 + 2023-03-27 【新增】表【CoreCmsTopUpType】充值规则类型表