From be379ab0bf3acc85c135ceba5e6a0ce99c7bd58d Mon Sep 17 00:00:00 2001
From: schangxiang@126.com <schangxiang@126.com>
Date: 周五, 04 4月 2025 15:54:07 +0800
Subject: [PATCH] 优化 修复检测bug

---
 Api/Util/AuthorizeHelper.cs |   27 ++++++++++++++++++++++-----
 1 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/Api/Util/AuthorizeHelper.cs b/Api/Util/AuthorizeHelper.cs
index 8937594..a97c2b9 100644
--- a/Api/Util/AuthorizeHelper.cs
+++ b/Api/Util/AuthorizeHelper.cs
@@ -17,11 +17,16 @@
         {
             try
             {
+                var licenseFolerName = input.LicenseFolerName;
+                if (string.IsNullOrEmpty(licenseFolerName))
+                {
+                    licenseFolerName = "lic";
+                }
                 //1銆佽幏鍙杕ac鍦板潃
                 var macAddresses = EnDecode.GetAllMacAddresses();
                 //2銆佹壘鍒� 鎺堟潈鏂囦欢
                 string baseDir = AppDomain.CurrentDomain.BaseDirectory;
-                DirectoryInfo theFolder = new DirectoryInfo(baseDir + @"\\AuthorizeFile\\lic");
+                DirectoryInfo theFolder = new DirectoryInfo(baseDir + @"\\AuthorizeFile\\" + licenseFolerName);
                 //閬嶅巻鏂囦欢,璇诲彇绗竴涓枃浠�
                 var files = theFolder.GetFiles();
                 if (files.Length == 0)
@@ -61,6 +66,12 @@
         /// <returns></returns>
         private static AuthorizeFunRetEntity ValidateLicenseForDev(string filePath, ValidateLicenseInput input, AuthorizeFunRetEntity newRet)
         {
+            var str_expiryDate = "";
+            if (!string.IsNullOrEmpty(newRet.expiryDate))
+            {
+                str_expiryDate = Convert.ToDateTime(newRet.expiryDate).ToString("yyyy-MM-dd HH:mm:ss");
+            }
+
             //璇诲彇 寮�鍙戞巿鏉�
             var val = EnDecode.ValidateDevLicense(filePath);
             if (val.IsValid)
@@ -68,16 +79,22 @@
                 if (input != null && input.WaringDays != null)
                 {
                     int waringDays = (int)input.WaringDays;
-                    if (waringDays >= val.RemainingDays)
+                    double _my_RemainingDays = Convert.ToDouble(val.RemainingDays.ToString("0.0"));
+                    if (waringDays >= _my_RemainingDays)
                     {
-                        return AuthorizeFunRetEntity.Success("鎴愬姛", val.RemainingDays, $"鎺堟潈鍓╀綑澶╂暟{val.RemainingDays}灏忎簬{waringDays}澶�");
+                        return AuthorizeFunRetEntity.Success("鎴愬姛", val.RemainingDays, $"鎺堟潈鍓╀綑澶╂暟{_my_RemainingDays}灏忎簬{waringDays}澶�,鍒版湡鏃{str_expiryDate}]");
                     }
                 }
                 return AuthorizeFunRetEntity.Success("鎴愬姛", val.RemainingDays, newRet);
             }
             else
-                return AuthorizeFunRetEntity.Fail("鎺堟潈澶辫触", val.RemainingDays, newRet);
-
+            {
+                if (string.IsNullOrEmpty(newRet.expiryDate))
+                {
+                    return AuthorizeFunRetEntity.Fail($"鎺堟潈澶辫触", val.RemainingDays, newRet);
+                }
+                return AuthorizeFunRetEntity.Fail($"鎺堟潈澶辫触,鍒版湡鏃{str_expiryDate}]", val.RemainingDays, newRet);
+            }
         }
 
     }

--
Gitblit v1.9.3