mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 17:43:26 +08:00
# 2022-01-22
### 开源社区版(会员专业版同步修改): --无修改 ### 0.1.1 会员专业版: 【新增】增加微信支付服务商配置,支付微信支付服务商及子商户功能。 【新增】增加根据不同下单类型,控制不同的下单送货模式的功能,如普通商品购买只需要【物流快递,同城配送】,团购秒杀只需要【同城配送,上门自提】,可后台自定义。 【新增】微信直播带货功能新增【上传图片】功能,可直接将本地图片上传至微信侧,获取cdn图片进行处理。 【更新】nuget更新组件。 【修复】修复首页商品组件图片高度被错写array的问题。 【修复】修复生成海报保存路径问题,调整开发版或者预览版小程序获取不到的二维码的报错问题。 【优化】调整订单详情商品tag未设置宽度,导致撑破容易的问题。 【修复】调整订单列表左侧图片大小,防止被遮挡。I4PP1F 【修复】修复微信自定义交易组件申请商品类目失败的问题。#I4QE17
This commit is contained in:
@@ -0,0 +1,239 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2022/1/21 2:34:32
|
||||
* 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 CoreCmsOrderDistributionModelRepository : BaseRepository<CoreCmsOrderDistributionModel>, ICoreCmsOrderDistributionModelRepository
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
public CoreCmsOrderDistributionModelRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
#region 实现重写增删改查操作==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> InsertAsync(CoreCmsOrderDistributionModel 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(CoreCmsOrderDistributionModel entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var oldModel = await DbClient.Queryable<CoreCmsOrderDistributionModel>().In(entity.id).SingleAsync();
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
//事物处理过程开始
|
||||
oldModel.id = entity.id;
|
||||
oldModel.orderType = entity.orderType;
|
||||
oldModel.description = entity.description;
|
||||
oldModel.isOpenMailing = entity.isOpenMailing;
|
||||
oldModel.isOpenHomeDelivery = entity.isOpenHomeDelivery;
|
||||
oldModel.isOpenSelfDelivery = entity.isOpenSelfDelivery;
|
||||
|
||||
//事物处理过程结束
|
||||
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<CoreCmsOrderDistributionModel> 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<CoreCmsOrderDistributionModel>(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<CoreCmsOrderDistributionModel>().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<CoreCmsOrderDistributionModel>> GetCaChe()
|
||||
{
|
||||
var cache = ManualDataCache.Instance.Get<List<CoreCmsOrderDistributionModel>>(GlobalConstVars.CacheCoreCmsOrderDistributionModel);
|
||||
if (cache != null)
|
||||
{
|
||||
return cache;
|
||||
}
|
||||
return await UpdateCaChe();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新cache
|
||||
/// </summary>
|
||||
public async Task<List<CoreCmsOrderDistributionModel>> UpdateCaChe()
|
||||
{
|
||||
var list = await DbClient.Queryable<CoreCmsOrderDistributionModel>().With(SqlWith.NoLock).ToListAsync();
|
||||
ManualDataCache.Instance.Set(GlobalConstVars.CacheCoreCmsOrderDistributionModel, 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<CoreCmsOrderDistributionModel>> QueryPageAsync(Expression<Func<CoreCmsOrderDistributionModel, bool>> predicate,
|
||||
Expression<Func<CoreCmsOrderDistributionModel, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsOrderDistributionModel> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsOrderDistributionModel>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsOrderDistributionModel
|
||||
{
|
||||
id = p.id,
|
||||
orderType = p.orderType,
|
||||
description = p.description,
|
||||
isOpenMailing = p.isOpenMailing,
|
||||
isOpenHomeDelivery = p.isOpenHomeDelivery,
|
||||
isOpenSelfDelivery = p.isOpenSelfDelivery,
|
||||
|
||||
}).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsOrderDistributionModel>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsOrderDistributionModel
|
||||
{
|
||||
id = p.id,
|
||||
orderType = p.orderType,
|
||||
description = p.description,
|
||||
isOpenMailing = p.isOpenMailing,
|
||||
isOpenHomeDelivery = p.isOpenHomeDelivery,
|
||||
isOpenSelfDelivery = p.isOpenSelfDelivery,
|
||||
|
||||
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsOrderDistributionModel>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user