mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 20:33:26 +08:00
# 2022-03-14
### 1.3.9 开源社区版: 【修复】修复BaseRepository数据交互层仓储SqlWith.NoLock使用方式异常的问题。 ### 0.2.8 专业版: 【新增】增加日历签到功能。实现通过日历签到获得积分,余额。【非破坏性无缝增加功能】 【新增】增加“连续签到周期”定时任务,用于根据后台的设置,实时重置清零用户连续签到计数。 【修复】修复BaseRepository数据交互层仓储SqlWith.NoLock使用方式异常的问题。
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2022/3/3 1:03:52
|
||||
* 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.IServices;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using SqlSugar;
|
||||
|
||||
|
||||
namespace CoreCms.Net.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 连续签到规则明细 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsContinuousCheckInRuleDetailsServices : BaseServices<CoreCmsContinuousCheckInRuleDetails>, ICoreCmsContinuousCheckInRuleDetailsServices
|
||||
{
|
||||
private readonly ICoreCmsContinuousCheckInRuleDetailsRepository _dal;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
public CoreCmsContinuousCheckInRuleDetailsServices(IUnitOfWork unitOfWork, ICoreCmsContinuousCheckInRuleDetailsRepository dal)
|
||||
{
|
||||
this._dal = dal;
|
||||
base.BaseDal = dal;
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2022/3/3 1:03:58
|
||||
* 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.IServices;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using SqlSugar;
|
||||
|
||||
|
||||
namespace CoreCms.Net.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 连续签到规则 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsContinuousCheckInRulesServices : BaseServices<CoreCmsContinuousCheckInRules>, ICoreCmsContinuousCheckInRulesServices
|
||||
{
|
||||
private readonly ICoreCmsContinuousCheckInRulesRepository _dal;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
public CoreCmsContinuousCheckInRulesServices(IUnitOfWork unitOfWork, ICoreCmsContinuousCheckInRulesRepository dal)
|
||||
{
|
||||
this._dal = dal;
|
||||
base.BaseDal = dal;
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> InsertAsync(List<CoreCmsContinuousCheckInRules> entity)
|
||||
{
|
||||
return await _dal.InsertAsync(entity);
|
||||
}
|
||||
|
||||
#region 获取缓存的所有数据==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 获取缓存的所有数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<CoreCmsContinuousCheckInRules>> GetCaChe()
|
||||
{
|
||||
return await _dal.GetCaChe();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新cache
|
||||
/// </summary>
|
||||
public async Task<List<CoreCmsContinuousCheckInRules>> UpdateCaChe()
|
||||
{
|
||||
return await _dal.UpdateCaChe();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2022/3/3 1:04:05
|
||||
* 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.IServices;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using SqlSugar;
|
||||
|
||||
|
||||
namespace CoreCms.Net.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 累计签到规则 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsCumulativeCheckInRulesServices : BaseServices<CoreCmsCumulativeCheckInRules>, ICoreCmsCumulativeCheckInRulesServices
|
||||
{
|
||||
private readonly ICoreCmsCumulativeCheckInRulesRepository _dal;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
public CoreCmsCumulativeCheckInRulesServices(IUnitOfWork unitOfWork, ICoreCmsCumulativeCheckInRulesRepository dal)
|
||||
{
|
||||
this._dal = dal;
|
||||
base.BaseDal = dal;
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
#region 实现重写增删改查操作==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> InsertAsync(CoreCmsCumulativeCheckInRules entity)
|
||||
{
|
||||
return await _dal.InsertAsync(entity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> InsertAsync(List<CoreCmsCumulativeCheckInRules> entity)
|
||||
{
|
||||
return await _dal.InsertAsync(entity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> UpdateAsync(CoreCmsCumulativeCheckInRules entity)
|
||||
{
|
||||
return await _dal.UpdateAsync(entity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> UpdateAsync(List<CoreCmsCumulativeCheckInRules> entity)
|
||||
{
|
||||
return await _dal.UpdateAsync(entity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写删除指定ID的数据
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> DeleteByIdAsync(object id)
|
||||
{
|
||||
return await _dal.DeleteByIdAsync(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写删除指定ID集合的数据(批量删除)
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> DeleteByIdsAsync(int[] ids)
|
||||
{
|
||||
return await _dal.DeleteByIdsAsync(ids);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 获取缓存的所有数据==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 获取缓存的所有数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<CoreCmsCumulativeCheckInRules>> GetCaChe()
|
||||
{
|
||||
return await _dal.GetCaChe();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新cache
|
||||
/// </summary>
|
||||
public async Task<List<CoreCmsCumulativeCheckInRules>> UpdateCaChe()
|
||||
{
|
||||
return await _dal.UpdateCaChe();
|
||||
}
|
||||
|
||||
#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<CoreCmsCumulativeCheckInRules>> QueryPageAsync(Expression<Func<CoreCmsCumulativeCheckInRules, bool>> predicate,
|
||||
Expression<Func<CoreCmsCumulativeCheckInRules, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
return await _dal.QueryPageAsync(predicate, orderByExpression, orderByType, pageIndex, pageSize, blUseNoLock);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2022/3/8 23:33:07
|
||||
* 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.IServices;
|
||||
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 SqlSugar;
|
||||
|
||||
|
||||
namespace CoreCms.Net.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户签到明细表 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsUserCheckInDetailsServices : BaseServices<CoreCmsUserCheckInDetails>, ICoreCmsUserCheckInDetailsServices
|
||||
{
|
||||
private readonly ICoreCmsUserCheckInDetailsRepository _dal;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
private readonly ICoreCmsSettingServices _settingServices;
|
||||
private readonly ICoreCmsUserPointLogServices _userPointLogServices;
|
||||
private readonly ICoreCmsUserBalanceServices _userBalanceServices;
|
||||
private readonly ICoreCmsCumulativeCheckInRulesServices _cumulativeCheckInRulesServices;
|
||||
private readonly ICoreCmsContinuousCheckInRulesServices _continuousCheckInRulesServices;
|
||||
private readonly ICoreCmsUserServices _userServices;
|
||||
private readonly ICoreCmsUserCheckInServices _userCheckInServices;
|
||||
|
||||
|
||||
public CoreCmsUserCheckInDetailsServices(IUnitOfWork unitOfWork, ICoreCmsUserCheckInDetailsRepository dal, ICoreCmsSettingServices settingServices, ICoreCmsUserPointLogServices userPointLogServices, ICoreCmsUserBalanceServices userBalanceServices, ICoreCmsCumulativeCheckInRulesServices cumulativeCheckInRulesServices, ICoreCmsContinuousCheckInRulesServices continuousCheckInRulesServices, ICoreCmsUserServices userServices, ICoreCmsUserCheckInServices userCheckInServices)
|
||||
{
|
||||
this._dal = dal;
|
||||
_settingServices = settingServices;
|
||||
_userPointLogServices = userPointLogServices;
|
||||
_userBalanceServices = userBalanceServices;
|
||||
_cumulativeCheckInRulesServices = cumulativeCheckInRulesServices;
|
||||
_continuousCheckInRulesServices = continuousCheckInRulesServices;
|
||||
_userServices = userServices;
|
||||
_userCheckInServices = userCheckInServices;
|
||||
base.BaseDal = dal;
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取缓存的所有数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<AdminUiCallBack> DoCheckIn(CoreCmsUserCheckInDetails entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
try
|
||||
{
|
||||
|
||||
var id = await _dal.InsertAsync(entity);
|
||||
|
||||
var userCheckIn = await _userCheckInServices.QueryByClauseAsync(p => p.userId == entity.userId);
|
||||
if (userCheckIn != null)
|
||||
{
|
||||
userCheckIn.continuousCheckInCount += 1;
|
||||
userCheckIn.cumulativeCheckInCount += 1;
|
||||
|
||||
await _userCheckInServices.UpdateAsync(userCheckIn);
|
||||
}
|
||||
else
|
||||
{
|
||||
userCheckIn = new CoreCmsUserCheckIn();
|
||||
userCheckIn.userId = entity.userId;
|
||||
userCheckIn.continuousCheckInCount = 1;
|
||||
userCheckIn.cumulativeCheckInCount = 1;
|
||||
await _userCheckInServices.InsertAsync(userCheckIn);
|
||||
}
|
||||
|
||||
//初始化获得的积分
|
||||
var point = 0;
|
||||
//初始化获得的余额
|
||||
var money = 0;
|
||||
|
||||
|
||||
var allConfigs = await _settingServices.GetConfigDictionaries();
|
||||
var showStoresSwitch = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.CheckInIsOpen).ObjectToInt(2); //是否开启签到
|
||||
if (showStoresSwitch == 1)
|
||||
{
|
||||
|
||||
//普通签到赠送处理
|
||||
//签到赠送的数量
|
||||
var checkInCommonNum = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.CheckInCommonNum).ObjectToInt(0);
|
||||
if (checkInCommonNum > 0)
|
||||
{
|
||||
//签到赠送的类别
|
||||
var checkInCommonType = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.CheckInCommonType).ObjectToInt(0);
|
||||
switch (checkInCommonType)
|
||||
{
|
||||
case (int)GlobalEnumVars.CheckInCommonType.积分:
|
||||
point += checkInCommonNum;
|
||||
//储值积分
|
||||
await _userPointLogServices.SetPoint(entity.userId, checkInCommonNum, (int)GlobalEnumVars.UserPointSourceTypes.PointTypeSign, "日历签到,获得" + checkInCommonNum + "积分");
|
||||
break;
|
||||
case (int)GlobalEnumVars.CheckInCommonType.余额:
|
||||
money += checkInCommonNum;
|
||||
//储值余额
|
||||
await _userBalanceServices.Change(entity.userId, (int)GlobalEnumVars.UserBalanceSourceTypes.CheckIn, checkInCommonNum, id.ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//判断累计签到次数是否满足
|
||||
var cumulativeCheckInRules = await _cumulativeCheckInRulesServices.GetCaChe();
|
||||
//获取用户总签到次数(使用userCheckIn的签到次数统计也可以,但是查询实时数据最可靠。根据个人来)
|
||||
//var cumulativeCheckInCount = await _dal.GetCountAsync(p => p.userId == entity.userId);
|
||||
var cumulativeCheckInCount = userCheckIn.cumulativeCheckInCount;
|
||||
//遍历规则
|
||||
async void Action(CoreCmsCumulativeCheckInRules p)
|
||||
{
|
||||
if (cumulativeCheckInCount == p.days)
|
||||
{
|
||||
switch (p.type)
|
||||
{
|
||||
case (int)GlobalEnumVars.CheckInCommonType.积分:
|
||||
point += p.num;
|
||||
//储值积分
|
||||
await _userPointLogServices.SetPoint(entity.userId, p.num, (int)GlobalEnumVars.UserPointSourceTypes.PointTypeSign, "日历签到,获得" + p.num + "积分");
|
||||
break;
|
||||
case (int)GlobalEnumVars.CheckInCommonType.余额:
|
||||
money += p.num;
|
||||
//储值余额
|
||||
await _userBalanceServices.Change(entity.userId, (int)GlobalEnumVars.UserBalanceSourceTypes.CheckIn, p.num, id.ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
//原则上应该还要加个日志。确定是否这个时间已经领取过了。
|
||||
}
|
||||
cumulativeCheckInRules.ForEach(Action);
|
||||
|
||||
|
||||
//判断连续签到次数是否满足
|
||||
var continuousCheckInRules = await _continuousCheckInRulesServices.GetCaChe();
|
||||
//获取用户数据
|
||||
var user = await _userServices.QueryByIdAsync(entity.userId);
|
||||
//获取用户当前已经连续签到的次数
|
||||
var userContinuousCheckInNum = userCheckIn.continuousCheckInCount;
|
||||
|
||||
//遍历处理结果
|
||||
async void Action1(CoreCmsContinuousCheckInRules p)
|
||||
{
|
||||
if (p.days == userContinuousCheckInNum)
|
||||
{
|
||||
var rule = p.details.Find(o => o.userGradeId == user.grade);
|
||||
if (rule != null)
|
||||
{
|
||||
switch (rule.type)
|
||||
{
|
||||
case (int)GlobalEnumVars.CheckInCommonType.积分:
|
||||
point += rule.num;
|
||||
//储值积分
|
||||
await _userPointLogServices.SetPoint(entity.userId, rule.num, (int)GlobalEnumVars.UserPointSourceTypes.PointTypeSign, "日历签到,获得" + rule.num + "积分");
|
||||
break;
|
||||
case (int)GlobalEnumVars.CheckInCommonType.余额:
|
||||
money += rule.num;
|
||||
//储值余额
|
||||
await _userBalanceServices.Change(entity.userId, (int)GlobalEnumVars.UserBalanceSourceTypes.CheckIn, rule.num, id.ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
continuousCheckInRules.ForEach(Action1);
|
||||
|
||||
jm.code = 0;
|
||||
jm.msg = "签到成功共获得" + point + "积分" + money + "余额";
|
||||
jm.data = userCheckIn;
|
||||
jm.otherData = cumulativeCheckInRules;
|
||||
}
|
||||
else
|
||||
{
|
||||
jm.code = 1;
|
||||
jm.msg = "日历签到暂未开启";
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
jm.code = 1;
|
||||
jm.msg = "更新失败";
|
||||
jm.data = e;
|
||||
}
|
||||
return jm;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
145
CoreCms.Net.Services/CheckIn/CoreCmsUserCheckInServices.cs
Normal file
145
CoreCms.Net.Services/CheckIn/CoreCmsUserCheckInServices.cs
Normal file
@@ -0,0 +1,145 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2022/3/13 22:21:26
|
||||
* 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.IServices;
|
||||
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 SqlSugar;
|
||||
|
||||
|
||||
namespace CoreCms.Net.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户日历签到统计 接口实现
|
||||
/// </summary>
|
||||
public class CoreCmsUserCheckInServices : BaseServices<CoreCmsUserCheckIn>, ICoreCmsUserCheckInServices
|
||||
{
|
||||
private readonly ICoreCmsUserCheckInRepository _dal;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly ICoreCmsSettingServices _settingServices;
|
||||
private readonly ISysTaskLogServices _sysTaskLogServices;
|
||||
|
||||
|
||||
public CoreCmsUserCheckInServices(IUnitOfWork unitOfWork, ICoreCmsUserCheckInRepository dal, ICoreCmsSettingServices settingServices, ISysTaskLogServices sysTaskLogServices)
|
||||
{
|
||||
this._dal = dal;
|
||||
_settingServices = settingServices;
|
||||
_sysTaskLogServices = sysTaskLogServices;
|
||||
base.BaseDal = dal;
|
||||
_unitOfWork = 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<CoreCmsUserCheckIn>> QueryPageAsync(Expression<Func<CoreCmsUserCheckIn, bool>> predicate,
|
||||
Expression<Func<CoreCmsUserCheckIn, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
return await _dal.QueryPageAsync(predicate, orderByExpression, orderByType, pageIndex, pageSize, blUseNoLock);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 清理用户连续签到
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<AdminUiCallBack> ClearUserContinuousCheckIn()
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var allConfigs = await _settingServices.GetConfigDictionaries();
|
||||
|
||||
var showStoresSwitch = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.CheckInIsOpen).ObjectToInt(2); //是否开启签到
|
||||
if (showStoresSwitch == 1)
|
||||
{
|
||||
var continuousCheckInPeriodType = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.ContinuousCheckInPeriodType).ObjectToInt(0); //连续签到周期
|
||||
|
||||
DateTime dt = DateTime.Now; //当前时间
|
||||
if (continuousCheckInPeriodType == (int)GlobalEnumVars.ContinuousCheckInPeriodType.不限)
|
||||
{
|
||||
//插入日志
|
||||
var model = new SysTaskLog
|
||||
{
|
||||
createTime = DateTime.Now,
|
||||
isSuccess = true,
|
||||
name = "不限制模式不执行",
|
||||
parameters = JsonConvert.SerializeObject(jm)
|
||||
};
|
||||
await _sysTaskLogServices.InsertAsync(model);
|
||||
}
|
||||
else if (continuousCheckInPeriodType == (int)GlobalEnumVars.ContinuousCheckInPeriodType.每周末)
|
||||
{
|
||||
if (dt.DayOfWeek == DayOfWeek.Sunday)
|
||||
{
|
||||
await _dal.UpdateAsync(p => new CoreCmsUserCheckIn() { continuousCheckInCount = 0 }, p => p.id > 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
//插入日志
|
||||
var model = new SysTaskLog
|
||||
{
|
||||
createTime = DateTime.Now,
|
||||
isSuccess = true,
|
||||
name = "非周末不执行",
|
||||
parameters = JsonConvert.SerializeObject(jm)
|
||||
};
|
||||
await _sysTaskLogServices.InsertAsync(model);
|
||||
}
|
||||
}
|
||||
else if (continuousCheckInPeriodType == (int)GlobalEnumVars.ContinuousCheckInPeriodType.每月末)
|
||||
{
|
||||
DateTime startMonth = dt.AddDays(1 - dt.Day); //本月月初
|
||||
DateTime endMonth = startMonth.AddMonths(1).AddDays(-1); //本月月末
|
||||
//同年同业同日生。
|
||||
if (dt.Year == endMonth.Year && dt.Month == endMonth.Month && dt.Day == endMonth.Day)
|
||||
{
|
||||
await _dal.UpdateAsync(p => new CoreCmsUserCheckIn() { continuousCheckInCount = 0 }, p => p.id > 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
//插入日志
|
||||
var model = new SysTaskLog
|
||||
{
|
||||
createTime = DateTime.Now,
|
||||
isSuccess = true,
|
||||
name = "非周末不执行",
|
||||
parameters = JsonConvert.SerializeObject(jm)
|
||||
};
|
||||
await _sysTaskLogServices.InsertAsync(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
return jm;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user