瀏覽代碼

HTTP代理开发完成

zhangyang 5 年之前
父節點
當前提交
1d127a8c0e

+ 41 - 0
bin/Win32/Debug/zhipuzi_pay_plugin/skin/http_proxy_setting_wnd.xml

@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Window size="600,450" caption="0,0,0,36" roundcorner="4,4" >
+	<VerticalLayout bkimage="file='Dialog_BG1.png' corner='4,50,4,4'">
+		<HorizontalLayout height="40" inset="10,2,10,0">
+			<Label name="http_proxy_setting_wnd_title" text="网络代理设置" width="150" />
+			<Control />
+			<Button name="http_proxy_setting_wnd_closebtn" padding="0,4,0,0" width="22" height="22" tooltip="关闭" normalimage="file='Login_TopBar_Close_Btn.png'" hotimage="file='Login_TopBar_Close_Btn_Hover.png'" pushedimage="file='Login_TopBar_Close_Btn_Click.png'"/>
+		</HorizontalLayout>
+		
+		<HorizontalLayout padding="0,50,0,0" height="36">
+			<CheckBox name="http_proxy_setting_wnd_isdaili" padding="30,10,10,0" width="16" height="16" normalimage="file='Setting_CheckBox_Normal.png'" hotimage="file='Setting_CheckBox_Hover.png'" selectedimage="file='Setting_CheckBox_Click.png'"/>
+			<Label text="开启HTTP代理模式(适用于局域网)" width="400"></Label>
+			<Control></Control>
+		</HorizontalLayout>
+		
+		<VerticalLayout height="176">
+			<HorizontalLayout height="44">
+				<Label text="HTTP代理IP地址:" width="120" padding="30,0,0,0"/>
+				<Edit name="http_proxy_setting_wnd_ip" width="220" height="34" padding="20,5,0,5" normalimage="file='Chat_InputBox_BG.png' corner='4,4,4,4'" hotimage="file='Chat_InputBox_BG_Hover.png' corner='4,4,4,4'" />
+			</HorizontalLayout>
+			<HorizontalLayout height="44">
+				<Label text="HTTP代理端口号:" width="120" padding="30,0,0,0"/>
+				<Edit name="http_proxy_setting_wnd_port" width="220" height="34" padding="20,5,0,5" normalimage="file='Chat_InputBox_BG.png' corner='4,4,4,4'" hotimage="file='Chat_InputBox_BG_Hover.png' corner='4,4,4,4'" />
+			</HorizontalLayout>
+			<HorizontalLayout height="44">
+				<Label text="HTTP代理用户名:" width="120" padding="30,0,0,0"/>
+				<Edit name="http_proxy_setting_wnd_username" width="220" height="34" padding="20,5,0,5" normalimage="file='Chat_InputBox_BG.png' corner='4,4,4,4'" hotimage="file='Chat_InputBox_BG_Hover.png' corner='4,4,4,4'" />
+			</HorizontalLayout>
+			<HorizontalLayout height="44">
+				<Label text="HTTP代理密码:" width="120" padding="30,0,0,0"/>
+				<Edit name="http_proxy_setting_wnd_password" width="220" height="34" padding="20,5,0,5" normalimage="file='Chat_InputBox_BG.png' corner='4,4,4,4'" hotimage="file='Chat_InputBox_BG_Hover.png' corner='4,4,4,4'" />
+			</HorizontalLayout>
+		</VerticalLayout>
+		
+		<HorizontalLayout height="56" valign="center" padding="0,30,0,20">
+			<Control />
+			<Button name="http_proxy_setting_wnd_save" align="center" width="280" height="44" text="保存" normalimage="file='Btn_White.png' corner='5,5,5,5'" hotimage="file='Btn_White_Hover.png' corner='5,5,5,5'" pushedimage="file='Btn_White_Click.png' corner='5,5,5,5'" />
+			<Control />
+		</HorizontalLayout>
+	</VerticalLayout>
+</Window>

+ 15 - 6
bin/Win32/Debug/zhipuzi_pay_plugin/skin/login.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<Window size="520,410" caption="0,0,0,36" roundcorner="4,4" >
+<Window size="600,450" caption="0,0,0,36" roundcorner="4,4" >
 	<Font shared="true" id="0" name="微软雅黑" size="20" />
 	<VerticalLayout bkimage="file='Dialog_BG2.png' corner='4,48,4,4'" >
 		<HorizontalLayout height="44">
@@ -16,16 +16,20 @@
 		
 		<VerticalLayout name="login_input" height="200">
 			<HorizontalLayout height="50">
