mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2026-05-09 11:07:21 +08:00
添加项目文件。
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 广告位置表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsAdvertPositionRepository : BaseRepository<CoreCmsAdvertPosition>,
|
||||
ICoreCmsAdvertPositionRepository
|
||||
{
|
||||
public CoreCmsAdvertPositionRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 广告表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsAdvertisementRepository : BaseRepository<CoreCmsAdvertisement>, ICoreCmsAdvertisementRepository
|
||||
{
|
||||
public CoreCmsAdvertisementRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
316
CoreCms.Net.Repository/Agent/CoreCmsAgentGoodsRepository.cs
Normal file
316
CoreCms.Net.Repository/Agent/CoreCmsAgentGoodsRepository.cs
Normal file
@@ -0,0 +1,316 @@
|
||||
/***********************************************************************
|
||||
* 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.Loging;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using NLog;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 代理商品池 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsAgentGoodsRepository : BaseRepository<CoreCmsAgentGoods>, ICoreCmsAgentGoodsRepository
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
public CoreCmsAgentGoodsRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
#region 实现重写增删改查操作==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <param name="products"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<AdminUiCallBack> InsertAsync(CoreCmsAgentGoods entity, List<CoreCmsAgentProducts> products)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
try
|
||||
{
|
||||
var isHave = await DbClient.Queryable<CoreCmsAgentGoods>().AnyAsync(p => p.goodId == entity.goodId);
|
||||
if (isHave)
|
||||
{
|
||||
jm.msg = "此商品已录入代理池";
|
||||
return jm;
|
||||
}
|
||||
|
||||
var good = await DbClient.Queryable<CoreCmsGoods>().FirstAsync(p => p.id == entity.goodId);
|
||||
if (good == null)
|
||||
{
|
||||
jm.msg = "商品不存在";
|
||||
return jm;
|
||||
}
|
||||
|
||||
_unitOfWork.BeginTran();
|
||||
|
||||
entity.createTime = DateTime.Now;
|
||||
entity.goodRefreshTime = good.updateTime;
|
||||
|
||||
var id = await DbClient.Insertable(entity).ExecuteReturnIdentityAsync();
|
||||
if (id <= 0)
|
||||
{
|
||||
_unitOfWork.RollbackTran();
|
||||
jm.msg = GlobalConstVars.DataHandleEx;
|
||||
return jm;
|
||||
}
|
||||
products.ForEach(p =>
|
||||
{
|
||||
p.agentGoodsId = id;
|
||||
p.createTime = DateTime.Now;
|
||||
p.isDel = false;
|
||||
p.goodId = entity.goodId;
|
||||
});
|
||||
|
||||
var bl = await DbClient.Insertable(products).ExecuteCommandAsync() > 0;
|
||||
|
||||
_unitOfWork.CommitTran();
|
||||
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.CreateSuccess : GlobalConstVars.CreateFailure;
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_unitOfWork.RollbackTran();
|
||||
jm.msg = GlobalConstVars.DataHandleEx;
|
||||
jm.data = e;
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="products"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<AdminUiCallBack> UpdateAsync(CoreCmsAgentGoods entity, List<CoreCmsAgentProducts> products)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
try
|
||||
{
|
||||
var isHave = await DbClient.Queryable<CoreCmsAgentGoods>().AnyAsync(p => p.goodId == entity.goodId && p.id != entity.id);
|
||||
if (isHave)
|
||||
{
|
||||
jm.msg = "此商品已录入代理池";
|
||||
return jm;
|
||||
}
|
||||
|
||||
var good = await DbClient.Queryable<CoreCmsGoods>().FirstAsync(p => p.id == entity.goodId);
|
||||
if (good == null)
|
||||
{
|
||||
jm.msg = "商品不存在";
|
||||
return jm;
|
||||
}
|
||||
|
||||
|
||||
var oldModel = await DbClient.Queryable<CoreCmsAgentGoods>().FirstAsync(p => p.id == entity.id);
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "编辑数据不存在";
|
||||
return jm;
|
||||
}
|
||||
_unitOfWork.BeginTran();
|
||||
|
||||
oldModel.updateTime = DateTime.Now;
|
||||
oldModel.goodId = entity.goodId;
|
||||
oldModel.sortId = entity.sortId;
|
||||
oldModel.isEnable = entity.isEnable;
|
||||
oldModel.goodRefreshTime = good.updateTime;
|
||||
|
||||
products.ForEach(p =>
|
||||
{
|
||||
p.agentGoodsId = oldModel.id;
|
||||
p.createTime = DateTime.Now;
|
||||
p.isDel = false;
|
||||
p.goodId = entity.goodId;
|
||||
});
|
||||
|
||||
//数据处理
|
||||
await DbClient.Updateable(oldModel).ExecuteCommandAsync();
|
||||
|
||||
await DbClient.Deleteable<CoreCmsAgentProducts>(p => p.agentGoodsId == oldModel.id).ExecuteCommandHasChangeAsync();
|
||||
|
||||
await DbClient.Insertable(products).ExecuteCommandAsync();
|
||||
|
||||
_unitOfWork.CommitTran();
|
||||
|
||||
jm.code = 0;
|
||||
jm.msg = GlobalConstVars.EditSuccess;
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_unitOfWork.RollbackTran();
|
||||
jm.msg = GlobalConstVars.DataHandleEx;
|
||||
jm.data = e;
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> UpdateAsync(List<CoreCmsAgentGoods> 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(int id)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
try
|
||||
{
|
||||
var model = await DbClient.Queryable<CoreCmsAgentGoods>().FirstAsync(p => p.id == id);
|
||||
if (model == null)
|
||||
{
|
||||
jm.msg = GlobalConstVars.DataisNo;
|
||||
return jm;
|
||||
}
|
||||
|
||||
_unitOfWork.BeginTran();
|
||||
var bl = await DbClient.Deleteable<CoreCmsAgentGoods>(id).ExecuteCommandHasChangeAsync();
|
||||
if (bl)
|
||||
{
|
||||
await DbClient.Deleteable<CoreCmsAgentProducts>(p => p.agentGoodsId == model.id).ExecuteCommandHasChangeAsync();
|
||||
}
|
||||
_unitOfWork.CommitTran();
|
||||
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_unitOfWork.RollbackTran();
|
||||
NLogUtil.WriteAll(LogLevel.Error, LogType.Web, "删除代理池商品", "删除报错 ", e);
|
||||
}
|
||||
|
||||
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<CoreCmsAgentGoods>().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<CoreCmsAgentGoods>> QueryPageAsync(Expression<Func<CoreCmsAgentGoods, bool>> predicate,
|
||||
Expression<Func<CoreCmsAgentGoods, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsAgentGoods> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsAgentGoods, CoreCmsGoods>((ag, cg) => new JoinQueryInfos(JoinType.Left, ag.goodId == cg.id))
|
||||
.Select((ag, cg) => new CoreCmsAgentGoods
|
||||
{
|
||||
id = ag.id,
|
||||
goodId = ag.goodId,
|
||||
goodRefreshTime = ag.goodRefreshTime,
|
||||
sortId = ag.sortId,
|
||||
isEnable = ag.isEnable,
|
||||
createTime = ag.createTime,
|
||||
updateTime = ag.updateTime,
|
||||
goodName = cg.name,
|
||||
goodImage = cg.image,
|
||||
goodUpdateTime = cg.updateTime
|
||||
})
|
||||
.With(SqlWith.NoLock)
|
||||
.MergeTable()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsAgentGoods, CoreCmsGoods>((ag, cg) => new JoinQueryInfos(JoinType.Left, ag.goodId == cg.id))
|
||||
.Select((ag, cg) => new CoreCmsAgentGoods
|
||||
{
|
||||
id = ag.id,
|
||||
goodId = ag.goodId,
|
||||
goodRefreshTime = ag.goodRefreshTime,
|
||||
sortId = ag.sortId,
|
||||
isEnable = ag.isEnable,
|
||||
createTime = ag.createTime,
|
||||
updateTime = ag.updateTime,
|
||||
goodName = cg.name,
|
||||
goodImage = cg.image,
|
||||
goodUpdateTime = cg.updateTime
|
||||
})
|
||||
.MergeTable()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsAgentGoods>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
261
CoreCms.Net.Repository/Agent/CoreCmsAgentGradeRepository.cs
Normal file
261
CoreCms.Net.Repository/Agent/CoreCmsAgentGradeRepository.cs
Normal file
@@ -0,0 +1,261 @@
|
||||
/***********************************************************************
|
||||
* 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 CoreCmsAgentGradeRepository : BaseRepository<CoreCmsAgentGrade>, ICoreCmsAgentGradeRepository
|
||||
{
|
||||
public CoreCmsAgentGradeRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
#region 实现重写增删改查操作==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> InsertAsync(CoreCmsAgentGrade entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
if (await DbClient.Queryable<CoreCmsAgentGrade>().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<CoreCmsAgentGrade>().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(CoreCmsAgentGrade entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
if (await DbClient.Queryable<CoreCmsAgentGrade>().AnyAsync(p => p.sortId == entity.sortId && entity.id != p.id))
|
||||
{
|
||||
jm.msg = "存在相同等级排序,请更换!";
|
||||
return jm;
|
||||
}
|
||||
|
||||
if (entity.isDefault == false)
|
||||
{
|
||||
var otherHave = await DbClient.Queryable<CoreCmsAgentGrade>().AnyAsync(p => p.isDefault == true && p.id != entity.id);
|
||||
if (otherHave == false)
|
||||
{
|
||||
jm.msg = "请保持一个默认分销等级";
|
||||
return jm;
|
||||
}
|
||||
}
|
||||
|
||||
var oldModel = await DbClient.Queryable<CoreCmsAgentGrade>().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.defaultSalesPriceType = entity.defaultSalesPriceType;
|
||||
oldModel.defaultSalesPriceNumber = entity.defaultSalesPriceNumber;
|
||||
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<CoreCmsAgentGrade>().SetColumns(it => it.isDefault == false).Where(p => p.isDefault == true && p.id != entity.id).ExecuteCommandAsync();
|
||||
}
|
||||
await UpdateCaChe();
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> UpdateAsync(List<CoreCmsAgentGrade> 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 async Task<AdminUiCallBack> DeleteByIdAsync(int id)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
if (await DbClient.Queryable<CoreCmsAgent>().AnyAsync(p => p.gradeId == id))
|
||||
{
|
||||
jm.msg = "存在关联的分销用户数据,禁止删除";
|
||||
return jm;
|
||||
}
|
||||
|
||||
var bl = await DbClient.Deleteable<CoreCmsAgentGrade>(id).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
||||
if (bl)
|
||||
{
|
||||
await DbClient.Deleteable<CoreCmsAgentProducts>().Where(p => p.agentGradeId == id).ExecuteCommandHasChangeAsync();
|
||||
await UpdateCaChe();
|
||||
}
|
||||
return jm;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 获取缓存的所有数据==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 获取缓存的所有数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<CoreCmsAgentGrade>> GetCaChe()
|
||||
{
|
||||
var cache = ManualDataCache.Instance.Get<List<CoreCmsAgentGrade>>(GlobalConstVars.CacheCoreCmsAgentGrade);
|
||||
if (cache != null)
|
||||
{
|
||||
return cache;
|
||||
}
|
||||
return await UpdateCaChe();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新cache
|
||||
/// </summary>
|
||||
public async Task<List<CoreCmsAgentGrade>> UpdateCaChe()
|
||||
{
|
||||
var list = await DbClient.Queryable<CoreCmsAgentGrade>().With(SqlWith.NoLock).ToListAsync();
|
||||
ManualDataCache.Instance.Set(GlobalConstVars.CacheCoreCmsAgentGrade, 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<CoreCmsAgentGrade>> QueryPageAsync(Expression<Func<CoreCmsAgentGrade, bool>> predicate,
|
||||
Expression<Func<CoreCmsAgentGrade, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsAgentGrade> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsAgentGrade>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsAgentGrade
|
||||
{
|
||||
id = p.id,
|
||||
name = p.name,
|
||||
isDefault = p.isDefault,
|
||||
isAutoUpGrade = p.isAutoUpGrade,
|
||||
defaultSalesPriceType = p.defaultSalesPriceType,
|
||||
defaultSalesPriceNumber = p.defaultSalesPriceNumber,
|
||||
sortId = p.sortId,
|
||||
description = p.description,
|
||||
|
||||
}).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsAgentGrade>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsAgentGrade
|
||||
{
|
||||
id = p.id,
|
||||
name = p.name,
|
||||
isDefault = p.isDefault,
|
||||
isAutoUpGrade = p.isAutoUpGrade,
|
||||
defaultSalesPriceType = p.defaultSalesPriceType,
|
||||
defaultSalesPriceNumber = p.defaultSalesPriceNumber,
|
||||
sortId = p.sortId,
|
||||
description = p.description,
|
||||
|
||||
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsAgentGrade>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
216
CoreCms.Net.Repository/Agent/CoreCmsAgentOrderRepository.cs
Normal file
216
CoreCms.Net.Repository/Agent/CoreCmsAgentOrderRepository.cs
Normal file
@@ -0,0 +1,216 @@
|
||||
/***********************************************************************
|
||||
* 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 CoreCmsAgentOrderRepository : BaseRepository<CoreCmsAgentOrder>, ICoreCmsAgentOrderRepository
|
||||
{
|
||||
public CoreCmsAgentOrderRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
#region 实现重写增删改查操作==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> InsertAsync(CoreCmsAgentOrder 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(CoreCmsAgentOrder entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var oldModel = await DbClient.Queryable<CoreCmsAgentOrder>().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.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<CoreCmsAgentOrder> 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<CoreCmsAgentOrder>(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<CoreCmsAgentOrder>().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<CoreCmsAgentOrder>> QueryPageAsync(Expression<Func<CoreCmsAgentOrder, bool>> predicate,
|
||||
Expression<Func<CoreCmsAgentOrder, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsAgentOrder> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsAgentOrder, 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 CoreCmsAgentOrder
|
||||
{
|
||||
id = dOrder.id,
|
||||
userId = dOrder.userId,
|
||||
buyUserId = dOrder.buyUserId,
|
||||
orderId = dOrder.orderId,
|
||||
amount = dOrder.amount,
|
||||
isSettlement = dOrder.isSettlement,
|
||||
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<CoreCmsAgentOrder, 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 CoreCmsAgentOrder
|
||||
{
|
||||
id = dOrder.id,
|
||||
userId = dOrder.userId,
|
||||
buyUserId = dOrder.buyUserId,
|
||||
orderId = dOrder.orderId,
|
||||
amount = dOrder.amount,
|
||||
isSettlement = dOrder.isSettlement,
|
||||
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<CoreCmsAgentOrder>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/***********************************************************************
|
||||
* 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 CoreCmsAgentProductsRepository : BaseRepository<CoreCmsAgentProducts>, ICoreCmsAgentProductsRepository
|
||||
{
|
||||
public CoreCmsAgentProductsRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
#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<CoreCmsAgentProducts>> QueryPageAsync(Expression<Func<CoreCmsAgentProducts, bool>> predicate,
|
||||
Expression<Func<CoreCmsAgentProducts, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsAgentProducts> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsAgentProducts>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsAgentProducts
|
||||
{
|
||||
id = p.id,
|
||||
goodId = p.goodId,
|
||||
productId = p.productId,
|
||||
productCostPrice = p.productCostPrice,
|
||||
productPrice = p.productPrice,
|
||||
agentGradeId = p.agentGradeId,
|
||||
agentGradePrice = p.agentGradePrice,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
isDel = p.isDel,
|
||||
|
||||
}).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsAgentProducts>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsAgentProducts
|
||||
{
|
||||
id = p.id,
|
||||
goodId = p.goodId,
|
||||
productId = p.productId,
|
||||
productCostPrice = p.productCostPrice,
|
||||
productPrice = p.productPrice,
|
||||
agentGradeId = p.agentGradeId,
|
||||
agentGradePrice = p.agentGradePrice,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
isDel = p.isDel,
|
||||
|
||||
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsAgentProducts>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
189
CoreCms.Net.Repository/Agent/CoreCmsAgentRepository.cs
Normal file
189
CoreCms.Net.Repository/Agent/CoreCmsAgentRepository.cs
Normal file
@@ -0,0 +1,189 @@
|
||||
/***********************************************************************
|
||||
* 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 CoreCms.Net.Model.ViewModels.DTO.Agent;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 代理商表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsAgentRepository : BaseRepository<CoreCmsAgent>, ICoreCmsAgentRepository
|
||||
{
|
||||
public CoreCmsAgentRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
#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<CoreCmsAgent>> QueryPageAsync(Expression<Func<CoreCmsAgent, bool>> predicate,
|
||||
Expression<Func<CoreCmsAgent, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsAgent> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsAgent>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsAgent
|
||||
{
|
||||
id = p.id,
|
||||
userId = p.userId,
|
||||
name = p.name,
|
||||
gradeId = p.gradeId,
|
||||
mobile = p.mobile,
|
||||
weixin = p.weixin,
|
||||
qq = p.qq,
|
||||
storeName = p.storeName,
|
||||
storeLogo = p.storeLogo,
|
||||
storeBanner = p.storeBanner,
|
||||
storeDesc = p.storeDesc,
|
||||
verifyStatus = p.verifyStatus,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
verifyTime = p.verifyTime,
|
||||
isDelete = p.isDelete,
|
||||
}).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsAgent>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsAgent
|
||||
{
|
||||
id = p.id,
|
||||
userId = p.userId,
|
||||
name = p.name,
|
||||
gradeId = p.gradeId,
|
||||
mobile = p.mobile,
|
||||
weixin = p.weixin,
|
||||
qq = p.qq,
|
||||
storeName = p.storeName,
|
||||
storeLogo = p.storeLogo,
|
||||
storeBanner = p.storeBanner,
|
||||
storeDesc = p.storeDesc,
|
||||
verifyStatus = p.verifyStatus,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
verifyTime = p.verifyTime,
|
||||
isDelete = p.isDelete,
|
||||
|
||||
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsAgent>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#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<CoreCmsAgentOrder>> QueryOrderPageAsync(int userId, int pageIndex = 1, int pageSize = 20, int typeId = 0)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
var page = await DbClient.Queryable<CoreCmsAgentOrder, 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 CoreCmsAgentOrder()
|
||||
{
|
||||
id = dOrder.id,
|
||||
userId = dOrder.userId,
|
||||
buyUserId = dOrder.buyUserId,
|
||||
orderId = dOrder.orderId,
|
||||
amount = dOrder.amount,
|
||||
isSettlement = dOrder.isSettlement,
|
||||
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<CoreCmsAgentOrder>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 获取代理商排行
|
||||
|
||||
/// <summary>
|
||||
/// 获取代理商排行
|
||||
/// </summary>
|
||||
/// <param name="pageIndex">当前页面索引</param>
|
||||
/// <param name="pageSize">分布大小</param>
|
||||
/// <returns></returns>
|
||||
public async Task<IPageList<AgentRankingDTO>> QueryRankingPageAsync(int pageIndex = 1, int pageSize = 20)
|
||||
{
|
||||
|
||||
RefAsync<int> totalCount = 0;
|
||||
var page = await DbClient.Queryable<CoreCmsAgent>()
|
||||
.Select(p => new AgentRankingDTO()
|
||||
{
|
||||
id = p.userId,
|
||||
nickname = p.name,
|
||||
createtime = p.createTime,
|
||||
totalInCome = SqlFunc.Subqueryable<CoreCmsAgentOrder>().Where(o => o.userId == p.userId && p.isDelete == false && p.verifyStatus == (int)GlobalEnumVars.AgentOrderSettlementStatus.SettlementYes).Sum(o => o.amount),
|
||||
orderCount = SqlFunc.Subqueryable<CoreCmsAgentOrder>().Where(o => o.userId == p.userId && p.isDelete == false && p.verifyStatus == (int)GlobalEnumVars.AgentOrderSettlementStatus.SettlementYes).Count()
|
||||
})
|
||||
.With(SqlWith.NoLock)
|
||||
.MergeTable()
|
||||
.OrderBy(dOrder => dOrder.totalInCome, OrderByType.Desc)
|
||||
.WithCache()
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
|
||||
var list = new PageList<AgentRankingDTO>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/***********************************************************************
|
||||
* 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.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;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 第三方授权记录表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsApiAccessTokenRepository : BaseRepository<CoreCmsApiAccessToken>, ICoreCmsApiAccessTokenRepository
|
||||
{
|
||||
public CoreCmsApiAccessTokenRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
132
CoreCms.Net.Repository/Article/CoreCmsArticleRepository.cs
Normal file
132
CoreCms.Net.Repository/Article/CoreCmsArticleRepository.cs
Normal file
@@ -0,0 +1,132 @@
|
||||
/***********************************************************************
|
||||
* 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.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Utility.Helper;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 文章表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsArticleRepository : BaseRepository<CoreCmsArticle>, ICoreCmsArticleRepository
|
||||
{
|
||||
public CoreCmsArticleRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#region 获取指定id 的文章详情
|
||||
/// <summary>
|
||||
/// 获取指定id 的文章详情
|
||||
/// </summary>
|
||||
/// <param name="id">序列</param>
|
||||
public async Task<CoreCmsArticle> ArticleDetail(int id)
|
||||
{
|
||||
var article = await DbClient.Queryable<CoreCmsArticle>().Where(p => p.id == id && p.isPub == true)
|
||||
.FirstAsync();
|
||||
if (article == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
article.contentBody = CommonHelper.ClearHtml(article.contentBody, new[] { "width", "height" });
|
||||
article.contentBody = article.contentBody.Replace("<img", "<img style='max-width: 100%'");
|
||||
article.contentBody = article.contentBody.Replace("oembed url=", "video width=\"100%\" controls=\"controls\" src=");
|
||||
article.contentBody = article.contentBody.Replace("/oembed", "/video");
|
||||
|
||||
if (article.typeId > 0)
|
||||
{
|
||||
article.articleType = await DbClient.Queryable<CoreCmsArticleType>().InSingleAsync(article.typeId);
|
||||
}
|
||||
//上一篇
|
||||
article.upArticle = await DbClient.Queryable<CoreCmsArticle>().Where(p => p.id < article.id && p.isPub == true).Select(p => new CoreCmsArticle
|
||||
{
|
||||
id = p.id,
|
||||
title = p.title,
|
||||
brief = p.brief,
|
||||
coverImage = p.coverImage,
|
||||
typeId = p.typeId,
|
||||
sort = p.sort,
|
||||
isPub = p.isPub,
|
||||
isDel = p.isDel,
|
||||
pv = p.pv,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime
|
||||
}).FirstAsync();
|
||||
//下一篇
|
||||
article.downArticle = await DbClient.Queryable<CoreCmsArticle>().Where(p => p.id > article.id && p.isPub == true).Select(p => new CoreCmsArticle
|
||||
{
|
||||
id = p.id,
|
||||
title = p.title,
|
||||
brief = p.brief,
|
||||
coverImage = p.coverImage,
|
||||
typeId = p.typeId,
|
||||
sort = p.sort,
|
||||
isPub = p.isPub,
|
||||
isDel = p.isDel,
|
||||
pv = p.pv,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime
|
||||
}).FirstAsync();
|
||||
|
||||
await DbClient.Updateable<CoreCmsArticle>().SetColumns(p => p.pv == (p.pv + 1)).Where(p => p.id == article.id).ExecuteCommandAsync();
|
||||
|
||||
return article;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 重写根据条件查询分页数据
|
||||
/// <summary>
|
||||
/// 重写根据条件查询分页数据
|
||||
/// </summary>
|
||||
/// <param name="predicate">判断集合</param>
|
||||
/// <param name="orderByType">排序方式</param>
|
||||
/// <param name="pageIndex">当前页面索引</param>
|
||||
/// <param name="pageSize">分布大小</param>
|
||||
/// <param name="orderByExpression"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IPageList<CoreCmsArticle>> QueryPageAsync(Expression<Func<CoreCmsArticle, bool>> predicate,
|
||||
Expression<Func<CoreCmsArticle, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
var page = await DbClient.Queryable<CoreCmsArticle>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsArticle
|
||||
{
|
||||
id = p.id,
|
||||
title = p.title,
|
||||
brief = p.brief,
|
||||
coverImage = p.coverImage,
|
||||
typeId = p.typeId,
|
||||
sort = p.sort,
|
||||
isPub = p.isPub,
|
||||
isDel = p.isDel,
|
||||
pv = p.pv,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime
|
||||
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
var list = new PageList<CoreCmsArticle>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 文章分类表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsArticleTypeRepository : BaseRepository<CoreCmsArticleType>, ICoreCmsArticleTypeRepository
|
||||
{
|
||||
public CoreCmsArticleTypeRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
1303
CoreCms.Net.Repository/BaseRepository.cs
Normal file
1303
CoreCms.Net.Repository/BaseRepository.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,27 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品图片关联表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsBillAftersalesImagesRepository : BaseRepository<CoreCmsBillAftersalesImages>,
|
||||
ICoreCmsBillAftersalesImagesRepository
|
||||
{
|
||||
public CoreCmsBillAftersalesImagesRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 售后单明细表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsBillAftersalesItemRepository : BaseRepository<CoreCmsBillAftersalesItem>,
|
||||
ICoreCmsBillAftersalesItemRepository
|
||||
{
|
||||
public CoreCmsBillAftersalesItemRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
122
CoreCms.Net.Repository/Bill/CoreCmsBillAftersalesRepository.cs
Normal file
122
CoreCms.Net.Repository/Bill/CoreCmsBillAftersalesRepository.cs
Normal file
@@ -0,0 +1,122 @@
|
||||
/***********************************************************************
|
||||
* 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.Configuration;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.Entities.Expression;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.Model.ViewModels.DTO;
|
||||
using CoreCms.Net.Utility.Helper;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 退货单表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsBillAftersalesRepository : BaseRepository<CoreCmsBillAftersales>, ICoreCmsBillAftersalesRepository
|
||||
{
|
||||
public CoreCmsBillAftersalesRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
#region 根据条件查询分页数据
|
||||
/// <summary>
|
||||
/// 根据条件查询分页数据
|
||||
/// </summary>
|
||||
/// <param name="predicate">判断集合</param>
|
||||
/// <param name="orderByType">排序方式</param>
|
||||
/// <param name="pageIndex">当前页面索引</param>
|
||||
/// <param name="pageSize">分布大小</param>
|
||||
/// <param name="orderByExpression"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IPageList<CoreCmsBillAftersales>> QueryPageAsync(Expression<Func<CoreCmsBillAftersales, bool>> predicate,
|
||||
Expression<Func<CoreCmsBillAftersales, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
var page = await DbClient.Queryable<CoreCmsBillAftersales, CoreCmsUser>((p, sc) => new JoinQueryInfos(
|
||||
JoinType.Left, p.userId == sc.id))
|
||||
.Select((p, sc) => new CoreCmsBillAftersales
|
||||
{
|
||||
aftersalesId = p.aftersalesId,
|
||||
orderId = p.orderId,
|
||||
userId = p.userId,
|
||||
type = p.type,
|
||||
refundAmount = p.refundAmount,
|
||||
status = p.status,
|
||||
reason = p.reason,
|
||||
mark = p.mark,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
userNickName = sc.nickName
|
||||
})
|
||||
.MergeTable()
|
||||
.Mapper(p => p.items, p => p.items.First().aftersalesId)
|
||||
.Mapper(p => p.images, p => p.images.First().aftersalesId)
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
|
||||
if (page.Any())
|
||||
{
|
||||
var billAftersalesStatus = EnumHelper.EnumToList<GlobalEnumVars.BillAftersalesStatus>();
|
||||
foreach (var item in page)
|
||||
{
|
||||
var statusModel = billAftersalesStatus.Find(p => p.value == item.status);
|
||||
if (statusModel != null) item.statusName = statusModel.description;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var list = new PageList<CoreCmsBillAftersales>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 获取单个数据
|
||||
|
||||
/// <summary>
|
||||
/// 获取单个数据
|
||||
/// </summary>
|
||||
/// <param name="aftersalesId"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<CoreCmsBillAftersales> GetInfo(string aftersalesId, int userId = 0)
|
||||
{
|
||||
var model = userId > 0
|
||||
? await DbClient.Queryable<CoreCmsBillAftersales>()
|
||||
.Where(p => p.aftersalesId == aftersalesId && p.userId == userId).FirstAsync()
|
||||
: await DbClient.Queryable<CoreCmsBillAftersales>()
|
||||
.Where(p => p.aftersalesId == aftersalesId).FirstAsync();
|
||||
|
||||
if (model != null)
|
||||
{
|
||||
model.order = await DbClient.Queryable<CoreCmsOrder>().Where(p => p.orderId == model.orderId).FirstAsync();
|
||||
model.images = await DbClient.Queryable<CoreCmsBillAftersalesImages>().Where(p => p.aftersalesId == aftersalesId).OrderBy(p => p.sortId).ToListAsync();
|
||||
model.items = await DbClient.Queryable<CoreCmsBillAftersalesItem>().Where(p => p.aftersalesId == aftersalesId).OrderBy(p => p.createTime).ToListAsync();
|
||||
model.billRefund = await DbClient.Queryable<CoreCmsBillRefund>().Where(p => p.aftersalesId == aftersalesId).FirstAsync();
|
||||
model.billReship = await DbClient.Queryable<CoreCmsBillReship>().Where(p => p.aftersalesId == aftersalesId).FirstAsync();
|
||||
}
|
||||
return model;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 发货单详情表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsBillDeliveryItemRepository : BaseRepository<CoreCmsBillDeliveryItem>,
|
||||
ICoreCmsBillDeliveryItemRepository
|
||||
{
|
||||
public CoreCmsBillDeliveryItemRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
62
CoreCms.Net.Repository/Bill/CoreCmsBillDeliveryRepository.cs
Normal file
62
CoreCms.Net.Repository/Bill/CoreCmsBillDeliveryRepository.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
/***********************************************************************
|
||||
* 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.Threading.Tasks;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Loging;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.Model.ViewModels.DTO;
|
||||
using CoreCms.Net.Utility.Helper;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 发货单表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsBillDeliveryRepository : BaseRepository<CoreCmsBillDelivery>, ICoreCmsBillDeliveryRepository
|
||||
{
|
||||
public CoreCmsBillDeliveryRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发货单统计7天统计
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<StatisticsOut>> Statistics()
|
||||
{
|
||||
var dt = DateTime.Now.AddDays(-8);
|
||||
|
||||
var list = await DbClient.Queryable<CoreCmsBillDelivery>()
|
||||
.Where(p => p.createTime >= dt)
|
||||
.Select(it => new
|
||||
{
|
||||
it.deliveryId,
|
||||
createTime = it.createTime.Date
|
||||
})
|
||||
.MergeTable()
|
||||
.GroupBy(it => it.createTime)
|
||||
.Select(it => new StatisticsOut { day = it.createTime.ToString("yyyy-MM-dd"), nums = SqlFunc.AggregateCount(it.deliveryId) })
|
||||
.ToListAsync();
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
78
CoreCms.Net.Repository/Bill/CoreCmsBillLadingRepository.cs
Normal file
78
CoreCms.Net.Repository/Bill/CoreCmsBillLadingRepository.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
/***********************************************************************
|
||||
* 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.Threading.Tasks;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.Utility.Helper;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 提货单表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsBillLadingRepository : BaseRepository<CoreCmsBillLading>, ICoreCmsBillLadingRepository
|
||||
{
|
||||
public CoreCmsBillLadingRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加提货单
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<WebApiCallBack> AddData(string orderId, int storeId, string name, string mobile)
|
||||
{
|
||||
var jm = new WebApiCallBack();
|
||||
|
||||
var model = new CoreCmsBillLading();
|
||||
model.id = GenerateId();
|
||||
model.orderId = orderId;
|
||||
model.storeId = storeId;
|
||||
model.name = name;
|
||||
model.mobile = mobile;
|
||||
model.clerkId = 0;
|
||||
model.status = false;
|
||||
model.createTime = DateTime.Now;
|
||||
model.isDel = false;
|
||||
|
||||
//事物处理过程结束
|
||||
await DbClient.Insertable(model).ExecuteCommandAsync();
|
||||
jm.code = 0;
|
||||
jm.msg = "添加成功";
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 生成唯一提货单号
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private string GenerateId()
|
||||
{
|
||||
bool bl;
|
||||
string id;
|
||||
do
|
||||
{
|
||||
id = CommonHelper.GetSerialNumberType((int) GlobalEnumVars.SerialNumberType.提货单号);
|
||||
var id1 = id;
|
||||
bl = DbClient.Queryable<CoreCmsBillLading>().Any(p => p.id == id1);
|
||||
} while (bl);
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
}
|
||||
133
CoreCms.Net.Repository/Bill/CoreCmsBillPaymentsRepository.cs
Normal file
133
CoreCms.Net.Repository/Bill/CoreCmsBillPaymentsRepository.cs
Normal file
@@ -0,0 +1,133 @@
|
||||
/***********************************************************************
|
||||
* 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.Configuration;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 支付单表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsBillPaymentsRepository : BaseRepository<CoreCmsBillPayments>, ICoreCmsBillPaymentsRepository
|
||||
{
|
||||
|
||||
public CoreCmsBillPaymentsRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 支付单7天统计
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<StatisticsOut>> Statistics()
|
||||
{
|
||||
var dt = DateTime.Now.AddDays(-8);
|
||||
|
||||
var list = await DbClient.Queryable<CoreCmsBillPayments>()
|
||||
.Where(p => p.createTime >= dt && p.status == (int)GlobalEnumVars.BillPaymentsStatus.Payed && p.type == (int)GlobalEnumVars.BillPaymentsType.Order)
|
||||
.Select(it => new
|
||||
{
|
||||
it.paymentId,
|
||||
createTime = it.createTime.Date
|
||||
})
|
||||
.MergeTable()
|
||||
.GroupBy(it => it.createTime)
|
||||
.Select(it => new StatisticsOut { day = it.createTime.ToString("yyyy-MM-dd"), nums = SqlFunc.AggregateCount(it.paymentId) })
|
||||
.ToListAsync();
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
#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<CoreCmsBillPayments>> QueryPageAsync(Expression<Func<CoreCmsBillPayments, bool>> predicate,
|
||||
Expression<Func<CoreCmsBillPayments, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsBillPayments> page;
|
||||
if (blUseNoLock)
|
||||
page = await DbClient.Queryable<CoreCmsBillPayments, CoreCmsUser>((p, sc) => new JoinQueryInfos(
|
||||
JoinType.Left, p.userId == sc.id))
|
||||
.Select((p, sc) => new CoreCmsBillPayments
|
||||
{
|
||||
paymentId = p.paymentId,
|
||||
money = p.money,
|
||||
userId = p.userId,
|
||||
type = p.type,
|
||||
status = p.status,
|
||||
paymentCode = p.paymentCode,
|
||||
ip = p.ip,
|
||||
parameters = p.parameters,
|
||||
payedMsg = p.payedMsg,
|
||||
tradeNo = p.tradeNo,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
userNickName = sc.nickName
|
||||
})
|
||||
.MergeTable()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
else
|
||||
page = await DbClient.Queryable<CoreCmsBillPayments, CoreCmsUser>((p, sc) => new JoinQueryInfos(
|
||||
JoinType.Left, p.userId == sc.id))
|
||||
.Select((p, sc) => new CoreCmsBillPayments
|
||||
{
|
||||
paymentId = p.paymentId,
|
||||
money = p.money,
|
||||
userId = p.userId,
|
||||
type = p.type,
|
||||
status = p.status,
|
||||
paymentCode = p.paymentCode,
|
||||
ip = p.ip,
|
||||
parameters = p.parameters,
|
||||
payedMsg = p.payedMsg,
|
||||
tradeNo = p.tradeNo,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
userNickName = sc.nickName
|
||||
})
|
||||
.MergeTable()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
var list = new PageList<CoreCmsBillPayments>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
107
CoreCms.Net.Repository/Bill/CoreCmsBillRefundRepository.cs
Normal file
107
CoreCms.Net.Repository/Bill/CoreCmsBillRefundRepository.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
/***********************************************************************
|
||||
* 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.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 退款单表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsBillRefundRepository : BaseRepository<CoreCmsBillRefund>, ICoreCmsBillRefundRepository
|
||||
{
|
||||
public CoreCmsBillRefundRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
#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<CoreCmsBillRefund>> QueryPageAsync(Expression<Func<CoreCmsBillRefund, bool>> predicate,
|
||||
Expression<Func<CoreCmsBillRefund, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsBillRefund> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsBillRefund, CoreCmsUser>((p, sc) => new JoinQueryInfos(
|
||||
JoinType.Left, p.userId == sc.id))
|
||||
.Select((p, sc) => new CoreCmsBillRefund
|
||||
{
|
||||
refundId = p.refundId,
|
||||
aftersalesId = p.aftersalesId,
|
||||
money = p.money,
|
||||
userId = p.userId,
|
||||
sourceId = p.sourceId,
|
||||
type = p.type,
|
||||
paymentCode = p.paymentCode,
|
||||
tradeNo = p.tradeNo,
|
||||
status = p.status,
|
||||
memo = p.memo,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
userNickName = sc.nickName
|
||||
})
|
||||
.MergeTable()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsBillRefund, CoreCmsUser>((p, sc) => new JoinQueryInfos(
|
||||
JoinType.Left, p.userId == sc.id))
|
||||
.Select((p, sc) => new CoreCmsBillRefund
|
||||
{
|
||||
refundId = p.refundId,
|
||||
aftersalesId = p.aftersalesId,
|
||||
money = p.money,
|
||||
userId = p.userId,
|
||||
sourceId = p.sourceId,
|
||||
type = p.type,
|
||||
paymentCode = p.paymentCode,
|
||||
tradeNo = p.tradeNo,
|
||||
status = p.status,
|
||||
memo = p.memo ?? "",
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
userNickName = sc.nickName
|
||||
})
|
||||
.MergeTable()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsBillRefund>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 退货单明细表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsBillReshipItemRepository : BaseRepository<CoreCmsBillReshipItem>, ICoreCmsBillReshipItemRepository
|
||||
{
|
||||
public CoreCmsBillReshipItemRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
113
CoreCms.Net.Repository/Bill/CoreCmsBillReshipRepository.cs
Normal file
113
CoreCms.Net.Repository/Bill/CoreCmsBillReshipRepository.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
/***********************************************************************
|
||||
* 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.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 退货单表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsBillReshipRepository : BaseRepository<CoreCmsBillReship>, ICoreCmsBillReshipRepository
|
||||
{
|
||||
public CoreCmsBillReshipRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单个数据带导航
|
||||
/// </summary>
|
||||
/// <param name="predicate"></param>
|
||||
/// <param name="orderByExpression"></param>
|
||||
/// <param name="orderByType"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<CoreCmsBillReship> GetDetails(Expression<Func<CoreCmsBillReship, bool>> predicate,
|
||||
Expression<Func<CoreCmsBillReship, object>> orderByExpression, OrderByType orderByType)
|
||||
{
|
||||
var model = await DbClient.Queryable<CoreCmsBillReship, CoreCmsUser>((p, sc) => new JoinQueryInfos(
|
||||
JoinType.Left, p.userId == sc.id))
|
||||
.Select((p, sc) => new CoreCmsBillReship
|
||||
{
|
||||
reshipId = p.reshipId,
|
||||
orderId = p.orderId,
|
||||
aftersalesId = p.aftersalesId,
|
||||
userId = p.userId,
|
||||
logiCode = p.logiCode,
|
||||
logiNo = p.logiNo,
|
||||
status = p.status,
|
||||
memo = p.memo,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
userNickName = sc.nickName
|
||||
})
|
||||
.MergeTable()
|
||||
.Mapper(p => p.items, p => p.reshipId)
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.FirstAsync();
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region 重写根据条件查询分页数据
|
||||
/// <summary>
|
||||
/// 重写根据条件查询分页数据
|
||||
/// </summary>
|
||||
/// <param name="predicate">判断集合</param>
|
||||
/// <param name="orderByType">排序方式</param>
|
||||
/// <param name="pageIndex">当前页面索引</param>
|
||||
/// <param name="pageSize">分布大小</param>
|
||||
/// <param name="orderByExpression"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IPageList<CoreCmsBillReship>> QueryPageAsync(Expression<Func<CoreCmsBillReship, bool>> predicate,
|
||||
Expression<Func<CoreCmsBillReship, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsBillReship> page = await DbClient.Queryable<CoreCmsBillReship, CoreCmsUser>((p, sc) => new JoinQueryInfos(
|
||||
JoinType.Left, p.userId == sc.id))
|
||||
.Select((p, sc) => new CoreCmsBillReship
|
||||
{
|
||||
reshipId = p.reshipId,
|
||||
orderId = p.orderId,
|
||||
aftersalesId = p.aftersalesId,
|
||||
userId = p.userId,
|
||||
logiCode = p.logiCode,
|
||||
logiNo = p.logiNo,
|
||||
status = p.status,
|
||||
memo = p.memo,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
userNickName = sc.nickName
|
||||
})
|
||||
.MergeTable()
|
||||
.Mapper(p => p.items, p => p.reshipId)
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
|
||||
var list = new PageList<CoreCmsBillReship>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
53
CoreCms.Net.Repository/Cart/CoreCmsCartRepository.cs
Normal file
53
CoreCms.Net.Repository/Cart/CoreCmsCartRepository.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 购物车表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsCartRepository : BaseRepository<CoreCmsCart>, ICoreCmsCartRepository
|
||||
{
|
||||
public CoreCmsCartRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#region 获取购物车用户数据总数
|
||||
|
||||
/// <summary>
|
||||
/// 获取购物车用户数据总数
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<int> GetCountAsync(int userId)
|
||||
{
|
||||
var count = DbClient.Queryable<CoreCmsCart, CoreCmsProducts, CoreCmsGoods>((cart, products, goods) =>
|
||||
new object[]
|
||||
{
|
||||
JoinType.Inner, cart.productId == products.id,
|
||||
JoinType.Inner, products.goodsId == goods.id
|
||||
})
|
||||
.Where((cart, products, goods) => cart.type == (int) GlobalEnumVars.OrderType.Common)
|
||||
.Select((cart, products, goods) => new {cart.id, cart.userId, goodId = goods.id})
|
||||
.MergeTable()
|
||||
.CountAsync(p => p.userId == userId);
|
||||
return await count;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
102
CoreCms.Net.Repository/CodeGenerator/CodeGeneratorRepository.cs
Normal file
102
CoreCms.Net.Repository/CodeGenerator/CodeGeneratorRepository.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using CoreCms.Net.CodeGenerator;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository.CodeGenerator
|
||||
{
|
||||
public class CodeGeneratorRepository : BaseRepository<object>, ICodeGeneratorRepository
|
||||
{
|
||||
public CodeGeneratorRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有的表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<DbTableInfo> GetDbTables()
|
||||
{
|
||||
var tables = DbClient.DbMaintenance.GetTableInfoList(false).OrderBy(p => p.Name).ToList();
|
||||
var views = DbClient.DbMaintenance.GetViewInfoList(false).OrderBy(p => p.Name).ToList();
|
||||
if (!views.Any()) return tables;
|
||||
var newList = tables.Union(views).ToList();
|
||||
return newList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取表下面所有的字段
|
||||
/// </summary>
|
||||
/// <param name="tableName"></param>
|
||||
/// <returns></returns>
|
||||
public List<DbColumnInfo> GetDbTablesColumns(string tableName)
|
||||
{
|
||||
var columns = DbClient.DbMaintenance.GetColumnInfosByTableName(tableName, false);
|
||||
return columns;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 自动生成代码
|
||||
/// </summary>
|
||||
/// <param name="tableName"></param>
|
||||
/// <param name="fileType"></param>
|
||||
/// <returns></returns>
|
||||
public byte[] CodeGen(string tableName, string fileType)
|
||||
{
|
||||
var tables = DbClient.DbMaintenance.GetTableInfoList(false);
|
||||
var views = DbClient.DbMaintenance.GetViewInfoList(false);
|
||||
var tb = tables.Find(p => p.Name == tableName) ?? views.Find(p => p.Name == tableName);
|
||||
if (tb == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var columns = DbClient.DbMaintenance.GetColumnInfosByTableName(tb.Name, false);
|
||||
return GeneratorCodeHelper.CodeGenerator(tb.Name, tb.Description, columns, fileType);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 自动生成类型的所有数据库代码
|
||||
/// </summary>
|
||||
/// <param name="tableName"></param>
|
||||
/// <param name="fileType"></param>
|
||||
/// <returns></returns>
|
||||
public byte[] CodeGenByAll(string fileType)
|
||||
{
|
||||
var tables = DbClient.DbMaintenance.GetTableInfoList(false);
|
||||
var views = DbClient.DbMaintenance.GetViewInfoList(false);
|
||||
var newList = tables;
|
||||
if (views.Any()) newList = tables.Union(views).ToList();
|
||||
|
||||
var allDb = new List<DbTableInfoAndColumns>();
|
||||
newList.ForEach(p =>
|
||||
{
|
||||
var model = new DbTableInfoAndColumns();
|
||||
model.Name = p.Name;
|
||||
model.DbObjectType = p.DbObjectType;
|
||||
model.Description = p.Description;
|
||||
model.columns = DbClient.DbMaintenance.GetColumnInfosByTableName(p.Name, false);
|
||||
allDb.Add(model);
|
||||
});
|
||||
|
||||
if (!allDb.Any())
|
||||
return null;
|
||||
return GeneratorCodeHelper.CodeGeneratorAll(allDb, fileType);
|
||||
}
|
||||
}
|
||||
}
|
||||
26
CoreCms.Net.Repository/Com/CoreCmsLabelRepository.cs
Normal file
26
CoreCms.Net.Repository/Com/CoreCmsLabelRepository.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 标签表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsLabelRepository : BaseRepository<CoreCmsLabel>, ICoreCmsLabelRepository
|
||||
{
|
||||
public CoreCmsLabelRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
23
CoreCms.Net.Repository/CoreCms.Net.Repository.csproj
Normal file
23
CoreCms.Net.Repository/CoreCms.Net.Repository.csproj
Normal file
@@ -0,0 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DotLiquid" Version="2.2.548" />
|
||||
<PackageReference Include="Essensoft.Paylink.WeChatPay" Version="4.0.6" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CoreCms.Net.Auth\CoreCms.Net.Auth.csproj" />
|
||||
<ProjectReference Include="..\CoreCms.Net.Caching\CoreCms.Net.Caching.csproj" />
|
||||
<ProjectReference Include="..\CoreCms.Net.CodeGenerator\CoreCms.Net.CodeGenerator.csproj" />
|
||||
<ProjectReference Include="..\CoreCms.Net.Configuration\CoreCms.Net.Configuration.csproj" />
|
||||
<ProjectReference Include="..\CoreCms.Net.Core\CoreCms.Net.Core.csproj" />
|
||||
<ProjectReference Include="..\CoreCms.Net.IRepository\CoreCms.Net.IRepository.csproj" />
|
||||
<ProjectReference Include="..\CoreCms.Net.Model\CoreCms.Net.Model.csproj" />
|
||||
<ProjectReference Include="..\CoreCms.Net.Utility\CoreCms.Net.Utility.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -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
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 发票信息记录 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsInvoiceRecordRepository : BaseRepository<CoreCmsInvoiceRecord>, ICoreCmsInvoiceRecordRepository
|
||||
{
|
||||
public CoreCmsInvoiceRecordRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
103
CoreCms.Net.Repository/Financial/CoreCmsInvoiceRepository.cs
Normal file
103
CoreCms.Net.Repository/Financial/CoreCmsInvoiceRepository.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
/***********************************************************************
|
||||
* 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.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 发票表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsInvoiceRepository : BaseRepository<CoreCmsInvoice>, ICoreCmsInvoiceRepository
|
||||
{
|
||||
public CoreCmsInvoiceRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
#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<CoreCmsInvoice>> QueryPageAsync(
|
||||
Expression<Func<CoreCmsInvoice, bool>> predicate,
|
||||
Expression<Func<CoreCmsInvoice, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsInvoice> page;
|
||||
if (blUseNoLock)
|
||||
page = await DbClient.Queryable<CoreCmsInvoice, CoreCmsUser>((p, sc) => new JoinQueryInfos(
|
||||
JoinType.Left, p.userId == sc.id))
|
||||
.Select((p, sc) => new CoreCmsInvoice
|
||||
{
|
||||
id = p.id,
|
||||
category = p.category,
|
||||
sourceId = p.sourceId,
|
||||
userId = p.userId,
|
||||
type = p.type,
|
||||
title = p.title,
|
||||
taxNumber = p.taxNumber,
|
||||
amount = p.amount,
|
||||
status = p.status,
|
||||
remarks = p.remarks,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
userNickName = sc.nickName
|
||||
})
|
||||
.MergeTable()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
else
|
||||
page = await DbClient.Queryable<CoreCmsInvoice, CoreCmsUser>((p, sc) => new JoinQueryInfos(
|
||||
JoinType.Left, p.userId == sc.id))
|
||||
.Select((p, sc) => new CoreCmsInvoice
|
||||
{
|
||||
id = p.id,
|
||||
category = p.category,
|
||||
sourceId = p.sourceId,
|
||||
userId = p.userId,
|
||||
type = p.type,
|
||||
title = p.title,
|
||||
taxNumber = p.taxNumber,
|
||||
amount = p.amount,
|
||||
status = p.status,
|
||||
remarks = p.remarks,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
userNickName = sc.nickName
|
||||
})
|
||||
.MergeTable()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
var list = new PageList<CoreCmsInvoice>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 支付方式表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsPaymentsRepository : BaseRepository<CoreCmsPayments>, ICoreCmsPaymentsRepository
|
||||
{
|
||||
public CoreCmsPaymentsRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
134
CoreCms.Net.Repository/Financial/CoreCmsReportsRepository.cs
Normal file
134
CoreCms.Net.Repository/Financial/CoreCmsReportsRepository.cs
Normal file
@@ -0,0 +1,134 @@
|
||||
/***********************************************************************
|
||||
* 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.Threading.Tasks;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.Echarts;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 报表通用返回 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsReportsRepository : BaseRepository<GetOrdersReportsDbSelectOut>, ICoreCmsReportsRepository
|
||||
{
|
||||
public CoreCmsReportsRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取订单销量查询返回结果
|
||||
/// </summary>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="end"></param>
|
||||
/// <param name="filter"></param>
|
||||
/// <param name="filterSed"></param>
|
||||
/// <param name="thesort"></param>
|
||||
/// <param name="pageIndex"></param>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IPageList<GoodsSalesVolume>> GetGoodsSalesVolumes(string start, string end, string filter, string filterSed, string thesort, int pageIndex = 1, int pageSize = 5000)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
|
||||
var startDt = DateTime.Parse(start);
|
||||
var endDt = DateTime.Parse(end);
|
||||
|
||||
var orderBy = thesort switch
|
||||
{
|
||||
"asc" => OrderByType.Asc,
|
||||
"desc" => OrderByType.Desc,
|
||||
_ => OrderByType.Desc
|
||||
};
|
||||
|
||||
var data = await DbClient.Queryable<CoreCmsOrderItem>()
|
||||
.LeftJoin<CoreCmsOrder>((oi, o) => oi.orderId == o.orderId)
|
||||
.Where((oi, o) => o.payStatus != 1 && o.paymentTime > startDt && o.paymentTime <= endDt)
|
||||
.GroupBy((oi, o) => new
|
||||
{
|
||||
oi.sn,
|
||||
oi.name,
|
||||
oi.imageUrl,
|
||||
oi.addon
|
||||
})
|
||||
.Select((oi, o) => new GoodsSalesVolume()
|
||||
{
|
||||
nums = SqlFunc.AggregateSum(oi.nums),
|
||||
amount = SqlFunc.AggregateSum(oi.amount),
|
||||
sn = oi.sn,
|
||||
name = oi.name,
|
||||
imageUrl = oi.imageUrl,
|
||||
addon = oi.addon
|
||||
})
|
||||
.MergeTable()
|
||||
.OrderByIF(filter == "nums", p => p.nums, orderBy)
|
||||
.OrderByIF(filter == "amount", p => p.amount, orderBy)
|
||||
.OrderByIF(filterSed == "nums", p => p.nums, orderBy)
|
||||
.OrderByIF(filterSed == "amount", p => p.amount, orderBy)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
|
||||
var list = new PageList<GoodsSalesVolume>(data, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取商品收藏查询返回结果
|
||||
/// </summary>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="end"></param>
|
||||
/// <param name="thesort"></param>
|
||||
/// <param name="pageIndex"></param>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IPageList<GoodsCollection>> GetGoodsCollections(string start, string end, string thesort, int pageIndex = 1, int pageSize = 5000)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
|
||||
var startDt = DateTime.Parse(start);
|
||||
var endDt = DateTime.Parse(end);
|
||||
|
||||
var orderBy = thesort switch
|
||||
{
|
||||
"asc" => OrderByType.Asc,
|
||||
"desc" => OrderByType.Desc,
|
||||
_ => OrderByType.Desc
|
||||
};
|
||||
|
||||
var data = await DbClient.Queryable<CoreCmsGoodsCollection>()
|
||||
.LeftJoin<CoreCmsGoods>((gc, g) => gc.goodsId == g.id)
|
||||
.Where((gc, g) => gc.createTime > startDt && gc.createTime <= endDt)
|
||||
.GroupBy((gc, g) => new { gc.goodsId, gc.goodsName, g.images })
|
||||
.Select((gc, g) => new GoodsCollection()
|
||||
{
|
||||
nums = SqlFunc.AggregateCount(gc.goodsId),
|
||||
goodsName = gc.goodsName,
|
||||
goodId = gc.goodsId,
|
||||
images = g.images
|
||||
})
|
||||
.MergeTable()
|
||||
.OrderBy(gc => gc.nums, orderBy)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
|
||||
var list = new PageList<GoodsCollection>(data, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
26
CoreCms.Net.Repository/Good/CoreCmsBrandRepository.cs
Normal file
26
CoreCms.Net.Repository/Good/CoreCmsBrandRepository.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 品牌表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsBrandRepository : BaseRepository<CoreCmsBrand>, ICoreCmsBrandRepository
|
||||
{
|
||||
public CoreCmsBrandRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/***********************************************************************
|
||||
* 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.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品浏览记录表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsGoodsBrowsingRepository : BaseRepository<CoreCmsGoodsBrowsing>, ICoreCmsGoodsBrowsingRepository
|
||||
{
|
||||
public CoreCmsGoodsBrowsingRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写根据条件查询分页数据
|
||||
/// </summary>
|
||||
/// <param name="predicate">判断集合</param>
|
||||
/// <param name="orderByType">排序方式</param>
|
||||
/// <param name="pageIndex">当前页面索引</param>
|
||||
/// <param name="pageSize">分布大小</param>
|
||||
/// <param name="orderByExpression"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IPageList<CoreCmsGoodsBrowsing>> QueryPageAsync(
|
||||
Expression<Func<CoreCmsGoodsBrowsing, bool>> predicate,
|
||||
Expression<Func<CoreCmsGoodsBrowsing, object>> orderByExpression, OrderByType orderByType,
|
||||
int pageIndex = 1,
|
||||
int pageSize = 20)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
var page = await DbClient.Queryable<CoreCmsGoodsBrowsing, CoreCmsGoods>((gb, goods) =>
|
||||
new JoinQueryInfos(JoinType.Left, gb.goodsId == goods.id))
|
||||
.Select((gb, goods) => new CoreCmsGoodsBrowsing
|
||||
{
|
||||
id = gb.id,
|
||||
goodsId = gb.goodsId,
|
||||
userId = gb.userId,
|
||||
goodsName = gb.goodsName,
|
||||
createTime = gb.createTime,
|
||||
isdel = gb.isdel,
|
||||
goodImage = goods.image
|
||||
//isCollection = SqlFunc.Subqueryable<CoreCmsGoodsCollection>().Where(p => p.userId == gb.userId && p.goodsId == gb.goodsId).Any()
|
||||
})
|
||||
.With(SqlWith.NoLock)
|
||||
.MergeTable()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
|
||||
var list = new PageList<CoreCmsGoodsBrowsing>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品分类扩展表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsGoodsCategoryExtendRepository : BaseRepository<CoreCmsGoodsCategoryExtend>,
|
||||
ICoreCmsGoodsCategoryExtendRepository
|
||||
{
|
||||
public CoreCmsGoodsCategoryExtendRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
167
CoreCms.Net.Repository/Good/CoreCmsGoodsCategoryRepository.cs
Normal file
167
CoreCms.Net.Repository/Good/CoreCmsGoodsCategoryRepository.cs
Normal file
@@ -0,0 +1,167 @@
|
||||
/***********************************************************************
|
||||
* 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.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 CoreCmsGoodsCategoryRepository : BaseRepository<CoreCmsGoodsCategory>, ICoreCmsGoodsCategoryRepository
|
||||
{
|
||||
public CoreCmsGoodsCategoryRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
#region 实现重写增删改查操作==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> InsertAsync(CoreCmsGoodsCategory 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;
|
||||
if (bl)
|
||||
{
|
||||
await UpdateCaChe();
|
||||
}
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> UpdateAsync(CoreCmsGoodsCategory 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>
|
||||
/// 重写异步更新方法方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> UpdateAsync(List<CoreCmsGoodsCategory> 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<CoreCmsGoodsCategory>(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<CoreCmsGoodsCategory>().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<CoreCmsGoodsCategory>> GetCaChe()
|
||||
{
|
||||
var cache = ManualDataCache.Instance.Get<List<CoreCmsGoodsCategory>>(GlobalConstVars.CacheCoreCmsGoodsCategory);
|
||||
if (cache != null)
|
||||
{
|
||||
return cache;
|
||||
}
|
||||
return await UpdateCaChe();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新cache
|
||||
/// </summary>
|
||||
private async Task<List<CoreCmsGoodsCategory>> UpdateCaChe()
|
||||
{
|
||||
var list = await DbClient.Queryable<CoreCmsGoodsCategory>().With(SqlWith.NoLock).ToListAsync();
|
||||
ManualDataCache.Instance.Set(GlobalConstVars.CacheCoreCmsGoodsCategory, list);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
/***********************************************************************
|
||||
* 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.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Loging;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品收藏表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsGoodsCollectionRepository : BaseRepository<CoreCmsGoodsCollection>, ICoreCmsGoodsCollectionRepository
|
||||
{
|
||||
public CoreCmsGoodsCollectionRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
#region 重写根据条件查询分页数据
|
||||
/// <summary>
|
||||
/// 重写根据条件查询分页数据
|
||||
/// </summary>
|
||||
/// <param name="predicate">判断集合</param>
|
||||
/// <param name="orderByType">排序方式</param>
|
||||
/// <param name="pageIndex">当前页面索引</param>
|
||||
/// <param name="pageSize">分布大小</param>
|
||||
/// <param name="orderByExpression"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IPageList<CoreCmsGoodsCollection>> QueryPageAsync(Expression<Func<CoreCmsGoodsCollection, bool>> predicate,
|
||||
Expression<Func<CoreCmsGoodsCollection, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
var page = await DbClient.Queryable<CoreCmsGoodsCollection>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.Mapper(p => p.goods, p => p.goodsId)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
|
||||
var list = new PageList<CoreCmsGoodsCollection>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 收藏
|
||||
/// <summary>
|
||||
/// 收藏
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="goodsId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<WebApiCallBack> ToAdd(int userId, int goodsId)
|
||||
{
|
||||
var jm = new WebApiCallBack();
|
||||
|
||||
var goodsModel = await DbClient.Queryable<CoreCmsGoods>().Where(p => p.id == goodsId).FirstAsync();
|
||||
if (goodsModel == null)
|
||||
{
|
||||
jm.msg = "没有此商品";
|
||||
return jm;
|
||||
}
|
||||
var model = new CoreCmsGoodsCollection();
|
||||
model.userId = userId;
|
||||
model.goodsId = goodsId;
|
||||
model.createTime = DateTime.Now;
|
||||
model.goodsName = goodsModel.name;
|
||||
|
||||
await DbClient.Insertable(model).ExecuteCommandAsync();
|
||||
|
||||
jm.status = true;
|
||||
jm.msg = "收藏成功";
|
||||
|
||||
return jm;
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
278
CoreCms.Net.Repository/Good/CoreCmsGoodsCommentRepository.cs
Normal file
278
CoreCms.Net.Repository/Good/CoreCmsGoodsCommentRepository.cs
Normal file
@@ -0,0 +1,278 @@
|
||||
/***********************************************************************
|
||||
* 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 CoreCmsGoodsCommentRepository : BaseRepository<CoreCmsGoodsComment>, ICoreCmsGoodsCommentRepository
|
||||
{
|
||||
public CoreCmsGoodsCommentRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
#region 实现重写增删改查操作==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> InsertAsync(CoreCmsGoodsComment 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(CoreCmsGoodsComment entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var oldModel = await DbClient.Queryable<CoreCmsGoodsComment>().In(entity.id).SingleAsync();
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
//事物处理过程开始
|
||||
oldModel.id = entity.id;
|
||||
oldModel.commentId = entity.commentId;
|
||||
oldModel.score = entity.score;
|
||||
oldModel.userId = entity.userId;
|
||||
oldModel.goodsId = entity.goodsId;
|
||||
oldModel.orderId = entity.orderId;
|
||||
oldModel.addon = entity.addon;
|
||||
oldModel.images = entity.images;
|
||||
oldModel.contentBody = entity.contentBody;
|
||||
oldModel.sellerContent = entity.sellerContent;
|
||||
oldModel.isDisplay = entity.isDisplay;
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> UpdateAsync(List<CoreCmsGoodsComment> 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<CoreCmsGoodsComment>(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<CoreCmsGoodsComment>().In(ids).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 商家回复评价
|
||||
/// </summary>
|
||||
/// <param name="id">序列</param>
|
||||
/// <param name="sellerContent">回复内容</param>
|
||||
/// <returns></returns>
|
||||
public async Task<AdminUiCallBack> Reply(int id,string sellerContent)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var oldModel = await DbClient.Queryable<CoreCmsGoodsComment>().In(id).SingleAsync();
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
//事物处理过程开始
|
||||
oldModel.sellerContent = sellerContent;
|
||||
|
||||
//事物处理过程结束
|
||||
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="predicate">判断集合</param>
|
||||
/// <param name="orderByType">排序方式</param>
|
||||
/// <param name="orderByExpression"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<CoreCmsGoodsComment> DetailsByIdAsync(Expression<Func<CoreCmsGoodsComment, bool>> predicate,
|
||||
Expression<Func<CoreCmsGoodsComment, object>> orderByExpression, OrderByType orderByType)
|
||||
{
|
||||
var model = await DbClient.Queryable<CoreCmsGoodsComment, CoreCmsUser, CoreCmsGoods>((p, cUser, cGood) => new JoinQueryInfos(
|
||||
JoinType.Left, p.userId == cUser.id,
|
||||
JoinType.Left, p.goodsId == cGood.id
|
||||
))
|
||||
.Select((p, cUser, cGood) => new CoreCmsGoodsComment
|
||||
{
|
||||
id = p.id,
|
||||
commentId = p.commentId,
|
||||
score = p.score,
|
||||
userId = p.userId,
|
||||
goodsId = p.goodsId,
|
||||
orderId = p.orderId,
|
||||
addon = p.addon,
|
||||
images = p.images,
|
||||
contentBody = p.contentBody,
|
||||
sellerContent = p.sellerContent,
|
||||
isDisplay = p.isDisplay,
|
||||
createTime = p.createTime,
|
||||
avatarImage = cUser.avatarImage,
|
||||
nickName = cUser.nickName,
|
||||
mobile = cUser.mobile,
|
||||
goodName = cGood.name,
|
||||
})
|
||||
.MergeTable()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.Where(predicate)
|
||||
.FirstAsync();
|
||||
|
||||
if (model != null)
|
||||
{
|
||||
model.imagesArr = !string.IsNullOrEmpty(model.images) ? model.images.Split(",") : new String[0];
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
|
||||
#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<CoreCmsGoodsComment>> QueryPageAsync(Expression<Func<CoreCmsGoodsComment, bool>> predicate,
|
||||
Expression<Func<CoreCmsGoodsComment, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
|
||||
List<CoreCmsGoodsComment> page = await DbClient.Queryable<CoreCmsGoodsComment, CoreCmsUser, CoreCmsGoods>((p, cUser, cGood) => new JoinQueryInfos(
|
||||
JoinType.Left, p.userId == cUser.id,
|
||||
JoinType.Left, p.goodsId == cGood.id
|
||||
))
|
||||
.Select((p, cUser, cGood) => new CoreCmsGoodsComment
|
||||
{
|
||||
id = p.id,
|
||||
commentId = p.commentId,
|
||||
score = p.score,
|
||||
userId = p.userId,
|
||||
goodsId = p.goodsId,
|
||||
orderId = p.orderId,
|
||||
addon = p.addon,
|
||||
images = p.images,
|
||||
contentBody = p.contentBody,
|
||||
sellerContent = p.sellerContent,
|
||||
isDisplay = p.isDisplay,
|
||||
createTime = p.createTime,
|
||||
avatarImage = cUser.avatarImage,
|
||||
nickName = cUser.nickName,
|
||||
mobile = cUser.mobile,
|
||||
goodName = cGood.name,
|
||||
})
|
||||
.MergeTable()//将上面的操作变成一个表 mergetable
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.Where(predicate)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
|
||||
if (page.Any())
|
||||
{
|
||||
foreach (var item in page)
|
||||
{
|
||||
item.imagesArr = !string.IsNullOrEmpty(item.images) ? item.images.Split(",") : new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var list = new PageList<CoreCmsGoodsComment>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
27
CoreCms.Net.Repository/Good/CoreCmsGoodsGradeRepository.cs
Normal file
27
CoreCms.Net.Repository/Good/CoreCmsGoodsGradeRepository.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品会员价表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsGoodsGradeRepository : BaseRepository<CoreCmsGoodsGrade>, ICoreCmsGoodsGradeRepository
|
||||
{
|
||||
public CoreCmsGoodsGradeRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
26
CoreCms.Net.Repository/Good/CoreCmsGoodsParamsRepository.cs
Normal file
26
CoreCms.Net.Repository/Good/CoreCmsGoodsParamsRepository.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品参数表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsGoodsParamsRepository : BaseRepository<CoreCmsGoodsParams>, ICoreCmsGoodsParamsRepository
|
||||
{
|
||||
public CoreCmsGoodsParamsRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
1762
CoreCms.Net.Repository/Good/CoreCmsGoodsRepository.cs
Normal file
1762
CoreCms.Net.Repository/Good/CoreCmsGoodsRepository.cs
Normal file
File diff suppressed because it is too large
Load Diff
172
CoreCms.Net.Repository/Good/CoreCmsGoodsTypeSpecRepository.cs
Normal file
172
CoreCms.Net.Repository/Good/CoreCmsGoodsTypeSpecRepository.cs
Normal file
@@ -0,0 +1,172 @@
|
||||
/***********************************************************************
|
||||
* 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.Threading.Tasks;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Loging;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.FromBody;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.Utility.Helper;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品类型属性表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsGoodsTypeSpecRepository : BaseRepository<CoreCmsGoodsTypeSpec>, ICoreCmsGoodsTypeSpecRepository
|
||||
{
|
||||
|
||||
public CoreCmsGoodsTypeSpecRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 使用事务重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public async Task<AdminUiCallBack> InsertAsync(FmGoodsTypeSpecInsert entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
if (entity.value == null)
|
||||
{
|
||||
jm.msg = "请添加属性值"; return jm;
|
||||
}
|
||||
|
||||
for (int i = 0; i < entity.value.Count; i++)
|
||||
{
|
||||
entity.value[i] = entity.value[i].Trim();
|
||||
if (GoodsHelper.FilterChar(entity.value[i]) == false) continue;
|
||||
jm.msg = "属性值不符合支持规则"; return jm;
|
||||
}
|
||||
|
||||
if (entity.value.GroupBy(n => n).Any(c => c.Count() > 1))
|
||||
{
|
||||
jm.msg = "属性值不允许有相同"; return jm;
|
||||
}
|
||||
|
||||
var goodsTypeSpec = new CoreCmsGoodsTypeSpec();
|
||||
goodsTypeSpec.name = entity.name;
|
||||
goodsTypeSpec.sort = entity.sort;
|
||||
var specId = await DbClient.Insertable(goodsTypeSpec).ExecuteReturnIdentityAsync();
|
||||
if (specId > 0 && entity.value != null && entity.value.Count > 0)
|
||||
{
|
||||
var list = new List<CoreCmsGoodsTypeSpecValue>();
|
||||
for (var index = 0; index < entity.value.Count; index++)
|
||||
{
|
||||
var item = entity.value[index];
|
||||
list.Add(new CoreCmsGoodsTypeSpecValue()
|
||||
{
|
||||
specId = specId,
|
||||
value = item,
|
||||
sort = index + 1
|
||||
});
|
||||
}
|
||||
var bl = await DbClient.Insertable(list).ExecuteCommandAsync() > 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(FmGoodsTypeSpecUpdate entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
if (entity.value == null)
|
||||
{
|
||||
jm.msg = "请添加属性值"; return jm;
|
||||
}
|
||||
for (int i = 0; i < entity.value.Count; i++)
|
||||
{
|
||||
entity.value[i] = entity.value[i].Trim();
|
||||
if (GoodsHelper.FilterChar(entity.value[i]) == false) continue;
|
||||
jm.msg = "属性值不符合支持规则"; return jm;
|
||||
}
|
||||
if (entity.value.GroupBy(n => n).Any(c => c.Count() > 1))
|
||||
{
|
||||
jm.msg = "属性值不允许有相同"; return jm;
|
||||
}
|
||||
|
||||
var oldModel = await DbClient.Queryable<CoreCmsGoodsTypeSpec>().In(entity.id).SingleAsync();
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
oldModel.name = entity.name;
|
||||
oldModel.sort = entity.sort;
|
||||
var bl = await DbClient.Updateable(oldModel).ExecuteCommandHasChangeAsync();
|
||||
if (bl)
|
||||
{
|
||||
var oldValues = await DbClient.Queryable<CoreCmsGoodsTypeSpecValue>().OrderBy(p => p.sort)
|
||||
.Where(p => p.specId == oldModel.id).ToListAsync();
|
||||
|
||||
//获取需要删除的数据库数据
|
||||
var deleteValues = oldValues.Where(p => !entity.value.Contains(p.value)).ToList();
|
||||
//删除旧数据
|
||||
if (deleteValues.Any()) bl = await DbClient.Deleteable<CoreCmsGoodsTypeSpecValue>(deleteValues).ExecuteCommandHasChangeAsync();
|
||||
|
||||
//新数据
|
||||
var values = oldValues.Select(p => p.value).ToList();
|
||||
var newValues = entity.value.Except(values).ToList();
|
||||
|
||||
//插入新数据
|
||||
if (newValues.Any())
|
||||
{
|
||||
var newList = newValues.Select((t, index) => new CoreCmsGoodsTypeSpecValue() { specId = oldModel.id, value = t, sort = oldValues.Count + index }).ToList();
|
||||
bl = await DbClient.Insertable<CoreCmsGoodsTypeSpecValue>(newList).ExecuteCommandAsync() > 0;
|
||||
}
|
||||
}
|
||||
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<CoreCmsGoodsTypeSpec>(id).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
||||
if (bl)
|
||||
{
|
||||
await DbClient.Deleteable<CoreCmsGoodsTypeSpecValue>(p => p.specId == (int)id).ExecuteCommandHasChangeAsync();
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品类型属性值表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsGoodsTypeSpecValueRepository : BaseRepository<CoreCmsGoodsTypeSpecValue>, ICoreCmsGoodsTypeSpecValueRepository
|
||||
{
|
||||
public CoreCmsGoodsTypeSpecValueRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/***********************************************************************
|
||||
* 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.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;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 货品三级佣金表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsProductsDistributionRepository : BaseRepository<CoreCmsProductsDistribution>, ICoreCmsProductsDistributionRepository
|
||||
{
|
||||
public CoreCmsProductsDistributionRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
333
CoreCms.Net.Repository/Good/CoreCmsProductsRepository.cs
Normal file
333
CoreCms.Net.Repository/Good/CoreCmsProductsRepository.cs
Normal file
@@ -0,0 +1,333 @@
|
||||
/***********************************************************************
|
||||
* 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.Auth.HttpContextUser;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.Utility.Extensions;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 货品表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsProductsRepository : BaseRepository<CoreCmsProducts>, ICoreCmsProductsRepository
|
||||
{
|
||||
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly ICoreCmsStockRepository _stockRepository;
|
||||
private readonly IHttpContextUser _user;
|
||||
|
||||
|
||||
public CoreCmsProductsRepository(IUnitOfWork unitOfWork, ICoreCmsStockRepository stockRepository, IHttpContextUser user) : base(unitOfWork)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
_stockRepository = stockRepository;
|
||||
_user = user;
|
||||
}
|
||||
|
||||
#region 判断货品上下架状态
|
||||
|
||||
/// <summary>
|
||||
/// 判断货品上下架状态
|
||||
/// </summary>
|
||||
/// <param name="productsId">货品序列</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> GetShelfStatus(int productsId)
|
||||
{
|
||||
var data = await DbClient.Queryable<CoreCmsProducts, CoreCmsGoods>((products, goods) => new object[]
|
||||
{
|
||||
JoinType.Inner, products.goodsId == goods.id
|
||||
})
|
||||
.Where((products, goods) => products.id == productsId)
|
||||
.Select((products, goods) => new
|
||||
{
|
||||
productsId = products.id,
|
||||
isMarketable = goods.isMarketable
|
||||
}).FirstAsync();
|
||||
return data != null && data.isMarketable == true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取库存报警数量
|
||||
/// <summary>
|
||||
/// 获取库存报警数量
|
||||
/// </summary>
|
||||
/// <param name="goodsStocksWarn"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> GoodsStaticsTotalWarn(int goodsStocksWarn)
|
||||
{
|
||||
var sql = @"SELECT COUNT(*) AS number
|
||||
FROM ( SELECT t.goodsId
|
||||
FROM ( SELECT goodsId ,
|
||||
( CASE WHEN stock < freezeStock THEN 0
|
||||
ELSE stock - freezeStock
|
||||
END ) AS number
|
||||
FROM CoreCmsProducts
|
||||
) t
|
||||
WHERE t.number < " + goodsStocksWarn + @"
|
||||
GROUP BY t.goodsId
|
||||
) d";
|
||||
|
||||
var dt = await DbClient.Ado.GetDataTableAsync(sql);
|
||||
var number = dt.Rows[0][0].ObjectToInt(0);
|
||||
return number;
|
||||
}
|
||||
|
||||
#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<CoreCmsProducts>> QueryDetailPageAsync(Expression<Func<CoreCmsProducts, bool>> predicate,
|
||||
Expression<Func<CoreCmsProducts, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsProducts> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsProducts, CoreCmsGoods>((p, good) => new JoinQueryInfos(
|
||||
JoinType.Left, p.goodsId == good.id))
|
||||
.Select((p, good) => new CoreCmsProducts
|
||||
{
|
||||
id = p.id,
|
||||
goodsId = p.goodsId,
|
||||
barcode = p.barcode,
|
||||
sn = p.sn,
|
||||
price = p.price,
|
||||
costprice = p.costprice,
|
||||
mktprice = p.mktprice,
|
||||
marketable = p.marketable,
|
||||
weight = p.weight,
|
||||
stock = p.stock,
|
||||
freezeStock = p.freezeStock,
|
||||
spesDesc = p.spesDesc,
|
||||
isDefalut = p.isDefalut,
|
||||
images = p.images,
|
||||
isDel = p.isDel,
|
||||
name = good.name,
|
||||
bn = good.bn,
|
||||
isMarketable = good.isMarketable,
|
||||
unit = good.unit
|
||||
}).With(SqlWith.NoLock)
|
||||
.MergeTable()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsProducts, CoreCmsGoods>((p, good) => new JoinQueryInfos(
|
||||
JoinType.Left, p.goodsId == good.id))
|
||||
.Select((p, good) => new CoreCmsProducts
|
||||
{
|
||||
id = p.id,
|
||||
goodsId = p.goodsId,
|
||||
barcode = p.barcode,
|
||||
sn = p.sn,
|
||||
price = p.price,
|
||||
costprice = p.costprice,
|
||||
mktprice = p.mktprice,
|
||||
marketable = p.marketable,
|
||||
weight = p.weight,
|
||||
stock = p.stock,
|
||||
freezeStock = p.freezeStock,
|
||||
spesDesc = p.spesDesc,
|
||||
isDefalut = p.isDefalut,
|
||||
images = p.images,
|
||||
isDel = p.isDel,
|
||||
name = good.name,
|
||||
bn = good.bn,
|
||||
isMarketable = good.isMarketable,
|
||||
unit = good.unit
|
||||
})
|
||||
.MergeTable()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsProducts>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 修改单个货品库存并记入库存管理日志内
|
||||
|
||||
/// <summary>
|
||||
/// 修改单个货品库存并记入库存管理日志内
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="stockNumber"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<AdminUiCallBack> EditStock(int productId, int stockNumber)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var product = await DbClient.Queryable<CoreCmsProducts, CoreCmsGoods>((p, good) => new JoinQueryInfos(
|
||||
JoinType.Left, p.goodsId == good.id))
|
||||
.Select((p, good) => new CoreCmsProducts
|
||||
{
|
||||
id = p.id,
|
||||
goodsId = p.goodsId,
|
||||
barcode = p.barcode,
|
||||
sn = p.sn,
|
||||
price = p.price,
|
||||
costprice = p.costprice,
|
||||
mktprice = p.mktprice,
|
||||
marketable = p.marketable,
|
||||
weight = p.weight,
|
||||
stock = p.stock,
|
||||
freezeStock = p.freezeStock,
|
||||
spesDesc = p.spesDesc,
|
||||
isDefalut = p.isDefalut,
|
||||
images = p.images,
|
||||
isDel = p.isDel,
|
||||
name = good.name,
|
||||
bn = good.bn,
|
||||
isMarketable = good.isMarketable,
|
||||
unit = good.unit
|
||||
})
|
||||
.MergeTable()
|
||||
.Where(p => p.id == productId)
|
||||
.FirstAsync();
|
||||
if (product == null)
|
||||
{
|
||||
jm.msg = "货品数据查询失败";
|
||||
return jm;
|
||||
}
|
||||
|
||||
|
||||
var nums = stockNumber - product.stock;
|
||||
var msg = string.Empty;
|
||||
if (nums == 0)
|
||||
{
|
||||
jm.code = 0;
|
||||
jm.msg = "库存未修改";
|
||||
return jm;
|
||||
}
|
||||
else if (nums < 0)
|
||||
{
|
||||
jm.code = 0;
|
||||
msg = "库存盘点:库存减少" + Math.Abs(nums);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = "库存盘点:库存增加" + nums;
|
||||
}
|
||||
|
||||
var stockModel = new CoreCmsStock();
|
||||
stockModel.id = await _stockRepository.CreateCode(GlobalEnumVars.StockType.CheckGoods.ToString());
|
||||
stockModel.memo = msg;
|
||||
stockModel.type = (int)GlobalEnumVars.StockType.CheckGoods;
|
||||
stockModel.manager = _user.ID;
|
||||
stockModel.createTime = DateTime.Now;
|
||||
|
||||
var stockLogModel = new CoreCmsStockLog();
|
||||
stockLogModel.stockId = stockModel.id;
|
||||
stockLogModel.productId = product.id;
|
||||
stockLogModel.goodsId = product.goodsId;
|
||||
stockLogModel.nums = nums;
|
||||
stockLogModel.goodsName = product.name;
|
||||
stockLogModel.sn = product.sn;
|
||||
stockLogModel.bn = product.bn;
|
||||
stockLogModel.spesDesc = product.spesDesc;
|
||||
|
||||
try
|
||||
{
|
||||
_unitOfWork.BeginTran();
|
||||
|
||||
await DbClient.Updateable<CoreCmsProducts>().SetColumns(p => new CoreCmsProducts() { stock = stockNumber }).Where(p => p.id == product.id).ExecuteCommandAsync();
|
||||
|
||||
await DbClient.Insertable(stockModel).ExecuteCommandAsync();
|
||||
await DbClient.Insertable(stockLogModel).ExecuteCommandAsync();
|
||||
|
||||
jm.code = 0;
|
||||
jm.msg = "库存修改成功";
|
||||
|
||||
_unitOfWork.CommitTran();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
jm.code = 1;
|
||||
jm.msg = "库存修改异常";
|
||||
jm.otherData = e;
|
||||
_unitOfWork.RollbackTran();
|
||||
}
|
||||
return jm;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 获取货品数据
|
||||
/// <summary>
|
||||
/// 获取货品数据
|
||||
/// </summary>
|
||||
/// <param name="goodId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<CoreCmsProducts>> GetProducts(int goodId = 0)
|
||||
{
|
||||
var list = await DbClient.Queryable<CoreCmsProducts, CoreCmsGoods>((p, good) => new JoinQueryInfos(
|
||||
JoinType.Left, p.goodsId == good.id))
|
||||
.Select((p, good) => new CoreCmsProducts
|
||||
{
|
||||
id = p.id,
|
||||
goodsId = p.goodsId,
|
||||
barcode = p.barcode,
|
||||
sn = p.sn,
|
||||
price = p.price,
|
||||
costprice = p.costprice,
|
||||
mktprice = p.mktprice,
|
||||
marketable = p.marketable,
|
||||
weight = p.weight,
|
||||
stock = p.stock,
|
||||
freezeStock = p.freezeStock,
|
||||
spesDesc = p.spesDesc,
|
||||
isDefalut = p.isDefalut,
|
||||
images = p.images,
|
||||
isDel = p.isDel,
|
||||
name = good.name,
|
||||
bn = good.bn,
|
||||
isMarketable = good.isMarketable,
|
||||
unit = good.unit
|
||||
}).With(SqlWith.NoLock)
|
||||
.MergeTable()
|
||||
.OrderBy(p => p.id, OrderByType.Desc)
|
||||
.WhereIF(goodId > 0, p => p.goodsId == goodId)
|
||||
.Where(p => p.isDel == false)
|
||||
.ToListAsync();
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 表单项表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsFormItemRepository : BaseRepository<CoreCmsFormItem>, ICoreCmsFormItemRepository
|
||||
{
|
||||
public CoreCmsFormItemRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
469
CoreCms.Net.Repository/IntelligentForms/CoreCmsFormRepository.cs
Normal file
469
CoreCms.Net.Repository/IntelligentForms/CoreCmsFormRepository.cs
Normal file
@@ -0,0 +1,469 @@
|
||||
/***********************************************************************
|
||||
* 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.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Loging;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.FromBody;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 表单 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsFormRepository : BaseRepository<CoreCmsForm>, ICoreCmsFormRepository
|
||||
{
|
||||
public CoreCmsFormRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
#region 重写异步插入方法==========================================================
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public async Task<AdminUiCallBack> InsertAsync(FMForm entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
|
||||
var check = CheckItems(entity.items);
|
||||
if (check.code == 1)
|
||||
{
|
||||
return check;
|
||||
}
|
||||
|
||||
entity.model.createTime = DateTime.Now;
|
||||
|
||||
var id = await DbClient.Insertable(entity.model).ExecuteReturnIdentityAsync();
|
||||
entity.items.ForEach(p =>
|
||||
{
|
||||
p.formId = id;
|
||||
});
|
||||
|
||||
var bl = await DbClient.Insertable(entity.items).ExecuteCommandAsync() > 0;
|
||||
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.CreateSuccess : GlobalConstVars.CreateFailure;
|
||||
|
||||
|
||||
if (bl)
|
||||
{
|
||||
await UpdateCaChe();
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<AdminUiCallBack> UpdateAsync(FMForm entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var check = CheckItems(entity.items);
|
||||
if (check.code == 1)
|
||||
{
|
||||
return check;
|
||||
}
|
||||
|
||||
var oldModel = await DbClient.Queryable<CoreCmsForm>().In(entity.model.id).SingleAsync();
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
//事物处理过程开始
|
||||
//oldModel.id = entity.model.id;
|
||||
oldModel.name = entity.model.name;
|
||||
oldModel.type = entity.model.type;
|
||||
oldModel.sort = entity.model.sort;
|
||||
oldModel.images = entity.model.images;
|
||||
oldModel.videoPath = entity.model.videoPath;
|
||||
oldModel.description = entity.model.description;
|
||||
oldModel.headType = entity.model.headType;
|
||||
oldModel.headTypeValue = entity.model.headTypeValue;
|
||||
oldModel.headTypeVideo = entity.model.headTypeVideo;
|
||||
oldModel.buttonName = entity.model.buttonName;
|
||||
oldModel.buttonColor = entity.model.buttonColor;
|
||||
oldModel.isLogin = entity.model.isLogin;
|
||||
oldModel.times = entity.model.times;
|
||||
//oldModel.qrcode = entity.model.qrcode;
|
||||
oldModel.returnMsg = entity.model.returnMsg;
|
||||
oldModel.endDateTime = entity.model.endDateTime;
|
||||
//oldModel.createTime = entity.model.createTime;
|
||||
oldModel.updateTime = DateTime.Now;
|
||||
|
||||
//事物处理过程结束
|
||||
var bl = await DbClient.Updateable(oldModel).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
|
||||
if (bl)
|
||||
{
|
||||
//查询已经存在的数据
|
||||
var items = await DbClient.Queryable<CoreCmsFormItem>().Where(p => p.formId == oldModel.id).ToListAsync();
|
||||
//找到提交的数据是否有老数据
|
||||
var oldPostItems = entity.items.Where(p => p.id > 0).ToList();
|
||||
if (oldPostItems.Any())
|
||||
{
|
||||
var oldPostItemsIds = oldPostItems.Select(p => p.id).ToList();
|
||||
//找到数据库中和提交的数据库中都不存在差集数据进行删除
|
||||
var deletes = items.Where(p => !oldPostItemsIds.Contains(p.id)).ToList();
|
||||
if (deletes.Any())
|
||||
{
|
||||
await DbClient.Deleteable<CoreCmsFormItem>(deletes).ExecuteCommandHasChangeAsync();
|
||||
}
|
||||
//对提交的老数据进行更新处理
|
||||
var oldDataItems = items.Where(p => oldPostItemsIds.Contains(p.id)).ToList();
|
||||
if (oldDataItems.Any())
|
||||
{
|
||||
oldDataItems.ForEach(p =>
|
||||
{
|
||||
var child = oldPostItems.Find(o => o.id == p.id);
|
||||
if (child != null)
|
||||
{
|
||||
p.name = child.name;
|
||||
p.type = child.type;
|
||||
p.validationType = child.validationType;
|
||||
p.value = child.value;
|
||||
p.defaultValue = child.defaultValue;
|
||||
//p.formId = child.formId;
|
||||
p.required = child.required;
|
||||
p.sort = child.sort;
|
||||
|
||||
}
|
||||
});
|
||||
await DbClient.Updateable(oldDataItems).ExecuteCommandHasChangeAsync();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
await DbClient.Deleteable<CoreCmsFormItem>(items).ExecuteCommandHasChangeAsync();
|
||||
}
|
||||
|
||||
//新数据
|
||||
var newPostItems = entity.items.Where(p => p.id == 0).ToList();
|
||||
if (newPostItems.Any())
|
||||
{
|
||||
entity.items.ForEach(p =>
|
||||
{
|
||||
p.formId = oldModel.id;
|
||||
});
|
||||
await DbClient.Insertable(newPostItems).ExecuteCommandAsync();
|
||||
}
|
||||
await UpdateCaChe();
|
||||
}
|
||||
return jm;
|
||||
}
|
||||
|
||||
public AdminUiCallBack CheckItems(List<CoreCmsFormItem> items)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
if (!items.Any())
|
||||
{
|
||||
jm.msg = "请添加字段数据";
|
||||
return jm;
|
||||
}
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
if (string.IsNullOrEmpty(item.name))
|
||||
{
|
||||
jm.msg = "字段名称不能为空";
|
||||
return jm;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(item.defaultValue))
|
||||
{
|
||||
item.defaultValue = item.defaultValue.Trim();
|
||||
item.defaultValue = item.defaultValue.Replace(",", ",");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(item.value))
|
||||
{
|
||||
item.value = item.value.Trim();
|
||||
item.value = item.value.Replace(",", ",");
|
||||
}
|
||||
|
||||
if (item.type == GlobalEnumVars.FormFieldTypes.goods.ToString() && string.IsNullOrEmpty(item.value))
|
||||
{
|
||||
jm.msg = "【商品】字段必须要选择商品";
|
||||
return jm;
|
||||
}
|
||||
else if (item.type == GlobalEnumVars.FormFieldTypes.radio.ToString() && string.IsNullOrEmpty(item.value))
|
||||
{
|
||||
jm.msg = "【单选】字段必须要至少有二个以上值,并且以逗号分隔";
|
||||
return jm;
|
||||
}
|
||||
else if (item.type == GlobalEnumVars.FormFieldTypes.radio.ToString() && !string.IsNullOrEmpty(item.value))
|
||||
{
|
||||
var arr = item.value.Split(",");
|
||||
if (arr.Length < 2)
|
||||
{
|
||||
jm.msg = "【单选】字段必须要至少有二个以上值,并且以逗号分隔";
|
||||
return jm;
|
||||
}
|
||||
}
|
||||
else if (item.type == GlobalEnumVars.FormFieldTypes.checbox.ToString() && string.IsNullOrEmpty(item.value))
|
||||
{
|
||||
jm.msg = "【多选项】字段必须要至少有二个或以上值,并且以逗号分隔";
|
||||
return jm;
|
||||
}
|
||||
else if (item.type == GlobalEnumVars.FormFieldTypes.checbox.ToString() && !string.IsNullOrEmpty(item.value))
|
||||
{
|
||||
var arr = item.value.Split(",");
|
||||
if (arr.Length < 2)
|
||||
{
|
||||
jm.msg = "【多选项】字段必须要至少有二个词组或以上值,并且以逗号分隔";
|
||||
return jm;
|
||||
}
|
||||
}
|
||||
else if (item.type == GlobalEnumVars.FormFieldTypes.date.ToString())
|
||||
{
|
||||
//没有值的时候设置下默认值
|
||||
}
|
||||
else if (item.type == GlobalEnumVars.FormFieldTypes.time.ToString())
|
||||
{
|
||||
//没有值的时候设置下默认值
|
||||
}
|
||||
}
|
||||
|
||||
jm.code = 0;
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
|
||||
#region 实现重写增删改查操作==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> InsertAsync(CoreCmsForm 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;
|
||||
if (bl)
|
||||
{
|
||||
await UpdateCaChe();
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> UpdateAsync(List<CoreCmsForm> 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 async Task<AdminUiCallBack> DeleteByIdAsync(int id)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var isHaveSubmitData = await DbClient.Queryable<CoreCmsFormSubmit>().AnyAsync(p => p.formId == id);
|
||||
if (isHaveSubmitData)
|
||||
{
|
||||
jm.msg = "此表单已经存在用户提交数据,禁止删除";
|
||||
return jm;
|
||||
}
|
||||
|
||||
|
||||
var bl = await DbClient.Deleteable<CoreCmsForm>(id).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
||||
if (bl)
|
||||
{
|
||||
await DbClient.Deleteable<CoreCmsFormItem>().Where(p => p.formId == id).ExecuteCommandHasChangeAsync();
|
||||
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<CoreCmsForm>().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<CoreCmsForm>> GetCaChe()
|
||||
{
|
||||
var cache = ManualDataCache.Instance.Get<List<CoreCmsForm>>(GlobalConstVars.CacheCoreCmsForm);
|
||||
if (cache != null)
|
||||
{
|
||||
return cache;
|
||||
}
|
||||
return await UpdateCaChe();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新cache
|
||||
/// </summary>
|
||||
public async Task<List<CoreCmsForm>> UpdateCaChe()
|
||||
{
|
||||
var list = await DbClient.Queryable<CoreCmsForm>().With(SqlWith.NoLock).ToListAsync();
|
||||
ManualDataCache.Instance.Set(GlobalConstVars.CacheCoreCmsForm, 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<CoreCmsForm>> QueryPageAsync(Expression<Func<CoreCmsForm, bool>> predicate,
|
||||
Expression<Func<CoreCmsForm, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsForm> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsForm>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsForm
|
||||
{
|
||||
id = p.id,
|
||||
name = p.name,
|
||||
type = p.type,
|
||||
sort = p.sort,
|
||||
images = p.images,
|
||||
videoPath = p.videoPath,
|
||||
description = p.description,
|
||||
headType = p.headType,
|
||||
headTypeValue = p.headTypeValue,
|
||||
headTypeVideo = p.headTypeVideo,
|
||||
buttonName = p.buttonName,
|
||||
buttonColor = p.buttonColor,
|
||||
isLogin = p.isLogin,
|
||||
times = p.times,
|
||||
qrcode = p.qrcode,
|
||||
returnMsg = p.returnMsg,
|
||||
endDateTime = p.endDateTime,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
})
|
||||
.Mapper(it => it.Items, it => it.Items.First().formId)
|
||||
.With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsForm>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsForm
|
||||
{
|
||||
id = p.id,
|
||||
name = p.name,
|
||||
type = p.type,
|
||||
sort = p.sort,
|
||||
images = p.images,
|
||||
videoPath = p.videoPath,
|
||||
description = p.description,
|
||||
headType = p.headType,
|
||||
headTypeValue = p.headTypeValue,
|
||||
headTypeVideo = p.headTypeVideo,
|
||||
buttonName = p.buttonName,
|
||||
buttonColor = p.buttonColor,
|
||||
isLogin = p.isLogin,
|
||||
times = p.times,
|
||||
qrcode = p.qrcode,
|
||||
returnMsg = p.returnMsg,
|
||||
endDateTime = p.endDateTime,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
|
||||
})
|
||||
.Mapper(it => it.Items, it => it.Items.First().formId)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsForm>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 提交表单保存大文本值表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsFormSubmitDetailRepository : BaseRepository<CoreCmsFormSubmitDetail>, ICoreCmsFormSubmitDetailRepository
|
||||
{
|
||||
public CoreCmsFormSubmitDetailRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,318 @@
|
||||
/***********************************************************************
|
||||
* 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.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Loging;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.Model.ViewModels.DTO;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户对表的提交记录 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsFormSubmitRepository : BaseRepository<CoreCmsFormSubmit>, ICoreCmsFormSubmitRepository
|
||||
{
|
||||
public CoreCmsFormSubmitRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#region 实现重写增删改查操作==========================================================
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法并返回自增值
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> InsertReturnIdentityAsync(CoreCmsFormSubmit entity)
|
||||
{
|
||||
return await DbClient.Insertable(entity).ExecuteReturnIdentityAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> InsertAsync(CoreCmsFormSubmit entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var id = await DbClient.Insertable(entity).ExecuteReturnIdentityAsync();
|
||||
var bl = id > 0;
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.CreateSuccess : GlobalConstVars.CreateFailure;
|
||||
jm.count = id;
|
||||
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> UpdateAsync(CoreCmsFormSubmit entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var oldModel = await DbClient.Queryable<CoreCmsFormSubmit>().In(entity.id).SingleAsync();
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
//事物处理过程开始
|
||||
oldModel.id = entity.id;
|
||||
oldModel.formId = entity.formId;
|
||||
oldModel.formName = entity.formName;
|
||||
oldModel.userId = entity.userId;
|
||||
oldModel.money = entity.money;
|
||||
oldModel.payStatus = entity.payStatus;
|
||||
oldModel.status = entity.status;
|
||||
oldModel.feedback = entity.feedback;
|
||||
oldModel.ip = entity.ip;
|
||||
oldModel.createTime = entity.createTime;
|
||||
oldModel.updateTime = entity.updateTime;
|
||||
|
||||
//事物处理过程结束
|
||||
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<CoreCmsFormSubmit> 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<CoreCmsFormSubmit>(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<CoreCmsFormSubmit>().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<CoreCmsFormSubmit>> QueryPageAsync(Expression<Func<CoreCmsFormSubmit, bool>> predicate,
|
||||
Expression<Func<CoreCmsFormSubmit, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsFormSubmit> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsFormSubmit, CoreCmsUser>((p, sc) => new JoinQueryInfos(
|
||||
JoinType.Left, p.userId == sc.id))
|
||||
.Select((p, sc) => new CoreCmsFormSubmit
|
||||
{
|
||||
id = p.id,
|
||||
formId = p.formId,
|
||||
formName = p.formName,
|
||||
userId = p.userId,
|
||||
money = p.money,
|
||||
payStatus = p.payStatus,
|
||||
status = p.status,
|
||||
feedback = p.feedback,
|
||||
ip = p.ip,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
userName = sc.nickName,
|
||||
avatarImage = sc.avatarImage
|
||||
})
|
||||
.With(SqlWith.NoLock)
|
||||
.MergeTable()
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsFormSubmit, CoreCmsUser>((p, sc) => new JoinQueryInfos(
|
||||
JoinType.Left, p.userId == sc.id))
|
||||
.Select((p, sc) => new CoreCmsFormSubmit
|
||||
{
|
||||
id = p.id,
|
||||
formId = p.formId,
|
||||
formName = p.formName,
|
||||
userId = p.userId,
|
||||
money = p.money,
|
||||
payStatus = p.payStatus,
|
||||
status = p.status,
|
||||
feedback = p.feedback,
|
||||
ip = p.ip,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
userName = sc.nickName,
|
||||
avatarImage = sc.avatarImage
|
||||
})
|
||||
.MergeTable()
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsFormSubmit>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region 表单支付
|
||||
|
||||
/// <summary>
|
||||
/// 表单支付
|
||||
/// </summary>
|
||||
/// <param name="id">序列</param>
|
||||
/// <returns></returns>
|
||||
public async Task<WebApiCallBack> Pay(int id)
|
||||
{
|
||||
var jm = new WebApiCallBack();
|
||||
|
||||
|
||||
if (id == 0)
|
||||
{
|
||||
jm.msg = "支付失败";
|
||||
return jm;
|
||||
}
|
||||
|
||||
await DbClient.Updateable<CoreCmsFormSubmit>().SetColumns(p => p.payStatus == true).Where(p => p.id == id && p.payStatus == false)
|
||||
.ExecuteCommandAsync();
|
||||
jm.status = true;
|
||||
jm.data = jm.msg = "支付成功";
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取表单的统计数据
|
||||
/// </summary>
|
||||
/// <param name="formId">表单序列</param>
|
||||
/// <param name="day">多少天内的数据</param>
|
||||
/// <returns></returns>
|
||||
public async Task<FormStatisticsViewDto> GetStatisticsByFormid(int formId, int day)
|
||||
{
|
||||
var dt = DateTime.Now;
|
||||
var whereDt = dt.AddDays(-day);
|
||||
|
||||
var list = await DbClient.Queryable<CoreCmsFormSubmit>()
|
||||
.Where(p => p.formId == formId)
|
||||
.WhereIF(day > 0, p => p.createTime >= whereDt)
|
||||
.GroupBy(p => new { p.createTime, p.formId })
|
||||
.Select(p => new FormStatisticsDto()
|
||||
{
|
||||
day = SqlFunc.MappingColumn(p.createTime, "CONVERT(varchar(100), createTime, 111)").ToString(),
|
||||
nums = SqlFunc.AggregateCount(p.id),
|
||||
formId = p.formId
|
||||
})
|
||||
.OrderBy(p => p.day)
|
||||
.With(SqlWith.NoLock)
|
||||
.ToListAsync();
|
||||
|
||||
var num = day - 1;
|
||||
var days = new int[day];
|
||||
var d = new String[day];
|
||||
|
||||
for (int i = 0; i <= num; i++)
|
||||
{
|
||||
var j = num - i;
|
||||
var iDt = dt.AddDays(-j).ToString("yyyy/MM/dd");
|
||||
|
||||
d[i] = iDt;
|
||||
|
||||
var result = list.Find(p => p.day == iDt);
|
||||
if (result != null)
|
||||
{
|
||||
days[i] = result.nums;
|
||||
}
|
||||
else
|
||||
{
|
||||
days[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
var obj = new FormStatisticsViewDto { data = days, day = d, formId = formId };
|
||||
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 消息配置表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsMessageCenterRepository : BaseRepository<CoreCmsMessageCenter>, ICoreCmsMessageCenterRepository
|
||||
{
|
||||
public CoreCmsMessageCenterRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
33
CoreCms.Net.Repository/Message/CoreCmsMessageRepository.cs
Normal file
33
CoreCms.Net.Repository/Message/CoreCmsMessageRepository.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
/***********************************************************************
|
||||
* 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.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;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 消息发送表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsMessageRepository : BaseRepository<CoreCmsMessage>, ICoreCmsMessageRepository
|
||||
{
|
||||
public CoreCmsMessageRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
37
CoreCms.Net.Repository/Message/CoreCmsSmsRepository.cs
Normal file
37
CoreCms.Net.Repository/Message/CoreCmsSmsRepository.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
/***********************************************************************
|
||||
* 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.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 短信发送日志 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsSmsRepository : BaseRepository<CoreCmsSms>, ICoreCmsSmsRepository
|
||||
{
|
||||
public CoreCmsSmsRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
57
CoreCms.Net.Repository/Order/CoreCmsOrderItemRepository.cs
Normal file
57
CoreCms.Net.Repository/Order/CoreCmsOrderItemRepository.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
/***********************************************************************
|
||||
* 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.Threading.Tasks;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单明细表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsOrderItemRepository : BaseRepository<CoreCmsOrderItem>, ICoreCmsOrderItemRepository
|
||||
{
|
||||
public CoreCmsOrderItemRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#region 算订单的商品退了多少个(未发货的退货数量,已发货的退货不算)
|
||||
|
||||
/// <summary>
|
||||
/// 算订单的商品退了多少个(未发货的退货数量,已发货的退货不算)
|
||||
/// </summary>
|
||||
/// <param name="orderId"></param>
|
||||
/// <param name="sn"></param>
|
||||
/// <returns></returns>
|
||||
public int GetaftersalesNums(string orderId, string sn)
|
||||
{
|
||||
var sum = DbClient.Queryable<CoreCmsBillAftersalesItem, CoreCmsBillAftersales>((item, parent) =>
|
||||
new object[]
|
||||
{
|
||||
JoinType.Inner, item.aftersalesId == parent.aftersalesId
|
||||
}).Where((item, parent) => parent.orderId == orderId)
|
||||
.Where((item, parent) => parent.status == (int)GlobalEnumVars.OrderStatus.Complete)
|
||||
.Where((item, parent) => item.sn == sn)
|
||||
.Where((item, parent) => parent.type == (int)GlobalEnumVars.BillAftersalesStatus.WaitAudit)
|
||||
.Sum((item, parent) => item.nums);
|
||||
return sum;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
29
CoreCms.Net.Repository/Order/CoreCmsOrderLogRepository.cs
Normal file
29
CoreCms.Net.Repository/Order/CoreCmsOrderLogRepository.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单记录表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsOrderLogRepository : BaseRepository<CoreCmsOrderLog>, ICoreCmsOrderLogRepository
|
||||
{
|
||||
public CoreCmsOrderLogRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
393
CoreCms.Net.Repository/Order/CoreCmsOrderRepository.cs
Normal file
393
CoreCms.Net.Repository/Order/CoreCmsOrderRepository.cs
Normal file
@@ -0,0 +1,393 @@
|
||||
/***********************************************************************
|
||||
* 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.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.Entities.Expression;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.Model.ViewModels.DTO;
|
||||
using CoreCms.Net.Utility.Helper;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsOrderRepository : BaseRepository<CoreCmsOrder>, ICoreCmsOrderRepository
|
||||
{
|
||||
public CoreCmsOrderRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
#region 查询团购秒杀下单数量
|
||||
/// <summary>
|
||||
/// 查询团购秒杀下单数量
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="startTime"></param>
|
||||
/// <param name="endTime"></param>
|
||||
/// <param name="orderType"></param>
|
||||
/// <returns></returns>
|
||||
public FindLimitOrderDto FindLimitOrder(int productId, int userId, DateTime? startTime, DateTime? endTime, int orderType = 0)
|
||||
{
|
||||
var dto = new FindLimitOrderDto();
|
||||
|
||||
var statusArr = new int[]{(int)GlobalEnumVars.OrderStatus.Normal,
|
||||
(int)GlobalEnumVars.OrderStatus.Complete};
|
||||
|
||||
var payStatusArr = new int[] { (int)GlobalEnumVars.OrderPayStatus.No, (int)GlobalEnumVars.OrderPayStatus.Yes, (int)GlobalEnumVars.OrderPayStatus.PartialYes };
|
||||
var shipStatusArr = new int[] { (int)GlobalEnumVars.OrderShipStatus.No, (int)GlobalEnumVars.OrderShipStatus.Yes, (int)GlobalEnumVars.OrderShipStatus.PartialYes };
|
||||
|
||||
|
||||
var queryable = DbClient.Queryable<CoreCmsOrderItem, CoreCmsOrder>((orderItem, orderModel) => new object[]
|
||||
{
|
||||
JoinType.Inner, orderItem.orderId == orderModel.orderId
|
||||
});
|
||||
|
||||
//计算订单总量
|
||||
queryable.WhereIF(productId > 0, (orderItem, orderModel) => orderItem.productId == productId);
|
||||
queryable.In((orderItem, orderModel) => orderModel.status, payStatusArr);
|
||||
//在活动时间范围内
|
||||
queryable.WhereIF(startTime != null, (orderItem, orderModel) => orderModel.createTime >= startTime);
|
||||
queryable.WhereIF(endTime != null, (orderItem, orderModel) => orderModel.createTime < endTime);
|
||||
//已退款、已退货、部分退款的、部分退货的排除
|
||||
queryable.In((orderItem, orderModel) => orderModel.payStatus, payStatusArr);
|
||||
queryable.In((orderItem, orderModel) => orderModel.shipStatus, shipStatusArr);
|
||||
|
||||
|
||||
//订单类型
|
||||
if (orderType > 0)
|
||||
{
|
||||
queryable.Where((orderItem, orderModel) => orderModel.orderType == orderType);
|
||||
}
|
||||
|
||||
dto.TotalOrders = queryable.Clone().Select((orderItem, orderModel) => new { nums = orderItem.nums }).MergeTable().With(SqlWith.Null).Sum(p => p.nums);
|
||||
|
||||
if (userId <= 0) return dto;
|
||||
{
|
||||
queryable.Where((orderItem, orderModel) => orderModel.userId == userId);
|
||||
dto.TotalUserOrders = queryable.Clone().Select((orderItem, orderModel) => new { nums = orderItem.nums }).MergeTable().With(SqlWith.Null).Sum(p => p.nums);
|
||||
}
|
||||
return dto;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 根据用户id和商品id获取下了多少订单
|
||||
/// <summary>
|
||||
/// 根据用户id和商品id获取下了多少订单
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="goodId"></param>
|
||||
/// <returns></returns>
|
||||
public int GetOrderNum(int userId, int goodId)
|
||||
{
|
||||
var num = DbClient.Queryable<CoreCmsOrder, CoreCmsOrderItem>((op, ot) => new object[]
|
||||
{
|
||||
JoinType.Inner, op.orderId == ot.orderId
|
||||
}).Where((op, ot) => op.userId == userId && ot.goodsId == goodId).Count();
|
||||
return num;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 重写根据条件列表数据
|
||||
/// <summary>
|
||||
/// 重写根据条件列表数据
|
||||
/// </summary>
|
||||
/// <param name="predicate">判断集合</param>
|
||||
/// <param name="orderByType">排序方式</param>
|
||||
/// <param name="orderByExpression"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<CoreCmsOrder>> QueryListAsync(Expression<Func<CoreCmsOrder, bool>> predicate,
|
||||
Expression<Func<CoreCmsOrder, object>> orderByExpression, OrderByType orderByType)
|
||||
{
|
||||
List<CoreCmsOrder> list = await DbClient.Queryable<CoreCmsOrder, CoreCmsUser>((sOrder, sUser) => new JoinQueryInfos(
|
||||
JoinType.Left, sOrder.userId == sUser.id))
|
||||
.Select((sOrder, sUser) => new CoreCmsOrder
|
||||
{
|
||||
orderId = sOrder.orderId,
|
||||
goodsAmount = sOrder.goodsAmount,
|
||||
payedAmount = sOrder.payedAmount,
|
||||
orderAmount = sOrder.orderAmount,
|
||||
payStatus = sOrder.payStatus,
|
||||
shipStatus = sOrder.shipStatus,
|
||||
status = sOrder.status,
|
||||
orderType = sOrder.orderType,
|
||||
receiptType = sOrder.receiptType,
|
||||
paymentCode = sOrder.paymentCode,
|
||||
paymentTime = sOrder.paymentTime,
|
||||
logisticsId = sOrder.logisticsId,
|
||||
logisticsName = sOrder.logisticsName,
|
||||
costFreight = sOrder.costFreight,
|
||||
userId = sOrder.userId,
|
||||
sellerId = sOrder.sellerId,
|
||||
confirmStatus = sOrder.confirmStatus,
|
||||
confirmTime = sOrder.confirmTime,
|
||||
storeId = sOrder.storeId,
|
||||
shipAreaId = sOrder.shipAreaId,
|
||||
shipAddress = sOrder.shipAddress,
|
||||
shipName = sOrder.shipName,
|
||||
shipMobile = sOrder.shipMobile,
|
||||
weight = sOrder.weight,
|
||||
taxType = sOrder.taxType,
|
||||
taxCode = sOrder.taxCode,
|
||||
taxTitle = sOrder.taxTitle,
|
||||
point = sOrder.point,
|
||||
pointMoney = sOrder.pointMoney,
|
||||
orderDiscountAmount = sOrder.orderDiscountAmount,
|
||||
goodsDiscountAmount = sOrder.goodsDiscountAmount,
|
||||
couponDiscountAmount = sOrder.couponDiscountAmount,
|
||||
coupon = sOrder.coupon,
|
||||
promotionList = sOrder.promotionList,
|
||||
memo = sOrder.memo,
|
||||
ip = sOrder.ip,
|
||||
mark = sOrder.mark,
|
||||
source = sOrder.source,
|
||||
isComment = sOrder.isComment,
|
||||
isdel = sOrder.isdel,
|
||||
createTime = sOrder.createTime,
|
||||
updateTime = sOrder.updateTime,
|
||||
userNickName = sUser.nickName
|
||||
})
|
||||
.With(SqlWith.NoLock)
|
||||
.MergeTable()
|
||||
.Mapper(sOrder => sOrder.aftersalesItem, sOrder => sOrder.aftersalesItem.First().orderId)
|
||||
.Mapper(sOrder => sOrder.items, sOrder => sOrder.items.First().orderId)
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.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 new async Task<IPageList<CoreCmsOrder>> QueryPageAsync(Expression<Func<CoreCmsOrder, bool>> predicate,
|
||||
Expression<Func<CoreCmsOrder, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsOrder> page = await DbClient.Queryable<CoreCmsOrder, CoreCmsUser>((sOrder, sUser) => new JoinQueryInfos(
|
||||
JoinType.Left, sOrder.userId == sUser.id))
|
||||
.Select((sOrder, sUser) => new CoreCmsOrder
|
||||
{
|
||||
orderId = sOrder.orderId,
|
||||
goodsAmount = sOrder.goodsAmount,
|
||||
payedAmount = sOrder.payedAmount,
|
||||
orderAmount = sOrder.orderAmount,
|
||||
payStatus = sOrder.payStatus,
|
||||
shipStatus = sOrder.shipStatus,
|
||||
status = sOrder.status,
|
||||
orderType = sOrder.orderType,
|
||||
receiptType = sOrder.receiptType,
|
||||
paymentCode = sOrder.paymentCode,
|
||||
paymentTime = sOrder.paymentTime,
|
||||
logisticsId = sOrder.logisticsId,
|
||||
logisticsName = sOrder.logisticsName,
|
||||
costFreight = sOrder.costFreight,
|
||||
userId = sOrder.userId,
|
||||
sellerId = sOrder.sellerId,
|
||||
confirmStatus = sOrder.confirmStatus,
|
||||
confirmTime = sOrder.confirmTime,
|
||||
storeId = sOrder.storeId,
|
||||
shipAreaId = sOrder.shipAreaId,
|
||||
shipAddress = sOrder.shipAddress,
|
||||
shipName = sOrder.shipName,
|
||||
shipMobile = sOrder.shipMobile,
|
||||
weight = sOrder.weight,
|
||||
taxType = sOrder.taxType,
|
||||
taxCode = sOrder.taxCode,
|
||||
taxTitle = sOrder.taxTitle,
|
||||
point = sOrder.point,
|
||||
pointMoney = sOrder.pointMoney,
|
||||
orderDiscountAmount = sOrder.orderDiscountAmount,
|
||||
goodsDiscountAmount = sOrder.goodsDiscountAmount,
|
||||
couponDiscountAmount = sOrder.couponDiscountAmount,
|
||||
coupon = sOrder.coupon,
|
||||
promotionList = sOrder.promotionList,
|
||||
memo = sOrder.memo,
|
||||
ip = sOrder.ip,
|
||||
mark = sOrder.mark,
|
||||
source = sOrder.source,
|
||||
isComment = sOrder.isComment,
|
||||
isdel = sOrder.isdel,
|
||||
createTime = sOrder.createTime,
|
||||
updateTime = sOrder.updateTime,
|
||||
userNickName = sUser.nickName
|
||||
})
|
||||
.MergeTable()
|
||||
.Mapper(sOrder => sOrder.aftersalesItem, sOrder => sOrder.aftersalesItem.First().orderId)
|
||||
.Mapper(sOrder => sOrder.items, sOrder => sOrder.items.First().orderId)
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
|
||||
var list = new PageList<CoreCmsOrder>(page, pageIndex, pageSize, totalCount);
|
||||
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<CoreCmsOrder>> QueryPageNewAsync(Expression<Func<CoreCmsOrder, bool>> predicate,
|
||||
Expression<Func<CoreCmsOrder, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsOrder> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsOrder>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsOrder
|
||||
{
|
||||
orderId = p.orderId,
|
||||
goodsAmount = p.goodsAmount,
|
||||
payedAmount = p.payedAmount,
|
||||
orderAmount = p.orderAmount,
|
||||
payStatus = p.payStatus,
|
||||
shipStatus = p.shipStatus,
|
||||
status = p.status,
|
||||
orderType = p.orderType,
|
||||
receiptType = p.receiptType,
|
||||
paymentCode = p.paymentCode,
|
||||
paymentTime = p.paymentTime,
|
||||
logisticsId = p.logisticsId,
|
||||
logisticsName = p.logisticsName,
|
||||
costFreight = p.costFreight,
|
||||
userId = p.userId,
|
||||
sellerId = p.sellerId,
|
||||
confirmStatus = p.confirmStatus,
|
||||
confirmTime = p.confirmTime,
|
||||
storeId = p.storeId,
|
||||
shipAreaId = p.shipAreaId,
|
||||
shipAddress = p.shipAddress,
|
||||
shipName = p.shipName,
|
||||
shipMobile = p.shipMobile,
|
||||
weight = p.weight,
|
||||
taxType = p.taxType,
|
||||
taxCode = p.taxCode,
|
||||
taxTitle = p.taxTitle,
|
||||
point = p.point,
|
||||
pointMoney = p.pointMoney,
|
||||
orderDiscountAmount = p.orderDiscountAmount,
|
||||
goodsDiscountAmount = p.goodsDiscountAmount,
|
||||
couponDiscountAmount = p.couponDiscountAmount,
|
||||
coupon = p.coupon,
|
||||
promotionList = p.promotionList,
|
||||
memo = p.memo,
|
||||
ip = p.ip,
|
||||
mark = p.mark,
|
||||
source = p.source,
|
||||
isComment = p.isComment,
|
||||
isdel = p.isdel,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
|
||||
}).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsOrder>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsOrder
|
||||
{
|
||||
orderId = p.orderId,
|
||||
goodsAmount = p.goodsAmount,
|
||||
payedAmount = p.payedAmount,
|
||||
orderAmount = p.orderAmount,
|
||||
payStatus = p.payStatus,
|
||||
shipStatus = p.shipStatus,
|
||||
status = p.status,
|
||||
orderType = p.orderType,
|
||||
receiptType = p.receiptType,
|
||||
paymentCode = p.paymentCode,
|
||||
paymentTime = p.paymentTime,
|
||||
logisticsId = p.logisticsId,
|
||||
logisticsName = p.logisticsName,
|
||||
costFreight = p.costFreight,
|
||||
userId = p.userId,
|
||||
sellerId = p.sellerId,
|
||||
confirmStatus = p.confirmStatus,
|
||||
confirmTime = p.confirmTime,
|
||||
storeId = p.storeId,
|
||||
shipAreaId = p.shipAreaId,
|
||||
shipAddress = p.shipAddress,
|
||||
shipName = p.shipName,
|
||||
shipMobile = p.shipMobile,
|
||||
weight = p.weight,
|
||||
taxType = p.taxType,
|
||||
taxCode = p.taxCode,
|
||||
taxTitle = p.taxTitle,
|
||||
point = p.point,
|
||||
pointMoney = p.pointMoney,
|
||||
orderDiscountAmount = p.orderDiscountAmount,
|
||||
goodsDiscountAmount = p.goodsDiscountAmount,
|
||||
couponDiscountAmount = p.couponDiscountAmount,
|
||||
coupon = p.coupon,
|
||||
promotionList = p.promotionList,
|
||||
memo = p.memo,
|
||||
ip = p.ip,
|
||||
mark = p.mark,
|
||||
source = p.source,
|
||||
isComment = p.isComment,
|
||||
isdel = p.isdel,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
|
||||
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsOrder>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
26
CoreCms.Net.Repository/Pay/AliPayRepository.cs
Normal file
26
CoreCms.Net.Repository/Pay/AliPayRepository.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 支付宝支付 接口实现
|
||||
/// </summary>
|
||||
public class AliPayRepository : BaseRepository<CoreCmsSetting>, IAliPayRepository
|
||||
{
|
||||
public AliPayRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
26
CoreCms.Net.Repository/Pay/BalancePayRepository.cs
Normal file
26
CoreCms.Net.Repository/Pay/BalancePayRepository.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 余额支付 接口实现
|
||||
/// </summary>
|
||||
public class BalancePayRepository : BaseRepository<CoreCmsSetting>, IBalancePayRepository
|
||||
{
|
||||
public BalancePayRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
26
CoreCms.Net.Repository/Pay/OfflinePayRepository.cs
Normal file
26
CoreCms.Net.Repository/Pay/OfflinePayRepository.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 线下支付 接口实现
|
||||
/// </summary>
|
||||
public class OfflinePayRepository : BaseRepository<CoreCmsSetting>, IOfflinePayRepository
|
||||
{
|
||||
public OfflinePayRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
26
CoreCms.Net.Repository/Pay/WeChatPayRepository.cs
Normal file
26
CoreCms.Net.Repository/Pay/WeChatPayRepository.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 微信支付 接口实现
|
||||
/// </summary>
|
||||
public class WeChatPayRepository : BaseRepository<CoreCmsSetting>, IWeChatPayRepository
|
||||
{
|
||||
public WeChatPayRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 拼团商品表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsPinTuanGoodsRepository : BaseRepository<CoreCmsPinTuanGoods>, ICoreCmsPinTuanGoodsRepository
|
||||
{
|
||||
public CoreCmsPinTuanGoodsRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
221
CoreCms.Net.Repository/Pintuan/CoreCmsPintuanRecordRepository.cs
Normal file
221
CoreCms.Net.Repository/Pintuan/CoreCmsPintuanRecordRepository.cs
Normal file
@@ -0,0 +1,221 @@
|
||||
/***********************************************************************
|
||||
* 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.Configuration;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.Utility.Extensions;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 拼团记录表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsPinTuanRecordRepository : BaseRepository<CoreCmsPinTuanRecord>, ICoreCmsPinTuanRecordRepository
|
||||
{
|
||||
public CoreCmsPinTuanRecordRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成订单的时候,增加信息
|
||||
/// </summary>
|
||||
/// <param name="order">订单数据</param>
|
||||
/// <param name="items">商品列表</param>
|
||||
/// <param name="teamId">团队序列</param>
|
||||
/// <returns></returns>
|
||||
public async Task<WebApiCallBack> OrderAdd(CoreCmsOrder order, List<CoreCmsOrderItem> items, int teamId = 0)
|
||||
{
|
||||
var res = new WebApiCallBack() { methodDescription = "拼团生成订单的时候,增加信息" };
|
||||
|
||||
var orderItem = items.FirstOrDefault();
|
||||
|
||||
if (teamId > 0)
|
||||
{
|
||||
//参加别人拼团
|
||||
var info = await DbClient.Queryable<CoreCmsPinTuanRecord>().FirstAsync(p => p.id == teamId && p.closeTime > DateTime.Now &&
|
||||
p.status == (int)GlobalEnumVars.PinTuanRecordStatus.InProgress);
|
||||
if (info == null)
|
||||
{
|
||||
res.status = false;
|
||||
res.data = 15607;
|
||||
res.msg = GlobalErrorCodeVars.Code15607;
|
||||
return res;
|
||||
}
|
||||
//判断订单商品是否是要参加的拼团的商品
|
||||
if (info.goodsId != orderItem.goodsId)
|
||||
{
|
||||
res.status = false;
|
||||
res.data = 15608;
|
||||
res.msg = GlobalErrorCodeVars.Code15608;
|
||||
return res;
|
||||
}
|
||||
|
||||
var model = new CoreCmsPinTuanRecord();
|
||||
model.teamId = teamId;
|
||||
model.userId = order.userId;
|
||||
model.ruleId = info.ruleId;
|
||||
model.status = (int)GlobalEnumVars.PinTuanRecordStatus.InProgress;
|
||||
model.orderId = order.orderId;
|
||||
model.goodsId = (int)orderItem.goodsId;
|
||||
|
||||
|
||||
await DbClient.Insertable(model).ExecuteReturnIdentityAsync();
|
||||
|
||||
//判断团是否满了,如果满了,就更新状态
|
||||
if (!string.IsNullOrEmpty(info.parameters))
|
||||
{
|
||||
var parametersObj = (JObject)JsonConvert.DeserializeObject(info.parameters);
|
||||
if (parametersObj != null && parametersObj.ContainsKey("peopleNumber"))
|
||||
{
|
||||
var countPeopleNumber = await DbClient.Queryable<CoreCmsPinTuanRecord>().CountAsync(p => p.teamId == teamId);
|
||||
var peopleNumber = parametersObj["peopleNumber"].ObjectToInt(0);
|
||||
if (peopleNumber > 0 && countPeopleNumber >= peopleNumber)
|
||||
{
|
||||
await DbClient.Updateable<CoreCmsPinTuanRecord>()
|
||||
.SetColumns(p => p.status == (int)GlobalEnumVars.PinTuanRecordStatus.Succeed)
|
||||
.Where(p => p.teamId == teamId).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 自己创建拼团
|
||||
//取得规则id
|
||||
var pinfo = await DbClient.Queryable<CoreCmsPinTuanRule, CoreCmsPinTuanGoods>((role, goods) => new object[]
|
||||
{
|
||||
JoinType.Inner, role.id == goods.ruleId
|
||||
}).Where((role, goods) => role.isStatusOpen == true && goods.goodsId == orderItem.goodsId).FirstAsync();
|
||||
|
||||
if (pinfo == null)
|
||||
{
|
||||
res.status = false;
|
||||
res.data = 10000;
|
||||
res.msg = GlobalErrorCodeVars.Code10000;
|
||||
return res;
|
||||
}
|
||||
|
||||
var model = new CoreCmsPinTuanRecord();
|
||||
//model.teamId = teamId;
|
||||
model.userId = order.userId;
|
||||
model.ruleId = pinfo.id;
|
||||
model.status = (int)GlobalEnumVars.PinTuanRecordStatus.InProgress;
|
||||
model.orderId = order.orderId;
|
||||
model.goodsId = (int)orderItem.goodsId;
|
||||
|
||||
//冗余拼团人数,拼团结束时间字段
|
||||
model.createTime = DateTime.Now;
|
||||
model.closeTime = DateTime.Now.AddMinutes(pinfo.significantInterval);
|
||||
//附加参数
|
||||
var parameters = new { peopleNumber = pinfo.peopleNumber };
|
||||
model.parameters = JsonConvert.SerializeObject(parameters);
|
||||
model.teamId = 0;
|
||||
var outId = await DbClient.Insertable(model).ExecuteReturnIdentityAsync();
|
||||
if (outId > 0)
|
||||
{
|
||||
await DbClient.Updateable<CoreCmsPinTuanRecord>().SetColumns(p => p.teamId == outId).Where(p => p.id == outId).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
res.status = true;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
#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<CoreCmsPinTuanRecord>> QueryPageAsync(Expression<Func<CoreCmsPinTuanRecord, bool>> predicate,
|
||||
Expression<Func<CoreCmsPinTuanRecord, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsPinTuanRecord> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsPinTuanRecord, CoreCmsUser, CoreCmsPinTuanRule, CoreCmsGoods>((p, sc, ptr, good) => new JoinQueryInfos(
|
||||
JoinType.Left, p.userId == sc.id, JoinType.Left, p.ruleId == ptr.id, JoinType.Left, p.goodsId == good.id))
|
||||
.Select((p, sc, ptr, good) => new CoreCmsPinTuanRecord
|
||||
{
|
||||
id = p.id,
|
||||
teamId = p.teamId,
|
||||
userId = p.userId,
|
||||
ruleId = p.ruleId,
|
||||
goodsId = p.goodsId,
|
||||
status = p.status,
|
||||
orderId = p.orderId,
|
||||
parameters = p.parameters,
|
||||
closeTime = p.closeTime,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
userAvatar = sc.avatarImage,
|
||||
nickName = sc.nickName,
|
||||
ruleName = ptr.name,
|
||||
goodName = good.name
|
||||
})
|
||||
.MergeTable()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsPinTuanRecord, CoreCmsUser, CoreCmsPinTuanRule, CoreCmsGoods>((p, sc, ptr, good) => new JoinQueryInfos(
|
||||
JoinType.Left, p.userId == sc.id, JoinType.Left, p.ruleId == ptr.id, JoinType.Left, p.goodsId == good.id))
|
||||
.Select((p, sc, ptr, good) => new CoreCmsPinTuanRecord
|
||||
{
|
||||
id = p.id,
|
||||
teamId = p.teamId,
|
||||
userId = p.userId,
|
||||
ruleId = p.ruleId,
|
||||
goodsId = p.goodsId,
|
||||
status = p.status,
|
||||
orderId = p.orderId,
|
||||
parameters = p.parameters,
|
||||
closeTime = p.closeTime,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
userAvatar = sc.avatarImage,
|
||||
nickName = sc.nickName,
|
||||
ruleName = ptr.name,
|
||||
goodName = good.name
|
||||
})
|
||||
.MergeTable()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsPinTuanRecord>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
180
CoreCms.Net.Repository/Pintuan/CoreCmsPintuanRuleRepository.cs
Normal file
180
CoreCms.Net.Repository/Pintuan/CoreCmsPintuanRuleRepository.cs
Normal file
@@ -0,0 +1,180 @@
|
||||
/***********************************************************************
|
||||
* 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.Configuration;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.Model.ViewModels.DTO;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 拼团规则表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsPinTuanRuleRepository : BaseRepository<CoreCmsPinTuanRule>, ICoreCmsPinTuanRuleRepository
|
||||
{
|
||||
public CoreCmsPinTuanRuleRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
#region 取购物车数据的时候,更新价格
|
||||
/// <summary>
|
||||
/// 取购物车数据的时候,更新价格
|
||||
/// </summary>
|
||||
/// <param name="list"></param>
|
||||
/// <returns></returns>
|
||||
public WebApiCallBack PinTuanInfo(List<CartProducts> list)
|
||||
{
|
||||
var res = new WebApiCallBack();
|
||||
foreach (var item in list)
|
||||
{
|
||||
var ruleModel = DbClient.Queryable<CoreCmsPinTuanGoods, CoreCmsPinTuanRule>(
|
||||
(pinTuanGoods, pinTuanRule) => new object[]
|
||||
{
|
||||
JoinType.Inner, pinTuanGoods.ruleId == pinTuanRule.id
|
||||
}).Where((pinTuanGoods, pinTuanRule) =>
|
||||
pinTuanGoods.goodsId == item.products.goodsId && pinTuanRule.isStatusOpen == true)
|
||||
.Select((pinTuanGoods, pinTuanRule) => pinTuanRule).First();
|
||||
if (ruleModel == null)
|
||||
{
|
||||
res.data = 15603;
|
||||
res.msg = GlobalErrorCodeVars.Code15603;
|
||||
return res;
|
||||
}
|
||||
var dt = DateTime.Now;
|
||||
if (ruleModel.startTime > dt)
|
||||
{
|
||||
res.data = 15601;
|
||||
res.msg = GlobalErrorCodeVars.Code15601;
|
||||
return res;
|
||||
}
|
||||
if (ruleModel.endTime < dt)
|
||||
{
|
||||
res.data = 15602;
|
||||
res.msg = GlobalErrorCodeVars.Code15602;
|
||||
return res;
|
||||
}
|
||||
item.products.price = item.products.price - ruleModel.discountAmount;
|
||||
if (item.products.price < 0)
|
||||
{
|
||||
res.data = 15612;
|
||||
res.msg = GlobalErrorCodeVars.Code15612;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
res.status = true;
|
||||
res.data = list;
|
||||
return res;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 根据条件查询分页数据
|
||||
|
||||
/// <summary>
|
||||
/// 根据条件查询分页数据
|
||||
/// </summary>
|
||||
/// <param name="predicate">判断集合</param>
|
||||
/// <param name="orderByExpression"></param>
|
||||
/// <param name="orderByType">排序方式</param>
|
||||
/// <param name="pageIndex">当前页面索引</param>
|
||||
/// <param name="pageSize">分布大小</param>
|
||||
/// <returns></returns>
|
||||
public async Task<IPageList<TagPinTuanResult>> QueryTagPinTuanPageAsync(Expression<Func<TagPinTuanResult, bool>> predicate,
|
||||
Expression<Func<TagPinTuanResult, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1, int pageSize = 20)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
var page = await DbClient.Queryable<CoreCmsPinTuanGoods, CoreCmsPinTuanRule, CoreCmsGoods>((pgModel, prModel, goodModel) => new object[] {
|
||||
JoinType.Inner,pgModel.ruleId==prModel.id,
|
||||
JoinType.Inner,pgModel.goodsId==goodModel.id
|
||||
}).Select((pgModel, prModel, goodModel) => new TagPinTuanResult
|
||||
{
|
||||
id = prModel.id,
|
||||
name = prModel.name,
|
||||
startTime = prModel.startTime,
|
||||
endTime = prModel.endTime,
|
||||
peopleNumber = prModel.peopleNumber,
|
||||
significantInterval = prModel.significantInterval,
|
||||
discountAmount = prModel.discountAmount,
|
||||
maxNums = prModel.maxNums,
|
||||
maxGoodsNums = prModel.maxGoodsNums,
|
||||
sort = prModel.sort,
|
||||
isStatusOpen = prModel.isStatusOpen,
|
||||
createTime = prModel.createTime,
|
||||
updateTime = prModel.updateTime,
|
||||
goodsId = pgModel.goodsId,
|
||||
goodsName = goodModel.name,
|
||||
goodsImages = goodModel.images,
|
||||
goodsImage = goodModel.image,
|
||||
}).MergeTable()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.With(SqlWith.Null).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
|
||||
var list = new PageList<TagPinTuanResult>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 根据商品id获取拼团规则信息
|
||||
/// <summary>
|
||||
/// 根据商品id获取拼团规则信息
|
||||
/// </summary>
|
||||
/// <param name="goodId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<TagPinTuanResult> GetPinTuanInfo(int goodId)
|
||||
{
|
||||
var dt = DateTime.Now;
|
||||
var reuslt = await DbClient.Queryable<CoreCmsPinTuanGoods, CoreCmsPinTuanRule, CoreCmsGoods, CoreCmsProducts>(
|
||||
(pgModel, prModel, goodModel, productsModel) => new object[]
|
||||
{
|
||||
JoinType.Inner, pgModel.ruleId == prModel.id,
|
||||
JoinType.Inner, pgModel.goodsId == goodModel.id,
|
||||
JoinType.Left, goodModel.id == productsModel.goodsId
|
||||
})
|
||||
.Where((pgModel, prModel, goodModel, productsModel) => prModel.isStatusOpen == true && pgModel.goodsId == goodId && prModel.endTime > dt && productsModel.isDefalut == true && productsModel.isDel == false)
|
||||
.Select((pgModel, prModel, goodModel, productsModel) => new TagPinTuanResult
|
||||
{
|
||||
id = prModel.id,
|
||||
name = prModel.name,
|
||||
startTime = prModel.startTime,
|
||||
endTime = prModel.endTime,
|
||||
peopleNumber = prModel.peopleNumber,
|
||||
significantInterval = prModel.significantInterval,
|
||||
discountAmount = prModel.discountAmount,
|
||||
maxNums = prModel.maxNums,
|
||||
maxGoodsNums = prModel.maxGoodsNums,
|
||||
sort = prModel.sort,
|
||||
isStatusOpen = prModel.isStatusOpen,
|
||||
createTime = prModel.createTime,
|
||||
updateTime = prModel.updateTime,
|
||||
goodsId = pgModel.goodsId,
|
||||
goodsName = goodModel.name,
|
||||
goodsImages = goodModel.images,
|
||||
goodsPrice = productsModel.price,
|
||||
goodsImage = goodModel.image,
|
||||
|
||||
}).FirstAsync();
|
||||
return reuslt;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
435
CoreCms.Net.Repository/Promotion/CoreCmsCouponRepository.cs
Normal file
435
CoreCms.Net.Repository/Promotion/CoreCmsCouponRepository.cs
Normal file
@@ -0,0 +1,435 @@
|
||||
/***********************************************************************
|
||||
* 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.Configuration;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Loging;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.Model.ViewModels.DTO;
|
||||
using CoreCms.Net.Utility.Helper;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 优惠券码表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsCouponRepository : BaseRepository<CoreCmsCoupon>, ICoreCmsCouponRepository
|
||||
{
|
||||
|
||||
|
||||
public CoreCmsCouponRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#region 根据优惠券编码取优惠券的信息,并判断是否可用
|
||||
|
||||
/// <summary>
|
||||
/// 根据优惠券编码取优惠券的信息,并判断是否可用
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
/// <param name="check"></param>
|
||||
public async Task<WebApiCallBack> ToInfo(string[] code, bool check = false)
|
||||
{
|
||||
var jm = new WebApiCallBack();
|
||||
var outData = new List<CoreCmsPromotion>();
|
||||
|
||||
foreach (var codeStr in code)
|
||||
{
|
||||
var model =await DbClient.Queryable<CoreCmsCoupon, CoreCmsPromotion>((coupon, prommotion) => new object[]
|
||||
{
|
||||
JoinType.Inner, coupon.promotionId == prommotion.id
|
||||
}).Where((coupon, prommotion) => coupon.couponCode == codeStr)
|
||||
.Select((coupon, prommotion) => new
|
||||
{
|
||||
coupon,
|
||||
prommotion
|
||||
}).FirstAsync();
|
||||
;
|
||||
if (model != null)
|
||||
{
|
||||
if (check)
|
||||
{
|
||||
//判断规则是否开启
|
||||
if (model.prommotion.isEnable == false)
|
||||
{
|
||||
jm.data = 15012;
|
||||
jm.msg = GlobalErrorCodeVars.Code15012;
|
||||
return jm;
|
||||
}
|
||||
//判断优惠券规则是否到达开始时间
|
||||
var dt = DateTime.Now;
|
||||
if (model.coupon.startTime > dt)
|
||||
{
|
||||
jm.data = 15010;
|
||||
jm.msg = GlobalErrorCodeVars.Code15010;
|
||||
return jm;
|
||||
}
|
||||
//判断优惠券规则是否已经到结束时间了,也就是是否过期了
|
||||
if (model.coupon.endTime < dt)
|
||||
{
|
||||
jm.data = 15011;
|
||||
jm.msg = GlobalErrorCodeVars.Code15011;
|
||||
return jm;
|
||||
}
|
||||
//判断是否已经使用过了
|
||||
if (model.coupon.isUsed)
|
||||
{
|
||||
jm.data = 15013;
|
||||
jm.msg = GlobalErrorCodeVars.Code15013;
|
||||
return jm;
|
||||
}
|
||||
//判断此类优惠券是否已经使用过,防止一类优惠券使用多张
|
||||
if (outData.Exists(p => p.id == model.coupon.promotionId))
|
||||
{
|
||||
jm.data = 15015;
|
||||
jm.msg = GlobalErrorCodeVars.Code15015;
|
||||
return jm;
|
||||
}
|
||||
}
|
||||
outData.Add(model.prommotion);
|
||||
}
|
||||
else
|
||||
{
|
||||
jm.data = 15009;
|
||||
jm.msg = GlobalErrorCodeVars.Code15009;
|
||||
return jm;
|
||||
}
|
||||
}
|
||||
jm.status = true;
|
||||
jm.data = outData;
|
||||
return jm;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 获取 我的优惠券
|
||||
/// <summary>
|
||||
/// 获取 我的优惠券
|
||||
/// </summary>
|
||||
/// <param name="userId">用户序列</param>
|
||||
/// <param name="promotionId">促销序列</param>
|
||||
/// <param name="display">优惠券状态编码</param>
|
||||
/// <param name="page">页码</param>
|
||||
/// <param name="limit">数量</param>
|
||||
public async Task<WebApiCallBack> GetMyCoupon(int userId, int promotionId = 0, string display = "", int page = 1, int limit = 10)
|
||||
{
|
||||
var jm = new WebApiCallBack();
|
||||
jm.code = 0;
|
||||
|
||||
RefAsync<int> totalCount = 0;
|
||||
var dt = DateTime.Now;
|
||||
var listData = await DbClient.Queryable<CoreCmsCoupon, CoreCmsPromotion>((coupon, promotion) => new object[]
|
||||
{
|
||||
JoinType.Inner, coupon.promotionId == promotion.id
|
||||
})
|
||||
.Where((coupon, promotion) => coupon.userId == userId)
|
||||
.Where((coupon, promotion) => promotion.isDel == false)
|
||||
.Where((coupon, promotion) => promotion.type == (int)GlobalEnumVars.PromotionType.Coupon)
|
||||
.WhereIF(display == GlobalEnumVars.CouponIsUsedStatusText.noUsed.ToString(), (coupon, promotion) => coupon.isUsed == false && coupon.endTime >= dt)
|
||||
.WhereIF(display == GlobalEnumVars.CouponIsUsedStatusText.yesUsed.ToString(), (coupon, promotion) => coupon.isUsed == true)
|
||||
.WhereIF(display == GlobalEnumVars.CouponIsUsedStatusText.invalid.ToString(), (coupon, promotion) => coupon.endTime < dt)
|
||||
.WhereIF(promotionId > 0, (coupon, promotion) => coupon.promotionId == promotionId)
|
||||
.WhereIF(promotionId == 0, (coupon, promotion) => promotion.isEnable == true)
|
||||
.Select((coupon, promotion) => new CoreCmsCoupon
|
||||
{
|
||||
couponCode = coupon.couponCode,
|
||||
promotionId = coupon.promotionId,
|
||||
isUsed = coupon.isUsed,
|
||||
userId = coupon.userId,
|
||||
usedId = coupon.usedId,
|
||||
createTime = coupon.createTime,
|
||||
updateTime = coupon.updateTime,
|
||||
couponName = promotion.name,
|
||||
startTime = coupon.startTime,
|
||||
endTime = coupon.endTime,
|
||||
|
||||
}).MergeTable()
|
||||
.Mapper(p => p.conditions, p => p.promotionId)
|
||||
.Mapper(p => p.results, p => p.promotionId)
|
||||
.OrderBy(p => p.createTime, OrderByType.Desc)
|
||||
.With(SqlWith.Null)
|
||||
.ToPageListAsync(page, limit, totalCount);
|
||||
|
||||
var totalPages = totalCount.Value / limit;
|
||||
if (totalPages == 0) { totalPages++; }
|
||||
if (totalPages % limit > 0)
|
||||
totalPages++;
|
||||
|
||||
var resutlList = new List<GetMyCouponResultDto>();
|
||||
if (listData != null && listData.Any())
|
||||
{
|
||||
foreach (var item in listData)
|
||||
{
|
||||
//var pcondition = await DbClient.Queryable<CoreCmsPromotionCondition>().Where(p => p.promotionId == item.promotionId).ToListAsync();
|
||||
//var presult = await DbClient.Queryable<CoreCmsPromotionResult>().Where(p => p.promotionId == item.promotionId).ToListAsync();
|
||||
var expression1 = string.Empty;
|
||||
var expression2 = string.Empty;
|
||||
|
||||
var dto = new GetMyCouponResultDto();
|
||||
|
||||
foreach (var condition in item.conditions)
|
||||
{
|
||||
var str = PromotionHelper.GetConditionMsg(condition.code, condition.parameters);
|
||||
expression1 += str;
|
||||
dto.conditions.Add(str);
|
||||
}
|
||||
foreach (var result in item.results)
|
||||
{
|
||||
var str = PromotionHelper.GetResultMsg(result.code, result.parameters);
|
||||
expression2 += str;
|
||||
dto.results.Add(str);
|
||||
}
|
||||
|
||||
dto.couponCode = item.couponCode;
|
||||
dto.promotionId = item.promotionId;
|
||||
dto.isUsed = item.isUsed;
|
||||
dto.userId = item.userId;
|
||||
dto.usedId = item.usedId;
|
||||
dto.createTime = item.createTime;
|
||||
dto.updateTime = item.updateTime;
|
||||
dto.couponName = item.couponName;
|
||||
|
||||
dto.expression1 = expression1;
|
||||
dto.expression2 = expression2;
|
||||
|
||||
dto.isExpire = dt > item.endTime;
|
||||
dto.startTime = item.startTime;
|
||||
dto.endTime = item.endTime;
|
||||
dto.stime = item.startTime.ToString("yyyy-MM-dd");
|
||||
dto.etime = item.endTime.ToString("yyyy-MM-dd");
|
||||
|
||||
resutlList.Add(dto);
|
||||
}
|
||||
}
|
||||
jm.status = true;
|
||||
jm.msg = "获取成功";
|
||||
jm.data = new
|
||||
{
|
||||
list = resutlList,
|
||||
count = totalCount.Value,
|
||||
display,
|
||||
page = totalPages
|
||||
};
|
||||
jm.code = totalCount.Value;
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 根据条件查询分页数据及导航数据
|
||||
|
||||
/// <summary>
|
||||
/// 根据条件查询分页数据及导航数据
|
||||
/// </summary>
|
||||
/// <param name="predicate">判断集合</param>
|
||||
/// <param name="orderByType">排序方式</param>
|
||||
/// <param name="isToPage">是否分页</param>
|
||||
/// <param name="pageIndex">当前页面索引</param>
|
||||
/// <param name="pageSize">分布大小</param>
|
||||
/// <param name="orderByExpression"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IPageList<CoreCmsCoupon>> QueryPageMapperAsync(Expression<Func<CoreCmsCoupon, bool>> predicate,
|
||||
Expression<Func<CoreCmsCoupon, object>> orderByExpression, OrderByType orderByType, bool isToPage = false, int pageIndex = 1,
|
||||
int pageSize = 20)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsCoupon> page;
|
||||
if (isToPage)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsCoupon>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsCoupon
|
||||
{
|
||||
id = p.id,
|
||||
couponCode = p.couponCode,
|
||||
promotionId = p.promotionId,
|
||||
isUsed = p.isUsed,
|
||||
userId = p.userId,
|
||||
usedId = p.usedId,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
startTime = p.startTime,
|
||||
endTime = p.endTime,
|
||||
})
|
||||
.Mapper(p => p.promotion, p => p.promotionId)
|
||||
.Mapper(p => p.conditions, p => p.conditions.First().promotionId)
|
||||
.Mapper(p => p.results, p => p.results.First().promotionId)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsCoupon>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.Take(pageSize)
|
||||
.Select(p => new CoreCmsCoupon
|
||||
{
|
||||
id = p.id,
|
||||
couponCode = p.couponCode,
|
||||
promotionId = p.promotionId,
|
||||
isUsed = p.isUsed,
|
||||
userId = p.userId,
|
||||
usedId = p.usedId,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
startTime = p.startTime,
|
||||
endTime = p.endTime,
|
||||
})
|
||||
.Mapper(p => p.promotion, p => p.promotionId)
|
||||
.Mapper(p => p.conditions, p => p.conditions.First().promotionId)
|
||||
.Mapper(p => p.results, p => p.results.First().promotionId)
|
||||
.ToListAsync();
|
||||
}
|
||||
var list = new PageList<CoreCmsCoupon>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 重写数据并获取相关
|
||||
/// <summary>
|
||||
/// 重写数据并获取相关
|
||||
/// </summary>
|
||||
/// <param name="predicate">判断集合</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<CoreCmsCoupon>> QueryWithAboutAsync(Expression<Func<CoreCmsCoupon, bool>> predicate)
|
||||
{
|
||||
var page = await DbClient.Queryable<CoreCmsCoupon, CoreCmsUser, CoreCmsPromotion>((p, sUser, sPromotion) => new JoinQueryInfos(
|
||||
JoinType.Left, p.userId == sUser.id,
|
||||
JoinType.Left, p.promotionId == sPromotion.id))
|
||||
.Select((p, sUser, sPromotion) => new CoreCmsCoupon
|
||||
{
|
||||
id = p.id,
|
||||
couponCode = p.couponCode,
|
||||
promotionId = p.promotionId,
|
||||
isUsed = p.isUsed,
|
||||
userId = p.userId,
|
||||
usedId = p.usedId,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
userNickName = sUser.nickName,
|
||||
couponName = sPromotion.name,
|
||||
startTime = p.startTime,
|
||||
endTime = p.endTime,
|
||||
})
|
||||
.MergeTable()
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.ToListAsync();
|
||||
return page;
|
||||
}
|
||||
|
||||
#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<CoreCmsCoupon>> QueryPageAsync(Expression<Func<CoreCmsCoupon, bool>> predicate,
|
||||
Expression<Func<CoreCmsCoupon, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
var page = blUseNoLock
|
||||
? await DbClient.Queryable<CoreCmsCoupon, CoreCmsUser, CoreCmsPromotion>((p, sUser, sPromotion) => new JoinQueryInfos(
|
||||
JoinType.Left, p.userId == sUser.id,
|
||||
JoinType.Left, p.promotionId == sPromotion.id))
|
||||
.Select((p, sUser, sPromotion) => new CoreCmsCoupon
|
||||
{
|
||||
id = p.id,
|
||||
couponCode = p.couponCode,
|
||||
promotionId = p.promotionId,
|
||||
isUsed = p.isUsed,
|
||||
userId = p.userId,
|
||||
usedId = p.usedId,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
userNickName = sUser.nickName,
|
||||
couponName = sPromotion.name,
|
||||
startTime = p.startTime,
|
||||
endTime = p.endTime,
|
||||
})
|
||||
.MergeTable()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount)
|
||||
:
|
||||
await DbClient.Queryable<CoreCmsCoupon, CoreCmsUser, CoreCmsPromotion>((p, sUser, sPromotion) => new JoinQueryInfos(
|
||||
JoinType.Left, p.userId == sUser.id,
|
||||
JoinType.Left, p.promotionId == sPromotion.id))
|
||||
.Select((p, sUser, sPromotion) => new CoreCmsCoupon
|
||||
{
|
||||
id = p.id,
|
||||
couponCode = p.couponCode,
|
||||
promotionId = p.promotionId,
|
||||
isUsed = p.isUsed,
|
||||
userId = p.userId,
|
||||
usedId = p.usedId,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
userNickName = sUser.nickName,
|
||||
couponName = sPromotion.name,
|
||||
startTime = p.startTime,
|
||||
endTime = p.endTime,
|
||||
})
|
||||
.MergeTable()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
var list = new PageList<CoreCmsCoupon>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 获取 我的优惠券可用数量
|
||||
/// <summary>
|
||||
/// 获取 我的优惠券可用数量
|
||||
/// </summary>
|
||||
/// <param name="userId">用户序列</param>
|
||||
public async Task<int> GetMyCouponCount(int userId)
|
||||
{
|
||||
var jm = new WebApiCallBack();
|
||||
jm.code = 0;
|
||||
|
||||
var dt = DateTime.Now;
|
||||
var count = await DbClient.Queryable<CoreCmsCoupon, CoreCmsPromotion>((coupon, promotion) => new object[]
|
||||
{
|
||||
JoinType.Inner, coupon.promotionId == promotion.id
|
||||
})
|
||||
.Where((coupon, promotion) => coupon.userId == userId)
|
||||
.Where((coupon, promotion) => promotion.isDel == false)
|
||||
.Where((coupon, promotion) => coupon.isUsed == false)
|
||||
.Where((coupon, promotion) => promotion.type == (int)GlobalEnumVars.PromotionType.Coupon)
|
||||
.Where((coupon, promotion) => coupon.endTime > dt)
|
||||
.CountAsync();
|
||||
return count;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/***********************************************************************
|
||||
* 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.Linq;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.DTO;
|
||||
using CoreCms.Net.Utility.Helper;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 促销条件表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsPromotionConditionRepository : BaseRepository<CoreCmsPromotionCondition>, ICoreCmsPromotionConditionRepository
|
||||
{
|
||||
|
||||
public CoreCmsPromotionConditionRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/***********************************************************************
|
||||
* 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 CoreCmsPromotionRecordRepository : BaseRepository<CoreCmsPromotionRecord>, ICoreCmsPromotionRecordRepository
|
||||
{
|
||||
public CoreCmsPromotionRecordRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
157
CoreCms.Net.Repository/Promotion/CoreCmsPromotionRepository.cs
Normal file
157
CoreCms.Net.Repository/Promotion/CoreCmsPromotionRepository.cs
Normal file
@@ -0,0 +1,157 @@
|
||||
/***********************************************************************
|
||||
* 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.Configuration;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Utility.Extensions;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 促销表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsPromotionRepository : BaseRepository<CoreCmsPromotion>, ICoreCmsPromotionRepository
|
||||
{
|
||||
public CoreCmsPromotionRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//判断商品是否参加团购
|
||||
/// <summary>
|
||||
/// 判断商品是否参加团购
|
||||
/// </summary>
|
||||
/// <param name="goodId">商品序列</param>
|
||||
/// <param name="promotionId">关联促销信息</param>
|
||||
/// <returns></returns>
|
||||
public bool IsInGroup(int goodId, out int promotionId)
|
||||
{
|
||||
promotionId = 0;
|
||||
if (goodId == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var dt = DateTime.Now;
|
||||
var goodIds = "\"" + goodId + "\"";
|
||||
|
||||
var model = DbClient.Queryable<CoreCmsPromotion, CoreCmsPromotionCondition>(
|
||||
(pro, ccpc) => new object[] {
|
||||
JoinType.Inner, pro.id == ccpc.promotionId
|
||||
}
|
||||
)
|
||||
.Where((pro, ccpc) => pro.isEnable == true && pro.isDel == false)
|
||||
//.Where((pro, ccpc) => pro.startTime < dt && pro.endTime > dt)
|
||||
//.Where((pro, ccpc) => ccpc.parameters.Contains("%\"" + goodId + "\"%"))
|
||||
.Where((pro, ccpc) => ccpc.parameters.Contains(goodIds))
|
||||
.Where((pro, ccpc) => pro.type == (int)GlobalEnumVars.PromotionType.Group ||
|
||||
pro.type == (int)GlobalEnumVars.PromotionType.Seckill)
|
||||
.Select((pro, ccpc) => ccpc)
|
||||
.First();
|
||||
|
||||
if (model != null)
|
||||
{
|
||||
promotionId = model.promotionId.ObjectToInt();
|
||||
}
|
||||
return model != null;
|
||||
}
|
||||
|
||||
|
||||
#region 查询查了并获取导航下级数据
|
||||
|
||||
/// <summary>
|
||||
/// 查询查了并获取导航下级数据
|
||||
/// </summary>
|
||||
/// <param name="predicate">判断集合</param>
|
||||
/// <param name="orderByType">排序方式</param>
|
||||
/// <param name="isToPage">是否分页</param>
|
||||
/// <param name="pageIndex">当前页面索引</param>
|
||||
/// <param name="pageSize">分布大小</param>
|
||||
/// <param name="orderByExpression"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IPageList<CoreCmsPromotion>> QueryPageAndChildsAsync(Expression<Func<CoreCmsPromotion, bool>> predicate,
|
||||
Expression<Func<CoreCmsPromotion, object>> orderByExpression, OrderByType orderByType, bool isToPage = false, int pageIndex = 1,
|
||||
int pageSize = 20)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsPromotion> page;
|
||||
if (isToPage)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsPromotion>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsPromotion
|
||||
{
|
||||
id = p.id,
|
||||
name = p.name,
|
||||
type = p.type,
|
||||
sort = p.sort,
|
||||
parameters = p.parameters,
|
||||
maxNums = p.maxNums,
|
||||
maxGoodsNums = p.maxGoodsNums,
|
||||
maxRecevieNums = p.maxRecevieNums,
|
||||
startTime = p.startTime,
|
||||
endTime = p.endTime,
|
||||
isExclusive = p.isExclusive,
|
||||
isAutoReceive = p.isAutoReceive,
|
||||
isEnable = p.isEnable,
|
||||
isDel = p.isDel,
|
||||
getNumber = SqlFunc.Subqueryable<CoreCmsCoupon>().Where(o => o.promotionId == p.id).Count()
|
||||
})
|
||||
.Mapper(p => p.promotionCondition, p => p.promotionCondition.First().promotionId)
|
||||
.Mapper(p => p.promotionResult, p => p.promotionResult.First().promotionId)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsPromotion>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.Take(pageSize)
|
||||
.Select(p => new CoreCmsPromotion
|
||||
{
|
||||
id = p.id,
|
||||
name = p.name,
|
||||
type = p.type,
|
||||
sort = p.sort,
|
||||
parameters = p.parameters,
|
||||
maxNums = p.maxNums,
|
||||
maxGoodsNums = p.maxGoodsNums,
|
||||
maxRecevieNums = p.maxRecevieNums,
|
||||
startTime = p.startTime,
|
||||
endTime = p.endTime,
|
||||
isExclusive = p.isExclusive,
|
||||
isAutoReceive = p.isAutoReceive,
|
||||
isEnable = p.isEnable,
|
||||
isDel = p.isDel,
|
||||
getNumber = SqlFunc.Subqueryable<CoreCmsCoupon>().Where(o => o.promotionId == p.id).Count()
|
||||
})
|
||||
.Mapper(p => p.promotionCondition, p => p.promotionCondition.First().promotionId)
|
||||
.Mapper(p => p.promotionResult, p => p.promotionResult.First().promotionId)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
var list = new PageList<CoreCmsPromotion>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.DTO;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 促销结果表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsPromotionResultRepository : BaseRepository<CoreCmsPromotionResult>, ICoreCmsPromotionResultRepository
|
||||
{
|
||||
public CoreCmsPromotionResultRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
73
CoreCms.Net.Repository/Service/CoreCmsServicesRepository.cs
Normal file
73
CoreCms.Net.Repository/Service/CoreCmsServicesRepository.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
/***********************************************************************
|
||||
* 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.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 服务项目表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsServicesRepository : BaseRepository<CoreCmsServices>, ICoreCmsServicesRepository
|
||||
{
|
||||
public CoreCmsServicesRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据条件查询分页数据
|
||||
/// </summary>
|
||||
/// <param name="predicate">判断集合</param>
|
||||
/// <param name="orderByType">排序方式</param>
|
||||
/// <param name="pageIndex">当前页面索引</param>
|
||||
/// <param name="pageSize">分布大小</param>
|
||||
/// <param name="orderByExpression"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IPageList<CoreCmsServices>> TagQueryPageAsync(
|
||||
Expression<Func<CoreCmsServices, bool>> predicate,
|
||||
Expression<Func<CoreCmsServices, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
var page = await DbClient.Queryable<CoreCmsServices>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsServices
|
||||
{
|
||||
id = p.id,
|
||||
title = p.title,
|
||||
thumbnail = p.thumbnail,
|
||||
description = p.description,
|
||||
allowedMembership = p.allowedMembership,
|
||||
status = p.status,
|
||||
maxBuyNumber = p.maxBuyNumber,
|
||||
amount = p.amount,
|
||||
startTime = p.startTime,
|
||||
endTime = p.endTime,
|
||||
validityType = p.validityType,
|
||||
validityStartTime = p.validityStartTime,
|
||||
validityEndTime = p.validityEndTime,
|
||||
ticketNumber = p.ticketNumber,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
money = p.money
|
||||
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
var list = new PageList<CoreCmsServices>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 服务购买表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsUserServicesOrderRepository : BaseRepository<CoreCmsUserServicesOrder>,
|
||||
ICoreCmsUserServicesOrderRepository
|
||||
{
|
||||
public CoreCmsUserServicesOrderRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 服务消费券 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsUserServicesTicketRepository : BaseRepository<CoreCmsUserServicesTicket>,
|
||||
ICoreCmsUserServicesTicketRepository
|
||||
{
|
||||
public CoreCmsUserServicesTicketRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 服务券核验日志 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsUserServicesTicketVerificationLogRepository :
|
||||
BaseRepository<CoreCmsUserServicesTicketVerificationLog>, ICoreCmsUserServicesTicketVerificationLogRepository
|
||||
{
|
||||
public CoreCmsUserServicesTicketVerificationLogRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
185
CoreCms.Net.Repository/Shop/CoreCmsAreaRepository.cs
Normal file
185
CoreCms.Net.Repository/Shop/CoreCmsAreaRepository.cs
Normal file
@@ -0,0 +1,185 @@
|
||||
/***********************************************************************
|
||||
* 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 CoreCmsAreaRepository : BaseRepository<CoreCmsArea>, ICoreCmsAreaRepository
|
||||
{
|
||||
public CoreCmsAreaRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
#region 实现重写增删改查操作==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> InsertAsync(CoreCmsArea 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;
|
||||
if (bl)
|
||||
{
|
||||
await UpdateCaChe();
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> UpdateAsync(CoreCmsArea entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var oldModel = await DbClient.Queryable<CoreCmsArea>().In(entity.id).SingleAsync();
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
//事物处理过程开始
|
||||
//oldModel.id = entity.id;
|
||||
//oldModel.parentId = entity.parentId;
|
||||
//oldModel.depth = entity.depth;
|
||||
oldModel.name = entity.name;
|
||||
oldModel.postalCode = entity.postalCode;
|
||||
oldModel.sort = entity.sort;
|
||||
|
||||
//事物处理过程结束
|
||||
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<CoreCmsArea> 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<CoreCmsArea>(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<CoreCmsArea>().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<CoreCmsArea>> GetCaChe()
|
||||
{
|
||||
var cache = ManualDataCache.Instance.Get<List<CoreCmsArea>>(GlobalConstVars.CacheCoreCmsArea);
|
||||
if (cache != null)
|
||||
{
|
||||
return cache;
|
||||
}
|
||||
return await UpdateCaChe();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新cache
|
||||
/// </summary>
|
||||
public async Task<List<CoreCmsArea>> UpdateCaChe()
|
||||
{
|
||||
|
||||
var list = await DbClient.Queryable<CoreCmsArea>().OrderBy(p=>p.sort).With(SqlWith.NoLock).ToListAsync();
|
||||
ManualDataCache.Instance.Set(GlobalConstVars.CacheCoreCmsArea, list);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
170
CoreCms.Net.Repository/Shop/CoreCmsClerkRepository.cs
Normal file
170
CoreCms.Net.Repository/Shop/CoreCmsClerkRepository.cs
Normal file
@@ -0,0 +1,170 @@
|
||||
/***********************************************************************
|
||||
* 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.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.Utility.Extensions;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 店铺店员关联表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsClerkRepository : BaseRepository<CoreCmsClerk>, ICoreCmsClerkRepository
|
||||
{
|
||||
public CoreCmsClerkRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
#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<StoreClerkDto>> QueryStoreClerkDtoPageAsync(Expression<Func<StoreClerkDto, bool>> predicate,
|
||||
Expression<Func<StoreClerkDto, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<StoreClerkDto> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsClerk, CoreCmsStore, CoreCmsUser>((p, sst, ccu) => new JoinQueryInfos(
|
||||
JoinType.Left, p.storeId == sst.id,
|
||||
JoinType.Left, p.userId == ccu.id
|
||||
))
|
||||
.Select((p, sst, ccu) => new StoreClerkDto
|
||||
{
|
||||
id = p.id,
|
||||
storeId = p.storeId,
|
||||
userId = p.userId,
|
||||
isDel = p.isDel,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
storeName = sst.storeName,
|
||||
nickName = ccu.nickName,
|
||||
mobile = ccu.mobile,
|
||||
avatarImage = ccu.avatarImage,
|
||||
}).With(SqlWith.NoLock)
|
||||
.MergeTable()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsClerk, CoreCmsStore, CoreCmsUser>((p, sst, ccu) => new JoinQueryInfos(
|
||||
JoinType.Left, p.storeId == sst.id,
|
||||
JoinType.Left, p.userId == ccu.id
|
||||
))
|
||||
.Select((p, sst, ccu) => new StoreClerkDto
|
||||
{
|
||||
id = p.id,
|
||||
storeId = p.storeId,
|
||||
userId = p.userId,
|
||||
isDel = p.isDel,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
storeName = sst.storeName,
|
||||
nickName = ccu.nickName,
|
||||
mobile = ccu.mobile,
|
||||
avatarImage = ccu.avatarImage,
|
||||
})
|
||||
.MergeTable()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<StoreClerkDto>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 获取单个门店用户数据
|
||||
/// <summary>
|
||||
/// 获取单个门店用户数据
|
||||
/// </summary>
|
||||
/// <param name="predicate">判断集合</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<StoreClerkDto> QueryStoreClerkDtoByClauseAsync(Expression<Func<StoreClerkDto, bool>> predicate, bool blUseNoLock = false)
|
||||
{
|
||||
StoreClerkDto obj;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
obj = await DbClient.Queryable<CoreCmsClerk, CoreCmsStore, CoreCmsUser>((p, sst, ccu) => new JoinQueryInfos(
|
||||
JoinType.Left, p.storeId == sst.id,
|
||||
JoinType.Left, p.userId == ccu.id
|
||||
))
|
||||
.Select((p, sst, ccu) => new StoreClerkDto
|
||||
{
|
||||
id = p.id,
|
||||
storeId = p.storeId,
|
||||
userId = p.userId,
|
||||
isDel = p.isDel,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
storeName = sst.storeName,
|
||||
nickName = ccu.nickName,
|
||||
mobile = ccu.mobile,
|
||||
avatarImage = ccu.avatarImage,
|
||||
}).With(SqlWith.NoLock)
|
||||
.MergeTable()
|
||||
.FirstAsync(predicate);
|
||||
}
|
||||
else
|
||||
{
|
||||
obj = await DbClient.Queryable<CoreCmsClerk, CoreCmsStore, CoreCmsUser>((p, sst, ccu) => new JoinQueryInfos(
|
||||
JoinType.Left, p.storeId == sst.id,
|
||||
JoinType.Left, p.userId == ccu.id
|
||||
))
|
||||
.Select((p, sst, ccu) => new StoreClerkDto
|
||||
{
|
||||
id = p.id,
|
||||
storeId = p.storeId,
|
||||
userId = p.userId,
|
||||
isDel = p.isDel,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
storeName = sst.storeName,
|
||||
nickName = ccu.nickName,
|
||||
mobile = ccu.mobile,
|
||||
avatarImage = ccu.avatarImage,
|
||||
})
|
||||
.MergeTable()
|
||||
.FirstAsync(predicate);
|
||||
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
31
CoreCms.Net.Repository/Shop/CoreCmsLogisticsRepository.cs
Normal file
31
CoreCms.Net.Repository/Shop/CoreCmsLogisticsRepository.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
/***********************************************************************
|
||||
* 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.Threading.Tasks;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 物流公司表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsLogisticsRepository : BaseRepository<CoreCmsLogistics>, ICoreCmsLogisticsRepository
|
||||
{
|
||||
public CoreCmsLogisticsRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
92
CoreCms.Net.Repository/Shop/CoreCmsNoticeRepository.cs
Normal file
92
CoreCms.Net.Repository/Shop/CoreCmsNoticeRepository.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
/***********************************************************************
|
||||
* 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.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 公告表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsNoticeRepository : BaseRepository<CoreCmsNotice>, ICoreCmsNoticeRepository
|
||||
{
|
||||
public CoreCmsNoticeRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写根据条件查询分页数据
|
||||
/// </summary>
|
||||
/// <param name="predicate">判断集合</param>
|
||||
/// <param name="orderByType">排序方式</param>
|
||||
/// <param name="pageIndex">当前页面索引</param>
|
||||
/// <param name="pageSize">分布大小</param>
|
||||
/// <param name="orderByExpression"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IPageList<CoreCmsNotice>> QueryPageAsync(Expression<Func<CoreCmsNotice, bool>> predicate,
|
||||
Expression<Func<CoreCmsNotice, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
var page = await DbClient.Queryable<CoreCmsNotice>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsNotice
|
||||
{
|
||||
id = p.id,
|
||||
title = p.title,
|
||||
type = p.type,
|
||||
sort = p.sort,
|
||||
isDel = p.isDel,
|
||||
createTime = p.createTime
|
||||
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
var list = new PageList<CoreCmsNotice>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取列表首页用
|
||||
/// </summary>
|
||||
/// <param name="predicate">判断集合</param>
|
||||
/// <param name="orderByType">排序方式</param>
|
||||
/// <param name="pageIndex">当前页面索引</param>
|
||||
/// <param name="pageSize">分布大小</param>
|
||||
/// <param name="orderByExpression"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<CoreCmsNotice>> QueryListAsync(Expression<Func<CoreCmsNotice, bool>> predicate,
|
||||
Expression<Func<CoreCmsNotice, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20)
|
||||
{
|
||||
var list = await DbClient.Queryable<CoreCmsNotice>().OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsNotice
|
||||
{
|
||||
id = p.id,
|
||||
title = p.title,
|
||||
type = p.type,
|
||||
sort = p.sort,
|
||||
isDel = p.isDel,
|
||||
createTime = p.createTime
|
||||
}).ToPageListAsync(pageIndex, pageSize);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
26
CoreCms.Net.Repository/Shop/CoreCmsPagesItemsRepository.cs
Normal file
26
CoreCms.Net.Repository/Shop/CoreCmsPagesItemsRepository.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 单页内容 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsPagesItemsRepository : BaseRepository<CoreCmsPagesItems>, ICoreCmsPagesItemsRepository
|
||||
{
|
||||
public CoreCmsPagesItemsRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
264
CoreCms.Net.Repository/Shop/CoreCmsPagesRepository.cs
Normal file
264
CoreCms.Net.Repository/Shop/CoreCmsPagesRepository.cs
Normal file
@@ -0,0 +1,264 @@
|
||||
/***********************************************************************
|
||||
* 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.Threading.Tasks;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Loging;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.FromBody;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.Utility.Extensions;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 单页 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsPagesRepository : BaseRepository<CoreCmsPages>, ICoreCmsPagesRepository
|
||||
{
|
||||
public CoreCmsPagesRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> InsertAsync(CoreCmsPages entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var have = await DbClient.Queryable<CoreCmsPages>().Where(p => p.code == entity.code).With(SqlWith.NoLock).AnyAsync();
|
||||
if (have)
|
||||
{
|
||||
jm.msg = "存在相同【区域编码】请更正";
|
||||
return jm;
|
||||
}
|
||||
|
||||
entity.code = entity.code.Trim();
|
||||
|
||||
var id = await DbClient.Insertable(entity).ExecuteReturnIdentityAsync();
|
||||
var bl = id > 0;
|
||||
|
||||
if (bl && entity.type == 1)
|
||||
{
|
||||
//如果设为新默认,则修改其他为非默认。
|
||||
await DbClient.Updateable<CoreCmsPages>().Where(p => p.type == 1 && p.id != id).SetColumns(p => new CoreCmsPages() { type = 2 }).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
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(CoreCmsPages entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var have = await DbClient.Queryable<CoreCmsPages>().Where(p => p.code == entity.code && p.id != entity.id).With(SqlWith.NoLock).AnyAsync();
|
||||
if (have)
|
||||
{
|
||||
jm.msg = "存在相同【区域编码】请更正";
|
||||
return jm;
|
||||
}
|
||||
var oldModel = await DbClient.Queryable<CoreCmsPages>().In(entity.id).SingleAsync();
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
//事物处理过程开始
|
||||
var oldType = oldModel.type;
|
||||
var newType = entity.type;
|
||||
|
||||
oldModel.code = entity.code;
|
||||
oldModel.name = entity.name;
|
||||
oldModel.description = entity.description;
|
||||
oldModel.layout = entity.layout;
|
||||
oldModel.type = entity.type;
|
||||
|
||||
//事物处理过程结束
|
||||
var bl = await DbClient.Updateable(oldModel).ExecuteCommandHasChangeAsync();
|
||||
|
||||
if (bl)
|
||||
{
|
||||
//如果不是默认的情况下
|
||||
if (oldType == 1 && newType != 1)
|
||||
{
|
||||
//判断修改当前,而是否其他有默认
|
||||
var haveDefault = await DbClient.Queryable<CoreCmsPages>().Where(p => p.type == 1 && p.id != oldModel.id).With(SqlWith.NoLock).AnyAsync();
|
||||
//如果不存在,则当前不能调整为非默认。
|
||||
if (!haveDefault)
|
||||
{
|
||||
await DbClient.Updateable<CoreCmsPages>().Where(p => p.id == oldModel.id).SetColumns(p => new CoreCmsPages() { type = 1 }).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
//如果设为新默认,则修改其他为非默认。
|
||||
if (newType == 1)
|
||||
{
|
||||
await DbClient.Updateable<CoreCmsPages>().Where(p => p.id != oldModel.id).SetColumns(p => new CoreCmsPages() { type = 2 }).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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(int id)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await DbClient.Queryable<CoreCmsPages>().Where(p => p.id == id).FirstAsync();
|
||||
if (model == null)
|
||||
{
|
||||
jm.msg = GlobalConstVars.DataisNo;
|
||||
return jm;
|
||||
}
|
||||
if (model.type == 1)
|
||||
{
|
||||
jm.msg = "默认页面禁止删除";
|
||||
return jm;
|
||||
}
|
||||
|
||||
var count = await DbClient.Queryable<CoreCmsPages>().CountAsync();
|
||||
if (count == 1)
|
||||
{
|
||||
jm.msg = "只有一个页面了,别删了。";
|
||||
return jm;
|
||||
}
|
||||
|
||||
var bl = await DbClient.Deleteable<CoreCmsPages>(id).ExecuteCommandHasChangeAsync();
|
||||
if (bl)
|
||||
{
|
||||
await DbClient.Deleteable<CoreCmsPagesItems>().Where(p => p.pageCode == model.code).ExecuteCommandAsync();
|
||||
}
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 复制一个同样的数据
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<AdminUiCallBack> CopyByIdAsync(int id)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await DbClient.Queryable<CoreCmsPages>().Where(p => p.id == id).FirstAsync();
|
||||
if (model == null)
|
||||
{
|
||||
jm.msg = GlobalConstVars.DataisNo;
|
||||
return jm;
|
||||
}
|
||||
var oldCode = model.code;
|
||||
model.type = 2;
|
||||
model.code = model.code + DateTime.Now.ToString("yyyyMMddHHmmssfffff");
|
||||
model.name = model.name + "(复制)";
|
||||
|
||||
var items = await DbClient.Queryable<CoreCmsPagesItems>().Where(p => p.pageCode == oldCode).ToListAsync();
|
||||
foreach (var item in items)
|
||||
{
|
||||
item.pageCode = model.code;
|
||||
}
|
||||
|
||||
var bl = await DbClient.Insertable<CoreCmsPages>(model).ExecuteReturnIdentityAsync() > 0;
|
||||
if (bl)
|
||||
{
|
||||
await DbClient.Insertable<CoreCmsPagesItems>(items).ExecuteCommandAsync();
|
||||
}
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region 更新设计==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 更新设计
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<AdminUiCallBack> UpdateDesignAsync(FmPagesUpdate entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var bl = false;
|
||||
|
||||
var oldModel = await DbClient.Queryable<CoreCmsPages>().Where(p => p.code == entity.pageCode).SingleAsync();
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
//事物处理过程开始
|
||||
|
||||
bl = await DbClient.Deleteable<CoreCmsPagesItems>().Where(p => p.pageCode == entity.pageCode).ExecuteCommandHasChangeAsync();
|
||||
var list = new List<CoreCmsPagesItems>();
|
||||
var count = 0;
|
||||
entity.datalist.ForEach(p =>
|
||||
{
|
||||
var model = new CoreCmsPagesItems
|
||||
{
|
||||
widgetCode = p.sType,
|
||||
pageCode = entity.pageCode,
|
||||
positionId = count,
|
||||
sort = count + 1,
|
||||
parameters = p.sValue
|
||||
};
|
||||
list.Add(model);
|
||||
count++;
|
||||
});
|
||||
|
||||
if (list.Any())
|
||||
{
|
||||
bl = await DbClient.Insertable(list).ExecuteCommandAsync() > 0;
|
||||
}
|
||||
//事物处理过程结束
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
|
||||
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
/***********************************************************************
|
||||
* 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 CoreCmsServiceDescriptionRepository : BaseRepository<CoreCmsServiceDescription>, ICoreCmsServiceDescriptionRepository
|
||||
{
|
||||
public CoreCmsServiceDescriptionRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
#region 实现重写增删改查操作==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> InsertAsync(CoreCmsServiceDescription 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;
|
||||
if (bl)
|
||||
{
|
||||
await UpdateCaChe();
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> UpdateAsync(CoreCmsServiceDescription entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var oldModel = await DbClient.Queryable<CoreCmsServiceDescription>().In(entity.id).SingleAsync();
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
//事物处理过程开始
|
||||
oldModel.id = entity.id;
|
||||
oldModel.title = entity.title;
|
||||
oldModel.type = entity.type;
|
||||
oldModel.description = entity.description;
|
||||
oldModel.isShow = entity.isShow;
|
||||
oldModel.sortId = entity.sortId;
|
||||
|
||||
//事物处理过程结束
|
||||
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<CoreCmsServiceDescription> 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<CoreCmsServiceDescription>(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<CoreCmsServiceDescription>().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<CoreCmsServiceDescription>> GetCaChe()
|
||||
{
|
||||
var cache = ManualDataCache.Instance.Get<List<CoreCmsServiceDescription>>(GlobalConstVars.CacheCoreCmsServiceDescription);
|
||||
if (cache != null)
|
||||
{
|
||||
return cache;
|
||||
}
|
||||
return await UpdateCaChe();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新cache
|
||||
/// </summary>
|
||||
public async Task<List<CoreCmsServiceDescription>> UpdateCaChe()
|
||||
{
|
||||
var list = await DbClient.Queryable<CoreCmsServiceDescription>().With(SqlWith.NoLock).ToListAsync();
|
||||
ManualDataCache.Instance.Set(GlobalConstVars.CacheCoreCmsServiceDescription, 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<CoreCmsServiceDescription>> QueryPageAsync(Expression<Func<CoreCmsServiceDescription, bool>> predicate,
|
||||
Expression<Func<CoreCmsServiceDescription, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsServiceDescription> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsServiceDescription>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsServiceDescription
|
||||
{
|
||||
id = p.id,
|
||||
title = p.title,
|
||||
type = p.type,
|
||||
description = p.description,
|
||||
isShow = p.isShow,
|
||||
sortId = p.sortId,
|
||||
|
||||
}).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsServiceDescription>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsServiceDescription
|
||||
{
|
||||
id = p.id,
|
||||
title = p.title,
|
||||
type = p.type,
|
||||
description = p.description,
|
||||
isShow = p.isShow,
|
||||
sortId = p.sortId,
|
||||
|
||||
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsServiceDescription>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
40
CoreCms.Net.Repository/Shop/CoreCmsSettingRepository.cs
Normal file
40
CoreCms.Net.Repository/Shop/CoreCmsSettingRepository.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
/***********************************************************************
|
||||
* 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.Threading.Tasks;
|
||||
using CoreCms.Net.Caching;
|
||||
using CoreCms.Net.Caching.Manual;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.FromBody;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 店铺设置表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsSettingRepository : BaseRepository<CoreCmsSetting>, ICoreCmsSettingRepository
|
||||
{
|
||||
public CoreCmsSettingRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
276
CoreCms.Net.Repository/Shop/CoreCmsShipRepository.cs
Normal file
276
CoreCms.Net.Repository/Shop/CoreCmsShipRepository.cs
Normal file
@@ -0,0 +1,276 @@
|
||||
/***********************************************************************
|
||||
* 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.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Loging;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.Utility.Extensions;
|
||||
using CoreCms.Net.Utility.Helper;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 配送方式表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsShipRepository : BaseRepository<CoreCmsShip>, ICoreCmsShipRepository
|
||||
{
|
||||
public CoreCmsShipRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#region 实现重写增删改查操作==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> InsertAsync(CoreCmsShip entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var logistics = await DbClient.Queryable<CoreCmsLogistics>().FirstAsync(p => p.logiCode == entity.logiCode);
|
||||
if (logistics != null)
|
||||
{
|
||||
entity.logiName = logistics.logiName;
|
||||
}
|
||||
var id = await DbClient.Insertable(entity).ExecuteReturnIdentityAsync();
|
||||
var bl = id > 0;
|
||||
|
||||
if (bl && entity.isDefault == true)
|
||||
{
|
||||
await DbClient.Updateable<CoreCmsShip>().SetColumns(p => p.isDefault == false).Where(p => p.isDefault == true && p.id != id).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
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(CoreCmsShip entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
if (entity.isDefault == false)
|
||||
{
|
||||
var otherHave = await DbClient.Queryable<CoreCmsShip>().AnyAsync(p => p.isDefault == true && p.id != entity.id);
|
||||
if (otherHave == false)
|
||||
{
|
||||
jm.msg = "请保持一个默认配送方式";
|
||||
return jm;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
var oldModel = await DbClient.Queryable<CoreCmsShip>().In(entity.id).SingleAsync();
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
|
||||
//事物处理过程开始
|
||||
//oldModel.id = entity.id;
|
||||
oldModel.name = entity.name;
|
||||
oldModel.isCashOnDelivery = entity.isCashOnDelivery;
|
||||
oldModel.firstUnit = entity.firstUnit;
|
||||
oldModel.continueUnit = entity.continueUnit;
|
||||
oldModel.isdefaultAreaFee = entity.isdefaultAreaFee;
|
||||
oldModel.areaType = entity.areaType;
|
||||
oldModel.firstunitPrice = entity.firstunitPrice;
|
||||
oldModel.continueunitPrice = entity.continueunitPrice;
|
||||
oldModel.exp = entity.exp;
|
||||
oldModel.logiName = entity.logiName;
|
||||
oldModel.logiCode = entity.logiCode;
|
||||
oldModel.isDefault = entity.isDefault;
|
||||
oldModel.sort = entity.sort;
|
||||
oldModel.status = entity.status;
|
||||
oldModel.isfreePostage = entity.isfreePostage;
|
||||
oldModel.areaFee = entity.areaFee;
|
||||
oldModel.goodsMoney = entity.goodsMoney;
|
||||
|
||||
var logistics = await DbClient.Queryable<CoreCmsLogistics>().FirstAsync(p => p.logiCode == oldModel.logiCode);
|
||||
if (logistics != null)
|
||||
{
|
||||
oldModel.logiName = logistics.logiName;
|
||||
}
|
||||
|
||||
//事物处理过程结束
|
||||
var bl = await DbClient.Updateable(oldModel).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
|
||||
|
||||
if (bl && entity.isDefault == true)
|
||||
{
|
||||
await DbClient.Updateable<CoreCmsShip>().SetColumns(p => p.isDefault == false).Where(p => p.isDefault == true && p.id != oldModel.id).ExecuteCommandAsync();
|
||||
}
|
||||
return jm;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重写删除指定ID的数据
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<AdminUiCallBack> DeleteByIdAsync(int id)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var isDefault = await DbClient.Queryable<CoreCmsShip>().AnyAsync(p => p.isDefault == true && p.id == id);
|
||||
if (isDefault)
|
||||
{
|
||||
jm.msg = "默认方式禁止删除";
|
||||
}
|
||||
var bl = await DbClient.Deleteable<CoreCmsShip>(id).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置是否默认
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="isDefault"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<AdminUiCallBack> SetIsDefault(int id, bool isDefault)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
if (isDefault == false)
|
||||
{
|
||||
var otherHave = await DbClient.Queryable<CoreCmsShip>().AnyAsync(p => p.isDefault == true && p.id != id);
|
||||
if (otherHave == false)
|
||||
{
|
||||
jm.msg = "请保持一个默认配送方式";
|
||||
return jm;
|
||||
}
|
||||
}
|
||||
//事物处理过程结束
|
||||
var bl = await DbClient.Updateable<CoreCmsShip>().SetColumns(p => p.isDefault == isDefault).Where(p => p.id == id).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
|
||||
|
||||
if (bl && isDefault == true)
|
||||
{
|
||||
await DbClient.Updateable<CoreCmsShip>().SetColumns(p => p.isDefault == false).Where(p => p.isDefault == true && p.id != id).ExecuteCommandAsync();
|
||||
}
|
||||
return jm;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#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<CoreCmsShip>> QueryPageAsync(Expression<Func<CoreCmsShip, bool>> predicate,
|
||||
Expression<Func<CoreCmsShip, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsShip> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsShip>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsShip
|
||||
{
|
||||
id = p.id,
|
||||
name = p.name,
|
||||
isCashOnDelivery = p.isCashOnDelivery,
|
||||
firstUnit = p.firstUnit,
|
||||
continueUnit = p.continueUnit,
|
||||
isdefaultAreaFee = p.isdefaultAreaFee,
|
||||
areaType = p.areaType,
|
||||
firstunitPrice = p.firstunitPrice,
|
||||
continueunitPrice = p.continueunitPrice,
|
||||
exp = p.exp,
|
||||
logiName = p.logiName,
|
||||
logiCode = p.logiCode,
|
||||
isDefault = p.isDefault,
|
||||
sort = p.sort,
|
||||
status = p.status,
|
||||
isfreePostage = p.isfreePostage,
|
||||
areaFee = p.areaFee,
|
||||
goodsMoney = p.goodsMoney,
|
||||
|
||||
}).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsShip>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsShip
|
||||
{
|
||||
id = p.id,
|
||||
name = p.name,
|
||||
isCashOnDelivery = p.isCashOnDelivery,
|
||||
firstUnit = p.firstUnit,
|
||||
continueUnit = p.continueUnit,
|
||||
isdefaultAreaFee = p.isdefaultAreaFee,
|
||||
areaType = p.areaType,
|
||||
firstunitPrice = p.firstunitPrice,
|
||||
continueunitPrice = p.continueunitPrice,
|
||||
exp = p.exp,
|
||||
logiName = p.logiName,
|
||||
logiCode = p.logiCode,
|
||||
isDefault = p.isDefault,
|
||||
sort = p.sort,
|
||||
status = p.status,
|
||||
isfreePostage = p.isfreePostage,
|
||||
areaFee = p.areaFee,
|
||||
goodsMoney = p.goodsMoney,
|
||||
|
||||
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsShip>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
275
CoreCms.Net.Repository/Shop/CoreCmsStoreRepository.cs
Normal file
275
CoreCms.Net.Repository/Shop/CoreCmsStoreRepository.cs
Normal file
@@ -0,0 +1,275 @@
|
||||
/***********************************************************************
|
||||
* 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.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Loging;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 门店表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsStoreRepository : BaseRepository<CoreCmsStore>, ICoreCmsStoreRepository
|
||||
{
|
||||
|
||||
|
||||
public CoreCmsStoreRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> InsertAsync(CoreCmsStore entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var isDefaultObj = DbClient.Queryable<CoreCmsStore>().Where(p => p.isDefault == true).Any();
|
||||
if (isDefaultObj && entity.isDefault == true)
|
||||
{
|
||||
await DbClient.Updateable<CoreCmsStore>().SetColumns(it => it.isDefault == false).Where(p => p.id > 0).ExecuteCommandAsync(); ;
|
||||
}
|
||||
else if (!isDefaultObj)
|
||||
{
|
||||
entity.isDefault = true;
|
||||
}
|
||||
entity.createTime = DateTime.Now;
|
||||
entity.updateTime = DateTime.Now;
|
||||
entity.distance = 0;
|
||||
if (entity.coordinate.Contains(","))
|
||||
{
|
||||
var latlong = entity.coordinate.Split(",");
|
||||
entity.latitude = latlong[0];
|
||||
entity.longitude = latlong[1];
|
||||
}
|
||||
|
||||
var id = await DbClient.Insertable(entity).ExecuteReturnIdentityAsync();
|
||||
var bl = id > 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(CoreCmsStore entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var oldModel = await DbClient.Queryable<CoreCmsStore>().In(entity.id).SingleAsync();
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
//事物处理过程开始
|
||||
oldModel.storeName = entity.storeName;
|
||||
oldModel.mobile = entity.mobile;
|
||||
oldModel.linkMan = entity.linkMan;
|
||||
oldModel.logoImage = entity.logoImage;
|
||||
oldModel.areaId = entity.areaId;
|
||||
oldModel.address = entity.address;
|
||||
oldModel.coordinate = entity.coordinate;
|
||||
oldModel.latitude = entity.latitude;
|
||||
oldModel.longitude = entity.longitude;
|
||||
oldModel.updateTime = entity.updateTime;
|
||||
oldModel.isDefault = entity.isDefault;
|
||||
|
||||
if (entity.coordinate.Contains(","))
|
||||
{
|
||||
var latlong = entity.coordinate.Split(",");
|
||||
oldModel.latitude = latlong[0];
|
||||
oldModel.longitude = latlong[1];
|
||||
}
|
||||
|
||||
var isDefaultObj = DbClient.Queryable<CoreCmsStore>().Where(p => p.isDefault == true).Any();
|
||||
if (isDefaultObj && entity.isDefault == true)
|
||||
{
|
||||
await DbClient.Updateable<CoreCmsStore>().SetColumns(it => it.isDefault == false).Where(p => p.id > 0).ExecuteCommandAsync();
|
||||
}
|
||||
else if (!isDefaultObj)
|
||||
{
|
||||
oldModel.isDefault = true;
|
||||
}
|
||||
|
||||
//事物处理过程结束
|
||||
var bl = await DbClient.Updateable(oldModel).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
|
||||
#region Sql根据条件查询分页数据带距离
|
||||
|
||||
/// <summary>
|
||||
/// Sql根据条件查询分页数据带距离
|
||||
/// </summary>
|
||||
/// <param name="predicate">判断集合</param>
|
||||
/// <param name="orderByType">排序方式</param>
|
||||
/// <param name="pageIndex">当前页面索引</param>
|
||||
/// <param name="pageSize">分布大小</param>
|
||||
/// <param name="orderByExpression"></param>
|
||||
/// <param name="latitude">纬度</param>
|
||||
/// <param name="longitude">精度</param>
|
||||
/// <returns></returns>
|
||||
public async Task<IPageList<CoreCmsStore>> QueryPageAsyncByCoordinate(Expression<Func<CoreCmsStore, bool>> predicate,
|
||||
Expression<Func<CoreCmsStore, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, decimal latitude = 0, decimal longitude = 0)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
|
||||
//MySql与SqlServer查询语句相同
|
||||
List<CoreCmsStore> page;
|
||||
if (latitude > 0 && longitude > 0)
|
||||
{
|
||||
var sqrt = "SQRT(power(SIN((" + latitude + "*PI()/180-(CoreCmsStore.latitude)*PI()/180)/2),2)+COS(" + latitude + "*PI()/180)*COS((CoreCmsStore.latitude)*PI()/180)*power(SIN((" + longitude + "*PI()/180-(CoreCmsStore.longitude)*PI()/180)/2),2))";
|
||||
var sql = "SELECT id, storeName, mobile, linkMan, logoImage, areaId, address, coordinate, latitude, longitude, isDefault, createTime, updateTime, ROUND(6378.138*2*ASIN(" + sqrt + ")*1000,2) AS distance FROM CoreCmsStore";
|
||||
|
||||
page = await DbClient.SqlQueryable<CoreCmsStore>(sql)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.Select(p => new CoreCmsStore
|
||||
{
|
||||
id = p.id,
|
||||
storeName = p.storeName,
|
||||
mobile = p.mobile,
|
||||
linkMan = p.linkMan,
|
||||
logoImage = p.logoImage,
|
||||
areaId = p.areaId,
|
||||
address = p.address,
|
||||
coordinate = p.coordinate,
|
||||
latitude = p.latitude,
|
||||
longitude = p.longitude,
|
||||
isDefault = p.isDefault,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
distance = Convert.ToDecimal(p.distance)
|
||||
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsStore>()
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.Select(p => new CoreCmsStore
|
||||
{
|
||||
id = p.id,
|
||||
storeName = p.storeName,
|
||||
mobile = p.mobile,
|
||||
linkMan = p.linkMan,
|
||||
logoImage = p.logoImage,
|
||||
areaId = p.areaId,
|
||||
address = p.address,
|
||||
coordinate = p.coordinate,
|
||||
latitude = p.latitude,
|
||||
longitude = p.longitude,
|
||||
isDefault = p.isDefault,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
distance = Convert.ToDecimal(p.distance)
|
||||
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
|
||||
var list = new PageList<CoreCmsStore>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 根据用户序列获取单个门店数据
|
||||
|
||||
/// <summary>
|
||||
/// 根据用户序列获取单个门店数据
|
||||
/// </summary>
|
||||
/// <param name="userId">用户序列</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<CoreCmsStore> GetStoreByUserId(int userId, bool blUseNoLock = false)
|
||||
{
|
||||
CoreCmsStore obj;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
obj = await DbClient.Queryable<CoreCmsStore, CoreCmsClerk>((p, clerks) => new JoinQueryInfos(
|
||||
JoinType.Left, p.id == clerks.storeId
|
||||
))
|
||||
.Where((p, clerks) => clerks.userId == userId)
|
||||
.Select((p, clerks) => new CoreCmsStore
|
||||
{
|
||||
id = p.id,
|
||||
storeName = p.storeName,
|
||||
mobile = p.mobile,
|
||||
linkMan = p.linkMan,
|
||||
logoImage = p.logoImage,
|
||||
areaId = p.areaId,
|
||||
address = p.address,
|
||||
coordinate = p.coordinate,
|
||||
latitude = p.latitude,
|
||||
longitude = p.longitude,
|
||||
isDefault = p.isDefault,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
}).With(SqlWith.NoLock)
|
||||
.FirstAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
obj = await DbClient.Queryable<CoreCmsStore, CoreCmsClerk>((p, clerks) => new JoinQueryInfos(
|
||||
JoinType.Left, p.id == clerks.storeId
|
||||
))
|
||||
.Where((p, clerks) => clerks.userId == userId)
|
||||
.Select((p, clerks) => new CoreCmsStore
|
||||
{
|
||||
id = p.id,
|
||||
storeName = p.storeName,
|
||||
mobile = p.mobile,
|
||||
linkMan = p.linkMan,
|
||||
logoImage = p.logoImage,
|
||||
areaId = p.areaId,
|
||||
address = p.address,
|
||||
coordinate = p.coordinate,
|
||||
latitude = p.latitude,
|
||||
longitude = p.longitude,
|
||||
isDefault = p.isDefault,
|
||||
createTime = p.createTime,
|
||||
updateTime = p.updateTime,
|
||||
})
|
||||
.FirstAsync();
|
||||
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
209
CoreCms.Net.Repository/Stock/CoreCmsStockLogRepository.cs
Normal file
209
CoreCms.Net.Repository/Stock/CoreCmsStockLogRepository.cs
Normal file
@@ -0,0 +1,209 @@
|
||||
/***********************************************************************
|
||||
* 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 CoreCmsStockLogRepository : BaseRepository<CoreCmsStockLog>, ICoreCmsStockLogRepository
|
||||
{
|
||||
public CoreCmsStockLogRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
#region 实现重写增删改查操作==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> InsertAsync(CoreCmsStockLog 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(CoreCmsStockLog entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var oldModel = await DbClient.Queryable<CoreCmsStockLog>().In(entity.id).SingleAsync();
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
//事物处理过程开始
|
||||
oldModel.id = entity.id;
|
||||
oldModel.stockId = entity.stockId;
|
||||
oldModel.productId = entity.productId;
|
||||
oldModel.goodsId = entity.goodsId;
|
||||
oldModel.nums = entity.nums;
|
||||
oldModel.sn = entity.sn;
|
||||
oldModel.bn = entity.bn;
|
||||
oldModel.goodsName = entity.goodsName;
|
||||
oldModel.spesDesc = entity.spesDesc;
|
||||
|
||||
//事物处理过程结束
|
||||
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<CoreCmsStockLog> 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<CoreCmsStockLog>(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<CoreCmsStockLog>().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<CoreCmsStockLog>> QueryPageAsync(Expression<Func<CoreCmsStockLog, bool>> predicate,
|
||||
Expression<Func<CoreCmsStockLog, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsStockLog> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsStockLog, CoreCmsStock>((p, stock) => new JoinQueryInfos(JoinType.Left, p.stockId == stock.id))
|
||||
.Select((p, stock) => new CoreCmsStockLog
|
||||
{
|
||||
id = p.id,
|
||||
stockId = p.stockId,
|
||||
productId = p.productId,
|
||||
goodsId = p.goodsId,
|
||||
nums = p.nums,
|
||||
sn = p.sn,
|
||||
bn = p.bn,
|
||||
goodsName = p.goodsName,
|
||||
spesDesc = p.spesDesc,
|
||||
type = stock.type,
|
||||
manager = stock.manager,
|
||||
memo = stock.memo,
|
||||
createTime = stock.createTime
|
||||
|
||||
}).With(SqlWith.NoLock)
|
||||
.MergeTable()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsStockLog, CoreCmsStock>((p, stock) => new JoinQueryInfos(JoinType.Left, p.stockId == stock.id))
|
||||
.Select((p, stock) => new CoreCmsStockLog
|
||||
{
|
||||
id = p.id,
|
||||
stockId = p.stockId,
|
||||
productId = p.productId,
|
||||
goodsId = p.goodsId,
|
||||
nums = p.nums,
|
||||
sn = p.sn,
|
||||
bn = p.bn,
|
||||
goodsName = p.goodsName,
|
||||
spesDesc = p.spesDesc,
|
||||
type = stock.type,
|
||||
manager = stock.manager,
|
||||
memo = stock.memo,
|
||||
createTime = stock.createTime
|
||||
})
|
||||
.MergeTable()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsStockLog>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
364
CoreCms.Net.Repository/Stock/CoreCmsStockRepository.cs
Normal file
364
CoreCms.Net.Repository/Stock/CoreCmsStockRepository.cs
Normal file
@@ -0,0 +1,364 @@
|
||||
/***********************************************************************
|
||||
* 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.FromBody;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.Utility.Helper;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 库存操作表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsStockRepository : BaseRepository<CoreCmsStock>, ICoreCmsStockRepository
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
public CoreCmsStockRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
#region 实现重写增删改查操作==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public async Task<AdminUiCallBack> InsertAsync(FMCreateStock entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
if (entity.items == null || !entity.items.Any())
|
||||
{
|
||||
jm.msg = "至少选择一个货品哦";
|
||||
return jm;
|
||||
}
|
||||
|
||||
bool isRepeat = entity.items.GroupBy(i => i.productId).Any(g => g.Count() > 1);
|
||||
if (isRepeat)
|
||||
{
|
||||
jm.msg = "请勿提交相同货品";
|
||||
return jm;
|
||||
}
|
||||
|
||||
if (entity.items.Any(p => p.nums <= 0))
|
||||
{
|
||||
jm.msg = "入库出库的货品数量不能为0";
|
||||
return jm;
|
||||
}
|
||||
|
||||
var stockModel = new CoreCmsStock();
|
||||
if (entity.model.type == (int)GlobalEnumVars.StockType.In)
|
||||
{
|
||||
stockModel.id = await CreateCode(GlobalEnumVars.StockType.In.ToString());
|
||||
}
|
||||
else if (entity.model.type == (int)GlobalEnumVars.StockType.Out)
|
||||
{
|
||||
stockModel.id = await CreateCode(GlobalEnumVars.StockType.Out.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
jm.msg = "单据类型错误";
|
||||
return jm;
|
||||
}
|
||||
|
||||
stockModel.memo = entity.model.memo;
|
||||
stockModel.createTime = DateTime.Now;
|
||||
stockModel.manager = entity.model.manager;
|
||||
stockModel.type = entity.model.type;
|
||||
|
||||
var logs = new List<CoreCmsStockLog>();
|
||||
var products = new List<CoreCmsProducts>();
|
||||
var index = 0;
|
||||
foreach (var item in entity.items)
|
||||
{
|
||||
index++;
|
||||
//判断此货品是否存在
|
||||
var product = await DbClient.Queryable<CoreCmsProducts, CoreCmsGoods>((p, good) => new JoinQueryInfos(
|
||||
JoinType.Left, p.goodsId == good.id))
|
||||
.Select((p, good) => new CoreCmsProducts
|
||||
{
|
||||
id = p.id,
|
||||
goodsId = p.goodsId,
|
||||
barcode = p.barcode,
|
||||
sn = p.sn,
|
||||
price = p.price,
|
||||
costprice = p.costprice,
|
||||
mktprice = p.mktprice,
|
||||
marketable = p.marketable,
|
||||
weight = p.weight,
|
||||
stock = p.stock,
|
||||
freezeStock = p.freezeStock,
|
||||
spesDesc = p.spesDesc,
|
||||
isDefalut = p.isDefalut,
|
||||
images = p.images,
|
||||
isDel = p.isDel,
|
||||
name = good.name,
|
||||
bn = good.bn,
|
||||
isMarketable = good.isMarketable,
|
||||
unit = good.unit
|
||||
}).With(SqlWith.NoLock)
|
||||
.MergeTable()
|
||||
.Where(p => p.id == item.productId).FirstAsync();
|
||||
if (product != null && item.nums > 0)
|
||||
{
|
||||
var stock = 0;
|
||||
if (entity.model.type == (int)GlobalEnumVars.StockType.In)
|
||||
{
|
||||
stock = product.stock + item.nums;
|
||||
}
|
||||
else if (entity.model.type == (int)GlobalEnumVars.StockType.Out)
|
||||
{
|
||||
stock = product.stock - item.nums;
|
||||
if (stock < 0)
|
||||
{
|
||||
jm.msg = $"第{index}个货品最大出库数量为:" + product.stock;
|
||||
return jm;
|
||||
}
|
||||
}
|
||||
product.stock = stock;
|
||||
products.Add(product);
|
||||
|
||||
var log = new CoreCmsStockLog
|
||||
{
|
||||
stockId = stockModel.id,
|
||||
productId = product.id,
|
||||
goodsId = product.goodsId,
|
||||
nums = item.nums,
|
||||
sn = product.sn,
|
||||
bn = product.barcode,
|
||||
goodsName = product.name,
|
||||
spesDesc = product.spesDesc
|
||||
};
|
||||
logs.Add(log);
|
||||
}
|
||||
else
|
||||
{
|
||||
jm.msg = $"请检查第{index}个货品或数量是否正确";
|
||||
return jm;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_unitOfWork.BeginTran();
|
||||
var bl = await DbClient.Insertable(stockModel).ExecuteCommandAsync() > 0;
|
||||
if (products.Any())
|
||||
{
|
||||
await DbClient.Updateable(products).ExecuteCommandAsync();
|
||||
}
|
||||
if (logs.Any())
|
||||
{
|
||||
await DbClient.Insertable(logs).ExecuteCommandAsync();
|
||||
}
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.CreateSuccess : GlobalConstVars.CreateFailure;
|
||||
_unitOfWork.CommitTran();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_unitOfWork.RollbackTran();
|
||||
jm.code = 1;
|
||||
jm.msg = "处理异常";
|
||||
jm.data = e;
|
||||
}
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> UpdateAsync(CoreCmsStock entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var oldModel = await DbClient.Queryable<CoreCmsStock>().In(entity.id).SingleAsync();
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
//事物处理过程开始
|
||||
oldModel.id = entity.id;
|
||||
oldModel.type = entity.type;
|
||||
oldModel.manager = entity.manager;
|
||||
oldModel.memo = entity.memo;
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> UpdateAsync(List<CoreCmsStock> 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<CoreCmsStock>(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<CoreCmsStock>().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<CoreCmsStock>> QueryPageAsync(Expression<Func<CoreCmsStock, bool>> predicate,
|
||||
Expression<Func<CoreCmsStock, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsStock> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsStock, SysUser>((p, sUser) => new JoinQueryInfos(
|
||||
JoinType.Left, p.manager == sUser.id))
|
||||
.Select((p, sUser) => new CoreCmsStock
|
||||
{
|
||||
id = p.id,
|
||||
type = p.type,
|
||||
manager = p.manager,
|
||||
memo = p.memo,
|
||||
createTime = p.createTime,
|
||||
managerName = sUser.nickName
|
||||
})
|
||||
.With(SqlWith.NoLock)
|
||||
.MergeTable()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsStock, SysUser>((p, sUser) => new JoinQueryInfos(JoinType.Left, p.manager == sUser.id))
|
||||
.Select((p, sUser) => new CoreCmsStock
|
||||
{
|
||||
id = p.id,
|
||||
type = p.type,
|
||||
manager = p.manager,
|
||||
memo = p.memo,
|
||||
createTime = p.createTime,
|
||||
managerName = sUser.nickName
|
||||
})
|
||||
.MergeTable()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsStock>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 生成唯一单号
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<string> CreateCode(string type)
|
||||
{
|
||||
Random rand = new Random();
|
||||
while (true)
|
||||
{
|
||||
var str = string.Empty;
|
||||
if (type == GlobalEnumVars.StockType.In.ToString())
|
||||
{
|
||||
str = "sI";
|
||||
}
|
||||
else if (type == GlobalEnumVars.StockType.Out.ToString())
|
||||
{
|
||||
str = "sO";
|
||||
}
|
||||
else
|
||||
{
|
||||
str = "sU";
|
||||
}
|
||||
|
||||
str += CommonHelper.Msectime() + rand.Next(0, 9);
|
||||
var bl = await DbClient.Queryable<CoreCmsStock>().AnyAsync(p => p.id == str);
|
||||
if (bl == false)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
33
CoreCms.Net.Repository/System/SysDictionaryDataRepository.cs
Normal file
33
CoreCms.Net.Repository/System/SysDictionaryDataRepository.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
/***********************************************************************
|
||||
* 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.Threading.Tasks;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据字典项表 接口实现
|
||||
/// </summary>
|
||||
public class SysDictionaryDataRepository : BaseRepository<SysDictionaryData>, ISysDictionaryDataRepository
|
||||
{
|
||||
public SysDictionaryDataRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
26
CoreCms.Net.Repository/System/SysDictionaryRepository.cs
Normal file
26
CoreCms.Net.Repository/System/SysDictionaryRepository.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据字典表 接口实现
|
||||
/// </summary>
|
||||
public class SysDictionaryRepository : BaseRepository<SysDictionary>, ISysDictionaryRepository
|
||||
{
|
||||
public SysDictionaryRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
26
CoreCms.Net.Repository/System/SysLoginRecordRepository.cs
Normal file
26
CoreCms.Net.Repository/System/SysLoginRecordRepository.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 登录日志表 接口实现
|
||||
/// </summary>
|
||||
public class SysLoginRecordRepository : BaseRepository<SysLoginRecord>, ISysLoginRecordRepository
|
||||
{
|
||||
public SysLoginRecordRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
207
CoreCms.Net.Repository/System/SysMenuRepository.cs
Normal file
207
CoreCms.Net.Repository/System/SysMenuRepository.cs
Normal file
@@ -0,0 +1,207 @@
|
||||
/***********************************************************************
|
||||
* 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.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 Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 菜单表 接口实现
|
||||
/// </summary>
|
||||
public class SysMenuRepository : BaseRepository<SysMenu>, ISysMenuRepository
|
||||
{
|
||||
public SysMenuRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
#region 实现重写增删改查操作==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> InsertAsync(SysMenu 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;
|
||||
if (bl)
|
||||
{
|
||||
await UpdateCaChe();
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> UpdateAsync(SysMenu entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var oldModel = await DbClient.Queryable<SysMenu>().In(entity.id).SingleAsync();
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
//事物处理过程开始
|
||||
//oldModel.id = entity.id;
|
||||
oldModel.parentId = entity.parentId;
|
||||
oldModel.menuName = entity.menuName;
|
||||
oldModel.menuIcon = entity.menuIcon;
|
||||
oldModel.path = entity.path;
|
||||
oldModel.component = entity.component;
|
||||
oldModel.menuType = entity.menuType;
|
||||
oldModel.sortNumber = entity.sortNumber;
|
||||
oldModel.authority = entity.authority;
|
||||
oldModel.target = entity.target;
|
||||
oldModel.iconColor = entity.iconColor;
|
||||
oldModel.hide = entity.hide;
|
||||
//oldModel.deleted = entity.deleted;
|
||||
//oldModel.createTime = oldModel.createTime;
|
||||
oldModel.updateTime = DateTime.Now;
|
||||
oldModel.identificationCode = entity.identificationCode;
|
||||
|
||||
//事物处理过程结束
|
||||
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<SysMenu> 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 async Task<AdminUiCallBack> DeleteByIdAsync(int id)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var all = await GetCaChe();
|
||||
var model = all.Find(p => p.id == id);
|
||||
if (model == null)
|
||||
{
|
||||
jm.msg = GlobalConstVars.DataisNo;
|
||||
return jm;
|
||||
}
|
||||
|
||||
var ids = new List<int>() { id };
|
||||
GetIds(all, id, ids);
|
||||
|
||||
var bl = await DbClient.Deleteable<SysMenu>().In(ids).ExecuteCommandHasChangeAsync();
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
||||
if (bl)
|
||||
{
|
||||
await UpdateCaChe();
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
///获取下级所有数据序列
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="parentId"></param>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
private List<int> GetIds(List<SysMenu> data, int parentId, List<int> ids)
|
||||
{
|
||||
var childs = data.Where(p => p.parentId == parentId).ToList();
|
||||
foreach (var item in childs)
|
||||
{
|
||||
ids.Add(item.id);
|
||||
if (data.Exists(p => p.parentId == item.id))
|
||||
{
|
||||
ids = GetIds(data, item.id, ids);
|
||||
}
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
#region 获取缓存的所有数据==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 获取缓存的所有数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<SysMenu>> GetCaChe()
|
||||
{
|
||||
var cache = ManualDataCache.Instance.Get<List<SysMenu>>(GlobalConstVars.CacheSysMenu);
|
||||
if (cache != null)
|
||||
{
|
||||
return cache;
|
||||
}
|
||||
return await UpdateCaChe();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新cache
|
||||
/// </summary>
|
||||
public async Task<List<SysMenu>> UpdateCaChe()
|
||||
{
|
||||
var list = await DbClient.Queryable<SysMenu>().ToListAsync();
|
||||
ManualDataCache.Instance.Set(GlobalConstVars.CacheSysMenu, list);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
26
CoreCms.Net.Repository/System/SysNLogRecordsRepository.cs
Normal file
26
CoreCms.Net.Repository/System/SysNLogRecordsRepository.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// Nlog记录表 接口实现
|
||||
/// </summary>
|
||||
public class SysNLogRecordsRepository : BaseRepository<SysNLogRecords>, ISysNLogRecordsRepository
|
||||
{
|
||||
public SysNLogRecordsRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
26
CoreCms.Net.Repository/System/SysOperRecordRepository.cs
Normal file
26
CoreCms.Net.Repository/System/SysOperRecordRepository.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 操作日志表 接口实现
|
||||
/// </summary>
|
||||
public class SysOperRecordRepository : BaseRepository<SysOperRecord>, ISysOperRecordRepository
|
||||
{
|
||||
public SysOperRecordRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
26
CoreCms.Net.Repository/System/SysOrganizationRepository.cs
Normal file
26
CoreCms.Net.Repository/System/SysOrganizationRepository.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 组织机构表 接口实现
|
||||
/// </summary>
|
||||
public class SysOrganizationRepository : BaseRepository<SysOrganization>, ISysOrganizationRepository
|
||||
{
|
||||
public SysOrganizationRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
53
CoreCms.Net.Repository/System/SysRoleMenuRepository.cs
Normal file
53
CoreCms.Net.Repository/System/SysRoleMenuRepository.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 角色菜单关联表 接口实现
|
||||
/// </summary>
|
||||
public class SysRoleMenuRepository : BaseRepository<SysRoleMenu>, ISysRoleMenuRepository
|
||||
{
|
||||
public SysRoleMenuRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 角色权限Map
|
||||
/// RoleModulePermission, Module, Role 三表联合
|
||||
/// 第四个类型 RoleModulePermission 是返回值
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<SysRoleMenu>> RoleModuleMaps()
|
||||
{
|
||||
return await QueryMuchAsync<SysRoleMenu, SysMenu, SysRole, SysRoleMenu>(
|
||||
(rmp, m, r) => new object[]
|
||||
{
|
||||
JoinType.Left, rmp.menuId == m.id,
|
||||
JoinType.Left, rmp.roleId == r.id
|
||||
},
|
||||
(rmp, m, r) => new SysRoleMenu
|
||||
{
|
||||
role = r,
|
||||
menu = m
|
||||
},
|
||||
(rmp, m, r) => m.deleted == false && r.deleted == false
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
26
CoreCms.Net.Repository/System/SysRoleRepository.cs
Normal file
26
CoreCms.Net.Repository/System/SysRoleRepository.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 角色表 接口实现
|
||||
/// </summary>
|
||||
public class SysRoleRepository : BaseRepository<SysRole>, ISysRoleRepository
|
||||
{
|
||||
public SysRoleRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
26
CoreCms.Net.Repository/System/SysTaskLogRepository.cs
Normal file
26
CoreCms.Net.Repository/System/SysTaskLogRepository.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 定时任务日志 接口实现
|
||||
/// </summary>
|
||||
public class SysTaskLogRepository : BaseRepository<SysTaskLog>, ISysTaskLogRepository
|
||||
{
|
||||
public SysTaskLogRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
26
CoreCms.Net.Repository/System/SysUserRepository.cs
Normal file
26
CoreCms.Net.Repository/System/SysUserRepository.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户表 接口实现
|
||||
/// </summary>
|
||||
public class SysUserRepository : BaseRepository<SysUser>, ISysUserRepository
|
||||
{
|
||||
public SysUserRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
26
CoreCms.Net.Repository/System/SysUserRoleRepository.cs
Normal file
26
CoreCms.Net.Repository/System/SysUserRoleRepository.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户角色关联表 接口实现
|
||||
/// </summary>
|
||||
public class SysUserRoleRepository : BaseRepository<SysUserRole>, ISysUserRoleRepository
|
||||
{
|
||||
public SysUserRoleRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
63
CoreCms.Net.Repository/UnitOfWork/UnitOfWork.cs
Normal file
63
CoreCms.Net.Repository/UnitOfWork/UnitOfWork.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
using System;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Loging;
|
||||
using NLog;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository.UnitOfWork
|
||||
{
|
||||
public class UnitOfWork : IUnitOfWork
|
||||
{
|
||||
private readonly ISqlSugarClient _sqlSugarClient;
|
||||
|
||||
public UnitOfWork(ISqlSugarClient sqlSugarClient)
|
||||
{
|
||||
_sqlSugarClient = sqlSugarClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取DB,保证唯一性
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public SqlSugarClient GetDbClient()
|
||||
{
|
||||
// 必须要as,后边会用到切换数据库操作
|
||||
return _sqlSugarClient as SqlSugarClient;
|
||||
}
|
||||
|
||||
public void BeginTran()
|
||||
{
|
||||
GetDbClient().BeginTran();
|
||||
}
|
||||
|
||||
public void CommitTran()
|
||||
{
|
||||
try
|
||||
{
|
||||
GetDbClient().CommitTran(); //
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
GetDbClient().RollbackTran();
|
||||
NLogUtil.WriteFileLog(LogLevel.Error, LogType.Web, "事务提交异常", "事务提交异常", new Exception("事务提交异常", ex));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void RollbackTran()
|
||||
{
|
||||
GetDbClient().RollbackTran();
|
||||
}
|
||||
}
|
||||
}
|
||||
95
CoreCms.Net.Repository/User/CoreCmsUserBalanceRepository.cs
Normal file
95
CoreCms.Net.Repository/User/CoreCmsUserBalanceRepository.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
/***********************************************************************
|
||||
* 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.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户余额表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsUserBalanceRepository : BaseRepository<CoreCmsUserBalance>, ICoreCmsUserBalanceRepository
|
||||
{
|
||||
public CoreCmsUserBalanceRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
#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<CoreCmsUserBalance>> QueryPageAsync(
|
||||
Expression<Func<CoreCmsUserBalance, bool>> predicate,
|
||||
Expression<Func<CoreCmsUserBalance, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsUserBalance> page;
|
||||
if (blUseNoLock)
|
||||
page = await DbClient.Queryable<CoreCmsUserBalance, CoreCmsUser>((p, sc) => new JoinQueryInfos(
|
||||
JoinType.Left, p.userId == sc.id))
|
||||
.Select((p, sc) => new CoreCmsUserBalance
|
||||
{
|
||||
id = p.id,
|
||||
userId = p.userId,
|
||||
type = p.type,
|
||||
money = p.money,
|
||||
balance = p.balance,
|
||||
sourceId = p.sourceId,
|
||||
memo = p.memo,
|
||||
createTime = p.createTime,
|
||||
userNickName = sc.nickName
|
||||
})
|
||||
.MergeTable()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
else
|
||||
page = await DbClient.Queryable<CoreCmsUserBalance, CoreCmsUser>((p, sc) => new JoinQueryInfos(
|
||||
JoinType.Left, p.userId == sc.id))
|
||||
.Select((p, sc) => new CoreCmsUserBalance
|
||||
{
|
||||
id = p.id,
|
||||
userId = p.userId,
|
||||
type = p.type,
|
||||
money = p.money,
|
||||
balance = p.balance,
|
||||
sourceId = p.sourceId,
|
||||
memo = p.memo,
|
||||
createTime = p.createTime,
|
||||
userNickName = sc.nickName
|
||||
})
|
||||
.MergeTable()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
var list = new PageList<CoreCmsUserBalance>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
26
CoreCms.Net.Repository/User/CoreCmsUserBankCardRepository.cs
Normal file
26
CoreCms.Net.Repository/User/CoreCmsUserBankCardRepository.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 银行卡信息 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsUserBankCardRepository : BaseRepository<CoreCmsUserBankCard>, ICoreCmsUserBankCardRepository
|
||||
{
|
||||
public CoreCmsUserBankCardRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user