Browse Source

收银机登录调通了

zhangyang 6 years ago
parent
commit
8d341c3415

BIN
bin/Win32/Debug/zhipuzi_pos_windows/zhipuzi_pos_windows.exe


BIN
lewaimai_dispatch/RCa02172


BIN
lewaimai_dispatch/RCb02172


+ 12 - 15
lewaimai_dispatch/network/CZhipuziHttpClient.cpp

@@ -1,4 +1,4 @@
-#include "../pch/pch.h"
+#include "../pch/pch.h"
 #include "CZhipuziHttpClient.h"
 
 #include "rapidjson/document.h"
@@ -36,7 +36,7 @@ bool CZhipuziHttpClient::Login(std::string& errmsg)
 
 	if (!ret)
 	{
-		//网络请求出错
+		//缃戠粶璇锋眰鍑洪敊
 		LOG_INFO("network failed!");
 		errmsg = "network failed!";
 		return false;
@@ -48,8 +48,8 @@ bool CZhipuziHttpClient::Login(std::string& errmsg)
 	document.Parse(response.c_str());
 	if (!document.IsObject())
 	{
-		LOG_INFO("message 非法!");
-		errmsg = "message 非法!";
+		LOG_INFO("message 非法!");
+		errmsg = "message 非法!";
 		return false;
 	}
 
@@ -70,24 +70,21 @@ bool CZhipuziHttpClient::Login(std::string& errmsg)
 bool CZhipuziHttpClient::Request(std::string url, std::map<string, string> params, std::string& response)
 {
 	std::string timestamp = to_string(time(NULL));
-	std::string nonce = "12345";
+	std::string nonce = "123456";
 	std::string machinecode = "e6bc5694877b2aec";
 
 	std::string lwm_appid = "84b19199fd221a78c491cd553cbb4ab7";
 	std::string open_secret = "#repast!@#AfAS#@!";
 
-	std::string upper_passowrd = m_password;
-	transform(upper_passowrd.begin(), upper_passowrd.end(), upper_passowrd.begin(), ::toupper);
-
-	//先添加默认参数,用于计算签名
+	//鍏堟坊鍔犻粯璁ゅ弬鏁帮紝鐢ㄤ簬璁$畻绛惧悕
 	params["machinecode"] = machinecode;
 	params["username"] = m_username;
-	params["password"] = upper_passowrd;
+	params["password"] = md5(m_password);
 	params["lwm_appid"] = "84b19199fd221a78c491cd553cbb4ab7";
 	params["nonce"] = nonce;
 	params["timestamp"] = timestamp;
 
-	//计算签名
+	//璁$畻绛惧悕
 	std::string postString;
 	for (std::map<string, string>::iterator it = params.begin(); it != params.end(); )
 	{
@@ -103,7 +100,7 @@ bool CZhipuziHttpClient::Request(std::string url, std::map<string, string> param
 
 	LOG_INFO("postString:" << postString.c_str());
 
-	//用于计算签名的临时变量
+	//用于计算签名的临时变量
 	string tmp = md5(postString);
 	tmp += open_secret;
 
@@ -111,7 +108,7 @@ bool CZhipuziHttpClient::Request(std::string url, std::map<string, string> param
 	transform(sign.begin(), sign.end(), sign.begin(), ::toupper);
 	LOG_INFO("sign:" << sign.c_str());
 
-	//加上签名,去掉url,计算post
+	//鍔犱笂绛惧悕锛屽幓鎺塽rl锛岃�绠梡ost
 	params["sign"] = sign;
 
 	postString = "";
@@ -135,7 +132,7 @@ bool CZhipuziHttpClient::Request(std::string url, std::map<string, string> param
 
 	if (ret == 0)
 	{
-		//ret为0表示没有出错
+		//ret为0表示没有出错
 		return true;
 	}
 
@@ -144,7 +141,7 @@ bool CZhipuziHttpClient::Request(std::string url, std::map<string, string> param
 /*
 	rapidjson::Document doc;
 	doc.SetObject();
-	rapidjson::Document::AllocatorType &allocator = doc.GetAllocator(); //获取分配器
+	rapidjson::Document::AllocatorType &allocator = doc.GetAllocator(); //获取分配器
 
 	doc.AddMember(rapidjson::StringRef("useranme"), rapidjson::StringRef(m_username.c_str()), allocator);