Browse Source

登录先跑通了

张洋 4 years ago
parent
commit
556d098ee5

BIN
bin/Win32/Debug/zhipuzi_pos_windows/db/pos.db


+ 1 - 1
bin/Win32/Debug/zhipuzi_pos_windows/skin/main.xml

@@ -13,7 +13,7 @@
     		<Control height="2" bkcolor="#FFD1EDFF" />
     		<HorizontalLayout height="90" bkcolor="#FF8DD3FF" bkcolor2="#FF60B1FE">
     			<VerticalLayout width="600">
-    				<Label name="main_name_version" text="乐外卖接单软件" padding="5,5,0,0"/>
+    				<Label name="main_name_version" text="智铺子接单软件" padding="5,5,0,0"/>
     			</VerticalLayout>
     			<HorizontalLayout childpadding="20" inset="10,16,10,10" >    				
     				<Control />

+ 1 - 1
bin/Win32/Debug/zhipuzi_pos_windows/skin/setting.xml

@@ -191,7 +191,7 @@
 
 				<VerticalLayout bkcolor="#FFFFFFFF" padding="0,20,20,20" inset="15,15,15,15">
 					<Control height="300" />
-					<Label text="乐外卖接单软件" align="center">
+					<Label text="智铺子接单软件" align="center">
 					</Label>
 					<Label name="setting_version" text="版本号:1.0.0.1" align="center">
 					</Label>

+ 1 - 1
bin/Win32/Debug/zhipuzi_pos_windows_server/conf/pathplanning.conf

@@ -28,7 +28,7 @@ debug_pos_task_queue = zhipuzi-pos-windows-dev
 #mns.accesskeyid = LTAIpYffXvFnEUzp
 #mns.accesskeysecret = F3lqBxo6Uj9pJpLs7btMW5u30X5uKB
 
-#乐外卖
+#智铺子
 mns.accountendpoint = https://1111769578085953.mns.cn-hangzhou.aliyuncs.com/
 mns.accesskeyid = 2HUnzc9XJV92PjvW
 mns.accesskeysecret = 20mMc8wuzlfC0r323b6oJqxlBPEyjW

+ 1 - 1
bin/Win32/Release/setup/listen.txt

@@ -4,4 +4,4 @@
 
 3.本协议的最终解释权归深圳市迅享智慧云科技有限公司所有;
 
-乐外卖官网 https://www.zhipuzi.com/
+智铺子官网 https://www.zhipuzi.com/

+ 224 - 172
zhipuzi_pos_windows/network/CHttpClient.cpp

@@ -4,7 +4,7 @@
 #include <curl/curl.h>
 
 CHttpClient::CHttpClient(void) :
-    m_bDebug(false)
+	m_bDebug(false)
 {
 
 }
@@ -16,202 +16,254 @@ CHttpClient::~CHttpClient(void)
 
 static int OnDebug(CURL *, curl_infotype itype, char * pData, size_t size, void *)
 {
-    if(itype == CURLINFO_TEXT)
-    {
-        //printf("[TEXT]%s\n", pData);
-    }
-    else if(itype == CURLINFO_HEADER_IN)
-    {
-        printf("[HEADER_IN]%s\n", pData);
-    }
-
-    else if(itype == CURLINFO_HEADER_OUT)
-    {
-        printf("[HEADER_OUT]%s\n", pData);
-    }
-
-    else if(itype == CURLINFO_DATA_IN)
-    {
-        printf("[DATA_IN]%s\n", pData);
-    }
-
-    else if(itype == CURLINFO_DATA_OUT)
-    {
-        printf("[DATA_OUT]%s\n", pData);
-    }
-
-    return 0;
+	if (itype == CURLINFO_TEXT)
+	{
+		//printf("[TEXT]%s\n", pData);
+	}
+	else if (itype == CURLINFO_HEADER_IN)
+	{
+		printf("[HEADER_IN]%s\n", pData);
+	}
+
+	else if (itype == CURLINFO_HEADER_OUT)
+	{
+		printf("[HEADER_OUT]%s\n", pData);
+	}
+
+	else if (itype == CURLINFO_DATA_IN)
+	{
+		printf("[DATA_IN]%s\n", pData);
+	}
+
+	else if (itype == CURLINFO_DATA_OUT)
+	{
+		printf("[DATA_OUT]%s\n", pData);
+	}
+
+	return 0;
 }
 
 static size_t OnWriteData(void* buffer, size_t size, size_t nmemb, void* lpVoid)
 {
-    std::string* str = dynamic_cast<std::string*>((std::string *)lpVoid);
+	std::string* str = dynamic_cast<std::string*>((std::string *)lpVoid);
 
-    if(NULL == str || NULL == buffer)
-    {
-        return -1;
-    }
+	if (NULL == str || NULL == buffer)
+	{
+		return -1;
+	}
 
-    char* pData = (char*)buffer;
-    str->append(pData, size * nmemb);
-    return nmemb;
+	char* pData = (char*)buffer;
+	str->append(pData, size * nmemb);
+	return nmemb;
 }
 
