mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2026-05-14 01:07:21 +08:00
添加项目文件。
This commit is contained in:
@@ -0,0 +1,242 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* 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 CoreCmsDistributionConditionRepository : BaseRepository<CoreCmsDistributionCondition>, ICoreCmsDistributionConditionRepository
|
||||
{
|
||||
public CoreCmsDistributionConditionRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
#region 实现重写增删改查操作==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> InsertAsync(CoreCmsDistributionCondition entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
if (await DbClient.Queryable<CoreCmsDistributionCondition>().AnyAsync(p => p.gradeId == entity.gradeId && p.code == entity.code))
|
||||
{
|
||||
jm.msg = "存在相同【升级条件】";
|
||||
return jm;
|
||||
}
|
||||
|
||||
var bl = await DbClient.Insertable(entity).ExecuteReturnIdentityAsync() > 0;
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.CreateSuccess : GlobalConstVars.CreateFailure;
|
||||
if (bl)
|
||||
{
|
||||
await UpdateCaChe();
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> UpdateAsync(CoreCmsDistributionCondition entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
if (await DbClient.Queryable<CoreCmsDistributionCondition>().AnyAsync(p => p.gradeId == entity.gradeId && p.code == entity.code && p.id != entity.id))
|
||||
{
|
||||
jm.msg = "存在相同【升级条件】";
|
||||
return jm;
|
||||
}
|
||||
|
||||
var oldModel = await DbClient.Queryable<CoreCmsDistributionCondition>().In(entity.id).SingleAsync();
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
//事物处理过程开始
|
||||
//oldModel.id = entity.id;
|
||||
oldModel.gradeId = entity.gradeId;
|
||||
oldModel.code = entity.code;
|
||||
oldModel.parameters = entity.parameters;
|
||||
|
||||
//事物处理过程结束
|
||||
var bl = await DbClient.Updateable(oldModel).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
|
||||
if (bl)
|
||||
{
|
||||
await UpdateCaChe();
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> UpdateAsync(List<CoreCmsDistributionCondition> entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var bl = await DbClient.Updateable(entity).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
|
||||
if (bl)
|
||||
{
|
||||
await UpdateCaChe();
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写删除指定ID的数据
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> DeleteByIdAsync(object id)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var bl = await DbClient.Deleteable<CoreCmsDistributionCondition>(id).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
||||
if (bl)
|
||||
{
|
||||
await UpdateCaChe();
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写删除指定ID集合的数据(批量删除)
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> DeleteByIdsAsync(int[] ids)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var bl = await DbClient.Deleteable<CoreCmsDistributionCondition>().In(ids).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
||||
if (bl)
|
||||
{
|
||||
await UpdateCaChe();
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 获取缓存的所有数据==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 获取缓存的所有数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<CoreCmsDistributionCondition>> GetCaChe()
|
||||
{
|
||||
var cache = ManualDataCache.Instance.Get<List<CoreCmsDistributionCondition>>(GlobalConstVars.CacheCoreCmsDistributionCondition);
|
||||
if (cache != null)
|
||||
{
|
||||
return cache;
|
||||
}
|
||||
return await UpdateCaChe();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新cache
|
||||
/// </summary>
|
||||
public async Task<List<CoreCmsDistributionCondition>> UpdateCaChe()
|
||||
{
|
||||
var list = await DbClient.Queryable<CoreCmsDistributionCondition>().With(SqlWith.NoLock).ToListAsync();
|
||||
ManualDataCache.Instance.Set(GlobalConstVars.CacheCoreCmsDistributionCondition, list);
|
||||
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 new async Task<IPageList<CoreCmsDistributionCondition>> QueryPageAsync(Expression<Func<CoreCmsDistributionCondition, bool>> predicate,
|
||||
Expression<Func<CoreCmsDistributionCondition, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsDistributionCondition> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsDistributionCondition>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsDistributionCondition
|
||||
{
|
||||
id = p.id,
|
||||
gradeId = p.gradeId,
|
||||
code = p.code,
|
||||
parameters = p.parameters,
|
||||
|
||||
}).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsDistributionCondition>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsDistributionCondition
|
||||
{
|
||||
id = p.id,
|
||||
gradeId = p.gradeId,
|
||||
code = p.code,
|
||||
parameters = p.parameters,
|
||||
|
||||
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsDistributionCondition>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* 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 CoreCmsDistributionGradeRepository : BaseRepository<CoreCmsDistributionGrade>, ICoreCmsDistributionGradeRepository
|
||||
{
|
||||
public CoreCmsDistributionGradeRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
#region 实现重写增删改查操作==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> InsertAsync(CoreCmsDistributionGrade entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
if (await DbClient.Queryable<CoreCmsDistributionGrade>().AnyAsync(p => p.sortId == entity.sortId))
|
||||
{
|
||||
jm.msg = "存在相同等级排序,请更换!";
|
||||
return jm;
|
||||
}
|
||||
|
||||
var id = await DbClient.Insertable(entity).ExecuteReturnIdentityAsync();
|
||||
var bl = id > 0;
|
||||
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.CreateSuccess : GlobalConstVars.CreateFailure;
|
||||
if (bl)
|
||||
{
|
||||
if (entity.isDefault == true)
|
||||
{
|
||||
await DbClient.Updateable<CoreCmsDistributionGrade>().SetColumns(p => p.isDefault == false).Where(p => p.isDefault == true && p.id != id).ExecuteCommandAsync();
|
||||
}
|
||||
await UpdateCaChe();
|
||||
}
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> UpdateAsync(CoreCmsDistributionGrade entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
if (await DbClient.Queryable<CoreCmsDistributionGrade>().AnyAsync(p => p.sortId == entity.sortId && entity.id != p.id))
|
||||
{
|
||||
jm.msg = "存在相同等级排序,请更换!";
|
||||
return jm;
|
||||
}
|
||||
|
||||
if (entity.isDefault == false)
|
||||
{
|
||||
var otherHave = await DbClient.Queryable<CoreCmsDistributionGrade>().AnyAsync(p => p.isDefault == true && p.id != entity.id);
|
||||
if (otherHave == false)
|
||||
{
|
||||
jm.msg = "请保持一个默认分销等级";
|
||||
return jm;
|
||||
}
|
||||
}
|
||||
|
||||
var oldModel = await DbClient.Queryable<CoreCmsDistributionGrade>().In(entity.id).SingleAsync();
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
//事物处理过程开始
|
||||
//oldModel.id = entity.id;
|
||||
oldModel.name = entity.name;
|
||||
oldModel.isDefault = entity.isDefault;
|
||||
oldModel.isAutoUpGrade = entity.isAutoUpGrade;
|
||||
oldModel.sortId = entity.sortId;
|
||||
oldModel.description = entity.description;
|
||||
|
||||
//事物处理过程结束
|
||||
var bl = await DbClient.Updateable(oldModel).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
|
||||
if (bl)
|
||||
{
|
||||
//其他处理
|
||||
if (entity.isDefault)
|
||||
{
|
||||
await DbClient.Updateable<CoreCmsDistributionGrade>().SetColumns(it => it.isDefault == false).Where(p => p.isDefault == true && p.id != entity.id).ExecuteCommandAsync();
|
||||
}
|
||||
await UpdateCaChe();
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重写删除指定ID的数据
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<AdminUiCallBack> DeleteByIdAsync(int id)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
if (await DbClient.Queryable<CoreCmsDistribution>().AnyAsync(p => p.gradeId == id))
|
||||
{
|
||||
jm.msg = "存在关联的分销用户数据,禁止删除";
|
||||
return jm;
|
||||
}
|
||||
var bl = await DbClient.Deleteable<CoreCmsDistributionGrade>(id).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
||||
if (bl)
|
||||
{
|
||||
await DbClient.Deleteable<CoreCmsDistributionCondition>().Where(p => p.gradeId == id).ExecuteCommandAsync();
|
||||
await DbClient.Deleteable<CoreCmsDistributionResult>().Where(p => p.gradeId == id).ExecuteCommandAsync();
|
||||
await UpdateCaChe();
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 获取缓存的所有数据==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 获取缓存的所有数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<CoreCmsDistributionGrade>> GetCaChe()
|
||||
{
|
||||
var cache = ManualDataCache.Instance.Get<List<CoreCmsDistributionGrade>>(GlobalConstVars.CacheCoreCmsDistributionGrade);
|
||||
if (cache != null)
|
||||
{
|
||||
return cache;
|
||||
}
|
||||
return await UpdateCaChe();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新cache
|
||||
/// </summary>
|
||||
public async Task<List<CoreCmsDistributionGrade>> UpdateCaChe()
|
||||
{
|
||||
var list = await DbClient.Queryable<CoreCmsDistributionGrade>().With(SqlWith.NoLock).ToListAsync();
|
||||
ManualDataCache.Instance.Set(GlobalConstVars.CacheCoreCmsDistributionGrade, list);
|
||||
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 new async Task<IPageList<CoreCmsDistributionGrade>> QueryPageAsync(Expression<Func<CoreCmsDistributionGrade, bool>> predicate,
|
||||
Expression<Func<CoreCmsDistributionGrade, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsDistributionGrade> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsDistributionGrade>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsDistributionGrade
|
||||
{
|
||||
id = p.id,
|
||||
name = p.name,
|
||||
isDefault = p.isDefault,
|
||||
isAutoUpGrade = p.isAutoUpGrade,
|
||||
sortId = p.sortId,
|
||||
description = p.description,
|
||||
|
||||
}).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsDistributionGrade>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsDistributionGrade
|
||||
{
|
||||
id = p.id,
|
||||
name = p.name,
|
||||
isDefault = p.isDefault,
|
||||
isAutoUpGrade = p.isAutoUpGrade,
|
||||
sortId = p.sortId,
|
||||
description = p.description,
|
||||
|
||||
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsDistributionGrade>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,377 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
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 CoreCmsDistributionOrderRepository : BaseRepository<CoreCmsDistributionOrder>, ICoreCmsDistributionOrderRepository
|
||||
{
|
||||
public CoreCmsDistributionOrderRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
#region 实现重写增删改查操作==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> InsertAsync(CoreCmsDistributionOrder 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 new async Task<AdminUiCallBack> UpdateAsync(CoreCmsDistributionOrder entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var oldModel = await DbClient.Queryable<CoreCmsDistributionOrder>().In(entity.id).SingleAsync();
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
//事物处理过程开始
|
||||
oldModel.id = entity.id;
|
||||
oldModel.userId = entity.userId;
|
||||
oldModel.buyUserId = entity.buyUserId;
|
||||
oldModel.orderId = entity.orderId;
|
||||
oldModel.amount = entity.amount;
|
||||
oldModel.isSettlement = entity.isSettlement;
|
||||
oldModel.level = entity.level;
|
||||
oldModel.createTime = entity.createTime;
|
||||
oldModel.updateTime = entity.updateTime;
|
||||
oldModel.isDelete = entity.isDelete;
|
||||
|
||||
//事物处理过程结束
|
||||
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 new async Task<AdminUiCallBack> UpdateAsync(List<CoreCmsDistributionOrder> 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 new async Task<AdminUiCallBack> DeleteByIdAsync(object id)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var bl = await DbClient.Deleteable<CoreCmsDistributionOrder>(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 new async Task<AdminUiCallBack> DeleteByIdsAsync(int[] ids)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var bl = await DbClient.Deleteable<CoreCmsDistributionOrder>().In(ids).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
#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 new async Task<IPageList<CoreCmsDistributionOrder>> QueryPageAsync(Expression<Func<CoreCmsDistributionOrder, bool>> predicate,
|
||||
Expression<Func<CoreCmsDistributionOrder, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsDistributionOrder> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsDistributionOrder, CoreCmsOrder, CoreCmsUser, CoreCmsUser>((dOrder, cOrder, cUser, pUser) => new object[] {
|
||||
JoinType.Inner,dOrder.orderId==cOrder.orderId,
|
||||
JoinType.Inner,dOrder.buyUserId==cUser.id,
|
||||
JoinType.Inner,dOrder.userId==pUser.id
|
||||
})
|
||||
.Select((dOrder, cOrder, cUser, pUser) => new CoreCmsDistributionOrder
|
||||
{
|
||||
id = dOrder.id,
|
||||
userId = dOrder.userId,
|
||||
buyUserId = dOrder.buyUserId,
|
||||
orderId = dOrder.orderId,
|
||||
amount = dOrder.amount,
|
||||
isSettlement = dOrder.isSettlement,
|
||||
level = dOrder.level,
|
||||
createTime = dOrder.createTime,
|
||||
updateTime = dOrder.updateTime,
|
||||
isDelete = dOrder.isDelete,
|
||||
buyUserNickName = cUser.nickName,
|
||||
distributorName = pUser.nickName
|
||||
})
|
||||
.With(SqlWith.NoLock)
|
||||
.MergeTable()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsDistributionOrder, CoreCmsOrder, CoreCmsUser, CoreCmsUser>((dOrder, cOrder, cUser, pUser) => new object[] {
|
||||
JoinType.Inner,dOrder.orderId==cOrder.orderId,
|
||||
JoinType.Inner,dOrder.buyUserId==cUser.id,
|
||||
JoinType.Inner,dOrder.userId==pUser.id
|
||||
})
|
||||
.Select((dOrder, cOrder, cUser, pUser) => new CoreCmsDistributionOrder
|
||||
{
|
||||
id = dOrder.id,
|
||||
userId = dOrder.userId,
|
||||
buyUserId = dOrder.buyUserId,
|
||||
orderId = dOrder.orderId,
|
||||
amount = dOrder.amount,
|
||||
isSettlement = dOrder.isSettlement,
|
||||
level = dOrder.level,
|
||||
createTime = dOrder.createTime,
|
||||
updateTime = dOrder.updateTime,
|
||||
isDelete = dOrder.isDelete,
|
||||
buyUserNickName = cUser.nickName,
|
||||
distributorName = pUser.nickName
|
||||
})
|
||||
.MergeTable()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsDistributionOrder>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取下级推广订单数量
|
||||
/// </summary>
|
||||
/// <param name="parentId">父类序列</param>
|
||||
/// <param name="type">1获取1级,其他为2级,0为全部</param>
|
||||
/// <param name="thisMonth">显示当月</param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> QueryChildOrderCountAsync(int parentId, int type = 1, bool thisMonth = false)
|
||||
{
|
||||
var totalSum = 0;
|
||||
|
||||
DateTime dt = DateTime.Now;
|
||||
//本月第一天时间
|
||||
DateTime dtFirst = dt.AddDays(1 - (dt.Day));
|
||||
dtFirst = new DateTime(dtFirst.Year, dtFirst.Month, dtFirst.Day, 0, 0, 0);
|
||||
|
||||
//获得某年某月的天数
|
||||
int dayCount = DateTime.DaysInMonth(dt.Date.Year, dt.Date.Month);
|
||||
//本月最后一天时间
|
||||
DateTime dtLast = dtFirst.AddDays(dayCount - 1);
|
||||
|
||||
if (type == 1)
|
||||
{
|
||||
totalSum = await DbClient.Queryable<CoreCmsDistributionOrder, CoreCmsUser>((orders, users) => new JoinQueryInfos(JoinType.Left, orders.buyUserId == users.id))
|
||||
.WhereIF(thisMonth == true, (orders, users) => orders.createTime > dtFirst && orders.createTime < dtLast)
|
||||
.Where((orders, users) => users.parentId == parentId)
|
||||
.With(SqlWith.NoLock)
|
||||
.WithCache(60 * 60)
|
||||
.CountAsync();
|
||||
|
||||
return totalSum;
|
||||
}
|
||||
else if (type == 2)
|
||||
{
|
||||
//获取一级列表
|
||||
List<int> firstIds = await DbClient.Queryable<CoreCmsUser>().Where(p => p.parentId == parentId).Select(p => p.id).ToListAsync();
|
||||
if (firstIds.Count == 0)
|
||||
{
|
||||
return totalSum;
|
||||
}
|
||||
var allIds = await DbClient.Queryable<CoreCmsUser>().Where(p => firstIds.Contains(p.parentId)).Select(p => p.id).ToListAsync();
|
||||
if (allIds.Count == 0)
|
||||
{
|
||||
return totalSum;
|
||||
}
|
||||
totalSum = await DbClient.Queryable<CoreCmsDistributionOrder>()
|
||||
.Where(p => allIds.Contains(p.buyUserId))
|
||||
.WhereIF(thisMonth, p => p.createTime > dtFirst && p.createTime < dtLast)
|
||||
.With(SqlWith.NoLock)
|
||||
.WithCache(60 * 60)
|
||||
.CountAsync();
|
||||
|
||||
return totalSum;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//获取一级列表
|
||||
List<int> firstIds = await DbClient.Queryable<CoreCmsUser>().Where(p => p.parentId == parentId).Select(p => p.id).ToListAsync();
|
||||
if (firstIds.Count == 0)
|
||||
{
|
||||
return totalSum;
|
||||
}
|
||||
var allIds = await DbClient.Queryable<CoreCmsUser>().Where(p => firstIds.Contains(p.id) || firstIds.Contains(p.parentId)).Select(p => p.id).ToListAsync();
|
||||
if (allIds.Count == 0)
|
||||
{
|
||||
return totalSum;
|
||||
}
|
||||
totalSum = await DbClient.Queryable<CoreCmsDistributionOrder>()
|
||||
.Where(p => allIds.Contains(p.buyUserId))
|
||||
.WhereIF(thisMonth, p => p.createTime > dtFirst && p.createTime < dtLast)
|
||||
.With(SqlWith.NoLock)
|
||||
.WithCache(60 * 60)
|
||||
.CountAsync();
|
||||
|
||||
return totalSum;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取下级推广订单金额
|
||||
/// </summary>
|
||||
/// <param name="parentId">父类序列</param>
|
||||
/// <param name="type">1获取1级,其他为2级,0为全部</param>
|
||||
/// <param name="thisMonth">显示当月</param>
|
||||
/// <returns></returns>
|
||||
public async Task<decimal> QueryChildOrderMoneySumAsync(int parentId, int type = 1, bool thisMonth = false)
|
||||
{
|
||||
decimal totalSum = 0;
|
||||
|
||||
DateTime dt = DateTime.Now;
|
||||
//本月第一天时间
|
||||
DateTime dtFirst = dt.AddDays(1 - (dt.Day));
|
||||
dtFirst = new DateTime(dtFirst.Year, dtFirst.Month, dtFirst.Day, 0, 0, 0);
|
||||
//获得某年某月的天数
|
||||
int year = dt.Date.Year;
|
||||
int month = dt.Date.Month;
|
||||
int dayCount = DateTime.DaysInMonth(year, month);
|
||||
//本月最后一天时间
|
||||
DateTime dtLast = dtFirst.AddDays(dayCount - 1);
|
||||
|
||||
if (type == 1)
|
||||
{
|
||||
totalSum = await DbClient.Queryable<CoreCmsDistributionOrder, CoreCmsUser>((orders, users) =>
|
||||
new JoinQueryInfos(JoinType.Left, orders.buyUserId == users.id))
|
||||
.Where((orders, users) => users.parentId == parentId)
|
||||
.WhereIF(thisMonth, (orders, users) => orders.createTime > dtFirst && orders.createTime < dtLast)
|
||||
.With(SqlWith.NoLock)
|
||||
.WithCache(60 * 60)
|
||||
.SumAsync((orders, users) => orders.amount);
|
||||
return totalSum;
|
||||
}
|
||||
else if (type == 2)
|
||||
{
|
||||
//获取一级列表
|
||||
List<int> firstIds = await DbClient.Queryable<CoreCmsUser>().Where(p => p.parentId == parentId).Select(p => p.id).ToListAsync();
|
||||
if (firstIds.Count == 0)
|
||||
{
|
||||
return totalSum;
|
||||
}
|
||||
var allIds = await DbClient.Queryable<CoreCmsUser>().Where(p => firstIds.Contains(p.parentId)).Select(p => p.id).ToListAsync();
|
||||
if (allIds.Count == 0)
|
||||
{
|
||||
return totalSum;
|
||||
}
|
||||
totalSum = await DbClient.Queryable<CoreCmsDistributionOrder, CoreCmsUser>((orders, users) => new JoinQueryInfos(JoinType.Left, orders.buyUserId == users.id))
|
||||
.Where((orders, users) => allIds.Contains(orders.buyUserId))
|
||||
.WhereIF(thisMonth, (orders, users) => orders.createTime > dtFirst && orders.createTime < dtLast)
|
||||
.With(SqlWith.NoLock)
|
||||
.WithCache(60 * 60)
|
||||
.SumAsync((orders, users) => orders.amount);
|
||||
return totalSum;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//获取全部
|
||||
List<int> firstIds = await DbClient.Queryable<CoreCmsUser>().Where(p => p.parentId == parentId).Select(p => p.id).ToListAsync();
|
||||
if (firstIds.Count == 0)
|
||||
{
|
||||
return totalSum;
|
||||
}
|
||||
var allIds = await DbClient.Queryable<CoreCmsUser>().Where(p => firstIds.Contains(p.id) || firstIds.Contains(p.parentId)).Select(p => p.id).ToListAsync();
|
||||
if (allIds.Count == 0)
|
||||
{
|
||||
return totalSum;
|
||||
}
|
||||
totalSum = await DbClient.Queryable<CoreCmsDistributionOrder, CoreCmsUser>((orders, users) => new JoinQueryInfos(JoinType.Left, orders.buyUserId == users.id))
|
||||
.Where((orders, users) => allIds.Contains(orders.buyUserId))
|
||||
.WhereIF(thisMonth, (orders, users) => orders.createTime > dtFirst && orders.createTime < dtLast)
|
||||
.With(SqlWith.NoLock)
|
||||
.WithCache(60 * 60)
|
||||
.SumAsync((orders, users) => orders.amount);
|
||||
return totalSum;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
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.DTO.Agent;
|
||||
using CoreCms.Net.Model.ViewModels.DTO.Distribution;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 分销商表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsDistributionRepository : BaseRepository<CoreCmsDistribution>, ICoreCmsDistributionRepository
|
||||
{
|
||||
public CoreCmsDistributionRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#region 根据条件查询分页数据
|
||||
|
||||
/// <summary>
|
||||
/// 根据条件查询分页数据
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="pageIndex">当前页面索引</param>
|
||||
/// <param name="pageSize">分布大小</param>
|
||||
/// <param name="typeId">类型</param>
|
||||
/// <returns></returns>
|
||||
public async Task<IPageList<CoreCmsDistributionOrder>> QueryOrderPageAsync(int userId, int pageIndex = 1, int pageSize = 20, int typeId = 0)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
var page = await DbClient.Queryable<CoreCmsDistributionOrder, CoreCmsOrder, CoreCmsUser>((dOrder, cOrder, userInfo) => new object[] {
|
||||
JoinType.Inner,dOrder.orderId==cOrder.orderId,JoinType.Inner,dOrder.buyUserId==userInfo.id
|
||||
})
|
||||
.Where((dOrder, cOrder, userInfo) => dOrder.userId == userId)
|
||||
.Select((dOrder, cOrder, userInfo) => new CoreCmsDistributionOrder()
|
||||
{
|
||||
id = dOrder.id,
|
||||
userId = dOrder.userId,
|
||||
buyUserId = dOrder.buyUserId,
|
||||
orderId = dOrder.orderId,
|
||||
amount = dOrder.amount,
|
||||
isSettlement = dOrder.isSettlement,
|
||||
level = dOrder.level,
|
||||
createTime = dOrder.createTime,
|
||||
updateTime = dOrder.updateTime,
|
||||
isDelete = dOrder.isDelete,
|
||||
buyUserNickName = userInfo.nickName
|
||||
})
|
||||
.With(SqlWith.NoLock)
|
||||
.MergeTable()
|
||||
.WhereIF(typeId > 0, p => p.isSettlement == typeId)
|
||||
.OrderBy(dOrder => dOrder.id, OrderByType.Desc)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
var list = new PageList<CoreCmsDistributionOrder>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 获取代理商排行
|
||||
|
||||
/// <summary>
|
||||
/// 获取代理商排行
|
||||
/// </summary>
|
||||
/// <param name="pageIndex">当前页面索引</param>
|
||||
/// <param name="pageSize">分布大小</param>
|
||||
/// <returns></returns>
|
||||
public async Task<IPageList<DistributionRankingDTO>> QueryRankingPageAsync(int pageIndex = 1, int pageSize = 20)
|
||||
{
|
||||
|
||||
RefAsync<int> totalCount = 0;
|
||||
var page = await DbClient.Queryable<CoreCmsDistribution>()
|
||||
.Select(p => new DistributionRankingDTO()
|
||||
{
|
||||
id = p.userId,
|
||||
nickname = p.name,
|
||||
createtime = p.createTime,
|
||||
totalInCome = SqlFunc.Subqueryable<CoreCmsDistributionOrder>().Where(o => o.userId == p.userId && p.isDelete == false && p.verifyStatus == (int)GlobalEnumVars.DistributionOrderSettlementStatus.SettlementYes).Sum(o => o.amount),
|
||||
orderCount = SqlFunc.Subqueryable<CoreCmsDistributionOrder>().Where(o => o.userId == p.userId && p.isDelete == false && p.verifyStatus == (int)GlobalEnumVars.DistributionOrderSettlementStatus.SettlementYes).Count()
|
||||
})
|
||||
.With(SqlWith.NoLock)
|
||||
.MergeTable()
|
||||
.OrderBy(dOrder => dOrder.totalInCome, OrderByType.Desc)
|
||||
.WithCache()
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
|
||||
var list = new PageList<DistributionRankingDTO>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,241 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* 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 CoreCmsDistributionResultRepository : BaseRepository<CoreCmsDistributionResult>, ICoreCmsDistributionResultRepository
|
||||
{
|
||||
public CoreCmsDistributionResultRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
#region 实现重写增删改查操作==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> InsertAsync(CoreCmsDistributionResult entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
if (await DbClient.Queryable<CoreCmsDistributionResult>().AnyAsync(p => p.gradeId == entity.gradeId && p.code == entity.code))
|
||||
{
|
||||
jm.msg = "存在相同级别佣金代码等级";
|
||||
return jm;
|
||||
}
|
||||
|
||||
var bl = await DbClient.Insertable(entity).ExecuteReturnIdentityAsync() > 0;
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.CreateSuccess : GlobalConstVars.CreateFailure;
|
||||
if (bl)
|
||||
{
|
||||
await UpdateCaChe();
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> UpdateAsync(CoreCmsDistributionResult entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
if (await DbClient.Queryable<CoreCmsDistributionResult>().AnyAsync(p => p.gradeId == entity.gradeId && p.code == entity.code && p.id != entity.id))
|
||||
{
|
||||
jm.msg = "存在相同级别佣金代码等级";
|
||||
return jm;
|
||||
}
|
||||
|
||||
var oldModel = await DbClient.Queryable<CoreCmsDistributionResult>().In(entity.id).SingleAsync();
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
//事物处理过程开始
|
||||
//oldModel.id = entity.id;
|
||||
oldModel.gradeId = entity.gradeId;
|
||||
oldModel.code = entity.code;
|
||||
oldModel.parameters = entity.parameters;
|
||||
|
||||
//事物处理过程结束
|
||||
var bl = await DbClient.Updateable(oldModel).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
|
||||
if (bl)
|
||||
{
|
||||
await UpdateCaChe();
|
||||
}
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> UpdateAsync(List<CoreCmsDistributionResult> entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var bl = await DbClient.Updateable(entity).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
|
||||
if (bl)
|
||||
{
|
||||
await UpdateCaChe();
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写删除指定ID的数据
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> DeleteByIdAsync(object id)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var bl = await DbClient.Deleteable<CoreCmsDistributionResult>(id).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
||||
if (bl)
|
||||
{
|
||||
await UpdateCaChe();
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写删除指定ID集合的数据(批量删除)
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> DeleteByIdsAsync(int[] ids)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var bl = await DbClient.Deleteable<CoreCmsDistributionResult>().In(ids).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
||||
if (bl)
|
||||
{
|
||||
await UpdateCaChe();
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 获取缓存的所有数据==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 获取缓存的所有数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<CoreCmsDistributionResult>> GetCaChe()
|
||||
{
|
||||
var cache = ManualDataCache.Instance.Get<List<CoreCmsDistributionResult>>(GlobalConstVars.CacheCoreCmsDistributionResult);
|
||||
if (cache != null)
|
||||
{
|
||||
return cache;
|
||||
}
|
||||
return await UpdateCaChe();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新cache
|
||||
/// </summary>
|
||||
public async Task<List<CoreCmsDistributionResult>> UpdateCaChe()
|
||||
{
|
||||
var list = await DbClient.Queryable<CoreCmsDistributionResult>().With(SqlWith.NoLock).ToListAsync();
|
||||
ManualDataCache.Instance.Set(GlobalConstVars.CacheCoreCmsDistributionResult, list);
|
||||
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 new async Task<IPageList<CoreCmsDistributionResult>> QueryPageAsync(Expression<Func<CoreCmsDistributionResult, bool>> predicate,
|
||||
Expression<Func<CoreCmsDistributionResult, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsDistributionResult> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsDistributionResult>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsDistributionResult
|
||||
{
|
||||
id = p.id,
|
||||
gradeId = p.gradeId,
|
||||
code = p.code,
|
||||
parameters = p.parameters,
|
||||
|
||||
}).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsDistributionResult>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsDistributionResult
|
||||
{
|
||||
id = p.id,
|
||||
gradeId = p.gradeId,
|
||||
code = p.code,
|
||||
parameters = p.parameters,
|
||||
|
||||
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsDistributionResult>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user