mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 16:03:25 +08:00
# 2022-03-14
### 1.3.9 开源社区版: 【修复】修复BaseRepository数据交互层仓储SqlWith.NoLock使用方式异常的问题。 ### 0.2.8 专业版: 【新增】增加日历签到功能。实现通过日历签到获得积分,余额。【非破坏性无缝增加功能】 【新增】增加“连续签到周期”定时任务,用于根据后台的设置,实时重置清零用户连续签到计数。 【修复】修复BaseRepository数据交互层仓储SqlWith.NoLock使用方式异常的问题。
This commit is contained in:
@@ -10,7 +10,7 @@ namespace CoreCms.Net.Configuration
|
||||
/// <summary>
|
||||
/// 配置文件格式化
|
||||
/// </summary>
|
||||
public class AppSettingsConstVars
|
||||
public static class AppSettingsConstVars
|
||||
{
|
||||
|
||||
#region 全局地址================================================================================
|
||||
@@ -24,6 +24,7 @@ namespace CoreCms.Net.Configuration
|
||||
public static readonly string AppConfigAppInterFaceUrl = AppSettingsHelper.GetContent("AppConfig", "AppInterFaceUrl");
|
||||
#endregion
|
||||
|
||||
|
||||
#region 数据库================================================================================
|
||||
/// <summary>
|
||||
/// 获取数据库连接字符串
|
||||
@@ -35,6 +36,7 @@ namespace CoreCms.Net.Configuration
|
||||
public static readonly string DbDbType = AppSettingsHelper.GetContent("ConnectionStrings", "DbType");
|
||||
#endregion
|
||||
|
||||
|
||||
#region redis================================================================================
|
||||
|
||||
/// <summary>
|
||||
@@ -53,6 +55,7 @@ namespace CoreCms.Net.Configuration
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region AOP================================================================================
|
||||
/// <summary>
|
||||
/// 事务切面开关
|
||||
@@ -68,12 +71,14 @@ namespace CoreCms.Net.Configuration
|
||||
public static readonly string JwtConfigAudience = AppSettingsHelper.GetContent("JwtConfig", "Audience");
|
||||
#endregion
|
||||
|
||||
|
||||
#region Cors跨域设置================================================================================
|
||||
public static readonly string CorsPolicyName = AppSettingsHelper.GetContent("Cors", "PolicyName");
|
||||
public static readonly bool CorsEnableAllIPs = AppSettingsHelper.GetContent("Cors", "EnableAllIPs").ObjToBool();
|
||||
public static readonly string CorsIPs = AppSettingsHelper.GetContent("Cors", "IPs");
|
||||
#endregion
|
||||
|
||||
|
||||
#region Middleware中间件================================================================================
|
||||
/// <summary>
|
||||
/// Ip限流
|
||||
@@ -114,6 +119,7 @@ namespace CoreCms.Net.Configuration
|
||||
public static readonly string PayCallBackAlipayRefundUrl = AppSettingsHelper.GetContent("PayCallBack", "AlipayRefundUrl");
|
||||
#endregion
|
||||
|
||||
|
||||
#region 易联云打印机================================================================================
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -284,6 +284,9 @@
|
||||
public const string CacheWeChatTransactionComponentGood = "CacheWeChatTransactionComponentGood";
|
||||
public const string CacheWeChatTransactionComponentDeliveryCompany = "CacheWeChatTransactionComponentDeliveryCompany";
|
||||
public const string CacheCoreCmsOrderDistributionModel = "CacheCoreCmsOrderDistributionModel";
|
||||
public const string CacheCoreCmsContinuousCheckInRuleDetails = "CacheCoreCmsContinuousCheckInRuleDetails";
|
||||
public const string CacheCoreCmsContinuousCheckInRules = "CacheCoreCmsContinuousCheckInRules";
|
||||
public const string CacheCoreCmsCumulativeCheckInRules = "CacheCoreCmsCumulativeCheckInRules";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -216,6 +216,11 @@ namespace CoreCms.Net.Configuration
|
||||
/// </summary>
|
||||
[Description("代理商提成")]
|
||||
Agent = 9,
|
||||
/// <summary>
|
||||
/// 日历签到
|
||||
/// </summary>
|
||||
[Description("日历签到")]
|
||||
CheckIn = 10,
|
||||
}
|
||||
/// <summary>
|
||||
/// 用户积分变动来源类型
|
||||
@@ -2880,5 +2885,28 @@ namespace CoreCms.Net.Configuration
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 日历签到
|
||||
|
||||
/// <summary>
|
||||
/// 每天签到赠送-签到赠送类型
|
||||
/// </summary>
|
||||
|
||||
public enum CheckInCommonType
|
||||
{
|
||||
积分 = 1,
|
||||
余额 = 2
|
||||
}
|
||||
/// <summary>
|
||||
/// 清除连续签到次数
|
||||
/// </summary>
|
||||
public enum ContinuousCheckInPeriodType
|
||||
{
|
||||
不限 = 0,
|
||||
每周末 = 1,
|
||||
每月末 = 2
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -779,5 +779,40 @@ namespace CoreCms.Net.Configuration
|
||||
public static readonly string IntraCityServiceBy20KM = "intraCityServiceBy20KM";
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 是否开启签到
|
||||
/// </summary>
|
||||
public static readonly string CheckInIsOpen = "checkInIsOpen";
|
||||
|
||||
/// <summary>
|
||||
/// 是否签到提醒
|
||||
/// </summary>
|
||||
public static readonly string CheckInIsAlert = "checkInIsAlert";
|
||||
|
||||
/// <summary>
|
||||
/// 签到提醒时间
|
||||
/// </summary>
|
||||
public static readonly string CheckInAlertTime = "checkInAlertTime";
|
||||
|
||||
/// <summary>
|
||||
/// 普通签到赠送
|
||||
/// </summary>
|
||||
public static readonly string CheckInCommonNum = "checkInCommonNum";
|
||||
|
||||
/// <summary>
|
||||
/// 普通签到赠送类型
|
||||
/// </summary>
|
||||
public static readonly string CheckInCommonType = "checkInCommonType";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 连续签到周期
|
||||
/// </summary>
|
||||
public static readonly string ContinuousCheckInPeriodType = "continuousCheckInPeriodType";
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -226,6 +226,13 @@ namespace CoreCms.Net.Configuration
|
||||
di.Add(SystemSettingConstVars.IntraCityServiceBy15KM, new DictionaryKeyValues() { sKey = "15公里内", sValue = "0" });
|
||||
di.Add(SystemSettingConstVars.IntraCityServiceBy20KM, new DictionaryKeyValues() { sKey = "20公里内", sValue = "0" });
|
||||
|
||||
//签到
|
||||
di.Add(SystemSettingConstVars.CheckInIsOpen, new DictionaryKeyValues() { sKey = "是否开启签到", sValue = "1" });
|
||||
di.Add(SystemSettingConstVars.CheckInIsAlert, new DictionaryKeyValues() { sKey = "是否签到提醒", sValue = "1" });
|
||||
di.Add(SystemSettingConstVars.CheckInAlertTime, new DictionaryKeyValues() { sKey = "签到提醒时间", sValue = "08:00:00" });
|
||||
di.Add(SystemSettingConstVars.CheckInCommonNum, new DictionaryKeyValues() { sKey = "签到赠送", sValue = "0" });
|
||||
di.Add(SystemSettingConstVars.CheckInCommonType, new DictionaryKeyValues() { sKey = "签到赠送类型", sValue = GlobalEnumVars.CheckInCommonType.积分.ToString() });
|
||||
di.Add(SystemSettingConstVars.ContinuousCheckInPeriodType, new DictionaryKeyValues() { sKey = "连续签到周期", sValue = GlobalEnumVars.ContinuousCheckInPeriodType.不限.ToString() });
|
||||
|
||||
return di;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/***********************************************************************
|
||||
* 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.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using SqlSugar;
|
||||
|
||||
|
||||
namespace CoreCms.Net.IRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// 连续签到规则明细 工厂接口
|
||||
/// </summary>
|
||||
public interface ICoreCmsContinuousCheckInRuleDetailsRepository : IBaseRepository<CoreCmsContinuousCheckInRuleDetails>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/***********************************************************************
|
||||
* 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.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using SqlSugar;
|
||||
|
||||
|
||||
namespace CoreCms.Net.IRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// 连续签到规则 工厂接口
|
||||
/// </summary>
|
||||
public interface ICoreCmsContinuousCheckInRulesRepository : IBaseRepository<CoreCmsContinuousCheckInRules>
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
new Task<AdminUiCallBack> InsertAsync(List<CoreCmsContinuousCheckInRules> entity);
|
||||
|
||||
|
||||
#region 获取缓存的所有数据==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 获取缓存的所有数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<CoreCmsContinuousCheckInRules>> GetCaChe();
|
||||
|
||||
/// <summary>
|
||||
/// 更新cache
|
||||
/// </summary>
|
||||
Task<List<CoreCmsContinuousCheckInRules>> UpdateCaChe();
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
/***********************************************************************
|
||||
* 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.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using SqlSugar;
|
||||
|
||||
|
||||
namespace CoreCms.Net.IRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// 累计签到规则 工厂接口
|
||||
/// </summary>
|
||||
public interface ICoreCmsCumulativeCheckInRulesRepository : IBaseRepository<CoreCmsCumulativeCheckInRules>
|
||||
{
|
||||
#region 重写增删改查操作===========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
new Task<AdminUiCallBack> InsertAsync(CoreCmsCumulativeCheckInRules entity);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
new Task<AdminUiCallBack> InsertAsync(List<CoreCmsCumulativeCheckInRules> entity);
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
new Task<AdminUiCallBack> UpdateAsync(CoreCmsCumulativeCheckInRules entity);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
new Task<AdminUiCallBack> UpdateAsync(List<CoreCmsCumulativeCheckInRules> entity);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重写删除指定ID的数据
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
new Task<AdminUiCallBack> DeleteByIdAsync(object id);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重写删除指定ID集合的数据(批量删除)
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
new Task<AdminUiCallBack> DeleteByIdsAsync(int[] ids);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 获取缓存的所有数据==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 获取缓存的所有数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<CoreCmsCumulativeCheckInRules>> GetCaChe();
|
||||
|
||||
/// <summary>
|
||||
/// 更新cache
|
||||
/// </summary>
|
||||
Task<List<CoreCmsCumulativeCheckInRules>> UpdateCaChe();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
/// <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>
|
||||
new 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);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/***********************************************************************
|
||||
* 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.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using SqlSugar;
|
||||
|
||||
|
||||
namespace CoreCms.Net.IRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户签到明细表 工厂接口
|
||||
/// </summary>
|
||||
public interface ICoreCmsUserCheckInDetailsRepository : IBaseRepository<CoreCmsUserCheckInDetails>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/***********************************************************************
|
||||
* 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.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using SqlSugar;
|
||||
|
||||
|
||||
namespace CoreCms.Net.IRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户日历签到统计 工厂接口
|
||||
/// </summary>
|
||||
public interface ICoreCmsUserCheckInRepository : IBaseRepository<CoreCmsUserCheckIn>
|
||||
{
|
||||
/// <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>
|
||||
new 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);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/***********************************************************************
|
||||
* 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.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.IServices
|
||||
{
|
||||
/// <summary>
|
||||
/// 连续签到规则明细 服务工厂接口
|
||||
/// </summary>
|
||||
public interface ICoreCmsContinuousCheckInRuleDetailsServices : IBaseServices<CoreCmsContinuousCheckInRuleDetails>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/***********************************************************************
|
||||
* 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.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.IServices
|
||||
{
|
||||
/// <summary>
|
||||
/// 连续签到规则 服务工厂接口
|
||||
/// </summary>
|
||||
public interface ICoreCmsContinuousCheckInRulesServices : IBaseServices<CoreCmsContinuousCheckInRules>
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
new Task<AdminUiCallBack> InsertAsync(List<CoreCmsContinuousCheckInRules> entity);
|
||||
|
||||
|
||||
#region 获取缓存的所有数据==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 获取缓存的所有数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<CoreCmsContinuousCheckInRules>> GetCaChe();
|
||||
|
||||
/// <summary>
|
||||
/// 更新cache
|
||||
/// </summary>
|
||||
Task<List<CoreCmsContinuousCheckInRules>> UpdateCaChe();
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
/***********************************************************************
|
||||
* 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.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.IServices
|
||||
{
|
||||
/// <summary>
|
||||
/// 累计签到规则 服务工厂接口
|
||||
/// </summary>
|
||||
public interface ICoreCmsCumulativeCheckInRulesServices : IBaseServices<CoreCmsCumulativeCheckInRules>
|
||||
{
|
||||
#region 重写增删改查操作===========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
new Task<AdminUiCallBack> InsertAsync(CoreCmsCumulativeCheckInRules entity);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
new Task<AdminUiCallBack> InsertAsync(List<CoreCmsCumulativeCheckInRules> entity);
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
new Task<AdminUiCallBack> UpdateAsync(CoreCmsCumulativeCheckInRules entity);
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
new Task<AdminUiCallBack> UpdateAsync(List<CoreCmsCumulativeCheckInRules> entity);
|
||||
|
||||
/// <summary>
|
||||
/// 重写删除指定ID的数据
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
new Task<AdminUiCallBack> DeleteByIdAsync(object id);
|
||||
|
||||
/// <summary>
|
||||
/// 重写删除指定ID集合的数据(批量删除)
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
new Task<AdminUiCallBack> DeleteByIdsAsync(int[] ids);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 获取缓存的所有数据==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 获取缓存的所有数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<CoreCmsCumulativeCheckInRules>> GetCaChe();
|
||||
|
||||
/// <summary>
|
||||
/// 更新cache
|
||||
/// </summary>
|
||||
Task<List<CoreCmsCumulativeCheckInRules>> 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>
|
||||
new 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);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/***********************************************************************
|
||||
* 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.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.IServices
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户签到明细表 服务工厂接口
|
||||
/// </summary>
|
||||
public interface ICoreCmsUserCheckInDetailsServices : IBaseServices<CoreCmsUserCheckInDetails>
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 用户签到
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
Task<AdminUiCallBack> DoCheckIn(CoreCmsUserCheckInDetails entity);
|
||||
|
||||
}
|
||||
}
|
||||
51
CoreCms.Net.IServices/CheckIn/ICoreCmsUserCheckInServices.cs
Normal file
51
CoreCms.Net.IServices/CheckIn/ICoreCmsUserCheckInServices.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
/***********************************************************************
|
||||
* 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.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.Basics;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.IServices
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户日历签到统计 服务工厂接口
|
||||
/// </summary>
|
||||
public interface ICoreCmsUserCheckInServices : IBaseServices<CoreCmsUserCheckIn>
|
||||
{
|
||||
#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>
|
||||
new 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);
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 定时清理用户连续签到信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<AdminUiCallBack> ClearUserContinuousCheckIn();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2022/3/3 1:03:52
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using SqlSugar;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace CoreCms.Net.Model.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// 连续签到规则明细
|
||||
/// </summary>
|
||||
public partial class CoreCmsContinuousCheckInRuleDetails
|
||||
{
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
public CoreCmsContinuousCheckInRuleDetails()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 序列
|
||||
/// </summary>
|
||||
[Display(Name = "序列")]
|
||||
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
|
||||
[Required(ErrorMessage = "请输入{0}")]
|
||||
|
||||
|
||||
|
||||
public System.Int32 id { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 用户级别
|
||||
/// </summary>
|
||||
[Display(Name = "用户级别")]
|
||||
|
||||
[Required(ErrorMessage = "请输入{0}")]
|
||||
|
||||
|
||||
|
||||
public System.Int32 userGradeId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 连续签到规则序列
|
||||
/// </summary>
|
||||
[Display(Name = "连续签到规则序列")]
|
||||
|
||||
[Required(ErrorMessage = "请输入{0}")]
|
||||
|
||||
|
||||
|
||||
public System.Int32 ruleId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 数量
|
||||
/// </summary>
|
||||
[Display(Name = "数量")]
|
||||
|
||||
[Required(ErrorMessage = "请输入{0}")]
|
||||
|
||||
|
||||
|
||||
public System.Int32 num { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 积分1余额2
|
||||
/// </summary>
|
||||
[Display(Name = "积分1余额2")]
|
||||
|
||||
[Required(ErrorMessage = "请输入{0}")]
|
||||
|
||||
|
||||
|
||||
public System.Int32 type { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2022/3/3 1:03:58
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using SqlSugar;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace CoreCms.Net.Model.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// 连续签到规则
|
||||
/// </summary>
|
||||
public partial class CoreCmsContinuousCheckInRules
|
||||
{
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
public CoreCmsContinuousCheckInRules()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 序列
|
||||
/// </summary>
|
||||
[Display(Name = "序列")]
|
||||
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
|
||||
[Required(ErrorMessage = "请输入{0}")]
|
||||
|
||||
|
||||
|
||||
public System.Int32 id { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 天数
|
||||
/// </summary>
|
||||
[Display(Name = "天数")]
|
||||
|
||||
[Required(ErrorMessage = "请输入{0}")]
|
||||
|
||||
|
||||
|
||||
public System.Int32 days { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2022/3/3 1:03:58
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using SqlSugar;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace CoreCms.Net.Model.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// 连续签到规则
|
||||
/// </summary>
|
||||
public partial class CoreCmsContinuousCheckInRules
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 明细
|
||||
/// </summary>
|
||||
[Display(Name = "明细")]
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public List<CoreCmsContinuousCheckInRuleDetails> details { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2022/3/3 1:04:05
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using SqlSugar;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace CoreCms.Net.Model.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// 累计签到规则
|
||||
/// </summary>
|
||||
public partial class CoreCmsCumulativeCheckInRules
|
||||
{
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
public CoreCmsCumulativeCheckInRules()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 序列
|
||||
/// </summary>
|
||||
[Display(Name = "序列")]
|
||||
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
|
||||
[Required(ErrorMessage = "请输入{0}")]
|
||||
|
||||
|
||||
|
||||
public System.Int32 id { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 累计天数
|
||||
/// </summary>
|
||||
[Display(Name = "累计天数")]
|
||||
|
||||
[Required(ErrorMessage = "请输入{0}")]
|
||||
|
||||
|
||||
|
||||
public System.Int32 days { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 数量
|
||||
/// </summary>
|
||||
[Display(Name = "数量")]
|
||||
|
||||
[Required(ErrorMessage = "请输入{0}")]
|
||||
|
||||
|
||||
|
||||
public System.Int32 num { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 积分1余额2
|
||||
/// </summary>
|
||||
[Display(Name = "积分1余额2")]
|
||||
|
||||
[Required(ErrorMessage = "请输入{0}")]
|
||||
|
||||
|
||||
|
||||
public System.Int32 type { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
80
CoreCms.Net.Model/Entities/CheckIn/CoreCmsUserCheckIn.cs
Normal file
80
CoreCms.Net.Model/Entities/CheckIn/CoreCmsUserCheckIn.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2022/3/13 22:21:26
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using SqlSugar;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace CoreCms.Net.Model.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户日历签到统计
|
||||
/// </summary>
|
||||
public partial class CoreCmsUserCheckIn
|
||||
{
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
public CoreCmsUserCheckIn()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 序列
|
||||
/// </summary>
|
||||
[Display(Name = "序列")]
|
||||
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
|
||||
[Required(ErrorMessage = "请输入{0}")]
|
||||
|
||||
|
||||
|
||||
public System.Int32 id { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 用户序列
|
||||
/// </summary>
|
||||
[Display(Name = "用户序列")]
|
||||
|
||||
[Required(ErrorMessage = "请输入{0}")]
|
||||
|
||||
|
||||
|
||||
public System.Int32 userId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 连续签到次数
|
||||
/// </summary>
|
||||
[Display(Name = "连续签到次数")]
|
||||
|
||||
[Required(ErrorMessage = "请输入{0}")]
|
||||
|
||||
|
||||
|
||||
public System.Int32 continuousCheckInCount { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 累计签到次数
|
||||
/// </summary>
|
||||
[Display(Name = "累计签到次数")]
|
||||
|
||||
[Required(ErrorMessage = "请输入{0}")]
|
||||
|
||||
|
||||
|
||||
public System.Int32 cumulativeCheckInCount { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2022/3/9 0:59:03
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using SqlSugar;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace CoreCms.Net.Model.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户签到明细表
|
||||
/// </summary>
|
||||
public partial class CoreCmsUserCheckInDetails
|
||||
{
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
public CoreCmsUserCheckInDetails()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 序列
|
||||
/// </summary>
|
||||
[Display(Name = "序列")]
|
||||
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
|
||||
[Required(ErrorMessage = "请输入{0}")]
|
||||
|
||||
|
||||
|
||||
public System.Int32 id { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 用户序列
|
||||
/// </summary>
|
||||
[Display(Name = "用户序列")]
|
||||
|
||||
[Required(ErrorMessage = "请输入{0}")]
|
||||
|
||||
|
||||
|
||||
public System.Int32 userId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 打卡日期
|
||||
/// </summary>
|
||||
[Display(Name = "打卡日期")]
|
||||
|
||||
[Required(ErrorMessage = "请输入{0}")]
|
||||
|
||||
|
||||
|
||||
public System.DateTime checkInData { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 打卡时间
|
||||
/// </summary>
|
||||
[Display(Name = "打卡时间")]
|
||||
|
||||
[Required(ErrorMessage = "请输入{0}")]
|
||||
|
||||
|
||||
|
||||
public System.DateTime createTime { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
48
CoreCms.Net.Model/FromBody/FMCheckIn.cs
Normal file
48
CoreCms.Net.Model/FromBody/FMCheckIn.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
|
||||
namespace CoreCms.Net.Model.FromBody
|
||||
{
|
||||
/// <summary>
|
||||
/// 保存累计签到规则
|
||||
/// </summary>
|
||||
public class FMDoSaveCumulativeCheckInRules
|
||||
{
|
||||
public List<CoreCmsCumulativeCheckInRules> entity { set; get; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存连续签到规则
|
||||
/// </summary>
|
||||
public class FMDoSaveContinuousCheckInRules
|
||||
{
|
||||
public List<CoreCmsContinuousCheckInRules> entity { set; get; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 前端用户签到提交
|
||||
/// </summary>
|
||||
public class FMDoUserCheckIn
|
||||
{
|
||||
|
||||
public DateTime date { set; get; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 前端获取用户签到数据
|
||||
/// </summary>
|
||||
public class FMGetUserCheckInByMonth
|
||||
{
|
||||
public int year { set; get; }
|
||||
public int month { set; get; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1023,7 +1023,7 @@ namespace CoreCms.Net.Repository
|
||||
var totalCount = 0;
|
||||
var page = blUseNoLock
|
||||
? DbBaseClient.Queryable<T>().OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
|
||||
.WhereIF(predicate != null, predicate).Where(SqlWith.NoLock)
|
||||
.WhereIF(predicate != null, predicate).With(SqlWith.NoLock)
|
||||
.ToPageList(pageIndex, pageSize, ref totalCount)
|
||||
: DbClient.Queryable<T>().OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
|
||||
.WhereIF(predicate != null, predicate).ToPageList(pageIndex, pageSize, ref totalCount);
|
||||
@@ -1047,7 +1047,7 @@ namespace CoreCms.Net.Repository
|
||||
RefAsync<int> totalCount = 0;
|
||||
var page = blUseNoLock
|
||||
? await DbBaseClient.Queryable<T>().OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
|
||||
.WhereIF(predicate != null, predicate).Where(SqlWith.NoLock)
|
||||
.WhereIF(predicate != null, predicate).With(SqlWith.NoLock)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount)
|
||||
: await DbBaseClient.Queryable<T>().OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
|
||||
.WhereIF(predicate != null, predicate).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
@@ -1072,7 +1072,7 @@ namespace CoreCms.Net.Repository
|
||||
var totalCount = 0;
|
||||
var page = blUseNoLock
|
||||
? DbBaseClient.Queryable<T>().OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Where(SqlWith.NoLock)
|
||||
.WhereIF(predicate != null, predicate).With(SqlWith.NoLock)
|
||||
.ToPageList(pageIndex, pageSize, ref totalCount)
|
||||
: DbBaseClient.Queryable<T>().OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).ToPageList(pageIndex, pageSize, ref totalCount);
|
||||
@@ -1097,7 +1097,7 @@ namespace CoreCms.Net.Repository
|
||||
RefAsync<int> totalCount = 0;
|
||||
var page = blUseNoLock
|
||||
? await DbBaseClient.Queryable<T>().WhereIF(predicate != null, predicate).OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.Where(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount)
|
||||
.With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount)
|
||||
: await DbBaseClient.Queryable<T>().WhereIF(predicate != null, predicate).OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
var list = new PageList<T>(page, pageIndex, pageSize, totalCount);
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/***********************************************************************
|
||||
* 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.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 CoreCmsContinuousCheckInRuleDetailsRepository : BaseRepository<CoreCmsContinuousCheckInRuleDetails>, ICoreCmsContinuousCheckInRuleDetailsRepository
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
public CoreCmsContinuousCheckInRuleDetailsRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
/***********************************************************************
|
||||
* 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;
|
||||
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 CoreCmsContinuousCheckInRulesRepository : BaseRepository<CoreCmsContinuousCheckInRules>, ICoreCmsContinuousCheckInRulesRepository
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
public CoreCmsContinuousCheckInRulesRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> InsertAsync(List<CoreCmsContinuousCheckInRules> entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
//判断是否存在0天数或者0赠送
|
||||
var isHaveEnptyDaysOrNum = entity.Count(p => p.days <= 0);
|
||||
if (isHaveEnptyDaysOrNum > 0)
|
||||
{
|
||||
jm.msg = "【连续签到天数】不能为零";
|
||||
return jm;
|
||||
}
|
||||
|
||||
//判断是否存在相同的天数设置。
|
||||
var isHave = entity.GroupBy(i => i.days).Any(g => g.Count() > 1);
|
||||
if (isHave)
|
||||
{
|
||||
jm.msg = "存在相同的【连续签到天数】。请排查";
|
||||
return jm;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_unitOfWork.BeginTran();
|
||||
|
||||
//先清理掉数据,因为是配置数据,可直接删除添加新的
|
||||
await DbClient.Deleteable<CoreCmsContinuousCheckInRules>().Where(p => p.id > 0).ExecuteCommandAsync();
|
||||
await DbClient.Deleteable<CoreCmsContinuousCheckInRuleDetails>().Where(p => p.id > 0).ExecuteCommandAsync();
|
||||
|
||||
//遍历数据存值
|
||||
foreach (var item in entity)
|
||||
{
|
||||
var continuous = new CoreCmsContinuousCheckInRules
|
||||
{
|
||||
days = item.days
|
||||
};
|
||||
|
||||
var id = await DbClient.Insertable(continuous).ExecuteReturnIdentityAsync();
|
||||
if (id <= 0) continue;
|
||||
foreach (var detail in item.details)
|
||||
{
|
||||
detail.ruleId = id;
|
||||
}
|
||||
await DbClient.Insertable(item.details).ExecuteReturnIdentityAsync();
|
||||
}
|
||||
|
||||
_unitOfWork.CommitTran();
|
||||
|
||||
jm.code = 0;
|
||||
jm.msg = "更新成功";
|
||||
|
||||
await UpdateCaChe();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_unitOfWork.RollbackTran();
|
||||
jm.code = 1;
|
||||
jm.msg = "更新失败";
|
||||
jm.data = e;
|
||||
}
|
||||
return jm;
|
||||
}
|
||||
|
||||
|
||||
#region 获取缓存的所有数据==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 获取缓存的所有数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<CoreCmsContinuousCheckInRules>> GetCaChe()
|
||||
{
|
||||
var cache = ManualDataCache.Instance.Get<List<CoreCmsContinuousCheckInRules>>(GlobalConstVars.CacheCoreCmsContinuousCheckInRules);
|
||||
if (cache != null)
|
||||
{
|
||||
return cache;
|
||||
}
|
||||
return await UpdateCaChe();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新cache
|
||||
/// </summary>
|
||||
public async Task<List<CoreCmsContinuousCheckInRules>> UpdateCaChe()
|
||||
{
|
||||
var list = await DbClient.Queryable<CoreCmsContinuousCheckInRules>()
|
||||
.Select(p => new CoreCmsContinuousCheckInRules
|
||||
{
|
||||
id = p.id,
|
||||
days = p.days,
|
||||
})
|
||||
.Mapper(p => p.details, p => p.details.First().ruleId)
|
||||
.With(SqlWith.NoLock).ToListAsync();
|
||||
ManualDataCache.Instance.Set(GlobalConstVars.CacheCoreCmsContinuousCheckInRules, 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<CoreCmsContinuousCheckInRules>> QueryPageAsync(Expression<Func<CoreCmsContinuousCheckInRules, bool>> predicate,
|
||||
Expression<Func<CoreCmsContinuousCheckInRules, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsContinuousCheckInRules> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsContinuousCheckInRules>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsContinuousCheckInRules
|
||||
{
|
||||
id = p.id,
|
||||
days = p.days,
|
||||
|
||||
}).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsContinuousCheckInRules>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsContinuousCheckInRules
|
||||
{
|
||||
id = p.id,
|
||||
days = p.days,
|
||||
|
||||
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsContinuousCheckInRules>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
/***********************************************************************
|
||||
* 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.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 CoreCmsCumulativeCheckInRulesRepository : BaseRepository<CoreCmsCumulativeCheckInRules>, ICoreCmsCumulativeCheckInRulesRepository
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
public CoreCmsCumulativeCheckInRulesRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
#region 实现重写增删改查操作==========================================================
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步插入方法
|
||||
/// </summary>
|
||||
/// <param name="entity">实体数据</param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> InsertAsync(CoreCmsCumulativeCheckInRules 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> InsertAsync(List<CoreCmsCumulativeCheckInRules> entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var bl = await DbClient.Insertable(entity).ExecuteCommandAsync();
|
||||
jm.code = 0;
|
||||
jm.msg = GlobalConstVars.EditSuccess;
|
||||
await UpdateCaChe();
|
||||
return jm;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重写异步更新方法
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<AdminUiCallBack> UpdateAsync(CoreCmsCumulativeCheckInRules entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var oldModel = await DbClient.Queryable<CoreCmsCumulativeCheckInRules>().In(entity.id).SingleAsync();
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
//事物处理过程开始
|
||||
oldModel.id = entity.id;
|
||||
oldModel.days = entity.days;
|
||||
oldModel.num = entity.num;
|
||||
oldModel.type = entity.type;
|
||||
|
||||
//事物处理过程结束
|
||||
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<CoreCmsCumulativeCheckInRules> 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<CoreCmsCumulativeCheckInRules>(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<CoreCmsCumulativeCheckInRules>().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<CoreCmsCumulativeCheckInRules>> GetCaChe()
|
||||
{
|
||||
var cache = ManualDataCache.Instance.Get<List<CoreCmsCumulativeCheckInRules>>(GlobalConstVars.CacheCoreCmsCumulativeCheckInRules);
|
||||
if (cache != null)
|
||||
{
|
||||
return cache;
|
||||
}
|
||||
return await UpdateCaChe();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新cache
|
||||
/// </summary>
|
||||
public async Task<List<CoreCmsCumulativeCheckInRules>> UpdateCaChe()
|
||||
{
|
||||
var list = await DbClient.Queryable<CoreCmsCumulativeCheckInRules>().With(SqlWith.NoLock).ToListAsync();
|
||||
ManualDataCache.Instance.Set(GlobalConstVars.CacheCoreCmsCumulativeCheckInRules, 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<CoreCmsCumulativeCheckInRules>> QueryPageAsync(Expression<Func<CoreCmsCumulativeCheckInRules, bool>> predicate,
|
||||
Expression<Func<CoreCmsCumulativeCheckInRules, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsCumulativeCheckInRules> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsCumulativeCheckInRules>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsCumulativeCheckInRules
|
||||
{
|
||||
id = p.id,
|
||||
days = p.days,
|
||||
num = p.num,
|
||||
type = p.type,
|
||||
|
||||
}).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsCumulativeCheckInRules>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsCumulativeCheckInRules
|
||||
{
|
||||
id = p.id,
|
||||
days = p.days,
|
||||
num = p.num,
|
||||
type = p.type,
|
||||
|
||||
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsCumulativeCheckInRules>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/***********************************************************************
|
||||
* 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.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 CoreCmsUserCheckInDetailsRepository : BaseRepository<CoreCmsUserCheckInDetails>, ICoreCmsUserCheckInDetailsRepository
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
public CoreCmsUserCheckInDetailsRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/***********************************************************************
|
||||
* 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.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 CoreCmsUserCheckInRepository : BaseRepository<CoreCmsUserCheckIn>, ICoreCmsUserCheckInRepository
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
public CoreCmsUserCheckInRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
_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)
|
||||
{
|
||||
RefAsync<int> totalCount = 0;
|
||||
List<CoreCmsUserCheckIn> page;
|
||||
if (blUseNoLock)
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsUserCheckIn>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsUserCheckIn
|
||||
{
|
||||
id = p.id,
|
||||
userId = p.userId,
|
||||
continuousCheckInCount = p.continuousCheckInCount,
|
||||
cumulativeCheckInCount = p.cumulativeCheckInCount,
|
||||
|
||||
}).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = await DbClient.Queryable<CoreCmsUserCheckIn>()
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate).Select(p => new CoreCmsUserCheckIn
|
||||
{
|
||||
id = p.id,
|
||||
userId = p.userId,
|
||||
continuousCheckInCount = p.continuousCheckInCount,
|
||||
cumulativeCheckInCount = p.cumulativeCheckInCount,
|
||||
|
||||
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||
}
|
||||
var list = new PageList<CoreCmsUserCheckIn>(page, pageIndex, pageSize, totalCount);
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
38
CoreCms.Net.Task/ClearUserContinuousCheckInJob.cs
Normal file
38
CoreCms.Net.Task/ClearUserContinuousCheckInJob.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms.Net *
|
||||
* Web: https://CoreCms.Net *
|
||||
* ProjectName: 核心内容管理系统 *
|
||||
* Author: 大灰灰 *
|
||||
* Email: JianWeie@163.com *
|
||||
* CreateTime: 2020-08-25 1:25:29
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
using System;
|
||||
using CoreCms.Net.IServices;
|
||||
using CoreCms.Net.Loging;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
|
||||
namespace CoreCms.Net.Task
|
||||
{
|
||||
/// <summary>
|
||||
/// 定时清理用户连续签到信息
|
||||
/// </summary>
|
||||
public class ClearUserContinuousCheckInJob
|
||||
{
|
||||
private readonly ICoreCmsUserCheckInServices _checkInServices;
|
||||
|
||||
public ClearUserContinuousCheckInJob(ICoreCmsUserCheckInServices checkInServices)
|
||||
{
|
||||
_checkInServices = checkInServices;
|
||||
}
|
||||
|
||||
public async System.Threading.Tasks.Task Execute()
|
||||
{
|
||||
await _checkInServices.ClearUserContinuousCheckIn();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,6 +65,9 @@ namespace CoreCms.Net.Task
|
||||
//定时刷新获取微信AccessToken
|
||||
RecurringJob.AddOrUpdate<RefreshWeChatAccessTokenJob>(s => s.Execute(), "0 0/4 * * * ? ", TimeZoneInfo.Local); // 每2分钟刷新获取微信AccessToken
|
||||
|
||||
//定时清理用户连续签到信息
|
||||
RecurringJob.AddOrUpdate<ClearUserContinuousCheckInJob>(s => s.Execute(), "0 0 0 */1 * ? ", TimeZoneInfo.Local); // 每天0点执行。
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -134,10 +134,20 @@ const install = (Vue, vm) => {
|
||||
let pay = (params, config = {}) => http.post('/Api/User/Pay', params, { custom: { methodName: 'user.pay', needToken: true } });
|
||||
// 订单评价接口
|
||||
let orderEvaluate = (params, config = {}) => http.post('/Api/User/OrderEvaluate', params, { custom: { methodName: 'user.orderevaluate', needToken: true } });
|
||||
// 判断是否签到
|
||||
let isSign = (params, config = {}) => http.post('/Api/User/IsSign', params, { custom: { methodName: 'user.issign', needToken: true } });
|
||||
|
||||
// 判断是否签到(作废)
|
||||
//let isSign = (params, config = {}) => http.post('/Api/User/IsSign', params, { custom: { methodName: 'user.issign', needToken: true } });
|
||||
// 签到接口(作废)
|
||||
//let sign = (params, config = {}) => http.post('/Api/User/Sign', params, { custom: { methodName: 'user.sign', needToken: true } });
|
||||
|
||||
// 签到接口
|
||||
let sign = (params, config = {}) => http.post('/Api/User/Sign', params, { custom: { methodName: 'user.sign', needToken: true } });
|
||||
let userCheckIn = (params, config = {}) => http.post('/Api/CheckIn/DoUserCheckIn', params, { custom: { methodName: 'user.doUserCheckIn', needToken: true } });
|
||||
//获取用户按月签到数据
|
||||
let getUserCheckByMonth = (params, config = {}) => http.post('/Api/CheckIn/GetUserCheckByMonth', params, { custom: { methodName: 'user.getUserCheckByMonth', needToken: true } });
|
||||
//获取用户总签到次数
|
||||
let getUserCheckCount = (params, config = {}) => http.post('/Api/CheckIn/GetUserCheckCount', params, { custom: { methodName: 'user.getUserCheckCount', needToken: true } });
|
||||
|
||||
|
||||
// 积分记录
|
||||
let pointLog = (params, config = {}) => http.post('/Api/User/UserPointLog', params, { custom: { methodName: 'user.userpointlog', needToken: true } });
|
||||
// 物流信息接口
|
||||
@@ -456,8 +466,12 @@ const install = (Vue, vm) => {
|
||||
paymentInfo,
|
||||
pay,
|
||||
orderEvaluate,
|
||||
isSign,
|
||||
sign,
|
||||
//isSign,
|
||||
//sign,
|
||||
userCheckIn,
|
||||
getUserCheckByMonth,
|
||||
getUserCheckCount,
|
||||
|
||||
pointLog,
|
||||
logistics,
|
||||
couponList,
|
||||
|
||||
@@ -215,6 +215,7 @@
|
||||
"navigationBarTitleText": "打赏"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"path": "pages/template",
|
||||
"style": {
|
||||
@@ -290,6 +291,13 @@
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "接龙详情"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "checkIn/checkIn/checkIn",
|
||||
"style": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "日历签到"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
.bar { display: flex; flex-direction: row; justify-content: space-between; align-items: center; margin: 30rpx 20rpx; padding: 10rpx;
|
||||
.barbtn { height: 30px; line-height: 30px; font-size: 12px; }
|
||||
}
|
||||
.week { display: flex; flex-direction: row; justify-content: space-between; padding: 20rpx; padding-left: 40rpx; padding-right: 40rpx; margin: 20rpx; border-radius: 10px; background-color: #fff; }
|
||||
.myDateTable { margin: 2.5vw; padding: 2vw; border-radius: 10px; background: linear-gradient(#74AADA, #94db98);
|
||||
.dateCell { width: 11vw; margin: 1vw; display: inline-block; text-align: center; font-size: 16px;
|
||||
.cell { display: flex; border-radius: 50%; height: 11vw; justify-content: center; align-items: center; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.greenColor { color: #01b90b; font-weight: bold; }
|
||||
.bgWhite { background-color: #fff; }
|
||||
.bgGray { background-color: rgba(255, 255, 255, 0.42); }
|
||||
.bgBlue { font-size: 14px; background-color: #4b95e6; }
|
||||
.redColor { color: #ff0000; }
|
||||
|
||||
.TipArea { word-break: break-all; word-wrap: break-word; font-size: 14px; padding: 10px; }
|
||||
.impTip { display: inline-block; color: #ff0000; }
|
||||
|
||||
|
||||
|
||||
.count { margin: 20rpx; padding: 30rpx; display: flex; text-align: center; border-radius: 10px; flex-direction: column; justify-content: center; align-items: center;
|
||||
.daynumber { display: flex; flex-direction: row; justify-content: center;
|
||||
.day { margin-top: 50rpx; }
|
||||
.number { color: #fff; font-size: 60rpx; background-color: #94db98; width: 100rpx; height: 100rpx; border-radius: 50%; display: flex; flex-direction: column; justify-content: center; margin: 20rpx; }
|
||||
}
|
||||
.monthSum { color: red; font-size: 40rpx; }
|
||||
}
|
||||
|
||||
|
||||
.count text { margin: 10rpx; }
|
||||
@@ -0,0 +1,307 @@
|
||||
<template>
|
||||
<!-- 打卡日历页面 -->
|
||||
<view>
|
||||
<u-toast ref="uToast" /><u-no-network></u-no-network>
|
||||
<u-navbar title="日历签到" safeAreaInsetTop fixed placeholder>
|
||||
<view class="coreshop-navbar-left-slot" slot="left">
|
||||
<u-icon name="arrow-left" size="19" @click="goNavigateBack"></u-icon>
|
||||
<u-line direction="column" :hairline="false" length="16" margin="0 8px"></u-line>
|
||||
<u-icon name="home" size="22" @click="goHome"></u-icon>
|
||||
</view>
|
||||
<view slot="right">
|
||||
</view>
|
||||
</u-navbar>
|
||||
|
||||
<view class="bar">
|
||||
<!-- 上一个月 -->
|
||||
<view class="previous" @click="handleCalendar(0)">
|
||||
<button class="barbtn" v-if="langType=='ch'">上一月</button>
|
||||
<button class="barbtn" v-else>Last</button>
|
||||
</view>
|
||||
<!-- 显示年月 -->
|
||||
<view class="date">{{cur_year || "--"}} 年 {{cur_month || "--"}} 月</view>
|
||||
<!-- 下一个月 -->
|
||||
<view class="next" @click="handleCalendar(1)">
|
||||
<button class="barbtn" v-if="langType=='ch'">下一月</button>
|
||||
<button class="barbtn" v-else>Next</button>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 显示星期 -->
|
||||
<view class="week" v-if="langType=='ch'">
|
||||
<view v-for="(item,index) in weeks_ch" :key="index">{{item}}</view>
|
||||
</view>
|
||||
<view class="week" v-else>
|
||||
<view v-for="(item,index) in weeks_en" :key="index">{{item}}</view>
|
||||
</view>
|
||||
<view class="myDateTable">
|
||||
<view v-for="(item,j) in days" :key="j" class='dateCell'>
|
||||
<view v-if="item.date==undefined||item.date == null" class='cell'>
|
||||
<text :decode="true"> </text>
|
||||
</view>
|
||||
<view v-else>
|
||||
<!-- 已签到日期 -->
|
||||
<view v-if="item.isSign == true" class='cell greenColor bgWhite '>
|
||||
<text>{{item.date}}</text>
|
||||
</view>
|
||||
<!-- 漏签 -->
|
||||
<view @click="clickSignUp(item.date,0)" class="cell redColor bgGray"
|
||||
v-else-if="cur_year<toYear||(cur_year==toYear&&cur_month<toMonth)||(cur_year==toYear&&cur_month==toMonth&&item.date<today)">
|
||||
<!-- 小程序不兼容这个 v-else-if="(new Date(cur_year+'-'+cur_month+'-'+item.date))<(new Date())"> -->
|
||||
<text>{{item.date}}</text>
|
||||
</view>
|
||||
<!-- 今日未签到-->
|
||||
<view @click="clickSignUp(item.date,1)" class="cell coreshop-text-white bgBlue" v-else-if="item.date==today&&cur_month==toMonth&&cur_year==toYear">
|
||||
<text>签到</text>
|
||||
</view>
|
||||
<!-- 当前日期之后 -->
|
||||
<view class="coreshop-text-white cell" v-else>
|
||||
<text>{{item.date}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
<!--<view class="TipArea ">
|
||||
坚持签到<view class="impTip">可获得积分和余额</view>
|
||||
</view>-->
|
||||
|
||||
<view class='count'>
|
||||
<text>截至目前,已坚持打卡</text>
|
||||
<view class='daynumber'>
|
||||
<text class='number'>{{sumCount}}</text>
|
||||
<text class='day'>天</text>
|
||||
</view>
|
||||
|
||||
<view>本月累积打卡<text class="monthSum">{{dataSource.length}}</text>天</view>
|
||||
<text>请再接再厉,继续努力!</text>
|
||||
</view>
|
||||
|
||||
<!-- 登录提示 -->
|
||||
<coreshop-login-modal></coreshop-login-modal>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapMutations, mapActions, mapState } from 'vuex';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
days: [],
|
||||
SignUp: [],
|
||||
cur_year: 0, //当前选的年
|
||||
cur_month: 0, //当前选的月
|
||||
today: parseInt(new Date().getDate()), //本日
|
||||
toMonth: parseInt(new Date().getMonth() + 1), //本月
|
||||
toYear: parseInt(new Date().getFullYear()), //本年
|
||||
weeks_ch: ['日', '一', '二', '三', '四', '五', '六'],
|
||||
weeks_en: ['Sun', 'Mon', 'Tues', 'Wed', 'Thur', 'Fri', 'Sat'],
|
||||
dataSource: [], //已签到的数据源
|
||||
langType: 'ch',//只是示例一个翻译而已,要想所有都翻译自己可以再加加
|
||||
sumCount: 0,
|
||||
signData: []
|
||||
};
|
||||
},
|
||||
onLoad() {
|
||||
var checkInIsOpen = this.$store.state.config.checkInIsOpen;
|
||||
if (checkInIsOpen == 2) {
|
||||
console.log('签到功能未开启');
|
||||
this.$refs.uToast.show({
|
||||
message: "签到功能未开启", type: 'error', complete: function () {
|
||||
uni.navigateBack({
|
||||
delta: 1
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.getUserCheckByMonth(this.cur_year, this.cur_month);
|
||||
this.getUserCheckCount();
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.cur_year = new Date().getFullYear();
|
||||
this.cur_month = new Date().getMonth() + 1;
|
||||
this.SignUp = this.dataSource;
|
||||
|
||||
this.calculateEmptyGrids(this.cur_year, this.cur_month);
|
||||
this.calculateDays(this.cur_year, this.cur_month);
|
||||
this.onJudgeSign();
|
||||
},
|
||||
watch: {
|
||||
dataSource: 'onResChange',
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
hasLogin: state => state.hasLogin,
|
||||
userInfo: state => state.userInfo,
|
||||
}),
|
||||
|
||||
},
|
||||
methods: {
|
||||
getUserCheckCount() {
|
||||
this.$u.api.getUserCheckCount().then(res => {
|
||||
console.log(res);
|
||||
if (res.status) {
|
||||
this.sumCount = res.data;
|
||||
} else {
|
||||
this.$refs.uToast.show({ message: res.msg, type: 'error', back: false })
|
||||
}
|
||||
});
|
||||
},
|
||||
getUserCheckByMonth(cur_year, cur_month) {
|
||||
this.$refs.uToast.show({
|
||||
loading: false, type: 'loading',
|
||||
title: '正在加载',
|
||||
message: "正在加载",
|
||||
duration: 1000
|
||||
})
|
||||
this.$u.api.getUserCheckByMonth({
|
||||
year: cur_year,
|
||||
month: cur_month,
|
||||
}).then(res => {
|
||||
console.log(res);
|
||||
if (res.status) {
|
||||
this.dataSource = res.data;
|
||||
} else {
|
||||
this.$refs.uToast.show({ message: res.msg, type: 'error', back: false })
|
||||
}
|
||||
});
|
||||
},
|
||||
goLogin() {
|
||||
this.$store.commit('showLoginTip', true);
|
||||
},
|
||||
// 获取当月共多少天
|
||||
getThisMonthDays(year, month) {
|
||||
return new Date(year, month, 0).getDate()
|
||||
},
|
||||
// 获取当月第一天星期几
|
||||
getFirstDayOfWeek(year, month) {
|
||||
return new Date(Date.UTC(year, month - 1, 1)).getDay();
|
||||
},
|
||||
// 计算当月1号前空了几个格子,把它填充在days数组的前面
|
||||
calculateEmptyGrids(year, month) {
|
||||
//计算每个月时要清零
|
||||
this.days = [];
|
||||
const firstDayOfWeek = this.getFirstDayOfWeek(year, month);
|
||||
if (firstDayOfWeek > 0) {
|
||||
for (let i = 0; i < firstDayOfWeek; i++) {
|
||||
var obj = {
|
||||
date: null,
|
||||
isSign: false
|
||||
}
|
||||
this.days.push(obj);
|
||||
}
|
||||
}
|
||||
},
|
||||
// 绘制当月天数占的格子,并把它放到days数组中
|
||||
calculateDays(year, month) {
|
||||
const thisMonthDays = this.getThisMonthDays(year, month);
|
||||
// this.columnsLen=Math.ceil(thisMonthDays/7);
|
||||
// console.log(this.columnsLen);
|
||||
for (let i = 1; i <= thisMonthDays; i++) {
|
||||
var obj = {
|
||||
date: i,
|
||||
isSign: false
|
||||
}
|
||||
this.days.push(obj);
|
||||
}
|
||||
//console.log(this.days);
|
||||
},
|
||||
onResChange(newD, oldD) {
|
||||
this.SignUp = newD;
|
||||
this.onJudgeSign();
|
||||
},
|
||||
//匹配判断当月与当月哪些日子签到打卡
|
||||
onJudgeSign() {
|
||||
var signs = this.SignUp;
|
||||
var daysArr = this.days;
|
||||
for (var i = 0; i < signs.length; i++) {
|
||||
var current = new Date(signs[i].replace(/-/g, "/"));
|
||||
var year = current.getFullYear();
|
||||
var month = current.getMonth() + 1;
|
||||
var day = current.getDate();
|
||||
day = parseInt(day);
|
||||
for (var j = 0; j < daysArr.length; j++) {
|
||||
//年月日相同则打卡成功
|
||||
if (year == this.cur_year && month == this.cur_month && daysArr[j].date == day) { //&& signs[i].isSign == "今日已打卡"
|
||||
// console.log(daysArr[j].date, day);
|
||||
daysArr[j].isSign = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.days = daysArr;
|
||||
},
|
||||
// 切换控制年月,上一个月,下一个月
|
||||
handleCalendar(type) {
|
||||
const cur_year = parseInt(this.cur_year);
|
||||
const cur_month = parseInt(this.cur_month);
|
||||
var newMonth;
|
||||
var newYear = cur_year;
|
||||
if (type === 0) { //上个月
|
||||
newMonth = cur_month - 1;
|
||||
if (newMonth < 1) {
|
||||
newYear = cur_year - 1;
|
||||
newMonth = 12;
|
||||
}
|
||||
} else {
|
||||
newMonth = cur_month + 1;
|
||||
if (newMonth > 12) {
|
||||
newYear = cur_year + 1;
|
||||
newMonth = 1;
|
||||
}
|
||||
}
|
||||
this.calculateEmptyGrids(newYear, newMonth);
|
||||
this.calculateDays(newYear, newMonth);
|
||||
|
||||
this.cur_year = newYear;
|
||||
this.cur_month = newMonth;
|
||||
|
||||
this.SignUp = []; //先清空
|
||||
|
||||
this.getUserCheckByMonth(this.cur_year, this.cur_month);
|
||||
|
||||
//this.$emit('dateChange', this.cur_year + "-" + this.cur_month); //传给调用模板页面去拿新数据
|
||||
},
|
||||
clickSignUp(date, type) { //type=0补签,type=1当日签到
|
||||
var _this = this;
|
||||
if (!this.hasLogin) {
|
||||
this.$store.commit('showLoginTip', true);
|
||||
return false;
|
||||
} else {
|
||||
//如果不需要补签功能直接在这阻止不执行后面的代码就行。
|
||||
if (type == 0) {
|
||||
//return false;
|
||||
}
|
||||
var postDate = this.cur_year + "-" + this.cur_month + "-" + date;
|
||||
this.$u.api.userCheckIn({
|
||||
date: postDate,
|
||||
}).then(res => {
|
||||
console.log(res);
|
||||
if (res.status) {
|
||||
uni.showToast({
|
||||
title: "签到成功",
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
});
|
||||
//this.SignUp.push(this.cur_year + "-" + this.cur_month + "-" + date);
|
||||
_this.dataSource.push(this.cur_year + "-" + this.cur_month + "-" + date);
|
||||
console.log(_this.dataSource);
|
||||
//_this.SignUp = _this.dataSource;
|
||||
if (res.data) {
|
||||
_this.sumCount = res.data.cumulativeCheckInCount;
|
||||
}
|
||||
|
||||
_this.onJudgeSign();
|
||||
} else {
|
||||
this.$refs.uToast.show({ message: res.msg, type: 'error', back: false })
|
||||
}
|
||||
});
|
||||
this.$forceUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@import "checkIn.scss";
|
||||
</style>
|
||||
@@ -356,6 +356,12 @@
|
||||
router: '/pages/activity/solitaire/list/list',
|
||||
showItem: true
|
||||
},
|
||||
calendar: {
|
||||
name: '日历签到',
|
||||
icon: 'calendar',
|
||||
router: '/pages/activity/checkIn/checkIn/checkIn',
|
||||
showItem: true
|
||||
},
|
||||
},
|
||||
other: {
|
||||
invite: {
|
||||
|
||||
@@ -62,6 +62,9 @@ namespace CoreCms.Net.Utility.Helper
|
||||
case (int)GlobalEnumVars.UserBalanceSourceTypes.Service:
|
||||
str += "购买服务消费了" + money + "元";
|
||||
break;
|
||||
case (int)GlobalEnumVars.UserBalanceSourceTypes.CheckIn:
|
||||
str += "日历签到奖励" + money + "元";
|
||||
break;
|
||||
}
|
||||
//::todo 这里还可以做一些其他的校验
|
||||
return str;
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.Filter;
|
||||
using CoreCms.Net.IServices;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.FromBody;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.Utility.Helper;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Web.Admin.Controllers.Shop
|
||||
{
|
||||
/// <summary>
|
||||
/// 日历签到设置
|
||||
/// </summary>
|
||||
[Description("日历签到设置")]
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
[RequiredErrorForAdmin]
|
||||
[Authorize(Permissions.Name)]
|
||||
public class CoreCmsCheckInController : ControllerBase
|
||||
{
|
||||
|
||||
private readonly ICoreCmsSettingServices _coreCmsSettingServices;
|
||||
private readonly ICoreCmsUserGradeServices _coreCmsUserGradeServices;
|
||||
private readonly ICoreCmsContinuousCheckInRuleDetailsServices _coreCmsContinuousCheckInRuleDetailsServices;
|
||||
private readonly ICoreCmsContinuousCheckInRulesServices _coreCmsContinuousCheckInRulesServices;
|
||||
private readonly ICoreCmsCumulativeCheckInRulesServices _coreCmsCumulativeCheckInRulesServices;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
public CoreCmsCheckInController(ICoreCmsSettingServices coreCmsSettingServices, ICoreCmsUserGradeServices coreCmsUserGradeServices, ICoreCmsContinuousCheckInRuleDetailsServices coreCmsContinuousCheckInRuleDetailsServices, ICoreCmsContinuousCheckInRulesServices coreCmsContinuousCheckInRulesServices, ICoreCmsCumulativeCheckInRulesServices coreCmsCumulativeCheckInRulesServices)
|
||||
{
|
||||
_coreCmsSettingServices = coreCmsSettingServices;
|
||||
_coreCmsUserGradeServices = coreCmsUserGradeServices;
|
||||
_coreCmsContinuousCheckInRuleDetailsServices = coreCmsContinuousCheckInRuleDetailsServices;
|
||||
_coreCmsContinuousCheckInRulesServices = coreCmsContinuousCheckInRulesServices;
|
||||
_coreCmsCumulativeCheckInRulesServices = coreCmsCumulativeCheckInRulesServices;
|
||||
}
|
||||
|
||||
|
||||
#region 首页数据============================================================
|
||||
// POST: Api/CoreCmsSetting/GetIndex
|
||||
/// <summary>
|
||||
/// 首页数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("首页数据")]
|
||||
public async Task<AdminUiCallBack> GetIndex()
|
||||
{
|
||||
//返回数据
|
||||
var jm = new AdminUiCallBack { code = 0 };
|
||||
var configs = await _coreCmsSettingServices.GetConfigDictionaries();
|
||||
var filesStorageOptionsType = EnumHelper.EnumToList<GlobalEnumVars.FilesStorageOptionsType>();
|
||||
var userGrade = await _coreCmsUserGradeServices.QueryAsync();
|
||||
|
||||
//连续签到规则
|
||||
var continuousCheckInRules = await _coreCmsContinuousCheckInRulesServices.GetCaChe();
|
||||
|
||||
//累计签到规则
|
||||
var cumulativeCheckInRules = await _coreCmsCumulativeCheckInRulesServices.GetCaChe();
|
||||
|
||||
jm.data = new
|
||||
{
|
||||
configs,
|
||||
filesStorageOptionsType,
|
||||
userGrade,
|
||||
continuousCheckInRules,
|
||||
cumulativeCheckInRules
|
||||
};
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 保存提交============================================================
|
||||
// POST: Api/CoreCmsSetting/DoSave
|
||||
/// <summary>
|
||||
/// 保存提交
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("保存提交")]
|
||||
public async Task<AdminUiCallBack> DoSave([FromBody] FMCoreCmsSettingDoSaveModel model)
|
||||
{
|
||||
var jm = await _coreCmsSettingServices.UpdateAsync(model);
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 保存累计签到规则============================================================
|
||||
// POST: Api/CoreCmsSetting/DoSave
|
||||
/// <summary>
|
||||
/// 保存累计签到规则
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("保存累计签到规则")]
|
||||
public async Task<AdminUiCallBack> DoSaveCumulativeCheckInRules([FromBody] FMDoSaveCumulativeCheckInRules entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
if (!entity.entity.Any())
|
||||
{
|
||||
jm.msg = "请提交数据";
|
||||
return jm;
|
||||
}
|
||||
|
||||
//判断是否存在0天数或者0赠送
|
||||
var isHaveEnptyDaysOrNum = entity.entity.Count(p => p.days <= 0 || p.num <= 0);
|
||||
if (isHaveEnptyDaysOrNum > 0)
|
||||
{
|
||||
jm.msg = "累计签到天数或赠送数量不能为零";
|
||||
return jm;
|
||||
}
|
||||
|
||||
//判断是否存在相同的天数设置。
|
||||
var isHave = entity.entity.GroupBy(i => i.days).Any(g => g.Count() > 1);
|
||||
if (isHave)
|
||||
{
|
||||
jm.msg = "存在相同的累计签到天数。请排查";
|
||||
return jm;
|
||||
}
|
||||
|
||||
//先清理掉数据,因为是配置数据,可直接删除添加新的
|
||||
var doEnpty = await _coreCmsCumulativeCheckInRulesServices.DeleteAsync(p => p.id > 0);
|
||||
|
||||
//插入新的数据
|
||||
|
||||
var insertCount = await _coreCmsCumulativeCheckInRulesServices.InsertAsync(entity.entity);
|
||||
jm.code = 0;
|
||||
jm.msg = "保存成功";
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 保存连续签到规则============================================================
|
||||
// POST: Api/CoreCmsSetting/DoSave
|
||||
/// <summary>
|
||||
/// 保存连续签到规则
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("保存连续签到规则")]
|
||||
public async Task<AdminUiCallBack> DoSaveContinuousCheckInRules([FromBody] FMDoSaveContinuousCheckInRules entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
if (entity.entity.Any()) return await _coreCmsContinuousCheckInRulesServices.InsertAsync(entity.entity);
|
||||
jm.msg = "请提交数据";
|
||||
return jm;
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
517
CoreCms.Net.Web.Admin/wwwroot/views/shop/checkin/index.html
Normal file
517
CoreCms.Net.Web.Admin/wwwroot/views/shop/checkin/index.html
Normal file
@@ -0,0 +1,517 @@
|
||||
<title>标题</title>
|
||||
<!--当前位置开始-->
|
||||
<div class="layui-card layadmin-header">
|
||||
<div class="layui-breadcrumb" lay-filter="breadcrumb">
|
||||
<script type="text/html" template lay-done="layui.data.updateMainBreadcrumb();">
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
<!--当前位置结束-->
|
||||
<style>
|
||||
/* 重写样式 */
|
||||
.layui-form-item label { width: 140px; }
|
||||
.classifyimg { margin-bottom: 20px; width: 672px !important; }
|
||||
.classifyimg-item { display: inline-block; width: 140px; }
|
||||
.classifyimg img { width: 100px; display: block; }
|
||||
.classifyimg .layui-form-radio { vertical-align: top; display: block; margin-bottom: 10px; }
|
||||
.image_storage_type .item { display: none; }
|
||||
.layui-elem-quote { margin: 10px; }
|
||||
.layui-tab-content { padding: 15px; }
|
||||
.layui-form-pane .layui-form-label { padding: 8px 5px; }
|
||||
</style>
|
||||
<script type="text/html" template lay-type="Post" lay-url="{{ layui.setter.apiUrl }}Api/CoreCmsCheckIn/GetIndex" lay-done="layui.data.done(d);">
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-row layui-col-space15">
|
||||
<div class="layui-col-md12">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-tab layui-tab-card" lay-filter="setting">
|
||||
<ul class="layui-tab-title">
|
||||
<li lay-id="checkInSet" class="layui-this">签到设置</li>
|
||||
<li lay-id="continuousCheckInRules">连续签到规则</li>
|
||||
<li lay-id="cumulativeCheckInRules">累计签到规则</li>
|
||||
</ul>
|
||||
<div class="layui-tab-content">
|
||||
<div class="layui-tab-item layui-show">
|
||||
<div class="layui-form coreshop-form layui-form-pane">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">{{d.data.configs['checkInIsOpen']['sKey']}}</label>
|
||||
<div class="layui-input-inline layui-inline-7">
|
||||
<input type="radio" lay-verify="required" name="checkInIsOpen" value="1" title="开启" {{d.data.configs['checkInIsOpen']['sValue']==="1" ? 'checked':''}}>
|
||||
<input type="radio" lay-verify="required" name="checkInIsOpen" value="2" title="不开启" {{d.data.configs['checkInIsOpen']['sValue']==="2" ? 'checked':''}}>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">{{d.data.configs['checkInIsAlert']['sKey']}}</label>
|
||||
<div class="layui-input-inline layui-inline-7">
|
||||
<input type="radio" lay-verify="required" name="checkInIsAlert" value="1" title="开启" {{d.data.configs['checkInIsAlert']['sValue']==="1" ? 'checked':''}}>
|
||||
<input type="radio" lay-verify="required" name="checkInIsAlert" value="2" title="不开启" {{d.data.configs['checkInIsAlert']['sValue']==="2" ? 'checked':''}}>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">{{d.data.configs['checkInAlertTime']['sKey']}}</label>
|
||||
<div class="layui-input-inline layui-inline-2">
|
||||
<input type="text" id="checkInAlertTime" name="checkInAlertTime" value="{{d.data.configs['checkInAlertTime']['sValue']}}" lay-verify="required" autocomplete="off" placeholder="" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux">点击选择时间</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">{{d.data.configs['checkInCommonNum']['sKey']}}</label>
|
||||
<div class="layui-input-inline layui-inline-2">
|
||||
<input type="number" name="checkInCommonNum" value="{{d.data.configs['checkInCommonNum']['sValue']}}" lay-verify="required|number" autocomplete="off" placeholder="" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-input-inline layui-inline-4">
|
||||
<input type="radio" lay-filter="checkInCommonType" name="checkInCommonType" value="1" title="积分" {{d.data.configs['checkInCommonType']['sValue']==="1" ? 'checked':''}}>
|
||||
<input type="radio" lay-filter="checkInCommonType" name="checkInCommonType" value="2" title="余额" {{d.data.configs['checkInCommonType']['sValue']==="2" ? 'checked':''}}>
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux">每天签到赠送</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">{{d.data.configs['continuousCheckInPeriodType']['sKey']}}</label>
|
||||
<div class="layui-input-inline layui-inline-7">
|
||||
<input type="radio" lay-filter="continuousCheckInPeriodType" name="continuousCheckInPeriodType" value="0" title="不限" {{d.data.configs['continuousCheckInPeriodType']['sValue']==="0" ? 'checked':''}}>
|
||||
<input type="radio" lay-filter="continuousCheckInPeriodType" name="continuousCheckInPeriodType" value="1" title="每周末" {{d.data.configs['continuousCheckInPeriodType']['sValue']==="1" ? 'checked':''}}>
|
||||
<input type="radio" lay-filter="continuousCheckInPeriodType" name="continuousCheckInPeriodType" value="2" title="每月末" {{d.data.configs['continuousCheckInPeriodType']['sValue']==="2" ? 'checked':''}}>
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux">清除连续签到次数</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" lay-submit="" lay-filter="save">保存更改</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-tab-item">
|
||||
<div class="layui-form coreshop-form layui-form-pane">
|
||||
<blockquote class="layui-elem-quote">
|
||||
连续签到【连续签到额外送XX积分或余额,只要达到要求才能领取奖励,每个连续时间内只能领取一次连续签到奖励】
|
||||
</blockquote>
|
||||
<div id="continuousCheckInBox">
|
||||
{{# layui.each(d.data.continuousCheckInRules, function(index, item){ }}
|
||||
<div class="continuousCheckInBox coreshop-solid" data-id="{{index}}">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">连续签到天数</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="hidden" id="id" name="continuousCheckInRules.id[{{index}}]" value="{{item.id}}">
|
||||
<input type="number" id="days" name="continuousCheckInRules.days[{{index}}]" value="{{item.days}}" lay-verify="required|number" autocomplete="off" placeholder="" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
|
||||
<legend>会员组设置</legend>
|
||||
</fieldset>
|
||||
{{# layui.each(item.details, function(indexChild, itemChild){ }}
|
||||
<div class="layui-form-item listItems">
|
||||
<input type="hidden" id="detailsId" name="continuousCheckInRules.details[{{index}}].id[{{indexChild}}]" value="{{itemChild.id}}">
|
||||
<input type="hidden" id="detailsUserGradeId" name="continuousCheckInRules.details[{{index}}].userGradeId[{{indexChild}}]" value="{{itemChild.userGradeId}}">
|
||||
<input type="hidden" id="detailsRuleId" name="continuousCheckInRules.details[{{index}}].ruleId[{{indexChild}}]" value="{{itemChild.ruleId}}">
|
||||
<label class="layui-form-label">
|
||||
{{# layui.each(d.data.userGrade, function(indexGrade, itemGrade){ }}
|
||||
{{# if(itemChild.userGradeId === itemGrade.id){ }}
|
||||
{{ itemGrade.title }}
|
||||
{{# } }}
|
||||
{{# }); }}
|
||||
</label>
|
||||
<div class="layui-input-inline layui-inline-2">
|
||||
<input type="number" id="detailsNum" name="continuousCheckInRules.details[{{index}}].num[{{indexChild}}]" value="{{itemChild.num}}" lay-verify="required|number" autocomplete="off" placeholder="" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-input-inline layui-inline-4">
|
||||
<input type="radio" id="detailsType" name="continuousCheckInRules.details[{{index}}].type[{{indexChild}}]" value="1" title="积分" {{itemChild.type==1?'checked="checked"':''}}>
|
||||
<input type="radio" id="detailsType" name="continuousCheckInRules.details[{{index}}].type[{{indexChild}}]" value="2" title="余额" {{itemChild.type==2?'checked="checked"':''}}>
|
||||
</div>
|
||||
</div>
|
||||
{{# }); }}
|
||||
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm btn-continuous-delete">
|
||||
<i class="layui-icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
{{# }); }}
|
||||
<input id="continuousCheckInRulesCount" type="hidden" value="{{d.data.continuousCheckInRules.length}}" />
|
||||
</div>
|
||||
<div class="layui-form-item" style="margin-left: 50px;">
|
||||
<button type="button" class="layui-btn layui-btn-primary layui-btn-sm btn-continuous-add">
|
||||
<i class="layui-icon"></i>新增规则
|
||||
</button>
|
||||
</div>
|
||||
<div class="layui-form-item text-center">
|
||||
<button class="layui-btn" lay-submit="" lay-filter="saveCoreCmsContinuousCheckInRules">保存更改</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-tab-item">
|
||||
<div class="layui-form coreshop-form layui-form-pane">
|
||||
<blockquote class="layui-elem-quote">
|
||||
累计签到【累计签到额外送XX积分或余额,只送一次】
|
||||
</blockquote>
|
||||
<div id="cumulativeCheckInBox">
|
||||
{{# layui.each(d.data.cumulativeCheckInRules, function(index, item){ }}
|
||||
<div class="cumulativeCheckInBox coreshop-solid">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">累计签到天数</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="hidden" id="id" name="id[{{index}}]" value="{{item.id}}">
|
||||
<input type="number" id="days" name="days[{{index}}]" value="{{item.days}}" lay-verify="required|number" autocomplete="off" placeholder="" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">赠送数量</label>
|
||||
<div class="layui-input-inline layui-inline-2">
|
||||
<input type="number" id="num" name="num[{{index}}]" value="{{item.num}}" lay-verify="required|number" autocomplete="off" placeholder="" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-input-inline layui-inline-4">
|
||||
<input type="radio" id="type" name="type[{{index}}]" value="1" title="积分" {{item.type==1?'checked="checked"':''}}>
|
||||
<input type="radio" id="type" name="type[{{index}}]" value="2" title="余额" {{item.type==2?'checked="checked"':''}}>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm btn-delete">
|
||||
<i class="layui-icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
{{# }); }}
|
||||
<input id="cumulativeCheckInRulesCount" type="hidden" value="{{d.data.cumulativeCheckInRules.length}}" />
|
||||
</div>
|
||||
<div class="layui-form-item" style="margin-left: 50px;">
|
||||
<button type="button" class="layui-btn layui-btn-primary layui-btn-sm btn-add">
|
||||
<i class="layui-icon"></i>新增规则
|
||||
</button>
|
||||
</div>
|
||||
<div class="layui-form-item text-center">
|
||||
<button class="layui-btn" lay-submit="" lay-filter="saveCumulativeCheckInRules">保存更改</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
|
||||
<script id="continuousCheckInBoxTmp" type="text/html">
|
||||
<div class="continuousCheckInBox coreshop-solid" data-id="{{d.index}}">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">累计签到天数</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="hidden" id="id" name="continuousCheckInRules.id[{{d.index}}]" value="0">
|
||||
<input type="number" id="days" name="continuousCheckInRules.days[{{d.index}}]" value="100" lay-verify="required|number" autocomplete="off" placeholder="" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
|
||||
<legend>会员组设置</legend>
|
||||
</fieldset>
|
||||
{{# layui.each(d.userGrade, function(index, item){ }}
|
||||
<div class="layui-form-item listItems">
|
||||
<input type="hidden" id="detailsId" name="continuousCheckInRules.details[{{d.index}}].id[{{index}}]" value="0">
|
||||
<input type="hidden" id="detailsUserGradeId" name="continuousCheckInRules.details[{{d.index}}].userGradeId[{{index}}]" value="{{item.id}}">
|
||||
<input type="hidden" id="detailsRuleId" name="continuousCheckInRules.details[{{d.index}}].ruleId[{{index}}]" value="0">
|
||||
<label class="layui-form-label">{{ item.title }}</label>
|
||||
<div class="layui-input-inline layui-inline-2">
|
||||
<input type="number" id="detailsNum" name="continuousCheckInRules.details[{{d.index}}].num[{{index}}]" value="100" lay-verify="required|number" autocomplete="off" placeholder="" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-input-inline layui-inline-4">
|
||||
<input type="radio" id="detailsType" name="continuousCheckInRules.details[{{d.index}}].type[{{index}}]" value="1" title="积分" checked="checked">
|
||||
<input type="radio" id="detailsType" name="continuousCheckInRules.details[{{d.index}}].type[{{index}}]" value="2" title="余额">
|
||||
</div>
|
||||
</div>
|
||||
{{# }); }}
|
||||
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm btn-continuous-delete">
|
||||
<i class="layui-icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
|
||||
<script id="cumulativeCheckInBoxTmp" type="text/html">
|
||||
<div class="cumulativeCheckInBox coreshop-solid">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">累计签到天数</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="hidden" id="id" name="id[{{d.index}}]" value="0">
|
||||
<input type="number" id="days" name="days[{{d.index}}]" value="0" lay-verify="required|number" autocomplete="off" placeholder="" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">赠送数量</label>
|
||||
<div class="layui-input-inline layui-inline-2">
|
||||
<input type="number" id="num" name="num[{{d.index}}]" value="0" lay-verify="required|number" autocomplete="off" placeholder="" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-input-inline layui-inline-4">
|
||||
<input type="radio" id="type" name="type[{{d.index}}]" value="1" title="积分" checked="checked">
|
||||
<input type="radio" id="type" name="type[{{d.index}}]" value="2" title="余额">
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm btn-delete">
|
||||
<i class="layui-icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
var cumulativeCheckInRulesCount = 0;
|
||||
var continuousCheckInRulesCount = 0;
|
||||
var indexData;
|
||||
var debug = layui.setter.debug;
|
||||
layui.data.done = function (d) {
|
||||
//开启调试情况下获取接口赋值数据
|
||||
if (debug) { console.log(d); }
|
||||
indexData = d.data;
|
||||
layui.use(['admin', 'form', 'coreHelper', 'element', 'table', 'util', 'laytpl', 'table', 'laydate'], function () {
|
||||
var $ = layui.$
|
||||
, setter = layui.setter
|
||||
, admin = layui.admin
|
||||
, coreHelper = layui.coreHelper
|
||||
, form = layui.form
|
||||
, element = layui.element
|
||||
, table = layui.table
|
||||
, util = layui.util
|
||||
, laytpl = layui.laytpl
|
||||
, laydate = layui.laydate
|
||||
, router = layui.router()
|
||||
, search = router.search;
|
||||
|
||||
|
||||
//时间选择器
|
||||
laydate.render({
|
||||
elem: '#checkInAlertTime'
|
||||
, type: 'time'
|
||||
});
|
||||
|
||||
continuousCheckInRulesCount = d.data.continuousCheckInRules.length;
|
||||
if (d.data.continuousCheckInRules.length <= 0) {
|
||||
var data = {
|
||||
index: 0,
|
||||
userGrade: d.data.userGrade
|
||||
};
|
||||
var getTpl = continuousCheckInBoxTmp.innerHTML;
|
||||
laytpl(getTpl).render(data, function (html) {
|
||||
$("#continuousCheckInRulesCount").before(html);
|
||||
continuousCheckInRulesCount += 1;
|
||||
$('#continuousCheckInRulesCount').val(continuousCheckInRulesCount);
|
||||
form.render();
|
||||
});
|
||||
}
|
||||
$(".layui-form-pane").on('click', '.btn-continuous-add', function () {
|
||||
var data = {
|
||||
index: continuousCheckInRulesCount,
|
||||
userGrade: d.data.userGrade
|
||||
};
|
||||
console.log(data);
|
||||
var getTpl = continuousCheckInBoxTmp.innerHTML;
|
||||
laytpl(getTpl).render(data, function (html) {
|
||||
$("#continuousCheckInRulesCount").before(html);
|
||||
continuousCheckInRulesCount += 1;
|
||||
$('#continuousCheckInRulesCount').val(continuousCheckInRulesCount);
|
||||
form.render();
|
||||
});
|
||||
});
|
||||
$(".layui-form-pane").on('click', '.btn-continuous-delete', function () {
|
||||
if (continuousCheckInRulesCount == 1) {
|
||||
layer.msg("至少要保留一个连续签到规则");
|
||||
} else {
|
||||
continuousCheckInRulesCount -= 1;
|
||||
$('#continuousCheckInRulesCount').val(continuousCheckInRulesCount);
|
||||
$(this).parent().remove();
|
||||
resetContinuousCheckInRulesInputNameID();
|
||||
}
|
||||
});
|
||||
//重置排序
|
||||
function resetContinuousCheckInRulesInputNameID() {
|
||||
$.each($("#continuousCheckInBox .continuousCheckInBox"), function (i, item) {
|
||||
var oldIndex = $(this).attr('data-id');
|
||||
$(this).attr('data-id', i);
|
||||
$(this).find("#id").attr("name", "continuousCheckInRules.id[" + i + "]");
|
||||
$(this).find("#days").attr("name", "continuousCheckInRules.days[" + i + "]");
|
||||
|
||||
$.each($(item).find(".listItems"), function (j, itemChild) {
|
||||
$(this).find("#detailsId").attr("name", "continuousCheckInRules.details[" + i + "].id[" + j + "]");
|
||||
$(this).find("#detailsUserGradeId").attr("name", "continuousCheckInRules.details[" + i + "].userGradeId[" + j + "]");
|
||||
$(this).find("#detailsRuleId").attr("name", "continuousCheckInRules.details[" + i + "].ruleId[" + j + "]");
|
||||
$(this).find("#detailsNum").attr("name", "continuousCheckInRules.details[" + i + "].num[" + j + "]");
|
||||
$(this).find("#detailsType").attr("name", "continuousCheckInRules.details[" + i + "].type[" + j + "]");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
cumulativeCheckInRulesCount = d.data.cumulativeCheckInRules.length;
|
||||
if (d.data.cumulativeCheckInRules.length <= 0) {
|
||||
var data = {
|
||||
index: 0
|
||||
};
|
||||
var getTpl = cumulativeCheckInBoxTmp.innerHTML;
|
||||
laytpl(getTpl).render(data, function (html) {
|
||||
$("#cumulativeCheckInRulesCount").before(html);
|
||||
cumulativeCheckInRulesCount += 1;
|
||||
$('#cumulativeCheckInRulesCount').val(cumulativeCheckInRulesCount);
|
||||
form.render();
|
||||
});
|
||||
}
|
||||
$(".layui-form-pane").on('click', '.btn-add', function () {
|
||||
var data = {
|
||||
index: cumulativeCheckInRulesCount
|
||||
};
|
||||
console.log(data);
|
||||
var getTpl = cumulativeCheckInBoxTmp.innerHTML;
|
||||
laytpl(getTpl).render(data, function (html) {
|
||||
$("#cumulativeCheckInRulesCount").before(html);
|
||||
cumulativeCheckInRulesCount += 1;
|
||||
$('#cumulativeCheckInRulesCount').val(cumulativeCheckInRulesCount);
|
||||
form.render();
|
||||
});
|
||||
});
|
||||
$(".layui-form-pane").on('click', '.btn-delete', function () {
|
||||
if (cumulativeCheckInRulesCount == 1) {
|
||||
layer.msg("至少要保留一个累计签到规则");
|
||||
} else {
|
||||
cumulativeCheckInRulesCount -= 1;
|
||||
$('#cumulativeCheckInRulesCount').val(cumulativeCheckInRulesCount);
|
||||
$(this).parent().remove();
|
||||
resetCumulativeCheckInRulesInputNameID();
|
||||
}
|
||||
});
|
||||
//重置排序
|
||||
function resetCumulativeCheckInRulesInputNameID() {
|
||||
$.each($("#cumulativeCheckInBox .cumulativeCheckInBox"), function (i, item) {
|
||||
$(this).attr('data-id', i);
|
||||
$(this).find("#id").attr("name", "id[" + i + "]");
|
||||
$(this).find("#days").attr("name", "days[" + i + "]");
|
||||
$(this).find("#num").attr("name", "num[" + i + "]");
|
||||
$(this).find("#type").attr("name", "type[" + i + "]");
|
||||
});
|
||||
}
|
||||
|
||||
//处理属性 为 lay-active 的所有元素事件
|
||||
util.event('lay-active', {
|
||||
goodsDelete: function () {
|
||||
},
|
||||
});
|
||||
|
||||
form.verify({
|
||||
money: [/((^[1-9]\d*)|^0)(\.\d{0,2}){0,1}$/, '请输入合法整数或小数'],
|
||||
});
|
||||
|
||||
//保存数据
|
||||
form.on('submit(save)', function (data) {
|
||||
formData = data.field;
|
||||
console.log(formData);
|
||||
if (!formData) {
|
||||
layer.msg('请先完善数据', {
|
||||
time: 1300
|
||||
});
|
||||
return false;
|
||||
}
|
||||
var field = data.field;
|
||||
var keys = Object.keys(field);
|
||||
var postData = [];
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var keyName = Object.keys(field)[i];
|
||||
|
||||
var entity = {};
|
||||
entity.sKey = keyName;
|
||||
entity.sValue = field[keyName];
|
||||
postData.push(entity);
|
||||
}
|
||||
console.log(postData);
|
||||
coreHelper.Post("Api/CoreCmsCheckIn/DoSave", { entity: postData }, function (e) {
|
||||
if (debug) { console.log(e); } //开启调试返回数据
|
||||
layer.msg(e.msg);
|
||||
});
|
||||
});
|
||||
|
||||
//保存连续签到规则数据
|
||||
form.on('submit(saveCoreCmsContinuousCheckInRules)', function (data) {
|
||||
var field = data.field;
|
||||
console.log(field);
|
||||
if (!field) {
|
||||
layer.msg('请先完善数据', {
|
||||
time: 1300
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
var keys = Object.keys(field);
|
||||
var keysCount = 0;
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
if (keys[i].indexOf('continuousCheckInRules.days') != -1) {
|
||||
keysCount++;
|
||||
}
|
||||
}
|
||||
|
||||
var rules = [];
|
||||
//组合参数
|
||||
if (keysCount > 0) {
|
||||
for (var i = 0; i < keysCount; i++) {
|
||||
var rule = {};
|
||||
rule.id = parseInt(field['continuousCheckInRules.id[' + i + ']']);
|
||||
rule.days = parseInt(field['continuousCheckInRules.days[' + i + ']']);
|
||||
rule.details = [];
|
||||
for (var j = 0; j < d.data.userGrade.length; j++) {
|
||||
var detail = {};
|
||||
detail.id = 0;
|
||||
detail.num = parseInt(field['continuousCheckInRules.details[' + i + '].num[' + j + ']']);
|
||||
detail.type = parseInt(field['continuousCheckInRules.details[' + i + '].type[' + j + ']']);
|
||||
detail.userGradeId = parseInt(field['continuousCheckInRules.details[' + i + '].userGradeId[' + j + ']']);
|
||||
detail.ruleId = parseInt(field['continuousCheckInRules.details[' + i + '].ruleId[' + j + ']']);
|
||||
rule.details.push(detail);
|
||||
}
|
||||
rules.push(rule);
|
||||
}
|
||||
}
|
||||
console.log(rules);
|
||||
coreHelper.Post("Api/CoreCmsCheckIn/DoSaveContinuousCheckInRules", { entity: rules }, function (e) {
|
||||
if (debug) { console.log(e); } //开启调试返回数据
|
||||
layer.msg(e.msg);
|
||||
});
|
||||
});
|
||||
|
||||
//保存累计签到规则数据
|
||||
form.on('submit(saveCumulativeCheckInRules)', function (data) {
|
||||
var field = data.field;
|
||||
console.log(field);
|
||||
if (!field) {
|
||||
layer.msg('请先完善数据', {
|
||||
time: 1300
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
var keys = Object.keys(field);
|
||||
var keysCount = 0;
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
if (keys[i].indexOf('id') != -1) {
|
||||
keysCount++;
|
||||
}
|
||||
}
|
||||
|
||||
var rules = [];
|
||||
//组合参数
|
||||
if (keysCount > 0) {
|
||||
for (var i = 0; i < keysCount; i++) {
|
||||
var rule = {};
|
||||
rule.id = parseInt(field['id[' + i + ']']);
|
||||
rule.days = parseInt(field['days[' + i + ']']);
|
||||
rule.num = parseInt(field['num[' + i + ']']);
|
||||
rule.type = parseInt(field['type[' + i + ']']);
|
||||
rules.push(rule);
|
||||
}
|
||||
}
|
||||
|
||||
coreHelper.Post("Api/CoreCmsCheckIn/DoSaveCumulativeCheckInRules", { entity: rules }, function (e) {
|
||||
if (debug) { console.log(e); } //开启调试返回数据
|
||||
layer.msg(e.msg);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
form.render();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
118
CoreCms.Net.Web.WebApi/Controllers/CheckInController.cs
Normal file
118
CoreCms.Net.Web.WebApi/Controllers/CheckInController.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Auth.HttpContextUser;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IServices;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.FromBody;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Nito.AsyncEx;
|
||||
|
||||
namespace CoreCms.Net.Web.WebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 签到控制器
|
||||
/// </summary>
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class CheckInController : ControllerBase
|
||||
{
|
||||
private readonly ICoreCmsUserCheckInDetailsServices _userCheckInDetailsServices;
|
||||
private readonly IHttpContextUser _user;
|
||||
|
||||
//简单的异步锁
|
||||
private readonly AsyncLock _mutex = new AsyncLock();
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
public CheckInController(IHttpContextUser user, ICoreCmsUserCheckInDetailsServices userCheckInDetailsServices)
|
||||
{
|
||||
_user = user;
|
||||
_userCheckInDetailsServices = userCheckInDetailsServices;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 用户签到
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Authorize]
|
||||
public async Task<WebApiCallBack> DoUserCheckIn([FromBody] FMDoUserCheckIn entity)
|
||||
{
|
||||
using (await _mutex.LockAsync())
|
||||
{
|
||||
var jm = new WebApiCallBack();
|
||||
var isHave = await _userCheckInDetailsServices.ExistsAsync(p => p.userId == _user.ID && p.checkInData == entity.date);
|
||||
if (isHave)
|
||||
{
|
||||
jm.msg = "今日您已签到";
|
||||
return jm;
|
||||
}
|
||||
var detail = new CoreCmsUserCheckInDetails
|
||||
{
|
||||
userId = _user.ID,
|
||||
checkInData = entity.date,
|
||||
createTime = DateTime.Now
|
||||
};
|
||||
var callBack = await _userCheckInDetailsServices.DoCheckIn(detail);
|
||||
jm.status = callBack.code == 0;
|
||||
jm.msg = callBack.msg;
|
||||
jm.data = callBack.data;
|
||||
return jm;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户总签到次数
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Authorize]
|
||||
public async Task<WebApiCallBack> GetUserCheckCount()
|
||||
{
|
||||
var jm = new WebApiCallBack
|
||||
{
|
||||
status = true,
|
||||
data = await _userCheckInDetailsServices.GetCountAsync(p => p.userId == _user.ID),
|
||||
msg = "获取成功"
|
||||
};
|
||||
return jm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户按月签到数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Authorize]
|
||||
public async Task<WebApiCallBack> GetUserCheckByMonth([FromBody] FMGetUserCheckInByMonth entity)
|
||||
{
|
||||
var jm = new WebApiCallBack();
|
||||
|
||||
var dt = new DateTime(entity.year, entity.month, 1);
|
||||
|
||||
var min = dt.AddDays(-1);
|
||||
var max = dt.AddMonths(1);
|
||||
|
||||
var list = await _userCheckInDetailsServices.QueryListByClauseAsync(p => p.userId == _user.ID && p.checkInData > min && p.checkInData < max);
|
||||
|
||||
var stringArr = new List<string>();
|
||||
foreach (var item in list)
|
||||
{
|
||||
var stringStr = item.checkInData.ToString("yyyy-MM-dd");
|
||||
stringArr.Add(stringStr);
|
||||
}
|
||||
|
||||
jm.status = true;
|
||||
jm.data = stringArr;
|
||||
jm.msg = "获取成功";
|
||||
|
||||
return jm;
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
数据库/SqlServer/20220314/20220314脚本1-创建表.sql
Normal file
BIN
数据库/SqlServer/20220314/20220314脚本1-创建表.sql
Normal file
Binary file not shown.
BIN
数据库/SqlServer/20220314/20220314脚本2-增加后台菜单.sql
Normal file
BIN
数据库/SqlServer/20220314/20220314脚本2-增加后台菜单.sql
Normal file
Binary file not shown.
BIN
数据库/SqlServer/20220314/CoreShopProfessional20220314完整数据库.rar
Normal file
BIN
数据库/SqlServer/20220314/CoreShopProfessional20220314完整数据库.rar
Normal file
Binary file not shown.
@@ -1,3 +1,6 @@
|
||||
2022-03-14
|
||||
【新增】表【CoreCmsContinuousCheckInRuleDetails】【CoreCmsContinuousCheckInRules】【CoreCmsCumulativeCheckInRules】【CoreCmsUserCheckIn】【CoreCmsUserCheckInDetails】实现日历签到功能。
|
||||
|
||||
2022-02-25
|
||||
【新增】表【CoreCmsProducts】增加【赠送积分points】字段
|
||||
|
||||
|
||||
Reference in New Issue
Block a user