-int CHttpClient::Post(const std::string & strUrl, const std::string & strPost, std::string & strResponse)
+int CHttpClient::Post(const std::string & strUrl, const std::string & strPost, std::string & strResponse, CZhipuziHttpProxy proxy)
 {
-    CURLcode res;
-    CURL* curl = curl_easy_init();
-
-    if(NULL == curl)
-    {
-        return CURLE_FAILED_INIT;
-    }
-
-    if(m_bDebug)
-    {
-        curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
-        curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, OnDebug);
-    }
-
-    curl_easy_setopt(curl, CURLOPT_URL, strUrl.c_str());
-    curl_easy_setopt(curl, CURLOPT_POST, 1);
-    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, strPost.c_str());
-    curl_easy_setopt(curl, CURLOPT_READFUNCTION, NULL);
-    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, OnWriteData);
-    curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&strResponse);
-    curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
-    curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 8);//连接超时,这个数值如果设置太短可能导致数据请求不到就断开了
-    curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10);//接收数据时超时设置,如果10秒内数据未接收完,直接退出
-    res = curl_easy_perform(curl);
-    curl_easy_cleanup(curl);
-    return res;
+	CURLcode res;
+	CURL* curl = curl_easy_init();
+
+	if (NULL == curl)
+	{
+		return CURLE_FAILED_INIT;
+	}
+
+	if (m_bDebug)
+	{
+		curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
+		curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, OnDebug);
+	}
+
+	curl_easy_setopt(curl, CURLOPT_URL, strUrl.c_str());
+	curl_easy_setopt(curl, CURLOPT_POST, 1);
+	curl_easy_setopt(curl, CURLOPT_POSTFIELDS, strPost.c_str());
+	curl_easy_setopt(curl, CURLOPT_READFUNCTION, NULL);
+	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, OnWriteData);
+	curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&strResponse);
+
+	if (proxy.m_is_proxy)
+	{
+		std::string addr = proxy.ip + ":" + proxy.port;
+		curl_easy_setopt(curl, CURLOPT_PROXY, addr.c_str());
+		curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
+
+		if (!proxy.username.empty() && !proxy.password.empty())
+		{
+			curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, (proxy.username + ":" + proxy.password).c_str());
+		}
+	}
+
+	curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
+	curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 8);//连接超时,这个数值如果设置太短可能导致数据请求不到就断开了
+	curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10);//接收数据时超时设置,如果10秒内数据未接收完,直接退出
+	res = curl_easy_perform(curl);
+	curl_easy_cleanup(curl);
+	return res;
 }
 
-int CHttpClient::Get(const std::string & strUrl, std::string & strResponse)
+int CHttpClient::Get(const std::string & strUrl, std::string & strResponse, CZhipuziHttpProxy proxy)
 {
-    CURLcode res;
-    CURL* curl = curl_easy_init();
-
-    if(NULL == curl)
-    {
-        return CURLE_FAILED_INIT;
-    }
-
-    if(m_bDebug)
-    {
-        curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
-        curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, OnDebug);
-    }
-
-    curl_easy_setopt(curl, CURLOPT_URL, strUrl.c_str());
-    curl_easy_setopt(curl, CURLOPT_READFUNCTION, NULL);
-    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, OnWriteData);
-    curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&strResponse);
-    /**
-    * 当多个线程都使用超时处理的时候,同时主线程中有sleep或是wait等操作。
-    * 如果不设置这个选项,libcurl将会发信号打断这个wait从而导致程序退出。
-    */
-    curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
-    curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 8);//连接超时,这个数值如果设置太短可能导致数据请求不到就断开了
-    curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10);//接收数据时超时设置,如果10秒内数据未接收完,直接退出
-    res = curl_easy_perform(curl);
-    curl_easy_cleanup(curl);
-    return res;
+	CURLcode res;
+	CURL* curl = curl_easy_init();
+
+	if (NULL == curl)
+	{
+		return CURLE_FAILED_INIT;
+	}
+
+	if (m_bDebug)
+	{
+		curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
+		curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, OnDebug);
+	}
+
+	curl_easy_setopt(curl, CURLOPT_URL, strUrl.c_str());
+	curl_easy_setopt(curl, CURLOPT_READFUNCTION, NULL);
+	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, OnWriteData);
+	curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&strResponse);
+
+	if (proxy.m_is_proxy)
+	{
+		std::string addr = proxy.ip + ":" + proxy.port;
+		curl_easy_setopt(curl, CURLOPT_PROXY, addr.c_str());
+		curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
+
+		if (!proxy.username.empty() && !proxy.password.empty())
+		{
+			curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, (proxy.username + ":" + proxy.password).c_str());
+		}
+	}
+
+	/**
+	* 当多个线程都使用超时处理的时候,同时主线程中有sleep或是wait等操作。
+	* 如果不设置这个选项,libcurl将会发信号打断这个wait从而导致程序退出。
+	*/
+	curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
+	curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 8);//连接超时,这个数值如果设置太短可能导致数据请求不到就断开了
+	curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10);//接收数据时超时设置,如果10秒内数据未接收完,直接退出
+	res = curl_easy_perform(curl);
+	curl_easy_cleanup(curl);
+	return res;
 }
 
 /*
  *返回值说明 https://blog.csdn.net/u011857683/article/details/53069268
  **/
