Просмотр исходного кода

调整了一些文件的格式

zhangyang 7 лет назад
Родитель
Сommit
2953954339
27 измененных файлов с 2987 добавлено и 2988 удалено
  1. BIN
      bin/Win32/Debug/zhipuzi_pos_windows/zhipuzi_pos_windows.exe
  2. 150 150
      zhipuzi_pos_windows/network/CHttpClient.cpp
  3. 39 39
      zhipuzi_pos_windows/network/CHttpClient.h
  4. 312 312
      zhipuzi_pos_windows/network/CMessagePush.cpp
  5. 51 51
      zhipuzi_pos_windows/network/CMessagePush.h
  6. 156 156
      zhipuzi_pos_windows/network/CZhipuziHttpClient.cpp
  7. 12 12
      zhipuzi_pos_windows/network/CZhipuziHttpClient.h
  8. 358 358
      zhipuzi_pos_windows/order/CWaimaiOrder.cpp
  9. 100 100
      zhipuzi_pos_windows/order/CWaimaiOrder.h
  10. 66 66
      zhipuzi_pos_windows/tool/CPosPrinter.cpp
  11. 32 32
      zhipuzi_pos_windows/tool/CPosPrinter.h
  12. 221 221
      zhipuzi_pos_windows/tool/CSetting.cpp
  13. 129 129
      zhipuzi_pos_windows/tool/CSetting.h
  14. 16 16
      zhipuzi_pos_windows/tool/CSqlite3.cpp
  15. 15 15
      zhipuzi_pos_windows/tool/CSqlite3.h
  16. 77 77
      zhipuzi_pos_windows/wnd/CChufangSettingWnd.cpp
  17. 187 187
      zhipuzi_pos_windows/wnd/CChufangSettingWnd.h
  18. 262 262
      zhipuzi_pos_windows/wnd/CLoginWnd.cpp
  19. 24 24
      zhipuzi_pos_windows/wnd/CLoginWnd.h
  20. 374 374
      zhipuzi_pos_windows/wnd/CMainWnd.cpp
  21. 3 3
      zhipuzi_pos_windows/wnd/CMainWnd.h
  22. 77 77
      zhipuzi_pos_windows/wnd/CMessageboxWnd.cpp
  23. 68 68
      zhipuzi_pos_windows/wnd/CMessageboxWnd.h
  24. 58 59
      zhipuzi_pos_windows/wnd/CUpdateWnd.cpp
  25. 16 16
      zhipuzi_pos_windows/wnd/CUpdateWnd.h
  26. 77 77
      zhipuzi_pos_windows/wnd/CWaimaiOrderFailReasonWnd.cpp
  27. 107 107
      zhipuzi_pos_windows/wnd/CWaimaiOrderFailReasonWnd.h

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


+ 150 - 150
zhipuzi_pos_windows/network/CHttpClient.cpp

@@ -4,7 +4,7 @@
 #include <curl/curl.h>
 
 CHttpClient::CHttpClient(void) :
-	m_bDebug(false)
+    m_bDebug(false)
 {
 
 }
@@ -14,180 +14,180 @@ CHttpClient::~CHttpClient(void)
 
 }
 
-static int OnDebug(CURL *, curl_infotype itype, char * pData, size_t size, 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);
-	if (NULL == str || NULL == buffer)
-	{
-		return -1;
-	}
+    std::string* str = dynamic_cast<std::string*>((std::string*)lpVoid);
+    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)
 {
-	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);
+    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)
 {
-	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);
+    /**
+    * 当多个线程都使用超时处理的时候,同时主线程中有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)
 {
-	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);
-	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);
+    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)
 {
-	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(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;
 }

+ 39 - 39
zhipuzi_pos_windows/network/CHttpClient.h

@@ -5,50 +5,50 @@ using namespace std;
 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);
+
+    /**
+    * @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);
 
 public:
-	void SetDebug(bool bDebug);
+    void SetDebug(bool bDebug);
 
 private:
-	bool m_bDebug;
+    bool m_bDebug;
 };
 

+ 312 - 312
zhipuzi_pos_windows/network/CMessagePush.cpp

@@ -15,15 +15,15 @@ CMessagePush::~CMessagePush()
 
 void CMessagePush::Start()
 {
-	m_is_work = true;
+    m_is_work = true;
 
-	m_nStopNum = 0;
+    m_nStopNum = 0;
 
     //心跳包
-	std::thread(&CMessagePush::KeepAlive, this).detach();
+    std::thread(&CMessagePush::KeepAlive, this).detach();
 
-	//接收消息
-	std::thread(&CMessagePush::ReceiveMessage, this).detach();
+    //接收消息
+    std::thread(&CMessagePush::ReceiveMessage, this).detach();
 
     //处理声音提醒
     std::thread(&CMessagePush::HandleVoice, this).detach();
@@ -31,8 +31,8 @@ void CMessagePush::Start()
     //处理订单确认
     std::thread(&CMessagePush::HandleConfirm, this).detach();
 
-	//处理打印
-	std::thread(&CMessagePush::HandlePrinter, this).detach();
+    //处理打印
+    std::thread(&CMessagePush::HandlePrinter, this).detach();
 
     //处理收银打印
     std::thread(&CMessagePush::HandleShouyinPrinter, this).detach();
@@ -43,239 +43,239 @@ void CMessagePush::Start()
 
 void CMessagePush::Stop()
 {
-	m_is_work = false;
-
-	socket_.close();
-
-	m_voice_mutex.lock();
-	while (!m_voice_queue.empty())
-	{
-		m_voice_queue.pop();
-	}
-	m_voice_mutex.unlock();
-
-	m_confirm_mutex.lock();
-	while (!m_confirm_queue.empty())
-	{
-		m_confirm_queue.pop();
-	}
-	m_confirm_mutex.unlock();
-
-	m_printer_mutex.lock();
-	while (!m_printer_queue.empty())
-	{
-		m_printer_queue.pop();
-	}
-	m_printer_mutex.unlock();
-
-	m_shouyin_printer_mutex.lock();
-	while (!m_shouyin_printer_queue.empty())
-	{
-		m_shouyin_printer_queue.pop();
-	}
-	m_shouyin_printer_mutex.unlock();
-
-	m_chufang_printer_mutex.lock();
-	while (!m_chufang_printer_queue.empty())
-	{
-		m_chufang_printer_queue.pop();
-	}
-	m_chufang_printer_mutex.unlock();
+    m_is_work = false;
+
+    socket_.close();
+
+    m_voice_mutex.lock();
+    while(!m_voice_queue.empty())
+    {
+        m_voice_queue.pop();
+    }
+    m_voice_mutex.unlock();
+
+    m_confirm_mutex.lock();
+    while(!m_confirm_queue.empty())
+    {
+        m_confirm_queue.pop();
+    }
+    m_confirm_mutex.unlock();
+
+    m_printer_mutex.lock();
+    while(!m_printer_queue.empty())
+    {
+        m_printer_queue.pop();
+    }
+    m_printer_mutex.unlock();
+
+    m_shouyin_printer_mutex.lock();
+    while(!m_shouyin_printer_queue.empty())
+    {
+        m_shouyin_printer_queue.pop();
+    }
+    m_shouyin_printer_mutex.unlock();
+
+    m_chufang_printer_mutex.lock();
+    while(!m_chufang_printer_queue.empty())
+    {
+        m_chufang_printer_queue.pop();
+    }
+    m_chufang_printer_mutex.unlock();
 }
 
 void CMessagePush::KeepAlive()
 {
-	while (m_is_work)
-	{
-		//生成心跳包
-		rapidjson::Document doc;
-		doc.SetObject();
-		rapidjson::Document::AllocatorType& allocator = doc.GetAllocator(); //获取分配器
-
-		std::string username = CSetting::getUsername();
-		std::string timestamp = to_string(time(NULL));
-		doc.AddMember("username", StringRef(username.c_str(), username.length()), allocator);
-		doc.AddMember("timestamp", StringRef(timestamp.c_str(), timestamp.length()), allocator);
-		doc.AddMember("is_login", "0", allocator);
-
-		rapidjson::StringBuffer buffer;
-		rapidjson::Writer<StringBuffer> writer(buffer);
-		doc.Accept(writer);
-
-		//返回给接入层的消息
-		std::string m_keepalive_msg = buffer.GetString();
-
-		PosMessage new_msg;
-		new_msg.m_length = m_keepalive_msg.length();
-		memcpy(new_msg.data, m_keepalive_msg.c_str(), m_keepalive_msg.length());
-		new_msg.data[new_msg.m_length] = '\0';
-
-		try
-		{
-			socket_.write_some(boost::asio::buffer(&new_msg, sizeof(PosMessage)));
-		}
-		catch (const std::exception& e)
-		{
-			//走到这里来说明心跳包发送失败了,socket失效了
-			std::string err = e.what();
-
-			//先把socket关闭掉
-			socket_.close();
-
-			try
-			{
-				//发送失败,重新建立连接
-				char host[] = "pushserver.zhipuzi.com";
-				char port[] = "9001";
-
-				tcp::resolver resolver(m_io_context);
-				tcp::resolver::results_type endpoints =
-					resolver.resolve(tcp::v4(), host, port);
-
-				boost::asio::connect(socket_, endpoints);
-
-				//刚刚连接上,这是第一次登陆,发送登陆信息
-				rapidjson::Document doc_1;
-				doc_1.SetObject();
-				rapidjson::Document::AllocatorType& allocator_1 = doc_1.GetAllocator(); //获取分配器
-
-				std::string username_1 = CSetting::getUsername();
-				std::string timestamp_1 = to_string(time(NULL));
-				doc_1.AddMember("username", StringRef(username_1.c_str(), username_1.length()), allocator_1);
-				doc_1.AddMember("timestamp", StringRef(timestamp_1.c_str(), timestamp_1.length()), allocator_1);
-				doc_1.AddMember("is_login", "1", allocator_1);
-
-				rapidjson::StringBuffer buffer_1;
-				rapidjson::Writer<StringBuffer> writer_1(buffer_1);
-				doc_1.Accept(writer_1);
-
-				//返回给接入层的消息
-				std::string m_login_message = buffer_1.GetString();
-
-				PosMessage login_msg;
-				login_msg.m_length = m_login_message.length();
-				memcpy(login_msg.data, m_login_message.c_str(), m_login_message.length());
-				login_msg.data[login_msg.m_length] = '\0';
-
-				socket_.write_some(boost::asio::buffer(boost::asio::buffer(&login_msg, sizeof(PosMessage))));
-			}
-			catch (const std::exception& e)
-			{
-				//重新连接或者重新发送又失败了,可能是网络断了
-				std::string err = e.what();
-				LOG_INFO("write err info:" << err.c_str());
-
-				//关闭无效的连接
-				socket_.close();
-
-				//30秒后再重试
-				CSystem::my_sleep(30);
-
-				continue;
-			}
-		}
-
-		//走到这里,说明心跳包发送成功了,socket是连通的
-
-		//休眠30秒钟,之后再发心跳包
-		CSystem::my_sleep(30);
-	}
-
-	AddStopNum();
+    while(m_is_work)
+    {
+        //生成心跳包
+        rapidjson::Document doc;
+        doc.SetObject();
+        rapidjson::Document::AllocatorType& allocator = doc.GetAllocator(); //获取分配器
+
+        std::string username = CSetting::getUsername();
+        std::string timestamp = to_string(time(NULL));
+        doc.AddMember("username", StringRef(username.c_str(), username.length()), allocator);
+        doc.AddMember("timestamp", StringRef(timestamp.c_str(), timestamp.length()), allocator);
+        doc.AddMember("is_login", "0", allocator);
+
+        rapidjson::StringBuffer buffer;
+        rapidjson::Writer<StringBuffer> writer(buffer);
+        doc.Accept(writer);
+
+        //返回给接入层的消息
+        std::string m_keepalive_msg = buffer.GetString();
+
+        PosMessage new_msg;
+        new_msg.m_length = m_keepalive_msg.length();
+        memcpy(new_msg.data, m_keepalive_msg.c_str(), m_keepalive_msg.length());
+        new_msg.data[new_msg.m_length] = '\0';
+
+        try
+        {
+            socket_.write_some(boost::asio::buffer(&new_msg, sizeof(PosMessage)));
+        }
+        catch(const std::exception& e)
+        {
+            //走到这里来说明心跳包发送失败了,socket失效了
+            std::string err = e.what();
+
+            //先把socket关闭掉
+            socket_.close();
+
+            try
+            {
+                //发送失败,重新建立连接
+                char host[] = "pushserver.zhipuzi.com";
+                char port[] = "9001";
+
+                tcp::resolver resolver(m_io_context);
+                tcp::resolver::results_type endpoints =
+                    resolver.resolve(tcp::v4(), host, port);
+
+                boost::asio::connect(socket_, endpoints);
+
+                //刚刚连接上,这是第一次登陆,发送登陆信息
+                rapidjson::Document doc_1;
+                doc_1.SetObject();
+                rapidjson::Document::AllocatorType& allocator_1 = doc_1.GetAllocator(); //获取分配器
+
+                std::string username_1 = CSetting::getUsername();
+                std::string timestamp_1 = to_string(time(NULL));
+                doc_1.AddMember("username", StringRef(username_1.c_str(), username_1.length()), allocator_1);
+                doc_1.AddMember("timestamp", StringRef(timestamp_1.c_str(), timestamp_1.length()), allocator_1);
+                doc_1.AddMember("is_login", "1", allocator_1);
+
+                rapidjson::StringBuffer buffer_1;
+                rapidjson::Writer<StringBuffer> writer_1(buffer_1);
+                doc_1.Accept(writer_1);
+
+                //返回给接入层的消息
+                std::string m_login_message = buffer_1.GetString();
+
+                PosMessage login_msg;
+                login_msg.m_length = m_login_message.length();
+                memcpy(login_msg.data, m_login_message.c_str(), m_login_message.length());
+                login_msg.data[login_msg.m_length] = '\0';
+
+                socket_.write_some(boost::asio::buffer(boost::asio::buffer(&login_msg, sizeof(PosMessage))));
+            }
+            catch(const std::exception& e)
+            {
+                //重新连接或者重新发送又失败了,可能是网络断了
+                std::string err = e.what();
+                LOG_INFO("write err info:" << err.c_str());
+
+                //关闭无效的连接
+                socket_.close();
+
+                //30秒后再重试
+                CSystem::my_sleep(30);
+
+                continue;
+            }
+        }
+
+        //走到这里,说明心跳包发送成功了,socket是连通的
+
+        //休眠30秒钟,之后再发心跳包
+        CSystem::my_sleep(30);
+    }
+
+    AddStopNum();
 }
 
 void CMessagePush::ReceiveMessage()
 {
-	while (m_is_work)
-	{
-		try
-		{
-			PosMessage new_msg;
-			
-			boost::asio::read(socket_, boost::asio::buffer(&new_msg, sizeof(PosMessage)));
-
-			std::string msg = new_msg.data;
-
-			//收到服务器的消息,对服务器的消息进行处理
-			rapidjson::Document document;
-			document.Parse(msg.c_str());
-			if (!document.IsObject())
-			{
-				LOG_INFO("message 非法!");
-				return;
-			}
-
-			std::string type;
-			if (document["msg_type"].IsInt())
-			{
-				type = to_string(document["msg_type"].GetInt());
-			}
-			else
-			{
-				type = document["msg_type"].GetString();
-			}
-
-			if (type == "1")
-			{
-				std::string order_id = document["waimai_order_id"].GetString();
-				std::string order_no = document["waimai_order_no"].GetString();
-
-				//新订单来了,首先判断是否要语音提醒
-				if (CSetting::GetParam("setting_is_new_waimai_voice") == "1")
-				{
-					if (CSetting::GetParam("setting_is_new_waimai_autoconfirm") == "1")
-					{
-						AddVoice(2);
-					}
-					else
-					{
-						AddVoice(1);
-					}
-				}
-
-				//判断是否要自动确认
-				if (CSetting::GetParam("setting_is_new_waimai_autoconfirm") == "1")
-				{
-					AddConfirm(order_id);
-				}
-
-				//判断是否右下角弹框提醒
-				if (CSetting::GetParam("setting_is_new_waimai_dialog") == "1")
-				{
-
-				}
-
-				AddPinter(order_id, order_no, 1);
-			}
-			else if (type == "2")
-			{
-				AddVoice(3);
-			}
-			else if (type == "3")
-			{
-				AddVoice(4);
-			}
-			else if (type == "0")
-			{
-				//这个表示被人挤下线了
-				PostMessage(m_hwnd, WM_LOGIN_AGAIN_OUT, 0, 0);
-			}
-
-			//处理完了,接着处理下一条
-			continue;
-		}
-		catch (std::exception& e)
-		{
-			std::string err = e.what();
-			LOG_INFO("read err:" << err.c_str());
-
-			//如果这里异常了,说明socket失效了,等2秒重新读
-			CSystem::my_sleep(2);
-			continue;
-		}
-	}
-
-	AddStopNum();
+    while(m_is_work)
+    {
+        try
+        {
+            PosMessage new_msg;
+
+            boost::asio::read(socket_, boost::asio::buffer(&new_msg, sizeof(PosMessage)));
+
+            std::string msg = new_msg.data;
+
+            //收到服务器的消息,对服务器的消息进行处理
+            rapidjson::Document document;
+            document.Parse(msg.c_str());
+            if(!document.IsObject())
+            {
+                LOG_INFO("message 非法!");
+                return;
+            }
+
+            std::string type;
+            if(document["msg_type"].IsInt())
+            {
+                type = to_string(document["msg_type"].GetInt());
+            }
+            else
+            {
+                type = document["msg_type"].GetString();
+            }
+
+            if(type == "1")
+            {
+                std::string order_id = document["waimai_order_id"].GetString();
+                std::string order_no = document["waimai_order_no"].GetString();
+
+                //新订单来了,首先判断是否要语音提醒
+                if(CSetting::GetParam("setting_is_new_waimai_voice") == "1")
+                {
+                    if(CSetting::GetParam("setting_is_new_waimai_autoconfirm") == "1")
+                    {
+                        AddVoice(2);
+                    }
+                    else
+                    {
+                        AddVoice(1);
+                    }
+                }
+
+                //判断是否要自动确认
+                if(CSetting::GetParam("setting_is_new_waimai_autoconfirm") == "1")
+                {
+                    AddConfirm(order_id);
+                }
+
+                //判断是否右下角弹框提醒
+                if(CSetting::GetParam("setting_is_new_waimai_dialog") == "1")
+                {
+
+                }
+
+                AddPinter(order_id, order_no, 1);
+            }
+            else if(type == "2")
+            {
+                AddVoice(3);
+            }
+            else if(type == "3")
+            {
+                AddVoice(4);
+            }
+            else if(type == "0")
+            {
+                //这个表示被人挤下线了
+                PostMessage(m_hwnd, WM_LOGIN_AGAIN_OUT, 0, 0);
+            }
+
+            //处理完了,接着处理下一条
+            continue;
+        }
+        catch(std::exception& e)
+        {
+            std::string err = e.what();
+            LOG_INFO("read err:" << err.c_str());
+
+            //如果这里异常了,说明socket失效了,等2秒重新读
+            CSystem::my_sleep(2);
+            continue;
+        }
+    }
+
+    AddStopNum();
 }
 
 /*
@@ -301,16 +301,16 @@ void CMessagePush::AddConfirm(std::string order_id)
 
 void CMessagePush::AddPinter(std::string order_id, std::string order_no, int print_type)
 {
-	m_printer_mutex.lock();
+    m_printer_mutex.lock();
 
-	WaimaiPinterInfo newPrinter;
-	newPrinter.order_id = order_id;
-	newPrinter.order_no = order_no;
-	newPrinter.print_type = print_type;
+    WaimaiPinterInfo newPrinter;
+    newPrinter.order_id = order_id;
+    newPrinter.order_no = order_no;
+    newPrinter.print_type = print_type;
 
-	m_printer_queue.push(newPrinter);
+    m_printer_queue.push(newPrinter);
 
-	m_printer_mutex.unlock();
+    m_printer_mutex.unlock();
 }
 
 void CMessagePush::AddShouyinPrinter(CWaimaiOrder order)
@@ -350,32 +350,32 @@ void CMessagePush::HandleVoice()
 
         m_voice_mutex.unlock();
 
-		if (voice_type == 1)
-		{
-			wstring path = CSystem::GetProgramDir() + L"\\music\\waimai_new.wav";
-			PlaySound(path.c_str(), NULL, SND_FILENAME | SND_ASYNC);
-		}
-		else if (voice_type == 2)
-		{
-			wstring path = CSystem::GetProgramDir() + L"\\music\\waimai_new_auto.wav";
-			PlaySound(path.c_str(), NULL, SND_FILENAME | SND_ASYNC);
-		}
-		else if (voice_type == 3)
-		{
-			wstring path = CSystem::GetProgramDir() + L"\\music\\waimai_quxiao.wav";
-			PlaySound(path.c_str(), NULL, SND_FILENAME | SND_ASYNC);
-		}
-		else if (voice_type == 4)
-		{
-			wstring path = CSystem::GetProgramDir() + L"\\music\\waimai_tuikuan.wav";
-			PlaySound(path.c_str(), NULL, SND_FILENAME | SND_ASYNC);
-		}
+        if(voice_type == 1)
+        {
+            wstring path = CSystem::GetProgramDir() + L"\\music\\waimai_new.wav";
+            PlaySound(path.c_str(), NULL, SND_FILENAME | SND_ASYNC);
+        }
+        else if(voice_type == 2)
+        {
+            wstring path = CSystem::GetProgramDir() + L"\\music\\waimai_new_auto.wav";
+            PlaySound(path.c_str(), NULL, SND_FILENAME | SND_ASYNC);
+        }
+        else if(voice_type == 3)
+        {
+            wstring path = CSystem::GetProgramDir() + L"\\music\\waimai_quxiao.wav";
+            PlaySound(path.c_str(), NULL, SND_FILENAME | SND_ASYNC);
+        }
+        else if(voice_type == 4)
+        {
+            wstring path = CSystem::GetProgramDir() + L"\\music\\waimai_tuikuan.wav";
+            PlaySound(path.c_str(), NULL, SND_FILENAME | SND_ASYNC);
+        }
 
         //8秒内最多播放一次
         CSystem::my_sleep(8);
     }
 
-	AddStopNum();
+    AddStopNum();
 }
 
 void CMessagePush::HandleConfirm()
@@ -401,7 +401,7 @@ void CMessagePush::HandleConfirm()
         newOrder.ConfirmeOrder(order_id);
     }
 
-	AddStopNum();
+    AddStopNum();
 }
 
 void CMessagePush::HandlePrinter()
@@ -421,55 +421,55 @@ void CMessagePush::HandlePrinter()
         WaimaiPinterInfo printerInfo = m_printer_queue.front();
         std::string order_id = printerInfo.order_id;
         std::string order_no = printerInfo.order_no;
-		int print_type = printerInfo.print_type;
+        int print_type = printerInfo.print_type;
 
         m_printer_queue.pop();
 
         m_printer_mutex.unlock();
 
         CWaimaiOrder order;
-		if (print_type == 1)
-		{
-			if (CSetting::GetParam("setting_is_new_waimai_printer") == "1" || CSetting::GetParam("setting_is_new_waimai_chufang_printer") == "1")
-			{
-				bool ret = order.InitData(order_id, order_no);
-
-				if (ret == false)
-				{
-					this->AddPinter(order_id, order_no, print_type);
-					continue;
-				}
-			}
-
-			//判断是否自动打印收银小票
-			if (CSetting::GetParam("setting_is_new_waimai_printer") == "1")
-			{
-				AddShouyinPrinter(order);
-			}
-
-			//判断是否进行自动的厨房打印
-			if (CSetting::GetParam("setting_is_new_waimai_chufang_printer") == "1")
-			{
-				AddChufangPrinter(order);
-			}
-		}
-		else
-		{
-			bool ret = order.InitData(order_id, order_no);
-
-			if (ret == false)
-			{
-				this->AddPinter(order_id, order_no, print_type);
-				continue;
-			}
-
-			AddShouyinPrinter(order);
-
-			AddChufangPrinter(order);
-		}
+        if(print_type == 1)
+        {
+            if(CSetting::GetParam("setting_is_new_waimai_printer") == "1" || CSetting::GetParam("setting_is_new_waimai_chufang_printer") == "1")
+            {
+                bool ret = order.InitData(order_id, order_no);
+
+                if(ret == false)
+                {
+                    this->AddPinter(order_id, order_no, print_type);
+                    continue;
+                }
+            }
+
+            //判断是否自动打印收银小票
+            if(CSetting::GetParam("setting_is_new_waimai_printer") == "1")
+            {
+                AddShouyinPrinter(order);
+            }
+
+            //判断是否进行自动的厨房打印
+            if(CSetting::GetParam("setting_is_new_waimai_chufang_printer") == "1")
+            {
+                AddChufangPrinter(order);
+            }
+        }
+        else
+        {
+            bool ret = order.InitData(order_id, order_no);
+
+            if(ret == false)
+            {
+                this->AddPinter(order_id, order_no, print_type);
+                continue;
+            }
+
+            AddShouyinPrinter(order);
+
+            AddChufangPrinter(order);
+        }
     }
 
-	AddStopNum();
+    AddStopNum();
 }
 
 void CMessagePush::HandleShouyinPrinter()
@@ -496,7 +496,7 @@ void CMessagePush::HandleShouyinPrinter()
         printer.PrintWaimaiOrderShouyin(order);
     }
 
-	AddStopNum();
+    AddStopNum();
 }
 
 void CMessagePush::HandleChufangPrinter()
@@ -523,20 +523,20 @@ void CMessagePush::HandleChufangPrinter()
         printer.PrintWaimaiOrderChufang(order);
     }
 
-	AddStopNum();
+    AddStopNum();
 }
 
 void CMessagePush::AddStopNum()
 {
-	m_nStopNumMutex.lock();
+    m_nStopNumMutex.lock();
 
-	m_nStopNum++;
+    m_nStopNum++;
 
-	m_nStopNumMutex.unlock();
+    m_nStopNumMutex.unlock();
 
-	if (m_nStopNum == 7)
-	{
-		//确认所有子线程都退出了,再删除自己
-		delete this;
-	}
+    if(m_nStopNum == 7)
+    {
+        //确认所有子线程都退出了,再删除自己
+        delete this;
+    }
 }

+ 51 - 51
zhipuzi_pos_windows/network/CMessagePush.h

@@ -8,85 +8,85 @@ using boost::asio::ip::tcp;
 class CClientMessage
 {
 public:
-	int m_type; //消息类型 0:新的外卖订单
+    int m_type; //消息类型 0:新的外卖订单
 
-	std::string m_username;
-	std::string m_order_id;
-	std::string m_order_no;
+    std::string m_username;
+    std::string m_order_id;
+    std::string m_order_no;
 };
 
 class WaimaiPinterInfo
 {
 public:
-	std::string order_id;
-	std::string order_no;
-	int print_type; //打印类型 1:新订单自动打印 2:手动打印
+    std::string order_id;
+    std::string order_no;
+    int print_type; //打印类型 1:新订单自动打印 2:手动打印
 };
 
 class CMessagePush
 {
 public:
-	CMessagePush(HWND hwnd)
-		: socket_(m_io_context)
-	{
-		m_hwnd = hwnd;
-	}
+    CMessagePush(HWND hwnd)
+        : socket_(m_io_context)
+    {
+        m_hwnd = hwnd;
+    }
 
-	~CMessagePush();
+    ~CMessagePush();
 
-	//开始工作
-	void Start();
+    //开始工作
+    void Start();
 
-	//停止工作
-	void Stop();
+    //停止工作
+    void Stop();
 
-	//发送心跳包
-	void KeepAlive();
+    //发送心跳包
+    void KeepAlive();
 
-	//专门处理推送消息
-	void ReceiveMessage();
+    //专门处理推送消息
+    void ReceiveMessage();
 
-	//队列处理
-	void HandleVoice();
-	void HandleConfirm();
-	void HandlePrinter();
-	void HandleShouyinPrinter();
-	void HandleChufangPrinter();
+    //队列处理
+    void HandleVoice();
+    void HandleConfirm();
+    void HandlePrinter();
+    void HandleShouyinPrinter();
+    void HandleChufangPrinter();
 
 
-	void AddVoice(int voice_type);
-	void AddConfirm(std::string order_id);
-	void AddPinter(std::string order_id, std::string order_no, int print_type);
-	void AddShouyinPrinter(CWaimaiOrder order);
-	void AddChufangPrinter(CWaimaiOrder order);
+    void AddVoice(int voice_type);
+    void AddConfirm(std::string order_id);
+    void AddPinter(std::string order_id, std::string order_no, int print_type);
+    void AddShouyinPrinter(CWaimaiOrder order);
+    void AddChufangPrinter(CWaimaiOrder order);
 
 private:
-	void AddStopNum();
+    void AddStopNum();
 
 private:
-	bool m_is_work;
+    bool m_is_work;
 
-	int m_nStopNum = 0;
-	std::mutex m_nStopNumMutex;
+    int m_nStopNum = 0;
+    std::mutex m_nStopNumMutex;
 
-	boost::asio::io_context m_io_context;
-	tcp::socket socket_;
+    boost::asio::io_context m_io_context;
+    tcp::socket socket_;
 
-	enum { max_length = 1024 };
-	char data_[max_length];
+    enum { max_length = 1024 };
+    char data_[max_length];
 
-	std::queue<int> m_voice_queue;
-	std::queue<std::string> m_confirm_queue;
-	std::queue<WaimaiPinterInfo> m_printer_queue;
-	std::queue<CWaimaiOrder> m_shouyin_printer_queue;
-	std::queue<CWaimaiOrder> m_chufang_printer_queue;
+    std::queue<int> m_voice_queue;
+    std::queue<std::string> m_confirm_queue;
+    std::queue<WaimaiPinterInfo> m_printer_queue;
+    std::queue<CWaimaiOrder> m_shouyin_printer_queue;
+    std::queue<CWaimaiOrder> m_chufang_printer_queue;
 
-	std::mutex m_voice_mutex;
-	std::mutex m_confirm_mutex;
-	std::mutex m_printer_mutex;
-	std::mutex m_shouyin_printer_mutex;
-	std::mutex m_chufang_printer_mutex;
+    std::mutex m_voice_mutex;
+    std::mutex m_confirm_mutex;
+    std::mutex m_printer_mutex;
+    std::mutex m_shouyin_printer_mutex;
+    std::mutex m_chufang_printer_mutex;
 
-	HWND m_hwnd;
+    HWND m_hwnd;
 };
 

+ 156 - 156
zhipuzi_pos_windows/network/CZhipuziHttpClient.cpp

@@ -7,8 +7,8 @@ CZhipuziHttpClient CZhipuziHttpClient::m_client;
 
 CZhipuziHttpClient::CZhipuziHttpClient()
 {
-	m_username = CSetting::getUsername();
-	m_password = CSetting::getPassword();
+    m_username = CSetting::getUsername();
+    m_password = CSetting::getPassword();
 }
 
 
@@ -18,204 +18,204 @@ CZhipuziHttpClient::~CZhipuziHttpClient()
 
 void CZhipuziHttpClient::Init(std::string username, std::string password)
 {
-	m_client.m_username = username;
-	m_client.m_password = password;
+    m_client.m_username = username;
+    m_client.m_password = password;
 }
 
 bool CZhipuziHttpClient::Login(std::string& errmsg)
 {
-	std::map<string, string> params;
-
-	std::string response;
-	bool ret = m_client.RequestNew("/login/login", params, response);
-
-	if (!ret)
-	{
-		//网络请求出错
-		LOG_INFO("network failed!");
-		errmsg = "network failed!";
-		return false;
-	}
-
-	LOG_INFO("response:" << response.c_str());
-
-	rapidjson::Document document;
-	document.Parse(response.c_str());
-	if (!document.IsObject())
-	{
-		LOG_INFO("message 非法!");
-		errmsg = "message 非法!";
-		return false;
-	}
-
-	if (document.HasMember("errcode"))
-	{
-		rapidjson::Value& v_errcode = document["errcode"];
-		int errcode = v_errcode.GetInt();
-		if (errcode == -1)
-		{
-			LOG_INFO("login failed! message:" << document["errmsg"].GetString());
-			errmsg = std::string(document["errmsg"].GetString());
-			return false;
-		}
-	}
-	else if (document.HasMember("error_code"))
-	{
-		rapidjson::Value& v_errcode = document["error_code"];
-		int errcode = v_errcode.GetInt();
-		if (errcode < 0)
-		{
-			LOG_INFO("login failed! message:" << document["error_msg"].GetString());
-			errmsg = std::string(document["error_msg"].GetString());
-			return false;
-		}
-	}	
-
-	LOG_INFO("login success!");
-	
-	return true;
+    std::map<string, string> params;
+
+    std::string response;
+    bool ret = m_client.RequestNew("/login/login", params, response);
+
+    if(!ret)
+    {
+        //网络请求出错
+        LOG_INFO("network failed!");
+        errmsg = "network failed!";
+        return false;
+    }
+
+    LOG_INFO("response:" << response.c_str());
+
+    rapidjson::Document document;
+    document.Parse(response.c_str());
+    if(!document.IsObject())
+    {
+        LOG_INFO("message 非法!");
+        errmsg = "message 非法!";
+        return false;
+    }
+
+    if(document.HasMember("errcode"))
+    {
+        rapidjson::Value& v_errcode = document["errcode"];
+        int errcode = v_errcode.GetInt();
+        if(errcode == -1)
+        {
+            LOG_INFO("login failed! message:" << document["errmsg"].GetString());
+            errmsg = std::string(document["errmsg"].GetString());
+            return false;
+        }
+    }
+    else if(document.HasMember("error_code"))
+    {
+        rapidjson::Value& v_errcode = document["error_code"];
+        int errcode = v_errcode.GetInt();
+        if(errcode < 0)
+        {
+            LOG_INFO("login failed! message:" << document["error_msg"].GetString());
+            errmsg = std::string(document["error_msg"].GetString());
+            return false;
+        }
+    }
+
+    LOG_INFO("login success!");
+
+    return true;
 }
 
 bool CZhipuziHttpClient::RequestOld(std::string url, std::map<string, string> params, std::string& response)
 {
-	std::string timestamp = to_string(time(NULL));
-	std::string nonce = "123456";
+    std::string timestamp = to_string(time(NULL));
+    std::string nonce = "123456";
 
-	//先添加默认参数,用于计算签名
-	params["machinecode"] = m_client.m_machinecode;
-	params["username"] = m_client.m_username;
-	params["nonce"] = nonce;
-	params["timestamp"] = timestamp;
-	params["url"] = m_client.m_old_url + url;
+    //先添加默认参数,用于计算签名
+    params["machinecode"] = m_client.m_machinecode;
+    params["username"] = m_client.m_username;
+    params["nonce"] = nonce;
+    params["timestamp"] = timestamp;
+    params["url"] = m_client.m_old_url + url;
 
-	//计算签名
-	std::string postString;
-	for (std::map<string, string>::iterator it = params.begin(); it != params.end(); )
-	{
-		postString += it->first + "=" + it->second;
+    //计算签名
+    std::string postString;
+    for(std::map<string, string>::iterator it = params.begin(); it != params.end();)
+    {
+        postString += it->first + "=" + it->second;
 
-		it++;
+        it++;
 
-		if (it != params.end())
-		{
-			postString += "&";
-		}
-	}
+        if(it != params.end())
+        {
+            postString += "&";
+        }
+    }
 
-	LOG_INFO("postString:" << postString.c_str());
+    LOG_INFO("postString:" << postString.c_str());
 
-	//用于计算签名的临时变量
-	std::string password = md5(m_client.m_password);
-	transform(password.begin(), password.end(), password.begin(), ::toupper);
+    //用于计算签名的临时变量
+    std::string password = md5(m_client.m_password);
+    transform(password.begin(), password.end(), password.begin(), ::toupper);
 
-	string tmp = postString + password;
+    string tmp = postString + password;
 
-	std::string sign = md5(tmp);
-	transform(sign.begin(), sign.end(), sign.begin(), ::toupper);
-	LOG_INFO("sign:" << sign.c_str());
+    std::string sign = md5(tmp);
+    transform(sign.begin(), sign.end(), sign.begin(), ::toupper);
+    LOG_INFO("sign:" << sign.c_str());
 
-	//加上签名,去掉url,计算post
-	params["sign"] = sign;
-	params.erase("url");
+    //加上签名,去掉url,计算post
+    params["sign"] = sign;
+    params.erase("url");
 
-	//未签名之前,不能进行urlencode,签名完成之后可以(params的value必须为utf8格式)
-	postString = "";
-	for (std::map<string, string>::iterator it = params.begin(); it != params.end(); )
-	{
-		postString += it->first + "=" + CLewaimaiString::UrlEncode(it->second);
+    //未签名之前,不能进行urlencode,签名完成之后可以(params的value必须为utf8格式)
+    postString = "";
+    for(std::map<string, string>::iterator it = params.begin(); it != params.end();)
+    {
+        postString += it->first + "=" + CLewaimaiString::UrlEncode(it->second);
 
-		it++;
+        it++;
 
-		if (it != params.end())
-		{
-			postString += "&";
-		}
-	}
+        if(it != params.end())
+        {
+            postString += "&";
+        }
+    }
 
-	LOG_INFO("postString:" << postString.c_str());
+    LOG_INFO("postString:" << postString.c_str());
 
-	CHttpClient m_httpClient;
-	int ret = m_httpClient.Posts(m_client.m_old_url + url, postString, response, NULL);
+    CHttpClient m_httpClient;
+    int ret = m_httpClient.Posts(m_client.m_old_url + url, postString, response, NULL);
 
-	LOG_INFO("response:" << response.c_str());
+    LOG_INFO("response:" << response.c_str());
 
-	if (ret == 0)
-	{
-		//ret为0表示没有出错
-		return true;
-	}
+    if(ret == 0)
+    {
+        //ret为0表示没有出错
+        return true;
+    }
 
-	return false;
+    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 timestamp = to_string(time(NULL));
+    std::string nonce = "123456";
 
-	std::string lwm_appid = "84b19199fd221a78c491cd553cbb4ab7";
-	std::string open_secret = "#repast!@#AfAS#@!";
+    std::string lwm_appid = "84b19199fd221a78c491cd553cbb4ab7";
+    std::string open_secret = "#repast!@#AfAS#@!";
 
-	//先添加默认参数,用于计算签名
-	params["machinecode"] = m_client.m_machinecode;
-	params["username"] = CLewaimaiString::UrlEncode(m_client.m_username);
-	params["password"] = md5(m_client.m_password);
-	params["lwm_appid"] = "84b19199fd221a78c491cd553cbb4ab7";
-	params["nonce"] = nonce;
-	params["timestamp"] = timestamp;
+    //先添加默认参数,用于计算签名
+    params["machinecode"] = m_client.m_machinecode;
+    params["username"] = CLewaimaiString::UrlEncode(m_client.m_username);
+    params["password"] = md5(m_client.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(); )
-	{
-		postString += it->first + "=" + it->second;
+    //计算签名
+    std::string postString;
+    for(std::map<string, string>::iterator it = params.begin(); it != params.end();)
+    {
+        postString += it->first + "=" + it->second;
 
-		it++;
+        it++;
 
-		if (it != params.end())
-		{
-			postString += "&";
-		}
-	}
+        if(it != params.end())
+        {
+            postString += "&";
+        }
+    }
 
-	LOG_INFO("postString:" << postString.c_str());
+    LOG_INFO("postString:" << postString.c_str());
 
-	//用于计算签名的临时变量
-	string tmp = md5(postString);
-	tmp += open_secret;
+    //用于计算签名的临时变量
+    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());
+    std::string sign = md5(tmp);
+    transform(sign.begin(), sign.end(), sign.begin(), ::toupper);
+    LOG_INFO("sign:" << sign.c_str());
 
-	//加上签名,去掉url,计算post
-	params["sign"] = sign;
+    //加上签名,去掉url,计算post
+    params["sign"] = sign;
 
-	postString = "";
-	for (std::map<string, string>::iterator it = params.begin(); it != params.end(); )
-	{
-		postString += it->first + "=" + it->second;
+    postString = "";
+    for(std::map<string, string>::iterator it = params.begin(); it != params.end();)
+    {
+        postString += it->first + "=" + it->second;
 
-		it++;
+        it++;
 
-		if (it != params.end())
-		{
-			postString += "&";
-		}
-	}
+        if(it != params.end())
+        {
+            postString += "&";
+        }
+    }
 
-	LOG_INFO("postString:" << postString.c_str());
+    LOG_INFO("postString:" << postString.c_str());
 
-	CHttpClient m_httpClient;
-	int ret = m_httpClient.Posts(m_client.m_new_url + url, postString, response, NULL);
+    CHttpClient m_httpClient;
+    int ret = m_httpClient.Posts(m_client.m_new_url + url, postString, response, NULL);
 
-	LOG_INFO("response:" << response.c_str());
+    LOG_INFO("response:" << response.c_str());
 
-	if (ret == 0)
-	{
-		//ret为0表示没有出错
-		return true;
-	}
+    if(ret == 0)
+    {
+        //ret为0表示没有出错
+        return true;
+    }
 
-	return false;
+    return false;
 }

+ 12 - 12
zhipuzi_pos_windows/network/CZhipuziHttpClient.h

@@ -5,26 +5,26 @@
 class CZhipuziHttpClient
 {
 public:
-	CZhipuziHttpClient();
-	~CZhipuziHttpClient();
+    CZhipuziHttpClient();
+    ~CZhipuziHttpClient();
 
 public:
-	static void Init(std::string username, std::string password);
+    static void Init(std::string username, std::string password);
 
-	static bool Login(std::string& errmsg);
+    static bool Login(std::string& errmsg);
 
-	static bool RequestOld(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 RequestOld(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);
 
 public:
-	static CZhipuziHttpClient m_client;
+    static CZhipuziHttpClient m_client;
 
 private:
-	std::string m_username;
-	std::string m_password;
-	std::string m_machinecode = "e6bc5694877b2aec";
+    std::string m_username;
+    std::string m_password;
+    std::string m_machinecode = "e6bc5694877b2aec";
 
-	std::string m_old_url = "https://cyapi.zhipuzi.com/pos";
-	std::string m_new_url = "https://pf-api.zhipuzi.com/pos";
+    std::string m_old_url = "https://cyapi.zhipuzi.com/pos";
+    std::string m_new_url = "https://pf-api.zhipuzi.com/pos";
 };
 

+ 358 - 358
zhipuzi_pos_windows/order/CWaimaiOrder.cpp

@@ -13,382 +13,382 @@ CWaimaiOrder::~CWaimaiOrder()
 //通过订单ID,获取订单详情
 bool CWaimaiOrder::InitData(std::string order_id, std::string order_no)
 {
-	std::map<string, string> params;
-	params["id"] = order_id;
-	params["order_no"] = order_no;
-
-	std::string response;
-	bool ret = CZhipuziHttpClient::RequestOld("/waimaiorder/getorderdetail", params, response);
-	if (!ret)
-	{
-		LOG_INFO("网络请求出错");
-		return false;
-	}
-
-	rapidjson::Document document;
-	document.Parse(response.c_str());
-
-	if (document.HasParseError())
-	{
-		LOG_INFO("parse response error!");
-		return false;
-	}
-	else
-	{
-		if (!document.HasMember("errcode") || !document.HasMember("errmsg") || !document.HasMember("data"))
-		{
-			LOG_INFO("json error!");
-			return false;
-		}
-
-		rapidjson::Value& v_errcode = document["errcode"];
-		int errcode = v_errcode.GetInt();
-		if (errcode != 0)
-		{
-			LOG_INFO("response failed! message:" << document["errmsg"].GetString());
-			return false;
-		}
-		{
-			//获得数据成功
-			rapidjson::Value& data = document["data"];
-
-			m_order_id = data["id"].GetString();
-			m_shop_id = data["shop_id"].GetString();
-			m_restaurant_number = data["restaurant_number"].GetString();
-			m_customer_id = data["customer_id"].GetString();
-			m_customer_name = data["customer_name"].GetString();
-			m_phone = data["phone"].GetString();
-			m_address = data["address"].GetString();
-			m_memo = data["memo"].GetString();
-			m_pay_type = data["pay_type"].GetString();
-			m_promotion = data["promotion"].GetString();
-			m_is_member_discount = data["is_member_discount"].GetString();
-			m_member_discount = data["member_discount"].GetString();
-			m_discount = data["discount"].GetFloat();
-			m_coupon = data["coupon"].GetFloat();
-			m_delivery = data["delivery"].GetFloat();
-			m_price = data["price"].GetFloat();
-			m_order_date = data["order_date"].GetString();
-			m_order_fields = data["order_fields"].GetString();
-			m_order_status = data["order_status"].GetString();
-			m_courier_id = data["courier_id"].GetString();
-			m_is_selftake = data["is_selftake"].GetString();
-			//m_addservice_text = data["addservice_text"].GetString();
-			m_is_dabao = data["is_dabao"].GetString();
-			m_dabao_money = data["dabao_money"].GetString();
-			m_phone_customer_id = data["phone_customer_id"].GetString();
-			m_order_num = data["order_num"].GetString();
-			m_from_type = data["from_type"].GetString();
-			m_is_refund = data["is_refund"].GetString();
-			m_refund_status = data["refund_status"].GetString();
-			m_is_pickup = data["is_pickup"].GetString();
-			m_pickup_time = data["pickup_time"].GetString();
-			m_verify_time = data["verify_time"].GetString();
-			m_verify_user = data["verify_user"].GetString();
-			m_refund_failed_reason = data["refund_failed_reason"].GetString();
-			m_refund_time = data["refund_time"].GetString();
-			m_failed_reason = data["failed_reason"].GetString();
-			m_configmemo = data["configmemo"].GetString();
-			m_courier_type = data["courier_type"].GetString();
-			m_courier_name = data["courier_name"].GetString();
-			m_courier_phone = data["courier_phone"].GetString();
-			m_receiver_lng = data["receiver_lng"].GetString();
-			m_receiver_lat = data["receiver_lat"].GetString();
-			m_reduction_value = data["reduction_value"].GetString();
-			m_price_moling = data["price_moling"].GetString();
-			m_price_plus = data["price_plus"].GetString();
-			m_discount_price = data["discount_price"].GetString();
-			m_order_no = data["order_no"].GetString();
-			m_is_firstcut = data["is_firstcut"].GetString();
-			m_firstcut_value = data["firstcut_value"].GetString();
-			m_goods_coupon_value = data["goods_coupon_value"].GetString();
-			m_take_food_code = data["take_food_code"].GetString();
-			m_need_to_refund = data["need_to_refund"].GetString();
-
-			m_is_nowprinter = data["is_nowprinter"].GetInt();
-
-			m_shop_name = data["shop_name"].GetString();
-			m_longitude = data["longitude"].GetString();
-			m_latitude = data["latitude"].GetString();
-			m_open_selftake = data["open_selftake"].GetString();
-			m_invitetimetimerange = data["invitetimetimerange"].GetString();
-			m_machine_qrcode_open = data["machine_qrcode_open"].GetString();
-			m_machine_qrcode_url = data["machine_qrcode_url"].GetString();
-			m_machine_qrcode_title = data["machine_qrcode_title"].GetString();
-			m_delivery_date = data["delivery_date"].GetString();
-			m_head_picture = data["head_picture"].GetString();
-			m_courier = data["courier"].GetString();
-			m_delivertime = data["delivertime"].GetString();
-			m_customer_order_total = data["customer_order_total"].GetString();
-
-			m_invoice = data["invoice"].GetInt();
-
-			m_invoice_type = data["invoice_type"].GetString();
-			m_tax_payer_id = data["tax_payer_id"].GetString();
-
-			//开始保存订单详情
-			rapidjson::Value& v_rows = data["order_item"];
-
-			for (rapidjson::SizeType i = 0; i < v_rows.Size(); ++i)
-			{
-				rapidjson::Value& v_row_i = v_rows[i];
-
-				CWaimaiOrderItem newItem;
-				newItem.m_id = v_row_i["id"].GetString();
-				newItem.m_food_name = v_row_i["food_name"].GetString();
-				newItem.m_item_price = v_row_i["item_price"].GetString();
-				newItem.m_quantity = v_row_i["quantity"].GetString();
-				newItem.m_type_id = v_row_i["type_id"].GetString();
-				newItem.m_foodpackage_id = v_row_i["foodpackage_id"].GetString();
-				newItem.m_is_foodpackage = v_row_i["is_foodpackage"].GetString();
-				newItem.m_food_unit = v_row_i["food_unit"].GetString();
-				newItem.m_order_item_id = v_row_i["order_item_id"].GetString();
-				newItem.m_food_id = v_row_i["food_id"].GetString();
-				newItem.m_barcode = v_row_i["barcode"].GetString();
-
-				m_order_items.push_back(newItem);
-			}
-
-			//开始保存预设选项
-			v_rows = data["order_field"];
-
-			for (rapidjson::SizeType i = 0; i < v_rows.Size(); ++i)
-			{
-				rapidjson::Value& v_row_i = v_rows[i];
-
-				CWaimaiOrderField newItem;
-				newItem.name = v_row_i["name"].GetString();
-				newItem.value = v_row_i["value"].GetString();
-
-				m_order_field.push_back(newItem);
-			}
-
-			//开始保存增值服务费
-			v_rows = data["addservice"];
-
-			for (rapidjson::SizeType i = 0; i < v_rows.Size(); ++i)
-			{
-				rapidjson::Value& v_row_i = v_rows[i];
-
-				CWaimaiOrderField newItem;
-				newItem.name = v_row_i["name"].GetString();
-				newItem.value = v_row_i["value"].GetString();
-
-				m_addservie.push_back(newItem);
-			}
-		}
-	}
-
-	return true;
+    std::map<string, string> params;
+    params["id"] = order_id;
+    params["order_no"] = order_no;
+
+    std::string response;
+    bool ret = CZhipuziHttpClient::RequestOld("/waimaiorder/getorderdetail", params, response);
+    if(!ret)
+    {
+        LOG_INFO("网络请求出错");
+        return false;
+    }
+
+    rapidjson::Document document;
+    document.Parse(response.c_str());
+
+    if(document.HasParseError())
+    {
+        LOG_INFO("parse response error!");
+        return false;
+    }
+    else
+    {
+        if(!document.HasMember("errcode") || !document.HasMember("errmsg") || !document.HasMember("data"))
+        {
+            LOG_INFO("json error!");
+            return false;
+        }
+
+        rapidjson::Value& v_errcode = document["errcode"];
+        int errcode = v_errcode.GetInt();
+        if(errcode != 0)
+        {
+            LOG_INFO("response failed! message:" << document["errmsg"].GetString());
+            return false;
+        }
+        {
+            //获得数据成功
+            rapidjson::Value& data = document["data"];
+
+            m_order_id = data["id"].GetString();
+            m_shop_id = data["shop_id"].GetString();
+            m_restaurant_number = data["restaurant_number"].GetString();
+            m_customer_id = data["customer_id"].GetString();
+            m_customer_name = data["customer_name"].GetString();
+            m_phone = data["phone"].GetString();
+            m_address = data["address"].GetString();
+            m_memo = data["memo"].GetString();
+            m_pay_type = data["pay_type"].GetString();
+            m_promotion = data["promotion"].GetString();
+            m_is_member_discount = data["is_member_discount"].GetString();
+            m_member_discount = data["member_discount"].GetString();
+            m_discount = data["discount"].GetFloat();
+            m_coupon = data["coupon"].GetFloat();
+            m_delivery = data["delivery"].GetFloat();
+            m_price = data["price"].GetFloat();
+            m_order_date = data["order_date"].GetString();
+            m_order_fields = data["order_fields"].GetString();
+            m_order_status = data["order_status"].GetString();
+            m_courier_id = data["courier_id"].GetString();
+            m_is_selftake = data["is_selftake"].GetString();
+            //m_addservice_text = data["addservice_text"].GetString();
+            m_is_dabao = data["is_dabao"].GetString();
+            m_dabao_money = data["dabao_money"].GetString();
+            m_phone_customer_id = data["phone_customer_id"].GetString();
+            m_order_num = data["order_num"].GetString();
+            m_from_type = data["from_type"].GetString();
+            m_is_refund = data["is_refund"].GetString();
+            m_refund_status = data["refund_status"].GetString();
+            m_is_pickup = data["is_pickup"].GetString();
+            m_pickup_time = data["pickup_time"].GetString();
+            m_verify_time = data["verify_time"].GetString();
+            m_verify_user = data["verify_user"].GetString();
+            m_refund_failed_reason = data["refund_failed_reason"].GetString();
+            m_refund_time = data["refund_time"].GetString();
+            m_failed_reason = data["failed_reason"].GetString();
+            m_configmemo = data["configmemo"].GetString();
+            m_courier_type = data["courier_type"].GetString();
+            m_courier_name = data["courier_name"].GetString();
+            m_courier_phone = data["courier_phone"].GetString();
+            m_receiver_lng = data["receiver_lng"].GetString();
+            m_receiver_lat = data["receiver_lat"].GetString();
+            m_reduction_value = data["reduction_value"].GetString();
+            m_price_moling = data["price_moling"].GetString();
+            m_price_plus = data["price_plus"].GetString();
+            m_discount_price = data["discount_price"].GetString();
+            m_order_no = data["order_no"].GetString();
+            m_is_firstcut = data["is_firstcut"].GetString();
+            m_firstcut_value = data["firstcut_value"].GetString();
+            m_goods_coupon_value = data["goods_coupon_value"].GetString();
+            m_take_food_code = data["take_food_code"].GetString();
+            m_need_to_refund = data["need_to_refund"].GetString();
+
+            m_is_nowprinter = data["is_nowprinter"].GetInt();
+
+            m_shop_name = data["shop_name"].GetString();
+            m_longitude = data["longitude"].GetString();
+            m_latitude = data["latitude"].GetString();
+            m_open_selftake = data["open_selftake"].GetString();
+            m_invitetimetimerange = data["invitetimetimerange"].GetString();
+            m_machine_qrcode_open = data["machine_qrcode_open"].GetString();
+            m_machine_qrcode_url = data["machine_qrcode_url"].GetString();
+            m_machine_qrcode_title = data["machine_qrcode_title"].GetString();
+            m_delivery_date = data["delivery_date"].GetString();
+            m_head_picture = data["head_picture"].GetString();
+            m_courier = data["courier"].GetString();
+            m_delivertime = data["delivertime"].GetString();
+            m_customer_order_total = data["customer_order_total"].GetString();
+
+            m_invoice = data["invoice"].GetInt();
+
+            m_invoice_type = data["invoice_type"].GetString();
+            m_tax_payer_id = data["tax_payer_id"].GetString();
+
+            //开始保存订单详情
+            rapidjson::Value& v_rows = data["order_item"];
+
+            for(rapidjson::SizeType i = 0; i < v_rows.Size(); ++i)
+            {
+                rapidjson::Value& v_row_i = v_rows[i];
+
+                CWaimaiOrderItem newItem;
+                newItem.m_id = v_row_i["id"].GetString();
+                newItem.m_food_name = v_row_i["food_name"].GetString();
+                newItem.m_item_price = v_row_i["item_price"].GetString();
+                newItem.m_quantity = v_row_i["quantity"].GetString();
+                newItem.m_type_id = v_row_i["type_id"].GetString();
+                newItem.m_foodpackage_id = v_row_i["foodpackage_id"].GetString();
+                newItem.m_is_foodpackage = v_row_i["is_foodpackage"].GetString();
+                newItem.m_food_unit = v_row_i["food_unit"].GetString();
+                newItem.m_order_item_id = v_row_i["order_item_id"].GetString();
+                newItem.m_food_id = v_row_i["food_id"].GetString();
+                newItem.m_barcode = v_row_i["barcode"].GetString();
+
+                m_order_items.push_back(newItem);
+            }
+
+            //开始保存预设选项
+            v_rows = data["order_field"];
+
+            for(rapidjson::SizeType i = 0; i < v_rows.Size(); ++i)
+            {
+                rapidjson::Value& v_row_i = v_rows[i];
+
+                CWaimaiOrderField newItem;
+                newItem.name = v_row_i["name"].GetString();
+                newItem.value = v_row_i["value"].GetString();
+
+                m_order_field.push_back(newItem);
+            }
+
+            //开始保存增值服务费
+            v_rows = data["addservice"];
+
+            for(rapidjson::SizeType i = 0; i < v_rows.Size(); ++i)
+            {
+                rapidjson::Value& v_row_i = v_rows[i];
+
+                CWaimaiOrderField newItem;
+                newItem.name = v_row_i["name"].GetString();
+                newItem.value = v_row_i["value"].GetString();
+
+                m_addservie.push_back(newItem);
+            }
+        }
+    }
+
+    return true;
 }
 
 bool CWaimaiOrder::ConfirmeOrder(std::string order_id)
 {
-	std::string url = "/waimaiorder/orderconfirm";
-
-	//请求外卖的未处理订单
-	std::map<string, string> params;
-	params["id"] = order_id;
-	std::string response;
-
-	CZhipuziHttpClient::RequestOld(url.c_str(), params, response);
-
-	rapidjson::Document document;
-	document.Parse(response.c_str());
-
-	if (document.HasParseError())
-	{
-		LOG_INFO("parse response error!");
-		return false;
-	}
-
-	if (!document.HasMember("errcode") || !document.HasMember("errmsg") || !document.HasMember("data"))
-	{
-		LOG_INFO("json error!");
-		return false;
-	}
-
-	rapidjson::Value& v_errcode = document["errcode"];
-	int errcode = v_errcode.GetInt();
-	if (errcode != 0)
-	{
-		LOG_INFO("response failed! message:" << document["errmsg"].GetString());
-		return false;
-	}
-
-	//获得数据成功
-	rapidjson::Value& data = document["data"];
-	rapidjson::Value& v_count = data["count"];
-	string count = v_count.GetString();
-
-	return true;
+    std::string url = "/waimaiorder/orderconfirm";
+
+    //请求外卖的未处理订单
+    std::map<string, string> params;
+    params["id"] = order_id;
+    std::string response;
+
+    CZhipuziHttpClient::RequestOld(url.c_str(), params, response);
+
+    rapidjson::Document document;
+    document.Parse(response.c_str());
+
+    if(document.HasParseError())
+    {
+        LOG_INFO("parse response error!");
+        return false;
+    }
+
+    if(!document.HasMember("errcode") || !document.HasMember("errmsg") || !document.HasMember("data"))
+    {
+        LOG_INFO("json error!");
+        return false;
+    }
+
+    rapidjson::Value& v_errcode = document["errcode"];
+    int errcode = v_errcode.GetInt();
+    if(errcode != 0)
+    {
+        LOG_INFO("response failed! message:" << document["errmsg"].GetString());
+        return false;
+    }
+
+    //获得数据成功
+    rapidjson::Value& data = document["data"];
+    rapidjson::Value& v_count = data["count"];
+    string count = v_count.GetString();
+
+    return true;
 }
 
 bool CWaimaiOrder::SuccessOrder(std::string order_id)
 {
-	std::string url = "/waimaiorder/ordersucceeded";
-
-	//请求外卖的未处理订单
-	std::map<string, string> params;
-	params["id"] = order_id;
-	std::string response;
-
-	CZhipuziHttpClient::RequestOld(url.c_str(), params, response);
-
-	rapidjson::Document document;
-	document.Parse(response.c_str());
-
-	if (document.HasParseError())
-	{
-		LOG_INFO("parse response error!");
-		return false;
-	}
-
-	if (!document.HasMember("errcode") || !document.HasMember("errmsg") || !document.HasMember("data"))
-	{
-		LOG_INFO("json error!");
-		return false;
-	}
-
-	rapidjson::Value& v_errcode = document["errcode"];
-	int errcode = v_errcode.GetInt();
-	if (errcode != 0)
-	{
-		LOG_INFO("response failed! message:" << document["errmsg"].GetString());
-		return false;
-	}
-
-	//获得数据成功
-	rapidjson::Value& data = document["data"];
-	rapidjson::Value& v_count = data["count"];
-	string count = v_count.GetString();
-
-	return true;
+    std::string url = "/waimaiorder/ordersucceeded";
+
+    //请求外卖的未处理订单
+    std::map<string, string> params;
+    params["id"] = order_id;
+    std::string response;
+
+    CZhipuziHttpClient::RequestOld(url.c_str(), params, response);
+
+    rapidjson::Document document;
+    document.Parse(response.c_str());
+
+    if(document.HasParseError())
+    {
+        LOG_INFO("parse response error!");
+        return false;
+    }
+
+    if(!document.HasMember("errcode") || !document.HasMember("errmsg") || !document.HasMember("data"))
+    {
+        LOG_INFO("json error!");
+        return false;
+    }
+
+    rapidjson::Value& v_errcode = document["errcode"];
+    int errcode = v_errcode.GetInt();
+    if(errcode != 0)
+    {
+        LOG_INFO("response failed! message:" << document["errmsg"].GetString());
+        return false;
+    }
+
+    //获得数据成功
+    rapidjson::Value& data = document["data"];
+    rapidjson::Value& v_count = data["count"];
+    string count = v_count.GetString();
+
+    return true;
 }
 
 bool CWaimaiOrder::FailOrder(std::string order_id, std::string reason)
 {
-	std::string url = "/waimaiorder/orderfail";
-
-	//请求外卖的未处理订单
-	std::map<string, string> params;
-	params["id"] = order_id;
-	params["failed_reason"] = reason;
-	std::string response;
-
-	CZhipuziHttpClient::RequestOld(url.c_str(), params, response);
-
-	rapidjson::Document document;
-	document.Parse(response.c_str());
-
-	if (document.HasParseError())
-	{
-		LOG_INFO("parse response error!");
-		return false;
-	}
-
-	if (!document.HasMember("errcode") || !document.HasMember("errmsg") || !document.HasMember("data"))
-	{
-		LOG_INFO("json error!");
-		return false;
-	}
-
-	rapidjson::Value& v_errcode = document["errcode"];
-	int errcode = v_errcode.GetInt();
-	if (errcode != 0)
-	{
-		LOG_INFO("response failed! message:" << document["errmsg"].GetString());
-		return false;
-	}
-
-	//获得数据成功
-	rapidjson::Value& data = document["data"];
-	rapidjson::Value& v_count = data["count"];
-	string count = v_count.GetString();
-
-	return true;
+    std::string url = "/waimaiorder/orderfail";
+
+    //请求外卖的未处理订单
+    std::map<string, string> params;
+    params["id"] = order_id;
+    params["failed_reason"] = reason;
+    std::string response;
+
+    CZhipuziHttpClient::RequestOld(url.c_str(), params, response);
+
+    rapidjson::Document document;
+    document.Parse(response.c_str());
+
+    if(document.HasParseError())
+    {
+        LOG_INFO("parse response error!");
+        return false;
+    }
+
+    if(!document.HasMember("errcode") || !document.HasMember("errmsg") || !document.HasMember("data"))
+    {
+        LOG_INFO("json error!");
+        return false;
+    }
+
+    rapidjson::Value& v_errcode = document["errcode"];
+    int errcode = v_errcode.GetInt();
+    if(errcode != 0)
+    {
+        LOG_INFO("response failed! message:" << document["errmsg"].GetString());
+        return false;
+    }
+
+    //获得数据成功
+    rapidjson::Value& data = document["data"];
+    rapidjson::Value& v_count = data["count"];
+    string count = v_count.GetString();
+
+    return true;
 }
 
 bool CWaimaiOrder::AgreeRefund(std::string order_id)
 {
-	std::string url = "/waimaiorder/agreerefund";
-
-	//请求外卖的未处理订单
-	std::map<string, string> params;
-	params["order_id"] = order_id;
-	std::string response;
-
-	CZhipuziHttpClient::RequestOld(url.c_str(), params, response);
-
-	rapidjson::Document document;
-	document.Parse(response.c_str());
-
-	if (document.HasParseError())
-	{
-		LOG_INFO("parse response error!");
-		return false;
-	}
-
-	if (!document.HasMember("errcode") || !document.HasMember("errmsg") || !document.HasMember("data"))
-	{
-		LOG_INFO("json error!");
-		return false;
-	}
-
-	rapidjson::Value& v_errcode = document["errcode"];
-	int errcode = v_errcode.GetInt();
-	if (errcode != 0)
-	{
-		LOG_INFO("response failed! message:" << document["errmsg"].GetString());
-		return false;
-	}
-
-	//获得数据成功
-	rapidjson::Value& data = document["data"];
-	rapidjson::Value& v_count = data["count"];
-	string count = v_count.GetString();
-
-	return true;
+    std::string url = "/waimaiorder/agreerefund";
+
+    //请求外卖的未处理订单
+    std::map<string, string> params;
+    params["order_id"] = order_id;
+    std::string response;
+
+    CZhipuziHttpClient::RequestOld(url.c_str(), params, response);
+
+    rapidjson::Document document;
+    document.Parse(response.c_str());
+
+    if(document.HasParseError())
+    {
+        LOG_INFO("parse response error!");
+        return false;
+    }
+
+    if(!document.HasMember("errcode") || !document.HasMember("errmsg") || !document.HasMember("data"))
+    {
+        LOG_INFO("json error!");
+        return false;
+    }
+
+    rapidjson::Value& v_errcode = document["errcode"];
+    int errcode = v_errcode.GetInt();
+    if(errcode != 0)
+    {
+        LOG_INFO("response failed! message:" << document["errmsg"].GetString());
+        return false;
+    }
+
+    //获得数据成功
+    rapidjson::Value& data = document["data"];
+    rapidjson::Value& v_count = data["count"];
+    string count = v_count.GetString();
+
+    return true;
 }
 
 bool CWaimaiOrder::DisagreeRefund(std::string order_id)
 {
-	std::string url = "/waimaiorder/disagreerefund";
-
-	//请求外卖的未处理订单
-	std::map<string, string> params;
-	params["order_id"] = order_id;
-	std::string response;
-
-	CZhipuziHttpClient::RequestOld(url.c_str(), params, response);
-
-	rapidjson::Document document;
-	document.Parse(response.c_str());
-
-	if (document.HasParseError())
-	{
-		LOG_INFO("parse response error!");
-		return false;
-	}
-
-	if (!document.HasMember("errcode") || !document.HasMember("errmsg") || !document.HasMember("data"))
-	{
-		LOG_INFO("json error!");
-		return false;
-	}
-
-	rapidjson::Value& v_errcode = document["errcode"];
-	int errcode = v_errcode.GetInt();
-	if (errcode != 0)
-	{
-		LOG_INFO("response failed! message:" << document["errmsg"].GetString());
-		return false;
-	}
-
-	//获得数据成功
-	rapidjson::Value& data = document["data"];
-	rapidjson::Value& v_count = data["count"];
-	string count = v_count.GetString();
-
-	return true;
+    std::string url = "/waimaiorder/disagreerefund";
+
+    //请求外卖的未处理订单
+    std::map<string, string> params;
+    params["order_id"] = order_id;
+    std::string response;
+
+    CZhipuziHttpClient::RequestOld(url.c_str(), params, response);
+
+    rapidjson::Document document;
+    document.Parse(response.c_str());
+
+    if(document.HasParseError())
+    {
+        LOG_INFO("parse response error!");
+        return false;
+    }
+
+    if(!document.HasMember("errcode") || !document.HasMember("errmsg") || !document.HasMember("data"))
+    {
+        LOG_INFO("json error!");
+        return false;
+    }
+
+    rapidjson::Value& v_errcode = document["errcode"];
+    int errcode = v_errcode.GetInt();
+    if(errcode != 0)
+    {
+        LOG_INFO("response failed! message:" << document["errmsg"].GetString());
+        return false;
+    }
+
+    //获得数据成功
+    rapidjson::Value& data = document["data"];
+    rapidjson::Value& v_count = data["count"];
+    string count = v_count.GetString();
+
+    return true;
 }

+ 100 - 100
zhipuzi_pos_windows/order/CWaimaiOrder.h

@@ -6,120 +6,120 @@
 class CWaimaiOrderItem
 {
 public:
-	std::string m_id;
-	std::string m_food_name;
-	std::string m_item_price;
-	std::string m_quantity;
-	std::string m_type_id;
-	std::string m_foodpackage_id;
-	std::string m_is_foodpackage;
-	std::string m_food_unit;
-	std::string m_order_item_id;
-	std::string m_food_id;
-	std::string m_barcode;
+    std::string m_id;
+    std::string m_food_name;
+    std::string m_item_price;
+    std::string m_quantity;
+    std::string m_type_id;
+    std::string m_foodpackage_id;
+    std::string m_is_foodpackage;
+    std::string m_food_unit;
+    std::string m_order_item_id;
+    std::string m_food_id;
+    std::string m_barcode;
 };
 
 class CWaimaiOrderField
 {
 public:
-	std::string name;
-	std::string value;
+    std::string name;
+    std::string value;
 };
 
 class CWaimaiOrder
 {
 public:
-	CWaimaiOrder();
-	~CWaimaiOrder();
+    CWaimaiOrder();
+    ~CWaimaiOrder();
 
-	bool InitData(std::string order_id, std::string order_no);
+    bool InitData(std::string order_id, std::string order_no);
 
-	bool ConfirmeOrder(std::string order_id);
-	bool SuccessOrder(std::string order_id);
-	bool FailOrder(std::string order_id, std::string reason);
+    bool ConfirmeOrder(std::string order_id);
+    bool SuccessOrder(std::string order_id);
+    bool FailOrder(std::string order_id, std::string reason);
 
-	bool AgreeRefund(std::string order_id);
-	bool DisagreeRefund(std::string order_id);
+    bool AgreeRefund(std::string order_id);
+    bool DisagreeRefund(std::string order_id);
 
 public:
-	std::string m_order_id;
-	std::string m_shop_id;
-	std::string m_restaurant_number;
-	std::string m_customer_id;
-	std::string m_customer_name;
-	std::string m_phone;
-	std::string m_address;
-	std::string m_memo;
-	std::string m_pay_type;
-	std::string m_promotion;
-	std::string m_is_member_discount;
-	std::string m_member_discount;
-
-	double m_discount;
-	double m_coupon;
-	double m_delivery;
-	double m_price;
-
-	std::string m_order_date;
-	std::string m_order_fields;
-	std::string m_order_status;
-	std::string m_courier_id;
-	std::string m_is_selftake;
-	std::string m_addservice_text;
-	std::string m_is_dabao;
-	std::string m_dabao_money;
-	std::string m_phone_customer_id;
-	std::string m_order_num;
-	std::string m_from_type;
-	std::string m_is_refund;
-	std::string m_refund_status;
-	std::string m_is_pickup;
-	std::string m_pickup_time;
-	std::string m_verify_time;
-	std::string m_verify_user;
-	std::string m_refund_failed_reason;
-	std::string m_refund_time;
-	std::string m_failed_reason;
-	std::string m_configmemo;
-	std::string m_courier_type;
-	std::string m_courier_name;
-	std::string m_courier_phone;
-	std::string m_receiver_lng;
-	std::string m_receiver_lat;
-	std::string m_reduction_value;
-	std::string m_price_moling;
-	std::string m_price_plus;
-	std::string m_discount_price;
-	std::string m_order_no;
-	std::string m_is_firstcut;
-	std::string m_firstcut_value;
-	std::string m_goods_coupon_value;
-	std::string m_take_food_code;
-	std::string m_need_to_refund;
-
-	int m_is_nowprinter;
-
-	std::string m_shop_name;
-	std::string m_longitude;
-	std::string m_latitude;
-	std::string m_open_selftake;
-	std::string m_invitetimetimerange;
-	std::string m_machine_qrcode_open;
-	std::string m_machine_qrcode_url;
-	std::string m_machine_qrcode_title;
-	std::string m_delivery_date;
-	std::string m_head_picture;
-	std::string m_courier;
-	std::string m_delivertime;
-	std::string m_customer_order_total;
-
-	int m_invoice;
-
-	std::string m_invoice_type;
-	std::string m_tax_payer_id;
-
-	std::vector<CWaimaiOrderItem> m_order_items;
-	std::vector<CWaimaiOrderField> m_order_field;
-	std::vector<CWaimaiOrderField> m_addservie;
+    std::string m_order_id;
+    std::string m_shop_id;
+    std::string m_restaurant_number;
+    std::string m_customer_id;
+    std::string m_customer_name;
+    std::string m_phone;
+    std::string m_address;
+    std::string m_memo;
+    std::string m_pay_type;
+    std::string m_promotion;
+    std::string m_is_member_discount;
+    std::string m_member_discount;
+
+    double m_discount;
+    double m_coupon;
+    double m_delivery;
+    double m_price;
+
+    std::string m_order_date;
+    std::string m_order_fields;
+    std::string m_order_status;
+    std::string m_courier_id;
+    std::string m_is_selftake;
+    std::string m_addservice_text;
+    std::string m_is_dabao;
+    std::string m_dabao_money;
+    std::string m_phone_customer_id;
+    std::string m_order_num;
+    std::string m_from_type;
+    std::string m_is_refund;
+    std::string m_refund_status;
+    std::string m_is_pickup;
+    std::string m_pickup_time;
+    std::string m_verify_time;
+    std::string m_verify_user;
+    std::string m_refund_failed_reason;
+    std::string m_refund_time;
+    std::string m_failed_reason;
+    std::string m_configmemo;
+    std::string m_courier_type;
+    std::string m_courier_name;
+    std::string m_courier_phone;
+    std::string m_receiver_lng;
+    std::string m_receiver_lat;
+    std::string m_reduction_value;
+    std::string m_price_moling;
+    std::string m_price_plus;
+    std::string m_discount_price;
+    std::string m_order_no;
+    std::string m_is_firstcut;
+    std::string m_firstcut_value;
+    std::string m_goods_coupon_value;
+    std::string m_take_food_code;
+    std::string m_need_to_refund;
+
+    int m_is_nowprinter;
+
+    std::string m_shop_name;
+    std::string m_longitude;
+    std::string m_latitude;
+    std::string m_open_selftake;
+    std::string m_invitetimetimerange;
+    std::string m_machine_qrcode_open;
+    std::string m_machine_qrcode_url;
+    std::string m_machine_qrcode_title;
+    std::string m_delivery_date;
+    std::string m_head_picture;
+    std::string m_courier;
+    std::string m_delivertime;
+    std::string m_customer_order_total;
+
+    int m_invoice;
+
+    std::string m_invoice_type;
+    std::string m_tax_payer_id;
+
+    std::vector<CWaimaiOrderItem> m_order_items;
+    std::vector<CWaimaiOrderField> m_order_field;
+    std::vector<CWaimaiOrderField> m_addservie;
 };
 

+ 66 - 66
zhipuzi_pos_windows/tool/CPosPrinter.cpp

@@ -165,7 +165,7 @@ bool CPosPrinter::InitShouyin()
             {
                 LOG_INFO("set baudRate failed!");
 
-				CloseHandle(hPort);
+                CloseHandle(hPort);
                 continue;
             }
 
@@ -178,8 +178,8 @@ bool CPosPrinter::InitShouyin()
             tmouts.WriteTotalTimeoutMultiplier = 100;
             SetCommTimeouts(hPort, &tmouts);
 
-			//设置端口缓冲
-			SetupComm(hPort, 1024, 1024);
+            //设置端口缓冲
+            SetupComm(hPort, 1024, 1024);
 
             //清除通讯端口缓存
             PurgeComm(hPort, PURGE_TXCLEAR | PURGE_RXCLEAR | PURGE_TXABORT | PURGE_RXABORT);
@@ -689,18 +689,18 @@ void CPosPrinter::PrintWaimaiOrderShouyin(CWaimaiOrder& order)
 
         POS_FeedLine();
 
-		//走纸几行再切
-		POS_FeedLine();
-		POS_FeedLine();
-		POS_FeedLine();
-		POS_FeedLine();
-		POS_FeedLine();
+        //走纸几行再切
+        POS_FeedLine();
+        POS_FeedLine();
+        POS_FeedLine();
+        POS_FeedLine();
+        POS_FeedLine();
 
         POS_CutPaper();
     }
 
-	//还原打印机初始设置,有些傻逼收银设备居然不是自动调用,比如哗啦啦
-	POS_Reset();
+    //还原打印机初始设置,有些傻逼收银设备居然不是自动调用,比如哗啦啦
+    POS_Reset();
 
     //关闭设备
     for(std::vector<PrinterHandle>::iterator it = m_hPorts.begin(); it != m_hPorts.end(); it++)
@@ -778,21 +778,21 @@ void CPosPrinter::PrintWaimaiOrderChufang(CWaimaiOrder& order)
 
             POS_FeedLine();
 
-			string order_type = "#" + order.m_restaurant_number + "  ";
-			if (order.m_is_selftake == "1")
-			{
-				POS_TextOut(order_type + "到店自取订单", false, false, 1);
-				POS_FeedLine();
+            string order_type = "#" + order.m_restaurant_number + "  ";
+            if(order.m_is_selftake == "1")
+            {
+                POS_TextOut(order_type + "到店自取订单", false, false, 1);
+                POS_FeedLine();
 
-				POS_FeedLine();
-			}
-			else
-			{
-				POS_TextOut(order_type + "外卖订单", false, false, 1);
-				POS_FeedLine();
+                POS_FeedLine();
+            }
+            else
+            {
+                POS_TextOut(order_type + "外卖订单", false, false, 1);
+                POS_FeedLine();
 
-				POS_FeedLine();
-			}
+                POS_FeedLine();
+            }
 
             //预设选项
             if(order.m_order_field.size() > 1)
@@ -894,15 +894,15 @@ void CPosPrinter::PrintWaimaiOrderChufang(CWaimaiOrder& order)
             POS_FeedLine();
 
             POS_FeedLine();
-			POS_FeedLine();
-			POS_FeedLine();
-			POS_FeedLine();
-			POS_FeedLine();
+            POS_FeedLine();
+            POS_FeedLine();
+            POS_FeedLine();
+            POS_FeedLine();
 
             POS_CutPaper();
 
-			//还原打印机初始设置,有些傻逼收银设备居然不是自动调用,比如哗啦啦
-			POS_Reset();
+            //还原打印机初始设置,有些傻逼收银设备居然不是自动调用,比如哗啦啦
+            POS_Reset();
         }
         else
         {
@@ -916,21 +916,21 @@ void CPosPrinter::PrintWaimaiOrderChufang(CWaimaiOrder& order)
 
                 POS_FeedLine();
 
-				string order_type = "#" + order.m_restaurant_number + "  ";
-				if (order.m_is_selftake == "1")
-				{
-					POS_TextOut(order_type + "到店自取订单", false, false, 1);
-					POS_FeedLine();
+                string order_type = "#" + order.m_restaurant_number + "  ";
+                if(order.m_is_selftake == "1")
+                {
+                    POS_TextOut(order_type + "到店自取订单", false, false, 1);
+                    POS_FeedLine();
 
-					POS_FeedLine();
-				}
-				else
-				{
-					POS_TextOut(order_type + "外卖订单", false, false, 1);
-					POS_FeedLine();
+                    POS_FeedLine();
+                }
+                else
+                {
+                    POS_TextOut(order_type + "外卖订单", false, false, 1);
+                    POS_FeedLine();
 
-					POS_FeedLine();
-				}
+                    POS_FeedLine();
+                }
 
                 //预设选项
                 if(order.m_order_field.size() > 1)
@@ -1012,20 +1012,20 @@ void CPosPrinter::PrintWaimaiOrderChufang(CWaimaiOrder& order)
                 }
 
                 //结束商品详情打印
-                POS_TextOut(lines);                
-				POS_FeedLine();
+                POS_TextOut(lines);
+                POS_FeedLine();
 
-				POS_FeedLine();
-				POS_FeedLine();
-				POS_FeedLine();
-				POS_FeedLine();
-				POS_FeedLine();
+                POS_FeedLine();
+                POS_FeedLine();
+                POS_FeedLine();
+                POS_FeedLine();
+                POS_FeedLine();
 
                 POS_CutPaper();
             }
 
-			//还原打印机初始设置,有些傻逼收银设备居然不是自动调用,比如哗啦啦
-			POS_Reset();
+            //还原打印机初始设置,有些傻逼收银设备居然不是自动调用,比如哗啦啦
+            POS_Reset();
         }
 
         m_socket.close();
@@ -1297,13 +1297,13 @@ void CPosPrinter::CalWord(string s, int& nHanzi, int& nZimu)
         {
             //汉字
             buffer++;
-			buffer++;
+            buffer++;
             nHanzi++;
         }
         else
         {
             //字母
-			buffer++;
+            buffer++;
             nZimu++;
         }
     }
@@ -1320,7 +1320,7 @@ std::vector<std::string>CPosPrinter::HandleFoodname(std::string oldname, int gui
     int nWidth = nHanzi * 2 + nZimu;
     int maxWidth;
 
-	if(guige == 1)
+    if(guige == 1)
     {
         maxWidth = 15;
     }
@@ -1351,21 +1351,21 @@ std::vector<std::string>CPosPrinter::HandleFoodname(std::string oldname, int gui
         if(!(*s >= 0 && *s <= 127))
         {
             //汉字的情况
-			s++;
-			nTmp++;
-			nTotal++;
+            s++;
+            nTmp++;
+            nTotal++;
 
-			s++;
+            s++;
+            nTmp++;
+            nTotal++;
+        }
+        else
+        {
+            //字母的情况
+            s++;
             nTmp++;
             nTotal++;
         }
-		else
-		{
-			//字母的情况
-			s++;
-			nTmp++;
-			nTotal++;
-		}
 
         if(nTmp == maxWidth)
         {

+ 32 - 32
zhipuzi_pos_windows/tool/CPosPrinter.h

@@ -17,8 +17,8 @@ const GUID USB_GUID = {0x28d78fad, 0x5a12, 0x11d1, {0xae, 0x5b, 0x00, 0x00, 0xf8
 class PrinterHandle
 {
 public:
-	HANDLE hPort;
-	int type; //句柄类型 1:usb 2:并口 3:串口
+    HANDLE hPort;
+    int type; //句柄类型 1:usb 2:并口 3:串口
 };
 
 class CPosPrinter
@@ -28,48 +28,48 @@ public:
     ~CPosPrinter();
 
     void PrintWaimaiOrderShouyin(CWaimaiOrder& order);
-	void PrintWaimaiOrderChufang(CWaimaiOrder& order);
+    void PrintWaimaiOrderChufang(CWaimaiOrder& order);
 
 private:
-	bool InitShouyin();
-	int GetDevicePath(LPGUID lpGuid, LPTSTR* pszDevicePath);
+    bool InitShouyin();
+    int GetDevicePath(LPGUID lpGuid, LPTSTR* pszDevicePath);
 
-	int WriteData(string meg);
-	int WriteBuf(const char* buf, int len);
+    int WriteData(string meg);
+    int WriteBuf(const char* buf, int len);
 
-	bool PortTest(HANDLE hPort);
+    bool PortTest(HANDLE hPort);
 
-	int POS_Reset(void);
-	int POS_FeedLine(void);
-	int POS_Feed(void);
-	int POS_SetMotionUnit(int x, int y);
+    int POS_Reset(void);
+    int POS_FeedLine(void);
+    int POS_Feed(void);
+    int POS_SetMotionUnit(int x, int y);
 
-	//设置横向跳格位置
-	int POS_SET_MOVE_X();
-	int POS_MOVE_X();
-	int POS_SET_ABS_X(int x, int y);
-	int POS_SET_PRINT_AREA(int x, int y);
+    //设置横向跳格位置
+    int POS_SET_MOVE_X();
+    int POS_MOVE_X();
+    int POS_SET_ABS_X(int x, int y);
+    int POS_SET_PRINT_AREA(int x, int y);
 
-	int POS_TextOut(string abc, bool is_double_width = false, bool is_double_height = false, int align_type = 0);
+    int POS_TextOut(string abc, bool is_double_width = false, bool is_double_height = false, int align_type = 0);
 
-	int POS_CutPaper();
-	int POS_OutQRCode();
+    int POS_CutPaper();
+    int POS_OutQRCode();
 
-	//字符空格计算的辅助函数
-	void CalWord(string s,  int& nHanzi, int& nZimu);
+    //字符空格计算的辅助函数
+    void CalWord(string s,  int& nHanzi, int& nZimu);
 
-	//对名字进行换行处理
-	std::vector<std::string> HandleFoodname(std::string oldname, int guige = 1);
-	std::string HandleFoodItemPrice(std::string oldprice, int guige = 1);
-	std::string HandleFoodQuantity(std::string oldquantity, int guige = 1);
-	std::string HandleFoodTotalPrice(std::string oldprice, int guige = 1);
+    //对名字进行换行处理
+    std::vector<std::string> HandleFoodname(std::string oldname, int guige = 1);
+    std::string HandleFoodItemPrice(std::string oldprice, int guige = 1);
+    std::string HandleFoodQuantity(std::string oldquantity, int guige = 1);
+    std::string HandleFoodTotalPrice(std::string oldprice, int guige = 1);
 
 private:
-	std::vector<PrinterHandle> m_hPorts;
+    std::vector<PrinterHandle> m_hPorts;
 
-	boost::asio::io_service m_io;
-	boost::asio::ip::tcp::socket m_socket;
+    boost::asio::io_service m_io;
+    boost::asio::ip::tcp::socket m_socket;
 
-	//这个是当前的输出模式,是收银模式还是厨房打印模式
-	int m_type;
+    //这个是当前的输出模式,是收银模式还是厨房打印模式
+    int m_type;
 };

+ 221 - 221
zhipuzi_pos_windows/tool/CSetting.cpp

@@ -23,70 +23,70 @@ CSetting::~CSetting()
 
 void CSetting::SetParam(std::string name, std::string value, bool isSave)
 {
-	m_mutex.lock();
+    m_mutex.lock();
 
-	m_paramsMap[name] = value;
+    m_paramsMap[name] = value;
 
-	m_mutex.unlock();
+    m_mutex.unlock();
 
-	if (isSave)
-	{
-		SaveParams();
-	}
+    if(isSave)
+    {
+        SaveParams();
+    }
 }
 
 std::string CSetting::GetParam(std::string name)
 {
-	m_mutex.lock();
+    m_mutex.lock();
 
-	std::string value = m_paramsMap[name];
+    std::string value = m_paramsMap[name];
 
-	m_mutex.unlock();
+    m_mutex.unlock();
 
-	return value;
+    return value;
 }
 
 void CSetting::AddChufangPrinter(std::string date, std::string name, std::string ip, std::string guige, std::string fendan, std::string fenlei, std::string fenlei_ids, bool isSave)
 {
-	ChufangPrinter newPrinter;
-
-	newPrinter.date = date;
-	newPrinter.name = name;
-	newPrinter.ip = ip;
-	newPrinter.guige = guige;
-	newPrinter.fendan = fendan;
-	newPrinter.fenlei = fenlei;
-	newPrinter.fenlei_ids = fenlei_ids;
-
-	m_chufang_printers.push_back(newPrinter);
-
-	if (isSave)
-	{
-		SaveChufangPrinter();
-	}
+    ChufangPrinter newPrinter;
+
+    newPrinter.date = date;
+    newPrinter.name = name;
+    newPrinter.ip = ip;
+    newPrinter.guige = guige;
+    newPrinter.fendan = fendan;
+    newPrinter.fenlei = fenlei;
+    newPrinter.fenlei_ids = fenlei_ids;
+
+    m_chufang_printers.push_back(newPrinter);
+
+    if(isSave)
+    {
+        SaveChufangPrinter();
+    }
 }
 
 void CSetting::UpdateChufangPrinter(std::string date, std::string name, std::string ip, std::string guige, std::string fendan, std::string fenlei, std::string fenlei_ids, bool isSave)
 {
-	for (std::vector<ChufangPrinter>::iterator it = m_chufang_printers.begin(); it != m_chufang_printers.end(); it++)
-	{
-		if ((*it).date == date)
-		{
-			(*it).name = name;
-			(*it).ip = ip;
-			(*it).guige = guige;
-			(*it).fendan = fendan;
-			(*it).fenlei = fenlei;
-			(*it).fenlei_ids = fenlei_ids;
-
-			break;
-		}
-	}
-
-	if (isSave)
-	{
-		SaveChufangPrinter();
-	}
+    for(std::vector<ChufangPrinter>::iterator it = m_chufang_printers.begin(); it != m_chufang_printers.end(); it++)
+    {
+        if((*it).date == date)
+        {
+            (*it).name = name;
+            (*it).ip = ip;
+            (*it).guige = guige;
+            (*it).fendan = fendan;
+            (*it).fenlei = fenlei;
+            (*it).fenlei_ids = fenlei_ids;
+
+            break;
+        }
+    }
+
+    if(isSave)
+    {
+        SaveChufangPrinter();
+    }
 }
 
 /*
@@ -94,201 +94,201 @@ void CSetting::UpdateChufangPrinter(std::string date, std::string name, std::str
  **/
 void CSetting::DelChufangPrinter(std::string date)
 {
-	for (std::vector<ChufangPrinter>::iterator it = m_chufang_printers.begin(); it != m_chufang_printers.end(); it++)
-	{
-		if ((*it).date == date)
-		{
-			m_chufang_printers.erase(it);
+    for(std::vector<ChufangPrinter>::iterator it = m_chufang_printers.begin(); it != m_chufang_printers.end(); it++)
+    {
+        if((*it).date == date)
+        {
+            m_chufang_printers.erase(it);
 
-			break;
-		}
-	}
+            break;
+        }
+    }
 
-	SaveChufangPrinter();
+    SaveChufangPrinter();
 }
 
 ChufangPrinter CSetting::GetChufangPrinter(std::string date)
 {
-	for (std::vector<ChufangPrinter>::iterator it = m_chufang_printers.begin(); it != m_chufang_printers.end(); it++)
-	{
-		if ((*it).date == date)
-		{
-			return (*it);
-		}
-	}
-
-	return ChufangPrinter();
+    for(std::vector<ChufangPrinter>::iterator it = m_chufang_printers.begin(); it != m_chufang_printers.end(); it++)
+    {
+        if((*it).date == date)
+        {
+            return (*it);
+        }
+    }
+
+    return ChufangPrinter();
 }
 
 void CSetting::Init()
 {
-	//先读取数据库的数据
-	CSqlite3 sqllite;
-	sqllite.InitConfig();
-
-	//再对数据进行初始化,如果没有记录的就加上默认设置
-	m_mutex.lock();
-
-	//外卖设置参数
-	std::string setting_is_new_waimai_voice = "setting_is_new_waimai_voice";
-	if (m_paramsMap.find(setting_is_new_waimai_voice) == m_paramsMap.end())
-	{
-		m_paramsMap[setting_is_new_waimai_voice] = "1";
-	}
-
-	std::string setting_is_new_waimai_autoconfirm = "setting_is_new_waimai_autoconfirm";
-	if (m_paramsMap.find(setting_is_new_waimai_autoconfirm) == m_paramsMap.end())
-	{
-		m_paramsMap[setting_is_new_waimai_autoconfirm] = "1";
-	}
-
-	std::string setting_is_new_waimai_dialog = "setting_is_new_waimai_dialog";
-	if (m_paramsMap.find(setting_is_new_waimai_dialog) == m_paramsMap.end())
-	{
-		m_paramsMap[setting_is_new_waimai_dialog] = "1";
-	}
-
-	//新订单打印设置参数
-	std::string setting_is_new_waimai_printer = "setting_is_new_waimai_printer";
-	if (m_paramsMap.find(setting_is_new_waimai_printer) == m_paramsMap.end())
-	{
-		m_paramsMap[setting_is_new_waimai_printer] = "1";
-	}
-
-	std::string setting_printer_guige = "setting_printer_guige";
-	if (m_paramsMap.find(setting_printer_guige) == m_paramsMap.end())
-	{
-		m_paramsMap[setting_printer_guige] = "58";
-	}
-
-	std::string setting_printer_lianshu = "setting_printer_lianshu";
-	if (m_paramsMap.find(setting_printer_lianshu) == m_paramsMap.end())
-	{
-		m_paramsMap[setting_printer_lianshu] = "1";
-	}
-
-	std::string setting_printer_quhuo_big = "setting_printer_quhuo_big";
-	if (m_paramsMap.find(setting_printer_quhuo_big) == m_paramsMap.end())
-	{
-		m_paramsMap[setting_printer_quhuo_big] = "0";
-	}
-
-	std::string setting_printer_dingdanhao_big = "setting_printer_dingdanhao_big";
-	if (m_paramsMap.find(setting_printer_dingdanhao_big) == m_paramsMap.end())
-	{
-		m_paramsMap[setting_printer_dingdanhao_big] = "0";
-	}
-
-	std::string setting_printer_xiadanshijian_big = "setting_printer_xiadanshijian_big";
-	if (m_paramsMap.find(setting_printer_xiadanshijian_big) == m_paramsMap.end())
-	{
-		m_paramsMap[setting_printer_xiadanshijian_big] = "0";
-	}
-
-	std::string setting_printer_peisongshijian_big = "setting_printer_peisongshijian_big";
-	if (m_paramsMap.find(setting_printer_peisongshijian_big) == m_paramsMap.end())
-	{
-		m_paramsMap[setting_printer_peisongshijian_big] = "0";
-	}
-
-	std::string setting_printer_name_big = "setting_printer_name_big";
-	if (m_paramsMap.find(setting_printer_name_big) == m_paramsMap.end())
-	{
-		m_paramsMap[setting_printer_name_big] = "0";
-	}
-
-	std::string setting_printer_phone_big = "setting_printer_phone_big";
-	if (m_paramsMap.find(setting_printer_phone_big) == m_paramsMap.end())
-	{
-		m_paramsMap[setting_printer_phone_big] = "0";
-	}
-
-	std::string setting_printer_address_big = "setting_printer_address_big";
-	if (m_paramsMap.find(setting_printer_address_big) == m_paramsMap.end())
-	{
-		m_paramsMap[setting_printer_address_big] = "0";
-	}
-
-	std::string setting_printer_shangpin_big = "setting_printer_shangpin_big";
-	if (m_paramsMap.find(setting_printer_shangpin_big) == m_paramsMap.end())
-	{
-		m_paramsMap[setting_printer_shangpin_big] = "0";
-	}
-
-	std::string setting_printer_memo_big = "setting_printer_memo_big";
-	if (m_paramsMap.find(setting_printer_memo_big) == m_paramsMap.end())
-	{
-		m_paramsMap[setting_printer_memo_big] = "0";
-	}
-
-	std::string setting_printer_price_big = "setting_printer_price_big";
-	if (m_paramsMap.find(setting_printer_price_big) == m_paramsMap.end())
-	{
-		m_paramsMap[setting_printer_price_big] = "0";
-	}
-
-	std::string setting_printer_pay_big = "setting_printer_pay_big";
-	if (m_paramsMap.find(setting_printer_pay_big) == m_paramsMap.end())
-	{
-		m_paramsMap[setting_printer_pay_big] = "0";
-	}
-
-	//厨房打印的默认参数
-	std::string setting_is_new_waimai_chufang_printer = "setting_is_new_waimai_chufang_printer";
-	if (m_paramsMap.find(setting_is_new_waimai_chufang_printer) == m_paramsMap.end())
-	{
-		m_paramsMap[setting_is_new_waimai_chufang_printer] = "1";
-	}
-
-	//系统设置的参数
-	std::string setting_is_auto_start = "setting_is_auto_start";
-	if (CSystem::IsAutoStart() == true)
-	{
-		m_paramsMap[setting_is_auto_start] = "1";
-	}
-	else
-	{
-		m_paramsMap[setting_is_auto_start] = "0";
-	}
-
-	std::string setting_is_auto_login = "setting_is_auto_login";
-	if (m_paramsMap.find(setting_is_auto_login) == m_paramsMap.end())
-	{
-		m_paramsMap[setting_is_auto_login] = "0";
-	}
-
-	std::string setting_is_remember_password = "setting_is_remember_password";
-	if (m_paramsMap.find(setting_is_remember_password) == m_paramsMap.end())
-	{
-		m_paramsMap[setting_is_remember_password] = "1";
-	}
-
-	std::string setting_is_close_min = "setting_is_close_min";
-	if (m_paramsMap.find(setting_is_close_min) == m_paramsMap.end())
-	{
-		m_paramsMap[setting_is_close_min] = "1";
-	}
-
-	m_mutex.unlock();
-
-	//设置好默认参数之后,将默认参数写回到数据库
-	SaveParams();
+    //先读取数据库的数据
+    CSqlite3 sqllite;
+    sqllite.InitConfig();
+
+    //再对数据进行初始化,如果没有记录的就加上默认设置
+    m_mutex.lock();
+
+    //外卖设置参数
+    std::string setting_is_new_waimai_voice = "setting_is_new_waimai_voice";
+    if(m_paramsMap.find(setting_is_new_waimai_voice) == m_paramsMap.end())
+    {
+        m_paramsMap[setting_is_new_waimai_voice] = "1";
+    }
+
+    std::string setting_is_new_waimai_autoconfirm = "setting_is_new_waimai_autoconfirm";
+    if(m_paramsMap.find(setting_is_new_waimai_autoconfirm) == m_paramsMap.end())
+    {
+        m_paramsMap[setting_is_new_waimai_autoconfirm] = "1";
+    }
+
+    std::string setting_is_new_waimai_dialog = "setting_is_new_waimai_dialog";
+    if(m_paramsMap.find(setting_is_new_waimai_dialog) == m_paramsMap.end())
+    {
+        m_paramsMap[setting_is_new_waimai_dialog] = "1";
+    }
+
+    //新订单打印设置参数
+    std::string setting_is_new_waimai_printer = "setting_is_new_waimai_printer";
+    if(m_paramsMap.find(setting_is_new_waimai_printer) == m_paramsMap.end())
+    {
+        m_paramsMap[setting_is_new_waimai_printer] = "1";
+    }
+
+    std::string setting_printer_guige = "setting_printer_guige";
+    if(m_paramsMap.find(setting_printer_guige) == m_paramsMap.end())
+    {
+        m_paramsMap[setting_printer_guige] = "58";
+    }
+
+    std::string setting_printer_lianshu = "setting_printer_lianshu";
+    if(m_paramsMap.find(setting_printer_lianshu) == m_paramsMap.end())
+    {
+        m_paramsMap[setting_printer_lianshu] = "1";
+    }
+
+    std::string setting_printer_quhuo_big = "setting_printer_quhuo_big";
+    if(m_paramsMap.find(setting_printer_quhuo_big) == m_paramsMap.end())
+    {
+        m_paramsMap[setting_printer_quhuo_big] = "0";
+    }
+
+    std::string setting_printer_dingdanhao_big = "setting_printer_dingdanhao_big";
+    if(m_paramsMap.find(setting_printer_dingdanhao_big) == m_paramsMap.end())
+    {
+        m_paramsMap[setting_printer_dingdanhao_big] = "0";
+    }
+
+    std::string setting_printer_xiadanshijian_big = "setting_printer_xiadanshijian_big";
+    if(m_paramsMap.find(setting_printer_xiadanshijian_big) == m_paramsMap.end())
+    {
+        m_paramsMap[setting_printer_xiadanshijian_big] = "0";
+    }
+
+    std::string setting_printer_peisongshijian_big = "setting_printer_peisongshijian_big";
+    if(m_paramsMap.find(setting_printer_peisongshijian_big) == m_paramsMap.end())
+    {
+        m_paramsMap[setting_printer_peisongshijian_big] = "0";
+    }
+
+    std::string setting_printer_name_big = "setting_printer_name_big";
+    if(m_paramsMap.find(setting_printer_name_big) == m_paramsMap.end())
+    {
+        m_paramsMap[setting_printer_name_big] = "0";
+    }
+
+    std::string setting_printer_phone_big = "setting_printer_phone_big";
+    if(m_paramsMap.find(setting_printer_phone_big) == m_paramsMap.end())
+    {
+        m_paramsMap[setting_printer_phone_big] = "0";
+    }
+
+    std::string setting_printer_address_big = "setting_printer_address_big";
+    if(m_paramsMap.find(setting_printer_address_big) == m_paramsMap.end())
+    {
+        m_paramsMap[setting_printer_address_big] = "0";
+    }
+
+    std::string setting_printer_shangpin_big = "setting_printer_shangpin_big";
+    if(m_paramsMap.find(setting_printer_shangpin_big) == m_paramsMap.end())
+    {
+        m_paramsMap[setting_printer_shangpin_big] = "0";
+    }
+
+    std::string setting_printer_memo_big = "setting_printer_memo_big";
+    if(m_paramsMap.find(setting_printer_memo_big) == m_paramsMap.end())
+    {
+        m_paramsMap[setting_printer_memo_big] = "0";
+    }
+
+    std::string setting_printer_price_big = "setting_printer_price_big";
+    if(m_paramsMap.find(setting_printer_price_big) == m_paramsMap.end())
+    {
+        m_paramsMap[setting_printer_price_big] = "0";
+    }
+
+    std::string setting_printer_pay_big = "setting_printer_pay_big";
+    if(m_paramsMap.find(setting_printer_pay_big) == m_paramsMap.end())
+    {
+        m_paramsMap[setting_printer_pay_big] = "0";
+    }
+
+    //厨房打印的默认参数
+    std::string setting_is_new_waimai_chufang_printer = "setting_is_new_waimai_chufang_printer";
+    if(m_paramsMap.find(setting_is_new_waimai_chufang_printer) == m_paramsMap.end())
+    {
+        m_paramsMap[setting_is_new_waimai_chufang_printer] = "1";
+    }
+
+    //系统设置的参数
+    std::string setting_is_auto_start = "setting_is_auto_start";
+    if(CSystem::IsAutoStart() == true)
+    {
+        m_paramsMap[setting_is_auto_start] = "1";
+    }
+    else
+    {
+        m_paramsMap[setting_is_auto_start] = "0";
+    }
+
+    std::string setting_is_auto_login = "setting_is_auto_login";
+    if(m_paramsMap.find(setting_is_auto_login) == m_paramsMap.end())
+    {
+        m_paramsMap[setting_is_auto_login] = "0";
+    }
+
+    std::string setting_is_remember_password = "setting_is_remember_password";
+    if(m_paramsMap.find(setting_is_remember_password) == m_paramsMap.end())
+    {
+        m_paramsMap[setting_is_remember_password] = "1";
+    }
+
+    std::string setting_is_close_min = "setting_is_close_min";
+    if(m_paramsMap.find(setting_is_close_min) == m_paramsMap.end())
+    {
+        m_paramsMap[setting_is_close_min] = "1";
+    }
+
+    m_mutex.unlock();
+
+    //设置好默认参数之后,将默认参数写回到数据库
+    SaveParams();
 }
 
 void CSetting::SaveParams()
 {
-	CSqlite3 sqllite;
-	sqllite.SaveParams(m_paramsMap);
+    CSqlite3 sqllite;
+    sqllite.SaveParams(m_paramsMap);
 }
 
 void CSetting::SaveChufangPrinter()
 {
-	CSqlite3 sqllite;
-	sqllite.SaveChufangPrinter(m_chufang_printers);
+    CSqlite3 sqllite;
+    sqllite.SaveChufangPrinter(m_chufang_printers);
 }
 
 void CSetting::SaveUsers()
 {
-	CSqlite3 sqllite;
-	sqllite.SaveUsers(m_users);
+    CSqlite3 sqllite;
+    sqllite.SaveUsers(m_users);
 }

