فهرست منبع

wifi产品30天未激活提醒,35天未激活按押金扣款

lcl 7 ماه پیش
والد
کامیت
89c5a98af6
2فایلهای تغییر یافته به همراه194 افزوده شده و 0 حذف شده
  1. 93 0
      AppStart/Helper/WifiWarningService.cs
  2. 101 0
      AppStart/Helper/WifiWithholdService.cs

+ 93 - 0
AppStart/Helper/WifiWarningService.cs

@@ -0,0 +1,93 @@
+using System;
+using System.Collections.Generic;
+using Library;
+using LitJson;
+using System.Linq;
+using System.Data;
+using System.Threading;
+using MySystem.PxcModels;
+
+namespace MySystem
+{
+    public class WifiWarningService
+    {
+        public readonly static WifiWarningService Instance = new WifiWarningService();
+        private WifiWarningService()
+        { }
+
+        public void Start()
+        {
+            Thread th = new Thread(dosomething);
+            th.IsBackground = true;
+            th.Start();
+        }
+
+        public void dosomething()
+        {
+            while (true)
+            {
+                try
+                {
+                    if(DateTime.Now.Hour > 2 && DateTime.Now.Hour < 4 && DateTime.Now >= DateTime.Parse("2024-10-30 00:00:00"))
+                    {
+                        string chk = function.ReadInstance("/WifiWithhold/" + DateTime.Now.ToString("yyyyMMdd") + ".txt");
+                        if(string.IsNullOrEmpty(chk))
+                        {
+                            function.WritePage("/WifiWithhold/", "" + DateTime.Now.ToString("yyyyMMdd") + ".txt", DateTime.Now.ToString());
+                            WifiWithhold();
+                        }
+                    }
+                }
+                catch (Exception ex)
+                {
+                    function.WriteLog(DateTime.Now.ToString() + "\r\n" + ex.ToString(), "WIFI提醒异常");
+                }
+                Thread.Sleep(300000);
+            }
+        }
+
+        //WIFI30天未完成申请时向预发创客增加一条预扣款
+        private void WifiWithhold()
+        {
+            WebCMSEntities db = new WebCMSEntities();
+            DateTime end = DateTime.Parse(DateTime.Now.AddDays(-29).ToString("yyyy-MM-dd") + " 00:00:00");
+            int Id = 0;
+            bool op = true;
+            while(op)
+            {
+                List<int> BrandIds = new List<int>();
+                BrandIds.Add(23);
+                BrandIds.Add(24);
+                BrandIds.Add(25);
+                BrandIds.Add(26);
+                DateTime time = DateTime.Now.AddDays(-30);
+                List<PosMachinesTwo> WifiList = db.PosMachinesTwo.Where(m => m.Id > Id && BrandIds.Contains(m.BrandId) && m.ActivationState == 0 && m.TransferTime < time && m.Sort == 0).OrderBy(m => m.Id).Take(20).ToList();
+                if(WifiList.Count > 0)
+                {
+                    foreach(var Pos in WifiList)
+                    {
+                        RedisDbconn.Instance.AddList("MsgPersonalQueue", Newtonsoft.Json.JsonConvert.SerializeObject(new MsgPersonal()
+                        {
+                            UserId = Pos.BuyUserId, //创客
+                            Title = "WIFI设备超时提醒", //标题
+                            Content = "<div class='f16'>尊敬的客小爽创客:<br />您好,您名下的部分WIFI设备已接收30天,超过35天未完成激活时将预扣您的创客余额。<br>为保障您的收益不受影响,请您尽快完成WIFI设备激活!</ div > ",//内容
+                            CreateDate = DateTime.Now,
+                        }));
+                        PosMachinesTwo edit = db.PosMachinesTwo.FirstOrDefault(m => m.Id == Pos.Id);
+                        if(edit != null)
+                        {
+                            edit.Sort = 1;
+                        }
+                        Id = Pos.Id;
+                    }
+                    db.SaveChanges();
+                }
+                else
+                {
+                    op = false;
+                }
+            }
+            db.Dispose();
+        }
+    }
+}