-int CHttpClient::Posts(const std::string & strUrl, const std::string & strPost, std::string & strResponse, const char * pCaPath)
+int CHttpClient::Posts(const std::string & strUrl, const std::string & strPost, std::string & strResponse, const char * pCaPath, CZhipuziHttpProxy proxy)
 {
-    CURLcode res;
-    CURL* curl = curl_easy_init();
-
-    if(NULL == curl)
-    {
-        return CURLE_FAILED_INIT;
-    }
-
-    if(m_bDebug)
-    {
-        curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
-        curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, OnDebug);
-    }
-
-    curl_easy_setopt(curl, CURLOPT_URL, strUrl.c_str());
-    curl_easy_setopt(curl, CURLOPT_POST, 1);
-    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, strPost.c_str());
-    curl_easy_setopt(curl, CURLOPT_READFUNCTION, NULL);
-    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, OnWriteData);
-    curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&strResponse);
-    curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
-    //curl_easy_setopt(curl, CURLOPT_COOKIE, "lwm_gray_tag=rc");;
-
-    if(NULL == pCaPath)
-    {
-        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
-        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, false);
-    }
-
-    else
-    {
-        //缺省情况就是PEM,所以无需设置,另外支持DER
-        //curl_easy_setopt(curl,CURLOPT_SSLCERTTYPE,"PEM");
-        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, true);
-        curl_easy_setopt(curl, CURLOPT_CAINFO, pCaPath);
-    }
-
-    curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 8);//连接超时,这个数值如果设置太短可能导致数据请求不到就断开了
-    curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10);//接收数据时超时设置,如果10秒内数据未接收完,直接退出
-    res = curl_easy_perform(curl);
-    curl_easy_cleanup(curl);
-    return res;
+	CURLcode res;
+	CURL* curl = curl_easy_init();
+
+	if (NULL == curl)
+	{
+		return CURLE_FAILED_INIT;
+	}
+
+	if (m_bDebug)
+	{
+		curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
+		curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, OnDebug);
+	}
+
+	curl_easy_setopt(curl, CURLOPT_URL, strUrl.c_str());
+	curl_easy_setopt(curl, CURLOPT_POST, 1);
+	curl_easy_setopt(curl, CURLOPT_POSTFIELDS, strPost.c_str());
+	curl_easy_setopt(curl, CURLOPT_READFUNCTION, NULL);
+	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, OnWriteData);
+	curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&strResponse);
+	curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
+	//curl_easy_setopt(curl, CURLOPT_COOKIE, "lwm_gray_tag=rc");;
+
+	if (proxy.m_is_proxy)
+	{
+		std::string addr = proxy.ip + ":" + proxy.port;
+		curl_easy_setopt(curl, CURLOPT_PROXY, addr.c_str());
+		curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
+		curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
+
+		if (!proxy.username.empty() && !proxy.password.empty())
+		{
+			curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, (proxy.username + ":" + proxy.password).c_str());
+		}
+	}
+
+	if (NULL == pCaPath)
+	{
+		curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
+		curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, false);
+	}
+
+	else
+	{
+		//缺省情况就是PEM,所以无需设置,另外支持DER
+		//curl_easy_setopt(curl,CURLOPT_SSLCERTTYPE,"PEM");
+		curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, true);
+		curl_easy_setopt(curl, CURLOPT_CAINFO, pCaPath);
+	}
+
+	curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 8);//连接超时,这个数值如果设置太短可能导致数据请求不到就断开了
+	curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10);//接收数据时超时设置,如果10秒内数据未接收完,直接退出
+	res = curl_easy_perform(curl);
+	curl_easy_cleanup(curl);
+	return res;
 }
 