-				<Label text="账号:" float="true" pos="123,12,228,40"/>
-				<Combo name="accountcombo" float="true" pos="183, 12, 398, 38" tooltip="请点击这里选择您的登录账号" normalimage="file='Setting_Combox_Normal.png' corner='2,2,24,2'" hotimage="file='Setting_Combox_Hover.png' corner='2,2,24,2'" pushedimage="Setting_Combox_Click.png' corner='2,2,24,2'" textpadding="10,1,1,1" >
-				</Combo>
-				<Edit name="accountedit" float="true" pos="183,12,368,38" normalimage="file='Chat_InputBox_BG.png' corner='4,4,4,4'" hotimage="file='Chat_InputBox_BG_Hover.png' corner='4,4,4,4'" />
+				<Control></Control>
+				<Label text="账号:" width="60"/>
+				<HorizontalLayout width="215" height="32" padding="0,9,0,9">
+					<Combo name="accountcombo" float="true" pos="0, 0, 215, 32" tooltip="请点击这里选择您的登录账号" normalimage="file='Setting_Combox_Normal.png' corner='2,2,24,2'" hotimage="file='Setting_Combox_Hover.png' corner='2,2,24,2'" pushedimage="Setting_Combox_Click.png' corner='2,2,24,2'" textpadding="10,1,1,1" >
+					</Combo>
+					<Edit name="accountedit" float="true" pos="0,0,185,32" normalimage="file='Chat_InputBox_BG.png' corner='4,4,4,4'" hotimage="file='Chat_InputBox_BG_Hover.png' corner='4,4,4,4'" />
+				</HorizontalLayout>
+				<Control></Control>
 			</HorizontalLayout>
 			
 			<HorizontalLayout height="50">
 				<Control></Control>
 				<Label text="密码:" width="60" />
-				<Edit name="pwdedit" width="215" height="32" password="true" padding="0,12,0,12" normalimage="file='Chat_InputBox_BG.png' corner='4,4,4,4'" hotimage="file='Chat_InputBox_BG_Hover.png' corner='4,4,4,4'" />
+				<Edit name="pwdedit" width="215" height="32" password="true" padding="0,9,0,9" normalimage="file='Chat_InputBox_BG.png' corner='4,4,4,4'" hotimage="file='Chat_InputBox_BG_Hover.png' corner='4,4,4,4'" />
 				<Control></Control>
 			</HorizontalLayout>
 			
@@ -55,6 +59,11 @@
 			<Control></Control>
 		</HorizontalLayout>
 		
+		<HorizontalLayout padding="0,0,0,15" height="24">
+			<Control></Control>
+			<Button text="{u}网络代理{/u}" name="proxy_setting" width="120" showhtml="true"></Button>
+		</HorizontalLayout>
+		
 		<HorizontalLayout padding="0,0,0,15">
 			<Control></Control>
 			<Button name="guanwang" text="{u}www.zhipuzi.com{/u}" showhtml="true" width="200" align="center"/>

+ 11 - 3
bin/Win32/Debug/zhipuzi_pay_plugin/skin/shoukuan_setting.xml

@@ -34,14 +34,22 @@
 			<Control></Control>
 		</HorizontalLayout>
 		
-		<VerticalLayout height="88" name="shoukuan_setting_wangkou_layout" padding="0,0,0,0">			
+		<VerticalLayout height="176" name="shoukuan_setting_wangkou_layout" padding="0,0,0,0">			
 			<HorizontalLayout height="44">
 				<Label text="HTTP代理IP地址:" width="120" padding="30,0,0,0"/>
-				<Edit name="shoukuan_setting_daili_ip" width="220" height="34" padding="0,5,0,5" normalimage="file='Chat_InputBox_BG.png' corner='4,4,4,4'" hotimage="file='Chat_InputBox_BG_Hover.png' corner='4,4,4,4'" />
+				<Edit name="shoukuan_setting_daili_ip" width="220" height="34" padding="20,5,0,5" normalimage="file='Chat_InputBox_BG.png' corner='4,4,4,4'" hotimage="file='Chat_InputBox_BG_Hover.png' corner='4,4,4,4'" />
 			</HorizontalLayout>
 			<HorizontalLayout height="44">
 				<Label text="HTTP代理端口号:" width="120" padding="30,0,0,0"/>
