Prechádzať zdrojové kódy

wifi分月添加交易

lcl 6 mesiacov pred
rodič
commit
e465fca581

BIN
.DS_Store


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 1776
AppStart/Timer/TestHelper.cs


+ 78 - 0
AppStart/WifiTradeHelper.cs

@@ -0,0 +1,78 @@
+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 WifiTradeHelper
+{
+    public readonly static WifiTradeHelper Instance = new WifiTradeHelper();
+    private WifiTradeHelper()
+    {
+    }
+
+    public void Start()
+    {
+        Thread th = new Thread(DoWorks);
+        th.IsBackground = true;
+        th.Start();
+    }
+
+    private void DoWorks()
+    {
+        while (true)
+        {
+            try
+            {
+                string Month = DateTime.Now.ToString("yyyyMM");
+                string chk = function.ReadInstance("/wifi/trade" + Month + ".txt");
+                if(string.IsNullOrEmpty(chk))
+                {
+                    function.WritePage("/wifi/", "trade" + Month + ".txt", DateTime.Now.ToString());
+                    DoSomething(Month);
+                }
+                Thread.Sleep(3600000);
+            }
+            catch (Exception ex)
+            {
+                function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "WIFI发放交易额异常");
+            }
+        }
+    }
+
+    public void DoSomething(string Month)
+    {
+        WebCMSEntities db = new WebCMSEntities();
+        List<WifiTradeRecord> trades = db.WifiTradeRecord.Where(m => m.Duration > m.DoMonths && m.LastMonth != Month).ToList();
+        foreach(WifiTradeRecord trade in trades)
+        {
+            if(trade.Unit == "m" && trade.Duration > 0)
+            {
+                decimal TradeAmt = trade.TradeAmount / trade.Duration;
+                DateTime StartMonth = DateTime.Parse(DateTime.Now.ToString("yyyy-MM") + "-01 00:00:00");
+                PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == trade.SnNo) ?? new PosMachinesTwo();
+                SycnSpTradeWifiService.Instance.StatTrade(db, pos.BuyUserId, pos.BrandId, StartMonth.ToString("yyyyMM"), TradeAmt);
+                if (pos.BindingTime < trade.CreateDate.Value.AddMonths(-9))
+                {
+                    SycnSpTradeWifiService.Instance.StatTradeBefore(db, pos.BuyUserId, pos.BrandId, StartMonth.ToString("yyyyMM"), TradeAmt);
+                }
+                else
+                {
+                    SycnSpTradeWifiService.Instance.StatTradeAfter(db, pos.BuyUserId, pos.BrandId, StartMonth.ToString("yyyyMM"), TradeAmt);
+                }
+                WifiTradeRecord edit = db.WifiTradeRecord.FirstOrDefault(m => m.Id == trade.Id);
+                if(edit != null)
+                {
+                    edit.DoMonths += 1;
+                    edit.LastMonth = Month;
+                }
+            }
+            db.SaveChanges();
+        }
+        db.Dispose();
+    }
+}

+ 0 - 95
AppStart/WifiUnBindHelper.cs

@@ -1,95 +0,0 @@
-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>("WifiUnBindQueue");
-                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 SnNo)
-    {
-        WebCMSEntities db = new WebCMSEntities();
-        PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == SnNo) ?? new PosMachinesTwo();
-        PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId);
-        if(merchant != null)
-        {
-            //备份解绑的商户信息
-            CustomerSqlConn.op("insert into PosMerchantInfoBak select * from PosMerchantInfo where Id=" + pos.BindMerchantId, MysqlConn.SqlConnStr);
-            MachineForMerNo forMerNo = db.MachineForMerNo.FirstOrDefault(m => m.MerNo == merchant.KqMerNo);
-            if (forMerNo != null)
-            {
-                db.MachineForMerNo.Remove(forMerNo);
-            }
-            pos.BindMerchantId = 0;
-            pos.BindingState = 0;
-            pos.BindingTime = null;
-            db.PosMerchantInfo.Remove(merchant);
-            db.SaveChanges();
-        }
-
-        WifiTradeRecord trade = db.WifiTradeRecord.FirstOrDefault(m => m.SnNo == SnNo);
-        if(trade != null)
-        {
-            if(trade.Unit == "m" && trade.Duration > 0)
-            {
-                decimal TradeAmt = trade.TradeAmount / trade.Duration;
-                string TradeMonth = trade.CreateDate.Value.ToString("yyyy-MM");
-                DateTime StartMonth = DateTime.Parse(TradeMonth + "-01 00:00:00");
-                for (int i = 1; i <= trade.Duration; i++)
-                {
-                    StartMonth = StartMonth.AddMonths(1);
-                    SycnSpTradeWifiService.Instance.StatTrade(db, pos.BuyUserId, pos.BrandId, StartMonth.ToString("yyyyMM"), -TradeAmt);
-                    if (pos.BindingTime < trade.CreateDate.Value.AddMonths(-9))
-                    {
-                        SycnSpTradeWifiService.Instance.StatTradeBefore(db, pos.BuyUserId, pos.BrandId, StartMonth.ToString("yyyyMM"), -TradeAmt);
-                    }
-                    else
-                    {
-                        SycnSpTradeWifiService.Instance.StatTradeAfter(db, pos.BuyUserId, pos.BrandId, StartMonth.ToString("yyyyMM"), -TradeAmt);
-                    }
-                }
-            }
-            db.SaveChanges();
-        }
-        db.Dispose();
-    }
-}

+ 10 - 0
PxcModels/WebCMSEntities.cs

@@ -22209,10 +22209,20 @@ namespace MySystem.PxcModels
                     .HasColumnType("datetime")
                     .HasComment("创建时间");
 
+                entity.Property(e => e.DoMonths)
+                    .HasColumnType("int(11)")
+                    .HasComment("执行月份");
+
                 entity.Property(e => e.Duration)
                     .HasColumnType("int(11)")
                     .HasComment("时长");
 
+                entity.Property(e => e.LastMonth)
+                    .HasColumnType("varchar(6)")
+                    .HasComment("最后执行月份")
+                    .HasCharSet("utf8")
+                    .HasCollation("utf8_general_ci");
+
                 entity.Property(e => e.Remark)
                     .HasColumnType("varchar(64)")
                     .HasComment("备注")

+ 2 - 0
PxcModels/WifiTradeRecord.cs

@@ -15,5 +15,7 @@ namespace MySystem.PxcModels
         public string SnNo { get; set; }
         public int Duration { get; set; }
         public string Unit { get; set; }
+        public int DoMonths { get; set; }
+        public string LastMonth { get; set; }
     }
 }

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov