mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 16:03:25 +08:00
添加项目文件。
This commit is contained in:
38
CoreCms.Net.Task/AutoCancelOrderJob.cs
Normal file
38
CoreCms.Net.Task/AutoCancelOrderJob.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 AutoCancelOrderJob
|
||||
{
|
||||
private readonly ICoreCmsOrderServices _orderServices;
|
||||
|
||||
public AutoCancelOrderJob(ICoreCmsOrderServices orderServices)
|
||||
{
|
||||
_orderServices = orderServices;
|
||||
}
|
||||
|
||||
public async System.Threading.Tasks.Task Execute()
|
||||
{
|
||||
await _orderServices.AutoCancelOrder();
|
||||
}
|
||||
}
|
||||
}
|
||||
38
CoreCms.Net.Task/AutoCanclePintuanJob.cs
Normal file
38
CoreCms.Net.Task/AutoCanclePintuanJob.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;
|
||||
|
||||
namespace CoreCms.Net.Task
|
||||
{
|
||||
/// <summary>
|
||||
/// 拼团自动取消到期团
|
||||
/// </summary>
|
||||
public class AutoCanclePinTuanJob
|
||||
{
|
||||
private readonly ICoreCmsPinTuanRecordServices _pinTuanRecordServices;
|
||||
|
||||
|
||||
public AutoCanclePinTuanJob(ICoreCmsPinTuanRecordServices pinTuanRecordServices)
|
||||
{
|
||||
_pinTuanRecordServices = pinTuanRecordServices;
|
||||
}
|
||||
|
||||
public async System.Threading.Tasks.Task Execute()
|
||||
{
|
||||
await _pinTuanRecordServices.AutoCanclePinTuanOrder();
|
||||
}
|
||||
}
|
||||
}
|
||||
39
CoreCms.Net.Task/AutoSignOrderJob.cs
Normal file
39
CoreCms.Net.Task/AutoSignOrderJob.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
/***********************************************************************
|
||||
* 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;
|
||||
|
||||
namespace CoreCms.Net.Task
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单自动签收任务
|
||||
/// </summary>
|
||||
public class AutoSignOrderJob
|
||||
{
|
||||
private readonly ICoreCmsOrderServices _orderServices;
|
||||
|
||||
|
||||
public AutoSignOrderJob(ICoreCmsOrderServices orderServices)
|
||||
{
|
||||
_orderServices = orderServices;
|
||||
}
|
||||
|
||||
public async System.Threading.Tasks.Task Execute()
|
||||
{
|
||||
await _orderServices.AutoSignOrder();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
37
CoreCms.Net.Task/CompleteOrderJob.cs
Normal file
37
CoreCms.Net.Task/CompleteOrderJob.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
/***********************************************************************
|
||||
* 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;
|
||||
|
||||
namespace CoreCms.Net.Task
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单自动完成任务
|
||||
/// </summary>
|
||||
public class CompleteOrderJob
|
||||
{
|
||||
private readonly ICoreCmsOrderServices _orderServices;
|
||||
|
||||
public CompleteOrderJob(ICoreCmsOrderServices orderServices)
|
||||
{
|
||||
_orderServices = orderServices;
|
||||
}
|
||||
|
||||
public async System.Threading.Tasks.Task Execute()
|
||||
{
|
||||
await _orderServices.AutoCompleteOrder();
|
||||
}
|
||||
}
|
||||
}
|
||||
21
CoreCms.Net.Task/CoreCms.Net.Task.csproj
Normal file
21
CoreCms.Net.Task/CoreCms.Net.Task.csproj
Normal file
@@ -0,0 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Hangfire" Version="1.7.25" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CoreCms.Net.IRepository\CoreCms.Net.IRepository.csproj" />
|
||||
<ProjectReference Include="..\CoreCms.Net.IServices\CoreCms.Net.IServices.csproj" />
|
||||
<ProjectReference Include="..\CoreCms.Net.Loging\CoreCms.Net.Loging.csproj" />
|
||||
<ProjectReference Include="..\CoreCms.Net.Repository\CoreCms.Net.Repository.csproj" />
|
||||
<ProjectReference Include="..\CoreCms.Net.Services\CoreCms.Net.Services.csproj" />
|
||||
<ProjectReference Include="..\CoreCms.Net.Utility\CoreCms.Net.Utility.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
38
CoreCms.Net.Task/EvaluateOrderJob.cs
Normal file
38
CoreCms.Net.Task/EvaluateOrderJob.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;
|
||||
|
||||
namespace CoreCms.Net.Task
|
||||
{
|
||||
/// <summary>
|
||||
/// 自动评价订单任务
|
||||
/// </summary>
|
||||
public class EvaluateOrderJob
|
||||
{
|
||||
private readonly ICoreCmsOrderServices _orderServices;
|
||||
|
||||
|
||||
public EvaluateOrderJob(ICoreCmsOrderServices orderServices)
|
||||
{
|
||||
_orderServices = orderServices;
|
||||
}
|
||||
|
||||
public async System.Threading.Tasks.Task Execute()
|
||||
{
|
||||
await _orderServices.AutoEvaluateOrder();
|
||||
}
|
||||
}
|
||||
}
|
||||
73
CoreCms.Net.Task/HangfireDispose.cs
Normal file
73
CoreCms.Net.Task/HangfireDispose.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms.Net *
|
||||
* Web: https://CoreCms.Net *
|
||||
* ProjectName: 核心内容管理系统 *
|
||||
* Author: 大灰灰 *
|
||||
* Email: JianWeie@163.com *
|
||||
* CreateTime: 2020-08-27 2:09:38
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
using System;
|
||||
using Hangfire;
|
||||
|
||||
namespace CoreCms.Net.Task
|
||||
{
|
||||
public class HangfireDispose
|
||||
{
|
||||
#region 配置服务
|
||||
|
||||
public static void HangfireService()
|
||||
{
|
||||
//Fire - And - forget(发布 / 订阅)
|
||||
//这是一个主要的后台任务类型,持久化消息队列会去处理这个任务。当你创建了一个发布 / 订阅任务,该任务会被保存到默认队列里面(默认队列是"Default",但是支持使用多队列)。多个专注的工作者(Worker)会监听这个队列,并且从中获取任务并且完成任务。
|
||||
//BackgroundJob.Enqueue(() => Console.WriteLine("Fire-and-forget"));
|
||||
|
||||
//延迟
|
||||
//如果想要延迟某些任务的执行,可以是用以下任务。在给定延迟时间后,任务会被排入队列,并且和发布 / 订阅任务一样执行。
|
||||
//BackgroundJob.Schedule(() => Console.WriteLine("Delayed"), TimeSpan.FromDays(1));
|
||||
|
||||
//循环
|
||||
//按照周期性(小时,天等)来调用方法,请使用RecurringJob类。在复杂的场景,您可以使用CRON表达式指定计划时间来处理任务。
|
||||
//RecurringJob.AddOrUpdate(() => Console.WriteLine("Daily Job"), Cron.Daily);
|
||||
|
||||
//连续
|
||||
//连续性允许您通过将多个后台任务链接在一起来定义复杂的工作流。
|
||||
//var id = BackgroundJob.Enqueue(() => Console.WriteLine("Hello, "));
|
||||
//BackgroundJob.ContinueWith(id, () => Console.WriteLine("world!"));
|
||||
|
||||
//这里呢就是需要触发的方法 "0/10 * * * * ? " 可以自行搜索cron表达式 代表循环的规律很简单
|
||||
//CancelOrderJob代表你要触发的类 Execute代表你要触发的方法
|
||||
|
||||
|
||||
//自动取消订单任务
|
||||
RecurringJob.AddOrUpdate<AutoCancelOrderJob>(s => s.Execute(), "0 0/5 * * * ? ", TimeZoneInfo.Utc); // 每5分钟取消一次订单
|
||||
|
||||
//自动完成订单任务
|
||||
RecurringJob.AddOrUpdate<CompleteOrderJob>(s => s.Execute(), Cron.Hourly, TimeZoneInfo.Utc); // 每小时自动完成订单
|
||||
|
||||
//自动评价订单任务
|
||||
RecurringJob.AddOrUpdate<EvaluateOrderJob>(s => s.Execute(), Cron.Hourly, TimeZoneInfo.Utc); // 每小时自动完成订单
|
||||
|
||||
//自动签收订单任务
|
||||
RecurringJob.AddOrUpdate<AutoSignOrderJob>(s => s.Execute(), Cron.Hourly, TimeZoneInfo.Utc); // 每小时自动完成订单
|
||||
|
||||
//催付款订单
|
||||
RecurringJob.AddOrUpdate<RemindOrderPayJob>(s => s.Execute(), "0 0/5 * * * ? ", TimeZoneInfo.Utc); // 每5分钟催付款订单
|
||||
|
||||
//拼团自动取消到期团(每分钟执行一次)
|
||||
RecurringJob.AddOrUpdate<AutoCanclePinTuanJob>(s => s.Execute(), Cron.Minutely, TimeZoneInfo.Utc); // 每分钟取消一次订单
|
||||
|
||||
//每天凌晨5点定期清理7天前操作日志
|
||||
RecurringJob.AddOrUpdate<RemoveOperationLogJob>(s => s.Execute(), "0 0 5 * * ? ", TimeZoneInfo.Utc); // 每天5点固定时间清理一次
|
||||
|
||||
|
||||
//定时刷新获取微信AccessToken
|
||||
RecurringJob.AddOrUpdate<RefreshWeChatAccessTokenJob>(s => s.Execute(), "0 0/2 * * * ? ", TimeZoneInfo.Utc); // 每2分钟刷新获取微信AccessToken
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
220
CoreCms.Net.Task/RefreshWeChatAccessTokenJob.cs
Normal file
220
CoreCms.Net.Task/RefreshWeChatAccessTokenJob.cs
Normal file
@@ -0,0 +1,220 @@
|
||||
/***********************************************************************
|
||||
* 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.Caching.AutoMate.RedisCache;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.IServices;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.WeChat.Service.HttpClients;
|
||||
using CoreCms.Net.WeChat.Service.Options;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Newtonsoft.Json;
|
||||
using SKIT.FlurlHttpClient;
|
||||
using SKIT.FlurlHttpClient.Wechat;
|
||||
using SKIT.FlurlHttpClient.Wechat.Api;
|
||||
using SKIT.FlurlHttpClient.Wechat.Api.Models;
|
||||
|
||||
|
||||
namespace CoreCms.Net.Task
|
||||
{
|
||||
/// <summary>
|
||||
/// 定时刷新获取微信AccessToken
|
||||
/// </summary>
|
||||
public class RefreshWeChatAccessTokenJob
|
||||
{
|
||||
private readonly ISysTaskLogServices _taskLogServices;
|
||||
|
||||
private readonly IRedisOperationRepository _redisOperationRepository;
|
||||
|
||||
private readonly WeChatOptions _weChatOptions;
|
||||
private readonly IWeChatApiHttpClientFactory _weChatApiHttpClientFactory;
|
||||
private readonly IWeChatAccessTokenServices _weChatAccessTokenServices;
|
||||
|
||||
|
||||
public RefreshWeChatAccessTokenJob(IRedisOperationRepository redisOperationRepository, ISysTaskLogServices taskLogServices, IOptions<WeChatOptions> weChatOptions, IWeChatApiHttpClientFactory weChatApiHttpClientFactory, IWeChatAccessTokenServices weChatAccessTokenServices)
|
||||
{
|
||||
_redisOperationRepository = redisOperationRepository;
|
||||
_taskLogServices = taskLogServices;
|
||||
_weChatApiHttpClientFactory = weChatApiHttpClientFactory;
|
||||
_weChatAccessTokenServices = weChatAccessTokenServices;
|
||||
_weChatOptions = weChatOptions.Value;
|
||||
}
|
||||
|
||||
public async System.Threading.Tasks.Task Execute()
|
||||
{
|
||||
try
|
||||
{
|
||||
//微信公众号刷新
|
||||
if (!string.IsNullOrEmpty(_weChatOptions.WeiXinAppId) && !string.IsNullOrEmpty(_weChatOptions.WeiXinAppSecret))
|
||||
{
|
||||
var entity = await _weChatAccessTokenServices.QueryByClauseAsync(p => p.appId == _weChatOptions.WeiXinAppId && p.appType == (int)GlobalEnumVars.AccessTokenEnum.WeiXinAccessToken);
|
||||
if (entity == null || entity.expireTimestamp <= DateTimeOffset.Now.ToUnixTimeSeconds())
|
||||
{
|
||||
var client = _weChatApiHttpClientFactory.CreateWeXinClient();
|
||||
var request = new CgibinTokenRequest();
|
||||
var response = await client.ExecuteCgibinTokenAsync(request);
|
||||
if (!response.IsSuccessful())
|
||||
{
|
||||
//插入日志
|
||||
var log = new SysTaskLog
|
||||
{
|
||||
createTime = DateTime.Now,
|
||||
isSuccess = false,
|
||||
name = "定时刷新获取微信AccessToken",
|
||||
parameters = $"刷新 AppId 为 {_weChatOptions.WeiXinAppId} 微信 AccessToken 失败(状态码:{response.RawStatus},错误代码:{response.ErrorCode},错误描述:{response.ErrorMessage})。"
|
||||
};
|
||||
await _taskLogServices.InsertAsync(log);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 提前十分钟过期,以便于系统能及时刷新,防止因在过期临界点时出现问题
|
||||
long nextExpireTimestamp = DateTimeOffset.Now.AddSeconds(response.ExpiresIn).AddMinutes(-10).ToUnixTimeSeconds();
|
||||
|
||||
if (entity == null)
|
||||
{
|
||||
entity = new WeChatAccessToken();
|
||||
|
||||
entity.appId = _weChatOptions.WeiXinAppId;
|
||||
entity.accessToken = response.AccessToken;
|
||||
entity.appType = (int)GlobalEnumVars.AccessTokenEnum.WeiXinAccessToken;
|
||||
entity.expireTimestamp = nextExpireTimestamp;
|
||||
entity.createTimestamp = DateTimeOffset.Now.ToUnixTimeSeconds();
|
||||
entity.updateTimestamp = entity.createTimestamp;
|
||||
|
||||
entity.id = await _weChatAccessTokenServices.InsertAsync(entity);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.accessToken = response.AccessToken;
|
||||
entity.expireTimestamp = nextExpireTimestamp;
|
||||
entity.updateTimestamp = DateTimeOffset.Now.ToUnixTimeSeconds();
|
||||
await _weChatAccessTokenServices.UpdateAsync(entity);
|
||||
}
|
||||
await _redisOperationRepository.Set(GlobalEnumVars.AccessTokenEnum.WeiXinAccessToken.ToString(), entity, TimeSpan.FromMinutes(120));
|
||||
|
||||
//插入日志
|
||||
var model = new SysTaskLog
|
||||
{
|
||||
createTime = DateTime.Now,
|
||||
isSuccess = true,
|
||||
name = "定时刷新获取微信AccessToken",
|
||||
parameters = JsonConvert.SerializeObject(entity)
|
||||
};
|
||||
await _taskLogServices.InsertAsync(model);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//插入日志
|
||||
var model = new SysTaskLog
|
||||
{
|
||||
createTime = DateTime.Now,
|
||||
isSuccess = true,
|
||||
name = "定时刷新获取微信AccessToken",
|
||||
parameters = "无需刷新AccessToken,AccessToken 未过期"
|
||||
};
|
||||
await _taskLogServices.InsertAsync(model);
|
||||
}
|
||||
}
|
||||
//微信小程序也刷新
|
||||
if (!string.IsNullOrEmpty(_weChatOptions.WxOpenAppId) && !string.IsNullOrEmpty(_weChatOptions.WxOpenAppSecret))
|
||||
{
|
||||
var entity = await _weChatAccessTokenServices.QueryByClauseAsync(p => p.appId == _weChatOptions.WxOpenAppId && p.appType == (int)GlobalEnumVars.AccessTokenEnum.WxOpenAccessToken);
|
||||
if (entity == null || entity.expireTimestamp <= DateTimeOffset.Now.ToUnixTimeSeconds())
|
||||
{
|
||||
var client = _weChatApiHttpClientFactory.CreateWxOpenClient();
|
||||
|
||||
var request = new CgibinTokenRequest();
|
||||
var response = await client.ExecuteCgibinTokenAsync(request);
|
||||
if (response.IsSuccessful())
|
||||
{
|
||||
// 提前十分钟过期,以便于系统能及时刷新,防止因在过期临界点时出现问题
|
||||
long nextExpireTimestamp = DateTimeOffset.Now.AddSeconds(response.ExpiresIn).AddMinutes(-10).ToUnixTimeSeconds();
|
||||
|
||||
if (entity == null)
|
||||
{
|
||||
entity = new WeChatAccessToken();
|
||||
|
||||
entity.appId = _weChatOptions.WxOpenAppId;
|
||||
entity.accessToken = response.AccessToken;
|
||||
entity.appType = (int)GlobalEnumVars.AccessTokenEnum.WxOpenAccessToken;
|
||||
entity.expireTimestamp = nextExpireTimestamp;
|
||||
entity.createTimestamp = DateTimeOffset.Now.ToUnixTimeSeconds();
|
||||
entity.updateTimestamp = entity.createTimestamp;
|
||||
|
||||
await _weChatAccessTokenServices.InsertAsync(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.accessToken = response.AccessToken;
|
||||
entity.expireTimestamp = nextExpireTimestamp;
|
||||
entity.updateTimestamp = DateTimeOffset.Now.ToUnixTimeSeconds();
|
||||
await _weChatAccessTokenServices.UpdateAsync(entity);
|
||||
}
|
||||
|
||||
await _redisOperationRepository.Set(
|
||||
GlobalEnumVars.AccessTokenEnum.WxOpenAccessToken.ToString(), entity,
|
||||
TimeSpan.FromMinutes(120));
|
||||
|
||||
//插入日志
|
||||
var model = new SysTaskLog
|
||||
{
|
||||
createTime = DateTime.Now,
|
||||
isSuccess = true,
|
||||
name = "定时刷新获取微信AccessToken",
|
||||
parameters = JsonConvert.SerializeObject(entity)
|
||||
};
|
||||
await _taskLogServices.InsertAsync(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
//插入日志
|
||||
var log = new SysTaskLog
|
||||
{
|
||||
createTime = DateTime.Now,
|
||||
isSuccess = false,
|
||||
name = "定时刷新获取微信AccessToken",
|
||||
parameters = $"刷新 AppId 为 {_weChatOptions.WeiXinAppId} 微信 AccessToken 失败(状态码:{response.RawStatus},错误代码:{response.ErrorCode},错误描述:{response.ErrorMessage})。"
|
||||
};
|
||||
await _taskLogServices.InsertAsync(log);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//插入日志
|
||||
var model = new SysTaskLog
|
||||
{
|
||||
createTime = DateTime.Now,
|
||||
isSuccess = true,
|
||||
name = "定时刷新获取微信AccessToken",
|
||||
parameters = "无需刷新AccessToken,AccessToken 未过期"
|
||||
};
|
||||
await _taskLogServices.InsertAsync(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//插入日志
|
||||
var model = new SysTaskLog
|
||||
{
|
||||
createTime = DateTime.Now,
|
||||
isSuccess = false,
|
||||
name = "定时刷新获取微信AccessToken",
|
||||
parameters = JsonConvert.SerializeObject(ex)
|
||||
};
|
||||
await _taskLogServices.InsertAsync(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
38
CoreCms.Net.Task/RemindOrderPayJob.cs
Normal file
38
CoreCms.Net.Task/RemindOrderPayJob.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;
|
||||
|
||||
namespace CoreCms.Net.Task
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单催付款任务
|
||||
/// </summary>
|
||||
public class RemindOrderPayJob
|
||||
{
|
||||
private readonly ICoreCmsOrderServices _orderServices;
|
||||
|
||||
|
||||
public RemindOrderPayJob(ICoreCmsOrderServices orderServices)
|
||||
{
|
||||
_orderServices = orderServices;
|
||||
}
|
||||
|
||||
public async System.Threading.Tasks.Task Execute()
|
||||
{
|
||||
await _orderServices.RemindOrderPay();
|
||||
}
|
||||
}
|
||||
}
|
||||
51
CoreCms.Net.Task/RemoveOperationLogJob.cs
Normal file
51
CoreCms.Net.Task/RemoveOperationLogJob.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
/***********************************************************************
|
||||
* 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.IRepository;
|
||||
using CoreCms.Net.IServices;
|
||||
using CoreCms.Net.Loging;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
namespace CoreCms.Net.Task
|
||||
{
|
||||
/// <summary>
|
||||
/// 定期清理7天前操作日志任务
|
||||
/// </summary>
|
||||
public class RemoveOperationLogJob
|
||||
{
|
||||
private readonly ISysTaskLogServices _taskLogServices;
|
||||
private readonly ISysNLogRecordsServices _nLogRecordsServices;
|
||||
private readonly ICoreCmsGoodsBrowsingServices _browsingServices;
|
||||
|
||||
public RemoveOperationLogJob(ISysTaskLogServices taskLogServices, ISysNLogRecordsServices nLogRecordsServices, ICoreCmsGoodsBrowsingServices browsingServices)
|
||||
{
|
||||
_taskLogServices = taskLogServices;
|
||||
_nLogRecordsServices = nLogRecordsServices;
|
||||
_browsingServices = browsingServices;
|
||||
}
|
||||
|
||||
public async System.Threading.Tasks.Task Execute()
|
||||
{
|
||||
var dt = DateTime.Now.AddDays(-7);
|
||||
var dt2 = DateTime.Now.AddDays(-7);
|
||||
var dt3 = DateTime.Now.AddDays(-7);
|
||||
//清理7天前的Nlog记录
|
||||
await _nLogRecordsServices.DeleteAsync(p => p.LogDate <= dt);
|
||||
//清理7天前的定时任务记录
|
||||
await _taskLogServices.DeleteAsync(p => p.createTime <= dt2);
|
||||
//清理7天前的用户足迹
|
||||
await _browsingServices.DeleteAsync(p => p.createTime <= dt3);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user