+ 101 - 0
AppStart/Helper/WifiWithholdService.cs

@@ -0,0 +1,101 @@
+using System;
+using System.Collections.Generic;
+using Library;
+using LitJson;
+using System.Linq;
+using System.Data;
+using System.Threading;
+using MySystem.PxcModels;
+
+namespace MySystem
+{
+    public class WifiWithholdService
+    {
+        public readonly static WifiWithholdService Instance = new WifiWithholdService();
+        private WifiWithholdService()
+        { }
+
+        public void Start()
+        {
+            Thread th = new Thread(dosomething);
+            th.IsBackground = true;
+            th.Start();
+        }
+
+        public void dosomething()
+        {
+            while (true)
+            {
+                try
+                {
+                    if(DateTime.Now.Hour > 3 && DateTime.Now.Hour < 5 && DateTime.Now >= DateTime.Parse("2024-10-30 00:00:00"))
+                    {
+                        string chk = function.ReadInstance("/WifiWithhold/" + DateTime.Now.ToString("yyyyMMdd") + ".txt");
+                        if(string.IsNullOrEmpty(chk))
+                        {
+                            function.WritePage("/WifiWithhold/", "" + DateTime.Now.ToString("yyyyMMdd") + ".txt", DateTime.Now.ToString());
+                            WifiWithhold();
+                        }
+                    }
+                }
+                catch (Exception ex)
+                {
+                    function.WriteLog(DateTime.Now.ToString() + "\r\n" + ex.ToString(), "WIFI提醒异常");
+                }
+                Thread.Sleep(300000);
+            }
+        }
+
+        //WIFI30天未完成申请时向预发创客增加一条预扣款
+        private void WifiWithhold()
+        {
+            WebCMSEntities db = new WebCMSEntities();
+            DateTime end = DateTime.Parse(DateTime.Now.AddDays(-29).ToString("yyyy-MM-dd") + " 00:00:00");
+            int Id = 0;
+            bool op = true;
+            while(op)
+            {
+                List<int> BrandIds = new List<int>();
+                BrandIds.Add(23);
+                BrandIds.Add(24);
+                BrandIds.Add(25);
+                BrandIds.Add(26);
+                DateTime time = DateTime.Now.AddDays(-35);
+                List<PosMachinesTwo> WifiList = db.PosMachinesTwo.Where(m => m.Id > Id && BrandIds.Contains(m.BrandId) && m.ActivationState == 0 && m.TransferTime < time && m.Sort == 1).OrderBy(m => m.Id).Take(20).ToList();
+                if(WifiList.Count > 0)
+                {
+                    foreach(var Pos in WifiList)
+                    {
+                        KqProducts brand = db.KqProducts.FirstOrDefault(m => m.Id == Pos.BrandId) ?? new KqProducts();
+                        decimal ChargeAmount = decimal.Parse(function.CheckNum(Pos.SeoKeyword));
+                        db.ToChargeBackRecord.Add(new ToChargeBackRecord
+                        {
+                            CreateDate = DateTime.Now,
+                            SeoTitle = "系统",
+                            SeoDescription = "WIFI超时未激活扣款",
+                            Remark = "WIFI超时未激活扣款",
+                            ChargeType = 1,
+                            ChargeAmount = ChargeAmount,
+                            UserId = Pos.BuyUserId,
+                            Field1 = Pos.PosSn,
+                        });
+                        PosMachinesTwo edit = db.PosMachinesTwo.FirstOrDefault(m => m.Id == Pos.Id);
+                        if(edit != null)
+                        {
+                            edit.Sort = 2;
+                        }
+                        //增加账户预扣总额
+                        Utils.Instance.ToChargeAmount(Pos.BuyUserId, ChargeAmount);
+                        Id = Pos.Id;
+                    }
+                    db.SaveChanges();
+                }
+                else
+                {
+                    op = false;
+                }
+            }
+            db.Dispose();
+        }
+    }
+}