-				<Edit name="shoukuan_setting_daili_port" width="220" height="34" padding="0,5,0,5" normalimage="file='Chat_InputBox_BG.png' corner='4,4,4,4'" hotimage="file='Chat_InputBox_BG_Hover.png' corner='4,4,4,4'" />
+				<Edit name="shoukuan_setting_daili_port" width="220" height="34" padding="20,5,0,5" normalimage="file='Chat_InputBox_BG.png' corner='4,4,4,4'" hotimage="file='Chat_InputBox_BG_Hover.png' corner='4,4,4,4'" />
+			</HorizontalLayout>
+			<HorizontalLayout height="44">
+				<Label text="HTTP代理用户名:" width="120" padding="30,0,0,0"/>
+				<Edit name="shoukuan_setting_daili_username" width="220" height="34" padding="20,5,0,5" normalimage="file='Chat_InputBox_BG.png' corner='4,4,4,4'" hotimage="file='Chat_InputBox_BG_Hover.png' corner='4,4,4,4'" />
+			</HorizontalLayout>
+			<HorizontalLayout height="44">
+				<Label text="HTTP代理密码:" width="120" padding="30,0,0,0"/>
+				<Edit name="shoukuan_setting_daili_password" width="220" height="34" padding="20,5,0,5" normalimage="file='Chat_InputBox_BG.png' corner='4,4,4,4'" hotimage="file='Chat_InputBox_BG_Hover.png' corner='4,4,4,4'" />
 			</HorizontalLayout>
 		</VerticalLayout>
 		

+ 50 - 6
zhipuzi_pay_plugin/network/CHttpClient.cpp

@@ -57,7 +57,7 @@ static size_t OnWriteData(void* buffer, size_t size, size_t nmemb, void* lpVoid)
 	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();