+ 129 - 129
zhipuzi_pos_windows/tool/CSetting.h

@@ -5,151 +5,151 @@
 class ChufangPrinter
 {
 public:
-	std::string date;
-	std::string name;
-	std::string ip;
-	std::string guige;
-	std::string fendan;
-	std::string fenlei;
-	std::string fenlei_ids;
+    std::string date;
+    std::string name;
+    std::string ip;
+    std::string guige;
+    std::string fendan;
+    std::string fenlei;
+    std::string fenlei_ids;
 };
 
 class FoodType
 {
 public:
-	std::string name;
-	std::string type_id;
+    std::string name;
+    std::string type_id;
 };
 
 class CSetting
 {
 public:
-	CSetting();
-	~CSetting();
-
-	//修改内存中的参数设置
-	static void SetParam(std::string name, std::string value, bool isSave = true);
-	static std::string GetParam(std::string name);
-
-	//厨房打印机相关的参数配置
-	static void AddChufangPrinter(std::string date, std::string name, std::string ip, std::string guige, std::string fendan, std::string fenlei, std::string fenlei_ids, bool isSave = true);
-	static void UpdateChufangPrinter(std::string date, std::string name, std::string ip, std::string guige, std::string fendan, std::string fenlei, std::string fenlei_ids, bool isSave = true);
-	static void DelChufangPrinter(std::string date);
-
-	static ChufangPrinter GetChufangPrinter(std::string date);
-
-	static void SetUser(std::string name, std::string password, bool isSave = true)
-	{
-		m_users[name] = password;
-
-		if (isSave)
-		{
-			SaveUsers();
-		}
-	}
-
-	static std::string GetUser(std::string name)
-	{
-		if (m_users.find(name) == m_users.end())
-		{
-			return "";
-		}
-
-		return m_users[name];
-	}
-
-	static std::map<string, string> getUsers()
-	{
-		return m_users;
-	}
-
-	//刚打开程序的时候,根据数据库初始化内存,并且添加默认参数
-	static void Init();
-
-	static std::string getValue(std::string name)
-	{
-		return m_paramsMap[name];
-	}
-
-	static ChufangPrinter getLastChufangPrinter()
-	{
-		return m_chufang_printers.back();
-	}
-
-	static std::vector<ChufangPrinter>& getChufangPrints()
-	{
-		return m_chufang_printers;
-	}
-
-	static void AddFoodtype(std::string name, std::string type_id)
-	{
-		FoodType newFoodType;
-		newFoodType.name = name;
-		newFoodType.type_id = type_id;
-
-		m_foodtypes.push_back(newFoodType);
-
-		m_foodtype_id_name[type_id] = name;
-	}
-
-	static std::vector<FoodType>& GetFoodtype()
-	{
-		return m_foodtypes;
-	}
-
-	static std::string getFoodtypeName(std::string type_id)
-	{
-		if (m_foodtype_id_name.find(type_id) != m_foodtype_id_name.end())
-		{
-			return m_foodtype_id_name[type_id];
-		}
-
-		//返回这个表示没找到这个分类
-		return "zhipuzi_not_found_xxx";
-	}
-
-	static void SetLoginInfo(std::string username, std::string password)
-	{
-		m_username = username;
-		m_password = password;
-	}
-
-	static std::string getUsername()
-	{
-		return m_username;
-	}
-
-	static std::string getPassword()
-	{
-		return m_password;
-	}
-
-	/*
-	 *把内存中的参数,写到数据库中
-	 **/
-	static void SaveParams();
-
-	/*
-	 *把内存中的厨房打印机信息,存到数据库
-	 **/
-	static void SaveChufangPrinter();
-
-	static void SaveUsers();
+    CSetting();
+    ~CSetting();
+
+    //修改内存中的参数设置
+    static void SetParam(std::string name, std::string value, bool isSave = true);
+    static std::string GetParam(std::string name);
+
+    //厨房打印机相关的参数配置
+    static void AddChufangPrinter(std::string date, std::string name, std::string ip, std::string guige, std::string fendan, std::string fenlei, std::string fenlei_ids, bool isSave = true);
+    static void UpdateChufangPrinter(std::string date, std::string name, std::string ip, std::string guige, std::string fendan, std::string fenlei, std::string fenlei_ids, bool isSave = true);
+    static void DelChufangPrinter(std::string date);
+
+    static ChufangPrinter GetChufangPrinter(std::string date);
+
+    static void SetUser(std::string name, std::string password, bool isSave = true)
+    {
+        m_users[name] = password;
+
+        if(isSave)
+        {
+            SaveUsers();
+        }
+    }
+
+    static std::string GetUser(std::string name)
+    {
+        if(m_users.find(name) == m_users.end())
+        {
+            return "";
+        }
+
+        return m_users[name];
+    }
+
+    static std::map<string, string> getUsers()
+    {
+        return m_users;
+    }
+
+    //刚打开程序的时候,根据数据库初始化内存,并且添加默认参数
+    static void Init();
+
+    static std::string getValue(std::string name)
+    {
+        return m_paramsMap[name];
+    }
+
+    static ChufangPrinter getLastChufangPrinter()
+    {
+        return m_chufang_printers.back();
+    }
+
+    static std::vector<ChufangPrinter>& getChufangPrints()
+    {
+        return m_chufang_printers;
+    }
+
+    static void AddFoodtype(std::string name, std::string type_id)
+    {
+        FoodType newFoodType;
+        newFoodType.name = name;
+        newFoodType.type_id = type_id;
+
+        m_foodtypes.push_back(newFoodType);
+
+        m_foodtype_id_name[type_id] = name;
+    }
+
+    static std::vector<FoodType>& GetFoodtype()
+    {
+        return m_foodtypes;
+    }
+
+    static std::string getFoodtypeName(std::string type_id)
+    {
+        if(m_foodtype_id_name.find(type_id) != m_foodtype_id_name.end())
+        {
+            return m_foodtype_id_name[type_id];
+        }
+
+        //返回这个表示没找到这个分类
+        return "zhipuzi_not_found_xxx";
+    }
+
+    static void SetLoginInfo(std::string username, std::string password)
+    {
+        m_username = username;
+        m_password = password;
+    }
+
+    static std::string getUsername()
+    {
+        return m_username;
+    }
+
+    static std::string getPassword()
+    {
+        return m_password;
+    }
+
+    /*
+     *把内存中的参数,写到数据库中
+     **/
+    static void SaveParams();
+
+    /*
+     *把内存中的厨房打印机信息,存到数据库
+     **/
+    static void SaveChufangPrinter();
+
+    static void SaveUsers();
 
 private:
-	static std::map<std::string, std::string> m_paramsMap;
-	static std::vector<ChufangPrinter> m_chufang_printers;
+    static std::map<std::string, std::string> m_paramsMap;
+    static std::vector<ChufangPrinter> m_chufang_printers;
 
-	static std::mutex m_mutex;
+    static std::mutex m_mutex;
 
-	static std::vector<FoodType> m_foodtypes;
+    static std::vector<FoodType> m_foodtypes;
 
-	//从商品分类的id到name的映射
-	static std::map<std::string, std::string> m_foodtype_id_name;
+    //从商品分类的id到name的映射
+    static std::map<std::string, std::string> m_foodtype_id_name;
 
-	static std::map<string, string> m_users;
+    static std::map<string, string> m_users;
 
-	static std::string m_username;
-	static std::string m_password;
+    static std::string m_username;
+    static std::string m_password;
 };
 

