Kaynağa Gözat

添加wifi解绑队列

lcl 1 yıl önce
ebeveyn
işleme
cd1ad17c0e
2 değiştirilmiş dosya ile 64 ekleme ve 1 silme
  1. 62 0
      AppStart/WifiUnBindHelper.cs
  2. 2 1
      Startup.cs

+ 62 - 0
AppStart/WifiUnBindHelper.cs

@@ -0,0 +1,62 @@
+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 WifiUnBindHelper
+{
+    public readonly static WifiUnBindHelper Instance = new WifiUnBindHelper();
+    private WifiUnBindHelper()
+    {
+    }
+
+    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>("WifiUnBindHelper");
+                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)
+    {
+        JsonData jsonObj = JsonMapper.ToObject(content);
+        string posSn = jsonObj["pos_sn"].ToString();
+        WebCMSEntities db = new WebCMSEntities();
+        WifiTradeRecord edit = db.WifiTradeRecord.FirstOrDefault(m => m.SnNo == posSn);
+        if(edit != null)
+        {
+            edit.DoMonths = edit.Duration + 1;
+            edit.Status = -1;
+            db.SaveChanges();
+        }
+        db.Dispose();
+    }
+}

+ 2 - 1
Startup.cs

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