From c8b4bbd78dbaa732a85e08cd9283bf5021b2a14d Mon Sep 17 00:00:00 2001 From: jianweie code Date: Tue, 29 Jul 2025 00:51:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E7=AB=AF=E3=80=90=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E3=80=91=E6=96=B0=E5=A2=9E=E5=95=86=E5=AE=B6=E8=BD=AC=E8=B4=A6?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=90=8E=E5=8F=B0=E5=A4=84=E7=90=86=E5=8F=8A?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=9B=9E=E8=B0=83=E8=8E=B7=E5=8F=96=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CoreCms.Net.Configuration/GlobalEnumVars.cs | 45 ++- ...sWeChatPayPlatformCertificateRepository.cs | 91 +++++ ...CoreCmsUserTocashWeChatNotifyRepository.cs | 81 +++++ ...reCmsUserTocashWeChatResponseRepository.cs | 81 +++++ .../CoreCms.Net.IServices.csproj | 1 + ...CmsWeChatPayPlatformCertificateServices.cs | 95 +++++ .../ICoreCmsUserTocashWeChatNotifyServices.cs | 83 +++++ ...CoreCmsUserTocashWeChatResponseServices.cs | 85 +++++ .../IWechatTenpayClientFactory.cs | 13 + CoreCms.Net.Model/CoreCms.Net.Model.xml | 268 +++++++++++++- .../Entities/Pay/CoreCmsWeChatPayConfig.cs | 233 ++++++------- .../CoreCmsWeChatPayPlatformCertificate.cs | 95 +++++ .../User/CoreCmsUserTocashWeChatNotify.cs | 91 +++++ .../User/CoreCmsUserTocashWeChatResponse.cs | 105 ++++++ .../FromBody/FMTransferBillsCallBack.cs | 80 +++++ ...sWeChatPayPlatformCertificateRepository.cs | 212 +++++++++++ .../Pay/WeChatPayConfigRepository.cs | 116 +++--- ...CoreCmsUserTocashWeChatNotifyRepository.cs | 195 +++++++++++ ...reCmsUserTocashWeChatResponseRepository.cs | 201 +++++++++++ .../CoreCms.Net.Services.csproj | 1 + ...CmsWeChatPayPlatformCertificateServices.cs | 129 +++++++ .../User/CoreCmsUserTocashServices.cs | 143 +++++++- .../CoreCmsUserTocashWeChatNotifyServices.cs | 116 ++++++ ...CoreCmsUserTocashWeChatResponseServices.cs | 116 ++++++ .../WechatTenpay/WechatTenpayClientFactory.cs | 79 +++++ .../AutoRefreshPlatformCertificateJob.cs | 137 ++++++++ CoreCms.Net.Task/HangfireDispose.cs | 3 + .../CoreCms.Net.WeChat.Service.csproj | 1 + .../Pay/CoreCmsWeChatPayConfigController.cs | 14 +- .../shop/pay/wechatpayconfig/create.html | 330 +++++++++++------- .../views/shop/pay/wechatpayconfig/edit.html | 326 ++++++++++------- .../views/shop/pay/wechatpayconfig/index.html | 12 +- .../PayNotify/WeChatPayController.cs | 66 +++- .../CoreCms.Net.Web.WebApi.xml | 8 +- ...新【微信支付配置表】CoreCmsWeChatPayConfig.sql | Bin 0 -> 4924 bytes ...平台证书表】CoreCmsWeChatPayPlatformCertificate.sql | 56 +++ ...家转账微信回调通知表】CoreCmsUserTocashWeChatNotify.sql | 52 +++ ...商家转账回调记录表】CoreCmsUserTocashWeChatResponse.sql | 61 ++++ 38 files changed, 3385 insertions(+), 436 deletions(-) create mode 100644 CoreCms.Net.IRepository/Pay/ICoreCmsWeChatPayPlatformCertificateRepository.cs create mode 100644 CoreCms.Net.IRepository/User/ICoreCmsUserTocashWeChatNotifyRepository.cs create mode 100644 CoreCms.Net.IRepository/User/ICoreCmsUserTocashWeChatResponseRepository.cs create mode 100644 CoreCms.Net.IServices/Pay/ICoreCmsWeChatPayPlatformCertificateServices.cs create mode 100644 CoreCms.Net.IServices/User/ICoreCmsUserTocashWeChatNotifyServices.cs create mode 100644 CoreCms.Net.IServices/User/ICoreCmsUserTocashWeChatResponseServices.cs create mode 100644 CoreCms.Net.IServices/WechatTenpay/IWechatTenpayClientFactory.cs create mode 100644 CoreCms.Net.Model/Entities/Pay/CoreCmsWeChatPayPlatformCertificate.cs create mode 100644 CoreCms.Net.Model/Entities/User/CoreCmsUserTocashWeChatNotify.cs create mode 100644 CoreCms.Net.Model/Entities/User/CoreCmsUserTocashWeChatResponse.cs create mode 100644 CoreCms.Net.Model/FromBody/FMTransferBillsCallBack.cs create mode 100644 CoreCms.Net.Repository/Pay/CoreCmsWeChatPayPlatformCertificateRepository.cs create mode 100644 CoreCms.Net.Repository/User/CoreCmsUserTocashWeChatNotifyRepository.cs create mode 100644 CoreCms.Net.Repository/User/CoreCmsUserTocashWeChatResponseRepository.cs create mode 100644 CoreCms.Net.Services/Pay/CoreCmsWeChatPayPlatformCertificateServices.cs create mode 100644 CoreCms.Net.Services/User/CoreCmsUserTocashWeChatNotifyServices.cs create mode 100644 CoreCms.Net.Services/User/CoreCmsUserTocashWeChatResponseServices.cs create mode 100644 CoreCms.Net.Services/WechatTenpay/WechatTenpayClientFactory.cs create mode 100644 CoreCms.Net.Task/AutoRefreshPlatformCertificateJob.cs create mode 100644 数据库/SqlServer/20250729/1、更新【微信支付配置表】CoreCmsWeChatPayConfig.sql create mode 100644 数据库/SqlServer/20250729/2、新增【微信支付平台证书表】CoreCmsWeChatPayPlatformCertificate.sql create mode 100644 数据库/SqlServer/20250729/3、新增【用户提现使用商家转账微信回调通知表】CoreCmsUserTocashWeChatNotify.sql create mode 100644 数据库/SqlServer/20250729/4、新增【用户提现使用商家转账回调记录表】CoreCmsUserTocashWeChatResponse.sql diff --git a/CoreCms.Net.Configuration/GlobalEnumVars.cs b/CoreCms.Net.Configuration/GlobalEnumVars.cs index 3cefb814..6bf8b3bf 100644 --- a/CoreCms.Net.Configuration/GlobalEnumVars.cs +++ b/CoreCms.Net.Configuration/GlobalEnumVars.cs @@ -351,7 +351,9 @@ namespace CoreCms.Net.Configuration [Description("企业付款到银行卡")] 企业付款到银行卡 = 2, [Description("商家转账到零钱")] - 商家转账到零钱 = 3 + 商家转账到零钱 = 3, + [Description("商家转账")] + 商家转账 = 4 } #endregion @@ -3406,6 +3408,47 @@ namespace CoreCms.Net.Configuration #endregion + #region 微信在线客服 + + /// + /// 抽奖活动类型 + /// + public enum WeChatAutoReplyMatchModel + { + /// + /// 完全等于 + /// + [Description("完全等于")] + Complete = 1, + + /// + /// 模糊包含 + /// + [Description("模糊包含")] + FuzzyMatching = 2, + } + + #endregion + + #region 微信支付相关 + + /// + /// 微信支付验证微信支付身份方式 + /// + public enum WeChatPayIdentityVerificationMethods + { + /// + /// 平台证书 + /// + [Description("平台证书")] + PlatformCertificate = 0, + /// + /// 微信支付公钥 + /// + [Description("微信支付公钥")] + PlatformPublicKey = 1, + } + #endregion } } diff --git a/CoreCms.Net.IRepository/Pay/ICoreCmsWeChatPayPlatformCertificateRepository.cs b/CoreCms.Net.IRepository/Pay/ICoreCmsWeChatPayPlatformCertificateRepository.cs new file mode 100644 index 00000000..deaea2e2 --- /dev/null +++ b/CoreCms.Net.IRepository/Pay/ICoreCmsWeChatPayPlatformCertificateRepository.cs @@ -0,0 +1,91 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2025/7/21 20:36:56 + * 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 ICoreCmsWeChatPayPlatformCertificateRepository : IBaseRepository + { + #region 重写增删改查操作=========================================================== + + /// + /// 重写异步插入方法 + /// + /// + /// + Task InsertAsync(CoreCmsWeChatPayPlatformCertificate entity); + + /// + /// 重写异步更新方法 + /// + /// + /// + Task UpdateAsync(CoreCmsWeChatPayPlatformCertificate 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); + } +} \ No newline at end of file diff --git a/CoreCms.Net.IRepository/User/ICoreCmsUserTocashWeChatNotifyRepository.cs b/CoreCms.Net.IRepository/User/ICoreCmsUserTocashWeChatNotifyRepository.cs new file mode 100644 index 00000000..dcded3dd --- /dev/null +++ b/CoreCms.Net.IRepository/User/ICoreCmsUserTocashWeChatNotifyRepository.cs @@ -0,0 +1,81 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2025/7/28 23:08:04 + * 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 ICoreCmsUserTocashWeChatNotifyRepository : IBaseRepository + { + #region 重写增删改查操作=========================================================== + + /// + /// 重写异步插入方法 + /// + /// + /// + Task InsertAsync(CoreCmsUserTocashWeChatNotify entity); + + /// + /// 重写异步更新方法 + /// + /// + /// + Task UpdateAsync(CoreCmsUserTocashWeChatNotify entity); + + /// + /// 重写异步更新方法 + /// + /// + /// + Task UpdateAsync(List entity); + + /// + /// 重写删除指定ID的数据 + /// + /// + /// + Task DeleteByIdAsync(object id); + + /// + /// 重写删除指定ID集合的数据(批量删除) + /// + /// + /// + Task DeleteByIdsAsync(int[] ids); + + #endregion 重写增删改查操作=========================================================== + + /// + /// 重写根据条件查询分页数据 + /// + /// 判断集合 + /// 排序方式 + /// 当前页面索引 + /// 分布大小 + /// + /// 是否使用WITH(NOLOCK) + /// + Task> QueryPageAsync( + Expression> predicate, + Expression> orderByExpression, OrderByType orderByType, int pageIndex = 1, + int pageSize = 20, bool blUseNoLock = false); + } +} \ No newline at end of file diff --git a/CoreCms.Net.IRepository/User/ICoreCmsUserTocashWeChatResponseRepository.cs b/CoreCms.Net.IRepository/User/ICoreCmsUserTocashWeChatResponseRepository.cs new file mode 100644 index 00000000..3f2198bc --- /dev/null +++ b/CoreCms.Net.IRepository/User/ICoreCmsUserTocashWeChatResponseRepository.cs @@ -0,0 +1,81 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2025/7/23 16:37:18 + * 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 ICoreCmsUserTocashWeChatResponseRepository : IBaseRepository + { + #region 重写增删改查操作=========================================================== + + /// + /// 重写异步插入方法 + /// + /// + /// + Task InsertAsync(CoreCmsUserTocashWeChatResponse entity); + + /// + /// 重写异步更新方法 + /// + /// + /// + Task UpdateAsync(CoreCmsUserTocashWeChatResponse entity); + + /// + /// 重写异步更新方法 + /// + /// + /// + Task UpdateAsync(List entity); + + /// + /// 重写删除指定ID的数据 + /// + /// + /// + Task DeleteByIdAsync(object id); + + /// + /// 重写删除指定ID集合的数据(批量删除) + /// + /// + /// + Task DeleteByIdsAsync(int[] ids); + + #endregion 重写增删改查操作=========================================================== + + /// + /// 重写根据条件查询分页数据 + /// + /// 判断集合 + /// 排序方式 + /// 当前页面索引 + /// 分布大小 + /// + /// 是否使用WITH(NOLOCK) + /// + Task> QueryPageAsync( + Expression> predicate, + Expression> orderByExpression, OrderByType orderByType, int pageIndex = 1, + int pageSize = 20, bool blUseNoLock = false); + } +} \ No newline at end of file diff --git a/CoreCms.Net.IServices/CoreCms.Net.IServices.csproj b/CoreCms.Net.IServices/CoreCms.Net.IServices.csproj index 6bc6b92b..97dcad17 100644 --- a/CoreCms.Net.IServices/CoreCms.Net.IServices.csproj +++ b/CoreCms.Net.IServices/CoreCms.Net.IServices.csproj @@ -7,6 +7,7 @@ + diff --git a/CoreCms.Net.IServices/Pay/ICoreCmsWeChatPayPlatformCertificateServices.cs b/CoreCms.Net.IServices/Pay/ICoreCmsWeChatPayPlatformCertificateServices.cs new file mode 100644 index 00000000..8cdc096c --- /dev/null +++ b/CoreCms.Net.IServices/Pay/ICoreCmsWeChatPayPlatformCertificateServices.cs @@ -0,0 +1,95 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2025/7/21 20:36:56 + * 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 ICoreCmsWeChatPayPlatformCertificateServices : IBaseServices + { + #region 重写增删改查操作=========================================================== + + /// + /// 重写异步插入方法 + /// + /// + /// + Task InsertAsync(CoreCmsWeChatPayPlatformCertificate entity); + + /// + /// 重写异步更新方法 + /// + /// + /// + Task UpdateAsync(CoreCmsWeChatPayPlatformCertificate 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 重写根据条件查询分页数据 + } +} \ No newline at end of file diff --git a/CoreCms.Net.IServices/User/ICoreCmsUserTocashWeChatNotifyServices.cs b/CoreCms.Net.IServices/User/ICoreCmsUserTocashWeChatNotifyServices.cs new file mode 100644 index 00000000..b91b49b1 --- /dev/null +++ b/CoreCms.Net.IServices/User/ICoreCmsUserTocashWeChatNotifyServices.cs @@ -0,0 +1,83 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2025/7/28 23:08:04 + * 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 ICoreCmsUserTocashWeChatNotifyServices : IBaseServices + { + #region 重写增删改查操作=========================================================== + + /// + /// 重写异步插入方法 + /// + /// + /// + Task InsertAsync(CoreCmsUserTocashWeChatNotify entity); + + /// + /// 重写异步更新方法 + /// + /// + /// + Task UpdateAsync(CoreCmsUserTocashWeChatNotify entity); + + /// + /// 重写异步更新方法 + /// + /// + /// + Task UpdateAsync(List entity); + + /// + /// 重写删除指定ID的数据 + /// + /// + /// + Task DeleteByIdAsync(object id); + + /// + /// 重写删除指定ID集合的数据(批量删除) + /// + /// + /// + Task DeleteByIdsAsync(int[] ids); + + #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/User/ICoreCmsUserTocashWeChatResponseServices.cs b/CoreCms.Net.IServices/User/ICoreCmsUserTocashWeChatResponseServices.cs new file mode 100644 index 00000000..028b4eab --- /dev/null +++ b/CoreCms.Net.IServices/User/ICoreCmsUserTocashWeChatResponseServices.cs @@ -0,0 +1,85 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2025/7/23 16:37:18 + * 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 ICoreCmsUserTocashWeChatResponseServices : IBaseServices + { + #region 重写增删改查操作=========================================================== + + /// + /// 重写异步插入方法 + /// + /// + /// + Task InsertAsync(CoreCmsUserTocashWeChatResponse entity); + + /// + /// 重写异步更新方法 + /// + /// + /// + Task UpdateAsync(CoreCmsUserTocashWeChatResponse entity); + + /// + /// 重写异步更新方法 + /// + /// + /// + Task UpdateAsync(List entity); + + /// + /// 重写删除指定ID的数据 + /// + /// + /// + Task DeleteByIdAsync(object id); + + /// + /// 重写删除指定ID集合的数据(批量删除) + /// + /// + /// + Task DeleteByIdsAsync(int[] ids); + + #endregion 重写增删改查操作=========================================================== + + #region 重写根据条件查询分页数据 + + /// + /// 重写根据条件查询分页数据 + /// + /// 判断集合 + /// 排序方式 + /// 当前页面索引 + /// 分布大小 + /// + /// 是否使用WITH(NOLOCK) + /// + Task> QueryPageAsync( + Expression> predicate, + Expression> orderByExpression, OrderByType orderByType, int pageIndex = 1, + int pageSize = 20, bool blUseNoLock = false); + + #endregion 重写根据条件查询分页数据 + } +} \ No newline at end of file diff --git a/CoreCms.Net.IServices/WechatTenpay/IWechatTenpayClientFactory.cs b/CoreCms.Net.IServices/WechatTenpay/IWechatTenpayClientFactory.cs new file mode 100644 index 00000000..61c5872d --- /dev/null +++ b/CoreCms.Net.IServices/WechatTenpay/IWechatTenpayClientFactory.cs @@ -0,0 +1,13 @@ +using System.Threading.Tasks; +using SKIT.FlurlHttpClient.Wechat.TenpayV3; + +namespace CoreCms.Net.IServices +{ + /// + /// ΢֧ӹӿ + /// + public interface IWechatTenpayClientFactory + { + Task Create(string merchantId); + } +} diff --git a/CoreCms.Net.Model/CoreCms.Net.Model.xml b/CoreCms.Net.Model/CoreCms.Net.Model.xml index 180edf4d..f2e7d9c0 100644 --- a/CoreCms.Net.Model/CoreCms.Net.Model.xml +++ b/CoreCms.Net.Model/CoreCms.Net.Model.xml @@ -4743,7 +4743,7 @@ - 微信支付配置 + 微信支付配置表 @@ -4826,6 +4826,96 @@ 应用类型 + + + 高级模式 + + + + + 商户证书序列号 + + + + + 商户证书文件内容 + + + + + 平台证书序列号 + + + + + 平台公钥ID + + + + + 平台公钥内容 + + + + + 提现回调通知 + + + + + 微信支付平台证书 + + + + + 构造函数 + + + + + 序列 + + + + + 证书算法类型 + + + + + 证书内容 + + + + + 获取生效时间 + + + + + 获取过期时间 + + + + + 证书编号 + + + + + 商户编号 + + + + + 创建时间 + + + + + 更新时间 + + 拼团商品表 @@ -8302,6 +8392,116 @@ 用户昵称 + + + 用户提现使用商家转账微信回调通知 + + + + + 构造函数 + + + + + 序列 + + + + + 通知ID + + + + + 通知创建时间 + + + + + 通知数据类型 + + + + + 通知类型 + + + + + 回调摘要 + + + + + 通知数据 + + + + + 创建时间 + + + + + 用户提现使用商家转账回调记录 + + + + + 构造函数 + + + + + 序列 + + + + + 商户单号 + + + + + 微信转账单号 + + + + + 单据创建时间 + + + + + 单据状态 + + + + + 跳转领取页面的package信息 + + + + + 状态码 + + + + + 消息内容 + + + + + 描述 + + + + + 创建时间 + + 用户token @@ -10094,6 +10294,72 @@ base64数据 + + + 商家转账回调通知实体数据 + + + + + 通知ID】通知的唯一ID + + + + + 【通知创建时间】 + 通知创建的时间,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示北京时间2015年05月20日13点29分35秒。 + + + + + 【通知数据类型】通知的资源数据类型,商家转账通知为encrypt-resource + + + + + 【通知类型】通知的类型,商家转账通知的类型为MCHTRANSFER.BILL.FINISHED + + + + + 【回调摘要】回调摘要 + + + + + 通知数据 + + + + + 商家转账回调通知实体数据-通知数据 + + + + + 【原始类型】原始回调类型,为mch_payment + + + + + 【加密算法类型】对开启结果数据进行加密的加密算法,目前只支持AEAD_AES_256_GCM + + + + + 数据密文】Base64编码后的商家转账结果数据密文 + + + + + 【附加数据】附加数据 + + + + + 随机串】加密使用的随机串。 + + 按照序列进行更新Bool类型数据 diff --git a/CoreCms.Net.Model/Entities/Pay/CoreCmsWeChatPayConfig.cs b/CoreCms.Net.Model/Entities/Pay/CoreCmsWeChatPayConfig.cs index ce7f315b..9d25f3d9 100644 --- a/CoreCms.Net.Model/Entities/Pay/CoreCmsWeChatPayConfig.cs +++ b/CoreCms.Net.Model/Entities/Pay/CoreCmsWeChatPayConfig.cs @@ -1,10 +1,10 @@ /*********************************************************************** * Project: CoreCms - * ProjectName: 核心内容管理系统 - * Web: https://www.corecms.net - * Author: 大灰灰 - * Email: jianweie@163.com - * CreateTime: 2023/4/22 23:40:15 + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2025/7/28 22:49:53 * Description: 暂无 ***********************************************************************/ @@ -15,7 +15,7 @@ using System.ComponentModel.DataAnnotations; namespace CoreCms.Net.Model.Entities { /// - /// 微信支付配置 + /// 微信支付配置表 /// public partial class CoreCmsWeChatPayConfig { @@ -25,188 +25,173 @@ namespace CoreCms.Net.Model.Entities public CoreCmsWeChatPayConfig() { } - + /// /// 序列 /// [Display(Name = "序列")] - [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] - [Required(ErrorMessage = "请输入{0}")] - - - - public System.Int32 id { get; set; } - - + public System.Int32 id { get; set; } + /// /// 应用号 /// [Display(Name = "应用号")] - [Required(ErrorMessage = "请输入{0}")] - - [StringLength(maximumLength:50,ErrorMessage = "{0}不能超过{1}字")] - - public System.String appId { get; set; } - - + [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; } - - + [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; } - - + [Required(ErrorMessage = "请输入{0}")] + [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; } - - + + [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; } - - + [Required(ErrorMessage = "请输入{0}")] + public System.String certificate { get; set; } + /// /// RSA公钥 /// [Display(Name = "RSA公钥")] - - - - [StringLength(maximumLength:1000,ErrorMessage = "{0}不能超过{1}字")] - - public System.String rsaPublicKey { get; set; } - - + + [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; } - - + + [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; } - - + + [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; } - - + [Required(ErrorMessage = "请输入{0}")] + [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; } - - + [Required(ErrorMessage = "请输入{0}")] + [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; } - - + + [StringLength(maximumLength: 200, ErrorMessage = "{0}不能超过{1}字")] + public System.String jumpUrl { get; set; } + /// /// 是否开启 /// [Display(Name = "是否开启")] - [Required(ErrorMessage = "请输入{0}")] - - - - public System.Boolean isEnable { get; set; } - - + public System.Boolean isEnable { get; set; } + /// /// 是否本类默认 /// [Display(Name = "是否本类默认")] - [Required(ErrorMessage = "请输入{0}")] - - - - public System.Boolean isDefault { get; set; } - - + public System.Boolean isDefault { get; set; } + /// /// 应用类型 /// [Display(Name = "应用类型")] - - - - [StringLength(maximumLength:50,ErrorMessage = "{0}不能超过{1}字")] - - public System.String appType { get; set; } - - + [Required(ErrorMessage = "请输入{0}")] + [StringLength(maximumLength: 50, ErrorMessage = "{0}不能超过{1}字")] + public System.String appType { get; set; } + + /// + /// 高级模式 + /// + [Display(Name = "高级模式")] + [Required(ErrorMessage = "请输入{0}")] + public System.Int32 payType { get; set; } + + /// + /// 商户证书序列号 + /// + [Display(Name = "商户证书序列号")] + + [StringLength(maximumLength: 50, ErrorMessage = "{0}不能超过{1}字")] + public System.String certificateSerialNumber { get; set; } + + /// + /// 商户证书文件内容 + /// + [Display(Name = "商户证书文件内容")] + public System.String certificatePrivateKey { get; set; } + + /// + /// 平台证书序列号 + /// + [Display(Name = "平台证书序列号")] + + [StringLength(maximumLength: 50, ErrorMessage = "{0}不能超过{1}字")] + public System.String platformSerialNumber { get; set; } + + /// + /// 平台公钥ID + /// + [Display(Name = "平台公钥ID")] + + [StringLength(maximumLength: 50, ErrorMessage = "{0}不能超过{1}字")] + public System.String platformPublicKeyId { get; set; } + + /// + /// 平台公钥内容 + /// + [Display(Name = "平台公钥内容")] + public System.String platformPublicKey { get; set; } + + /// + /// 提现回调通知 + /// + [Display(Name = "提现回调通知")] + + [StringLength(maximumLength: 200, ErrorMessage = "{0}不能超过{1}字")] + public System.String transferBillsUrl { get; set; } } -} +} \ No newline at end of file diff --git a/CoreCms.Net.Model/Entities/Pay/CoreCmsWeChatPayPlatformCertificate.cs b/CoreCms.Net.Model/Entities/Pay/CoreCmsWeChatPayPlatformCertificate.cs new file mode 100644 index 00000000..1d7bea01 --- /dev/null +++ b/CoreCms.Net.Model/Entities/Pay/CoreCmsWeChatPayPlatformCertificate.cs @@ -0,0 +1,95 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2025/7/21 20:39:06 + * Description: 暂无 + ***********************************************************************/ + +using SqlSugar; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; + +namespace CoreCms.Net.Model.Entities +{ + /// + /// 微信支付平台证书 + /// + public partial class CoreCmsWeChatPayPlatformCertificate + { + /// + /// 构造函数 + /// + public CoreCmsWeChatPayPlatformCertificate() + { + } + + /// + /// 序列 + /// + [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 algorithmType { get; set; } + + /// + /// 证书内容 + /// + [Display(Name = "证书内容")] + [Required(ErrorMessage = "请输入{0}")] + public System.String certificate { get; set; } + + /// + /// 获取生效时间 + /// + [Display(Name = "获取生效时间")] + [Required(ErrorMessage = "请输入{0}")] + public System.DateTime effectiveTime { get; set; } + + /// + /// 获取过期时间 + /// + [Display(Name = "获取过期时间")] + [Required(ErrorMessage = "请输入{0}")] + public System.DateTime expireTime { get; set; } + + /// + /// 证书编号 + /// + [Display(Name = "证书编号")] + [Required(ErrorMessage = "请输入{0}")] + [StringLength(maximumLength: 50, ErrorMessage = "{0}不能超过{1}字")] + public System.String serialNumber { get; set; } + + /// + /// 商户编号 + /// + [Display(Name = "商户编号")] + [Required(ErrorMessage = "请输入{0}")] + [StringLength(maximumLength: 50, ErrorMessage = "{0}不能超过{1}字")] + public System.String merchantId { get; set; } + + /// + /// 创建时间 + /// + [Display(Name = "创建时间")] + [Required(ErrorMessage = "请输入{0}")] + public System.DateTime createTime { get; set; } + + /// + /// 更新时间 + /// + [Display(Name = "更新时间")] + public System.DateTime? updataTime { get; set; } + } +} \ No newline at end of file diff --git a/CoreCms.Net.Model/Entities/User/CoreCmsUserTocashWeChatNotify.cs b/CoreCms.Net.Model/Entities/User/CoreCmsUserTocashWeChatNotify.cs new file mode 100644 index 00000000..efcd9c12 --- /dev/null +++ b/CoreCms.Net.Model/Entities/User/CoreCmsUserTocashWeChatNotify.cs @@ -0,0 +1,91 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2025/7/28 23:08:04 + * Description: 暂无 + ***********************************************************************/ + +using SqlSugar; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; + +namespace CoreCms.Net.Model.Entities +{ + /// + /// 用户提现使用商家转账微信回调通知 + /// + public partial class CoreCmsUserTocashWeChatNotify + { + /// + /// 构造函数 + /// + public CoreCmsUserTocashWeChatNotify() + { + } + + /// + /// 序列 + /// + [Display(Name = "序列")] + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + [Required(ErrorMessage = "请输入{0}")] + public System.Int32 id { get; set; } + + /// + /// 通知ID + /// + [Display(Name = "通知ID")] + [Required(ErrorMessage = "请输入{0}")] + [StringLength(maximumLength: 50, ErrorMessage = "{0}不能超过{1}字")] + public System.String callBackId { get; set; } + + /// + /// 通知创建时间 + /// + [Display(Name = "通知创建时间")] + [Required(ErrorMessage = "请输入{0}")] + [StringLength(maximumLength: 50, ErrorMessage = "{0}不能超过{1}字")] + public System.String create_time { get; set; } + + /// + /// 通知数据类型 + /// + [Display(Name = "通知数据类型")] + [Required(ErrorMessage = "请输入{0}")] + [StringLength(maximumLength: 50, ErrorMessage = "{0}不能超过{1}字")] + public System.String resource_type { get; set; } + + /// + /// 通知类型 + /// + [Display(Name = "通知类型")] + [Required(ErrorMessage = "请输入{0}")] + [StringLength(maximumLength: 50, ErrorMessage = "{0}不能超过{1}字")] + public System.String event_type { get; set; } + + /// + /// 回调摘要 + /// + [Display(Name = "回调摘要")] + [Required(ErrorMessage = "请输入{0}")] + [StringLength(maximumLength: 100, ErrorMessage = "{0}不能超过{1}字")] + public System.String summary { get; set; } + + /// + /// 通知数据 + /// + [Display(Name = "通知数据")] + [Required(ErrorMessage = "请输入{0}")] + public System.String resource { get; set; } + + /// + /// 创建时间 + /// + [Display(Name = "创建时间")] + [Required(ErrorMessage = "请输入{0}")] + public System.DateTime createTime { get; set; } + } +} \ No newline at end of file diff --git a/CoreCms.Net.Model/Entities/User/CoreCmsUserTocashWeChatResponse.cs b/CoreCms.Net.Model/Entities/User/CoreCmsUserTocashWeChatResponse.cs new file mode 100644 index 00000000..6a255c87 --- /dev/null +++ b/CoreCms.Net.Model/Entities/User/CoreCmsUserTocashWeChatResponse.cs @@ -0,0 +1,105 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2025/7/23 16:44:04 + * Description: 暂无 + ***********************************************************************/ + +using SqlSugar; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; + +namespace CoreCms.Net.Model.Entities +{ + /// + /// 用户提现使用商家转账回调记录 + /// + public partial class CoreCmsUserTocashWeChatResponse + { + /// + /// 构造函数 + /// + public CoreCmsUserTocashWeChatResponse() + { + } + + /// + /// 序列 + /// + [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 out_bill_no { get; set; } + + /// + /// 微信转账单号 + /// + [Display(Name = "微信转账单号")] + [Required(ErrorMessage = "请输入{0}")] + [StringLength(maximumLength: 100, ErrorMessage = "{0}不能超过{1}字")] + public System.String transfer_bill_no { get; set; } + + /// + /// 单据创建时间 + /// + [Display(Name = "单据创建时间")] + [Required(ErrorMessage = "请输入{0}")] + public System.DateTime create_time { get; set; } + + /// + /// 单据状态 + /// + [Display(Name = "单据状态")] + [Required(ErrorMessage = "请输入{0}")] + [StringLength(maximumLength: 50, ErrorMessage = "{0}不能超过{1}字")] + public System.String state { get; set; } + + /// + /// 跳转领取页面的package信息 + /// + [Display(Name = "跳转领取页面的package信息")] + + [StringLength(maximumLength: 255, ErrorMessage = "{0}不能超过{1}字")] + public System.String package_info { get; set; } + + /// + /// 状态码 + /// + [Display(Name = "状态码")] + public System.Int32? code { get; set; } + + /// + /// 消息内容 + /// + [Display(Name = "消息内容")] + + [StringLength(maximumLength: 255, ErrorMessage = "{0}不能超过{1}字")] + public System.String message { get; set; } + + /// + /// 描述 + /// + [Display(Name = "描述")] + + [StringLength(maximumLength: 255, ErrorMessage = "{0}不能超过{1}字")] + public System.String detail { get; set; } + + /// + /// 创建时间 + /// + [Display(Name = "创建时间")] + [Required(ErrorMessage = "请输入{0}")] + public System.DateTime createTime { get; set; } + } +} \ No newline at end of file diff --git a/CoreCms.Net.Model/FromBody/FMTransferBillsCallBack.cs b/CoreCms.Net.Model/FromBody/FMTransferBillsCallBack.cs new file mode 100644 index 00000000..a6e96cf3 --- /dev/null +++ b/CoreCms.Net.Model/FromBody/FMTransferBillsCallBack.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CoreCms.Net.Model.FromBody +{ + /// + /// 商家转账回调通知实体数据 + /// + public class FMTransferBillsCallBack + { + /// + /// 通知ID】通知的唯一ID + /// + public string id { get; set; } + + /// + /// 【通知创建时间】 + /// 通知创建的时间,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示北京时间2015年05月20日13点29分35秒。 + /// + public string create_time { get; set; } + + /// + /// 【通知数据类型】通知的资源数据类型,商家转账通知为encrypt-resource + /// + public string resource_type { get; set; } + + /// + /// 【通知类型】通知的类型,商家转账通知的类型为MCHTRANSFER.BILL.FINISHED + /// + public string event_type { get; set; } + + /// + /// 【回调摘要】回调摘要 + /// + public string summary { get; set; } + + /// + /// 通知数据 + /// + public FMTransferBillsCallBackResource resource { get; set; } + + } + + + /// + /// 商家转账回调通知实体数据-通知数据 + /// + public class FMTransferBillsCallBackResource + { + /// + /// 【原始类型】原始回调类型,为mch_payment + /// + public string original_type { get; set; } + + /// + /// 【加密算法类型】对开启结果数据进行加密的加密算法,目前只支持AEAD_AES_256_GCM + /// + public string algorithm { get; set; } + + /// + /// 数据密文】Base64编码后的商家转账结果数据密文 + /// + public string ciphertext { get; set; } + + /// + /// 【附加数据】附加数据 + /// + public string? associated_data { get; set; } + + /// + /// 随机串】加密使用的随机串。 + /// + public string? nonce { get; set; } + + } + +} diff --git a/CoreCms.Net.Repository/Pay/CoreCmsWeChatPayPlatformCertificateRepository.cs b/CoreCms.Net.Repository/Pay/CoreCmsWeChatPayPlatformCertificateRepository.cs new file mode 100644 index 00000000..734c36c0 --- /dev/null +++ b/CoreCms.Net.Repository/Pay/CoreCmsWeChatPayPlatformCertificateRepository.cs @@ -0,0 +1,212 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2025/7/21 20:36:56 + * 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 CoreCmsWeChatPayPlatformCertificateRepository : BaseRepository, ICoreCmsWeChatPayPlatformCertificateRepository + { + private readonly IUnitOfWork _unitOfWork; + + public CoreCmsWeChatPayPlatformCertificateRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + _unitOfWork = unitOfWork; + } + + #region 实现重写增删改查操作========================================================== + + /// + /// 重写异步插入方法 + /// + /// 实体数据 + /// + public async Task InsertAsync(CoreCmsWeChatPayPlatformCertificate 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(CoreCmsWeChatPayPlatformCertificate 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.algorithmType = entity.algorithmType; + oldModel.certificate = entity.certificate; + oldModel.effectiveTime = entity.effectiveTime; + oldModel.expireTime = entity.expireTime; + oldModel.serialNumber = entity.serialNumber; + oldModel.merchantId = entity.merchantId; + oldModel.createTime = entity.createTime; + oldModel.updataTime = entity.updataTime; + + //事物处理过程结束 + 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 CoreCmsWeChatPayPlatformCertificate + { + id = p.id, + algorithmType = p.algorithmType, + certificate = p.certificate, + effectiveTime = p.effectiveTime, + expireTime = p.expireTime, + serialNumber = p.serialNumber, + merchantId = p.merchantId, + createTime = p.createTime, + updataTime = p.updataTime, + }).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount); + } + else + { + page = await DbClient.Queryable() + .OrderByIF(orderByExpression != null, orderByExpression, orderByType) + .WhereIF(predicate != null, predicate).Select(p => new CoreCmsWeChatPayPlatformCertificate + { + id = p.id, + algorithmType = p.algorithmType, + certificate = p.certificate, + effectiveTime = p.effectiveTime, + expireTime = p.expireTime, + serialNumber = p.serialNumber, + merchantId = p.merchantId, + createTime = p.createTime, + updataTime = p.updataTime, + }).ToPageListAsync(pageIndex, pageSize, totalCount); + } + var list = new PageList(page, pageIndex, pageSize, totalCount); + return list; + } + + #endregion 重写根据条件查询分页数据 + } +} \ No newline at end of file diff --git a/CoreCms.Net.Repository/Pay/WeChatPayConfigRepository.cs b/CoreCms.Net.Repository/Pay/WeChatPayConfigRepository.cs index de01564d..ef109208 100644 --- a/CoreCms.Net.Repository/Pay/WeChatPayConfigRepository.cs +++ b/CoreCms.Net.Repository/Pay/WeChatPayConfigRepository.cs @@ -1,9 +1,9 @@ /*********************************************************************** * Project: CoreCms - * ProjectName: 核心内容管理系统 - * Web: https://www.corecms.net - * Author: 大灰灰 - * Email: jianweie@163.com + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com * CreateTime: 2023/4/22 23:40:15 * Description: 暂无 ***********************************************************************/ @@ -29,12 +29,13 @@ namespace CoreCms.Net.Repository public class WeChatPayConfigRepository : BaseRepository, IWeChatPayConfigRepository { private readonly IUnitOfWork _unitOfWork; + public WeChatPayConfigRepository(IUnitOfWork unitOfWork) : base(unitOfWork) { _unitOfWork = unitOfWork; } - #region 实现重写增删改查操作========================================================== + #region 实现重写增删改查操作========================================================== /// /// 重写异步插入方法 @@ -64,11 +65,11 @@ namespace CoreCms.Net.Repository var oldModel = await DbClient.Queryable().In(entity.id).SingleAsync(); if (oldModel == null) { - jm.msg = "不存在此信息"; - return jm; + jm.msg = "不存在此信息"; + return jm; } //事物处理过程开始 - oldModel.id = entity.id; + //oldModel.id = entity.id; oldModel.appId = entity.appId; oldModel.mchId = entity.mchId; oldModel.apiKey = entity.apiKey; @@ -83,7 +84,14 @@ namespace CoreCms.Net.Repository oldModel.isEnable = entity.isEnable; oldModel.isDefault = entity.isDefault; oldModel.appType = entity.appType; - + oldModel.payType = entity.payType; + oldModel.certificateSerialNumber = entity.certificateSerialNumber; + oldModel.certificatePrivateKey = entity.certificatePrivateKey; + oldModel.platformSerialNumber = entity.platformSerialNumber; + oldModel.platformPublicKeyId = entity.platformPublicKeyId; + oldModel.platformPublicKey = entity.platformPublicKey; + oldModel.transferBillsUrl = entity.transferBillsUrl; + //事物处理过程结束 var bl = await DbClient.Updateable(oldModel).ExecuteCommandHasChangeAsync(); jm.code = bl ? 0 : 1; @@ -140,9 +148,9 @@ namespace CoreCms.Net.Repository return jm; } - #endregion + #endregion 实现重写增删改查操作========================================================== - #region 获取缓存的所有数据========================================================== + #region 获取缓存的所有数据========================================================== /// /// 获取缓存的所有数据 @@ -150,14 +158,14 @@ namespace CoreCms.Net.Repository /// public async Task> GetCaChe() { - var list = await DbClient.Queryable().With(SqlWith.NoLock).WithCache().ToListAsync(); + var list = await DbClient.Queryable().With(SqlWith.NoLock).WithCache().ToListAsync(); return list; } - #endregion - + #endregion 获取缓存的所有数据========================================================== #region 重写根据条件查询分页数据 + /// /// 重写根据条件查询分页数据 /// @@ -180,22 +188,28 @@ namespace CoreCms.Net.Repository .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, - + 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, + payType = p.payType, + certificateSerialNumber = p.certificateSerialNumber, + certificatePrivateKey = p.certificatePrivateKey, + platformSerialNumber = p.platformSerialNumber, + platformPublicKey = p.platformPublicKey, + platformPublicKeyId = p.platformPublicKeyId, + transferBillsUrl = p.transferBillsUrl }).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount); } else @@ -204,29 +218,33 @@ namespace CoreCms.Net.Repository .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, - + 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, + certificateSerialNumber = p.certificateSerialNumber, + certificatePrivateKey = p.certificatePrivateKey, + platformSerialNumber = p.platformSerialNumber, + platformPublicKey = p.platformPublicKey, + platformPublicKeyId = p.platformPublicKeyId, + transferBillsUrl = p.transferBillsUrl }).ToPageListAsync(pageIndex, pageSize, totalCount); } var list = new PageList(page, pageIndex, pageSize, totalCount); return list; } - #endregion - + #endregion 重写根据条件查询分页数据 } -} +} \ No newline at end of file diff --git a/CoreCms.Net.Repository/User/CoreCmsUserTocashWeChatNotifyRepository.cs b/CoreCms.Net.Repository/User/CoreCmsUserTocashWeChatNotifyRepository.cs new file mode 100644 index 00000000..2833a281 --- /dev/null +++ b/CoreCms.Net.Repository/User/CoreCmsUserTocashWeChatNotifyRepository.cs @@ -0,0 +1,195 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2025/7/28 23:08:04 + * 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 CoreCmsUserTocashWeChatNotifyRepository : BaseRepository, ICoreCmsUserTocashWeChatNotifyRepository + { + private readonly IUnitOfWork _unitOfWork; + + public CoreCmsUserTocashWeChatNotifyRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + _unitOfWork = unitOfWork; + } + + #region 实现重写增删改查操作========================================================== + + /// + /// 重写异步插入方法 + /// + /// 实体数据 + /// + public async Task InsertAsync(CoreCmsUserTocashWeChatNotify 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(CoreCmsUserTocashWeChatNotify 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.callBackId = entity.callBackId; + oldModel.create_time = entity.create_time; + oldModel.resource_type = entity.resource_type; + oldModel.event_type = entity.event_type; + oldModel.summary = entity.summary; + oldModel.resource = entity.resource; + oldModel.createTime = entity.createTime; + + //事物处理过程结束 + 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 重写根据条件查询分页数据 + + /// + /// 重写根据条件查询分页数据 + /// + /// 判断集合 + /// 排序方式 + /// 当前页面索引 + /// 分布大小 + /// + /// 是否使用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 CoreCmsUserTocashWeChatNotify + { + id = p.id, + callBackId = p.callBackId, + create_time = p.create_time, + resource_type = p.resource_type, + event_type = p.event_type, + summary = p.summary, + resource = p.resource, + createTime = p.createTime, + }).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount); + } + else + { + page = await DbClient.Queryable() + .OrderByIF(orderByExpression != null, orderByExpression, orderByType) + .WhereIF(predicate != null, predicate).Select(p => new CoreCmsUserTocashWeChatNotify + { + id = p.id, + callBackId = p.callBackId, + create_time = p.create_time, + resource_type = p.resource_type, + event_type = p.event_type, + summary = p.summary, + resource = p.resource, + createTime = p.createTime, + }).ToPageListAsync(pageIndex, pageSize, totalCount); + } + var list = new PageList(page, pageIndex, pageSize, totalCount); + return list; + } + + #endregion 重写根据条件查询分页数据 + } +} \ No newline at end of file diff --git a/CoreCms.Net.Repository/User/CoreCmsUserTocashWeChatResponseRepository.cs b/CoreCms.Net.Repository/User/CoreCmsUserTocashWeChatResponseRepository.cs new file mode 100644 index 00000000..9f9f05b9 --- /dev/null +++ b/CoreCms.Net.Repository/User/CoreCmsUserTocashWeChatResponseRepository.cs @@ -0,0 +1,201 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2025/7/23 16:37:18 + * 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 CoreCmsUserTocashWeChatResponseRepository : BaseRepository, ICoreCmsUserTocashWeChatResponseRepository + { + private readonly IUnitOfWork _unitOfWork; + + public CoreCmsUserTocashWeChatResponseRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + _unitOfWork = unitOfWork; + } + + #region 实现重写增删改查操作========================================================== + + /// + /// 重写异步插入方法 + /// + /// 实体数据 + /// + public async Task InsertAsync(CoreCmsUserTocashWeChatResponse 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(CoreCmsUserTocashWeChatResponse 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.out_bill_no = entity.out_bill_no; + oldModel.transfer_bill_no = entity.transfer_bill_no; + oldModel.create_time = entity.create_time; + oldModel.state = entity.state; + oldModel.package_info = entity.package_info; + oldModel.code = entity.code; + oldModel.message = entity.message; + oldModel.detail = entity.detail; + oldModel.createTime = entity.createTime; + + //事物处理过程结束 + 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 重写根据条件查询分页数据 + + /// + /// 重写根据条件查询分页数据 + /// + /// 判断集合 + /// 排序方式 + /// 当前页面索引 + /// 分布大小 + /// + /// 是否使用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 CoreCmsUserTocashWeChatResponse + { + id = p.id, + out_bill_no = p.out_bill_no, + transfer_bill_no = p.transfer_bill_no, + create_time = p.create_time, + state = p.state, + package_info = p.package_info, + code = p.code, + message = p.message, + detail = p.detail, + createTime = p.createTime, + }).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount); + } + else + { + page = await DbClient.Queryable() + .OrderByIF(orderByExpression != null, orderByExpression, orderByType) + .WhereIF(predicate != null, predicate).Select(p => new CoreCmsUserTocashWeChatResponse + { + id = p.id, + out_bill_no = p.out_bill_no, + transfer_bill_no = p.transfer_bill_no, + create_time = p.create_time, + state = p.state, + package_info = p.package_info, + code = p.code, + message = p.message, + detail = p.detail, + createTime = p.createTime, + }).ToPageListAsync(pageIndex, pageSize, totalCount); + } + var list = new PageList(page, pageIndex, pageSize, totalCount); + return list; + } + + #endregion 重写根据条件查询分页数据 + } +} \ No newline at end of file diff --git a/CoreCms.Net.Services/CoreCms.Net.Services.csproj b/CoreCms.Net.Services/CoreCms.Net.Services.csproj index 78e6109f..25d7fe2c 100644 --- a/CoreCms.Net.Services/CoreCms.Net.Services.csproj +++ b/CoreCms.Net.Services/CoreCms.Net.Services.csproj @@ -16,6 +16,7 @@ + diff --git a/CoreCms.Net.Services/Pay/CoreCmsWeChatPayPlatformCertificateServices.cs b/CoreCms.Net.Services/Pay/CoreCmsWeChatPayPlatformCertificateServices.cs new file mode 100644 index 00000000..03da356d --- /dev/null +++ b/CoreCms.Net.Services/Pay/CoreCmsWeChatPayPlatformCertificateServices.cs @@ -0,0 +1,129 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2025/7/21 20:36:56 + * 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 CoreCmsWeChatPayPlatformCertificateServices : BaseServices, ICoreCmsWeChatPayPlatformCertificateServices + { + private readonly ICoreCmsWeChatPayPlatformCertificateRepository _dal; + private readonly IUnitOfWork _unitOfWork; + + public CoreCmsWeChatPayPlatformCertificateServices(IUnitOfWork unitOfWork, ICoreCmsWeChatPayPlatformCertificateRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + _unitOfWork = unitOfWork; + } + + #region 实现重写增删改查操作========================================================== + + /// + /// 重写异步插入方法 + /// + /// 实体数据 + /// + public async Task InsertAsync(CoreCmsWeChatPayPlatformCertificate entity) + { + return await _dal.InsertAsync(entity); + } + + /// + /// 重写异步更新方法方法 + /// + /// + /// + public async Task UpdateAsync(CoreCmsWeChatPayPlatformCertificate 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 重写根据条件查询分页数据 + } +} \ No newline at end of file diff --git a/CoreCms.Net.Services/User/CoreCmsUserTocashServices.cs b/CoreCms.Net.Services/User/CoreCmsUserTocashServices.cs index 302d3efb..a3038632 100644 --- a/CoreCms.Net.Services/User/CoreCmsUserTocashServices.cs +++ b/CoreCms.Net.Services/User/CoreCmsUserTocashServices.cs @@ -8,11 +8,6 @@ * Description: 暂无 ***********************************************************************/ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Linq.Expressions; -using System.Threading.Tasks; using CoreCms.Net.Caching.AccressToken; using CoreCms.Net.Configuration; using CoreCms.Net.IRepository; @@ -31,14 +26,27 @@ using Essensoft.Paylink.WeChatPay.V2; using Essensoft.Paylink.WeChatPay.V2.Request; using Essensoft.Paylink.WeChatPay.V3.Domain; using Essensoft.Paylink.WeChatPay.V3.Request; +using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Options; using Newtonsoft.Json; +using SKIT.FlurlHttpClient.Wechat.Api.Models; +using SKIT.FlurlHttpClient.Wechat.TenpayV3; +using SKIT.FlurlHttpClient.Wechat.TenpayV3.Models; +using SKIT.FlurlHttpClient.Wechat.TenpayV3.Settings; using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Net.Http; +using System.Threading.Tasks; using Yitter.IdGenerator; -using Microsoft.AspNetCore.Hosting; +using NLog; + +using static SKIT.FlurlHttpClient.Wechat.Api.Models.ECFinderLiveGetFinderLiveNoticeRecordListResponse.Types; namespace CoreCms.Net.Services @@ -60,11 +68,12 @@ namespace CoreCms.Net.Services private readonly IWebHostEnvironment _webHostEnvironment; private readonly IWeChatPayConfigServices _weChatPayConfigServices; - + private readonly IWechatTenpayClientFactory _wechatTenpayClientFactory; + private readonly ICoreCmsUserTocashWeChatResponseServices _userTocashWeChatResponseServices; public CoreCmsUserTocashServices(IUnitOfWork unitOfWork, ICoreCmsUserTocashRepository dal, - IServiceProvider serviceProvider, ICoreCmsUserServices userServices, ICoreCmsUserBalanceServices userBalanceServices, ICoreCmsUserWeChatInfoServices weChatInfoServices, IWeChatPayClient v2Client, IHttpContextAccessor httpContextAccessor, IWebHostEnvironment webHostEnvironment, Essensoft.Paylink.WeChatPay.V3.IWeChatPayClient v3Client, IWeChatPayConfigServices weChatPayConfigServices) + IServiceProvider serviceProvider, ICoreCmsUserServices userServices, ICoreCmsUserBalanceServices userBalanceServices, ICoreCmsUserWeChatInfoServices weChatInfoServices, IWeChatPayClient v2Client, IHttpContextAccessor httpContextAccessor, IWebHostEnvironment webHostEnvironment, Essensoft.Paylink.WeChatPay.V3.IWeChatPayClient v3Client, IWeChatPayConfigServices weChatPayConfigServices, IWechatTenpayClientFactory wechatTenpayClientFactory, ICoreCmsUserTocashWeChatResponseServices userTocashWeChatResponseServices) { this._dal = dal; base.BaseDal = dal; @@ -78,6 +87,8 @@ namespace CoreCms.Net.Services _webHostEnvironment = webHostEnvironment; _v3Client = v3Client; _weChatPayConfigServices = weChatPayConfigServices; + _wechatTenpayClientFactory = wechatTenpayClientFactory; + _userTocashWeChatResponseServices = userTocashWeChatResponseServices; } /// @@ -508,6 +519,122 @@ namespace CoreCms.Net.Services break; } + case (int)GlobalEnumVars.UserTocashType.商家转账: + { + var user = await _userServices.QueryByIdAsync(info.userId); + if (user == null) + { + jm.msg = "用户信息获取失败"; + return jm; + } + var weChatUserInfo = await _weChatInfoServices.QueryByClauseAsync(p => p.userId == info.userId); + if (weChatUserInfo == null) + { + jm.msg = "微信用户数据获取失败"; + return jm; + } + + var config = await _weChatPayConfigServices.QueryByClauseAsync(p => p.isDefault == true && p.isEnable == true); + if (config == null) + { + jm.msg = "支付配置信息获取失败"; + return jm; + } + + var client = await _wechatTenpayClientFactory.Create(config.mchId); + + var request = new CreateFundAppMerchantTransferBillRequest(); + + request.WechatpaySerialNumber = config.payType switch + { + (int)GlobalEnumVars.WeChatPayIdentityVerificationMethods.PlatformCertificate => config + .platformSerialNumber, + (int)GlobalEnumVars.WeChatPayIdentityVerificationMethods.PlatformPublicKey => config + .platformPublicKeyId, + _ => request.WechatpaySerialNumber + }; + + request.AppId = config.appId; + request.OutBillNumber = "usertocash" + info.id; + request.TransferSceneId = "1000"; + request.OpenId = weChatUserInfo.openid; + + //按分计算 + request.TransferAmount = Convert.ToInt32(info.money * 100); + if (request.TransferAmount > 30) + { + request.UserName = info.accountName; + } + + request.TransferRemark = "客户推广业务佣金提现处理"; + request.NotifyUrl = config.transferBillsUrl; + request.TransferSceneReportInfoList = new List() + { + new CreateFundAppMerchantTransferBillRequest.Types.TransferSceneReportInfo() + { + InfoType = "活动名称", + InfoContent = "分销佣金提现", + }, + new CreateFundAppMerchantTransferBillRequest.Types.TransferSceneReportInfo() + { + InfoType = "奖励说明", + InfoContent = "用户分销佣金提现申请", + } + }; + + var response = await client.ExecuteCreateFundAppMerchantTransferBillAsync(request); + if (response.IsSuccessful()) + { + status = (int)GlobalEnumVars.UserTocashStatus.提现成功; + var message = JsonConvert.SerializeObject(new + { + response + }); + + var bl = await _dal.UpdateAsync(p => new CoreCmsUserTocash() { status = status, updateTime = DateTime.Now, message = message, type = type }, p => p.id == id && (p.status == (int)GlobalEnumVars.UserTocashStatus.待审核 || p.status == (int)GlobalEnumVars.UserTocashStatus.提现异常)); + + NLogUtil.WriteAll(LogLevel.Trace, LogType.Refund, "微信提现商家转账回调(成功)", JsonConvert.SerializeObject(new + { + response, + request + })); + + var log = new CoreCmsUserTocashWeChatResponse(); + log.out_bill_no = response.OutBillNumber; + log.transfer_bill_no = response.TransferBillNumber; + log.state = response.State; + log.create_time = response.CreateTime.DateTime; + log.package_info = response.PackageInfo; + log.message = response.FailReason; + log.createTime = DateTime.Now; + await _userTocashWeChatResponseServices.InsertAsync(log); + + + jm.status = bl; + jm.data = status; + } + else + { + status = (int)GlobalEnumVars.UserTocashStatus.提现异常; + var message = JsonConvert.SerializeObject(new + { + response + }); + + var bl = await _dal.UpdateAsync(p => new CoreCmsUserTocash() { status = status, updateTime = DateTime.Now, message = message, type = type }, p => p.id == id && (p.status == (int)GlobalEnumVars.UserTocashStatus.待审核 || p.status == (int)GlobalEnumVars.UserTocashStatus.提现异常)); + + NLogUtil.WriteAll(LogLevel.Trace, LogType.Refund, "微信提现商家转账回调(失败)", JsonConvert.SerializeObject(new + { + response, + request + })); + + jm.status = bl; + jm.data = status; + } + + break; + } default: jm.msg = "提现方式获取失败"; jm.status = false; diff --git a/CoreCms.Net.Services/User/CoreCmsUserTocashWeChatNotifyServices.cs b/CoreCms.Net.Services/User/CoreCmsUserTocashWeChatNotifyServices.cs new file mode 100644 index 00000000..8a7157dd --- /dev/null +++ b/CoreCms.Net.Services/User/CoreCmsUserTocashWeChatNotifyServices.cs @@ -0,0 +1,116 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2025/7/28 23:08:04 + * 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 CoreCmsUserTocashWeChatNotifyServices : BaseServices, ICoreCmsUserTocashWeChatNotifyServices + { + private readonly ICoreCmsUserTocashWeChatNotifyRepository _dal; + private readonly IUnitOfWork _unitOfWork; + + public CoreCmsUserTocashWeChatNotifyServices(IUnitOfWork unitOfWork, ICoreCmsUserTocashWeChatNotifyRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + _unitOfWork = unitOfWork; + } + + #region 实现重写增删改查操作========================================================== + + /// + /// 重写异步插入方法 + /// + /// 实体数据 + /// + public async Task InsertAsync(CoreCmsUserTocashWeChatNotify entity) + { + return await _dal.InsertAsync(entity); + } + + /// + /// 重写异步更新方法方法 + /// + /// + /// + public async Task UpdateAsync(CoreCmsUserTocashWeChatNotify 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 重写根据条件查询分页数据 + + /// + /// 重写根据条件查询分页数据 + /// + /// 判断集合 + /// 排序方式 + /// 当前页面索引 + /// 分布大小 + /// + /// 是否使用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 重写根据条件查询分页数据 + } +} \ No newline at end of file diff --git a/CoreCms.Net.Services/User/CoreCmsUserTocashWeChatResponseServices.cs b/CoreCms.Net.Services/User/CoreCmsUserTocashWeChatResponseServices.cs new file mode 100644 index 00000000..2cf81afd --- /dev/null +++ b/CoreCms.Net.Services/User/CoreCmsUserTocashWeChatResponseServices.cs @@ -0,0 +1,116 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2025/7/23 16:37:18 + * 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 CoreCmsUserTocashWeChatResponseServices : BaseServices, ICoreCmsUserTocashWeChatResponseServices + { + private readonly ICoreCmsUserTocashWeChatResponseRepository _dal; + private readonly IUnitOfWork _unitOfWork; + + public CoreCmsUserTocashWeChatResponseServices(IUnitOfWork unitOfWork, ICoreCmsUserTocashWeChatResponseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + _unitOfWork = unitOfWork; + } + + #region 实现重写增删改查操作========================================================== + + /// + /// 重写异步插入方法 + /// + /// 实体数据 + /// + public async Task InsertAsync(CoreCmsUserTocashWeChatResponse entity) + { + return await _dal.InsertAsync(entity); + } + + /// + /// 重写异步更新方法方法 + /// + /// + /// + public async Task UpdateAsync(CoreCmsUserTocashWeChatResponse 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 重写根据条件查询分页数据 + + /// + /// 重写根据条件查询分页数据 + /// + /// 判断集合 + /// 排序方式 + /// 当前页面索引 + /// 分布大小 + /// + /// 是否使用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 重写根据条件查询分页数据 + } +} \ No newline at end of file diff --git a/CoreCms.Net.Services/WechatTenpay/WechatTenpayClientFactory.cs b/CoreCms.Net.Services/WechatTenpay/WechatTenpayClientFactory.cs new file mode 100644 index 00000000..25992814 --- /dev/null +++ b/CoreCms.Net.Services/WechatTenpay/WechatTenpayClientFactory.cs @@ -0,0 +1,79 @@ +using System; +using System.Linq; +using System.Net.Http; +using System.Threading.Tasks; +using CoreCms.Net.Configuration; +using CoreCms.Net.IServices; +using Microsoft.Extensions.Options; +using SKIT.FlurlHttpClient.Wechat.TenpayV3; + +namespace CoreCms.Net.Services +{ + using SKIT.FlurlHttpClient.Wechat.TenpayV3.Settings; + + /// + /// 微信支付链接管理器实现 + /// + internal partial class WechatTenpayClientFactory : IWechatTenpayClientFactory + { + private readonly IHttpClientFactory _httpClientFactory; + private readonly IWeChatPayConfigServices _weChatPayConfigServices; + private readonly ICoreCmsWeChatPayPlatformCertificateServices _weChatPayPlatformCertificateServices; + + + public WechatTenpayClientFactory(IHttpClientFactory httpClientFactory, IWeChatPayConfigServices weChatPayConfigServices, ICoreCmsWeChatPayPlatformCertificateServices weChatPayPlatformCertificateServices) + { + _httpClientFactory = httpClientFactory; + _weChatPayConfigServices = weChatPayConfigServices; + _weChatPayPlatformCertificateServices = weChatPayPlatformCertificateServices; + } + + public async Task Create(string merchantId) + { + var tenpayMerchantOptions = await _weChatPayConfigServices.QueryByClauseAsync(p => p.mchId == merchantId && p.isDefault == true && p.isEnable == true); + + if (tenpayMerchantOptions == null) + { + throw new Exception("未在配置项中找到该 MerchantId 对应的微信商户号。"); + } + + var wechatTenpayClientOptions = new WechatTenpayClientOptions() + { + MerchantId = tenpayMerchantOptions.mchId, + MerchantV3Secret = tenpayMerchantOptions.apiV3Key, + MerchantCertificateSerialNumber = tenpayMerchantOptions.certificateSerialNumber, + MerchantCertificatePrivateKey = tenpayMerchantOptions.certificatePrivateKey, + AutoEncryptRequestSensitiveProperty = true, + AutoDecryptResponseSensitiveProperty = false, + }; + + // 基于平台证书的认证方式还需设置以下参数: + if (tenpayMerchantOptions.payType == (int)GlobalEnumVars.WeChatPayIdentityVerificationMethods.PlatformCertificate) + { + wechatTenpayClientOptions.PlatformAuthScheme = PlatformAuthScheme.Certificate; + + var certificate = await _weChatPayPlatformCertificateServices.QueryByClauseAsync(p => p.merchantId == tenpayMerchantOptions.mchId); + if (certificate != null) + { + var entity = new CertificateEntry(certificate.algorithmType, certificate.serialNumber, certificate.certificate, certificate.effectiveTime, certificate.expireTime); + + wechatTenpayClientOptions.PlatformCertificateManager.AddEntry(entity); + } + } + // 基于平台公钥的认证方式还需设置以下参数: + if (tenpayMerchantOptions.payType == (int)GlobalEnumVars.WeChatPayIdentityVerificationMethods.PlatformPublicKey) + { + wechatTenpayClientOptions.PlatformAuthScheme = PlatformAuthScheme.PublicKey; + wechatTenpayClientOptions.PlatformPublicKeyManager.AddEntry( + new PublicKeyEntry( + PublicKeyEntry.ALGORITHM_TYPE_RSA, + tenpayMerchantOptions.platformPublicKeyId!, + tenpayMerchantOptions.platformPublicKey!) + ); + } + + var wechatTenpayClient = WechatTenpayClientBuilder.Create(wechatTenpayClientOptions).Build(); + return wechatTenpayClient; + } + } +} diff --git a/CoreCms.Net.Task/AutoRefreshPlatformCertificateJob.cs b/CoreCms.Net.Task/AutoRefreshPlatformCertificateJob.cs new file mode 100644 index 00000000..b59113f7 --- /dev/null +++ b/CoreCms.Net.Task/AutoRefreshPlatformCertificateJob.cs @@ -0,0 +1,137 @@ +/*********************************************************************** + * Project: CoreCms.Net * + * Web: https://CoreCms.Net * + * ProjectName: 核心内容管理系统 * + * Author: 大灰灰 * + * Email: JianWeie@163.com * + * CreateTime: 2020-08-25 1:25:29 + * Description: 暂无 + ***********************************************************************/ + + +using CoreCms.Net.IServices; +using CoreCms.Net.Model.Entities; +using Newtonsoft.Json; +using System; +using SKIT.FlurlHttpClient.Wechat.TenpayV3; +using SKIT.FlurlHttpClient.Wechat.TenpayV3.Settings; +using SKIT.FlurlHttpClient.Wechat.TenpayV3.Models; + +namespace CoreCms.Net.Task +{ + /// + /// 定时更新微信支付平台证书 + /// + public class AutoRefreshPlatformCertificateJob + { + + private readonly IWeChatPayConfigServices _weChatPayConfigServices; + private readonly IWechatTenpayClientFactory _wechatTenpayClientFactory; + private readonly ICoreCmsWeChatPayPlatformCertificateServices _weChatPayPlatformCertificateServices; + private readonly ISysTaskLogServices _taskLogServices; + + /// + /// 构造函数 + /// + public AutoRefreshPlatformCertificateJob(IWeChatPayConfigServices weChatPayConfigServices, IWechatTenpayClientFactory wechatTenpayClientFactory, ICoreCmsWeChatPayPlatformCertificateServices weChatPayPlatformCertificateServices, ISysTaskLogServices taskLogServices) + { + _weChatPayConfigServices = weChatPayConfigServices; + _wechatTenpayClientFactory = wechatTenpayClientFactory; + _weChatPayPlatformCertificateServices = weChatPayPlatformCertificateServices; + _taskLogServices = taskLogServices; + } + + public async System.Threading.Tasks.Task Execute() + { + var config = await _weChatPayConfigServices.QueryListByClauseAsync(p => p.isDefault == true && p.isEnable == true); + if (config != null) + { + foreach (var item in config) + { + try + { + const string algorithmType = "RSA"; + var client = await _wechatTenpayClientFactory.Create(item.mchId); + var request = new QueryCertificatesRequest() { AlgorithmType = algorithmType }; + var response = await client.ExecuteQueryCertificatesAsync(request); + if (response.IsSuccessful()) + { + // NOTICE: + // 如果构造 Client 时启用了 `AutoDecryptResponseSensitiveProperty` 配置项,则无需再执行下面一行的手动解密方法: + response = client.DecryptResponseSensitiveProperty(response); + + foreach (var certificate in response.CertificateList) + { + var entity = CertificateEntry.Parse(algorithmType, certificate); + + // 将证书添加到平台证书管理器中 + var model = await _weChatPayPlatformCertificateServices.QueryByClauseAsync(p => + p.merchantId == item.mchId); + if (model != null) + { + model.algorithmType = entity.AlgorithmType; + model.serialNumber = entity.SerialNumber; + model.certificate = entity.Certificate; + model.effectiveTime = entity.EffectiveTime.DateTime; + model.expireTime = entity.ExpireTime.DateTime; + + model.updataTime = DateTime.Now; + await _weChatPayPlatformCertificateServices.UpdateAsync(model); + } + else + { + model = new CoreCmsWeChatPayPlatformCertificate(); + model.algorithmType = entity.AlgorithmType; + model.serialNumber = entity.SerialNumber; + model.certificate = entity.Certificate; + model.effectiveTime = entity.EffectiveTime.DateTime; + model.expireTime = entity.ExpireTime.DateTime; + model.merchantId = item.mchId; + model.createTime = DateTime.Now; + await _weChatPayPlatformCertificateServices.InsertAsync(model); + } + //client.PlatformCertificateManager.AddEntry(entity); + } + + //插入日志 + var log = new SysTaskLog + { + createTime = DateTime.Now, + isSuccess = true, + name = "刷新微信商户平台证书成功", + parameters = JsonConvert.SerializeObject(response) + }; + await _taskLogServices.InsertAsync(log); + + } + else + { + //插入日志 + var log = new SysTaskLog + { + createTime = DateTime.Now, + isSuccess = true, + name = "刷新微信商户平台证书失败", + parameters = $"刷新微信商户平台证书失败(状态码:{response.GetRawStatus()},错误代码:{response.ErrorCode},错误描述:{response.ErrorMessage})。", + }; + await _taskLogServices.InsertAsync(log); + } + } + catch (Exception ex) + { + + //插入日志 + var log = new SysTaskLog + { + createTime = DateTime.Now, + isSuccess = true, + name = "刷新微信商户平台证书遇到异常", + parameters = JsonConvert.SerializeObject(ex) + }; + await _taskLogServices.InsertAsync(log); + } + } + } + } + } +} diff --git a/CoreCms.Net.Task/HangfireDispose.cs b/CoreCms.Net.Task/HangfireDispose.cs index 40bdf536..25e0d929 100644 --- a/CoreCms.Net.Task/HangfireDispose.cs +++ b/CoreCms.Net.Task/HangfireDispose.cs @@ -70,6 +70,9 @@ namespace CoreCms.Net.Task //自动取消服务器订单任务 RecurringJob.AddOrUpdate("AutoCancelServiceOrderJob", s => s.Execute(), "0 0/5 * * * ? ", new RecurringJobOptions { TimeZone = TimeZoneInfo.Local }); // 每5分钟取消一次订单 + //定时更新微信支付平台证书 + RecurringJob.AddOrUpdate("AutoRefreshPlatformCertificateJob", s => s.Execute(), "0 0 6 * * ? ", new RecurringJobOptions { TimeZone = TimeZoneInfo.Local }); // 每天凌晨6点执行,首次可以自主进入定时任务页面手动执行一次 + } diff --git a/CoreCms.Net.WeChat.Service/CoreCms.Net.WeChat.Service.csproj b/CoreCms.Net.WeChat.Service/CoreCms.Net.WeChat.Service.csproj index 3fae826b..214ba76f 100644 --- a/CoreCms.Net.WeChat.Service/CoreCms.Net.WeChat.Service.csproj +++ b/CoreCms.Net.WeChat.Service/CoreCms.Net.WeChat.Service.csproj @@ -10,6 +10,7 @@ + diff --git a/CoreCms.Net.Web.Admin/Controllers/Pay/CoreCmsWeChatPayConfigController.cs b/CoreCms.Net.Web.Admin/Controllers/Pay/CoreCmsWeChatPayConfigController.cs index a088b18e..b75c27c7 100644 --- a/CoreCms.Net.Web.Admin/Controllers/Pay/CoreCmsWeChatPayConfigController.cs +++ b/CoreCms.Net.Web.Admin/Controllers/Pay/CoreCmsWeChatPayConfigController.cs @@ -229,9 +229,11 @@ namespace CoreCms.Net.Web.Admin.Controllers var jm = new AdminUiCallBack { code = 0 }; var weiChatPayTradeType = EnumHelper.EnumToList(); + var weChatPayIdentityVerificationMethods = EnumHelper.EnumToList(); jm.data = new { - weiChatPayTradeType + weiChatPayTradeType, + weChatPayIdentityVerificationMethods }; return jm; @@ -252,9 +254,12 @@ namespace CoreCms.Net.Web.Admin.Controllers var jm = new AdminUiCallBack { code = 0 }; var weiChatPayTradeType = EnumHelper.EnumToList(); + var weChatPayIdentityVerificationMethods = EnumHelper.EnumToList(); + jm.data = new { - weiChatPayTradeType + weiChatPayTradeType, + weChatPayIdentityVerificationMethods }; return jm; @@ -299,10 +304,13 @@ namespace CoreCms.Net.Web.Admin.Controllers jm.code = 0; var weiChatPayTradeType = EnumHelper.EnumToList(); + var weChatPayIdentityVerificationMethods = EnumHelper.EnumToList(); + jm.data = new { model, - weiChatPayTradeType + weiChatPayTradeType, + weChatPayIdentityVerificationMethods }; return jm; 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 index 227fbb53..0325007c 100644 --- a/CoreCms.Net.Web.Admin/wwwroot/views/shop/pay/wechatpayconfig/create.html +++ b/CoreCms.Net.Web.Admin/wwwroot/views/shop/pay/wechatpayconfig/create.html @@ -1,128 +1,221 @@