|
@@ -1248,13 +1248,24 @@ namespace MySystem
|
|
|
#endregion
|
|
|
|
|
|
#region 拉卡拉
|
|
|
- // 生产环境
|
|
|
+
|
|
|
+ // 测试环境
|
|
|
string lklClientId = "testsit";
|
|
|
string lklClientSecret = "EguwEckByf2I6u6z";
|
|
|
+ string userName = "13200000001";
|
|
|
+ string password = "12345qwert";
|
|
|
string lklReqUrl = "https://test.wsmsd.cn/sit";
|
|
|
string lklPriKey = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKnlpXdmJcbZHxh3w3Ghy/5wXtUBQcFzRMXgw2d7uYjzAzbIQ/ZCAj6srWoN/obtkU+G62kgcpByGmiVtK4LS+BoelKM705SzV+mcr8mNmr2jwNq1SwDSfgVxx5z00FtXl3LnKvCujvGYOmx6+nX8h6IiyyLX6IP6cFaqpUXHsZVAgMBAAECgYA4NpeM7etJ48T6H4Y3LsWEJkH6UDQlgbIblsaQkstMmLtTgOebrzN28UNfd8njcu9FVOrHGclOKbK7L+1cOLiduWsZKc/c/gAy9wAR4EhoLvlerH9EEPiPWFxdEDbMxPqlkpqLOo+PxHrhTn4vU4CaPdJtL2ujKn7nmsUdUDWo8QJBANS1TlM6nhPt2XlzN5kGfsJ4kBYNjuLXNA2YdNuC2ttYvEXHJ9T70FN/GnRBBIZu47uHH3Ie5nfep+qMk6a8RP8CQQDMecIyI0z1kVt+tOfWKw2ZFLsi74708qTaeR4W1ABtkngj1+bxoWWXr3KqhjqJkWxnhioSfXqu7CScNzjdM1CrAkAQd+ESjI1EmbumrYb2cAxMXi05p98SLPs4uj8B58WuCda5yEuLL9vXOxX/PjFtfxRepn2GxmGtki2J+UxNMnJdAkAFoORjlO0tZU7rcfdfwdeh+xwbnhSFUZiQGv1lC3jnizybX/oPdK3jOwUhBIjf+IzPXLYTxDh4UC/BzRNXo235AkEAhgYBk6H7RU2iIuvwz1c6CtE1gJ8DvEp1F0KOMWMFB0KCpDXUToix0dlMz962FozYENi4X4zYQo6nFwlXeS3Pfw==";
|
|
|
- string lklPubKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCp5aV3ZiXG2R8Yd8Nxocv+cF7VAUHBc0TF4MNne7mI8wM2yEP2QgI+rK1qDf6G7ZFPhu tpIHKQchpolbSuC0vgaHpSjO9OUs1fpnK/JjZq9o8DatUsA0n4Fccec9NBbV5dy5yrwro7xmDpsevp1/IeiIssi1+iD+nBWqqVFx7GVQIDAQAB"; //解密api接口返回报文
|
|
|
- // string lklPubKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCKPK6iG+eNwCRRs1lzE4bUyp6n0GMcj9s6lEPLIEYRpBHCCHpfGZ422SLwHqQ9zcU88lMbqfuSfQuJiPhNAqMHgmT7n2gYfxotL311lw1qG2ARJRSIyQ3oHXS6GBe9kFRWK8I/sVbuRxeV+toUs9N2EPjKequY28oxl9+AU3U6gQIDAQAB"; //解密推送消息
|
|
|
+ string lklPubKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCp5aV3ZiXG2R8Yd8Nxocv+cF7VAUHBc0TF4MNne7mI8wM2yEP2QgI+rK1qDf6G7ZFPhu tpIHKQchpolbSuC0vgaHpSjO9OUs1fpnK/JjZq9o8DatUsA0n4Fccec9NBbV5dy5yrwro7xmDpsevp1/IeiIssi1+iD+nBWqqVFx7GVQIDAQAB";
|
|
|
+
|
|
|
+ // 生产环境
|
|
|
+ // string lklClientId = "testsit";
|
|
|
+ // string lklClientSecret = "EguwEckByf2I6u6z";
|
|
|
+ // string userName = "13200000001";
|
|
|
+ // string password = "12345qwert";
|
|
|
+ // string lklReqUrl = "https://tkapi.lakala.com";
|
|
|
+ // string lklPriKey = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKnlpXdmJcbZHxh3w3Ghy/5wXtUBQcFzRMXgw2d7uYjzAzbIQ/ZCAj6srWoN/obtkU+G62kgcpByGmiVtK4LS+BoelKM705SzV+mcr8mNmr2jwNq1SwDSfgVxx5z00FtXl3LnKvCujvGYOmx6+nX8h6IiyyLX6IP6cFaqpUXHsZVAgMBAAECgYA4NpeM7etJ48T6H4Y3LsWEJkH6UDQlgbIblsaQkstMmLtTgOebrzN28UNfd8njcu9FVOrHGclOKbK7L+1cOLiduWsZKc/c/gAy9wAR4EhoLvlerH9EEPiPWFxdEDbMxPqlkpqLOo+PxHrhTn4vU4CaPdJtL2ujKn7nmsUdUDWo8QJBANS1TlM6nhPt2XlzN5kGfsJ4kBYNjuLXNA2YdNuC2ttYvEXHJ9T70FN/GnRBBIZu47uHH3Ie5nfep+qMk6a8RP8CQQDMecIyI0z1kVt+tOfWKw2ZFLsi74708qTaeR4W1ABtkngj1+bxoWWXr3KqhjqJkWxnhioSfXqu7CScNzjdM1CrAkAQd+ESjI1EmbumrYb2cAxMXi05p98SLPs4uj8B58WuCda5yEuLL9vXOxX/PjFtfxRepn2GxmGtki2J+UxNMnJdAkAFoORjlO0tZU7rcfdfwdeh+xwbnhSFUZiQGv1lC3jnizybX/oPdK3jOwUhBIjf+IzPXLYTxDh4UC/BzRNXo235AkEAhgYBk6H7RU2iIuvwz1c6CtE1gJ8DvEp1F0KOMWMFB0KCpDXUToix0dlMz962FozYENi4X4zYQo6nFwlXeS3Pfw==";
|
|
|
+ // string lklPubKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCp5aV3ZiXG2R8Yd8Nxocv+cF7VAUHBc0TF4MNne7mI8wM2yEP2QgI+rK1qDf6G7ZFPhu tpIHKQchpolbSuC0vgaHpSjO9OUs1fpnK/JjZq9o8DatUsA0n4Fccec9NBbV5dy5yrwro7xmDpsevp1/IeiIssi1+iD+nBWqqVFx7GVQIDAQAB";
|
|
|
|
|
|
public string LkLGetToken()
|
|
|
{
|
|
@@ -1263,14 +1274,6 @@ namespace MySystem
|
|
|
{
|
|
|
Dictionary<string, string> headers = new Dictionary<string, string>();
|
|
|
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");
|
|
|
JsonData jsonObj = JsonMapper.ToObject(result);
|
|
@@ -1279,7 +1282,31 @@ namespace MySystem
|
|
|
access_token = jsonObj["access_token"].ToString();
|
|
|
string expires_in = jsonObj["expires_in"].ToString();
|
|
|
RedisDbconn.Instance.Set("LkLApiToken", access_token);
|
|
|
- RedisDbconn.Instance.SetExpire("LkLApiToken", int.Parse(function.CheckInt(expires_in)));
|
|
|
+ RedisDbconn.Instance.SetExpire("LkLApiToken", int.Parse(function.CheckInt(expires_in)) - 10);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return access_token;
|
|
|
+ //{"access_token":"a54b216a-18b7-4a0b-b6b7-b37eee813b6e","token_type":"bearer","expires_in":872822,"scope":"all"}
|
|
|
+ }
|
|
|
+ public string LkLGetToken2()
|
|
|
+ {
|
|
|
+ string access_token = RedisDbconn.Instance.Get<string>("LkLApiToken2");
|
|
|
+ if(string.IsNullOrEmpty(access_token))
|
|
|
+ {
|
|
|
+ Dictionary<string, string> headers = new Dictionary<string, string>();
|
|
|
+ headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(lklClientId + ":" + lklClientSecret)));
|
|
|
+ function.WriteLog("请求地址\n" + lklReqUrl + "/htkauth/oauth/token", "拉卡拉获取Token2");
|
|
|
+ string reqStr = "grant_type=password&username=" + userName + "&password=" + password;
|
|
|
+ function.WriteLog("请求参数\n" + reqStr, "拉卡拉获取Token2");
|
|
|
+ string result = function.PostWebRequest(lklReqUrl + "/htkauth/oauth/token", reqStr, headers);
|
|
|
+ function.WriteLog("返回报文\n" + result + "\n\n\n", "拉卡拉获取Token2");
|
|
|
+ JsonData jsonObj = JsonMapper.ToObject(result);
|
|
|
+ if(result.Contains("\"access_token\""))
|
|
|
+ {
|
|
|
+ access_token = jsonObj["access_token"].ToString();
|
|
|
+ string expires_in = jsonObj["expires_in"].ToString();
|
|
|
+ RedisDbconn.Instance.Set("LkLApiToken2", access_token);
|
|
|
+ RedisDbconn.Instance.SetExpire("LkLApiToken2", int.Parse(function.CheckInt(expires_in)) - 10);
|
|
|
}
|
|
|
}
|
|
|
return access_token;
|
|
@@ -1310,25 +1337,32 @@ namespace MySystem
|
|
|
}
|
|
|
public string LkLSetFee(string merNo, decimal rate = 0.6M, int fee = 0)
|
|
|
{
|
|
|
+ // rate = rate / 100;
|
|
|
List<Dictionary<string, string>> innerParamList = new List<Dictionary<string, string>>();
|
|
|
Dictionary<string, string> item = new Dictionary<string, string>();
|
|
|
item.Add("feeType", "CREDIT_CARD");
|
|
|
item.Add("fee", rate.ToString("f2"));
|
|
|
innerParamList.Add(item);
|
|
|
+ item = new Dictionary<string, string>();
|
|
|
+ item.Add("feeType", "CARD_SECOND");
|
|
|
+ item.Add("fee", fee.ToString());
|
|
|
+ innerParamList.Add(item);
|
|
|
Dictionary<string, string> headers = new Dictionary<string, string>();
|
|
|
- headers.Add("Authorization", "bearer " + LkLGetToken());
|
|
|
+ headers.Add("Authorization", "bearer " + LkLGetToken2());
|
|
|
function.WriteLog("请求地址\n" + lklReqUrl + "/htkmerchants/channel/customer/update/fee/" + merNo, "拉卡拉设置费率");
|
|
|
+ function.WriteLog("header\n" + Newtonsoft.Json.JsonConvert.SerializeObject(headers), "拉卡拉设置费率");
|
|
|
Dictionary<string, object> obj = new Dictionary<string, object>();
|
|
|
// obj.Add("productCode", "");
|
|
|
obj.Add("fees", innerParamList);
|
|
|
string content = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
|
|
|
function.WriteLog("明文参数\n" + content, "拉卡拉设置费率");
|
|
|
- content = LklEncrypt(content);
|
|
|
- string req = "{\"dto\":\"" + content + "\"}";
|
|
|
- function.WriteLog("加密参数\n" + req, "拉卡拉设置费率");
|
|
|
- string result = function.PostWebRequest(lklReqUrl + "/htkmerchants/channel/customer/update/fee/" + merNo, req, headers);
|
|
|
+ // content = LklEncrypt(content);
|
|
|
+ // content = "{\"dto\":\"" + content + "\"}";
|
|
|
+ // function.WriteLog("加密参数\n" + req, "拉卡拉设置费率");
|
|
|
+ string result = PostWebRequest(lklReqUrl + "/htkmerchants/channel/customer/update/fee/" + merNo, content, headers);
|
|
|
function.WriteLog("返回报文\n" + result + "\n\n\n", "拉卡拉设置费率");
|
|
|
return result;
|
|
|
+ //{"message":"SUCCESS","reviewRelatedId":130200781873162}
|
|
|
}
|
|
|
|
|
|
public string LklEncrypt(string data)
|