+ 16 - 16
zhipuzi_pos_windows/tool/CSqlite3.cpp

@@ -5,18 +5,18 @@
 
 CSqlite3::CSqlite3()
 {
-	wstring folderPath = CSystem::GetProgramDir() + L"\\db";
-	if (!CSystem::IsDirExist(folderPath))
-	{
-		LOG_INFO("folderPath:" << folderPath.c_str() << ",没有找到对应的目录,即将创建");
-		bool flag = CreateDirectory(folderPath.c_str(), NULL);
-		if (flag == false)
-		{
-			LOG_INFO("新建 db 目录失败!");
-		}
-
-		LOG_INFO("新建 db 目录成功!");
-	}
+    wstring folderPath = CSystem::GetProgramDir() + L"\\db";
+    if(!CSystem::IsDirExist(folderPath))
+    {
+        LOG_INFO("folderPath:" << folderPath.c_str() << ",没有找到对应的目录,即将创建");
+        bool flag = CreateDirectory(folderPath.c_str(), NULL);
+        if(flag == false)
+        {
+            LOG_INFO("新建 db 目录失败!");
+        }
+
+        LOG_INFO("新建 db 目录成功!");
+    }
 
     //如果没有这个文件,这里会创建这个文件
     wstring path = CSystem::GetProgramDir() + L"\\db\\pos.db";
@@ -48,7 +48,7 @@ bool CSqlite3::InitConfig()
 {
     //检查有没有pos_config这个表,如果没有就创建
     std::string sql = "SELECT COUNT(*) FROM sqlite_master where type = 'table' and name = 'pos_config';";
-    sqlite3_stmt * stmt = NULL;
+    sqlite3_stmt* stmt = NULL;
 
     if(sqlite3_prepare_v2(m_db, sql.c_str(), -1, &stmt, NULL) == SQLITE_OK)
     {
@@ -99,7 +99,7 @@ bool CSqlite3::InitConfig()
             }
 
             std::string sql = "SELECT * FROM pos_config;";
-            sqlite3_stmt * stmt = NULL;
+            sqlite3_stmt* stmt = NULL;
 
             if(sqlite3_prepare_v2(m_db, sql.c_str(), -1, &stmt, NULL) == SQLITE_OK)
             {
@@ -196,7 +196,7 @@ bool CSqlite3::InitConfig()
             }
 
             std::string sql = "SELECT * FROM pos_chufang_printer;";
-            sqlite3_stmt * stmt = NULL;
+            sqlite3_stmt* stmt = NULL;
 
             if(sqlite3_prepare_v2(m_db, sql.c_str(), -1, &stmt, NULL) == SQLITE_OK)
             {
@@ -280,7 +280,7 @@ bool CSqlite3::InitConfig()
             }
 
             std::string sql = "SELECT * FROM pos_user;";
-            sqlite3_stmt * stmt = NULL;
+            sqlite3_stmt* stmt = NULL;
 
             if(sqlite3_prepare_v2(m_db, sql.c_str(), -1, &stmt, NULL) == SQLITE_OK)
             {

+ 15 - 15
zhipuzi_pos_windows/tool/CSqlite3.h

@@ -7,29 +7,29 @@
 class CSqlite3
 {
 public:
-	CSqlite3();
-	~CSqlite3();
+    CSqlite3();
+    ~CSqlite3();
 
 public:
-	bool InitConfig();
+    bool InitConfig();
 
-	bool SaveParams(std::map<std::string, std::string>& params);
+    bool SaveParams(std::map<std::string, std::string>& params);
 
-	bool SaveChufangPrinter(std::vector<ChufangPrinter>& printers);
+    bool SaveChufangPrinter(std::vector<ChufangPrinter>& printers);
 
-	bool SaveUsers(std::map<string, string> users);
+    bool SaveUsers(std::map<string, string> users);
 
-	void Close()
-	{
-		if (m_db != NULL)
-		{
-			sqlite3_close(m_db);
-		}
-	}
+    void Close()
+    {
+        if(m_db != NULL)
+        {
+            sqlite3_close(m_db);
+        }
+    }
 
 private:
-	int m_rc;
+    int m_rc;
 
-	sqlite3* m_db = NULL;
+    sqlite3* m_db = NULL;
 };
 

+ 77 - 77
zhipuzi_pos_windows/wnd/CChufangSettingWnd.cpp

@@ -3,99 +3,99 @@
 
 LRESULT CChufangSettingWnd::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);
+    POINT pt;
+    pt.x = GET_X_LPARAM(lParam);
+    pt.y = GET_Y_LPARAM(lParam);
+    ::ScreenToClient(*this, &pt);
 
-	RECT rcClient;
-	::GetClientRect(*this, &rcClient);
+    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;
-		}
-	}
+    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;
+    return HTCLIENT;
 }
 
 LRESULT CChufangSettingWnd::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);