-int CHttpClient::Gets(const std::string & strUrl, std::string & strResponse, const char * pCaPath)
+int CHttpClient::Gets(const std::string & strUrl, std::string & strResponse, const char * pCaPath, CZhipuziHttpProxy proxy)
 {
-    CURLcode res;
-    CURL* curl = curl_easy_init();
-
-    if(NULL == curl)
-    {
-        return CURLE_FAILED_INIT;
-    }
-
-    if(m_bDebug)
-    {
-        curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
-        curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, OnDebug);
-    }
-
-    curl_easy_setopt(curl, CURLOPT_URL, strUrl.c_str());
-    curl_easy_setopt(curl, CURLOPT_READFUNCTION, NULL);
-    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, OnWriteData);
-    curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&strResponse);
-    curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
-
-    if(NULL == pCaPath)
-    {
-        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
-        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, false);
-    }
-
-    else
-    {
-        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, true);
-        curl_easy_setopt(curl, CURLOPT_CAINFO, pCaPath);
-    }
-
-    curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 8);//连接超时,这个数值如果设置太短可能导致数据请求不到就断开了
-    curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10);//接收数据时超时设置,如果10秒内数据未接收完,直接退出
-    res = curl_easy_perform(curl);
-    curl_easy_cleanup(curl);
-    return res;
+	CURLcode res;
+	CURL* curl = curl_easy_init();
+
+	if (NULL == curl)
+	{
+		return CURLE_FAILED_INIT;
+	}
+
+	if (m_bDebug)
+	{
+		curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
+		curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, OnDebug);
+	}
+
+	curl_easy_setopt(curl, CURLOPT_URL, strUrl.c_str());
+	curl_easy_setopt(curl, CURLOPT_READFUNCTION, NULL);
+	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, OnWriteData);
+	curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&strResponse);
+	curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
+
+	if (proxy.m_is_proxy)
+	{
+		std::string addr = proxy.ip + ":" + proxy.port;
+		curl_easy_setopt(curl, CURLOPT_PROXY, addr.c_str());
+		curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
+		curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
+
+		if (!proxy.username.empty() && !proxy.password.empty())
+		{
+			curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, (proxy.username + ":" + proxy.password).c_str());
+		}
+	}
+
+	if (NULL == pCaPath)
+	{
+		curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
+		curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, false);
+	}
+
+	else
+	{
+		curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, true);
+		curl_easy_setopt(curl, CURLOPT_CAINFO, pCaPath);
+	}
+
+	curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 8);//连接超时,这个数值如果设置太短可能导致数据请求不到就断开了
+	curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10);//接收数据时超时设置,如果10秒内数据未接收完,直接退出
+	res = curl_easy_perform(curl);
+	curl_easy_cleanup(curl);
+	return res;
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////
 
 void CHttpClient::SetDebug(bool bDebug)
 {
-    m_bDebug = bDebug;
+	m_bDebug = bDebug;
 }

+ 40 - 40
zhipuzi_pos_windows/network/CHttpClient.h

@@ -1,54 +1,54 @@
 #pragma once
 
-using namespace std;
+#include "CZhipuziHttpProxy.h"
 
 class CHttpClient
 {
 public:
-    CHttpClient();
-    ~CHttpClient();
+	CHttpClient();
+	~CHttpClient();
 
 public:
-    /**
-    * @brief HTTP POST请求
-    * @param strUrl 输入参数,请求的Url地址,如:http://www.baidu.com
-    * @param strPost 输入参数,使用如下格式para1=val1&para2=val2&…
-    * @param strResponse 输出参数,返回的内容
-    * @return 返回是否Post成功
-    */
-    int Post(const std::string & strUrl, const std::string & strPost, std::string & strResponse);
-
-    /**
-    * @brief HTTP GET请求
-    * @param strUrl 输入参数,请求的Url地址,如:http://www.baidu.com
-    * @param strResponse 输出参数,返回的内容
-    * @return 返回是否Post成功
-    */
-    int Get(const std::string & strUrl, std::string & strResponse);
-
-    /**
-    * @brief HTTPS POST请求,无证书版本
-    * @param strUrl 输入参数,请求的Url地址,如:https://www.alipay.com
-    * @param strPost 输入参数,使用如下格式ppara1=val1&para2=val2&…
-    * @param strResponse 输出参数,返回的内容
-    * @param pCaPath 输入参数,为CA证书的路径.如果输入为NULL,则不验证服务器端证书的有效性.
-    * @return 返回是否Post成功
-    */
-    int Posts(const std::string & strUrl, const std::string & strPost, std::string & strResponse, const char * pCaPath = NULL);
-
-    /**
-    * @brief HTTPS GET请求,无证书版本
-    * @param strUrl 输入参数,请求的Url地址,如:https://www.alipay.com
-    * @param strResponse 输出参数,返回的内容
-    * @param pCaPath 输入参数,为CA证书的路径.如果输入为NULL,则不验证服务器端证书的有效性.
-    * @return 返回是否Post成功
-    */
-    int Gets(const std::string & strUrl, std::string & strResponse, const char * pCaPath = NULL);
+	/**
+	* @brief HTTP POST请求
+	* @param strUrl 输入参数,请求的Url地址,如:http://www.baidu.com
+	* @param strPost 输入参数,使用如下格式para1=val1&para2=val2&…
+	* @param strResponse 输出参数,返回的内容
+	* @return 返回是否Post成功
+	*/
+	int Post(const std::string & strUrl, const std::string & strPost, std::string & strResponse, CZhipuziHttpProxy proxy = CZhipuziHttpProxy());
+
+	/**
+	* @brief HTTP GET请求
+	* @param strUrl 输入参数,请求的Url地址,如:http://www.baidu.com
+	* @param strResponse 输出参数,返回的内容
+	* @return 返回是否Post成功
+	*/
+	int Get(const std::string & strUrl, std::string & strResponse, CZhipuziHttpProxy proxy = CZhipuziHttpProxy());
+
+	/**
+	* @brief HTTPS POST请求,无证书版本
+	* @param strUrl 输入参数,请求的Url地址,如:https://www.alipay.com
+	* @param strPost 输入参数,使用如下格式ppara1=val1&para2=val2&…
+	* @param strResponse 输出参数,返回的内容
+	* @param pCaPath 输入参数,为CA证书的路径.如果输入为NULL,则不验证服务器端证书的有效性.
+	* @return 返回是否Post成功
+	*/
+	int Posts(const std::string & strUrl, const std::string & strPost, std::string & strResponse, const char * pCaPath = NULL, CZhipuziHttpProxy proxy = CZhipuziHttpProxy());
+
+	/**
+	* @brief HTTPS GET请求,无证书版本
+	* @param strUrl 输入参数,请求的Url地址,如:https://www.alipay.com
+	* @param strResponse 输出参数,返回的内容
+	* @param pCaPath 输入参数,为CA证书的路径.如果输入为NULL,则不验证服务器端证书的有效性.
+	* @return 返回是否Post成功
+	*/
+	int Gets(const std::string & strUrl, std::string & strResponse, const char * pCaPath = NULL, CZhipuziHttpProxy proxy = CZhipuziHttpProxy());
 
 public:
-    void SetDebug(bool bDebug);
+	void SetDebug(bool bDebug);
 
 private:
-    bool m_bDebug;
+	bool m_bDebug;
 };
 

