lcl hace 1 semana
padre
commit
90ae373c90
Se han modificado 6 ficheros con 123 adiciones y 15 borrados
  1. BIN
      .DS_Store
  2. 22 15
      AppStart/Helper/PosPushDataNewHelper.cs
  3. 10 0
      AppStart/RedisDbconn.cs
  4. 2 0
      Startup.cs
  5. 80 0
      Util/PosFeeHelper.cs
  6. 9 0
      Util/PosFeeItem.cs

BIN
.DS_Store


+ 22 - 15
AppStart/Helper/PosPushDataNewHelper.cs

@@ -431,7 +431,7 @@ namespace MySystem
                     FeeRate = "0.60";
                     FeeAmt = trade.ErrorMsg;
                 }
-                Dictionary<string, string> fee = GetFee(trade.TradeSnNo, FeeRate, FeeAmt);
+                Dictionary<string, string> fee = GetFee(trade.TradeSnNo, FeeRate, FeeAmt, trade.ProductType);
                 FeeRate = fee["FeeRate"];
                 FeeAmt = fee["FeeAmt"];
                 Dictionary<string, object> dataContent = new Dictionary<string, object>();
@@ -501,30 +501,37 @@ namespace MySystem
             return brand;
         }
 
-        public static Dictionary<string, string> GetFee(string PosSn, string FeeRate, string FeeAmt)
+        public static Dictionary<string, string> GetFee(string PosSn, string FeeRate, string FeeAmt, string ProductType)
         {
             if(decimal.Parse(FeeRate) > 0.63M) FeeRate = "0.63";
-            List<int> BrandIds = new List<int>();
-            BrandIds.Add(1);
-            BrandIds.Add(7);
-            BrandIds.Add(10);
-            BrandIds.Add(11);
-            BrandIds.Add(15);
-            BrandIds.Add(27);
+            List<string> BrandIds = new List<string>();
+            BrandIds.Add("1");
+            BrandIds.Add("7");
+            BrandIds.Add("10");
+            BrandIds.Add("11");
+            BrandIds.Add("15");
+            BrandIds.Add("16");
+            BrandIds.Add("27");
             Dictionary<string, string> result = new Dictionary<string, string>();
-            JavaProductModels.WebCMSEntities db = new JavaProductModels.WebCMSEntities();
-            JavaProductModels.KxsMachine pos = db.KxsMachine.FirstOrDefault(m => m.PosSn == PosSn && BrandIds.Contains(m.BrandId));
-            if(pos != null)
+            if(BrandIds.Contains(ProductType))
             {
-                result.Add("FeeRate", pos.MachineRatio.ToString("f2"));
-                result.Add("FeeAmt", pos.SecondFee.ToString("f2"));
+                PosFeeItem pos = RedisDbconn.Instance.GetList<PosFeeItem>("PosFeeList").FirstOrDefault(m => m.PosSn == PosSn);
+                if(pos != null)
+                {
+                    result.Add("FeeRate", pos.FeeRate.ToString("f2"));
+                    result.Add("FeeAmt", pos.FeeAmt.ToString("f2"));
+                }
+                else
+                {
+                    result.Add("FeeRate", FeeRate);
+                    result.Add("FeeAmt", FeeAmt);
+                }
             }
             else
             {
                 result.Add("FeeRate", FeeRate);
                 result.Add("FeeAmt", FeeAmt);
             }
-            db.Dispose();
             return result;
         }
     

+ 10 - 0
AppStart/RedisDbconn.cs

@@ -140,6 +140,11 @@ namespace MySystem
             T[] list = csredis.LRange<T>(key, start, end);
             return list.ToList();
         }
+        public List<T> GetList<T>(string key)
+        {
+            T[] list = csredis.LRange<T>(key, 0, -1);
+            return list.ToList();
+        }
         #endregion
 
         #region 删除列表元素
@@ -208,6 +213,11 @@ namespace MySystem
             csredis.Del(keys);
         }
 