-	}
+    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;
+    bHandled = FALSE;
+    return 0;
 }
 
 LRESULT CChufangSettingWnd::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 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 CChufangSettingWnd::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;
+    if(uMsg == WM_KEYDOWN)
+    {
+        if(wParam == VK_RETURN)
+        {
+            return true;
+        }
+        else if(wParam == VK_ESCAPE)
+        {
+            return true;
+        }
+    }
+    return false;
 }
 
 

+ 187 - 187
zhipuzi_pos_windows/wnd/CChufangSettingWnd.h

@@ -8,13 +8,13 @@ class CChufangSettingWnd : public CWindowWnd, public INotifyUI, public IMessageF
 public:
     CChufangSettingWnd(int mode)
     {
-		m_mode = mode;
+        m_mode = mode;
     }
 
-	void SetPrinterDate(std::string date)
-	{
-		m_printer_date = date;
-	}
+    void SetPrinterDate(std::string date)
+    {
+        m_printer_date = date;
+    }
 
     LPCTSTR GetWindowClassName() const
     {
@@ -35,145 +35,145 @@ public:
 
     void Init()
     {
-		CLabelUI* ip_error = static_cast<CLabelUI*>(m_pm.FindControl(_T("chufang_setting_ip_error")));
-		ip_error->SetVisible(false);
-
-		CLabelUI* title = static_cast<CLabelUI*>(m_pm.FindControl(_T("chufang_setting_title")));
-		if (m_mode == 1)
-		{
-			title->SetText(L"新建厨房打印机");
-		}
-		else
-		{
-			title->SetText(L"修改厨房打印机");
-		}
-
-		CEditUI* name = static_cast<CEditUI*>(m_pm.FindControl(_T("chufang_setting_name")));
-		if (m_mode == 1)
-		{
-			name->SetText(L"");
-		}
-		else
-		{
-			ChufangPrinter updatePrinter = CSetting::GetChufangPrinter(m_printer_date);
-			name->SetText(CLewaimaiString::UTF8ToUnicode(updatePrinter.name).c_str());
-		}
-		
-
-		CEditUI* ip = static_cast<CEditUI*>(m_pm.FindControl(_T("chufang_setting_ip")));
-		if (m_mode == 1)
-		{
-			ip->SetText(L"");
-		}
-		else
-		{
-			ChufangPrinter updatePrinter = CSetting::GetChufangPrinter(m_printer_date);
-			ip->SetText(CLewaimaiString::UTF8ToUnicode(updatePrinter.ip).c_str());
-		}
-		
-
-		CComboUI* com = static_cast<CComboUI*>(m_pm.FindControl(_T("chufang_setting_guige")));
-		if (m_mode == 1)
-		{
-			com->SelectItem(0, false, false);
-		}
-		else
-		{
-			ChufangPrinter updatePrinter = CSetting::GetChufangPrinter(m_printer_date);
-			if (updatePrinter.guige == "58")
-			{
-				com->SetInternVisible(true);
-				com->SelectItem(0, false, false);
-			}
-
-			else
-			{
-				com->SetInternVisible(true);
-				com->SelectItem(1, false, false);
-			}
-		}		
-
-		CCheckBoxUI* fendan = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("chufang_setting_fendan")));
-		if (m_mode == 1)
-		{
-			fendan->Selected(false, false);
-		}
-		else
-		{
-			ChufangPrinter updatePrinter = CSetting::GetChufangPrinter(m_printer_date);
-			if (updatePrinter.fendan == "1")
-			{
-				fendan->Selected(true, false);
-			}
-			else
-			{
-				fendan->Selected(false, false);
-			}
-		}		
-
-		CCheckBoxUI* fenlei = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("chufang_setting_fenlei")));
-		if (m_mode == 1)
-		{
-			fenlei->Selected(false, false);
-		}
-		else
-		{
-			ChufangPrinter updatePrinter = CSetting::GetChufangPrinter(m_printer_date);
-			if (updatePrinter.fenlei == "1")
-			{
-				fenlei->Selected(true, false);
-			}
-			else
-			{
-				fenlei->Selected(false, false);
-			}
-		}
-
-		//把所有分类显示出来
-		CVerticalLayoutUI* pLayout = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("chufang_setting_fenlei_xuanze_area")));
-		pLayout->RemoveAll();
-
-		ChufangPrinter updatePrinter;
-
-		//这个map用于后面判断每个分类ID是否被选中
-		std::map<string, bool> ids_map;
-
-		if (m_mode == 2)
-		{
-			updatePrinter = CSetting::GetChufangPrinter(m_printer_date);
-			std::string foodtype_ids = updatePrinter.fenlei_ids;
-			std::vector<string> ids = CLewaimaiString::Split(foodtype_ids, ",");
-			for (std::vector<string>::iterator it = ids.begin(); it != ids.end(); it++)
-			{
-				ids_map[(*it)] = true;
-			}
-		}
-
-		std::vector<FoodType> foodtypes = CSetting::GetFoodtype();
-		for (std::vector<FoodType>::iterator it = foodtypes.begin(); it != foodtypes.end(); it++)
-		{
-			CDialogBuilder builder;
-			CListContainerElementUI* pEle = static_cast<CListContainerElementUI*>(builder.Create(_T("chufang_printer_setting_fenlei_select.xml"), (UINT)0, NULL, &m_pm));
-
-			CCheckBoxUI* pCheck = static_cast<CCheckBoxUI*>(pEle->FindSubControl(_T("chufang_setting_fenleli_xuanze_checkbox")));
-			pCheck->AddCustomAttribute(L"type_id", CLewaimaiString::UTF8ToUnicode((*it).type_id).c_str());
-
-			if (m_mode == 2)
-			{
-				if (ids_map.find((*it).type_id) != ids_map.end())
-				{
-					pCheck->Selected(true, false);
-				}
-			}
-
-			CLabelUI* pName = static_cast<CLabelUI*>(pEle->FindSubControl(_T("chufang_setting_fenleli_xuanze_name")));
-			pName->SetText(CLewaimaiString::UTF8ToUnicode((*it).name).c_str());
-
-			pLayout->Add(pEle);
-		}
-
-		CVerticalLayoutUI* pOutLayout = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("chufang_setting_fenlei_xuanze")));
-		pOutLayout->SetFixedHeight(foodtypes.size() * 30 + 30);
+        CLabelUI* ip_error = static_cast<CLabelUI*>(m_pm.FindControl(_T("chufang_setting_ip_error")));
+        ip_error->SetVisible(false);
+
+        CLabelUI* title = static_cast<CLabelUI*>(m_pm.FindControl(_T("chufang_setting_title")));
+        if(m_mode == 1)
+        {
+            title->SetText(L"新建厨房打印机");
+        }
+        else
+        {
+            title->SetText(L"修改厨房打印机");
+        }
+
+        CEditUI* name = static_cast<CEditUI*>(m_pm.FindControl(_T("chufang_setting_name")));
+        if(m_mode == 1)
+        {
+            name->SetText(L"");
+        }
+        else
+        {
+            ChufangPrinter updatePrinter = CSetting::GetChufangPrinter(m_printer_date);
+            name->SetText(CLewaimaiString::UTF8ToUnicode(updatePrinter.name).c_str());
+        }
+
+
+        CEditUI* ip = static_cast<CEditUI*>(m_pm.FindControl(_T("chufang_setting_ip")));
+        if(m_mode == 1)
+        {
+            ip->SetText(L"");
+        }
+        else
+        {
+            ChufangPrinter updatePrinter = CSetting::GetChufangPrinter(m_printer_date);
+            ip->SetText(CLewaimaiString::UTF8ToUnicode(updatePrinter.ip).c_str());
+        }
+
+
+        CComboUI* com = static_cast<CComboUI*>(m_pm.FindControl(_T("chufang_setting_guige")));
+        if(m_mode == 1)
+        {
+            com->SelectItem(0, false, false);
+        }
+        else
+        {
+            ChufangPrinter updatePrinter = CSetting::GetChufangPrinter(m_printer_date);
+            if(updatePrinter.guige == "58")
+            {
+                com->SetInternVisible(true);
+                com->SelectItem(0, false, false);
+            }
+
+            else
+            {
+                com->SetInternVisible(true);
+                com->SelectItem(1, false, false);
+            }
+        }
+
+        CCheckBoxUI* fendan = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("chufang_setting_fendan")));
+        if(m_mode == 1)
+        {
+            fendan->Selected(false, false);
+        }
+        else
+        {
+            ChufangPrinter updatePrinter = CSetting::GetChufangPrinter(m_printer_date);
+            if(updatePrinter.fendan == "1")
+            {
+                fendan->Selected(true, false);
+            }
+            else
+            {
+                fendan->Selected(false, false);
+            }
+        }
+
+        CCheckBoxUI* fenlei = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("chufang_setting_fenlei")));
+        if(m_mode == 1)
+        {
+            fenlei->Selected(false, false);
+        }
+        else
+        {
+            ChufangPrinter updatePrinter = CSetting::GetChufangPrinter(m_printer_date);
+            if(updatePrinter.fenlei == "1")
+            {
+                fenlei->Selected(true, false);
+            }
+            else
+            {
+                fenlei->Selected(false, false);
+            }
+        }
+
+        //把所有分类显示出来
+        CVerticalLayoutUI* pLayout = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("chufang_setting_fenlei_xuanze_area")));
+        pLayout->RemoveAll();
+
+        ChufangPrinter updatePrinter;
+
+        //这个map用于后面判断每个分类ID是否被选中
+        std::map<string, bool> ids_map;
+
+        if(m_mode == 2)
+        {
+            updatePrinter = CSetting::GetChufangPrinter(m_printer_date);
+            std::string foodtype_ids = updatePrinter.fenlei_ids;
+            std::vector<string> ids = CLewaimaiString::Split(foodtype_ids, ",");
+            for(std::vector<string>::iterator it = ids.begin(); it != ids.end(); it++)
+            {
+                ids_map[(*it)] = true;
+            }
+        }
+
+        std::vector<FoodType> foodtypes = CSetting::GetFoodtype();
+        for(std::vector<FoodType>::iterator it = foodtypes.begin(); it != foodtypes.end(); it++)
+        {
+            CDialogBuilder builder;
+            CListContainerElementUI* pEle = static_cast<CListContainerElementUI*>(builder.Create(_T("chufang_printer_setting_fenlei_select.xml"), (UINT)0, NULL, &m_pm));
+
+            CCheckBoxUI* pCheck = static_cast<CCheckBoxUI*>(pEle->FindSubControl(_T("chufang_setting_fenleli_xuanze_checkbox")));
+            pCheck->AddCustomAttribute(L"type_id", CLewaimaiString::UTF8ToUnicode((*it).type_id).c_str());
+
+            if(m_mode == 2)
+            {
+                if(ids_map.find((*it).type_id) != ids_map.end())
+                {
+                    pCheck->Selected(true, false);
+                }
+            }
+
+            CLabelUI* pName = static_cast<CLabelUI*>(pEle->FindSubControl(_T("chufang_setting_fenleli_xuanze_name")));
+            pName->SetText(CLewaimaiString::UTF8ToUnicode((*it).name).c_str());
+
+            pLayout->Add(pEle);
+        }
+
+        CVerticalLayoutUI* pOutLayout = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("chufang_setting_fenlei_xuanze")));
+        pOutLayout->SetFixedHeight(foodtypes.size() * 30 + 30);
     }
 
     void Notify(TNotifyUI& msg)
