DuGuYang 3 anni fa
parent
commit
cd1336a159

+ 0 - 124
AppStart/Helper/InstallmentDeductionService.cs

@@ -1,124 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Linq;
-using System.Threading;
-using MySystem.Models;
-using Library;
-
-namespace MySystem
-{
-    /// <summary>
-    /// 分期扣款(每月20号执行)
-    /// </summary>
-    public class InstallmentDeductionService
-    {
-        public readonly static InstallmentDeductionService Instance = new InstallmentDeductionService();
-        private InstallmentDeductionService()
-        { }
-
-        public void Start()
-        {
-            Thread th = new Thread(doSomething);
-            th.IsBackground = true;
-            th.Start();
-        }
-
-        public void doSomething()
-        {
-            while (true)
-            {
-                // if (DateTime.Now.Day == 20 && DateTime.Now.Hour < 12)
-                if (DateTime.Now.Hour < 20)
-                {
-                    try
-                    {
-                        string check = function.ReadInstance("/InstallmentDeduction/check" + DateTime.Now.ToString("yyyy-MM-20") + ".txt");
-                        if (string.IsNullOrEmpty(check))
-                        {
-                            function.WritePage("/InstallmentDeduction/", "check" + DateTime.Now.ToString("yyyy-MM-20") + ".txt", DateTime.Now.ToString("HH:mm:ss"));
-                            WebCMSEntities db = new WebCMSEntities();
-                            var startdate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-20 00:00:00"));
-                            var enddate = startdate.AddDays(1);
-                            // var info = db.ToChargeBackRecordSub.Where(m => m.Status == 0 && m.StartDate >= startdate && m.StartDate < enddate).ToList();//分期扣款记录明细
-                            var info = db.ToChargeByStage.Where(m => m.Status == 0).ToList();//分期扣款记录
-                            foreach (var item in info)
-                            {
-                                var toChargeBackRecordSub = db.ToChargeBackRecordSub.FirstOrDefault(m => m.Status == 0 && m.ParentId == item.Id && m.StartDate >= startdate && m.StartDate < enddate) ?? new ToChargeBackRecordSub();
-                                if (toChargeBackRecordSub.Id > 0)
-                                {
-                                    var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == item.UserId);
-                                    if (userAccount == null)
-                                    {
-                                        userAccount = db.UserAccount.Add(new UserAccount()
-                                        {
-                                            Id = item.UserId,
-                                            UserId = item.UserId,
-                                        }).Entity;
-                                        db.SaveChanges();
-                                    }
-                                    toChargeBackRecordSub.Status = 2;
-                                    userAccount.ToChargeAmount += toChargeBackRecordSub.ChargeAmount;//增加预扣款
-                                    var toChargeBackRecord = db.ToChargeBackRecord.Add(new ToChargeBackRecord
-                                    {
-                                        CreateDate = DateTime.Now,
-                                        Sort = toChargeBackRecordSub.Id,
-                                        UserId = item.UserId,
-                                        ChargeAmount = toChargeBackRecordSub.ChargeAmount,
-                                        ChargeType = 2,//分期预扣款
-                                        Remark = toChargeBackRecordSub.Remark,
-
-                                    }).Entity;
-                                }
-
-                                // //只能存在一笔分期扣款记录(先前有的但是余额不够未扣除的则不添加新的)
-                                // var checks = db.ToChargeBackRecord.Any(m => m.Sort > 0 && (m.Status == 0 || m.Status == 3) && m.ChargeType == 2 && m.UserId == item.UserId);
-                                // if (!checks)
-                                // {
-                                //     string checkAdd = RedisDbconn.Instance.Get<string>("InstallmentDeductionAddRecord:" + item.UserId);
-                                //     if (string.IsNullOrEmpty(check))
-                                //     {
-                                //         var toChargeBackRecordSub = db.ToChargeBackRecordSub.FirstOrDefault(m => m.Status == 0 && m.ParentId == item.Id && m.StartDate >= startdate && m.StartDate < enddate) ?? new ToChargeBackRecordSub();
-                                //         if (toChargeBackRecordSub.Id > 0)
-                                //         {
-                                //             var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == item.UserId);
-                                //             if (userAccount == null)
-                                //             {
-                                //                 userAccount = db.UserAccount.Add(new UserAccount()
-                                //                 {
-                                //                     Id = item.UserId,
-                                //                     UserId = item.UserId,
-                                //                 }).Entity;
-                                //                 db.SaveChanges();
-                                //             }
-                                //             userAccount.ToChargeAmount += toChargeBackRecordSub.ChargeAmount;//增加预扣款
-                                //             var toChargeBackRecord = db.ToChargeBackRecord.Add(new ToChargeBackRecord
-                                //             {
-                                //                 CreateDate = DateTime.Now,
-                                //                 Sort = toChargeBackRecordSub.Id,
-                                //                 UserId = item.UserId,
-                                //                 ChargeAmount = toChargeBackRecordSub.ChargeAmount,
-                                //                 ChargeType = 2,//分期预扣款
-                                //                 Remark = "分期预扣款",
-
-                                //             }).Entity;
-                                //         }
-                                //     }
-                                //     RedisDbconn.Instance.Set("InstallmentDeductionAddRecord:" + item.UserId, "wait");
-                                //     RedisDbconn.Instance.SetExpire("InstallmentDeductionAddRecord:" + item.UserId, 300);
-                                // }
-                            }
-                            db.SaveChanges();
-
-                        }
-                    }
-                    catch (Exception ex)
-                    {
-                        function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "执行分期扣费异常");
-                    }
-                }
-                Thread.Sleep(1000);
-            }
-        }
-    }
-}