+ 223 - 63
zhipuzi_pos_windows/network/CZhipuziHttpClient.cpp

@@ -35,8 +35,10 @@ CZhipuziHttpClient::CZhipuziHttpClient()
 	//初始化curl
 	curl_global_init(CURL_GLOBAL_ALL);
 
-	m_username = CSetting::getUsername();
-	m_password = CSetting::getPassword();
+	m_client.m_http_proxy.ip = CSetting::GetParam("http_proxy_ip");
+	m_client.m_http_proxy.port = CSetting::GetParam("http_proxy_port");
+	m_client.m_http_proxy.username = CSetting::GetParam("http_proxy_username");
+	m_client.m_http_proxy.password = CSetting::GetParam("http_proxy_password");
 }
 
 
@@ -44,6 +46,27 @@ CZhipuziHttpClient::~CZhipuziHttpClient()
 {
 }
 
+/*
+ *修改了htttp代理设置之后,这里修改状态
+ **/
+void CZhipuziHttpClient::UpdateProxy()
+{
+	std::string http_is_proxy = CSetting::GetParam("http_is_proxy");
+	if (http_is_proxy == "1")
+	{
+		m_client.m_http_proxy.m_is_proxy = true;
+	}
+	else
+	{
+		m_client.m_http_proxy.m_is_proxy = false;
+	}
+
+	m_client.m_http_proxy.ip = CSetting::GetParam("http_proxy_ip");
+	m_client.m_http_proxy.port = CSetting::GetParam("http_proxy_port");
+	m_client.m_http_proxy.username = CSetting::GetParam("http_proxy_username");
+	m_client.m_http_proxy.password = CSetting::GetParam("http_proxy_password");
+}
+
 void CZhipuziHttpClient::Init(std::string username, std::string password)
 {
 	m_client.m_username = username;
@@ -55,7 +78,7 @@ bool CZhipuziHttpClient::Login(std::string& errmsg)
 	std::map<string, string> params;
 
     std::string response;
-    bool ret = m_client.RequestPingtai("/userlogin/userlogin", params, response);
+    bool ret = m_client.RequestPingtaiNew("/login/login", params, response);
 
 	if (!ret)
 	{
@@ -65,7 +88,7 @@ bool CZhipuziHttpClient::Login(std::string& errmsg)
 		return false;
 	}
 
-	//LOG_INFO("response:" << response.c_str());
+	LOG_INFO("response:" << response.c_str());
 
     rapidjson::Document document;
     document.Parse(response.c_str());
@@ -106,11 +129,11 @@ bool CZhipuziHttpClient::Login(std::string& errmsg)
 
 	if (m_client.m_version_type == "1")
 	{
-		m_client.m_yewu_url = "https://cyapi.zhipuzi.com/pos";
+		m_client.m_yewu_url = m_client.m_canyin_yewu_url;
 	}
 	else
 	{
-		m_client.m_yewu_url = "https://lsapi.zhipuzi.com/pos";
+		m_client.m_yewu_url = m_client.m_lingshou_yewu_url;
 	}
 
 	rapidjson::Value& v_lwm_sess_token = v_data["lwm_sess_token"];
@@ -123,73 +146,144 @@ 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 = "123456";
-
-    //先添加默认参数,用于计算签名
-    params["username"] = m_client.m_username;
-    params["nonce"] = nonce;
-    params["timestamp"] = timestamp;
-    params["url"] = m_client.m_yewu_url + url;
-
-    //计算签名
-    std::string postString;
-    for(std::map<string, string>::iterator it = params.begin(); it != params.end();)
-    {
-        postString += it->first + "=" + it->second;
+	std::string timestamp = to_string(time(NULL));
+	std::string nonce = "123456";
 
-        it++;
+	//先添加默认参数,用于计算签名
+	params["username"] = m_client.m_username;
+	params["nonce"] = nonce;
+	params["timestamp"] = timestamp;
+	params["url"] = m_client.m_yewu_url + url;
 
-        if(it != params.end())
-        {
-            postString += "&";
-        }
-    }
+	//计算签名
+	std::string postString;
+	for (std::map<string, string>::iterator it = params.begin(); it != params.end();)
+	{
+		postString += it->first + "=" + it->second;
 
-    LOG_INFO("postString:" << postString.c_str());
+		it++;
 
-    //用于计算签名的临时变量
-    std::string password = md5(m_client.m_password);
-    transform(password.begin(), password.end(), password.begin(), ::toupper);
+		if (it != params.end())
+		{
+			postString += "&";
+		}
+	}
 
-    string tmp = postString + password;
+	LOG_INFO("postString:" << postString.c_str());
 
-    std::string sign = md5(tmp);
-    transform(sign.begin(), sign.end(), sign.begin(), ::toupper);
-    LOG_INFO("sign:" << sign.c_str());
+	//用于计算签名的临时变量
+	std::string password = md5(m_client.m_password);
+	transform(password.begin(), password.end(), password.begin(), ::toupper);
 
-    //加上签名,去掉url,计算post
-    params["sign"] = sign;
-    params.erase("url");
+	string tmp = postString + password;
 
-    //未签名之前,不能进行urlencode,签名完成之后可以(params的value必须为utf8格式)
-    postString = "";
-    for(std::map<string, string>::iterator it = params.begin(); it != params.end();)
-    {
-        postString += it->first + "=" + CLewaimaiString::UrlEncode(it->second);
+	std::string sign = md5(tmp);
+	transform(sign.begin(), sign.end(), sign.begin(), ::toupper);
+	LOG_INFO("sign:" << sign.c_str());
 
-        it++;
+	//加上签名,去掉url,计算post
+	params["sign"] = sign;
+	params.erase("url");
 
-        if(it != params.end())
-        {
-            postString += "&";
-        }
-    }
+	//未签名之前,不能进行urlencode,签名完成之后可以(params的value必须为utf8格式)
+	postString = "";
+	for (std::map<string, string>::iterator it = params.begin(); it != params.end();)
+	{
+		postString += it->first + "=" + CLewaimaiString::UrlEncode(it->second);
 
-    LOG_INFO("postString:" << postString.c_str());
+		it++;
 
-    CHttpClient m_httpClient;
-    int ret = m_httpClient.Posts(m_client.m_yewu_url + url, postString, response, NULL);
+		if (it != params.end())
+		{
+			postString += "&";
+		}
+	}
 
-    LOG_INFO("response:" << response.c_str());
+	LOG_INFO("postString:" << postString.c_str());
 
-    if(ret == 0)
-    {
-        //ret为0表示没有出错
-        return true;
-    }
+	CHttpClient m_httpClient;
+	int ret = m_httpClient.Posts(m_client.m_yewu_url + url, postString, response, NULL, m_client.m_http_proxy);
 
-    return false;
+	LOG_INFO("response:" << response.c_str());
+
+	if (ret == 0)
+	{
+		//ret为0表示没有出错
+		return true;
+	}
+
+	return false;
+}
+
+bool CZhipuziHttpClient::RequestNew(std::string url, std::map<string, string> params, std::string& response)
+{
+	std::string timestamp = to_string(time(NULL));
+	std::string nonce = "123456";
+
+	std::string lwm_appid = "kJnkkHODnoloay197k97G129J";
+	std::string open_secret = "kMDNjjid91ydo#!9DH1";
+
+	//先添加默认参数,用于计算签名
+	params["username"] = CLewaimaiString::UrlEncode(m_client.m_username);
+	params["password"] = md5(m_client.m_password);
+	params["lwm_appid"] = lwm_appid;
+	params["nonce"] = nonce;
+	params["timestamp"] = timestamp;
+
+	//计算签名
+	std::string postString;
+	for (std::map<string, string>::iterator it = params.begin(); it != params.end(); )
+	{
+		postString += it->first + "=" + it->second;
+
+		it++;
+
+		if (it != params.end())
+		{
+			postString += "&";
+		}
+	}
+
+	LOG_INFO("postString:" << postString.c_str());
+
+	//用于计算签名的临时变量
+	string tmp = md5(postString);
+	tmp += open_secret;
+
+	std::string sign = md5(tmp);
+	transform(sign.begin(), sign.end(), sign.begin(), ::toupper);
+	LOG_INFO("sign:" << sign.c_str());
+
+	//加上签名,去掉url,计算post
+	params["sign"] = sign;
+
+	postString = "";
+	for (std::map<string, string>::iterator it = params.begin(); it != params.end(); )
+	{
+		postString += it->first + "=" + it->second;
+
+		it++;
+
+		if (it != params.end())
+		{
+			postString += "&";
+		}
+	}
+
+	LOG_INFO("postString:" << postString.c_str());
+
+	CHttpClient m_httpClient;
+	int ret = m_httpClient.Posts(m_client.m_yewu_url + url, postString, response, NULL, m_client.m_http_proxy);
+
+	LOG_INFO("response:" << response.c_str());
+
+	if (ret == 0)
+	{
+		//ret为0表示没有出错
+		return true;
+	}
+
+	return false;
 }
 
 bool CZhipuziHttpClient::RequestPingtai(std::string url, std::map<string, string> params, std::string& response)