@@ -196,15 +196,15 @@ public:
                 CEditUI* pIP = static_cast<CEditUI*>(m_pm.FindControl(_T("chufang_setting_ip")));
                 wstring wsIP = pIP->GetText();
 
-				//判断IP的格式是否合法
-				if (CLewaimaiString::isIPAddressValid(CLewaimaiString::UnicodeToUTF8(wsIP).c_str()) == false)
-				{
-					//如果IP格式不合法,就提示
-					CLabelUI* ip_error = static_cast<CLabelUI*>(m_pm.FindControl(_T("chufang_setting_ip_error")));
-					ip_error->SetVisible(true);
+                //判断IP的格式是否合法
+                if(CLewaimaiString::isIPAddressValid(CLewaimaiString::UnicodeToUTF8(wsIP).c_str()) == false)
+                {
+                    //如果IP格式不合法,就提示
+                    CLabelUI* ip_error = static_cast<CLabelUI*>(m_pm.FindControl(_T("chufang_setting_ip_error")));
+                    ip_error->SetVisible(true);
 
-					return;
-				}
+                    return;
+                }
 
                 CComboUI* com = static_cast<CComboUI*>(m_pm.FindControl(_T("chufang_setting_guige")));
                 wstring wsGuige;
@@ -239,44 +239,44 @@ public:
                     wsFenlei = L"0";
                 }
 
-				std::string fenlei_ids = "";
+                std::string fenlei_ids = "";
 
-				CVerticalLayoutUI* pLayout = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("chufang_setting_fenlei_xuanze_area")));
-				CDuiPtrArray* pArray = m_pm.FindSubControlsByClass(pLayout, _T("CheckBox"));
-				int size = pArray->GetSize();
-				for (int i = 0; i < size; i++)
-				{
-					CCheckBoxUI* pBox = static_cast<CCheckBoxUI*>(pArray->GetAt(i));
+                CVerticalLayoutUI* pLayout = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("chufang_setting_fenlei_xuanze_area")));
+                CDuiPtrArray* pArray = m_pm.FindSubControlsByClass(pLayout, _T("CheckBox"));
+                int size = pArray->GetSize();
+                for(int i = 0; i < size; i++)
+                {
+                    CCheckBoxUI* pBox = static_cast<CCheckBoxUI*>(pArray->GetAt(i));
 
-					if (pBox->IsSelected())
-					{
-						std::wstring ws_type_id = pBox->GetCustomAttribute(_T("type_id"));
-						std::string type_id = CLewaimaiString::UnicodeToUTF8(ws_type_id);
+                    if(pBox->IsSelected())
+                    {
+                        std::wstring ws_type_id = pBox->GetCustomAttribute(_T("type_id"));
+                        std::string type_id = CLewaimaiString::UnicodeToUTF8(ws_type_id);
 
-						fenlei_ids += type_id + ",";
-					}
-				}
+                        fenlei_ids += type_id + ",";
+                    }
+                }
 
-				fenlei_ids = fenlei_ids.substr(0, fenlei_ids.size() - 1);
+                fenlei_ids = fenlei_ids.substr(0, fenlei_ids.size() - 1);
 
                 //保存数据到数据库
 
-				std::string date = to_string(time(NULL));
+                std::string date = to_string(time(NULL));
 
-				std::string name = CLewaimaiString::UnicodeToUTF8(wsName);
-				std::string ip = CLewaimaiString::UnicodeToUTF8(wsIP);
-				std::string guige = CLewaimaiString::UnicodeToUTF8(wsGuige);
-				std::string fendan = CLewaimaiString::UnicodeToUTF8(wsFendan);
-				std::string fenlei = CLewaimaiString::UnicodeToUTF8(wsFenlei);
+                std::string name = CLewaimaiString::UnicodeToUTF8(wsName);
+                std::string ip = CLewaimaiString::UnicodeToUTF8(wsIP);
+                std::string guige = CLewaimaiString::UnicodeToUTF8(wsGuige);
+                std::string fendan = CLewaimaiString::UnicodeToUTF8(wsFendan);
+                std::string fenlei = CLewaimaiString::UnicodeToUTF8(wsFenlei);
 
-				if (m_mode == 1)
-				{
-					CSetting::AddChufangPrinter(date, name, ip, guige, fendan, fenlei, fenlei_ids, true);
-				}
-				else
-				{
-					CSetting::UpdateChufangPrinter(m_printer_date, name, ip, guige, fendan, fenlei, fenlei_ids, true);
-				}
+                if(m_mode == 1)
+                {
+                    CSetting::AddChufangPrinter(date, name, ip, guige, fendan, fenlei, fenlei_ids, true);
+                }
+                else
+                {
+                    CSetting::UpdateChufangPrinter(m_printer_date, name, ip, guige, fendan, fenlei, fenlei_ids, true);
+                }
 
                 Close(IDOK);
                 return;
@@ -330,18 +330,18 @@ public:
         return 0;
     }
 
-	LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+    LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
 
-	LRESULT OnSize(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 HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
 
-	LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled);
+    LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled);
 
 public:
     CPaintManagerUI m_pm;
 
-	int m_mode; //为1表示新建,为2表示修改
-	std::string m_printer_date; //修改模式下的打印机的日期
+    int m_mode; //为1表示新建,为2表示修改
+    std::string m_printer_date; //修改模式下的打印机的日期
 };
 

+ 262 - 262
zhipuzi_pos_windows/wnd/CLoginWnd.cpp

@@ -6,72 +6,72 @@
 
 void CLoginWnd::Init()
 {
-	CLabelUI* version = static_cast<CLabelUI*>(m_pm.FindControl(_T("login_version")));
-	version->SetText((L"智铺子收银软件 " + CLewaimaiString::UTF8ToUnicode(CSystem::GetVersion())).c_str());
-
-	std::map<string, string> users = CSetting::getUsers();
-
-	CComboUI* pCom = static_cast<CComboUI*>(m_pm.FindControl(_T("accountcombo")));
-
-	for (std::map<string, string>::iterator it = users.begin(); it != users.end(); it++)
-	{
-		std::string username = it->first;
-		
-		CListLabelElementUI* elem = new CListLabelElementUI();
-		elem->SetText(CLewaimaiString::UTF8ToUnicode(username).c_str());
-
-		pCom->Add(elem);
-	}
-
-	CCheckBoxUI* pAuto = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_auto_login")));
-	CCheckBoxUI* pRemember = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_remember_password")));
-
-	if (CSetting::GetParam("setting_is_remember_password") == "1")
-	{
-		pRemember->Selected(true, false);
-	}
-	else
-	{
-		pRemember->Selected(false, false);
-	}
-
-	if (CSetting::GetParam("setting_is_auto_login") == "1")
-	{
-		//自动登录开启了,记住密码一定要开启
-		pAuto->Selected(true, false);
-		pRemember->Selected(true, false);
-	}
-	else
-	{
-		pAuto->Selected(false, false);
-	}
-
-	std::string last_login_username = CSetting::GetParam("last_login_username");
-	std::string password = CSetting::GetUser(last_login_username);
-
-	CEditUI* pAccountEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("accountedit")));
-	CEditUI* pPasswordEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("pwdedit")));
-
-	pAccountEdit->SetText(CLewaimaiString::UTF8ToUnicode(last_login_username).c_str());
-	pPasswordEdit->SetText(CLewaimaiString::UTF8ToUnicode(password).c_str());
-
-	if (CSetting::GetParam("setting_is_auto_login") == "1")
-	{
-		StartLogin();
-	}
-	else
-	{
-		CVerticalLayoutUI* pInput = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_input")));
-		pInput->SetVisible(true);
-
-		CVerticalLayoutUI* pLoading = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_loading")));
-		pLoading->SetVisible(false);
-	}
-
-	if (m_mode == 2)
-	{
-		PostMessage(WM_LOGIN_AGAIN_OUT);
-	}
+    CLabelUI* version = static_cast<CLabelUI*>(m_pm.FindControl(_T("login_version")));
+    version->SetText((L"智铺子收银软件 " + CLewaimaiString::UTF8ToUnicode(CSystem::GetVersion())).c_str());
+
+    std::map<string, string> users = CSetting::getUsers();
+
+    CComboUI* pCom = static_cast<CComboUI*>(m_pm.FindControl(_T("accountcombo")));
+
+    for(std::map<string, string>::iterator it = users.begin(); it != users.end(); it++)
+    {
+        std::string username = it->first;
+
+        CListLabelElementUI* elem = new CListLabelElementUI();
+        elem->SetText(CLewaimaiString::UTF8ToUnicode(username).c_str());
+
+        pCom->Add(elem);
+    }
+
+    CCheckBoxUI* pAuto = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_auto_login")));
+    CCheckBoxUI* pRemember = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_remember_password")));
+
+    if(CSetting::GetParam("setting_is_remember_password") == "1")
+    {
+        pRemember->Selected(true, false);
+    }
+    else
+    {
+        pRemember->Selected(false, false);
+    }
+
+    if(CSetting::GetParam("setting_is_auto_login") == "1")
+    {
+        //自动登录开启了,记住密码一定要开启
+        pAuto->Selected(true, false);
+        pRemember->Selected(true, false);
+    }
+    else
+    {
+        pAuto->Selected(false, false);
+    }
+
+    std::string last_login_username = CSetting::GetParam("last_login_username");
+    std::string password = CSetting::GetUser(last_login_username);
+
+    CEditUI* pAccountEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("accountedit")));
+    CEditUI* pPasswordEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("pwdedit")));
+
+    pAccountEdit->SetText(CLewaimaiString::UTF8ToUnicode(last_login_username).c_str());
+    pPasswordEdit->SetText(CLewaimaiString::UTF8ToUnicode(password).c_str());
+
+    if(CSetting::GetParam("setting_is_auto_login") == "1")
+    {
+        StartLogin();
+    }
+    else
+    {
+        CVerticalLayoutUI* pInput = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_input")));
+        pInput->SetVisible(true);
+
+        CVerticalLayoutUI* pLoading = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_loading")));
+        pLoading->SetVisible(false);
+    }
+
+    if(m_mode == 2)
+    {
+        PostMessage(WM_LOGIN_AGAIN_OUT);
+    }
 }
 
 void CLoginWnd::Notify(TNotifyUI& msg)
@@ -80,58 +80,58 @@ void CLoginWnd::Notify(TNotifyUI& msg)
     {
         if(msg.pSender->GetName() == _T("closebtn"))
         {
-			PostQuitMessage(0);
+            PostQuitMessage(0);
             return;
         }
         else if(msg.pSender->GetName() == _T("loginBtn"))
         {
-			StartLogin();
+            StartLogin();
             return;
         }
-		else if (msg.pSender->GetName() == _T("login_auto_login"))
-		{
-			CCheckBoxUI* pAuto = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_auto_login")));
-			CCheckBoxUI* pRemember = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_remember_password")));
-
-			if (!pAuto->IsSelected())
-			{
-				pRemember->Selected(true, false);
-			}
-		}
-		else if (msg.pSender->GetName() == _T("login_remember_password"))
-		{
-			CCheckBoxUI* pAuto = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_auto_login")));
-			CCheckBoxUI* pRemember = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_remember_password")));
-
-			if (pRemember->IsSelected())
-			{
-				pAuto->Selected(false, false);
-			}
-		}
-		else if (msg.pSender->GetName() == _T("guanwang"))
-		{
-			ShellExecute(NULL, _T("open"), _T("explorer.exe"), _T("https://www.zhipuzi.com"), NULL, SW_SHOW);
-		}
+        else if(msg.pSender->GetName() == _T("login_auto_login"))
+        {
+            CCheckBoxUI* pAuto = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_auto_login")));
+            CCheckBoxUI* pRemember = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_remember_password")));
+
+            if(!pAuto->IsSelected())
+            {
+                pRemember->Selected(true, false);
+            }
+        }
+        else if(msg.pSender->GetName() == _T("login_remember_password"))
+        {
+            CCheckBoxUI* pAuto = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_auto_login")));
+            CCheckBoxUI* pRemember = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_remember_password")));
+
+            if(pRemember->IsSelected())
+            {
+                pAuto->Selected(false, false);
+            }
+        }
+        else if(msg.pSender->GetName() == _T("guanwang"))
+        {
+            ShellExecute(NULL, _T("open"), _T("explorer.exe"), _T("https://www.zhipuzi.com"), NULL, SW_SHOW);
+        }
     }
-	else if (msg.sType == _T("itemselect"))
-	{
-		CDuiString name = msg.pSender->GetName();
+    else if(msg.sType == _T("itemselect"))
+    {
+        CDuiString name = msg.pSender->GetName();
 
-		if (name == _T("accountcombo"))
-		{
-			CComboUI* pCom = static_cast<CComboUI*>(m_pm.FindControl(_T("accountcombo")));
+        if(name == _T("accountcombo"))
+        {
+            CComboUI* pCom = static_cast<CComboUI*>(m_pm.FindControl(_T("accountcombo")));
 
-			std::wstring name = pCom->GetItemAt(pCom->GetCurSel())->GetText();
-			std::string password = CSetting::GetUser(CLewaimaiString::UnicodeToUTF8(name));
-			std::wstring wspassword = CLewaimaiString::UTF8ToUnicode(password);
+            std::wstring name = pCom->GetItemAt(pCom->GetCurSel())->GetText();
+            std::string password = CSetting::GetUser(CLewaimaiString::UnicodeToUTF8(name));
+            std::wstring wspassword = CLewaimaiString::UTF8ToUnicode(password);
 
-			CEditUI* pEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("accountedit")));
-			pEdit->SetText(name.c_str());
+            CEditUI* pEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("accountedit")));
+            pEdit->SetText(name.c_str());
 
-			CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("pwdedit")));
-			pPassword->SetText(wspassword.c_str());
-		}
-	}
+            CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("pwdedit")));
+            pPassword->SetText(wspassword.c_str());
+        }
+    }
 }
 
 LRESULT CLoginWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
@@ -163,8 +163,8 @@ LRESULT CLoginWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHand
 
 LRESULT CLoginWnd::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
 {
-	bHandled = FALSE;
-	return 0;
+    bHandled = FALSE;
+    return 0;
 }
 
 /*
@@ -172,8 +172,8 @@ LRESULT CLoginWnd::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandl
  **/
 LRESULT CLoginWnd::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
 {
-	bHandled = FALSE;
-	return 0;
+    bHandled = FALSE;
+    return 0;
 }
 
 LRESULT CLoginWnd::OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
@@ -192,14 +192,14 @@ LRESULT CLoginWnd::OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& b
 
 LRESULT CLoginWnd::OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
 {
-	//在这里设置焦点才有用
-	CEditUI* pAccountEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("accountedit")));
-	if (pAccountEdit)
-	{
-		pAccountEdit->SetFocus();
-	}
-
-	return 0;
+    //在这里设置焦点才有用
+    CEditUI* pAccountEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("accountedit")));
+    if(pAccountEdit)
+    {
+        pAccountEdit->SetFocus();
+    }
+
+    return 0;
 }
 
 LRESULT CLoginWnd::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
@@ -254,12 +254,12 @@ LRESULT CLoginWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
     case WM_CREATE:
         lRes = OnCreate(uMsg, wParam, lParam, bHandled);
         break;
-	case WM_CLOSE:
-		lRes = OnClose(uMsg, wParam, lParam, bHandled);
-		break;
-	case WM_DESTROY:
-		lRes = OnDestroy(uMsg, wParam, lParam, bHandled);
-		break;
+    case WM_CLOSE:
+        lRes = OnClose(uMsg, wParam, lParam, bHandled);
+        break;
+    case WM_DESTROY:
+        lRes = OnDestroy(uMsg, wParam, lParam, bHandled);
+        break;
     case WM_NCACTIVATE:
         lRes = OnNcActivate(uMsg, wParam, lParam, bHandled);
         break;
@@ -321,58 +321,58 @@ LRESULT CLoginWnd::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool&
         }
 
     }
-	else if (uMsg == WM_LOGIN_SUCCESS)
-	{
-		LoginSuccess();
-		return true;
-	}
-	else if (uMsg == WM_LOGIN_ERROR)
-	{
-		LoginError();
-		return true;
-	}
-	else if (uMsg == WM_NEED_UPDATE)
-	{
-		//说明需要升级了
-
-		Update();
-
-		return true;
-	}
-	else if (uMsg == WM_LOGIN_AGAIN_OUT)
-	{
-		ShowLoginAgainOut();
-
-		return true;
-	}
+    else if(uMsg == WM_LOGIN_SUCCESS)
+    {
+        LoginSuccess();
+        return true;
+    }
+    else if(uMsg == WM_LOGIN_ERROR)
+    {
+        LoginError();
+        return true;
+    }
+    else if(uMsg == WM_NEED_UPDATE)
+    {
+        //说明需要升级了
+
+        Update();
+
+        return true;
+    }
+    else if(uMsg == WM_LOGIN_AGAIN_OUT)
+    {
+        ShowLoginAgainOut();
+
+        return true;
+    }
 
     return false;
 }
 
 void CLoginWnd::StartLogin()
 {
-	//隐藏密码输入框,显示进度条
-	CVerticalLayoutUI* pInput = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_input")));
-	pInput->SetVisible(false);
+    //隐藏密码输入框,显示进度条
+    CVerticalLayoutUI* pInput = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_input")));
+    pInput->SetVisible(false);
 
-	CVerticalLayoutUI* pLoading = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_loading")));
-	pLoading->SetVisible(true);
+    CVerticalLayoutUI* pLoading = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_loading")));
+    pLoading->SetVisible(true);
 
-	CLabelUI* pLoginResultLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("loginresult")));
-	pLoginResultLabel->SetVisible(false);
+    CLabelUI* pLoginResultLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("loginresult")));
+    pLoginResultLabel->SetVisible(false);
 
-	//开启一个线程,开始处理登录
-	std::thread(&CLoginWnd::HandleLogin, this).detach();
+    //开启一个线程,开始处理登录
+    std::thread(&CLoginWnd::HandleLogin, this).detach();
 }
 
 void CLoginWnd::HandleLogin()
 {
-	////真正登录前,先检测是否有需要更新
-	//CSystem::my_sleep(1);
+    ////真正登录前,先检测是否有需要更新
+    //CSystem::my_sleep(1);
 
-	////如果需要更新,那么就提示
-	//PostMessage(WM_NEED_UPDATE);
-	//return;
+    ////如果需要更新,那么就提示
+    //PostMessage(WM_NEED_UPDATE);
+    //return;
 
     //判断账号密码是否正确
     std::wstring account, password;
@@ -393,29 +393,29 @@ void CLoginWnd::HandleLogin()
     string s_account = CLewaimaiString::UnicodeToUTF8(account);
     string s_password = CLewaimaiString::UnicodeToUTF8(password);
 
-	CLewaimaiString::trim(s_account);
-	CLewaimaiString::trim(s_password);
+    CLewaimaiString::trim(s_account);
+    CLewaimaiString::trim(s_password);
 
-	CLabelUI* pLoginResultLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("loginresult")));
-	if (s_account.compare("") == 0)
-	{
-		pLoginResultLabel->SetText(std::wstring(_T("用户名不能为空")).c_str());
-		pLoginResultLabel->SetVisible(true);
+    CLabelUI* pLoginResultLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("loginresult")));
+    if(s_account.compare("") == 0)
+    {
+        pLoginResultLabel->SetText(std::wstring(_T("用户名不能为空")).c_str());
+        pLoginResultLabel->SetVisible(true);
 
-		PostMessage(WM_LOGIN_ERROR);
+        PostMessage(WM_LOGIN_ERROR);
 
-		return;
-	}
+        return;
+    }
 
-	if (s_password.compare("") == 0)
-	{
-		pLoginResultLabel->SetText(std::wstring(_T("密码不能为空")).c_str());
-		pLoginResultLabel->SetVisible(true);
+    if(s_password.compare("") == 0)
+    {
+        pLoginResultLabel->SetText(std::wstring(_T("密码不能为空")).c_str());
+        pLoginResultLabel->SetVisible(true);
 
-		PostMessage(WM_LOGIN_ERROR);
+        PostMessage(WM_LOGIN_ERROR);
 
-		return;
-	}
+        return;
+    }
 
     CZhipuziHttpClient::Init(s_account, s_password);
 
@@ -424,50 +424,50 @@ void CLoginWnd::HandleLogin()
 
     if(res)
     {
-		CCheckBoxUI* pAuto = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_auto_login")));
-		CCheckBoxUI* pRemember = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_remember_password")));
-
-		if (pAuto->IsSelected())
-		{
-			CSetting::SetParam("setting_is_auto_login", "1", false);
-			CSetting::SetParam("setting_is_remember_password", "1", false);
-
-			//相当于开启自动登录,默认就是开启了记住密码了
-			CSetting::SetUser(s_account, s_password, true);
-		}
-		else
-		{
-			CSetting::SetParam("setting_is_auto_login", "0", false);
-
-			if (pRemember->IsSelected())
-			{
-				CSetting::SetParam("setting_is_remember_password", "1", false);
-			}
-			else
-			{
-				CSetting::SetParam("setting_is_remember_password", "0", false);
-			}
-
-
-			if (pRemember->IsSelected())
-			{
-				CSetting::SetUser(s_account, s_password, true);
-			}
-			else
-			{
-				CSetting::SetUser(s_account, "", true);
-			}
-		}		
-
-		//在这里设置完参数后,统一保存到数据库
-		CSetting::SetParam("last_login_username", s_account, true);
-
-		//把用户名和密码保存起来
-		CSetting::SetLoginInfo(s_account, s_password);
-
-		PostMessage(WM_LOGIN_SUCCESS);
-
-		return;
+        CCheckBoxUI* pAuto = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_auto_login")));
+        CCheckBoxUI* pRemember = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_remember_password")));
+
+        if(pAuto->IsSelected())
+        {
+            CSetting::SetParam("setting_is_auto_login", "1", false);
+            CSetting::SetParam("setting_is_remember_password", "1", false);
+
+            //相当于开启自动登录,默认就是开启了记住密码了
+            CSetting::SetUser(s_account, s_password, true);
+        }
+        else
+        {
+            CSetting::SetParam("setting_is_auto_login", "0", false);
+
+            if(pRemember->IsSelected())
+            {
+                CSetting::SetParam("setting_is_remember_password", "1", false);
+            }
+            else
+            {
+                CSetting::SetParam("setting_is_remember_password", "0", false);
+            }
+
+
+            if(pRemember->IsSelected())
+            {
+                CSetting::SetUser(s_account, s_password, true);
+            }
+            else
+            {
+                CSetting::SetUser(s_account, "", true);
+            }
+        }
+
+        //在这里设置完参数后,统一保存到数据库
+        CSetting::SetParam("last_login_username", s_account, true);
+
+        //把用户名和密码保存起来
+        CSetting::SetLoginInfo(s_account, s_password);
+
+        PostMessage(WM_LOGIN_SUCCESS);
+
+        return;
     }
     else
     {
@@ -477,71 +477,71 @@ void CLoginWnd::HandleLogin()
         pLoginResultLabel->SetText(std::wstring(_T("登录失败:") + CLewaimaiString::UTF8ToUnicode(errmsg)).c_str());
         pLoginResultLabel->SetVisible(true);
 
-		PostMessage(WM_LOGIN_ERROR);
+        PostMessage(WM_LOGIN_ERROR);
     }
 }
 
 void CLoginWnd::LoginSuccess()
 {
-	CMainWnd* pFrame = new CMainWnd();
-	if (pFrame == NULL)
-	{
-		return;
-	}
+    CMainWnd* pFrame = new CMainWnd();
+    if(pFrame == NULL)
+    {
+        return;
+    }
 
-	pFrame->SetIcon(IDI_ICON_DUILIB);
-	pFrame->Create(NULL, _T("智铺子收银软件"), UI_WNDSTYLE_FRAME, 0L, 0, 0, 1024, 768);
-	pFrame->CenterWindow();
+    pFrame->SetIcon(IDI_ICON_DUILIB);
+    pFrame->Create(NULL, _T("智铺子收银软件"), UI_WNDSTYLE_FRAME, 0L, 0, 0, 1024, 768);
+    pFrame->CenterWindow();
 
-	::ShowWindow(*pFrame, SW_SHOWMAXIMIZED);
+    ::ShowWindow(*pFrame, SW_SHOWMAXIMIZED);
 
-	Close();
+    Close();
 }
 
 void CLoginWnd::LoginError()
 {
-	CVerticalLayoutUI* pInput = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_input")));
-	pInput->SetVisible(true);
+    CVerticalLayoutUI* pInput = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_input")));
+    pInput->SetVisible(true);
 
-	CVerticalLayoutUI* pLoading = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_loading")));
-	pLoading->SetVisible(false);
+    CVerticalLayoutUI* pLoading = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_loading")));
+    pLoading->SetVisible(false);
 
-	CLabelUI* pLoginResultLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("loginresult")));
-	pLoginResultLabel->SetVisible(true);
+    CLabelUI* pLoginResultLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("loginresult")));
+    pLoginResultLabel->SetVisible(true);
 }
 
 void CLoginWnd::Update()
 {
-	CUpdateWnd* pFrame = new CUpdateWnd();
-	if (pFrame == NULL)
-	{
-		return;
-	}
+    CUpdateWnd* pFrame = new CUpdateWnd();
+    if(pFrame == NULL)
+    {
+        return;
+    }
 
-	TCHAR lpTempPathBuffer[MAX_PATH];
-	DWORD dwRetVal = GetTempPath(MAX_PATH, lpTempPathBuffer);
+    TCHAR lpTempPathBuffer[MAX_PATH];
+    DWORD dwRetVal = GetTempPath(MAX_PATH, lpTempPathBuffer);
 
-	std::string url = "http://down10d.zol.com.cn/zoldownload_os/nsis3.04setup@81_262627.exe";
-	std::string filename = CLewaimaiString::UnicodeToANSI(lpTempPathBuffer);
-	pFrame->InitData(url, filename);
+    std::string url = "http://down10d.zol.com.cn/zoldownload_os/nsis3.04setup@81_262627.exe";
+    std::string filename = CLewaimaiString::UnicodeToANSI(lpTempPathBuffer);
+    pFrame->InitData(url, filename);
 
-	pFrame->SetIcon(IDI_ICON_DUILIB);
-	pFrame->Create(NULL, _T("自动更新"), UI_WNDSTYLE_DIALOG, 0, 0, 0, 0, 0, NULL);
-	pFrame->CenterWindow();
+    pFrame->SetIcon(IDI_ICON_DUILIB);
+    pFrame->Create(NULL, _T("自动更新"), UI_WNDSTYLE_DIALOG, 0, 0, 0, 0, 0, NULL);
+    pFrame->CenterWindow();
 
-	::ShowWindow(*pFrame, SW_SHOWNORMAL);
+    ::ShowWindow(*pFrame, SW_SHOWNORMAL);
 
-	Close();
+    Close();
 }
 
 void CLoginWnd::ShowLoginAgainOut()
 {
-	//这种模式是本人强制挤下线了
-	CMessageboxWnd* pMessagebox = new CMessageboxWnd;
-	pMessagebox->Create(m_hWnd, _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
-	pMessagebox->SetIcon(IDI_ICON_DUILIB);
-	pMessagebox->CenterWindow();
-	UINT ret = pMessagebox->ShowModal();
+    //这种模式是本人强制挤下线了
+    CMessageboxWnd* pMessagebox = new CMessageboxWnd;
+    pMessagebox->Create(m_hWnd, _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
+    pMessagebox->SetIcon(IDI_ICON_DUILIB);
+    pMessagebox->CenterWindow();
+    UINT ret = pMessagebox->ShowModal();
 }
 
 

+ 24 - 24
zhipuzi_pos_windows/wnd/CLoginWnd.h

@@ -27,53 +27,53 @@ public:
         delete this;
     };
 
-	void Init();
+    void Init();
 
-	void SetMode(int mode)
-	{
-		m_mode = mode;
-	}
+    void SetMode(int mode)
+    {
+        m_mode = mode;
+    }
 
-	void Notify(TNotifyUI& msg);
+    void Notify(TNotifyUI& msg);
 
-	LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+    LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
 
-	LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+    LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
 
-	LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+    LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
 
-	LRESULT OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+    LRESULT OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
 
-	LRESULT OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+    LRESULT OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
 
-	LRESULT OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+    LRESULT OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
 
-	LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+    LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
 
-	LRESULT OnSize(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 HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
 
-	LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled);
+    LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled);
 