+        public void Del(string key)
+        {
+            csredis.Del(key);
+        }
+
         public string[] GetKeys(string pattern)
         { 
             string[] keys = csredis.Keys(pattern);

+ 2 - 0
Startup.cs

@@ -195,6 +195,8 @@ namespace MySystem
                 SpDataHelper.Instance.Start("MainDataQueue");
                 SpDataHelper.Instance.StartData();
 
+                PosFeeHelper.Instance.Start(); //初始化机具名单
+
                 // WifiCheckHelper.Instance.DoSomething();
 
                 // StatService.Instance.StartActiveReward(); //实时处理激活奖励

+ 80 - 0
Util/PosFeeHelper.cs

@@ -0,0 +1,80 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using Library;
+using MySystem.JavaProductModels;
+
+namespace MySystem
+{
+    public class PosFeeHelper
+    {
+        public readonly static PosFeeHelper Instance = new PosFeeHelper();
+        private PosFeeHelper()
+        { }
+
+        public void Start()
+        {
+            Thread th = new Thread(DoWorks);
+            th.IsBackground = true;
+            th.Start();
+        }
+
+        private void DoWorks()
+        {
+            // while (true)
+            // {
+            //     try
+            //     {
+            //         InitPosList();
+            //         int timespan = 1000 * 60 * 60 * 2;
+            //         Thread.Sleep(timespan);
+            //     }
+            //     catch (Exception ex)
+            //     {
+            //         Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "初始化机具名单异常");
+            //     }
+            // }
+            try
+            {
+                InitPosList();
+            }
+            catch (Exception ex)
+            {
+                Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "初始化机具名单异常");
+            }
+        }
+
+        #region 初始化机具名单
+
+        public void InitPosList()
+        {
+            List<string> jkPos = function.ReadInstance("tmpdata/jk.txt").Split('\n').ToList();
+            List<string> Pos = new List<string>();
+            string posString = function.ReadInstance("tmpdata/1.txt");
+            Pos.AddRange(posString.Split('\n'));
+            posString = function.ReadInstance("tmpdata/2.txt");
+            Pos.AddRange(posString.Split('\n'));
+            posString = function.ReadInstance("tmpdata/3.txt");
+            Pos.AddRange(posString.Split('\n'));
+            posString = function.ReadInstance("tmpdata/4.txt");
+            Pos.AddRange(posString.Split('\n'));
+            WebCMSEntities db = new WebCMSEntities();
+            
+            //金控
+            var list1 = db.KxsMachine.Select(m => new { m.PosSn, m.BrandId, m.MachineRatio, m.SecondFee }).Where(m => (m.BrandId == 1 || m.BrandId == 3) && !jkPos.Contains(m.PosSn)).ToList().Select(m => new PosFeeItem(){ PosSn = m.PosSn, FeeRate = m.MachineRatio, FeeAmt = m.SecondFee }).ToArray();
+
+            //盛付通、来客吧、联动
+            var list2 = db.KxsMachine.Select(m => new { m.PosSn, m.BrandId, m.MachineRatio, m.SecondFee }).Where(m => Pos.Contains(m.PosSn)).ToList().Select(m => new PosFeeItem(){ PosSn = m.PosSn, FeeRate = m.MachineRatio, FeeAmt = m.SecondFee }).ToArray();
+
+            RedisDbconn.Instance.Del("PosFeeList");
+            RedisDbconn.Instance.AddList("PosFeeList", list1);
+            RedisDbconn.Instance.AddList("PosFeeList", list2);
+
+            db.Dispose();
+        }
+
+        #endregion 
+    
+    }
+}

+ 9 - 0
Util/PosFeeItem.cs

@@ -0,0 +1,9 @@
+namespace MySystem
+{
+    public class PosFeeItem
+    {
+        public string PosSn { set; get; }
+        public decimal FeeRate { set; get; }
+        public decimal FeeAmt { set; get; }
+    }
+}