张洋 6 лет назад
Родитель
Сommit
5b97a1566a

BIN
bin/Win32/Debug/zhipuzi_pay_plugin/zpzDll.dll


BIN
lib/debug/zpzDll.lib


+ 16 - 5
zhipuzi_pay_plugin/network/CZhipuziHttpClient.cpp

@@ -90,11 +90,22 @@ bool CZhipuziHttpClient::Login(std::string& errmsg)
 
 	if (m_client.m_version_type == "1")
 	{
-		m_client.m_yewu_ur = "https://cyapi.zhipuzi.com/pos";
+		if (m_client.m_env == RELEASE)
+		{
+			m_client.m_yewu_url = "https://cyapi.zhipuzi.com/pos";
+		}
+		else if (m_client.m_env == TEST)
+		{
+			m_client.m_yewu_url = "https://cyapi-test.zhipuzi.com/pos";
+		}
+		else if (m_client.m_env == DEV)
+		{
+			m_client.m_yewu_url = "https://cyapi-test.zhipuzi.com/pos";
+		}
 	}
 	else
 	{
-		m_client.m_yewu_ur = "https://lsapi.zhipuzi.com/pos";
+		m_client.m_yewu_url = "https://lsapi.zhipuzi.com/pos";
 	}
 
 	rapidjson::Value& v_lwm_sess_token = v_data["lwm_sess_token"];
@@ -114,7 +125,7 @@ bool CZhipuziHttpClient::Request(std::string url, std::map<string, string> param
     params["username"] = m_client.m_username;
     params["nonce"] = nonce;
     params["timestamp"] = timestamp;
-    params["url"] = m_client.m_yewu_ur + url;
+    params["url"] = m_client.m_yewu_url + url;
 	params["machinecode"] = "d31a20c2567006c5";
 
     //计算签名
@@ -164,7 +175,7 @@ bool CZhipuziHttpClient::Request(std::string url, std::map<string, string> param
     LOG_INFO("postString:" << postString.c_str());
 
     CHttpClient m_httpClient;
-    int ret = m_httpClient.Posts(m_client.m_yewu_ur + url, postString, response, NULL);
+    int ret = m_httpClient.Posts(m_client.m_yewu_url + url, postString, response, NULL);
 
     LOG_INFO("response:" << response.c_str());
 
@@ -236,7 +247,7 @@ bool CZhipuziHttpClient::RequestNew(std::string url, std::map<string, string> pa
 	LOG_INFO("postString:" << postString.c_str());
 
 	CHttpClient m_httpClient;
-	int ret = m_httpClient.Posts(m_client.m_yewu_ur + url, postString, response, NULL);
+	int ret = m_httpClient.Posts(m_client.m_yewu_url + url, postString, response, NULL);
 
 	LOG_INFO("response:" << response.c_str());
 

+ 11 - 1
zhipuzi_pay_plugin/network/CZhipuziHttpClient.h

@@ -2,12 +2,20 @@
 
 #include "CHttpClient.h"
 
+
 class CZhipuziHttpClient
 {
 public:
     CZhipuziHttpClient();
     ~CZhipuziHttpClient();
 
+	enum Env
+	{
+		DEV,
+		TEST,
+		RELEASE
+	};
+
 public:
     static void Init(std::string username, std::string password);
 
@@ -26,10 +34,12 @@ public:
     std::string m_password;
 
     std::string m_pingtai_url = "https://pf-api.zhipuzi.com/pos";
-	std::string m_yewu_ur = "";
+	std::string m_yewu_url = "";
 
 	std::string m_version_type;
 	std::string lwm_sess_token;
 
 	std::string m_shopname;
+
+	Env m_env = RELEASE;
 };