-	void StartLogin();
+    void StartLogin();
 
     void HandleLogin();
 
-	void LoginSuccess();
+    void LoginSuccess();
 
-	void LoginError();
+    void LoginError();
 
-	void Update();
+    void Update();
 
-	void ShowLoginAgainOut();
+    void ShowLoginAgainOut();
 
 public:
     CPaintManagerUI m_pm;
 
-	std::string m_update_url;
+    std::string m_update_url;
 
-	//模式1:正常的展示登录页面 2:被人挤下线的
-	int m_mode = 1;
+    //模式1:正常的展示登录页面 2:被人挤下线的
+    int m_mode = 1;
 };
 

+ 374 - 374
zhipuzi_pos_windows/wnd/CMainWnd.cpp

@@ -17,20 +17,20 @@ void CMainWnd::Init()
     m_pRestoreBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("restorebtn")));
     m_pMinBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("minbtn")));
 
-	//初始化外卖订单列表
-	COptionUI* waimai_tab = static_cast<COptionUI*>(m_pm.FindControl(_T("main_waimai")));
-	if (waimai_tab->IsSelected())
-	{
-		OrderListUI* orderlist = static_cast<OrderListUI*>(m_pm.FindControl(_T("orderlist")));
-		orderlist->Refresh();
-	}
+    //初始化外卖订单列表
+    COptionUI* waimai_tab = static_cast<COptionUI*>(m_pm.FindControl(_T("main_waimai")));
+    if(waimai_tab->IsSelected())
+    {
+        OrderListUI* orderlist = static_cast<OrderListUI*>(m_pm.FindControl(_T("orderlist")));
+        orderlist->Refresh();
+    }
 
     //初始化设置中心的状态
     InitSettingStatus();
 
-	//登录成功,启动消息和任务处理
-	m_push = new CMessagePush(m_hWnd);
-	m_push->Start();
+    //登录成功,启动消息和任务处理
+    m_push = new CMessagePush(m_hWnd);
+    m_push->Start();
 }
 
 LRESULT CMainWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
@@ -132,7 +132,7 @@ void CMainWnd::HandleClickMsg(TNotifyUI& msg)
         std::string waimai_order_id = item->getOrderID();
         std::string waimai_order_no = item->getOrderNo();
 
-		m_push->AddPinter(waimai_order_id, waimai_order_no, 2);
+        m_push->AddPinter(waimai_order_id, waimai_order_no, 2);
     }
 
     else if(name == _T("waimai_order_list_confirme"))
@@ -175,29 +175,29 @@ void CMainWnd::HandleClickMsg(TNotifyUI& msg)
         CWaimaiOrderItemUI* item = static_cast<CWaimaiOrderItemUI*>(msg.pSender->GetParent()->GetParent());
         std::string waimai_order_id = item->getOrderID();
 
-		CWaimaiOrderFailReasonWnd* pWaimaiFailFrame = new CWaimaiOrderFailReasonWnd();
-		pWaimaiFailFrame->Create(this->GetHWND(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
-		pWaimaiFailFrame->SetIcon(IDI_ICON_DUILIB);
-		pWaimaiFailFrame->CenterWindow();
-		UINT ret = pWaimaiFailFrame->ShowModal();
+        CWaimaiOrderFailReasonWnd* pWaimaiFailFrame = new CWaimaiOrderFailReasonWnd();
+        pWaimaiFailFrame->Create(this->GetHWND(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
+        pWaimaiFailFrame->SetIcon(IDI_ICON_DUILIB);
+        pWaimaiFailFrame->CenterWindow();
+        UINT ret = pWaimaiFailFrame->ShowModal();
 
-		if (ret == IDOK)
-		{
-			std::string sReason = pWaimaiFailFrame->getReason();
+        if(ret == IDOK)
+        {
+            std::string sReason = pWaimaiFailFrame->getReason();
 
-			CWaimaiOrder order;
-			bool ret = order.FailOrder(waimai_order_id, sReason);
+            CWaimaiOrder order;
+            bool ret = order.FailOrder(waimai_order_id, sReason);
 
-			if (ret)
-			{
-				//如果设为失败成功,将被设为失败的订单删除掉
-				OrderListUI* orderlist = static_cast<OrderListUI*>(m_pm.FindControl(_T("orderlist")));
-				int index = orderlist->GetItemIndex(item);
-				orderlist->RemoveAt(index);
-			}
-		}
+            if(ret)
+            {
+                //如果设为失败成功,将被设为失败的订单删除掉
+                OrderListUI* orderlist = static_cast<OrderListUI*>(m_pm.FindControl(_T("orderlist")));
+                int index = orderlist->GetItemIndex(item);
+                orderlist->RemoveAt(index);
+            }
+        }
 
-		delete pWaimaiFailFrame;
+        delete pWaimaiFailFrame;
     }
 
     else if(name == _T("waimai_order_list_agree"))
@@ -296,7 +296,7 @@ void CMainWnd::HandleClickMsg(TNotifyUI& msg)
     {
         CWaimaiOrderInfoUI* order_info_page = static_cast<CWaimaiOrderInfoUI*>(m_pm.FindControl(_T("waimaiorder_info_page")));
 
-		m_push->AddPinter(order_info_page->m_order.m_order_id, order_info_page->m_order.m_order_no, 2);
+        m_push->AddPinter(order_info_page->m_order.m_order_id, order_info_page->m_order.m_order_no, 2);
     }
 
     else if(name == _T("waimai_order_info_page_confirme"))
@@ -352,33 +352,33 @@ void CMainWnd::HandleClickMsg(TNotifyUI& msg)
         std::string waimai_order_id = order_info_page->m_order.m_order_id;
         std::string waimai_order_no = order_info_page->m_order.m_order_no;
 
-		CWaimaiOrderFailReasonWnd* pWaimaiFailFrame = new CWaimaiOrderFailReasonWnd();
-		pWaimaiFailFrame->Create(this->GetHWND(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
-		pWaimaiFailFrame->SetIcon(IDI_ICON_DUILIB);
-		pWaimaiFailFrame->CenterWindow();
-		UINT ret = pWaimaiFailFrame->ShowModal();
+        CWaimaiOrderFailReasonWnd* pWaimaiFailFrame = new CWaimaiOrderFailReasonWnd();
+        pWaimaiFailFrame->Create(this->GetHWND(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
+        pWaimaiFailFrame->SetIcon(IDI_ICON_DUILIB);
+        pWaimaiFailFrame->CenterWindow();
+        UINT ret = pWaimaiFailFrame->ShowModal();
 
-		if (ret == IDOK)
-		{
-			std::string sReason = pWaimaiFailFrame->getReason();
-
-			CWaimaiOrder order;
-			bool ret = order.FailOrder(waimai_order_id, sReason);
+        if(ret == IDOK)
+        {
+            std::string sReason = pWaimaiFailFrame->getReason();
 
-			if (ret)
-			{
-				//订单设为失败,这里怎么处理
-				//请求服务器,获取订单数据
-				CWaimaiOrder new_order;
-				new_order.InitData(waimai_order_id, waimai_order_no);
+            CWaimaiOrder order;
+            bool ret = order.FailOrder(waimai_order_id, sReason);
 
-				//刷新订单详情页数据
-				order_info_page->SetDate(new_order);
-				order_info_page->Refresh(new_order);
-			}
-		}
+            if(ret)
+            {
+                //订单设为失败,这里怎么处理
+                //请求服务器,获取订单数据
+                CWaimaiOrder new_order;
+                new_order.InitData(waimai_order_id, waimai_order_no);
+
+                //刷新订单详情页数据
+                order_info_page->SetDate(new_order);
+                order_info_page->Refresh(new_order);
+            }
+        }
 
-		delete pWaimaiFailFrame;
+        delete pWaimaiFailFrame;
     }
 
     else if(name == _T("waimai_order_info_page_agree"))
@@ -489,149 +489,149 @@ void CMainWnd::HandleClickMsg(TNotifyUI& msg)
         }
     }
 
-	else if (name == _T("setting_printer_quhuo_big"))
-	{
-	CCheckBoxUI* box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_quhuo_big")));
-
-	if (box->IsSelected())
-	{
-		CSetting::SetParam("setting_printer_quhuo_big", "0");
-	}
-	else
-	{
-		CSetting::SetParam("setting_printer_quhuo_big", "1");
-	}
-	}
-	else if (name == _T("setting_printer_dingdanhao_big"))
-	{
-	CCheckBoxUI* box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_dingdanhao_big")));
-
-	if (box->IsSelected())
-	{
-		CSetting::SetParam("setting_printer_dingdanhao_big", "0");
-	}
-	else
-	{
-		CSetting::SetParam("setting_printer_dingdanhao_big", "1");
-	}
-	}
-	else if (name == _T("setting_printer_xiadanshijian_big"))
-	{
-	CCheckBoxUI* box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_xiadanshijian_big")));
-
-	if (box->IsSelected())
-	{
-		CSetting::SetParam("setting_printer_xiadanshijian_big", "0");
-	}
-	else
-	{
-		CSetting::SetParam("setting_printer_xiadanshijian_big", "1");
-	}
-	}
-	else if (name == _T("setting_printer_peisongshijian_big"))
-	{
-	CCheckBoxUI* box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_peisongshijian_big")));
-
-	if (box->IsSelected())
-	{
-		CSetting::SetParam("setting_printer_peisongshijian_big", "0");
-	}
-	else
-	{
-		CSetting::SetParam("setting_printer_peisongshijian_big", "1");
-	}
-	}
-	else if (name == _T("setting_printer_name_big"))
-	{
-	CCheckBoxUI* box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_name_big")));
-
-	if (box->IsSelected())
-	{
-		CSetting::SetParam("setting_printer_name_big", "0");
-	}
-	else
-	{
-		CSetting::SetParam("setting_printer_name_big", "1");
-	}
-	}
-	else if (name == _T("setting_printer_phone_big"))
-	{
-	CCheckBoxUI* box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_phone_big")));
-
-	if (box->IsSelected())
-	{
-		CSetting::SetParam("setting_printer_phone_big", "0");
-	}
-	else
-	{
-		CSetting::SetParam("setting_printer_phone_big", "1");
-	}
-	}
-	else if (name == _T("setting_printer_address_big"))
-	{
-	CCheckBoxUI* box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_address_big")));
-
-	if (box->IsSelected())
-	{
-		CSetting::SetParam("setting_printer_address_big", "0");
-	}
-	else
-	{
-		CSetting::SetParam("setting_printer_address_big", "1");
-	}
-	}
-	else if (name == _T("setting_printer_shangpin_big"))
-	{
-	CCheckBoxUI* box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_shangpin_big")));
-
-	if (box->IsSelected())
-	{
-		CSetting::SetParam("setting_printer_shangpin_big", "0");
-	}
-	else
-	{
-		CSetting::SetParam("setting_printer_shangpin_big", "1");
-	}
-	}
-	else if (name == _T("setting_printer_memo_big"))
-	{
-	CCheckBoxUI* box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_memo_big")));
-
-	if (box->IsSelected())
-	{
-		CSetting::SetParam("setting_printer_memo_big", "0");
-	}
-	else
-	{
-		CSetting::SetParam("setting_printer_memo_big", "1");
-	}
-	}
-	else if (name == _T("setting_printer_price_big"))
-	{
-	CCheckBoxUI* box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_price_big")));
-
-	if (box->IsSelected())
-	{
-		CSetting::SetParam("setting_printer_price_big", "0");
-	}
-	else
-	{
-		CSetting::SetParam("setting_printer_price_big", "1");
-	}
-	}
-	else if (name == _T("setting_printer_pay_big"))
-	{
-	CCheckBoxUI* box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_pay_big")));
-
-	if (box->IsSelected())
-	{
-		CSetting::SetParam("setting_printer_pay_big", "0");
-	}
-	else
-	{
-		CSetting::SetParam("setting_printer_pay_big", "1");
-	}
-	}
+    else if(name == _T("setting_printer_quhuo_big"))
+    {
+        CCheckBoxUI* box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_quhuo_big")));
+
+        if(box->IsSelected())
+        {
+            CSetting::SetParam("setting_printer_quhuo_big", "0");
+        }
+        else
+        {
+            CSetting::SetParam("setting_printer_quhuo_big", "1");
+        }
+    }
+    else if(name == _T("setting_printer_dingdanhao_big"))
+    {
+        CCheckBoxUI* box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_dingdanhao_big")));
+
+        if(box->IsSelected())
+        {
+            CSetting::SetParam("setting_printer_dingdanhao_big", "0");
+        }
+        else
+        {
+            CSetting::SetParam("setting_printer_dingdanhao_big", "1");
+        }
+    }
+    else if(name == _T("setting_printer_xiadanshijian_big"))
+    {
+        CCheckBoxUI* box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_xiadanshijian_big")));
+
+        if(box->IsSelected())
+        {
+            CSetting::SetParam("setting_printer_xiadanshijian_big", "0");
+        }
+        else
+        {
+            CSetting::SetParam("setting_printer_xiadanshijian_big", "1");
+        }
+    }
+    else if(name == _T("setting_printer_peisongshijian_big"))
+    {
+        CCheckBoxUI* box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_peisongshijian_big")));
+
+        if(box->IsSelected())
+        {
+            CSetting::SetParam("setting_printer_peisongshijian_big", "0");
+        }
+        else
+        {
+            CSetting::SetParam("setting_printer_peisongshijian_big", "1");
+        }
+    }
+    else if(name == _T("setting_printer_name_big"))
+    {
+        CCheckBoxUI* box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_name_big")));
+
+        if(box->IsSelected())
+        {
+            CSetting::SetParam("setting_printer_name_big", "0");
+        }
+        else
+        {
+            CSetting::SetParam("setting_printer_name_big", "1");
+        }
+    }
+    else if(name == _T("setting_printer_phone_big"))
+    {
+        CCheckBoxUI* box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_phone_big")));
+
+        if(box->IsSelected())
+        {
+            CSetting::SetParam("setting_printer_phone_big", "0");
+        }
+        else
+        {
+            CSetting::SetParam("setting_printer_phone_big", "1");
+        }
+    }
+    else if(name == _T("setting_printer_address_big"))
+    {
+        CCheckBoxUI* box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_address_big")));
+
+        if(box->IsSelected())
+        {
+            CSetting::SetParam("setting_printer_address_big", "0");
+        }
+        else
+        {
+            CSetting::SetParam("setting_printer_address_big", "1");
+        }
+    }
+    else if(name == _T("setting_printer_shangpin_big"))
+    {
+        CCheckBoxUI* box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_shangpin_big")));
+
+        if(box->IsSelected())
+        {
+            CSetting::SetParam("setting_printer_shangpin_big", "0");
+        }
+        else
+        {
+            CSetting::SetParam("setting_printer_shangpin_big", "1");
+        }
+    }
+    else if(name == _T("setting_printer_memo_big"))
+    {
+        CCheckBoxUI* box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_memo_big")));
+
+        if(box->IsSelected())
+        {
+            CSetting::SetParam("setting_printer_memo_big", "0");
+        }
+        else
+        {
+            CSetting::SetParam("setting_printer_memo_big", "1");
+        }
+    }
+    else if(name == _T("setting_printer_price_big"))
+    {
+        CCheckBoxUI* box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_price_big")));
+
+        if(box->IsSelected())
+        {
+            CSetting::SetParam("setting_printer_price_big", "0");
+        }
+        else
+        {
+            CSetting::SetParam("setting_printer_price_big", "1");
+        }
+    }
+    else if(name == _T("setting_printer_pay_big"))
+    {
+        CCheckBoxUI* box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_pay_big")));
+
+        if(box->IsSelected())
+        {
+            CSetting::SetParam("setting_printer_pay_big", "0");
+        }
+        else
+        {
+            CSetting::SetParam("setting_printer_pay_big", "1");
+        }
+    }
 
     else if(name == _T("setting_is_new_waimai_chufang_printer"))
     {
@@ -865,24 +865,24 @@ void CMainWnd::HandleClickMsg(TNotifyUI& msg)
 
         pPrinterList->Remove(pEle);
     }
-	else if (name == _T("setting_logout"))
-	{
-		//退出登录
-		CSetting::SetParam("setting_is_auto_login", "0", true);
+    else if(name == _T("setting_logout"))
+    {
+        //退出登录
+        CSetting::SetParam("setting_is_auto_login", "0", true);
 
-		CLoginWnd* pLogin = new CLoginWnd();
-		if (pLogin == NULL)
-		{
-			return;
-		}
-		pLogin->Create(NULL, _T("智铺子收银软件登录"), UI_WNDSTYLE_DIALOG, 0, 0, 0, 0, 0, NULL);
-		pLogin->SetIcon(IDI_ICON_DUILIB);
-		pLogin->CenterWindow();
+        CLoginWnd* pLogin = new CLoginWnd();
+        if(pLogin == NULL)
+        {
+            return;
+        }
+        pLogin->Create(NULL, _T("智铺子收银软件登录"), UI_WNDSTYLE_DIALOG, 0, 0, 0, 0, 0, NULL);
+        pLogin->SetIcon(IDI_ICON_DUILIB);
+        pLogin->CenterWindow();
 
-		::ShowWindow(*pLogin, SW_SHOWNORMAL);
+        ::ShowWindow(*pLogin, SW_SHOWNORMAL);
 
-		Close();
-	}
+        Close();
+    }
 }
 
 void CMainWnd::HandleSelectChangeMsg(TNotifyUI& msg)
@@ -1092,12 +1092,12 @@ LRESULT CMainWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
     case  WM_SHOWTASK:
         lRes = OnTrayIcon(uMsg, wParam, lParam, bHandled);
         break;
-	case WM_ORDERLIST_REFRESH:
-		lRes = OnOrderlistRefresh(uMsg, wParam, lParam, bHandled);
-		break;
-	case WM_LOGIN_AGAIN_OUT:
-		lRes = OnLoginOut(uMsg, wParam, lParam, bHandled);
-		break;
+    case WM_ORDERLIST_REFRESH:
+        lRes = OnOrderlistRefresh(uMsg, wParam, lParam, bHandled);
+        break;
+    case WM_LOGIN_AGAIN_OUT:
+        lRes = OnLoginOut(uMsg, wParam, lParam, bHandled);
+        break;
     default:
         bHandled = FALSE;
     }
@@ -1219,8 +1219,8 @@ LRESULT CMainWnd::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled
 
 LRESULT CMainWnd::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
 {
-	bHandled = FALSE;
-	return 0;
+    bHandled = FALSE;
+    return 0;
 }
 
 /*
@@ -1228,30 +1228,30 @@ LRESULT CMainWnd::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandle
  **/
 LRESULT CMainWnd::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
 {
-	//直接退出程序,或者退出登录都会执行这个
-	m_push->Stop();
+    //直接退出程序,或者退出登录都会执行这个
+    m_push->Stop();
 
-	bHandled = FALSE;
-	return 0;
+    bHandled = FALSE;
+    return 0;
 }
 
 LRESULT CMainWnd::OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
 {
-	if (::IsIconic(*this))
-	{
-		bHandled = FALSE;
-	}
-	return (wParam == 0) ? TRUE : FALSE;
+    if(::IsIconic(*this))
+    {
+        bHandled = FALSE;
+    }
+    return (wParam == 0) ? TRUE : FALSE;
 }
 
 LRESULT CMainWnd::OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
 {
-	return 0;
+    return 0;
 }
 
 LRESULT CMainWnd::OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
 {
-	return 0;
+    return 0;
 }
 
 LRESULT CMainWnd::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
@@ -1385,27 +1385,27 @@ LRESULT CMainWnd::OnTrayIcon(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHan
 
 LRESULT CMainWnd::OnOrderlistRefresh(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
 {
-	OrderListUI* orderlist = static_cast<OrderListUI*>(m_pm.FindControl(_T("orderlist")));
-	orderlist->DoRefresh();
+    OrderListUI* orderlist = static_cast<OrderListUI*>(m_pm.FindControl(_T("orderlist")));
+    orderlist->DoRefresh();
 
-	return 1;
+    return 1;
 }
 
 LRESULT CMainWnd::OnLoginOut(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
 {
-	LoginOut(2);
+    LoginOut(2);
 
-	bHandled = true;
-	return 1;
+    bHandled = true;
+    return 1;
 }
 
 void CMainWnd::InitSettingStatus()
 {
-	CLabelUI* name_version = static_cast<CLabelUI*>(m_pm.FindControl(_T("main_name_version")));
-	name_version->SetText((L"智铺子收银软件 " + CLewaimaiString::UTF8ToUnicode(CSystem::GetVersion())).c_str());
+    CLabelUI* name_version = static_cast<CLabelUI*>(m_pm.FindControl(_T("main_name_version")));
+    name_version->SetText((L"智铺子收银软件 " + CLewaimaiString::UTF8ToUnicode(CSystem::GetVersion())).c_str());
 
-	CLabelUI* version = static_cast<CLabelUI*>(m_pm.FindControl(_T("setting_version")));
-	version->SetText((L"版本号:" + CLewaimaiString::UTF8ToUnicode(CSystem::GetVersion())).c_str());
+    CLabelUI* version = static_cast<CLabelUI*>(m_pm.FindControl(_T("setting_version")));
+    version->SetText((L"版本号:" + CLewaimaiString::UTF8ToUnicode(CSystem::GetVersion())).c_str());
 
     CCheckBoxUI* box = NULL;
     CComboUI* com = NULL;
@@ -1503,126 +1503,126 @@ void CMainWnd::InitSettingStatus()
         com->SetText(L"4联");
     }
 
-	box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_quhuo_big")));
-
-	if (CSetting::GetParam("setting_printer_quhuo_big") == "1")
-	{
-		box->Selected(true, false);
-	}
-	else
-	{
-		box->Selected(false, false);
-	}
-
-	box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_dingdanhao_big")));
-
-	if (CSetting::GetParam("setting_printer_dingdanhao_big") == "1")
-	{
-		box->Selected(true, false);
-	}
-	else
-	{
-		box->Selected(false, false);
-	}
-
-	box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_xiadanshijian_big")));
-
-	if (CSetting::GetParam("setting_printer_xiadanshijian_big") == "1")
-	{
-		box->Selected(true, false);
-	}
-	else
-	{
-		box->Selected(false, false);
-	}
-
-	box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_peisongshijian_big")));
-
-	if (CSetting::GetParam("setting_printer_peisongshijian_big") == "1")
-	{
-		box->Selected(true, false);
-	}
-	else
-	{
-		box->Selected(false, false);
-	}
-
-	box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_name_big")));
-
-	if (CSetting::GetParam("setting_printer_name_big") == "1")
-	{
-		box->Selected(true, false);
-	}
-	else
-	{
-		box->Selected(false, false);
-	}
-
-	box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_phone_big")));
-
-	if (CSetting::GetParam("setting_printer_phone_big") == "1")
-	{
-		box->Selected(true, false);
-	}
-	else
-	{
-		box->Selected(false, false);
-	}
-
-	box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_address_big")));
-
-	if (CSetting::GetParam("setting_printer_address_big") == "1")
-	{
-		box->Selected(true, false);
-	}
-	else
-	{
-		box->Selected(false, false);
-	}
-
-	box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_shangpin_big")));
-
-	if (CSetting::GetParam("setting_printer_shangpin_big") == "1")
-	{
-		box->Selected(true, false);
-	}
-	else
-	{
-		box->Selected(false, false);
-	}
-
-	box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_memo_big")));
-
-	if (CSetting::GetParam("setting_printer_memo_big") == "1")
-	{
-		box->Selected(true, false);
-	}
-	else
-	{
-		box->Selected(false, false);
-	}
-
-	box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_price_big")));
-
-	if (CSetting::GetParam("setting_printer_price_big") == "1")
-	{
-		box->Selected(true, false);
-	}
-	else
-	{
-		box->Selected(false, false);
-	}
-
-	box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_pay_big")));
-
-	if (CSetting::GetParam("setting_printer_pay_big") == "1")
-	{
-		box->Selected(true, false);
-	}
-	else
-	{
-		box->Selected(false, false);
-	}
+    box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_quhuo_big")));
+
+    if(CSetting::GetParam("setting_printer_quhuo_big") == "1")
+    {
+        box->Selected(true, false);
+    }
+    else
+    {
+        box->Selected(false, false);
+    }
+
+    box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_dingdanhao_big")));
+
+    if(CSetting::GetParam("setting_printer_dingdanhao_big") == "1")
+    {
+        box->Selected(true, false);
+    }
+    else
+    {
+        box->Selected(false, false);
+    }
+
+    box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_xiadanshijian_big")));
+
+    if(CSetting::GetParam("setting_printer_xiadanshijian_big") == "1")
+    {
+        box->Selected(true, false);
+    }
+    else
+    {
+        box->Selected(false, false);
+    }
+
+    box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_peisongshijian_big")));
+
+    if(CSetting::GetParam("setting_printer_peisongshijian_big") == "1")
+    {
+        box->Selected(true, false);
+    }
+    else
+    {
+        box->Selected(false, false);
+    }
+
+    box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_name_big")));
+
+    if(CSetting::GetParam("setting_printer_name_big") == "1")
+    {
+        box->Selected(true, false);
+    }
+    else
+    {
+        box->Selected(false, false);
+    }
+
+    box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_phone_big")));
+
+    if(CSetting::GetParam("setting_printer_phone_big") == "1")
+    {
+        box->Selected(true, false);
+    }
+    else
+    {
+        box->Selected(false, false);
+    }
+
+    box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_address_big")));
+
+    if(CSetting::GetParam("setting_printer_address_big") == "1")
+    {
+        box->Selected(true, false);
+    }
+    else
+    {
+        box->Selected(false, false);
+    }
+
+    box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_shangpin_big")));
+
+    if(CSetting::GetParam("setting_printer_shangpin_big") == "1")
+    {
+        box->Selected(true, false);
+    }
+    else
+    {
+        box->Selected(false, false);
+    }
+
+    box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_memo_big")));
+
+    if(CSetting::GetParam("setting_printer_memo_big") == "1")
+    {
+        box->Selected(true, false);
+    }
+    else
+    {
+        box->Selected(false, false);
+    }
+
+    box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_price_big")));
+
+    if(CSetting::GetParam("setting_printer_price_big") == "1")
+    {
+        box->Selected(true, false);
+    }
+    else
+    {
+        box->Selected(false, false);
+    }
+
+    box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_printer_pay_big")));
+
+    if(CSetting::GetParam("setting_printer_pay_big") == "1")
+    {
+        box->Selected(true, false);
+    }
+    else
+    {
+        box->Selected(false, false);
+    }
 
     box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_is_new_waimai_chufang_printer")));
 
@@ -1815,23 +1815,23 @@ void CMainWnd::InitSettingStatus()
 
 void CMainWnd::LoginOut(int mode)
 {
-	CSetting::SetParam("setting_is_auto_login", "0", true);
+    CSetting::SetParam("setting_is_auto_login", "0", true);
 
-	CLoginWnd* pLogin = new CLoginWnd();
-	if (pLogin == NULL)
-	{
-		return;
-	}
+    CLoginWnd* pLogin = new CLoginWnd();
+    if(pLogin == NULL)
+    {
+        return;
+    }
 
-	//设置模式
-	pLogin->SetMode(mode);
+    //设置模式
+    pLogin->SetMode(mode);
 
-	pLogin->Create(NULL, _T("乐外卖接单软件登录"), UI_WNDSTYLE_DIALOG, 0, 0, 0, 0, 0, NULL);
-	pLogin->SetIcon(IDI_ICON_DUILIB);
-	pLogin->CenterWindow();
+    pLogin->Create(NULL, _T("乐外卖接单软件登录"), UI_WNDSTYLE_DIALOG, 0, 0, 0, 0, 0, NULL);
+    pLogin->SetIcon(IDI_ICON_DUILIB);
+    pLogin->CenterWindow();
 
-	::ShowWindow(*pLogin, SW_SHOWNORMAL);
+    ::ShowWindow(*pLogin, SW_SHOWNORMAL);
 
-	Close();
+    Close();
 }
 

+ 3 - 3
zhipuzi_pos_windows/wnd/CMainWnd.h

@@ -65,9 +65,9 @@ public:
 
     LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
 
-	LRESULT OnOrderlistRefresh(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+    LRESULT OnOrderlistRefresh(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
 
-	LRESULT OnLoginOut(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+    LRESULT OnLoginOut(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
 
     //添加托盘图标(初始化)
     void AddTrayIcon();
@@ -75,7 +75,7 @@ public:
     //处理托盘图标上的事件
     LRESULT OnTrayIcon(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
 
-	void LoginOut(int mode);
+    void LoginOut(int mode);
 
 public:
     CPaintManagerUI m_pm;

+ 77 - 77
zhipuzi_pos_windows/wnd/CMessageboxWnd.cpp

@@ -3,99 +3,99 @@
 
 LRESULT CMessageboxWnd::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);
+    POINT pt;
+    pt.x = GET_X_LPARAM(lParam);
+    pt.y = GET_Y_LPARAM(lParam);
+    ::ScreenToClient(*this, &pt);
 
-	RECT rcClient;
-	::GetClientRect(*this, &rcClient);
+    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;
-		}
-	}
+    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;
+    return HTCLIENT;
 }
 
 LRESULT CMessageboxWnd::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);
-	}
+    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;
+    bHandled = FALSE;
+    return 0;
 }
 
 LRESULT CMessageboxWnd::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 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 CMessageboxWnd::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;
+    if(uMsg == WM_KEYDOWN)
+    {
+        if(wParam == VK_RETURN)
+        {
+            return true;
+        }
+        else if(wParam == VK_ESCAPE)
+        {
+            return true;
+        }
+    }
+    return false;
 }
 
 

+ 68 - 68
zhipuzi_pos_windows/wnd/CMessageboxWnd.h

@@ -6,98 +6,98 @@
 class CMessageboxWnd : public CWindowWnd, public INotifyUI, public IMessageFilterUI
 {
 public:
-	LPCTSTR GetWindowClassName() const
-	{
-		return _T("UIMessageboxFrame");
-	};
+    LPCTSTR GetWindowClassName() const
+    {
+        return _T("UIMessageboxFrame");
+    };
 
-	UINT GetClassStyle() const
-	{
-		return UI_CLASSSTYLE_DIALOG;
-	};
+    UINT GetClassStyle() const
+    {
+        return UI_CLASSSTYLE_DIALOG;
+    };
 
-	void OnFinalMessage(HWND /*hWnd*/)
-	{
-		//WindowImplBase::OnFinalMessage(hWnd);
-		m_pm.RemovePreMessageFilter(this);
+    void OnFinalMessage(HWND /*hWnd*/)
+    {
+        //WindowImplBase::OnFinalMessage(hWnd);
+        m_pm.RemovePreMessageFilter(this);
 
-		//delete this;
-	};
+        //delete this;
+    };
 
-	void Init()
-	{
+    void Init()
+    {
 
-	}
+    }
 
-	void Notify(TNotifyUI& msg)
-	{
-		if (msg.sType == _T("click"))
-		{
-			DuiLib::CDuiString senderName = msg.pSender->GetName();
+    void Notify(TNotifyUI& msg)
+    {
+        if(msg.sType == _T("click"))
+        {
+            DuiLib::CDuiString senderName = msg.pSender->GetName();
 
-			if (senderName == _T("messagebox_dlg_closebtn"))
-			{
-				Close(IDCANCEL);
-				return;
-			}
-		}
-	}
+            if(senderName == _T("messagebox_dlg_closebtn"))
+            {
+                Close(IDCANCEL);
+                return;
+            }
+        }
+    }
 
-	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);
+    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.Init(m_hWnd);
 
-		m_pm.AddPreMessageFilter(this);
+        m_pm.AddPreMessageFilter(this);
 
-		CDialogBuilder builder;
+        CDialogBuilder builder;
 
-		CControlUI* pRoot = builder.Create(_T("messagebox_dlg.xml"), (UINT)0, NULL, &m_pm);
-		ASSERT(pRoot && "Failed to parse XML");
+        CControlUI* pRoot = builder.Create(_T("messagebox_dlg.xml"), (UINT)0, NULL, &m_pm);
+        ASSERT(pRoot && "Failed to parse XML");
 
-		// 把这些控件绘制到本窗口上
-		m_pm.AttachDialog(pRoot);
+        // 把这些控件绘制到本窗口上
+        m_pm.AttachDialog(pRoot);
 
-		// 把自己加入到CPaintManagerUI的m_aNotifiers数组中,用于处理Notify函数
-		m_pm.AddNotifier(this);
+        // 把自己加入到CPaintManagerUI的m_aNotifiers数组中,用于处理Notify函数
+        m_pm.AddNotifier(this);
 
-		Init();
+        Init();
 
-		return 0;
-	}
+        return 0;
+    }
 
