diff --git a/CoreCms.Net.Configuration/GlobalEnumVars.cs b/CoreCms.Net.Configuration/GlobalEnumVars.cs index a64931ca..190e5aac 100644 --- a/CoreCms.Net.Configuration/GlobalEnumVars.cs +++ b/CoreCms.Net.Configuration/GlobalEnumVars.cs @@ -42,7 +42,9 @@ namespace CoreCms.Net.Configuration [Description("短信")] Sms = 2, [Description("微信小程序拉取手机号")] - WeChatPhoneNumber = 3, + WeChatPhoneNumber = 3, + [Description("支付宝小程序拉取手机号")] + AliPhoneNumber = 4, } /// diff --git a/CoreCms.Net.IRepository/User/ICoreCmsAliPayUserInfoRepository.cs b/CoreCms.Net.IRepository/User/ICoreCmsAliPayUserInfoRepository.cs new file mode 100644 index 00000000..dcf93fbd --- /dev/null +++ b/CoreCms.Net.IRepository/User/ICoreCmsAliPayUserInfoRepository.cs @@ -0,0 +1,87 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2024/4/10 星期三 22:28:09 + * 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 ICoreCmsAliPayUserInfoRepository : IBaseRepository + { + #region 重写增删改查操作=========================================================== + + /// + /// 重写异步插入方法 + /// + /// + /// + Task InsertAsync(CoreCmsAliPayUserInfo entity); + + + /// + /// 重写异步更新方法 + /// + /// + /// + Task UpdateAsync(CoreCmsAliPayUserInfo 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); + + } +} diff --git a/CoreCms.Net.IServices/CoreCms.Net.IServices.csproj b/CoreCms.Net.IServices/CoreCms.Net.IServices.csproj index b181c037..205e09c9 100644 --- a/CoreCms.Net.IServices/CoreCms.Net.IServices.csproj +++ b/CoreCms.Net.IServices/CoreCms.Net.IServices.csproj @@ -5,6 +5,7 @@ + diff --git a/CoreCms.Net.IServices/Pay/IAliPayServices.cs b/CoreCms.Net.IServices/Pay/IAliPayServices.cs index 03939f9a..49b0efe9 100644 --- a/CoreCms.Net.IServices/Pay/IAliPayServices.cs +++ b/CoreCms.Net.IServices/Pay/IAliPayServices.cs @@ -9,6 +9,7 @@ ***********************************************************************/ using System.Threading.Tasks; +using Aop.Api.Response; using CoreCms.Net.Model.Entities; using CoreCms.Net.Model.ViewModels.UI; @@ -35,6 +36,19 @@ namespace CoreCms.Net.IServices /// Task Refund(CoreCmsBillRefund refundInfo, CoreCmsBillPayments paymentInfo); + /// + /// 根据票据返回app_auth_token相关信息 + /// + /// + /// + AlipaySystemOauthTokenResponse GetAliPayAppAuthTokenBYCode(string code); + + /// + /// + /// + /// + /// + AlipayUserInfoShareResponse GetAliPayUserInfoByToken(string token); } } \ No newline at end of file diff --git a/CoreCms.Net.IServices/User/ICoreCmsAliPayUserInfoServices.cs b/CoreCms.Net.IServices/User/ICoreCmsAliPayUserInfoServices.cs new file mode 100644 index 00000000..724a36c4 --- /dev/null +++ b/CoreCms.Net.IServices/User/ICoreCmsAliPayUserInfoServices.cs @@ -0,0 +1,83 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2024/4/10 星期三 22:28:09 + * 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 ICoreCmsAliPayUserInfoServices : IBaseServices + { + #region 重写增删改查操作=========================================================== + + /// + /// 重写异步插入方法 + /// + /// + /// + Task InsertAsync(CoreCmsAliPayUserInfo entity); + + /// + /// 重写异步更新方法 + /// + /// + /// + Task UpdateAsync(CoreCmsAliPayUserInfo 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/ICoreCmsUserServices.cs b/CoreCms.Net.IServices/User/ICoreCmsUserServices.cs index 4c97c8a7..1c8e453e 100644 --- a/CoreCms.Net.IServices/User/ICoreCmsUserServices.cs +++ b/CoreCms.Net.IServices/User/ICoreCmsUserServices.cs @@ -101,10 +101,10 @@ namespace CoreCms.Net.IServices /// 手机短信验证码登陆,同时兼有手机短信注册的功能,还有第三方账户绑定的功能 /// /// 实体数据 - /// 登录方式(1普通,2短信,3微信小程序拉取手机号) + /// 登录方式(1普通,2短信,3微信小程序拉取手机号,4支付宝小程序拉取手机号) /// /// - Task SmsLogin(FMWxAccountCreate entity, + Task SmsLogin(FMComAccountCreate entity, int loginType = (int)GlobalEnumVars.LoginType.WeChatPhoneNumber, int platform = (int)GlobalEnumVars.CoreShopSystemCategory.Api); diff --git a/CoreCms.Net.Model/CoreCms.Net.Model.csproj b/CoreCms.Net.Model/CoreCms.Net.Model.csproj index 1d24e40c..32068bbe 100644 --- a/CoreCms.Net.Model/CoreCms.Net.Model.csproj +++ b/CoreCms.Net.Model/CoreCms.Net.Model.csproj @@ -7,6 +7,7 @@ + diff --git a/CoreCms.Net.Model/CoreCms.Net.Model.xml b/CoreCms.Net.Model/CoreCms.Net.Model.xml index e61b5390..46cf11ce 100644 --- a/CoreCms.Net.Model/CoreCms.Net.Model.xml +++ b/CoreCms.Net.Model/CoreCms.Net.Model.xml @@ -7609,6 +7609,76 @@ 修改时间 + + + 支付宝用户信息 + + + + + 构造函数 + + + + + 序列 + + + + + accessToken + + + + + 支付宝用户编号 + + + + + 授权开始 + + + + + 截止时间 + + + + + 刷新令牌时间 + + + + + 刷新后token + + + + + 授权商户的user_id + + + + + 注册用户序列 + + + + + openId + + + + + unionId + + + + + 创建时间 + + 登录日志 @@ -9081,6 +9151,31 @@ 审核状态 + + + 微信小程序登录解码手机号码 + + + + + 响应报文数据(待解码) + + + + + sign + + + + + 支付宝用户序列(也是前端缓存的用户编码) + + + + + 推荐码 + + 获取新文章 @@ -10279,47 +10374,47 @@ 微信小程序登录解码手机号码 - + - 微信账户创建 + 通用账户创建传输实体 - + 密码 - + 昵称 - + 头像 - + 短信验证码 - + 手机号码 - + 微信小程序授权sessionAuthId - + 来源 - + 推荐码 @@ -10349,6 +10444,86 @@ 用户发起订阅提交 + + + 支付宝配置信息数据 + + + + + AppId + + + + + 应用私钥 + + + + + 支付宝公钥 + + + + + 应用公钥 + + + + + 回调地址 + + + + + 阿里访问令牌刷新 + + + + + oauth2授权地址 + + + + + 支付宝授权类型 + + + + + 支付宝通用接口地址 + + + + + 外部H5唤起支付宝客户端进行实名认证接口地址 + + + + + 接口内容加密方式(AESKey) + + + + + 支付宝拉取解码手机号码 + + + + + 返回状态码 + + + + + 消息详情 + + + + + 手机号码 + + 快递100请求进行的参数封装实体 diff --git a/CoreCms.Net.Model/Entities/User/CoreCmsAliPayUserInfo.cs b/CoreCms.Net.Model/Entities/User/CoreCmsAliPayUserInfo.cs new file mode 100644 index 00000000..aa082e6c --- /dev/null +++ b/CoreCms.Net.Model/Entities/User/CoreCmsAliPayUserInfo.cs @@ -0,0 +1,121 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2024/4/11 星期四 1:24:31 + * Description: 暂无 + ***********************************************************************/ + +using SqlSugar; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; + +namespace CoreCms.Net.Model.Entities +{ + /// + /// 支付宝用户信息 + /// + public partial class CoreCmsAliPayUserInfo + { + /// + /// 构造函数 + /// + public CoreCmsAliPayUserInfo() + { + } + + /// + /// 序列 + /// + [Display(Name = "序列")] + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + [Required(ErrorMessage = "请输入{0}")] + public System.Int32 id { get; set; } + + /// + /// accessToken + /// + [Display(Name = "accessToken")] + + [StringLength(maximumLength: 50, ErrorMessage = "{0}不能超过{1}字")] + public System.String accessToken { get; set; } + + /// + /// 支付宝用户编号 + /// + [Display(Name = "支付宝用户编号")] + [Required(ErrorMessage = "请输入{0}")] + [StringLength(maximumLength: 50, ErrorMessage = "{0}不能超过{1}字")] + public System.String aliPayUserInfoId { get; set; } + + /// + /// 授权开始 + /// + [Display(Name = "授权开始")] + + [StringLength(maximumLength: 50, ErrorMessage = "{0}不能超过{1}字")] + public System.String authStart { get; set; } + + /// + /// 截止时间 + /// + [Display(Name = "截止时间")] + [Required(ErrorMessage = "请输入{0}")] + public System.Int32 expiresIn { get; set; } + + /// + /// 刷新令牌时间 + /// + [Display(Name = "刷新令牌时间")] + [Required(ErrorMessage = "请输入{0}")] + public System.Int32 reExpiresIn { get; set; } + + /// + /// 刷新后token + /// + [Display(Name = "刷新后token")] + + [StringLength(maximumLength: 50, ErrorMessage = "{0}不能超过{1}字")] + public System.String refreshToken { get; set; } + + /// + /// 授权商户的user_id + /// + [Display(Name = "授权商户的user_id")] + [Required(ErrorMessage = "请输入{0}")] + [StringLength(maximumLength: 50, ErrorMessage = "{0}不能超过{1}字")] + public System.String userId { get; set; } + + /// + /// 注册用户序列 + /// + [Display(Name = "注册用户序列")] + [Required(ErrorMessage = "请输入{0}")] + public System.Int32 userInfoId { get; set; } + + /// + /// openId + /// + [Display(Name = "openId")] + + [StringLength(maximumLength: 50, ErrorMessage = "{0}不能超过{1}字")] + public System.String openId { get; set; } + + /// + /// unionId + /// + [Display(Name = "unionId")] + + [StringLength(maximumLength: 50, ErrorMessage = "{0}不能超过{1}字")] + public System.String unionId { 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/FMAliPost.cs b/CoreCms.Net.Model/FromBody/FMAliPost.cs new file mode 100644 index 00000000..22711be1 --- /dev/null +++ b/CoreCms.Net.Model/FromBody/FMAliPost.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CoreCms.Net.Model.FromBody +{ + /// + /// 微信小程序登录解码手机号码 + /// + public class FMAliLoginDecryptPhoneNumber + { + /// + /// 响应报文数据(待解码) + /// + public string encryptedData { get; set; } + + /// + /// sign + /// + public string sign { get; set; } + + /// + /// 支付宝用户序列(也是前端缓存的用户编码) + /// + public string sessionAuthId { get; set; } + + /// + /// 推荐码 + /// + public int invitecode { get; set; } = 0; + + } +} diff --git a/CoreCms.Net.Model/FromBody/FMWxPost.cs b/CoreCms.Net.Model/FromBody/FMWxPost.cs index ecfb990c..2fbb02d1 100644 --- a/CoreCms.Net.Model/FromBody/FMWxPost.cs +++ b/CoreCms.Net.Model/FromBody/FMWxPost.cs @@ -63,9 +63,9 @@ namespace CoreCms.Net.Model.FromBody } /// - /// 微信账户创建 + /// 通用账户创建传输实体 /// - public class FMWxAccountCreate + public class FMComAccountCreate { /// /// 密码 diff --git a/CoreCms.Net.Model/Options/AliPayOptions.cs b/CoreCms.Net.Model/Options/AliPayOptions.cs new file mode 100644 index 00000000..d637cef8 --- /dev/null +++ b/CoreCms.Net.Model/Options/AliPayOptions.cs @@ -0,0 +1,61 @@ +using System; +using Microsoft.Extensions.Options; + +namespace CoreCms.Net.Model.Options +{ + /// + /// 支付宝配置信息数据 + /// + public partial class AliPayOptions : IOptions + { + AliPayOptions IOptions.Value => this; + + /// + /// AppId + /// + public string AppId { get; set; } = string.Empty; + /// + /// 应用私钥 + /// + public string AppSecret { get; set; } = string.Empty; + /// + /// 支付宝公钥 + /// + public string AliPublicKey { get; set; } = string.Empty; + /// + /// 应用公钥 + /// + public string AppPublicKey { get; set; } = string.Empty; + + /// + /// 回调地址 + /// + public string RedirectUrl { get; set; } = string.Empty; + /// + /// 阿里访问令牌刷新 + /// + public string AliAccessTokenRefresh { get; set; } = string.Empty; + /// + /// oauth2授权地址 + /// + public string AppConnectUrl { get; set; } = string.Empty; + /// + /// 支付宝授权类型 + /// + public string AppAuthToken { get; set; } = string.Empty; + /// + /// 支付宝通用接口地址 + /// + public string AliPublicApi { get; set; } = string.Empty; + /// + /// 外部H5唤起支付宝客户端进行实名认证接口地址 + /// + public string AliPayAppAuth { get; set; } = string.Empty; + /// + /// 接口内容加密方式(AESKey) + /// + public string AESKey { get; set; } = string.Empty; + } + + +} diff --git a/CoreCms.Net.Model/ViewModels/AliPay/AlipayEncryptDTO.cs b/CoreCms.Net.Model/ViewModels/AliPay/AlipayEncryptDTO.cs new file mode 100644 index 00000000..cf0e1059 --- /dev/null +++ b/CoreCms.Net.Model/ViewModels/AliPay/AlipayEncryptDTO.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CoreCms.Net.Model.ViewModels.AliPay +{ + /// + /// 支付宝拉取解码手机号码 + /// + public class AlipayEncryptDTO + { + /// + /// 返回状态码 + /// + public string code { get; set; } + + /// + /// 消息详情 + /// + public string msg { get; set; } + + /// + /// 手机号码 + /// + public string mobile { get; set; } + + } +} diff --git a/CoreCms.Net.Repository/User/CoreCmsAliPayUserInfoRepository.cs b/CoreCms.Net.Repository/User/CoreCmsAliPayUserInfoRepository.cs new file mode 100644 index 00000000..55b3a99d --- /dev/null +++ b/CoreCms.Net.Repository/User/CoreCmsAliPayUserInfoRepository.cs @@ -0,0 +1,208 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2024/4/11 星期四 1:24:31 + * 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 CoreCmsAliPayUserInfoRepository : BaseRepository, ICoreCmsAliPayUserInfoRepository + { + private readonly IUnitOfWork _unitOfWork; + public CoreCmsAliPayUserInfoRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + _unitOfWork = unitOfWork; + } + + #region 实现重写增删改查操作========================================================== + + /// + /// 重写异步插入方法 + /// + /// 实体数据 + /// + public async Task InsertAsync(CoreCmsAliPayUserInfo 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(CoreCmsAliPayUserInfo 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.accessToken = entity.accessToken; + oldModel.aliPayUserInfoId = entity.aliPayUserInfoId; + oldModel.authStart = entity.authStart; + oldModel.expiresIn = entity.expiresIn; + oldModel.reExpiresIn = entity.reExpiresIn; + oldModel.refreshToken = entity.refreshToken; + oldModel.userId = entity.userId; + oldModel.userInfoId = entity.userInfoId; + oldModel.openId = entity.openId; + oldModel.unionId = entity.unionId; + 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 CoreCmsAliPayUserInfo + { + id = p.id, + accessToken = p.accessToken, + aliPayUserInfoId = p.aliPayUserInfoId, + authStart = p.authStart, + expiresIn = p.expiresIn, + reExpiresIn = p.reExpiresIn, + refreshToken = p.refreshToken, + userId = p.userId, + userInfoId = p.userInfoId, + openId = p.openId, + unionId = p.unionId, + 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 CoreCmsAliPayUserInfo + { + id = p.id, + accessToken = p.accessToken, + aliPayUserInfoId = p.aliPayUserInfoId, + authStart = p.authStart, + expiresIn = p.expiresIn, + reExpiresIn = p.reExpiresIn, + refreshToken = p.refreshToken, + userId = p.userId, + userInfoId = p.userInfoId, + openId = p.openId, + unionId = p.unionId, + createTime = p.createTime, + + }).ToPageListAsync(pageIndex, pageSize, totalCount); + } + var list = new PageList(page, pageIndex, pageSize, totalCount); + return list; + } + + #endregion + + } +} diff --git a/CoreCms.Net.Services/CoreCms.Net.Services.csproj b/CoreCms.Net.Services/CoreCms.Net.Services.csproj index e3fc9366..96697089 100644 --- a/CoreCms.Net.Services/CoreCms.Net.Services.csproj +++ b/CoreCms.Net.Services/CoreCms.Net.Services.csproj @@ -6,6 +6,7 @@ + diff --git a/CoreCms.Net.Services/Pay/AliPayServices.cs b/CoreCms.Net.Services/Pay/AliPayServices.cs index a1543595..e6190a13 100644 --- a/CoreCms.Net.Services/Pay/AliPayServices.cs +++ b/CoreCms.Net.Services/Pay/AliPayServices.cs @@ -18,19 +18,19 @@ using System.Threading.Tasks; using NLog; using System; using System.Globalization; +using CoreCms.Net.Model.Options; using CoreCms.Net.Utility.Extensions; using CoreCms.Net.Utility.Helper; using Essensoft.Paylink.Alipay; using Essensoft.Paylink.Alipay.Domain; using Essensoft.Paylink.Alipay.Request; using Microsoft.Extensions.DependencyInjection; -using Essensoft.Paylink.WeChatPay; using Microsoft.Extensions.Options; using Newtonsoft.Json.Linq; -using static Aliyun.OSS.Model.LiveChannelStat; -using Essensoft.Paylink.WeChatPay.V2.Request; -using Essensoft.Paylink.WeChatPay.V2; -using static SKIT.FlurlHttpClient.Wechat.Api.Models.ShopCouponGetResponse.Types.Result.Types.Coupon.Types.CouponDetail.Types.Discount.Types.DiscountCondidtion.Types; +using Aop.Api; +using static SKIT.FlurlHttpClient.Wechat.Api.Models.WxaICPApplyICPFilingRequest.Types; +using Microsoft.IdentityModel.Tokens; + namespace CoreCms.Net.Services { @@ -42,17 +42,19 @@ namespace CoreCms.Net.Services private readonly IAlipayClient _client; private readonly IServiceProvider _serviceProvider; private readonly IAlipayConfigServices _alipayConfigServices; + private readonly AliPayOptions _options; - - public AliPayServices(IWeChatPayRepository dal, IServiceProvider serviceProvider, IAlipayClient client, IAlipayConfigServices alipayConfigServices) + public AliPayServices(IWeChatPayRepository dal, IServiceProvider serviceProvider, IAlipayClient client, IAlipayConfigServices alipayConfigServices, IOptions options) { _serviceProvider = serviceProvider; _client = client; _alipayConfigServices = alipayConfigServices; + _options = options.Value; BaseDal = dal; } + #region 发起支付宝支付 /// /// 发起支付宝支付 /// @@ -63,7 +65,14 @@ 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 _aliPayUserInfoServices = container.ServiceProvider.GetService(); + + var aliUserInfo = await _aliPayUserInfoServices.QueryByClauseAsync(p => p.userInfoId == entity.userId); + if (aliUserInfo == null) + { + jm.msg = "支付宝下单用户获取失败"; + return jm; + } var tradeType = GlobalEnumVars.AliPayPayTradeType.ScanQRCodes.ToString(); if (!string.IsNullOrEmpty(entity.parameters)) @@ -73,8 +82,6 @@ namespace CoreCms.Net.Services tradeType = PayHelper.GetAliPayPayTradeType(value.ObjectToString()); } - - var config = await _alipayConfigServices.QueryByClauseAsync(p => p.isDefault == true && p.isEnable == true && p.appType == tradeType); if (config == null) { @@ -90,7 +97,6 @@ namespace CoreCms.Net.Services var notifyUrl = config.notifyUrl.EndsWith("/") ? config.notifyUrl + "m-" + config.appId : config.notifyUrl + "/m-" + config.appId; - //构建linkPay请求配置实体 var payOptions = new AlipayOptions { @@ -132,30 +138,43 @@ namespace CoreCms.Net.Services jm.status = !response.IsError; } + //支付宝小程序支付 else if (tradeType == GlobalEnumVars.AliPayPayTradeType.JSAPI.ToString()) { - var model = new AlipayTradePagePayModel + Aop.Api.IAopClient alipayClient = new Aop.Api.DefaultAopClient(_options.AliPublicApi, _options.AppId, _options.AppSecret, "json", "1.0", "RSA2", _options.AliPublicKey, "utf-8", false); + + Aop.Api.Request.AlipayTradeCreateRequest request = new Aop.Api.Request.AlipayTradeCreateRequest(); + Aop.Api.Domain.AlipayTradeCreateModel model = new Aop.Api.Domain.AlipayTradeCreateModel(); + model.OutTradeNo = entity.paymentId; + model.TotalAmount = entity.money.ToString(CultureInfo.InvariantCulture); + model.Subject = entity.payTitle.Length > 40 ? entity.payTitle[..40] : entity.payTitle; + model.ProductCode = "JSAPI_PAY"; + model.OpAppId = _options.AppId; + model.Body = entity.payTitle.Length > 40 ? entity.payTitle[..40] : entity.payTitle; + + + if (!string.IsNullOrEmpty(aliUserInfo.userId)) { - OutTradeNo = entity.paymentId, - Subject = entity.payTitle.Length > 40 ? entity.payTitle[..40] : entity.payTitle, - ProductCode = "JSAPI_PAY", - TotalAmount = entity.money.ToString(CultureInfo.InvariantCulture), - Body = entity.payTitle.Length > 40 ? entity.payTitle[..40] : entity.payTitle + model.BuyerId = aliUserInfo.userId; + } + if (!string.IsNullOrEmpty(aliUserInfo.openId)) + { + model.OpBuyerOpenId = aliUserInfo.openId; + } + request.SetBizModel(model); + request.SetNotifyUrl(notifyUrl); + Aop.Api.Response.AlipayTradeCreateResponse response = alipayClient.Execute(request); + + jm.data = new + { + entity.paymentId, + response.TradeNo }; - var req = new AlipayTradePagePayRequest(); - req.SetBizModel(model); - req.SetNotifyUrl(notifyUrl); - //req.SetReturnUrl(config.jumpUrl); - - Loging.NLogUtil.WriteAll(NLog.LogLevel.Trace, Loging.LogType.Order, "支付宝JSAPI支付拼接支付宝小程序入参", JsonConvert.SerializeObject(model)); - var response = await _client.PageExecuteAsync(req, payOptions); - Loging.NLogUtil.WriteAll(NLog.LogLevel.Trace, Loging.LogType.Order, "支付宝JSAPI支付返回数据", JsonConvert.SerializeObject(response)); - - jm.data = response.Body; - //response.TradeNo = entity.paymentId; jm.otherData = response; jm.status = !response.IsError; + jm.msg = response.IsError ? response.SubMsg : "支付宝小程序支付参数构建成功。"; + } //PC网站支付 else if (tradeType == GlobalEnumVars.AliPayPayTradeType.JSAPI_PC.ToString()) @@ -179,7 +198,7 @@ namespace CoreCms.Net.Services jm.data = response.Body; - //response.TradeNo = entity.paymentId; + response.TradeNo = entity.paymentId; jm.otherData = response; jm.status = !response.IsError; @@ -245,8 +264,9 @@ namespace CoreCms.Net.Services return jm; } + #endregion - + #region 用户退款 /// /// 用户退款 /// @@ -315,6 +335,47 @@ namespace CoreCms.Net.Services return jm; } + #endregion + + #region 换取授权访问令牌(alipay.system.oauth.token) + /// + /// 根据票据返回app_auth_token相关信息 + /// + /// 票据 + /// + public Aop.Api.Response.AlipaySystemOauthTokenResponse GetAliPayAppAuthTokenBYCode(string code) + { + Aop.Api.IAopClient alipayClient = new Aop.Api.DefaultAopClient(_options.AliPublicApi, _options.AppId, _options.AppSecret, "json", "1.0", "RSA2", _options.AliPublicKey, "utf-8", false); + + Aop.Api.Request.AlipaySystemOauthTokenRequest request = new Aop.Api.Request.AlipaySystemOauthTokenRequest(); + + request.GrantType = "authorization_code"; + request.Code = code; + request.RefreshToken = _options.AliAccessTokenRefresh; + + Aop.Api.Response.AlipaySystemOauthTokenResponse response = alipayClient.Execute(request); + + return response; + } + #endregion + + + #region 支付宝会员授权信息查询接口(alipay.user.info.share) + /// + /// 根据Token返回支付宝用户基本信息 + /// + /// Token + public Aop.Api.Response.AlipayUserInfoShareResponse GetAliPayUserInfoByToken(string token) + { + Aop.Api.IAopClient alipayClient = new Aop.Api.DefaultAopClient(_options.AliPublicApi, _options.AppId, _options.AppSecret, "json", "1.0", "RSA2", _options.AliPublicKey, "utf-8", false); + + Aop.Api.Request.AlipayUserInfoShareRequest request = new Aop.Api.Request.AlipayUserInfoShareRequest(); + Aop.Api.Response.AlipayUserInfoShareResponse response = alipayClient.Execute(request, token); + + return response; + } + + #endregion } diff --git a/CoreCms.Net.Services/User/CoreCmsAliPayUserInfoServices.cs b/CoreCms.Net.Services/User/CoreCmsAliPayUserInfoServices.cs new file mode 100644 index 00000000..b96024a0 --- /dev/null +++ b/CoreCms.Net.Services/User/CoreCmsAliPayUserInfoServices.cs @@ -0,0 +1,116 @@ +/*********************************************************************** + * Project: CoreCms + * ProjectName: 核心内容管理系统 + * Web: https://www.corecms.net + * Author: 大灰灰 + * Email: jianweie@163.com + * CreateTime: 2024/4/10 星期三 22:28:09 + * 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 CoreCmsAliPayUserInfoServices : BaseServices, ICoreCmsAliPayUserInfoServices + { + private readonly ICoreCmsAliPayUserInfoRepository _dal; + private readonly IUnitOfWork _unitOfWork; + + public CoreCmsAliPayUserInfoServices(IUnitOfWork unitOfWork, ICoreCmsAliPayUserInfoRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + _unitOfWork = unitOfWork; + } + + #region 实现重写增删改查操作========================================================== + + /// + /// 重写异步插入方法 + /// + /// 实体数据 + /// + public async Task InsertAsync(CoreCmsAliPayUserInfo entity) + { + return await _dal.InsertAsync(entity); + } + + /// + /// 重写异步更新方法方法 + /// + /// + /// + public async Task UpdateAsync(CoreCmsAliPayUserInfo 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 + + } +} diff --git a/CoreCms.Net.Services/User/CoreCmsUserServices.cs b/CoreCms.Net.Services/User/CoreCmsUserServices.cs index 890a8184..f12cb8ba 100644 --- a/CoreCms.Net.Services/User/CoreCmsUserServices.cs +++ b/CoreCms.Net.Services/User/CoreCmsUserServices.cs @@ -571,7 +571,7 @@ public class CoreCmsUserServices : BaseServices, ICoreCmsUserServic /// 登录方式(1普通,2短信,3微信小程序拉取手机号) /// /// - public async Task SmsLogin(FMWxAccountCreate entity, + public async Task SmsLogin(FMComAccountCreate entity, int loginType = (int)GlobalEnumVars.LoginType.WeChatPhoneNumber, int platform = (int)GlobalEnumVars.CoreShopSystemCategory.Api) { diff --git a/CoreCms.Net.Uni-App/CoreShop/common/request/http.api.js b/CoreCms.Net.Uni-App/CoreShop/common/request/http.api.js index fcb6408a..3321e2ec 100644 --- a/CoreCms.Net.Uni-App/CoreShop/common/request/http.api.js +++ b/CoreCms.Net.Uni-App/CoreShop/common/request/http.api.js @@ -428,7 +428,10 @@ const install = (Vue, vm) => { let submitInvoiceApply = (params, config = {}) => http.post('/Api/Order/SubmitInvoiceApply', params, { custom: { methodName: 'order.submitInvoiceApply', needToken: true } }); - + //支付宝解析code + let getAliPayAppAuthTokenBYCode = (params, config = {}) => http.post('/Api/AliPayAuth/getAliPayAppAuthTokenBYCode', params, { custom: { methodName: 'user.GetAliPayAppAuthTokenByCode', needToken: false } }); + //支付宝小程序手机授权(拉取手机号码) + let loginByGetPhoneNumberForAli = (params, config = {}) => http.post('/Api/User/DecryptPhoneNumberByAli', params, { custom: { methodName: 'user.loginByGetPhoneNumberForAli', needToken: false } }); // 将各个定义的接口名称,统一放进对象挂载到vm.$u.api(因为vm就是this,也即this.$u.api)下 vm.$u.api = { @@ -632,7 +635,10 @@ const install = (Vue, vm) => { uploadFilesFByBase64, getPromotionList, checkInvoice, - submitInvoiceApply + submitInvoiceApply, + + getAliPayAppAuthTokenBYCode, + loginByGetPhoneNumberForAli }; } diff --git a/CoreCms.Net.Uni-App/CoreShop/components/coreshop-fab/coreshop-fab.vue b/CoreCms.Net.Uni-App/CoreShop/components/coreshop-fab/coreshop-fab.vue index 2ed7f937..e55909a6 100644 --- a/CoreCms.Net.Uni-App/CoreShop/components/coreshop-fab/coreshop-fab.vue +++ b/CoreCms.Net.Uni-App/CoreShop/components/coreshop-fab/coreshop-fab.vue @@ -10,7 +10,7 @@ }" :style="{ 'background-color': styles.buttonColor }" @click="open"> - + + @click="taps(index, item)"> + :src="item.active ? item.selectedIconPath : item.iconPath" + mode="aspectFit"> {{ item.text }} diff --git a/CoreCms.Net.Uni-App/CoreShop/components/coreshop-login-modal/coreshop-login-modal.scss b/CoreCms.Net.Uni-App/CoreShop/components/coreshop-login-modal/coreshop-login-modal.scss index a22950ec..439255a1 100644 --- a/CoreCms.Net.Uni-App/CoreShop/components/coreshop-login-modal/coreshop-login-modal.scss +++ b/CoreCms.Net.Uni-App/CoreShop/components/coreshop-login-modal/coreshop-login-modal.scss @@ -36,3 +36,6 @@ .noCaptcha { display: block; } .regain { display: block; } } + + +.aliGetNumberButton { height: 40px; position: relative; -webkit-box-align: center; -webkit-align-items: center; align-items: center; -webkit-box-pack: center; -webkit-justify-content: center; justify-content: center; display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-orient: horizontal; -webkit-box-direction: normal; -webkit-flex-direction: row; flex-direction: row; box-sizing: border-box; flex-direction: row; padding: 0 12px; font-size: 14px; color: #fff; background-color: #5ac725; border-color: #5ac725; border-width: 1px; border-style: solid; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; } diff --git a/CoreCms.Net.Uni-App/CoreShop/components/coreshop-login-modal/coreshop-login-modal.vue b/CoreCms.Net.Uni-App/CoreShop/components/coreshop-login-modal/coreshop-login-modal.vue index b76a6bff..af4b85e1 100644 --- a/CoreCms.Net.Uni-App/CoreShop/components/coreshop-login-modal/coreshop-login-modal.vue +++ b/CoreCms.Net.Uni-App/CoreShop/components/coreshop-login-modal/coreshop-login-modal.vue @@ -1,7 +1,7 @@