Kaynağa Gözat

对接拉卡拉服务费和费率接口,待续

lcl 6 gün önce
ebeveyn
işleme
89e8ec0f83
1 değiştirilmiş dosya ile 72 ekleme ve 0 silme
  1. 72 0
      AppStart/Helper/PublicImportDataService.cs

+ 72 - 0
AppStart/Helper/PublicImportDataService.cs

@@ -1245,6 +1245,78 @@ namespace MySystem
             // return new RSAHelper(RSAType.RSA, System.Text.Encoding.UTF8, clientPrivateKey, "").Sign(data);
         }
         #endregion
+        
+        #region 拉卡拉
+        // 生产环境
+        string lklClientId = "1";
+        string lklClientSecret = "1";
+        string lklReqUrl = "https://test.wsmsd.cn/sit";
+        string lklReqUrl2 = "https://test.wsmsd.cn/sit/htkmerchants/channel/customer/update/fee/";
+        
+        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");
+            function.WriteLog("返回报文\n" + result + "\n\n\n", "拉卡拉获取Token");
+            return result;
+        }
+        public string LkLSetDeposit(string sn, decimal serviceFee)
+        {
+            string target = "ZC0801TEST1HD1";
+            if(serviceFee == 0) target = "ZC0801TEST1HD1";
+            if(serviceFee == 99) target = "ZC0801TEST1HD1";
+            if(serviceFee == 199) target = "ZC0801TEST1HD1";
+            if(serviceFee == 299) target = "ZC0801TEST1HD1";
+            Dictionary<string, string> headers = new Dictionary<string, string>();
+            headers.Add("Authorization", "bearer " + 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" + result + "\n\n\n", "拉卡拉设置服务费");
+            return result;
+        }
+        public string LkLSetFee(string sn, decimal rate = 0.6M, int fee = 0)
+        {
+            List<Dictionary<string, string>> innerParamList = new List<Dictionary<string, string>>();
+            Dictionary<string, string> item = new Dictionary<string, string>();
+            item.Add("feeType", "R1012");
+            item.Add("fee", rate.ToString("f2"));
+            innerParamList.Add(item);
+            Dictionary<string, string> headers = new Dictionary<string, string>();
+            headers.Add("Authorization", "bearer " + LkLGetToken());
+            headers.Add("X-Trace", function.get_Random(32));
+            function.WriteLog("请求地址\n" + lkbReqUrl2, "来客吧L吧设置费率");
+            Dictionary<string, object> obj = new Dictionary<string, object>();
+            obj.Add("factorySequenceNo", sn);
+            obj.Add("productCode", "100");
+            obj.Add("productName", "来客吧");
+            obj.Add("fees", innerParamList);
+            string content = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
+            function.WriteLog("明文参数\n" + content, "来客吧L吧设置费率");
+            content = LkbEncrypt2(content);
+            string signstr = LkbSign(content);
+            headers.Add("X-Sign", signstr);
+            string req = "{\"param\":\"" + content + "\"}";
+            function.WriteLog("加密参数\n" + req, "来客吧L吧设置费率");
+            string result = function.PostWebRequest(lkbReqUrl2, req, headers, "application/json");
+            function.WriteLog("返回报文\n" + result + "\n\n\n", "来客吧L吧设置费率");
+            return result;
+        }
+        
+        #endregion