-	LRESULT OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
-	{
-		if (::IsIconic(*this))
-		{
-			bHandled = FALSE;
-		}
-		return (wParam == 0) ? TRUE : FALSE;
-	}
+    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 OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+    {
+        return 0;
+    }
 
-	LRESULT OnNcPaint(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 OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
 
-	LRESULT OnSize(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 HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
 
-	LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled);
+    LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled);
 
 public:
-	CPaintManagerUI m_pm;
+    CPaintManagerUI m_pm;
 };
 

+ 58 - 59
zhipuzi_pos_windows/wnd/CUpdateWnd.cpp

@@ -203,9 +203,9 @@ LRESULT CUpdateWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
     case WM_UPDATEPROGRESS:
         lRes = OnRefresh(uMsg, wParam, lParam, bHandled);
         break;
-	case  WM_DOWNLOAD_FINISH:
-		lRes = OnDownloadFinish(uMsg, wParam, lParam, bHandled);
-		break;
+    case  WM_DOWNLOAD_FINISH:
+        lRes = OnDownloadFinish(uMsg, wParam, lParam, bHandled);
+        break;
     default:
         bHandled = FALSE;
     }
@@ -230,29 +230,29 @@ LRESULT CUpdateWnd::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool
 
 std::string CUpdateWnd::GetFileNameFormUrl(std::string url)
 {
-	char fileName[512] = { 0 };
-
-	int urlLen = strlen(url.c_str());
-	char mUrl[512] = { 0 };
-	char fName[256] = { 0 };
-	strcpy(mUrl, url.c_str());
-	int cutIndex = 0;
-	int i = urlLen - 1, j = 0;
-	while (mUrl[--i] != '/');
-	i++;
-	while (mUrl[i] != '\0' && mUrl[i] != '?' &&mUrl[i] != '&')
-	{
-		fName[j++] = mUrl[i++];
-	}
-	fName[j] = '\0';
-	strcpy(fileName, fName);
-
-	return fileName;
+    char fileName[512] = { 0 };
+
+    int urlLen = strlen(url.c_str());
+    char mUrl[512] = { 0 };
+    char fName[256] = { 0 };
+    strcpy(mUrl, url.c_str());
+    int cutIndex = 0;
+    int i = urlLen - 1, j = 0;
+    while(mUrl[--i] != '/');
+    i++;
+    while(mUrl[i] != '\0' && mUrl[i] != '?' && mUrl[i] != '&')
+    {
+        fName[j++] = mUrl[i++];
+    }
+    fName[j] = '\0';
+    strcpy(fileName, fName);
+
+    return fileName;
 }
 
 double CUpdateWnd::getDownloadFileLength(std::string url)
 {
-    CURL *easy_handle = NULL;
+    CURL* easy_handle = NULL;
     int ret = CURLE_OK;
     double size = -1;
 
@@ -267,13 +267,13 @@ double CUpdateWnd::getDownloadFileLength(std::string url)
 
         // Only get the header data
         ret = curl_easy_setopt(easy_handle, CURLOPT_URL, url.c_str());
-		
-		if (url.find("https://") == 0)
-		{
-			ret |= curl_easy_setopt(easy_handle, CURLOPT_SSL_VERIFYPEER, false);
-			ret |= curl_easy_setopt(easy_handle, CURLOPT_SSL_VERIFYHOST, false);
-		}
-		
+
+        if(url.find("https://") == 0)
+        {
+            ret |= curl_easy_setopt(easy_handle, CURLOPT_SSL_VERIFYPEER, false);
+            ret |= curl_easy_setopt(easy_handle, CURLOPT_SSL_VERIFYHOST, false);
+        }
+
         ret |= curl_easy_setopt(easy_handle, CURLOPT_HEADER, 1L);
         ret |= curl_easy_setopt(easy_handle, CURLOPT_NOBODY, 1L);
         ret |= curl_easy_setopt(easy_handle, CURLOPT_WRITEFUNCTION, nousecb);    // libcurl_a.lib will return error code 23 without this sentence on windows
@@ -302,8 +302,7 @@ double CUpdateWnd::getDownloadFileLength(std::string url)
             break;
         }
 
-    }
-    while(0);
+    } while(0);
 
     curl_easy_cleanup(easy_handle);
 
@@ -312,7 +311,7 @@ double CUpdateWnd::getDownloadFileLength(std::string url)
 
 void CUpdateWnd::Run()
 {
-	m_filepath = m_dir + GetFileNameFormUrl(m_url);
+    m_filepath = m_dir + GetFileNameFormUrl(m_url);
 
     CURLcode res;
 
@@ -333,13 +332,13 @@ void CUpdateWnd::Run()
         m_outfile = fopen(m_filepath.c_str(), "ab+");
 
         curl_easy_setopt(m_curl, CURLOPT_URL, m_url.c_str());//在此要注意,此url必须是多字节
-		
-		if (m_url.find("https://") == 0)
-		{
-			curl_easy_setopt(m_curl, CURLOPT_SSL_VERIFYPEER, false);
-			curl_easy_setopt(m_curl, CURLOPT_SSL_VERIFYHOST, false);
-		}
-		
+
+        if(m_url.find("https://") == 0)
+        {
+            curl_easy_setopt(m_curl, CURLOPT_SSL_VERIFYPEER, false);
+            curl_easy_setopt(m_curl, CURLOPT_SSL_VERIFYHOST, false);
+        }
+
         curl_easy_setopt(m_curl, CURLOPT_TIMEOUT, 0);
         curl_easy_setopt(m_curl, CURLOPT_WRITEDATA, m_outfile);
         curl_easy_setopt(m_curl, CURLOPT_WRITEFUNCTION, my_write_func);
@@ -354,15 +353,15 @@ void CUpdateWnd::Run()
         curl_easy_cleanup(m_curl);
     }
 
-	//走到这里,下载完成了
-	HWND hWnd = FindWindow(NULL, L"自动更新");
+    //走到这里,下载完成了
+    HWND hWnd = FindWindow(NULL, L"自动更新");
 
-	if (hWnd)
-	{
-		::PostMessage(hWnd, WM_DOWNLOAD_FINISH, 0, 0);
-	}
+    if(hWnd)
+    {
+        ::PostMessage(hWnd, WM_DOWNLOAD_FINISH, 0, 0);
+    }
 }
-size_t CUpdateWnd::my_write_func(void *ptr, size_t size, size_t nmemb, FILE *stream)
+size_t CUpdateWnd::my_write_func(void* ptr, size_t size, size_t nmemb, FILE* stream)
 {
     size_t nWrite = fwrite(ptr, size, nmemb, stream);
 
@@ -377,20 +376,20 @@ size_t CUpdateWnd::my_write_func(void *ptr, size_t size, size_t nmemb, FILE *str
     }
 }
 
-int CUpdateWnd::my_progress_func(void *progress_data,
+int CUpdateWnd::my_progress_func(void* progress_data,
                                  double t, /* dltotal */
                                  double d, /* dlnow */
                                  double ultotal,
                                  double ulnow)
 {
-	if (t > 0)
-	{
-		CUpdateWnd::m_Percent = d * 100.0 / t;
-	}
-	else
-	{
-		CUpdateWnd::m_Percent = 0;
-	}
+    if(t > 0)
+    {
+        CUpdateWnd::m_Percent = d * 100.0 / t;
+    }
+    else
+    {
+        CUpdateWnd::m_Percent = 0;
+    }
 
     HWND hWnd = FindWindow(NULL, L"自动更新");
 
@@ -402,7 +401,7 @@ int CUpdateWnd::my_progress_func(void *progress_data,
     return 0;
 }
 
-size_t CUpdateWnd::nousecb(char *buffer, size_t x, size_t y, void *userdata)
+size_t CUpdateWnd::nousecb(char* buffer, size_t x, size_t y, void* userdata)
 {
     (void)buffer;
     (void)userdata;
@@ -423,9 +422,9 @@ LRESULT CUpdateWnd::OnRefresh(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHa
 
 LRESULT CUpdateWnd::OnDownloadFinish(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
 {
-	HINSTANCE hNewExe = ShellExecuteA(NULL, "open", m_filepath.c_str(), NULL, NULL, SW_SHOW);
+    HINSTANCE hNewExe = ShellExecuteA(NULL, "open", m_filepath.c_str(), NULL, NULL, SW_SHOW);
 
-	PostQuitMessage(0);
+    PostQuitMessage(0);
 
-	return 0;
+    return 0;
 }

+ 16 - 16
zhipuzi_pos_windows/wnd/CUpdateWnd.h

@@ -24,11 +24,11 @@ public:
         delete this;
     };
 
-	void InitData(std::string url, std::string dir)
-	{
-		m_url = url;
-		m_dir = dir;
-	}
+    void InitData(std::string url, std::string dir)
+    {
+        m_url = url;
+        m_dir = dir;
+    }
 
     void Init();
 
@@ -56,30 +56,30 @@ public:
 
     LRESULT OnRefresh(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
 
-	LRESULT OnDownloadFinish(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+    LRESULT OnDownloadFinish(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
 
-	std::string GetFileNameFormUrl(std::string url);
+    std::string GetFileNameFormUrl(std::string url);
 
-	static size_t nousecb(char *buffer, size_t x, size_t y, void *userdata);
+    static size_t nousecb(char* buffer, size_t x, size_t y, void* userdata);
 
     double getDownloadFileLength(std::string url);
 
     void Run();
 
-    static size_t my_write_func(void *ptr, size_t size, size_t nmemb, FILE *stream);
+    static size_t my_write_func(void* ptr, size_t size, size_t nmemb, FILE* stream);
 
-    static int my_progress_func(void *progress_data,
-                         double t, /* dltotal */
-                         double d, /* dlnow */
-                         double ultotal,
-                         double ulnow);
+    static int my_progress_func(void* progress_data,
+                                double t, /* dltotal */
+                                double d, /* dlnow */
+                                double ultotal,
+                                double ulnow);
 public:
     CPaintManagerUI m_pm;
 
     string m_dir;//目录名
-	std::string m_filepath; //完成文件在本地的路径名
+    std::string m_filepath; //完成文件在本地的路径名
 
-	CURL* m_curl;//libcurl句柄
+    CURL* m_curl;//libcurl句柄
 
     double m_downloadFileLength;//服务器文件长度
 

+ 77 - 77
zhipuzi_pos_windows/wnd/CWaimaiOrderFailReasonWnd.cpp

@@ -3,99 +3,99 @@
 
 LRESULT CWaimaiOrderFailReasonWnd::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);
+    POINT pt;
+    pt.x = GET_X_LPARAM(lParam);
+    pt.y = GET_Y_LPARAM(lParam);
+    ::ScreenToClient(*this, &pt);
 
-	RECT rcClient;
-	::GetClientRect(*this, &rcClient);
+    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;
-		}
-	}
+    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;
+    return HTCLIENT;
 }
 
 LRESULT CWaimaiOrderFailReasonWnd::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);
-	}
+    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;
+    bHandled = FALSE;
+    return 0;
 }
 
 LRESULT CWaimaiOrderFailReasonWnd::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 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 CWaimaiOrderFailReasonWnd::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;
+    if(uMsg == WM_KEYDOWN)
+    {
+        if(wParam == VK_RETURN)
+        {
+            return true;
+        }
+        else if(wParam == VK_ESCAPE)
+        {
+            return true;
+        }
+    }
+    return false;
 }
 
 

+ 107 - 107
zhipuzi_pos_windows/wnd/CWaimaiOrderFailReasonWnd.h

@@ -6,116 +6,116 @@
 class CWaimaiOrderFailReasonWnd : public CWindowWnd, public INotifyUI, public IMessageFilterUI
 {
 public:
-	LPCTSTR GetWindowClassName() const
-	{
-		return _T("UIWaimaiOrderFailFrame");
-	};
-
-	UINT GetClassStyle() const
-	{
-		return UI_CLASSSTYLE_DIALOG;
-	};
-
-	void OnFinalMessage(HWND /*hWnd*/)
-	{
-		//WindowImplBase::OnFinalMessage(hWnd);
-		m_pm.RemovePreMessageFilter(this);
-		
-		//delete this;
-	};
-
-	void Init()
-	{
-		
-	}
-
-	std::string getReason()
-	{
-		return m_reason;
-	}
-
-	void Notify(TNotifyUI& msg)
-	{
-		if (msg.sType == _T("click"))
-		{
-			DuiLib::CDuiString senderName = msg.pSender->GetName();
-
-			if (senderName == _T("waimai_order_fail_dlg_closebtn"))
-			{
-				Close(IDCANCEL);
-				return;
-			}
-			else if (senderName == _T("waimai_order_fail_dlg_save"))
-			{
-				//开始保存厨房打印机的数据
-				CEditUI* pReason = static_cast<CEditUI*>(m_pm.FindControl(_T("waimai_order_fail_dlg_reason")));
-				wstring wsReason = pReason->GetText();
-
-				m_reason = CLewaimaiString::UnicodeToUTF8(wsReason);
-
-				Close(IDOK);
-				return;
-			}
-		}
-	}
-
-	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("waimai_order_fail_reason_dlg.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);
+    LPCTSTR GetWindowClassName() const
+    {
+        return _T("UIWaimaiOrderFailFrame");
+    };
 
-	LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled);
+    UINT GetClassStyle() const
+    {
+        return UI_CLASSSTYLE_DIALOG;
+    };
+
+    void OnFinalMessage(HWND /*hWnd*/)
+    {
+        //WindowImplBase::OnFinalMessage(hWnd);
+        m_pm.RemovePreMessageFilter(this);
+
+        //delete this;
+    };
+
+    void Init()
+    {
+
+    }
+
+    std::string getReason()
+    {
+        return m_reason;
+    }
+
+    void Notify(TNotifyUI& msg)
+    {
+        if(msg.sType == _T("click"))
+        {
+            DuiLib::CDuiString senderName = msg.pSender->GetName();
+
+            if(senderName == _T("waimai_order_fail_dlg_closebtn"))
+            {
+                Close(IDCANCEL);
+                return;
+            }
+            else if(senderName == _T("waimai_order_fail_dlg_save"))
+            {
+                //开始保存厨房打印机的数据
+                CEditUI* pReason = static_cast<CEditUI*>(m_pm.FindControl(_T("waimai_order_fail_dlg_reason")));
+                wstring wsReason = pReason->GetText();
+
+                m_reason = CLewaimaiString::UnicodeToUTF8(wsReason);
+
+                Close(IDOK);
+                return;
+            }
+        }
+    }
+
+    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("waimai_order_fail_reason_dlg.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;
+    CPaintManagerUI m_pm;
 
-	std::string m_reason;
+    std::string m_reason;
 };