lcl преди 1 седмица
родител
ревизия
fceee37b66
променени са 3 файла, в които са добавени 105 реда и са изтрити 26 реда
  1. 88 15
      AppStart/Helper/PosPushDataNewHelper.cs
  2. 16 10
      Controllers/HomeController.cs
  3. 1 1
      Startup.cs

+ 88 - 15
AppStart/Helper/PosPushDataNewHelper.cs

@@ -503,31 +503,104 @@ namespace MySystem
 
         public static Dictionary<string, string> GetFee(string PosSn, string FeeRate, string FeeAmt, string ProductType)
         {
-            if(decimal.Parse(FeeRate) > 0.63M) FeeRate = "0.63";
-            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>();
-            if(BrandIds.Contains(ProductType))
+            try
             {
-                PosFeeItem pos = RedisDbconn.Instance.GetList<PosFeeItem>("PosFeeList").FirstOrDefault(m => m.PosSn == PosSn);
-                if(pos != null)
+                if(decimal.Parse(FeeRate) > 0.63M) FeeRate = "0.63";
+                List<int> BrandIds = new List<int>();
+                BrandIds.Add(7);
+                BrandIds.Add(10);
+                BrandIds.Add(11);
+                BrandIds.Add(15);
+                BrandIds.Add(16);
+                Utils.WriteLog("start");
+                bool op = false;
+                if(ProductType == "1" || ProductType == "27")
+                {
+                    op = true;
+                }
+                else if(BrandIds.Contains(int.Parse(ProductType)))
+                {
+                    PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
+                    op = db.TmpTradeNo.Any(m => m.RecordNo == PosSn);
+                    db.Dispose();
+                }
+                if(op)
+                {
+                    PosFeeItem pos = RedisDbconn.Instance.Get<PosFeeItem>("PosFee:" + PosSn);
+                    if(pos == null)
+                    {
+                        JavaProductModels.WebCMSEntities db = new JavaProductModels.WebCMSEntities();
+                        JavaProductModels.KxsMachine p = db.KxsMachine.FirstOrDefault(m => m.PosSn == PosSn && BrandIds.Contains(m.BrandId));
+                        pos = new PosFeeItem() { PosSn = p.PosSn, FeeRate = p.MachineRatio, FeeAmt = p.SecondFee };
+                        RedisDbconn.Instance.Set("PosFee:" + PosSn, pos);
+                        db.Dispose();
+                    }
+                    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", pos.FeeRate.ToString("f2"));
-                    result.Add("FeeAmt", pos.FeeAmt.ToString("f2"));
+                    result.Add("FeeRate", FeeRate);
+                    result.Add("FeeAmt", FeeAmt);
+                }
+                Utils.WriteLog("end");
+            }
+            catch
+            {
+                result.Add("FeeRate", FeeRate);
+                result.Add("FeeAmt", FeeAmt);
+            }
+            return result;
+        }
+
+
+        public static Dictionary<string, string> GetFee2(string PosSn, string FeeRate, string FeeAmt, string ProductType)
+        {
+            Dictionary<string, string> result = new Dictionary<string, string>();
+            try
+            {
+                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(16);
+                BrandIds.Add(27);
+                Utils.WriteLog("start");
+                if(BrandIds.Contains(int.Parse(ProductType)))
+                {
+                    JavaProductModels.WebCMSEntities db = new JavaProductModels.WebCMSEntities();
+                    JavaProductModels.KxsMachine pos = db.KxsMachine.FirstOrDefault(m => m.PosSn == PosSn && BrandIds.Contains(m.BrandId));
+                    if(pos != null)
+                    {
+                        result.Add("FeeRate", pos.MachineRatio.ToString("f2"));
+                        result.Add("FeeAmt", pos.SecondFee.ToString("f2"));
+                    }
+                    else
+                    {
+                        result.Add("FeeRate", FeeRate);
+                        result.Add("FeeAmt", FeeAmt);
+                    }
                 }
                 else
                 {
                     result.Add("FeeRate", FeeRate);
                     result.Add("FeeAmt", FeeAmt);
                 }
+                Utils.WriteLog("end");
             }
-            else
+            catch
             {
                 result.Add("FeeRate", FeeRate);
                 result.Add("FeeAmt", FeeAmt);

+ 16 - 10
Controllers/HomeController.cs

@@ -204,16 +204,22 @@ namespace MySystem.Controllers
             //     MerNo = "217F8106532",
             //     Id = 780709,
             // });
-            PosPushDataNewHelper.Bind(new MySystem.SpModels.Merchants()
-            {
-                ProductType = "200",
-                SnNo = "QR939300200002",
-                MerNo = "L00000000000400",
-                MerIdcardNo = "522121********6811",
-                MerName = "金银新村社区服务站",
-                MerMobile = "139****2383",
-                CreateTime = DateTime.Parse("2025-06-27 10:36:00"),
-            }, "33");
+            // PosPushDataNewHelper.Bind(new MySystem.SpModels.Merchants()
+            // {
+            //     ProductType = "200",
+            //     SnNo = "QR939300200002",
+            //     MerNo = "L00000000000400",
+            //     MerIdcardNo = "522121********6811",
+            //     MerName = "金银新村社区服务站",
+            //     MerMobile = "139****2383",
+            //     CreateTime = DateTime.Parse("2025-06-27 10:36:00"),
+            // }, "33");
+            string FeeRate = "0.63";
+            string FeeAmt = "0";
+            Dictionary<string, string> fee = PosPushDataNewHelper.GetFee("00000602H3R000100392323", FeeRate, FeeAmt, "1");
+            fee = PosPushDataNewHelper.GetFee2("00000602H3R000100392323", FeeRate, FeeAmt, "1");
+            FeeRate = fee["FeeRate"];
+            FeeAmt = fee["FeeAmt"];
             return "ok";
         }
 

+ 1 - 1
Startup.cs

@@ -195,7 +195,7 @@ namespace MySystem
                 SpDataHelper.Instance.Start("MainDataQueue");
                 SpDataHelper.Instance.StartData();
 
-                PosFeeHelper.Instance.Start(); //初始化机具名单
+                // PosFeeHelper.Instance.Start(); //初始化机具名单
 
                 // WifiCheckHelper.Instance.DoSomething();