Browse Source

添加换绑队列

lcl 2 months ago
parent
commit
64f03de3c2
3 changed files with 66 additions and 1 deletions
  1. 64 0
      AppStart/WifiChangeBindHelper.cs
  2. 1 1
      AppStart/WifiUnBindHelper.cs
  3. 1 0
      Startup.cs

+ 64 - 0
AppStart/WifiChangeBindHelper.cs

@@ -0,0 +1,64 @@
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Linq;
+using System.Data;
+using MySystem;
+using MySystem.PxcModels;
+using Library;
+using LitJson;
+
+public class WifiChangeBindHelper
+{
+    public readonly static WifiChangeBindHelper Instance = new WifiChangeBindHelper();
+    private WifiChangeBindHelper()
+    {
+    }
+
+    public void Start()
+    {
+        Thread th = new Thread(DoWorks);
+        th.IsBackground = true;
+        th.Start();
+    }
+
+    private void DoWorks()
+    {
+        while (true)
+        {
+            try
+            {
+                string content = RedisDbconn.Instance.RPop<string>("kxs_changebindwifi_list");
+                if(!string.IsNullOrEmpty(content))
+                {
+                    DoSomething(content);
+                }
+                else
+                {
+                    Thread.Sleep(60000);
+                }
+            }
+            catch (Exception ex)
+            {
+                function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "WIFI换绑异常");
+            }
+        }
+    }
+
+    public void DoSomething(string content)
+    {
+        string[] data = content.Split(new string[] { "#cut#" }, StringSplitOptions.None);
+        JsonData jsonObj = JsonMapper.ToObject(data[1]);
+        string oldSn = jsonObj["oldSn"].ToString();
+        string newSn = jsonObj["newSn"].ToString();
+        WebCMSEntities db = new WebCMSEntities();
+        WifiTradeRecord edit = db.WifiTradeRecord.FirstOrDefault(m => m.SnNo == oldSn);
+        if(edit != null)
+        {
+            edit.Remark = oldSn;
+            edit.SnNo = newSn;
+            db.SaveChanges();
+        }
+        db.Dispose();
+    }
+}

+ 1 - 1
AppStart/WifiUnBindHelper.cs

@@ -40,7 +40,7 @@ public class WifiUnBindHelper
             }
             catch (Exception ex)
             {
-                function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "WIFI发放交易额异常");
+                function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "WIFI解绑异常");
             }
         }
     }

+ 1 - 0
Startup.cs

@@ -185,6 +185,7 @@ namespace MySystem
                 SycnSpMerchantRecordService.Instance.Start(); //同步SP商户记录数据
                 WifiTradeHelper.Instance.Start(); //每月1号统计上月wifi交易
                 WifiUnBindHelper.Instance.Start(); //wifi解绑
+                WifiChangeBindHelper.Instance.Start(); //wifi换绑
 
                 // StatService.Instance.StartActiveReward(); //实时处理激活奖励
                 // StatService.Instance.StartActiveReward1(); //实时处理0押激活奖励