Browse Source

调整拉卡拉费率设置

lcl 4 months ago
parent
commit
896e96cbb7

+ 51 - 17
AppStart/Helper/PublicImportDataService.cs

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

+ 1 - 1
AppStart/Helper/SetDepositPostService.cs

@@ -395,7 +395,7 @@ namespace MySystem
                                     {
                                         string content = PublicImportDataService.Instance.LkLSetFee(merchant.KqMerNo, Fee, addRate);
                                         JsonData obj = JsonMapper.ToObject(content);
-                                        if (obj["code"].ToString() == "000000")
+                                        if (obj["message"].ToString() == "SUCCESS")
                                         {
                                             pos.SeoDescription = "设置成功";
                                             SetRecordResult(db, RecordId, 1, "设置成功");

+ 6 - 3
Controllers/HomeController.cs

@@ -70,14 +70,17 @@ 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("00003102722201179813196", 0);
             // return PublicImportDataService.Instance.LkbSetFee("00000302QRNL20019214", 0.63M, 300);
             
-            return PublicImportDataService.Instance.LkLSetFee("00007302823221000005", 0.63M, 3);
+            return PublicImportDataService.Instance.LkLSetFee("100117947", 0.6M, 300);
 
-            // string content = "Oa4NF8tNLKthg9Q9klCLxyWtNJdAuL8n7NH5yM8VgM2eekpkzJ8/sFiY31NBo8qXGDcNi9GAiALsTZcEO5PAAZPsErhYQTeHoZ/cRkySVXm50r1aZ0osZfXysjrwvkP3lPLZzjeB21JldrUKviJ4k7YQunWC+B2Y4MX1ApZoTCw=";
+            // string content = "OiqJAGEVZSIrQmtKggTtFfSwtybN7gdJd6obHt27KfZIdMUzIsXIVtNdYGWHWr93f6kR1+5JUuwQ1ZP0Z/HxSKd2FeOAJpkgBWjzaOZV4badFJt7ptxVCN4QWAyCSKB+uyGAwwj2zo2S6wz/ongWGZexAZk8K6PKyz0aXyhm0rFPEDl2e4r68luLMI7hd4fVsoxE+455afZyLCv2jt3XCH7XcyaxHO8HR/BaHJDIWu8RQwaPYgx2gdiOftlybiiSDhJcI2S1plDH5uSfMrx/UCQ+2KqSfF/HjlLWXLUk1jwlSs6hNaCHYdO5T/6nRjfO+nB0vJtSS9j++Wi7fxM9dg==";
             
             // return PublicImportDataService.Instance.LklDecrypt(content);
+            //{"orgCode":"1951139","agentNo":29146077,"agencyNo":30342600,"externalCustomerNo":"82212108299005P","customerName":"��机****了饭","legalName":"徐*","posSn":"123081400101002052","posType":"PAPER_CODE","termNo":"A9323753","type":"UNBIND","operateTime":"2024-11-14 11:36:00"}
+            //{"orderNo":"20241113170425","userNo":29115902,"agencyNo":30324920,"customerNo":100132238,"externalCustomerNo":"822121070110BDQ","customerName":"好拓*************件二","legalName":"宋*杰","posSn":"HAOTKwzn20241113111","type":"DEPOSIT","transCardType":"01","extTransCode":"412001","termId":"012001","amount":40000000,"transTime":"2024-11-13 17:04:25"}
+            //{"logNo":"24111250702305","posSn":"00007902C32300000502","externalCustomerNo":"822121070110BDB","amount":8.0,"time":"2024-11-12 00:00:00","deductDate":"20241112","agencyNo":30343214}
         }
     
     }

+ 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();
             }
         }