@@ -205,7 +299,7 @@ bool CZhipuziHttpClient::RequestPingtai(std::string url, std::map<string, string
 
 	//计算签名
 	std::string postString;
-	for (std::map<string, string>::iterator it = params.begin(); it != params.end(); )
+	for (std::map<string, string>::iterator it = params.begin(); it != params.end();)
 	{
 		postString += it->first + "=" + it->second;
 
@@ -250,7 +344,7 @@ bool CZhipuziHttpClient::RequestPingtai(std::string url, std::map<string, string
 	LOG_INFO("postString:" << postString.c_str());
 
 	CHttpClient m_httpClient;
-	int ret = m_httpClient.Posts(m_client.m_pingtai_url + url, postString, response, NULL);
+	int ret = m_httpClient.Posts(m_client.m_pingtai_url + url, postString, response, NULL, m_client.m_http_proxy);
 
 	LOG_INFO("response:" << response.c_str());
 
@@ -259,10 +353,76 @@ bool CZhipuziHttpClient::RequestPingtai(std::string url, std::map<string, string
 		//ret为0表示没有出错
 		return true;
 	}
-	else
+
+	return false;
+}
+
+bool CZhipuziHttpClient::RequestPingtaiNew(std::string url, std::map<string, string> params, std::string& response)
+{
+	std::string timestamp = to_string(time(NULL));
+	std::string nonce = "123456";
+
+	std::string lwm_appid = "84b19199fd221a78c491cd553cbb4ab7";
+	std::string open_secret = "#repast!@#AfAS#@!";
+
+	//先添加默认参数,用于计算签名
+	params["username"] = CLewaimaiString::UrlEncode(m_client.m_username);
+	params["password"] = md5(m_client.m_password);
+	params["lwm_appid"] = lwm_appid;
+	params["nonce"] = nonce;
+	params["timestamp"] = timestamp;
+
+	//计算签名
+	std::string postString;
+	for (std::map<string, string>::iterator it = params.begin(); it != params.end(); )
+	{
+		postString += it->first + "=" + it->second;
+
+		it++;
+
+		if (it != params.end())
+		{
+			postString += "&";
+		}
+	}
+
+	LOG_INFO("postString:" << postString.c_str());
+
+	//用于计算签名的临时变量
+	string tmp = md5(postString);
+	tmp += open_secret;
+
+	std::string sign = md5(tmp);
+	transform(sign.begin(), sign.end(), sign.begin(), ::toupper);
+	LOG_INFO("sign:" << sign.c_str());
+
+	//加上签名,去掉url,计算post
+	params["sign"] = sign;
+
+	postString = "";
+	for (std::map<string, string>::iterator it = params.begin(); it != params.end(); )
+	{
+		postString += it->first + "=" + it->second;
+
+		it++;
+
+		if (it != params.end())
+		{
+			postString += "&";
+		}
+	}
+
+	LOG_INFO("postString:" << postString.c_str());
+
+	CHttpClient m_httpClient;
+	int ret = m_httpClient.Posts(m_client.m_pingtai_url + url, postString, response, NULL, m_client.m_http_proxy);
+
+	LOG_INFO("response:" << response.c_str());
+
+	if (ret == 0)
 	{
-		//返回值说明 https://blog.csdn.net/u011857683/article/details/53069268
-		LOG_INFO("request error, ret value:" << ret);
+		//ret为0表示没有出错
+		return true;
 	}
 
 	return false;

+ 8 - 0
zhipuzi_pos_windows/network/CZhipuziHttpClient.h

@@ -1,6 +1,7 @@
 #pragma once
 
 #include "CHttpClient.h"
+#include "CZhipuziHttpProxy.h"
 
 class CZhipuziHttpClient
 {
@@ -18,11 +19,15 @@ public:
 public:
 	static void Init(std::string username, std::string password);
 
+	static void UpdateProxy();
+
 	static bool Login(std::string& errmsg);
 
 	static bool Request(std::string url, std::map<string, string> params, std::string& response);
+	static bool RequestNew(std::string url, std::map<string, string> params, std::string& response);
 
 	static bool RequestPingtai(std::string url, std::map<string, string> params, std::string& response);
+	static bool RequestPingtaiNew(std::string url, std::map<string, string> params, std::string& response);
 
 	static std::string getShopId();
 
@@ -46,5 +51,8 @@ private:
 
 	//这个是当前登陆的账号对应的店铺ID
 	std::string m_shop_id;
+
+	//htttp代理相关的参数
+	CZhipuziHttpProxy m_http_proxy;
 };
 

+ 19 - 0
zhipuzi_pos_windows/network/CZhipuziHttpProxy.h

@@ -0,0 +1,19 @@
+#pragma once
+
+#include "../pch/pch.h"
+
+class CZhipuziHttpProxy
+{
+public:
+	CZhipuziHttpProxy()
+	{
+		m_is_proxy = false;
+	}
+
+	bool m_is_proxy;
+
+	std::string ip;
+	std::string port;
+	std::string username;
+	std::string password;
+};

+ 1 - 1
zhipuzi_pos_windows/tool/CExceptionDmp.cpp

@@ -55,7 +55,7 @@ LONG WINAPI MyUnhandledExceptionFilter(PEXCEPTION_POINTERS pExInfo)
 		};
 		TCHAR msg[400];
 		_stprintf_s(msg, fmt, file_name);
-		MessageBox(NULL, msg, L"乐外卖接单软件异常报告", MB_ICONERROR | MB_SYSTEMMODAL);
+		MessageBox(NULL, msg, L"智铺子接单软件异常报告", MB_ICONERROR | MB_SYSTEMMODAL);
 	}
 	else
 	{

+ 34 - 0
zhipuzi_pos_windows/tool/CSetting.cpp

@@ -123,6 +123,40 @@ void CSetting::Init()
 	//再对数据进行初始化,如果没有记录的就加上默认设置
 	m_mutex.lock();
 
+	//http代理相关
+	std::string http_is_proxy = "http_is_proxy";
+	if (m_paramsMap.find(http_is_proxy) == m_paramsMap.end())
+	{
+		m_paramsMap[http_is_proxy] = "0";
+	}
+
+	std::string http_proxy_ip = "http_proxy_ip";
+	if (m_paramsMap.find(http_proxy_ip) == m_paramsMap.end())
+	{
+		m_paramsMap[http_proxy_ip] = "";
+	}
+
+	std::string http_proxy_port = "http_proxy_port";
+	if (m_paramsMap.find(http_proxy_port) == m_paramsMap.end())
+	{
+		//默认不开启收款免确认
+		m_paramsMap[http_proxy_port] = "";
+	}
+
+	std::string http_proxy_username = "http_proxy_username";
+	if (m_paramsMap.find(http_proxy_username) == m_paramsMap.end())
+	{
+		//默认不开启收款免确认
+		m_paramsMap[http_proxy_username] = "";
+	}
+
+	std::string http_proxy_password = "http_proxy_password";
+	if (m_paramsMap.find(http_proxy_password) == m_paramsMap.end())
+	{
+		//默认不开启收款免确认
+		m_paramsMap[http_proxy_password] = "";
+	}
+
 	//外卖设置参数
 	std::string setting_is_new_waimai_voice = "setting_is_new_waimai_voice";
 	if (m_paramsMap.find(setting_is_new_waimai_voice) == m_paramsMap.end())

+ 2 - 2
zhipuzi_pos_windows/wnd/CLoginWnd.cpp

@@ -380,7 +380,7 @@ void CLoginWnd::HandleLogin()
 	std::map<string, string> params;
 
 	std::string response;
-	bool ret = CZhipuziHttpClient::Request("/version/getwindowsversion", params, response);
+	bool ret = CZhipuziHttpClient::RequestPingtaiNew("/version/getwindowsposversion", params, response);
 	if (!ret)
 	{
 		pLoginResultLabel->SetText(std::wstring(_T("ÍøÂçÇëÇó³ö´í")).c_str());
@@ -430,7 +430,7 @@ void CLoginWnd::HandleLogin()
 
 		rapidjson::Value& data = document["data"];
 
-		std::string newest_version = data["newest_version"].GetString();
+		std::string newest_version = data["cur_version"].GetString();
 		m_update_url = data["url"].GetString();
 
 		if (newest_version > CSystem::GetVersion())

+ 3 - 3
zhipuzi_pos_windows/wnd/CMainWnd.cpp

@@ -1419,7 +1419,7 @@ void CMainWnd::AddTrayIcon()
     m_trayIcon.cbSize = sizeof(NOTIFYICONDATA);
     m_trayIcon.hIcon = ::LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON_DUILIB));
     m_trayIcon.hWnd = m_hWnd;
-    lstrcpy(m_trayIcon.szTip, _T("乐外卖接单软件"));
+    lstrcpy(m_trayIcon.szTip, _T("智铺子接单软件"));
     m_trayIcon.uCallbackMessage = WM_SHOWTASK;
     m_trayIcon.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
     Shell_NotifyIcon(NIM_ADD, &m_trayIcon);
@@ -1487,7 +1487,7 @@ void CMainWnd::InitSettingStatus()
 {
     //显示当前软件版本和登录账号信息
     CLabelUI* name_version = static_cast<CLabelUI*>(m_pm.FindControl(_T("main_name_version")));
-    std::wstring wsShowName = L"乐外卖接单软件 " + CLewaimaiString::UTF8ToUnicode(CSystem::GetVersion());
+    std::wstring wsShowName = L"智铺子接单软件 " + CLewaimaiString::UTF8ToUnicode(CSystem::GetVersion());
 
     std::string last_login_username = CSetting::GetParam("last_login_username");
     std::wstring wx_last_login_username = CLewaimaiString::UTF8ToUnicode(last_login_username);
@@ -2098,7 +2098,7 @@ void CMainWnd::LoginOut(int mode)
 
     //设置模式
     pLogin->SetMode(mode);
-    pLogin->Create(NULL, _T("乐外卖接单软件登录"), UI_WNDSTYLE_DIALOG, 0, 0, 0, 0, 0, NULL);
+    pLogin->Create(NULL, _T("智铺子接单软件登录"), UI_WNDSTYLE_DIALOG, 0, 0, 0, 0, 0, NULL);
     pLogin->SetIcon(IDI_ICON_DUILIB);
     pLogin->CenterWindow();