@@ -79,6 +79,19 @@ int CHttpClient::Post(const std::string & strUrl, const std::string & strPost, s
 	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秒内数据未接收完,直接退出
@@ -87,7 +100,7 @@ int CHttpClient::Post(const std::string & strUrl, const std::string & strPost, s
 	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();
@@ -107,6 +120,19 @@ int CHttpClient::Get(const std::string & strUrl, std::string & strResponse)
 	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从而导致程序退出。
@@ -122,7 +148,7 @@ int CHttpClient::Get(const std::string & strUrl, std::string & strResponse)
 /*
  *返回值说明 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, bool is_http_proxy, std::string http_proxy_ip, std::string http_proxy_port)
+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();
@@ -147,12 +173,17 @@ int CHttpClient::Posts(const std::string & strUrl, const std::string & strPost,
 	curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
 	//curl_easy_setopt(curl, CURLOPT_COOKIE, "lwm_gray_tag=rc");;
 
-	if (is_http_proxy)
+	if (proxy.m_is_proxy)
 	{
-		std::string addr = http_proxy_ip + ":" + http_proxy_port;
+		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)
@@ -176,7 +207,7 @@ int CHttpClient::Posts(const std::string & strUrl, const std::string & strPost,
 	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();
@@ -198,6 +229,19 @@ int CHttpClient::Gets(const std::string & strUrl, std::string & strResponse, con
 	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);

+ 6 - 4
zhipuzi_pay_plugin/network/CHttpClient.h

@@ -1,5 +1,7 @@
 #pragma once
 
+#include "CZhipuziHttpProxy.h"
+
 class CHttpClient
 {
 public:
@@ -14,7 +16,7 @@ public:
 	* @param strResponse 输出参数,返回的内容
 	* @return 返回是否Post成功
 	*/
-	int Post(const std::string & strUrl, const std::string & strPost, std::string & strResponse);
+	int Post(const std::string & strUrl, const std::string & strPost, std::string & strResponse, CZhipuziHttpProxy proxy = CZhipuziHttpProxy());
 
 	/**
 	* @brief HTTP GET请求
@@ -22,7 +24,7 @@ public:
 	* @param strResponse 输出参数,返回的内容
 	* @return 返回是否Post成功
 	*/
-	int Get(const std::string & strUrl, std::string & strResponse);
+	int Get(const std::string & strUrl, std::string & strResponse, CZhipuziHttpProxy proxy = CZhipuziHttpProxy());
 
 	/**
 	* @brief HTTPS POST请求,无证书版本
@@ -32,7 +34,7 @@ public:
 	* @param pCaPath 输入参数,为CA证书的路径.如果输入为NULL,则不验证服务器端证书的有效性.
 	* @return 返回是否Post成功
 	*/
-	int Posts(const std::string & strUrl, const std::string & strPost, std::string & strResponse, const char * pCaPath = NULL, bool is_http_proxy = false, std::string http_proxy_ip = "", std::string http_proxy_port = "");
+	int Posts(const std::string & strUrl, const std::string & strPost, std::string & strResponse, const char * pCaPath = NULL, CZhipuziHttpProxy proxy = CZhipuziHttpProxy());
 
 	/**
 	* @brief HTTPS GET请求,无证书版本
@@ -41,7 +43,7 @@ public:
 	* @param pCaPath 输入参数,为CA证书的路径.如果输入为NULL,则不验证服务器端证书的有效性.
 	* @return 返回是否Post成功
 	*/
-	int Gets(const std::string & strUrl, std::string & strResponse, const char * pCaPath = NULL);
+	int Gets(const std::string & strUrl, std::string & strResponse, const char * pCaPath = NULL, CZhipuziHttpProxy proxy = CZhipuziHttpProxy());
 
 public:
 	void SetDebug(bool bDebug);

+ 39 - 37
zhipuzi_pay_plugin/network/CZhipuziHttpClient.cpp

@@ -7,35 +7,46 @@
 
 CZhipuziHttpClient::CZhipuziHttpClient()
 {
-	//初始化curl
-	curl_global_init(CURL_GLOBAL_ALL);
-
-	//初始化htttp代理相关参数
-	std::string http_is_proxy = CSetting::GetParam("http_is_proxy");
-	if (http_is_proxy == "1")
-	{
-		m_is_http_proxy = true;
-	}
-	else
-	{
-		m_is_http_proxy = false;
-	}
-	
-	m_http_proxy_ip = CSetting::GetParam("http_proxy_ip");
-	m_http_proxy_port = CSetting::GetParam("http_proxy_port");
+	//htttp请求环境
+	m_env = DEV;
 
 	if (m_env == DEV)
 	{
 		m_pingtai_url = "https://pf-api-dev3.zhipuzi.com/seller";
+		m_canyin_yewu_url = "https://cyapi-dev3.zhipuzi.com/seller";
+		m_lingshou_yewu_url = "https://lsapi-dev3.zhipuzi.com/seller";
 	}
 	else if (m_env == TEST)
 	{
 		m_pingtai_url = "https://pf-api-test.zhipuzi.com/seller";
+		m_canyin_yewu_url = "https://cyapi-test.zhipuzi.com/seller";
+		m_lingshou_yewu_url = "https://lsapi-test.zhipuzi.com/seller";
 	}
 	else if (m_env == RELEASE)
 	{
 		m_pingtai_url = "https://pf-api.zhipuzi.com/seller";
+		m_canyin_yewu_url = "https://cyapi.zhipuzi.com/seller";
+		m_lingshou_yewu_url = "https://lsapi.zhipuzi.com/seller";
 	}
+
+	//初始化curl
+	curl_global_init(CURL_GLOBAL_ALL);
+
+	//初始化htttp代理相关参数
+	std::string http_is_proxy = CSetting::GetParam("http_is_proxy");
+	if (http_is_proxy == "1")
+	{
+		m_http_proxy.m_is_proxy = true;
+	}
+	else
+	{
+		m_http_proxy.m_is_proxy = false;
+	}
+	
+	m_http_proxy.ip = CSetting::GetParam("http_proxy_ip");
+	m_http_proxy.port = CSetting::GetParam("http_proxy_port");
+	m_http_proxy.username = CSetting::GetParam("http_proxy_username");
+	m_http_proxy.password = CSetting::GetParam("http_proxy_password");
 }
 
 /*
@@ -46,15 +57,17 @@ void CZhipuziHttpClient::UpdateProxy()
 	std::string http_is_proxy = CSetting::GetParam("http_is_proxy");
 	if (http_is_proxy == "1")
 	{
-		m_client.m_is_http_proxy = true;
+		m_client.m_http_proxy.m_is_proxy = true;
 	}
 	else
 	{
-		m_client.m_is_http_proxy = false;
+		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.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");
 }
 
 CZhipuziHttpClient::~CZhipuziHttpClient()
@@ -135,22 +148,11 @@ bool CZhipuziHttpClient::Login(std::string& errmsg)
 
 	if (m_client.m_version_type == "1")
 	{
-		if (m_client.m_env == RELEASE)
-		{
-			m_client.m_yewu_url = "https://cyapi.zhipuzi.com/seller";
-		}
-		else if (m_client.m_env == TEST)
-		{
-			m_client.m_yewu_url = "https://cyapi-test.zhipuzi.com/seller";
-		}
-		else if (m_client.m_env == DEV)
-		{
-			m_client.m_yewu_url = "https://cyapi-dev3.zhipuzi.com/seller";
-		}
+		m_client.m_yewu_url = m_client.m_canyin_yewu_url;
 	}
 	else
 	{
-		m_client.m_yewu_url = "https://lsapi.zhipuzi.com/seller";
+		m_client.m_yewu_url = m_client.m_lingshou_yewu_url;
 	}
 
 	rapidjson::Value& v_lwm_sess_token = v_data["lwm_sess_token"];
@@ -219,7 +221,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_url + url, postString, response, NULL, m_client.m_is_http_proxy, m_client.m_http_proxy_ip, m_client.m_http_proxy_port);
+    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());
 
@@ -290,7 +292,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_url + url, postString, response, NULL, m_client.m_is_http_proxy, m_client.m_http_proxy_ip, m_client.m_http_proxy_port);
+	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());
 
@@ -361,7 +363,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, m_client.m_is_http_proxy, m_client.m_http_proxy_ip, m_client.m_http_proxy_port);
+	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());
 
@@ -432,7 +434,7 @@ bool CZhipuziHttpClient::RequestPingtaiNew(std::string url, std::map<string, str
 	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_is_http_proxy, m_client.m_http_proxy_ip, m_client.m_http_proxy_port);
+	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());
 

+ 7 - 5
zhipuzi_pay_plugin/network/CZhipuziHttpClient.h

@@ -1,7 +1,7 @@
 #pragma once
 
 #include "CHttpClient.h"
-
+#include "CZhipuziHttpProxy.h"
 
 class CZhipuziHttpClient
 {
@@ -28,6 +28,7 @@ public:
 
 	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);
+
 public:
     static CZhipuziHttpClient m_client;
 
@@ -36,17 +37,18 @@ public:
     std::string m_password;
 
     std::string m_pingtai_url = "";
+
 	std::string m_yewu_url = "";
+	std::string m_canyin_yewu_url = "";
+	std::string m_lingshou_yewu_url = "";
 
 	std::string m_version_type;
 	std::string lwm_sess_token;
 
 	std::string m_shopname;
 
-	Env m_env = DEV;
+	Env m_env;
 
 	//htttp代理相关的参数
-	bool m_is_http_proxy = false;
-	std::string m_http_proxy_ip;
-	std::string m_http_proxy_port;
+	CZhipuziHttpProxy m_http_proxy;
 };

+ 19 - 0
zhipuzi_pay_plugin/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;
+};

+ 14 - 0
zhipuzi_pay_plugin/tool/CSetting.cpp

@@ -228,6 +228,20 @@ void CSetting::Init()
 		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 jiaoban_is_work = "jiaoban_is_work";
 	if (m_paramsMap.find(jiaoban_is_work) == m_paramsMap.end())

+ 178 - 0
zhipuzi_pay_plugin/wnd/CHttpProxySettingWnd.cpp

@@ -0,0 +1,178 @@
+#include "../pch/pch.h"
+#include "CHttpProxySettingWnd.h"
+
+void CHttpProxySettingWnd::Init()
+{
+	CCheckBoxUI* is_http_proxy = static_cast<CCheckBoxUI*>(m_pm.FindControl(L"http_proxy_setting_wnd_isdaili"));
+	std::string http_is_proxy = CSetting::GetParam("http_is_proxy");
+	if (http_is_proxy == "1")
+	{
+		is_http_proxy->SetCheck(true);
+	}
+	else
+	{
+		is_http_proxy->SetCheck(false);
+	}
+
+	CEditUI* httpIpEdit = static_cast<CEditUI*>(m_pm.FindControl(L"http_proxy_setting_wnd_ip"));
+	httpIpEdit->SetText(CLewaimaiString::UTF8ToUnicode(CSetting::GetParam("http_proxy_ip")).c_str());
+
+	CEditUI* httpPortEdit = static_cast<CEditUI*>(m_pm.FindControl(L"http_proxy_setting_wnd_port"));
+	httpPortEdit->SetText(CLewaimaiString::UTF8ToUnicode(CSetting::GetParam("http_proxy_port")).c_str());
+
+	CEditUI* httpUsernameEdit = static_cast<CEditUI*>(m_pm.FindControl(L"http_proxy_setting_wnd_username"));
+	httpUsernameEdit->SetText(CLewaimaiString::UTF8ToUnicode(CSetting::GetParam("http_proxy_username")).c_str());
+
+	CEditUI* httpPasswordEdit = static_cast<CEditUI*>(m_pm.FindControl(L"http_proxy_setting_wnd_password"));
+	httpPasswordEdit->SetText(CLewaimaiString::UTF8ToUnicode(CSetting::GetParam("http_proxy_password")).c_str());
+}
+
+void CHttpProxySettingWnd::Notify(TNotifyUI& msg)
+{
+	if (msg.sType == _T("click"))
+	{
+		DuiLib::CDuiString senderName = msg.pSender->GetName();
+
+		if (senderName == _T("http_proxy_setting_wnd_closebtn"))
+		{
+			Close(IDCANCEL);
+			return;
+		}
+		else if (senderName == _T("http_proxy_setting_wnd_save"))
+		{
+			//保存代理信息
+			CCheckBoxUI* is_http_proxy = static_cast<CCheckBoxUI*>(m_pm.FindControl(L"http_proxy_setting_wnd_isdaili"));
+			if (is_http_proxy->IsSelected())
+			{
+				CSetting::SetParam("http_is_proxy", "1");
+			}
+			else
+			{
+				CSetting::SetParam("http_is_proxy", "0");
+			}
+
+			CEditUI* httpIpEdit = static_cast<CEditUI*>(m_pm.FindControl(L"http_proxy_setting_wnd_ip"));
+			std::wstring http_proxy_ip = httpIpEdit->GetText();
+			CSetting::SetParam("http_proxy_ip", CLewaimaiString::UnicodeToUTF8(http_proxy_ip));
+
+			CEditUI* httpPortEdit = static_cast<CEditUI*>(m_pm.FindControl(L"http_proxy_setting_wnd_port"));
+			std::wstring http_proxy_port = httpPortEdit->GetText();
+			CSetting::SetParam("http_proxy_port", CLewaimaiString::UnicodeToUTF8(http_proxy_port));
+
+			CEditUI* httpUsernameEdit = static_cast<CEditUI*>(m_pm.FindControl(L"http_proxy_setting_wnd_username"));
+			std::wstring http_proxy_username = httpUsernameEdit->GetText();
+			CSetting::SetParam("http_proxy_username", CLewaimaiString::UnicodeToUTF8(http_proxy_username));
+
+			CEditUI* httpPassswordEdit = static_cast<CEditUI*>(m_pm.FindControl(L"http_proxy_setting_wnd_password"));
+			std::wstring http_proxy_password = httpPassswordEdit->GetText();
+			CSetting::SetParam("http_proxy_password", CLewaimaiString::UnicodeToUTF8(http_proxy_password));
+
+			//更新httt代理状态
+			CZhipuziHttpClient::UpdateProxy();
+
+			Close(IDOK);
+			return;
+		}
+	}
+}
+
+LRESULT CHttpProxySettingWnd::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+	POINT pt;
+	pt.x = GET_X_LPARAM(lParam);
+	pt.y = GET_Y_LPARAM(lParam);
+	::ScreenToClient(*this, &pt);
+
+	RECT rcClient;
+	::GetClientRect(*this, &rcClient);
+
+	RECT rcCaption = m_pm.GetCaptionRect();
+	if (pt.x >= rcClient.left + rcCaption.left && pt.x < rcClient.right - rcCaption.right \
+		&& pt.y >= rcCaption.top && pt.y < rcCaption.bottom)
+	{
+		CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(pt));
+		if (pControl && _tcscmp(pControl->GetClass(), DUI_CTR_BUTTON) != 0)
+		{
+			return HTCAPTION;
+		}
+	}
+
+	return HTCLIENT;
+}
+
+LRESULT CHttpProxySettingWnd::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+	SIZE szRoundCorner = m_pm.GetRoundCorner();
+	if (!::IsIconic(*this) && (szRoundCorner.cx != 0 || szRoundCorner.cy != 0))
+	{
+		CDuiRect rcWnd;
+		::GetWindowRect(*this, &rcWnd);
+		rcWnd.Offset(-rcWnd.left, -rcWnd.top);
+		rcWnd.right++;
+		rcWnd.bottom++;
+		HRGN hRgn = ::CreateRoundRectRgn(rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom, szRoundCorner.cx, szRoundCorner.cy);
+		::SetWindowRgn(*this, hRgn, TRUE);
+		::DeleteObject(hRgn);
+	}
+
+	bHandled = FALSE;
+	return 0;
+}
+
+LRESULT CHttpProxySettingWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+	LRESULT lRes = 0;
+	BOOL bHandled = TRUE;
+	switch (uMsg)
+	{
+	case WM_CREATE:
+		lRes = OnCreate(uMsg, wParam, lParam, bHandled);
+		break;
+	case WM_NCACTIVATE:
+		lRes = OnNcActivate(uMsg, wParam, lParam, bHandled);
+		break;
+	case WM_NCCALCSIZE:
+		lRes = OnNcCalcSize(uMsg, wParam, lParam, bHandled);
+		break;
+	case WM_NCPAINT:
+		lRes = OnNcPaint(uMsg, wParam, lParam, bHandled);
+		break;
+	case WM_NCHITTEST:
+		lRes = OnNcHitTest(uMsg, wParam, lParam, bHandled);
+		break;
+	case WM_SIZE:
+		lRes = OnSize(uMsg, wParam, lParam, bHandled);
+		break;
+	default:
+		bHandled = FALSE;
+	}
+	if (bHandled)
+	{
+		return lRes;
+	}
+	if (m_pm.MessageHandler(uMsg, wParam, lParam, lRes))
+	{
+		return lRes;
+	}
+	return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
+}
+
+LRESULT CHttpProxySettingWnd::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled)
+{
+	if (uMsg == WM_KEYDOWN)
+	{
+		if (wParam == VK_RETURN)
+		{
+			return true;
+		}
+		else if (wParam == VK_ESCAPE)
+		{
+			return true;
+		}
+	}
+	return false;
+}
+
+
+
+

+ 87 - 0
zhipuzi_pay_plugin/wnd/CHttpProxySettingWnd.h

@@ -0,0 +1,87 @@
+#pragma once
+
+#include "../pch/pch.h"
+
+class CHttpProxySettingWnd : public CWindowWnd, public INotifyUI, public IMessageFilterUI
+{
+public:
+	LPCTSTR GetWindowClassName() const
+	{
+		return _T("UIHttpProxySettingFrame");
+	};
+
+	UINT GetClassStyle() const
+	{
+		return UI_CLASSSTYLE_DIALOG;
+	};
+
+	void OnFinalMessage(HWND /*hWnd*/)
+	{
+		//WindowImplBase::OnFinalMessage(hWnd);
+		m_pm.RemovePreMessageFilter(this);
+
+		delete this;
+	};
+
+	void Init();
+
+	void Notify(TNotifyUI& msg);
+
+	LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+	{
+		LONG styleValue = ::GetWindowLong(*this, GWL_STYLE);
+		styleValue &= ~WS_CAPTION;
+		::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
+
+		// 把自己的窗口句柄与窗口绘制管理器挂接在一起
+		m_pm.Init(m_hWnd);
+
+		m_pm.AddPreMessageFilter(this);
+
+		CDialogBuilder builder;
+
+		CControlUI* pRoot = builder.Create(_T("http_proxy_setting_wnd.xml"), (UINT)0, NULL, &m_pm);
+		ASSERT(pRoot && "Failed to parse XML");
+
+		// 把这些控件绘制到本窗口上
+		m_pm.AttachDialog(pRoot);
+
+		// 把自己加入到CPaintManagerUI的m_aNotifiers数组中,用于处理Notify函数
+		m_pm.AddNotifier(this);
+
+		Init();
+
+		return 0;
+	}
+
+	LRESULT OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+	{
+		if (::IsIconic(*this))
+		{
+			bHandled = FALSE;
+		}
+		return (wParam == 0) ? TRUE : FALSE;
+	}
+
+	LRESULT OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+	{
+		return 0;
+	}
+
+	LRESULT OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+	{
+		return 0;
+	}
+
+	LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+
+	LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+
+	LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
+
+	LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled);
+
+public:
+	CPaintManagerUI m_pm;
+};
+