+ 0 - 77
AppStart/Helper/LeaderTimeoutSendMessageService.cs

@@ -1,77 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Threading;
-using System.Linq;
-using System.Data;
-using MySystem;
-using MySystem.Models;
-using Library;
-using LitJson;
-/// <summary>
-/// 盟主过期消息推送
-/// </summary>
-public class LeaderTimeoutSendMessageService
-{
-    public readonly static LeaderTimeoutSendMessageService Instance = new LeaderTimeoutSendMessageService();
-    private LeaderTimeoutSendMessageService()
-    {
-    }
-
-    public void StartEverTime()
-    {
-        Thread th = new Thread(StartEverTimeDo);
-        th.IsBackground = true;
-        th.Start();
-    }
-
-    private void StartEverTimeDo()
-    {
-        while (true)
-        {
-            if (DateTime.Now.Hour < 20)
-            {
-                try
-                {
-                    string check = function.ReadInstance("/LeaderTimeoutSendMessage/check" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt");
-                    if (string.IsNullOrEmpty(check))
-                    {
-                        function.WritePage("/LeaderTimeoutSendMessage/", "check" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt", DateTime.Now.ToString("HH:mm:ss"));
-                        WebCMSEntities db = new WebCMSEntities();
-                        var leaders = db.Leaders.Select(m => new { m.UserId, m.ExpiredDate }).ToList();
-                        var time = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
-                        foreach (var item in leaders)
-                        {
-                            var user = db.Users.FirstOrDefault(m => m.Id == item.UserId) ?? new Users();
-                            var leaderTimeOutDate = DateTime.Parse(item.ExpiredDate.Value.ToString("yyyy-MM-dd"));
-                            if (time >= leaderTimeOutDate.AddDays(-5))
-                            {
-                                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,
-                                }));
-                            }
-                            if (time >= leaderTimeOutDate)
-                            {
-                                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,
-                                }));
-                            }
-                        }
-                    }
-                }
-                catch (Exception ex)
-                {
-                    function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "盟主过期消息推送线程异常");
-                }
-            }
-            Thread.Sleep(1000);
-        }
-    }
-}

+ 0 - 2
Startup.cs

@@ -141,8 +141,6 @@ namespace MySystem
             ExcelHelper.Instance.Start();
             OpExcelHelper.Instance.Start();
             SycnUserMachineCountHelper.Instance.Start(); //重置创客机具数量
-            LeaderTimeoutSendMessageService.Instance.StartEverTime(); //盟主过期消息推送
-
 
         }