mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 21:03:26 +08:00
制作微信支付和支付宝支付后台管理及业务处理
This commit is contained in:
232
CoreCms.Net.Repository/Pay/AlipayConfigRepository.cs
Normal file
232
CoreCms.Net.Repository/Pay/AlipayConfigRepository.cs
Normal file
@@ -0,0 +1,232 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2023/4/20 23:33:03
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Caching.Manual;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 支付宝支付配置 接口实现
|
||||
/// </summary>
|
||||
public class AlipayConfigRepository : BaseRepository<CoreCmsAlipayConfig>, IAlipayConfigRepository
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
public AlipayConfigRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
#region 实现重写增删改查操作==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public async Task<AdminUiCallBack> InsertAsync(CoreCmsAlipayConfig entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var bl = await DbClient.Insertable(entity).ExecuteReturnIdentityAsync() > 0;
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.CreateSuccess : GlobalConstVars.CreateFailure;
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<AdminUiCallBack> UpdateAsync(CoreCmsAlipayConfig entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var oldModel = await DbClient.Queryable<CoreCmsAlipayConfig>().In(entity.id).SingleAsync();
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
//事物处理过程开始
|
||||
oldModel.id = entity.id;
|
||||
oldModel.appId = entity.appId;
|
||||
oldModel.publicKey = entity.publicKey;
|
||||
oldModel.privateKey = entity.privateKey;
|
||||
oldModel.serverUrl = entity.serverUrl;
|
||||
oldModel.signType = entity.signType;
|
||||
oldModel.appPublicCert = entity.appPublicCert;
|
||||
oldModel.alipayPublicCert = entity.alipayPublicCert;
|
||||
oldModel.alipayRootCert = entity.alipayRootCert;
|
||||
oldModel.appType = entity.appType;
|
||||
oldModel.notifyUrl = entity.notifyUrl;
|
||||
oldModel.refundUrl = entity.refundUrl;
|
||||
oldModel.jumpUrl = entity.jumpUrl;
|
||||
oldModel.isEnable = entity.isEnable;
|
||||
oldModel.isDefault = entity.isDefault;
|
||||
|
||||
//事物处理过程结束
|
||||
var bl = await DbClient.Updateable(oldModel).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<AdminUiCallBack> UpdateAsync(List<CoreCmsAlipayConfig> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写删除指定ID的数据
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<AdminUiCallBack> DeleteByIdAsync(object id)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var bl = await DbClient.Deleteable<CoreCmsAlipayConfig>(id).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写删除指定ID集合的数据(批量删除)
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<AdminUiCallBack> DeleteByIdsAsync(int[] ids)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var bl = await DbClient.Deleteable<CoreCmsAlipayConfig>().In(ids).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 获取缓存的所有数据==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 获取缓存的所有数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<CoreCmsAlipayConfig>> GetCaChe()
|
||||
{
|
||||
var list = await DbClient.Queryable<CoreCmsAlipayConfig>().With(SqlWith.NoLock).WithCache().ToListAsync();
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 重写根据条件查询分页数据
|
||||
/// <summary>
|
||||
/// 重写根据条件查询分页数据
|
||||
/// </summary>
|
||||
/// <param name="predicate">判断集合</param>
|
||||
/// <param name="orderByType">排序方式</param>
|
||||
/// <param name="pageIndex">当前页面索引</param>
|
||||
/// <param name="pageSize">分布大小</param>
|
||||
/// <param name="orderByExpression"></param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<IPageList<CoreCmsAlipayConfig>> QueryPageAsync(Expression<Func<CoreCmsAlipayConfig, bool>> predicate,
|
||||
Expression<Func<CoreCmsAlipayConfig, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsAlipayConfig> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsAlipayConfig>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsAlipayConfig
|
||||
{
|
||||
id = p.id,
|
||||
appId = p.appId,
|
||||
publicKey = p.publicKey,
|
||||
privateKey = p.privateKey,
|
||||
serverUrl = p.serverUrl,
|
||||
signType = p.signType,
|
||||
appPublicCert = p.appPublicCert,
|
||||
alipayPublicCert = p.alipayPublicCert,
|
||||
alipayRootCert = p.alipayRootCert,
|
||||
appType = p.appType,
|
||||
notifyUrl = p.notifyUrl,
|
||||
refundUrl = p.refundUrl,
|
||||
jumpUrl = p.jumpUrl,
|
||||
isEnable = p.isEnable,
|
||||
isDefault = p.isDefault,
|
||||
|
||||
}).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsAlipayConfig>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsAlipayConfig
|
||||
{
|
||||
id = p.id,
|
||||
appId = p.appId,
|
||||
publicKey = p.publicKey,
|
||||
privateKey = p.privateKey,
|
||||
serverUrl = p.serverUrl,
|
||||
signType = p.signType,
|
||||
appPublicCert = p.appPublicCert,
|
||||
alipayPublicCert = p.alipayPublicCert,
|
||||
alipayRootCert = p.alipayRootCert,
|
||||
appType = p.appType,
|
||||
notifyUrl = p.notifyUrl,
|
||||
refundUrl = p.refundUrl,
|
||||
jumpUrl = p.jumpUrl,
|
||||
isEnable = p.isEnable,
|
||||
isDefault = p.isDefault,
|
||||
|
||||
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsAlipayConfig>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
232
CoreCms.Net.Repository/Pay/WeChatPayConfigRepository.cs
Normal file
232
CoreCms.Net.Repository/Pay/WeChatPayConfigRepository.cs
Normal file
@@ -0,0 +1,232 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2023/4/22 23:40:15
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Caching.Manual;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 微信支付配置 接口实现
|
||||
/// </summary>
|
||||
public class WeChatPayConfigRepository : BaseRepository<CoreCmsWeChatPayConfig>, IWeChatPayConfigRepository
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
public WeChatPayConfigRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
#region 实现重写增删改查操作==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public async Task<AdminUiCallBack> InsertAsync(CoreCmsWeChatPayConfig entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var bl = await DbClient.Insertable(entity).ExecuteReturnIdentityAsync() > 0;
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.CreateSuccess : GlobalConstVars.CreateFailure;
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<AdminUiCallBack> UpdateAsync(CoreCmsWeChatPayConfig entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var oldModel = await DbClient.Queryable<CoreCmsWeChatPayConfig>().In(entity.id).SingleAsync();
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
//事物处理过程开始
|
||||
oldModel.id = entity.id;
|
||||
oldModel.appId = entity.appId;
|
||||
oldModel.mchId = entity.mchId;
|
||||
oldModel.apiKey = entity.apiKey;
|
||||
oldModel.apiV3Key = entity.apiV3Key;
|
||||
oldModel.certificate = entity.certificate;
|
||||
oldModel.rsaPublicKey = entity.rsaPublicKey;
|
||||
oldModel.subAppId = entity.subAppId;
|
||||
oldModel.subMchId = entity.subMchId;
|
||||
oldModel.notifyUrl = entity.notifyUrl;
|
||||
oldModel.refundUrl = entity.refundUrl;
|
||||
oldModel.jumpUrl = entity.jumpUrl;
|
||||
oldModel.isEnable = entity.isEnable;
|
||||
oldModel.isDefault = entity.isDefault;
|
||||
oldModel.appType = entity.appType;
|
||||
|
||||
//事物处理过程结束
|
||||
var bl = await DbClient.Updateable(oldModel).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<AdminUiCallBack> UpdateAsync(List<CoreCmsWeChatPayConfig> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写删除指定ID的数据
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<AdminUiCallBack> DeleteByIdAsync(object id)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var bl = await DbClient.Deleteable<CoreCmsWeChatPayConfig>(id).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写删除指定ID集合的数据(批量删除)
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<AdminUiCallBack> DeleteByIdsAsync(int[] ids)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var bl = await DbClient.Deleteable<CoreCmsWeChatPayConfig>().In(ids).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 获取缓存的所有数据==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 获取缓存的所有数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<CoreCmsWeChatPayConfig>> GetCaChe()
|
||||
{
|
||||
var list = await DbClient.Queryable<CoreCmsWeChatPayConfig>().With(SqlWith.NoLock).WithCache().ToListAsync();
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 重写根据条件查询分页数据
|
||||
/// <summary>
|
||||
/// 重写根据条件查询分页数据
|
||||
/// </summary>
|
||||
/// <param name="predicate">判断集合</param>
|
||||
/// <param name="orderByType">排序方式</param>
|
||||
/// <param name="pageIndex">当前页面索引</param>
|
||||
/// <param name="pageSize">分布大小</param>
|
||||
/// <param name="orderByExpression"></param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<IPageList<CoreCmsWeChatPayConfig>> QueryPageAsync(Expression<Func<CoreCmsWeChatPayConfig, bool>> predicate,
|
||||
Expression<Func<CoreCmsWeChatPayConfig, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsWeChatPayConfig> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsWeChatPayConfig>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsWeChatPayConfig
|
||||
{
|
||||
id = p.id,
|
||||
appId = p.appId,
|
||||
mchId = p.mchId,
|
||||
apiKey = p.apiKey,
|
||||
apiV3Key = p.apiV3Key,
|
||||
certificate = p.certificate,
|
||||
rsaPublicKey = p.rsaPublicKey,
|
||||
subAppId = p.subAppId,
|
||||
subMchId = p.subMchId,
|
||||
notifyUrl = p.notifyUrl,
|
||||
refundUrl = p.refundUrl,
|
||||
jumpUrl = p.jumpUrl,
|
||||
isEnable = p.isEnable,
|
||||
isDefault = p.isDefault,
|
||||
appType = p.appType,
|
||||
|
||||
}).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsWeChatPayConfig>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsWeChatPayConfig
|
||||
{
|
||||
id = p.id,
|
||||
appId = p.appId,
|
||||
mchId = p.mchId,
|
||||
apiKey = p.apiKey,
|
||||
apiV3Key = p.apiV3Key,
|
||||
certificate = p.certificate,
|
||||
rsaPublicKey = p.rsaPublicKey,
|
||||
subAppId = p.subAppId,
|
||||
subMchId = p.subMchId,
|
||||
notifyUrl = p.notifyUrl,
|
||||
refundUrl = p.refundUrl,
|
||||
jumpUrl = p.jumpUrl,
|
||||
isEnable = p.isEnable,
|
||||
isDefault = p.isDefault,
|
||||
appType = p.appType,
|
||||
|
||||
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsWeChatPayConfig>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user