+ 16 - 0
zhipuzi_pay_plugin/wnd/CLoginWnd.cpp

@@ -5,6 +5,7 @@
 #include "CValueWnd.h"
 
 #include "CMessageboxWnd.h"
+#include "CHttpProxySettingWnd.h"
 
 void CLoginWnd::Init()
 {
@@ -114,6 +115,21 @@ void CLoginWnd::Notify(TNotifyUI& msg)
         {
             ShellExecute(NULL, _T("open"), _T("explorer.exe"), _T("https://www.zhipuzi.com"), NULL, SW_SHOW);
         }
+		else if (msg.pSender->GetName() == L"proxy_setting")
+		{
+			CHttpProxySettingWnd* pWaimaiFailFrame = new CHttpProxySettingWnd();
+			pWaimaiFailFrame->Create(NULL, _T("网络代理设置"), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
+			pWaimaiFailFrame->SetIcon(IDI_ICON_DUILIB);
+			pWaimaiFailFrame->CenterWindow();
+			UINT ret = pWaimaiFailFrame->ShowModal();
+
+			if (ret == IDOK)
+			{
+				//不用处理,在窗口函数已经处理
+			}
+
+			//不用delete窗口对象,窗口销毁的时候回自动delte
+		}
     }
     else if(msg.sType == _T("itemselect"))
     {

+ 14 - 0
zhipuzi_pay_plugin/wnd/CSystemSettingWnd.cpp

@@ -396,6 +396,12 @@ void CSystemSettingWnd::Init()
 	CEditUI* httpPortEdit = static_cast<CEditUI*>(m_pm.FindControl(L"shoukuan_setting_daili_port"));
 	httpPortEdit->SetText(CLewaimaiString::UTF8ToUnicode(CSetting::GetParam("http_proxy_port")).c_str());
 
+	CEditUI* httpUsernameEdit = static_cast<CEditUI*>(m_pm.FindControl(L"shoukuan_setting_daili_username"));
+	httpUsernameEdit->SetText(CLewaimaiString::UTF8ToUnicode(CSetting::GetParam("http_proxy_username")).c_str());
+
+	CEditUI* httpPasswordEdit = static_cast<CEditUI*>(m_pm.FindControl(L"shoukuan_setting_daili_password"));
+	httpPasswordEdit->SetText(CLewaimaiString::UTF8ToUnicode(CSetting::GetParam("http_proxy_password")).c_str());
+
     //初始化快捷键的展示
     UINT shoukuan_mod = (UINT)atoi(CSetting::GetParam("system_setting_kuaijiejian_shoukuan_mod").c_str());
     UINT shoukuan_vk = (UINT)atoi(CSetting::GetParam("system_setting_kuaijiejian_shoukuan_vk").c_str());
@@ -932,6 +938,14 @@ void CSystemSettingWnd::HandleClickMsg(TNotifyUI& msg)
 		std::wstring http_proxy_port = httpPortEdit->GetText();
 		CSetting::SetParam("http_proxy_port", CLewaimaiString::UnicodeToUTF8(http_proxy_port));
 
+		CEditUI* httpUsernameEdit = static_cast<CEditUI*>(m_pm.FindControl(L"shoukuan_setting_daili_username"));
+		std::wstring http_proxy_username = httpUsernameEdit->GetText();
+		CSetting::SetParam("http_proxy_username", CLewaimaiString::UnicodeToUTF8(http_proxy_username));
+
+		CEditUI* httpPassswordEdit = static_cast<CEditUI*>(m_pm.FindControl(L"shoukuan_setting_daili_password"));
+		std::wstring http_proxy_password = httpPassswordEdit->GetText();
+		CSetting::SetParam("http_proxy_password", CLewaimaiString::UnicodeToUTF8(http_proxy_password));
+
 		//更新httt代理状态
 		CZhipuziHttpClient::UpdateProxy();
 	}

+ 0 - 2
zhipuzi_pay_plugin/zhipuzi_pay_plugin.cpp

@@ -44,8 +44,6 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
     pLogin->CenterWindow();
     pLogin->ShowModal();
 
-	int b = 1;
-
     CPaintManagerUI::MessageLoop();
 
     ::CoUninitialize();

+ 3 - 0
zhipuzi_pay_plugin/zhipuzi_pay_plugin.vcxproj

@@ -223,6 +223,8 @@ copy $(ProjectDir)conf\ $(SolutionDir)bin\$(Platform)\$(Configuration)\conf\</Co
     </PostBuildEvent>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClInclude Include="wnd\CHttpProxySettingWnd.h" />
+    <ClInclude Include="network\CZhipuziHttpProxy.h" />
     <ClInclude Include="tool\CJiaobanMessage.h" />
     <ClInclude Include="wnd\CJiaobanWnd.h" />
     <ClInclude Include="wnd\CJiaoyihuizongWnd.h" />
@@ -266,6 +268,7 @@ copy $(ProjectDir)conf\ $(SolutionDir)bin\$(Platform)\$(Configuration)\conf\</Co
     <ClInclude Include="helper\CSystem.h" />
   </ItemGroup>
   <ItemGroup>
+    <ClCompile Include="wnd\CHttpProxySettingWnd.cpp" />
     <ClCompile Include="wnd\CJiaobanWnd.cpp" />
     <ClCompile Include="wnd\CJiaoyihuizongWnd.cpp" />
     <ClCompile Include="wnd\CJiaoyijiluWnd.cpp" />

+ 9 - 0
zhipuzi_pay_plugin/zhipuzi_pay_plugin.vcxproj.filters

@@ -138,6 +138,12 @@
     <ClInclude Include="tool\CJiaobanMessage.h">
       <Filter>头文件</Filter>
     </ClInclude>
+    <ClInclude Include="network\CZhipuziHttpProxy.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="wnd\CHttpProxySettingWnd.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="pch\pch.cpp">
@@ -254,6 +260,9 @@
     <ClCompile Include="wnd\CJiaobanWnd.cpp">
       <Filter>源文件</Filter>
     </ClCompile>
+    <ClCompile Include="wnd\CHttpProxySettingWnd.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <Image Include="resource\zhipuzi.ico">