|
@@ -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
|
|
|
|