lcl 2 dagar sedan
förälder
incheckning
5df566e0ed
3 ändrade filer med 68 tillägg och 24 borttagningar
  1. 57 15
      AppStart/Helper/PublicImportDataService.cs
  2. 4 2
      Controllers/HomeController.cs
  3. 7 7
      Startup.cs

+ 57 - 15
AppStart/Helper/PublicImportDataService.cs

@@ -1248,22 +1248,25 @@ namespace MySystem
         
         #region 拉卡拉
         // 生产环境
-        string lklClientId = "1";
-        string lklClientSecret = "1";
+        string lklClientId = "testsit";
+        string lklClientSecret = "EguwEckByf2I6u6z";
         string lklReqUrl = "https://test.wsmsd.cn/sit";
         string lklReqUrl2 = "https://test.wsmsd.cn/sit/htkmerchants/channel/customer/update/fee/";
+        string lklPriKey = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAIo8rqIb543AJFGzWXMThtTKnqfQYxyP2zqUQ8sgRhGkEcIIel8ZnjbZIvAepD3NxTzyUxup+5J9C4mI+E0CoweCZPufaBh/Gi0vfXWXDWobYBElFIjJDegddLoYF72QVFYrwj+xVu5HF5X62hSz03YQ+Mp6q5jbyjGX34BTdTqBAgMBAAECgYAGgLmmlbVWJEn1F7CzVpGg+pXdbzKtYBlME3fPszFGoMsmz3kptnncSsk/ZlKbt22CCyR0lIHJi6U2e2VyUneep+vzSlvZdpdB4EgGZw3gLC7Cvz5bb9Uh3QJwBBoSHMdDBUnx/dYgnJhitCq/akH23LdyBpkYHx037W0EG+XaEQJBAMC9xgukaD2GsbRzspZeTWQToLh7K6Gz7o4VAg0r/ph2Lm/Z/jzjrahXzjcxSdwnMJmFJagDgFbmprZU5PWCMNECQQC3m25z/v3//TkkAzERV1Pjw/+d/h7Nd8I8G9wD9ZLGCO0JqMf+eugVXQ9dRyTC7xSuuV7EQAAMFRDbBGzsyFqxAkEAiPLOk1sgDgd0oMlMbXdX+fHQUwSBfgYBTMc0i/NklSPz3tm/wbfsnh61kZXd6yWVbJ+kn/rM5/I/JnKvtJnq4QJAJXwyPLRenxjPxa5xIh02H1Ywpczv9PrySNtXO+ezI4NHAaXXzvjA0TvCm0SfGL0+970Yv/BhEhZq7owkwOLWwQJBAIbcVtekbSVY/BaY5hJQ0JqjhfQBnhKJGH5a8WYMsvoy3Vd4vNITwTJMMjz7NsRTlp3NtJTr9E165WpqTnK17no=";
         
         public string LkLGetToken()
         {
             Dictionary<string, string> headers = new Dictionary<string, string>();
-            headers.Add("Authorization", "Basic " + lklClientId + ":" + lklClientSecret);
-            Dictionary<string, string> req = new Dictionary<string, string>();
-            req.Add("grant_type", "client_credentials");
-            req.Add("client_id", lklClientId);
-            req.Add("client_secret", lklClientSecret);
-            string reqStr = Newtonsoft.Json.JsonConvert.SerializeObject(req);
-            function.WriteLog("请求参数\n" + req, "拉卡拉获取Token");
-            string result = function.PostWebRequest(lklReqUrl + "/htkauth/oauth/token", reqStr, headers, "application/json");
+            headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(lklClientId + ":" + lklClientSecret)));
+            // Dictionary<string, string> req = new Dictionary<string, string>();
+            // req.Add("grant_type", "client_credentials");
+            // req.Add("client_id", lklClientId);
+            // req.Add("client_secret", lklClientSecret);
+            // string reqStr = Newtonsoft.Json.JsonConvert.SerializeObject(req);
+            // function.WriteLog("请求参数\n" + reqStr, "拉卡拉获取Token");
+            // reqStr = LklEncrypt(reqStr);
+            // function.WriteLog("加密参数\n" + reqStr, "拉卡拉获取Token");
+            string result = function.PostWebRequest(lklReqUrl + "/htkauth/oauth/token?grant_type=client_credentials&client_id=" + lklClientId + "&client_secret=" + lklClientSecret, "", headers, "application/json");
             function.WriteLog("返回报文\n" + result + "\n\n\n", "拉卡拉获取Token");
             return result;
         }
@@ -1275,16 +1278,16 @@ namespace MySystem
             if(serviceFee == 199) target = "ZC0801TEST1HD1";
             if(serviceFee == 299) target = "ZC0801TEST1HD1";
             Dictionary<string, string> headers = new Dictionary<string, string>();
-            headers.Add("Authorization", "bearer " + LkLGetToken());
+            headers.Add("Authorization", "bearer a54b216a-18b7-4a0b-b6b7-b37eee813b6e");// + LkLGetToken());
             Dictionary<string, string> req = new Dictionary<string, string>();
             req.Add("posSn", sn);
             req.Add("type", "ACTIVITY");
             req.Add("target", target);
             string reqStr = Newtonsoft.Json.JsonConvert.SerializeObject(req);
