瀏覽代碼

盟主过期的个人消息推送规则变更
1.盟主权益即将到期提醒:过期前5天每天一次变更 为 仅过期前第5天推送一次
2.盟主权益到期提醒:过期后30天每天一次变更 为 过期后当天、第7天、第14天、第28天各一次

lcl 1 年之前
父節點
當前提交
4238d9a0cc
共有 1 個文件被更改,包括 49 次插入12 次删除
  1. 49 12
      AppStart/Helper/LeaderTimeoutSendMessageService.cs

+ 49 - 12
AppStart/Helper/LeaderTimeoutSendMessageService.cs

@@ -7,6 +7,7 @@ using MySystem;
 using MySystem.Models;
 using Library;
 using LitJson;
+using GraphQL;
 /// <summary>
 /// 盟主过期消息推送
 /// </summary>
@@ -46,23 +47,59 @@ public class LeaderTimeoutSendMessageService
                             var day = leaderTimeOutDate - time;
                             if (time >= leaderTimeOutDate.AddDays(-5) && time <= leaderTimeOutDate)
                             {
-                                RedisDbconn.Instance.AddList("MsgPersonalQueue", Newtonsoft.Json.JsonConvert.SerializeObject(new MsgPersonal()
+                                string flag = RedisDbconn.Instance.Get<string>("MsgPersonalFirst" + item.UserId);
+                                if(string.IsNullOrEmpty(flag))
                                 {
-                                    UserId = item.UserId, //创客
-                                    Title = "盟主权益即将到期提醒", //标题
-                                    Content = "<div class='f16'>尊敬的" + user.RealName + "盟主您好:<br/>您的盟主权益将在" + day.Days + "天后到期,为保障您的收益持续到账,请尽快续期!</ div > ",//内容
-                                    CreateDate = DateTime.Now,
-                                }));
+                                    RedisDbconn.Instance.Set("MsgPersonalFirst" + item.UserId, "1");
+                                    int timespan = 60 * 60 * 24 * 6;
+                                    RedisDbconn.Instance.SetExpire("MsgPersonalFirst" + item.UserId, timespan);
+                                    RedisDbconn.Instance.AddList("MsgPersonalQueue", Newtonsoft.Json.JsonConvert.SerializeObject(new MsgPersonal()
+                                    {
+                                        UserId = item.UserId, //创客
+                                        Title = "盟主权益即将到期提醒", //标题
+                                        Content = "<div class='f16'>尊敬的" + user.RealName + "盟主您好:<br/>您的盟主权益将在" + day.Days + "天后到期,为保障您的收益持续到账,请尽快续期!</ div > ",//内容
+                                        CreateDate = DateTime.Now,
+                                    }));
+                                }
                             }
                             if (time > leaderTimeOutDate && time <= leaderTimeOutDate.AddMonths(1))
                             {
-                                RedisDbconn.Instance.AddList("MsgPersonalQueue", Newtonsoft.Json.JsonConvert.SerializeObject(new MsgPersonal()
+                                int number = 1; //提示标记(第几次)
+                                int timespan = 60 * 60 * 24 * 8;
+                                TimeSpan ts = time - leaderTimeOutDate;
+                                if(ts.Days == 0 || ts.Days == 1) 
                                 {
-                                    UserId = item.UserId, //创客
-                                    Title = "盟主权益到期提醒", //标题
-                                    Content = "<div class='f16'>尊敬的" + user.RealName + "盟主您好:<br/>您的盟主已经过期,重新开通后可恢复相关权益!</ div > ",//内容
-                                    CreateDate = DateTime.Now,
-                                }));
+                                    number = 1;
+                                    timespan = 60 * 60 * 24 * 8;
+                                }
+                                if(ts.Days == 7 || ts.Days == 8) 
+                                {
+                                    number = 2;
+                                    timespan = 60 * 60 * 24 * 8;
+                                }
+                                if(ts.Days == 14 || ts.Days == 15) 
+                                {
+                                    number = 3;
+                                    timespan = 60 * 60 * 24 * 15;
+                                }
+                                if(ts.Days == 28 || ts.Days == 29) 
+                                {
+                                    number = 4;
+                                    timespan = 60 * 60 * 24 * 5;
+                                }
+                                string flag = RedisDbconn.Instance.Get<string>("MsgPersonalAfter:" + number + ":" + item.UserId);
+                                if(string.IsNullOrEmpty(flag))
+                                {
+                                    RedisDbconn.Instance.Set("MsgPersonalAfter:" + number + ":" + item.UserId, "1");
+                                    RedisDbconn.Instance.SetExpire("MsgPersonalAfter:" + number + ":" + item.UserId, timespan);
+                                    RedisDbconn.Instance.AddList("MsgPersonalQueue", Newtonsoft.Json.JsonConvert.SerializeObject(new MsgPersonal()
+                                    {
+                                        UserId = item.UserId, //创客
+                                        Title = "盟主权益到期提醒", //标题
+                                        Content = "<div class='f16'>尊敬的" + user.RealName + "盟主您好:<br/>您的盟主已经过期,重新开通后可恢复相关权益!</ div > ",//内容
+                                        CreateDate = DateTime.Now,
+                                    }));
+                                }
                             }
                         }
                     }