mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 17:03:27 +08:00
# 2022-01-17
### 1.3.0 开源社区版: 【新增】完善商品查看详情功能。#I4QTLR 【新增】订单详情页面需要增加下单客户信息。 【新增】完善服务订单管理功能,实现订单作废、导出功能;核销码实现列表,作废,导出功能。#I4OSBK 【修复】修复普通订单查看详情,因优惠信息问题导致的异常情况。#I4QXUQ 【修复】修复门店列表下的用户编辑页面名称大小写问题(linux下大小写敏感问题)。 【修复】修复微信支付成功相应的日志记录类型有误。#I4QSNZ 【修复】修复发货日志记录sku货号错误问题。#I4PX25 【修复】修复发货单列表查看详情,提示权限不足的问题。#I4QDQR ### 0.0.8 会员专业版: 【新增】新增接龙功能营销功能,实现单个活动,可以添加多个不同商品的不同sku混合选择下单。 【新增】增加接龙数据库脚本及演示文件。 【升级】升级uView组件到2.0.20版本。 【修复】修复编辑收货地址的路径中选取区域部分可以手动输入文字。 【修复】修复【微信直播带货】组件缺少获取sku分页数据的问题。#I4QKSU 【优化】调整【微信自定义交易组件】商品类目排序方式及展示内容。#I4QE0N
This commit is contained in:
@@ -0,0 +1,313 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/6/19 23:42:28
|
||||
* 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.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 接龙活动商品表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsSolitaireItemsRepository : BaseRepository<CoreCmsSolitaireItems>, ICoreCmsSolitaireItemsRepository
|
||||
{
|
||||
public CoreCmsSolitaireItemsRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
#region 实现重写增删改查操作==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> InsertAsync(CoreCmsSolitaireItems 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(CoreCmsSolitaireItems entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var oldModel = await DbClient.Queryable<CoreCmsSolitaireItems>().In(entity.id).SingleAsync();
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
//事物处理过程开始
|
||||
oldModel.id = entity.id;
|
||||
oldModel.solitaireId = entity.solitaireId;
|
||||
oldModel.goodId = entity.goodId;
|
||||
oldModel.productId = entity.productId;
|
||||
oldModel.price = entity.price;
|
||||
oldModel.activityStock = entity.activityStock;
|
||||
oldModel.oneCanBuy = entity.oneCanBuy;
|
||||
oldModel.isDelete = entity.isDelete;
|
||||
|
||||
//事物处理过程结束
|
||||
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<CoreCmsSolitaireItems> 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<CoreCmsSolitaireItems>(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<CoreCmsSolitaireItems>().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<CoreCmsSolitaireItems>> GetCaChe()
|
||||
{
|
||||
var cache = ManualDataCache.Instance.Get<List<CoreCmsSolitaireItems>>(GlobalConstVars.CacheCoreCmsSolitaireItems);
|
||||
if (cache != null)
|
||||
{
|
||||
return cache;
|
||||
}
|
||||
return await UpdateCaChe();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新cache
|
||||
/// </summary>
|
||||
public async Task<List<CoreCmsSolitaireItems>> UpdateCaChe()
|
||||
{
|
||||
var list = await DbClient.Queryable<CoreCmsSolitaireItems>().With(SqlWith.NoLock).ToListAsync();
|
||||
ManualDataCache.Instance.Set(GlobalConstVars.CacheCoreCmsSolitaireItems, list);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 重写根据条件查询列表数据
|
||||
/// <summary>
|
||||
/// 重写根据条件查询列表数据
|
||||
/// </summary>
|
||||
/// <param name="predicate">判断集合</param>
|
||||
/// <param name="orderByType">排序方式</param>
|
||||
/// <param name="orderByExpression"></param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<List<CoreCmsSolitaireItems>> QueryListByClauseAsync(Expression<Func<CoreCmsSolitaireItems, bool>> predicate,
|
||||
Expression<Func<CoreCmsSolitaireItems, object>> orderByExpression, OrderByType orderByType, bool blUseNoLock = false)
|
||||
{
|
||||
List<CoreCmsSolitaireItems> list;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
list = await DbClient.Queryable<CoreCmsSolitaireItems>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsSolitaireItems
|
||||
{
|
||||
id = p.id,
|
||||
solitaireId = p.solitaireId,
|
||||
goodId = p.goodId,
|
||||
productId = p.productId,
|
||||
price = p.price,
|
||||
activityStock = p.activityStock,
|
||||
oneCanBuy = p.oneCanBuy,
|
||||
sortId = p.sortId,
|
||||
isDelete = p.isDelete,
|
||||
})
|
||||
.With(SqlWith.NoLock)
|
||||
.MergeTable()
|
||||
.Mapper(it => it.productObj, it => it.productId)
|
||||
.Mapper(it => it.goodObj, it => it.goodId)
|
||||
.ToListAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
list = await DbClient.Queryable<CoreCmsSolitaireItems>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsSolitaireItems
|
||||
{
|
||||
id = p.id,
|
||||
solitaireId = p.solitaireId,
|
||||
goodId = p.goodId,
|
||||
productId = p.productId,
|
||||
price = p.price,
|
||||
activityStock = p.activityStock,
|
||||
oneCanBuy = p.oneCanBuy,
|
||||
sortId = p.sortId,
|
||||
isDelete = p.isDelete,
|
||||
|
||||
})
|
||||
.Mapper(it => it.productObj, it => it.productId)
|
||||
.Mapper(it => it.goodObj, it => it.goodId)
|
||||
.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<CoreCmsSolitaireItems>> QueryPageAsync(Expression<Func<CoreCmsSolitaireItems, bool>> predicate,
|
||||
Expression<Func<CoreCmsSolitaireItems, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsSolitaireItems> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsSolitaireItems>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsSolitaireItems
|
||||
{
|
||||
id = p.id,
|
||||
solitaireId = p.solitaireId,
|
||||
goodId = p.goodId,
|
||||
productId = p.productId,
|
||||
price = p.price,
|
||||
activityStock = p.activityStock,
|
||||
oneCanBuy = p.oneCanBuy,
|
||||
sortId = p.sortId,
|
||||
isDelete = p.isDelete,
|
||||
|
||||
})
|
||||
.With(SqlWith.NoLock)
|
||||
.Mapper(it => it.productObj, it => it.productId)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsSolitaireItems>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsSolitaireItems
|
||||
{
|
||||
id = p.id,
|
||||
solitaireId = p.solitaireId,
|
||||
goodId = p.goodId,
|
||||
productId = p.productId,
|
||||
price = p.price,
|
||||
activityStock = p.activityStock,
|
||||
oneCanBuy = p.oneCanBuy,
|
||||
sortId = p.sortId,
|
||||
isDelete = p.isDelete,
|
||||
|
||||
})
|
||||
.Mapper(it => it.productObj, it => it.productId)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsSolitaireItems>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
488
CoreCms.Net.Repository/Solitaire/CoreCmsSolitaireRepository.cs
Normal file
488
CoreCms.Net.Repository/Solitaire/CoreCmsSolitaireRepository.cs
Normal file
@@ -0,0 +1,488 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/6/14 23:17:57
|
||||
* 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.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.DTO;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// 接龙活动表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsSolitaireRepository : BaseRepository<CoreCmsSolitaire>, ICoreCmsSolitaireRepository
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
public CoreCmsSolitaireRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
#region 实现重写增删改查操作==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> InsertAsync(CoreCmsSolitaire entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
if (entity.status != (int)GlobalEnumVars.SolitaireStatus.Close && entity.status != (int)GlobalEnumVars.SolitaireStatus.Open)
|
||||
{
|
||||
jm.msg = "请设置活动状态";
|
||||
return jm;
|
||||
}
|
||||
if (entity.endTime < entity.startTime)
|
||||
{
|
||||
jm.msg = "活动开始时间不能大于结束时间";
|
||||
return jm;
|
||||
}
|
||||
if (entity.items == null || entity.items.Count <= 0)
|
||||
{
|
||||
jm.msg = "请设置商品sku";
|
||||
return jm;
|
||||
}
|
||||
var bl = false;
|
||||
try
|
||||
{
|
||||
_unitOfWork.BeginTran();
|
||||
|
||||
entity.createTime = DateTime.Now;
|
||||
|
||||
var id = await DbClient.Insertable(entity).ExecuteReturnIdentityAsync();
|
||||
if (id > 0)
|
||||
{
|
||||
entity.items.ForEach(p =>
|
||||
{
|
||||
p.solitaireId = id;
|
||||
});
|
||||
}
|
||||
await DbClient.Insertable(entity.items).ExecuteCommandAsync();
|
||||
|
||||
_unitOfWork.CommitTran();
|
||||
bl = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
bl = false;
|
||||
_unitOfWork.RollbackTran();
|
||||
jm.msg = GlobalConstVars.DataHandleEx;
|
||||
jm.data = e;
|
||||
}
|
||||
|
||||
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(CoreCmsSolitaire entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
if (entity.status != (int)GlobalEnumVars.SolitaireStatus.Close && entity.status != (int)GlobalEnumVars.SolitaireStatus.Open)
|
||||
{
|
||||
jm.msg = "请设置活动状态";
|
||||
return jm;
|
||||
}
|
||||
if (entity.endTime < entity.startTime)
|
||||
{
|
||||
jm.msg = "活动开始时间不能大于结束时间";
|
||||
return jm;
|
||||
}
|
||||
if (entity.items == null || entity.items.Count <= 0)
|
||||
{
|
||||
jm.msg = "请设置商品sku";
|
||||
return jm;
|
||||
}
|
||||
|
||||
var oldModel = await DbClient.Queryable<CoreCmsSolitaire>().In(entity.id).SingleAsync();
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
|
||||
var bl = false;
|
||||
try
|
||||
{
|
||||
_unitOfWork.BeginTran();
|
||||
|
||||
//事物处理过程开始
|
||||
//oldModel.id = entity.id;
|
||||
oldModel.title = entity.title;
|
||||
oldModel.description = entity.description;
|
||||
oldModel.contentBody = entity.contentBody;
|
||||
oldModel.startTime = entity.startTime;
|
||||
oldModel.endTime = entity.endTime;
|
||||
oldModel.startBuyPrice = entity.startBuyPrice;
|
||||
oldModel.minDeliveryPrice = entity.minDeliveryPrice;
|
||||
oldModel.isShow = entity.isShow;
|
||||
oldModel.status = entity.status;
|
||||
oldModel.thumbnail = entity.thumbnail;
|
||||
|
||||
//oldModel.isDelete = entity.isDelete;
|
||||
//oldModel.createTime = entity.createTime;
|
||||
|
||||
await DbClient.Updateable(oldModel).ExecuteCommandHasChangeAsync();
|
||||
|
||||
//获取数据库存在的数据
|
||||
var oldList = await DbClient.Queryable<CoreCmsSolitaireItems>().Where(p => p.solitaireId == oldModel.id && p.isDelete == false).ToListAsync();
|
||||
var oldProductIds = oldList.Select(p => p.productId).ToList();
|
||||
|
||||
//获取提交的数据有货品序列
|
||||
var newProductIds = entity.items.Select(p => p.productId).ToList();
|
||||
|
||||
//标记已经不存在新数据里面的货品数据为假删除状态
|
||||
await DbClient.Updateable<CoreCmsSolitaireItems>(p => p.isDelete == true)
|
||||
.Where(p => !newProductIds.Contains(p.productId) && p.solitaireId == oldModel.id && p.isDelete == false)
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
//获取老数据并进行更新
|
||||
var oldItems = oldList.Where(p => newProductIds.Contains(p.productId)).ToList();
|
||||
if (oldItems.Any())
|
||||
{
|
||||
oldItems.ForEach(o =>
|
||||
{
|
||||
var newOne = entity.items.Find(p => p.productId == o.productId);
|
||||
o.price = newOne.price;
|
||||
o.activityStock = newOne.activityStock;
|
||||
o.oneCanBuy = newOne.oneCanBuy;
|
||||
o.sortId = newOne.sortId;
|
||||
});
|
||||
await DbClient.Updateable(oldItems).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
//获取新数据并进行增加
|
||||
var newItems = entity.items.Where(p => !oldProductIds.Contains(p.productId)).ToList();
|
||||
if (newItems.Any())
|
||||
{
|
||||
var newList = new List<CoreCmsSolitaireItems>();
|
||||
newItems.ForEach(p =>
|
||||
{
|
||||
newList.Add(new CoreCmsSolitaireItems()
|
||||
{
|
||||
solitaireId = oldModel.id,
|
||||
goodId = p.goodId,
|
||||
productId = p.productId,
|
||||
price = p.price,
|
||||
activityStock = p.activityStock,
|
||||
oneCanBuy = p.oneCanBuy,
|
||||
sortId = p.sortId,
|
||||
isDelete = false,
|
||||
});
|
||||
});
|
||||
await DbClient.Insertable(newList).ExecuteCommandAsync();
|
||||
}
|
||||
//事物处理过程结束
|
||||
_unitOfWork.CommitTran();
|
||||
bl = true;
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
bl = false;
|
||||
_unitOfWork.RollbackTran();
|
||||
jm.msg = GlobalConstVars.DataHandleEx;
|
||||
jm.data = e;
|
||||
}
|
||||
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<CoreCmsSolitaire> 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<CoreCmsSolitaire>(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<CoreCmsSolitaire>().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<CoreCmsSolitaire>> GetCaChe()
|
||||
{
|
||||
var cache = ManualDataCache.Instance.Get<List<CoreCmsSolitaire>>(GlobalConstVars.CacheCoreCmsSolitaire);
|
||||
if (cache != null)
|
||||
{
|
||||
return cache;
|
||||
}
|
||||
return await UpdateCaChe();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新cache
|
||||
/// </summary>
|
||||
public async Task<List<CoreCmsSolitaire>> UpdateCaChe()
|
||||
{
|
||||
var list = await DbClient.Queryable<CoreCmsSolitaire>().With(SqlWith.NoLock).ToListAsync();
|
||||
ManualDataCache.Instance.Set(GlobalConstVars.CacheCoreCmsSolitaire, 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<CoreCmsSolitaire>> QueryPageAsync(Expression<Func<CoreCmsSolitaire, bool>> predicate,
|
||||
Expression<Func<CoreCmsSolitaire, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsSolitaire> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsSolitaire>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsSolitaire
|
||||
{
|
||||
id = p.id,
|
||||
title = p.title,
|
||||
thumbnail = p.thumbnail,
|
||||
description = p.description,
|
||||
//contentBody = p.contentBody,
|
||||
startTime = p.startTime,
|
||||
endTime = p.endTime,
|
||||
startBuyPrice = p.startBuyPrice,
|
||||
minDeliveryPrice = p.minDeliveryPrice,
|
||||
isShow = p.isShow,
|
||||
status = p.status,
|
||||
isDelete = p.isDelete,
|
||||
createTime = p.createTime,
|
||||
|
||||
}).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsSolitaire>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsSolitaire
|
||||
{
|
||||
id = p.id,
|
||||
title = p.title,
|
||||
thumbnail = p.thumbnail,
|
||||
description = p.description,
|
||||
//contentBody = p.contentBody,
|
||||
startTime = p.startTime,
|
||||
endTime = p.endTime,
|
||||
startBuyPrice = p.startBuyPrice,
|
||||
minDeliveryPrice = p.minDeliveryPrice,
|
||||
isShow = p.isShow,
|
||||
status = p.status,
|
||||
isDelete = p.isDelete,
|
||||
createTime = p.createTime,
|
||||
|
||||
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsSolitaire>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 取购物车数据的时候,更新价格
|
||||
|
||||
/// <summary>
|
||||
/// 取购物车数据的时候,更新价格
|
||||
/// </summary>
|
||||
/// <param name="objectId"></param>
|
||||
/// <param name="list"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<WebApiCallBack> SolitaireInfo(int objectId, List<CartProducts> list)
|
||||
{
|
||||
var res = new WebApiCallBack();
|
||||
|
||||
var solitaire = await DbClient.Queryable<CoreCmsSolitaire>().FirstAsync(p => p.id == objectId);
|
||||
if (solitaire == null)
|
||||
{
|
||||
res.data = 21001;
|
||||
res.msg = GlobalErrorCodeVars.Code21001;
|
||||
return res;
|
||||
}
|
||||
var dt = DateTime.Now;
|
||||
if (solitaire.startTime > dt)
|
||||
{
|
||||
res.data = 21002;
|
||||
res.msg = GlobalErrorCodeVars.Code21002;
|
||||
return res;
|
||||
}
|
||||
if (solitaire.endTime < dt)
|
||||
{
|
||||
res.data = 21003;
|
||||
res.msg = GlobalErrorCodeVars.Code21003;
|
||||
return res;
|
||||
}
|
||||
|
||||
var items = await DbClient.Queryable<CoreCmsSolitaireItems>().Where(p => p.solitaireId == objectId && p.isDelete == false).ToListAsync();
|
||||
if (!items.Any())
|
||||
{
|
||||
res.data = 21004;
|
||||
res.msg = GlobalErrorCodeVars.Code21004;
|
||||
return res;
|
||||
}
|
||||
foreach (var item in list)
|
||||
{
|
||||
var sku = items.Find(p => p.productId == item.productId);
|
||||
if (sku == null)
|
||||
{
|
||||
res.data = 21005;
|
||||
res.msg = GlobalErrorCodeVars.Code21005;
|
||||
return res;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.products.price = sku.price;
|
||||
if (item.products.price < 0)
|
||||
{
|
||||
res.data = 21006;
|
||||
res.msg = GlobalErrorCodeVars.Code21006;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
res.status = true;
|
||||
res.data = list;
|
||||
return res;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 获取接龙购买用户记录
|
||||
/// <summary>
|
||||
/// 获取接龙购买用户记录
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<WebApiCallBack> GetBuyRecord(int id)
|
||||
{
|
||||
var jm = new WebApiCallBack() { status = true };
|
||||
var orderType = (int)GlobalEnumVars.OrderType.Solitaire;
|
||||
var list = await DbClient.Queryable<CoreCmsOrder>()
|
||||
.LeftJoin<CoreCmsUser>((sOrder, sUser) => sOrder.userId == sUser.id)
|
||||
.LeftJoin<CoreCmsOrderItem>((sOrder, sUser, sOrderItem) => sOrder.orderId == sOrderItem.orderId)
|
||||
.Where(sOrder => sOrder.orderType == orderType && sOrder.payStatus == 2 && sOrder.objectId == id)
|
||||
.OrderBy(sOrder => sOrder.createTime, OrderByType.Desc)
|
||||
.Select((sOrder, sUser, sOrderItem) => new
|
||||
{
|
||||
sUser.avatarImage,
|
||||
sUser.nickName,
|
||||
create = sOrder.createTime,
|
||||
productName = sOrderItem.name,
|
||||
productSku = sOrderItem.addon,
|
||||
sOrderItem.nums
|
||||
})
|
||||
.ToListAsync();
|
||||
jm.data = list;
|
||||
return jm;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user