-            function.WriteLog("请求参数\n" + req, "拉卡拉设置服务费");
-            string reqEncrypt = reqStr;
-            function.WriteLog("加密参数\n" + reqEncrypt, "拉卡拉设置服务费");
-            string result = function.PostWebRequest(lklReqUrl + "/htkterminal/open/terminal/change/activity/amount", reqEncrypt, headers, "application/json");
+            function.WriteLog("请求参数\n" + reqStr, "拉卡拉设置服务费");
+            reqStr = LklEncrypt(reqStr);
+            function.WriteLog("加密参数\n" + reqStr, "拉卡拉设置服务费");
+            string result = function.PostWebRequest(lklReqUrl + "/htkterminal/open/terminal/change/activity/amount", reqStr, headers, "application/json");
             function.WriteLog("返回报文\n" + result + "\n\n\n", "拉卡拉设置服务费");
             return result;
         }
@@ -1315,6 +1318,45 @@ namespace MySystem
             function.WriteLog("返回报文\n" + result + "\n\n\n", "来客吧L吧设置费率");
             return result;
         }
+
+        public string LklEncrypt(string data)
+        {
+            var rsa = RSA.Create();
+            var key = Convert.FromBase64String(lklPriKey);
+            var content = Encoding.UTF8.GetBytes(data);
+            rsa.ImportPkcs8PrivateKey(key, out _);
+
+            var result = LklEncryptData(rsa, content);
+
+            return Convert.ToBase64String(result);
+            // return new RSAHelper(RSAType.RSA, System.Text.Encoding.UTF8, lklPriKey).Encrypt(data);
+        }
+
+        public byte[] LklEncryptData(RSA rsa, byte[] data)
+        {
+            using var memoryStream = new System.IO.MemoryStream();
+            int offset = 0;
+            byte[] buffer;
+    
+            while (offset < data.Length)
+            {
+                if (offset + 117 < data.Length)
+                {
+                    buffer = data.AsSpan(offset, 117).ToArray();
+                }
+                else
+                {
+                    buffer = data.AsSpan(offset, data.Length - offset).ToArray();
+                }
+    
+                byte[] encrypted = rsa.Encrypt(buffer, RSAEncryptionPadding.Pkcs1);
+                memoryStream.Write(encrypted);
+    
+                offset += buffer.Length;
+            }
+    
+            return memoryStream.ToArray();
+        }
         
         #endregion
 

+ 4 - 2
Controllers/HomeController.cs

@@ -70,9 +70,11 @@ namespace MySystem.Controllers
             // {"existsFlag":"1","feeList":[{"feeCalcType":"M1","fixed":"0","rate":"0.24"},{"feeCalcType":"M2","fixed":"0","rate":"0.24"},{"feeCalcType":"M3","fixed":"0","rate":"0.38"},{"feeCalcType":"M4","fixed":"0","rate":"2.63"},{"feeCalcType":"M5","fixed":"0","rate":"0.63"},{"feeCalcType":"M7","fixed":"0"},{"feeCalcType":"M8","fixed":"0"},{"feeCalcType":"M9","fixed":"0"},{"feeCalcType":"T0","fixed":"1","rate":"300"}],"merchNo":"N00000D0022G499","ret_code":"00","ret_msg":"请求成功"}
 
             // return PublicImportDataService.Instance.SetLiSWeFee("WME52S0151221", "N00000C05U77807", "0.63", "300");
-            return PublicImportDataService.Instance.LkbSetDeposit("00000302QRNL15510103", 299);
+            // return PublicImportDataService.Instance.LkbSetDeposit("00000302QRNL15510103", 299);
             // return PublicImportDataService.Instance.LkbSetFee("00000302QRNL20019214", 0.63M, 300);
-        }   
+            
+            return PublicImportDataService.Instance.LkLSetDeposit("0000010222ATBEL00292", 299);
+        }
     
     }
 }

+ 7 - 7
Startup.cs

@@ -147,14 +147,14 @@ namespace MySystem
             }
             if(Library.ConfigurationManager.EnvironmentFlag == 2)
             {
-                SetFeeFlagService.Instance.Start(); //85天提前通知创客费率调升消息
-                SetDepositService.Instance.Start(); //调整费率(通知、标记)
-                SetDepositPostService.Instance.Start(); //提交支付公司设置费率接口
-                SetDepositPostService.Instance.StartKdb(); //监控开店宝费率设置结果
-                ChangePosFeeQueue.Instance.StartEverTime(); //设置服务费
-                SetSftFeeService.Instance.Start(); //盛付通420天费率加万2
+                // SetFeeFlagService.Instance.Start(); //85天提前通知创客费率调升消息
+                // SetDepositService.Instance.Start(); //调整费率(通知、标记)
+                // SetDepositPostService.Instance.Start(); //提交支付公司设置费率接口
+                // SetDepositPostService.Instance.StartKdb(); //监控开店宝费率设置结果
+                // ChangePosFeeQueue.Instance.StartEverTime(); //设置服务费
+                // SetSftFeeService.Instance.Start(); //盛付通420天费率加万2
 
-                TmpService.Instance.Start();
+                // TmpService.Instance.Start();
             }
         }