mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2026-02-05 17:59:50 +08:00
# 2022-03-14
### 1.3.9 开源社区版: 【修复】修复BaseRepository数据交互层仓储SqlWith.NoLock使用方式异常的问题。 ### 0.2.8 专业版: 【新增】增加日历签到功能。实现通过日历签到获得积分,余额。【非破坏性无缝增加功能】 【新增】增加“连续签到周期”定时任务,用于根据后台的设置,实时重置清零用户连续签到计数。 【修复】修复BaseRepository数据交互层仓储SqlWith.NoLock使用方式异常的问题。
This commit is contained in:
@@ -0,0 +1,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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user