312
This commit is contained in:
parent
09018795bf
commit
1796ec7b50
|
|
@ -1553,6 +1553,8 @@ namespace CoreCms.Net.Configuration
|
|||
/// </summary>
|
||||
[Description("通用类型")]
|
||||
Common = 11,
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using CoreCms.Net.Caching.AccressToken;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.IServices;
|
||||
|
|
@ -10,10 +11,13 @@ using CoreCms.Net.Model.ViewModels.UI;
|
|||
using CoreCms.Net.WeChat.Service.Enums;
|
||||
using CoreCms.Net.WeChat.Service.HttpClients;
|
||||
using CoreCms.Net.WeChat.Service.Models;
|
||||
|
||||
using InitQ.Abstractions;
|
||||
using InitQ.Attributes;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
using SKIT.FlurlHttpClient.Wechat.Api;
|
||||
using SKIT.FlurlHttpClient.Wechat.Api.Models;
|
||||
|
||||
|
|
@ -44,7 +48,7 @@ namespace CoreCms.Net.RedisMQ.Subscribe
|
|||
/// <param name="msg"></param>
|
||||
/// <returns></returns>
|
||||
[Subscribe(RedisMessageQueueKey.SendWxTemplateMessage)]
|
||||
private async Task SendWxTemplateMessage(string msg)
|
||||
public async Task SendWxTemplateMessage(string msg)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -146,6 +150,20 @@ namespace CoreCms.Net.RedisMQ.Subscribe
|
|||
templateMessageData[templateData.data04] = new CgibinMessageSubscribeSendRequest.Types.DataItem() { Value = parameters["paymentCode"].ToString() };
|
||||
templateMessageData[templateData.data05] = new CgibinMessageSubscribeSendRequest.Types.DataItem() { Value = parameters["createTime"].ToString() };
|
||||
}
|
||||
else if (request.code == GlobalEnumVars.WeChatMsgTemplateType.reservation_success.ToString())
|
||||
{
|
||||
templateMessageData[templateData.data01] = new CgibinMessageSubscribeSendRequest.Types.DataItem() { Value = parameters["createTime"].ToString() };
|
||||
templateMessageData[templateData.data02] = new CgibinMessageSubscribeSendRequest.Types.DataItem() { Value = parameters["title"].ToString() };
|
||||
templateMessageData[templateData.data03] = new CgibinMessageSubscribeSendRequest.Types.DataItem() { Value = parameters["roomName"].ToString() };
|
||||
templateMessageData[templateData.data04] = new CgibinMessageSubscribeSendRequest.Types.DataItem() { Value = parameters["tips"].ToString() };
|
||||
}
|
||||
else if (request.code == GlobalEnumVars.WeChatMsgTemplateType.reservation_change.ToString())
|
||||
{
|
||||
templateMessageData[templateData.data01] = new CgibinMessageSubscribeSendRequest.Types.DataItem() { Value = parameters["title"].ToString() };
|
||||
templateMessageData[templateData.data02] = new CgibinMessageSubscribeSendRequest.Types.DataItem() { Value = parameters["createTime"].ToString() };
|
||||
templateMessageData[templateData.data03] = new CgibinMessageSubscribeSendRequest.Types.DataItem() { Value = parameters["context"].ToString() };
|
||||
templateMessageData[templateData.data04] = new CgibinMessageSubscribeSendRequest.Types.DataItem() { Value = parameters["tips"].ToString() };
|
||||
}
|
||||
var result = await Send(weChatUserInfo.openid, templateData.templateId, templateMessageData, pageUrl);
|
||||
|
||||
NLogUtil.WriteAll(NLog.LogLevel.Info, LogType.RedisMessageQueue, "微信模板消息", JsonConvert.SerializeObject(result));
|
||||
|
|
@ -200,7 +218,7 @@ namespace CoreCms.Net.RedisMQ.Subscribe
|
|||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
newCode = code;
|
||||
}
|
||||
|
||||
var info = await _userWeChatMsgSubscriptionServices.QueryByClauseAsync(p => p.userId == userId && p.type == newCode);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,11 @@
|
|||
using CoreCms.Net.IServices;
|
||||
using CoreCms.Net.Caching.AutoMate.RedisCache;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.IServices;
|
||||
|
||||
using DotLiquid.Tags;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
using SqlSugar;
|
||||
|
||||
|
|
@ -8,6 +15,8 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using static SKIT.FlurlHttpClient.Wechat.Api.Models.CgibinUserInfoBatchGetRequest.Types;
|
||||
|
||||
namespace CoreCms.Net.Task
|
||||
{
|
||||
/// <summary>
|
||||
|
|
@ -17,11 +26,14 @@ namespace CoreCms.Net.Task
|
|||
{
|
||||
private readonly ISQReservationsServices _reservationsServices;
|
||||
private readonly ISQReservationParticipantsServices _participantsServices;
|
||||
private readonly IRedisOperationRepository _redisOperationRepository;
|
||||
public SQReservationJob(ISQReservationsServices reservationsServices,
|
||||
ISQReservationParticipantsServices participantsServices)
|
||||
ISQReservationParticipantsServices participantsServices,
|
||||
IRedisOperationRepository redisOperationRepository)
|
||||
{
|
||||
_reservationsServices = reservationsServices;
|
||||
_participantsServices = participantsServices;
|
||||
_redisOperationRepository = redisOperationRepository;
|
||||
}
|
||||
|
||||
public async System.Threading.Tasks.Task Execute()
|
||||
|
|
@ -58,6 +70,57 @@ namespace CoreCms.Net.Task
|
|||
await _reservationsServices.UpdateAsync(startedList);
|
||||
}
|
||||
|
||||
|
||||
// 2.5) 到达开始时间但人数未满的预约置为取消(4)
|
||||
Console.WriteLine("到达开始时间但人数未满的预约置为取消(4)");
|
||||
var toCancelList = await _reservationsServices.QueryListByClauseAsync(
|
||||
r => r.status == 0 && r.start_time <= now && r.end_time > now,
|
||||
r => r.id, OrderByType.Asc);
|
||||
if (toCancelList != null && toCancelList.Count > 0)
|
||||
{
|
||||
foreach (var item in toCancelList)
|
||||
{
|
||||
var count = await _participantsServices.GetCountAsync(p => p.reservation_id == item.id && p.status == 0);
|
||||
if (count < item.player_count)
|
||||
{
|
||||
item.status = 4;
|
||||
item.updated_at = now;
|
||||
}
|
||||
}
|
||||
var toCancelChanged = toCancelList.Where(x => x.status == 4).ToList();
|
||||
if (toCancelChanged.Count > 0)
|
||||
{
|
||||
await _reservationsServices.UpdateAsync(toCancelChanged);
|
||||
foreach (var item in toCancelChanged)
|
||||
{
|
||||
var userList = await _participantsServices.QueryListByClauseAsync(p => p.reservation_id == item.id && p.status == 0);
|
||||
foreach (var user in userList)
|
||||
{
|
||||
JObject parameters = new JObject();
|
||||
parameters.Add("title", item.title);
|
||||
parameters.Add("context", $"组局失败!");
|
||||
parameters.Add("createTime", item.start_time);
|
||||
parameters.Add("tips", $"组局人数未满,自动解散!");
|
||||
var @params = new JObject();
|
||||
@params.Add("parameters", parameters);
|
||||
var data = new
|
||||
{
|
||||
user.user_id,
|
||||
code = "reservation_change",
|
||||
parameters = @params
|
||||
};
|
||||
await _redisOperationRepository.ListLeftPushAsync(RedisMessageQueueKey.SendWxTemplateMessage, JsonConvert.SerializeObject(data));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 3) 开始前30分钟内,人数已凑齐则置为锁定(1)
|
||||
Console.WriteLine("开始前30分钟内,人数已凑齐则置为锁定(1)");
|
||||
var threshold = now.AddMinutes(30);
|
||||
|
|
@ -81,6 +144,29 @@ namespace CoreCms.Net.Task
|
|||
if (changed.Count > 0)
|
||||
{
|
||||
await _reservationsServices.UpdateAsync(changed);
|
||||
foreach (var item in changed)
|
||||
{
|
||||
var userList = await _participantsServices.QueryListByClauseAsync(p => p.reservation_id == item.id && p.status == 0);
|
||||
foreach (var user in userList)
|
||||
{
|
||||
JObject parameters = new JObject();
|
||||
parameters.Add("title", item.title);
|
||||
parameters.Add("roomName", item.room_name);
|
||||
parameters.Add("createTime", item.start_time);
|
||||
parameters.Add("tips", $"组局成功!");
|
||||
var @params = new JObject();
|
||||
@params.Add("parameters", parameters);
|
||||
var data = new
|
||||
{
|
||||
user.user_id,
|
||||
code = "reservation_success",
|
||||
parameters = @params
|
||||
};
|
||||
await _redisOperationRepository.ListLeftPushAsync(RedisMessageQueueKey.SendWxTemplateMessage, JsonConvert.SerializeObject(data));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user