zhangyang hace 6 años
padre
commit
d9e27095ca
Se han modificado 63 ficheros con 12027 adiciones y 0 borrados
  1. BIN
      zhipuzi_pay_plugin/.vs/zhipuzi_pos_windows/v15/.suo
  2. BIN
      zhipuzi_pay_plugin/.vs/zhipuzi_pos_windows/v15/Browse.VC.db
  3. 19 0
      zhipuzi_pay_plugin/control/CSettingUI.cpp
  4. 13 0
      zhipuzi_pay_plugin/control/CSettingUI.h
  5. 531 0
      zhipuzi_pay_plugin/control/CWaimaiOrderInfoUI.cpp
  6. 26 0
      zhipuzi_pay_plugin/control/CWaimaiOrderInfoUI.h
  7. 171 0
      zhipuzi_pay_plugin/control/CWaimaiOrderItemUI.cpp
  8. 55 0
      zhipuzi_pay_plugin/control/CWaimaiOrderItemUI.h
  9. 34 0
      zhipuzi_pay_plugin/control/ControlEx.h
  10. 235 0
      zhipuzi_pay_plugin/control/OrderListUI.cpp
  11. 47 0
      zhipuzi_pay_plugin/control/OrderListUI.h
  12. 395 0
      zhipuzi_pay_plugin/helper/CLewaimaiString.cpp
  13. 44 0
      zhipuzi_pay_plugin/helper/CLewaimaiString.h
  14. 11 0
      zhipuzi_pay_plugin/helper/CRandomHelper.cpp
  15. 40 0
      zhipuzi_pay_plugin/helper/CRandomHelper.h
  16. 32 0
      zhipuzi_pay_plugin/helper/CSystem.cpp
  17. 153 0
      zhipuzi_pay_plugin/helper/CSystem.h
  18. 350 0
      zhipuzi_pay_plugin/helper/MD5.cpp
  19. 47 0
      zhipuzi_pay_plugin/helper/MD5.h
  20. 16 0
      zhipuzi_pay_plugin/helper/define.h
  21. 217 0
      zhipuzi_pay_plugin/network/CHttpClient.cpp
  22. 54 0
      zhipuzi_pay_plugin/network/CHttpClient.h
  23. 542 0
      zhipuzi_pay_plugin/network/CMessagePush.cpp
  24. 92 0
      zhipuzi_pay_plugin/network/CMessagePush.h
  25. 238 0
      zhipuzi_pay_plugin/network/CZhipuziHttpClient.cpp
  26. 30 0
      zhipuzi_pay_plugin/network/CZhipuziHttpClient.h
  27. 10 0
      zhipuzi_pay_plugin/network/PosMessage.h
  28. 394 0
      zhipuzi_pay_plugin/order/CWaimaiOrder.cpp
  29. 125 0
      zhipuzi_pay_plugin/order/CWaimaiOrder.h
  30. 5 0
      zhipuzi_pay_plugin/pch/pch.cpp
  31. 92 0
      zhipuzi_pay_plugin/pch/pch.h
  32. 17 0
      zhipuzi_pay_plugin/resource/resource.h
  33. BIN
      zhipuzi_pay_plugin/resource/zhipuzi.ico
  34. BIN
      zhipuzi_pay_plugin/resource/zhipuzi_pay_plugin.aps
  35. BIN
      zhipuzi_pay_plugin/resource/zhipuzi_pay_plugin.rc
  36. 49 0
      zhipuzi_pay_plugin/tool/CLewaimaiLog.cpp
  37. 29 0
      zhipuzi_pay_plugin/tool/CLewaimaiLog.h
  38. 164 0
      zhipuzi_pay_plugin/tool/CLewaimaiTime.cpp
  39. 29 0
      zhipuzi_pay_plugin/tool/CLewaimaiTime.h
  40. 1663 0
      zhipuzi_pay_plugin/tool/CPosPrinter.cpp
  41. 88 0
      zhipuzi_pay_plugin/tool/CPosPrinter.h
  42. 312 0
      zhipuzi_pay_plugin/tool/CSetting.cpp
  43. 155 0
      zhipuzi_pay_plugin/tool/CSetting.h
  44. 398 0
      zhipuzi_pay_plugin/tool/CSqlite3.cpp
  45. 35 0
      zhipuzi_pay_plugin/tool/CSqlite3.h
  46. 103 0
      zhipuzi_pay_plugin/wnd/CChufangSettingWnd.cpp
  47. 347 0
      zhipuzi_pay_plugin/wnd/CChufangSettingWnd.h
  48. 609 0
      zhipuzi_pay_plugin/wnd/CLoginWnd.cpp
  49. 79 0
      zhipuzi_pay_plugin/wnd/CLoginWnd.h
  50. 2026 0
      zhipuzi_pay_plugin/wnd/CMainWnd.cpp
  51. 93 0
      zhipuzi_pay_plugin/wnd/CMainWnd.h
  52. 103 0
      zhipuzi_pay_plugin/wnd/CMessageboxWnd.cpp
  53. 103 0
      zhipuzi_pay_plugin/wnd/CMessageboxWnd.h
  54. 430 0
      zhipuzi_pay_plugin/wnd/CUpdateWnd.cpp
  55. 94 0
      zhipuzi_pay_plugin/wnd/CUpdateWnd.h
  56. 103 0
      zhipuzi_pay_plugin/wnd/CWaimaiOrderFailReasonWnd.cpp
  57. 121 0
      zhipuzi_pay_plugin/wnd/CWaimaiOrderFailReasonWnd.h
  58. 54 0
      zhipuzi_pay_plugin/zhipuzi_pay_plugin.cpp
  59. 290 0
      zhipuzi_pay_plugin/zhipuzi_pay_plugin.vcxproj
  60. 196 0
      zhipuzi_pay_plugin/zhipuzi_pay_plugin.vcxproj.filters
  61. 28 0
      zhipuzi_pay_plugin/zhipuzi_pay_plugin.vcxproj.user
  62. 287 0
      zhipuzi_pay_plugin/zhipuzi_pos_windows.vcxproj
  63. 4 0
      zhipuzi_pay_plugin/zhipuzi_pos_windows.vcxproj.user

BIN
zhipuzi_pay_plugin/.vs/zhipuzi_pos_windows/v15/.suo


BIN
zhipuzi_pay_plugin/.vs/zhipuzi_pos_windows/v15/Browse.VC.db


+ 19 - 0
zhipuzi_pay_plugin/control/CSettingUI.cpp

@@ -0,0 +1,19 @@
+#include "../pch/pch.h"
+#include "CSettingUI.h"
+
+
+
+CSettingUI::CSettingUI()
+{
+
+}
+
+
+CSettingUI::~CSettingUI()
+{
+}
+
+void CSettingUI::DoEvent(TEventUI& event)
+{
+	CVerticalLayoutUI::DoEvent(event);
+}

+ 13 - 0
zhipuzi_pay_plugin/control/CSettingUI.h

@@ -0,0 +1,13 @@
+#pragma once
+
+#include "../pch/pch.h"
+
+class CSettingUI : public CVerticalLayoutUI
+{
+public:
+	CSettingUI();
+	~CSettingUI();
+
+	void DoEvent(TEventUI& event);
+};
+

+ 531 - 0
zhipuzi_pay_plugin/control/CWaimaiOrderInfoUI.cpp

@@ -0,0 +1,531 @@
+#include "../pch/pch.h"
+#include "CWaimaiOrderInfoUI.h"
+
+#include "ControlEx.h"
+
+void CWaimaiOrderInfoUI::DoEvent(TEventUI& event)
+{
+	CVerticalLayoutUI::DoEvent(event);
+}
+
+void CWaimaiOrderInfoUI::Refresh(CWaimaiOrder& order)
+{
+	std::wstring liushuihao_show = L"#" + CLewaimaiString::UTF8ToUnicode(order.m_restaurant_number);
+	this->FindSubControl(_T("waimai_order_info_page_liushuihao"))->SetText(liushuihao_show.c_str());
+
+	std::wstring order_no_show = L"订单号:" + CLewaimaiString::UTF8ToUnicode(order.m_order_no);
+	this->FindSubControl(_T("waimai_order_info_page_order_no"))->SetText(order_no_show.c_str());
+
+	//商品详情的渲染
+	CListUI* pFoodList = static_cast<CListUI*>(this->FindSubControl(_T("waimai_order_info_page_foodlist")));
+	pFoodList->RemoveAll();
+
+	for (std::vector<CWaimaiOrderItem>::iterator it = order.m_order_items.begin(); it != order.m_order_items.end(); it++)
+	{
+		std::string food_name = (*it).m_food_name;
+		std::string food_price = (*it).m_item_price;
+		std::string quantity = (*it).m_quantity;
+
+		CDialogBuilder builder;
+		CListContainerElementUI* pEle = static_cast<CListContainerElementUI *>(builder.Create(_T("waimai_order_info_page_listitem.xml"), (UINT)0, NULL, m_pManager));
+
+		CLabelUI *pName = static_cast<CLabelUI *>(pEle->FindSubControl(_T("waimai_order_info_page_listitem_foodname")));
+		pName->SetText(CLewaimaiString::UTF8ToUnicode(food_name).c_str());
+
+		CLabelUI *pQuantity = static_cast<CLabelUI *>(pEle->FindSubControl(_T("waimai_order_info_page_listitem_quantity")));
+		pQuantity->SetText(CLewaimaiString::UTF8ToUnicode(quantity).c_str());
+
+		CLabelUI *pPrice = static_cast<CLabelUI *>(pEle->FindSubControl(_T("waimai_order_info_page_listitem_price")));
+		pPrice->SetText(CLewaimaiString::UTF8ToUnicode(food_price).c_str());
+
+		pFoodList->Add(pEle);
+	}
+
+	//重设商品列表的高度
+	int order_item_height = (order.m_order_items.size() + 1) * 30;
+	pFoodList->SetFixedHeight(order_item_height);
+
+	CLabelUI *pMemo = static_cast<CLabelUI *>(this->FindSubControl(_T("waimaorder_info_page_memo")));
+	wstring memo = _T("备注:") + CLewaimaiString::UTF8ToUnicode(order.m_memo);
+	pMemo->SetText(memo.c_str());
+
+	//开始展示各种费用
+	CVerticalLayoutUI* pFeesLayout = static_cast<CVerticalLayoutUI *>(this->FindSubControl(_T("waimai_order_info_page_fees")));
+	pFeesLayout->RemoveAll();
+
+	int fees_num = 0;
+	
+	if (order.m_delivery > 0)
+	{
+		CLabelUI *pDlieveryFee = new CLabelUI;
+		pDlieveryFee->SetFixedHeight(30);
+
+		wstring delivery_fee = L"配送费:" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString((double)order.m_delivery, 2));
+		pDlieveryFee->SetText(delivery_fee.c_str());
+
+		pFeesLayout->Add(pDlieveryFee);
+
+		fees_num++;
+	}
+
+	if (order.m_is_dabao == "1")
+	{
+		CLabelUI *pDabaoFee = new CLabelUI;
+		pDabaoFee->SetFixedHeight(30);
+
+		wstring dabao_fee = L"打包费:" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString((double)order.m_delivery, 2));
+		pDabaoFee->SetText(dabao_fee.c_str());
+
+		pFeesLayout->Add(pDabaoFee);
+
+		fees_num++;
+	}
+
+	//增值服务费
+	if (order.m_addservie.size() > 0)
+	{
+		for (std::vector<CWaimaiOrderField>::iterator it = order.m_addservie.begin(); it != order.m_addservie.end(); it++)
+		{
+			wstring addservice = CLewaimaiString::UTF8ToUnicode((*it).name) + L":" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString((double)atof((*it).value.c_str()), 2));
+
+			CLabelUI* newField = new CLabelUI();
+
+			newField->SetText(addservice.c_str());
+			newField->SetFixedHeight(30);
+
+			pFeesLayout->Add(newField);
+
+			fees_num++;
+		}
+	}
+
+	//店铺折扣
+	if (order.m_discount < 10)
+	{
+		CLabelUI *pDiscountFee = new CLabelUI;
+		pDiscountFee->SetFixedHeight(30);
+
+		wstring discount = L"店铺折扣:" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString((double)order.m_discount, 2)) + L"折";
+		pDiscountFee->SetText(discount.c_str());
+
+		pFeesLayout->Add(pDiscountFee);
+
+		fees_num++;
+	}
+
+	//会员优惠
+	if (order.m_is_member_discount == "1")
+	{
+		CLabelUI *pMemberFee = new CLabelUI;
+		pMemberFee->SetFixedHeight(30);
+
+		wstring memberfee = L"会员优惠:-" + CLewaimaiString::UTF8ToUnicode(order.m_member_discount);
+		pMemberFee->SetText(memberfee.c_str());
+
+		pFeesLayout->Add(pMemberFee);
+
+		fees_num++;
+	}
+
+	//首单优惠
+	if (order.m_is_firstcut == "1")
+	{
+		CLabelUI *pFirstCut = new CLabelUI;
+		pFirstCut->SetFixedHeight(30);
+
+		wstring firstcut = L"首单优惠:-" + CLewaimaiString::UTF8ToUnicode(order.m_firstcut_value);
+		pFirstCut->SetText(firstcut.c_str());
+
+		pFeesLayout->Add(pFirstCut);
+
+		fees_num++;
+	}
+
+	//满减
+	string::size_type position = order.m_promotion.find(":");
+	if (position != order.m_promotion.npos)
+	{
+		CLabelUI *pManjian = new CLabelUI;
+		pManjian->SetFixedHeight(30);
+
+		string promotion_value;
+		promotion_value.assign(order.m_promotion, position + 1);
+
+		wstring promotion = L"满减优惠:-" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString((double)(atof(promotion_value.c_str())), 2));
+		pManjian->SetText(promotion.c_str());
+
+		pFeesLayout->Add(pManjian);
+
+		fees_num++;
+	}
+
+	//优惠券
+	if (order.m_coupon > 0)
+	{
+		CLabelUI *pCoupon = new CLabelUI;
+		pCoupon->SetMaxHeight(30);
+
+		wstring coupon = L"优惠券:-" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString((double)order.m_coupon, 2));
+		pCoupon->SetText(coupon.c_str());
+
+		pFeesLayout->Add(pCoupon);
+
+		fees_num++;
+	}
+
+	//商品券
+	if (atof(order.m_goods_coupon_value.c_str()) > 0.0001)
+	{
+		CLabelUI *pGoodsCoupon = new CLabelUI;
+		pGoodsCoupon->SetFixedHeight(30);
+
+		wstring goods_coupon = L"商品券:-" + CLewaimaiString::UTF8ToUnicode(order.m_goods_coupon_value);
+		pGoodsCoupon->SetText(goods_coupon.c_str());
+
+		pFeesLayout->Add(pGoodsCoupon);
+
+		fees_num++;
+	}
+
+	int fees_height;
+	if (fees_num == 0)
+	{
+		pFeesLayout->SetVisible(false);
+		this->FindSubControl(_T("waimai_order_info_page_fees_line"))->SetVisible(false);
+
+		fees_height = 0;
+	}
+	else
+	{
+		pFeesLayout->SetVisible(true);
+		this->FindSubControl(_T("waimai_order_info_page_fees_line"))->SetVisible(true);
+		pFeesLayout->SetFixedHeight(fees_num * 30);
+
+		fees_height = fees_num * 30;
+	}
+
+	CLabelUI *pTotalPrice = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_totalprice")));
+	wstring price = L"总计:¥" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(order.m_price, 2));
+	pTotalPrice->SetText(price.c_str());
+
+	int nTotalHeight = order_item_height + fees_height + 133;
+	this->FindSubControl(_T("waimai_order_info_page_layout_1"))->SetFixedHeight(nTotalHeight);
+
+	//开始显示顾客信息
+	std::wstring name_show = L"姓名:" + CLewaimaiString::UTF8ToUnicode(order.m_customer_name);
+	this->FindSubControl(_T("waimai_order_info_page_name"))->SetText(name_show.c_str());
+
+	std::wstring phone_show = L"电话:" + CLewaimaiString::UTF8ToUnicode(order.m_phone);
+	this->FindSubControl(_T("waimai_order_info_page_phone"))->SetText(phone_show.c_str());
+
+	std::wstring address_show = L"地址:" + CLewaimaiString::UTF8ToUnicode(order.m_address);
+	this->FindSubControl(_T("waimai_order_info_page_address"))->SetText(address_show.c_str());
+
+	std::wstring order_date_show = L"下单时间:" + CLewaimaiString::UTF8ToUnicode(order.m_order_date);
+	this->FindSubControl(_T("waimai_order_info_page_init_date"))->SetText(order_date_show.c_str());
+
+	//开始处理骑手信息
+	if (atoi(order.m_courier_id.c_str()) > 0)
+	{
+		//有人接单了
+		this->FindSubControl(_T("waimai_order_info_page_qishouinfo"))->SetVisible(true);
+
+		std::wstring qishou_name = L"骑手姓名:" + CLewaimaiString::UTF8ToUnicode(order.m_courier_name);
+		this->FindSubControl(_T("waimai_order_info_page_qishou_name"))->SetText(qishou_name.c_str());
+
+		std::wstring qishou_phone = L"骑手电话:" + CLewaimaiString::UTF8ToUnicode(order.m_courier_phone);
+		this->FindSubControl(_T("waimai_order_info_page_qishou_phone"))->SetText(qishou_phone.c_str());
+
+		std::wstring qishou_type;
+		if (order.m_courier_type == "3")
+		{
+			qishou_type = L"骑手类型:快服务骑手";
+		}
+		else if (order.m_courier_type == "5")
+		{
+			qishou_type = L"骑手类型:达达骑手";
+		}
+		else
+		{
+			qishou_type = L"骑手类型:商家自配送骑手";
+		}
+
+		this->FindSubControl(_T("waimai_order_info_page_qishou_type"))->SetText(qishou_type.c_str());
+	}
+	else
+	{
+		this->FindSubControl(_T("waimai_order_info_page_qishouinfo"))->SetVisible(false);
+	}
+
+	//开始处理订单信息
+	if (order.m_is_selftake == "1")
+	{
+		CLabelUI *pDeliveryType = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_delivery_type")));
+		wstring wsDeliveryType = _T("配送方式:到店自取(取餐号:") + CLewaimaiString::UTF8ToUnicode(order.m_take_food_code) + _T(")");
+		pDeliveryType->SetText(wsDeliveryType.c_str());
+	}
+	else
+	{
+		CLabelUI *pDeliveryType = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_delivery_type")));
+		wstring wsDeliveryType = _T("配送方式:外卖配送");
+		pDeliveryType->SetText(wsDeliveryType.c_str());
+	}
+
+	CLabelUI *pStatus = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_status")));
+	wstring wsStatus = _T("订单状态:") + CLewaimaiString::UTF8ToUnicode(order.m_order_status);
+	if (CLewaimaiString::UTF8ToUnicode(order.m_order_status) == _T("交易失败"))
+	{
+		wsStatus += _T(",失败原因:") + CLewaimaiString::UTF8ToUnicode(order.m_failed_reason);
+	}
+	pStatus->SetText(wsStatus.c_str());
+
+	CLabelUI *pType = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_type")));
+	wstring wsType = _T("订单来源:") + CLewaimaiString::UTF8ToUnicode(order.m_from_type);
+	pType->SetText(wsType.c_str());
+
+	//预设选项
+	CVerticalLayoutUI* pLayout = static_cast<CVerticalLayoutUI *>(this->FindSubControl(_T("waimai_order_info_page_field")));
+	pLayout->RemoveAll();
+
+	int order_filed_height;
+	if (order.m_order_field.size() > 1)
+	{
+		for (std::vector<CWaimaiOrderField>::iterator it = order.m_order_field.begin(); it != order.m_order_field.end() - 1; it++)
+		{
+			wstring order_field = CLewaimaiString::UTF8ToUnicode((*it).name) + L":" + CLewaimaiString::UTF8ToUnicode((*it).value);
+
+			CLabelUI* newField = new CLabelUI();
+
+			newField->SetText(order_field.c_str());
+			newField->SetFixedHeight(30);
+
+			pLayout->Add(newField);
+		}
+
+		//这里预设选项默认有一个配送时间,所以要减1
+		pLayout->SetFixedHeight((order.m_order_field.size() - 1) * 30);
+
+		order_filed_height = (order.m_order_field.size() - 1) * 30;
+
+		pLayout->SetVisible(true);
+	}
+	else
+	{
+		order_filed_height = 0;
+
+		pLayout->SetVisible(false);
+	}
+
+	//配送时间
+	wstring delivery_date;
+	if (order.m_is_selftake == "1")
+	{
+		delivery_date = L"自取时间:" + CLewaimaiString::UTF8ToUnicode(order.m_delivery_date);
+	}
+	else
+	{
+		delivery_date = L"配送时间:" + CLewaimaiString::UTF8ToUnicode(order.m_delivery_date);
+	}
+
+	CLabelUI *pTime = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_delivery_time")));
+	pTime->SetText(delivery_date.c_str());
+
+	CLabelUI *pPayType = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_pay_type")));
+	wstring wsPayType = _T("付款方式:") + CLewaimaiString::UTF8ToUnicode(order.m_pay_type);
+	pPayType->SetText(wsPayType.c_str());
+
+	if (CLewaimaiString::UTF8ToUnicode(order.m_pay_type) == L"货到付款")
+	{
+		this->FindSubControl(_T("waimai_order_info_page_huodaofukuan"))->SetVisible(true);
+	}
+	else
+	{
+		this->FindSubControl(_T("waimai_order_info_page_huodaofukuan"))->SetVisible(false);
+	}
+
+	//右侧按钮的控制
+	CButtonUI* confirm_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_confirme")));
+	CButtonUI* success_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_success")));
+	CButtonUI* fail_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_fail")));
+
+	CButtonUI* agree_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_agree")));
+	CButtonUI* disagree_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_disagree")));
+
+	CButtonUI* refund_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_refund")));
+
+	CLabelUI *pRefundStatus = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_refund_status")));
+
+	int refundHeight = 0;
+	if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("未处理")) == 0)
+	{
+		confirm_button->SetVisible(true);
+		success_button->SetVisible(false);
+		fail_button->SetVisible(true);
+
+		agree_button->SetVisible(false);
+		disagree_button->SetVisible(false);
+
+		refund_button->SetVisible(false);
+
+		pRefundStatus->SetVisible(false);
+	}
+	else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("已确认")) == 0)
+	{
+		confirm_button->SetVisible(false);
+		success_button->SetVisible(true);
+		fail_button->SetVisible(true);
+
+		agree_button->SetVisible(false);
+		disagree_button->SetVisible(false);
+
+		refund_button->SetVisible(false);
+
+		pRefundStatus->SetVisible(false);
+	}
+	else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("交易成功")) == 0)
+	{
+		confirm_button->SetVisible(false);
+		success_button->SetVisible(false);
+		fail_button->SetVisible(false);
+
+		agree_button->SetVisible(false);
+		disagree_button->SetVisible(false);
+
+		refund_button->SetVisible(false);
+
+		pRefundStatus->SetVisible(false);
+	}
+	else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("交易失败")) == 0)
+	{
+		confirm_button->SetVisible(false);
+		success_button->SetVisible(false);
+		fail_button->SetVisible(false);
+
+		agree_button->SetVisible(false);
+		disagree_button->SetVisible(false);
+
+		std::string refund_status = m_order.m_refund_status;
+
+		if (CLewaimaiString::UTF8ToUnicode(order.m_pay_type) != L"货到付款")
+		{
+			pRefundStatus->SetVisible(true);
+			refundHeight = 30;
+
+			std::wstring refund_status_text = L"退款状态:";
+			if (refund_status == "0")
+			{
+				refund_button->SetVisible(true);
+				refund_status_text += L"未处理";
+			}
+			else if (refund_status == "10")
+			{
+				refund_button->SetVisible(false);
+				refund_status_text += L"退款处理中,等待退款结果";
+			}
+			else if (refund_status == "11")
+			{
+				refund_button->SetVisible(false);
+				refund_status_text += L"退款已完成";
+			}
+			else if (refund_status == "12")
+			{
+				refund_button->SetVisible(false);
+				refund_status_text += L"退款失败,原因:" + CLewaimaiString::UTF8ToUnicode(order.m_refund_failed_reason);
+			}
+
+			pRefundStatus->SetText(refund_status_text.c_str());
+		}
+		else
+		{
+			refund_button->SetVisible(false);
+
+			pRefundStatus->SetVisible(false);
+		}
+	}
+	else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("已取消")) == 0)
+	{
+		confirm_button->SetVisible(false);
+		success_button->SetVisible(false);
+		fail_button->SetVisible(false);
+
+		agree_button->SetVisible(false);
+		disagree_button->SetVisible(false);
+
+		refund_button->SetVisible(false);
+
+		pRefundStatus->SetVisible(false);
+	}
+	else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("退款中")) == 0)
+	{
+		confirm_button->SetVisible(false);
+		success_button->SetVisible(false);
+		fail_button->SetVisible(false);
+
+		refund_button->SetVisible(false);
+
+		std::string refund_status = m_order.m_refund_status;
+		if (refund_status == "1")
+		{
+			agree_button->SetVisible(true);
+			disagree_button->SetVisible(true);
+		}
+		else if (refund_status == "5")
+		{
+			agree_button->SetVisible(true);
+			disagree_button->SetVisible(false);
+		}
+		else
+		{
+			agree_button->SetVisible(false);
+			disagree_button->SetVisible(false);
+		}
+
+		pRefundStatus->SetVisible(true);
+
+		refundHeight = 30;
+
+		std::wstring refund_status_text = L"退款状态:";
+		if (refund_status == "1")
+		{
+			refund_status_text += L"顾客申请退款,等待商家处理";
+		}
+		else if (refund_status == "2")
+		{
+			refund_status_text += L"退款成功,订单失败";
+		}
+		else if (refund_status == "3")
+		{
+			refund_status_text += L"商家已拒绝退款,等待顾客受理";
+		}
+		else if (refund_status == "4")
+		{
+			refund_status_text += L"退款失败,订单变为已确认";
+		}
+		else if (refund_status == "5")
+		{
+			refund_status_text += L"顾客再次发起退款,等待客服介入处理中";
+		}
+
+		pRefundStatus->SetText(refund_status_text.c_str());
+	}
+
+	int configMemoHeight = 0;
+	CLabelUI *pConfigmemo = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_configmemo")));
+
+	if (m_order.m_configmemo != "")
+	{
+		configMemoHeight = 30;
+
+		wstring configMemo = L"商家备注:" + CLewaimaiString::UTF8ToUnicode(order.m_configmemo);
+		pConfigmemo->SetText(configMemo.c_str());
+		pConfigmemo->SetVisible(true);
+	}
+	else
+	{
+		configMemoHeight = 0;
+
+		pConfigmemo->SetVisible(false);
+	}
+
+	this->FindSubControl(_T("waimai_order_info_page_layout_3"))->SetFixedHeight(order_filed_height + refundHeight + configMemoHeight + 181);
+}

+ 26 - 0
zhipuzi_pay_plugin/control/CWaimaiOrderInfoUI.h

@@ -0,0 +1,26 @@
+#pragma once
+
+#include "../order/CWaimaiOrder.h"
+
+class CWaimaiOrderInfoUI : public CVerticalLayoutUI
+{
+public:
+	CWaimaiOrderInfoUI()
+	{
+
+	}
+
+	//刷新当前页面的内容,注意这个函数不会改变当前的订单状态以及“页数”
+	void DoEvent(TEventUI& event);
+
+	void SetDate(CWaimaiOrder& order)
+	{
+		m_order = order;
+	}
+
+	//根据外卖订单数据,刷新订单详情页的显示
+	void Refresh(CWaimaiOrder& order);
+
+public:
+	CWaimaiOrder m_order;
+};

+ 171 - 0
zhipuzi_pay_plugin/control/CWaimaiOrderItemUI.cpp

@@ -0,0 +1,171 @@
+#include "../pch/pch.h"
+#include "CWaimaiOrderItemUI.h"
+
+
+CWaimaiOrderItemUI::CWaimaiOrderItemUI()
+{
+}
+
+
+CWaimaiOrderItemUI::~CWaimaiOrderItemUI()
+{
+}
+
+void CWaimaiOrderItemUI::SetData(rapidjson::Value& orderinfo)
+{
+	m_name = orderinfo["customer_name"].GetString();
+	m_address = orderinfo["address"].GetString();
+	m_phone = orderinfo["customer_phone"].GetString();
+	m_price = orderinfo["price"].GetString();
+	m_order_no = orderinfo["order_no"].GetString();
+	m_init_date = orderinfo["init_date"].GetString();
+
+	m_is_selftake = orderinfo["is_selftake"].GetString();
+	m_delivery_date = orderinfo["delivery_date"].GetString();
+	m_deliverytime = orderinfo["delivertime"].GetString();
+
+	m_restaurant_number = orderinfo["restaurant_number"].GetString();
+
+	m_orderid = orderinfo["id"].GetString();
+
+	std::wstring name_show = L"姓名:" + CLewaimaiString::UTF8ToUnicode(m_name);
+	this->FindSubControl(L"waimai_order_list_name")->SetText(name_show.c_str());
+
+	std::wstring address_show = L"地址:" + CLewaimaiString::UTF8ToUnicode(m_address);
+	this->FindSubControl(L"waimai_order_list_address")->SetText(address_show.c_str());
+
+	std::wstring phone_show = L"电话:" + CLewaimaiString::UTF8ToUnicode(m_phone);
+	this->FindSubControl(L"waimai_order_list_phone")->SetText(phone_show.c_str());
+
+	std::wstring price_show = L"价格:" + CLewaimaiString::UTF8ToUnicode(m_price);
+	this->FindSubControl(L"waimai_order_list_price")->SetText(price_show.c_str());
+
+	std::wstring order_no_show = L"#" + CLewaimaiString::UTF8ToUnicode(m_restaurant_number) + L"  订单号:" + CLewaimaiString::UTF8ToUnicode(m_order_no);
+	this->FindSubControl(L"waimai_order_list_order_no")->SetText(order_no_show.c_str());
+
+	std::wstring init_date_show = L"下单时间:" + CLewaimaiString::UTF8ToUnicode(m_init_date);
+	this->FindSubControl(L"waimai_order_list_init_date")->SetText(init_date_show.c_str());
+
+	std::wstring order_type;
+	std::wstring delivery_date;
+	if (m_is_selftake == "1")
+	{
+		order_type = L"订单类型:到店自取";
+		delivery_date = L"自取时间:" + CLewaimaiString::UTF8ToUnicode(m_delivery_date);
+
+		this->FindSubControl(L"waimai_order_list_ziqu")->SetVisible(true);
+	}
+	else
+	{
+		order_type = L"订单类型:外卖配送";
+		delivery_date = L"配送时间:" + CLewaimaiString::UTF8ToUnicode(m_delivery_date);
+
+		this->FindSubControl(L"waimai_order_list_ziqu")->SetVisible(false);
+	}
+
+	this->FindSubControl(L"waimai_order_list_type")->SetText(order_type.c_str());
+	this->FindSubControl(L"waimai_order_list_delivery_date")->SetText(delivery_date.c_str());
+
+	//显示预约的戳
+	if (m_deliverytime == CLewaimaiString::UnicodeToUTF8(L"尽快送达"))
+	{
+		this->FindSubControl(L"waimai_order_list_yuyue")->SetVisible(false);
+	}
+	else
+	{
+		this->FindSubControl(L"waimai_order_list_yuyue")->SetVisible(true);
+	}
+
+	if (m_status == 1)
+	{
+		this->FindSubControl(L"waimai_order_list_refund_status")->SetVisible(false);
+
+		this->FindSubControl(L"waimai_order_list_confirme")->SetVisible(true);
+		this->FindSubControl(L"waimai_order_list_success")->SetVisible(false);
+		this->FindSubControl(L"waimai_order_list_fail")->SetVisible(true);
+
+		this->FindSubControl(L"waimai_order_list_agree")->SetVisible(false);
+		this->FindSubControl(L"waimai_order_list_disagree")->SetVisible(false);
+	}
+	else if (m_status == 2 || m_status == 3)
+	{
+		this->FindSubControl(L"waimai_order_list_refund_status")->SetVisible(false);
+
+		this->FindSubControl(L"waimai_order_list_confirme")->SetVisible(false);
+		this->FindSubControl(L"waimai_order_list_success")->SetVisible(true);
+		this->FindSubControl(L"waimai_order_list_fail")->SetVisible(true);
+
+		this->FindSubControl(L"waimai_order_list_agree")->SetVisible(false);
+		this->FindSubControl(L"waimai_order_list_disagree")->SetVisible(false);
+	}
+	else if (m_status == 4 || m_status == 5)
+	{
+		this->FindSubControl(L"waimai_order_list_refund_status")->SetVisible(false);
+
+		this->FindSubControl(L"waimai_order_list_confirme")->SetVisible(false);
+		this->FindSubControl(L"waimai_order_list_success")->SetVisible(false);
+		this->FindSubControl(L"waimai_order_list_fail")->SetVisible(false);
+
+		this->FindSubControl(L"waimai_order_list_agree")->SetVisible(false);
+		this->FindSubControl(L"waimai_order_list_disagree")->SetVisible(false);
+	}
+	else if (m_status == 6)
+	{
+		this->FindSubControl(L"waimai_order_list_refund_status")->SetVisible(false);
+
+		this->FindSubControl(L"waimai_order_list_confirme")->SetVisible(false);
+		this->FindSubControl(L"waimai_order_list_success")->SetVisible(false);
+		this->FindSubControl(L"waimai_order_list_fail")->SetVisible(false);
+
+		this->FindSubControl(L"waimai_order_list_agree")->SetVisible(false);
+		this->FindSubControl(L"waimai_order_list_disagree")->SetVisible(false);
+	}
+	else if (m_status == 7)
+	{
+		this->FindSubControl(L"waimai_order_list_confirme")->SetVisible(false);
+		this->FindSubControl(L"waimai_order_list_success")->SetVisible(false);
+		this->FindSubControl(L"waimai_order_list_fail")->SetVisible(false);
+
+		std::string refund_status = orderinfo["refund_status"].GetString();
+		if (refund_status == "1")
+		{
+			this->FindSubControl(L"waimai_order_list_agree")->SetVisible(true);
+			this->FindSubControl(L"waimai_order_list_disagree")->SetVisible(true);
+		}
+		else if (refund_status == "5")
+		{
+			this->FindSubControl(L"waimai_order_list_agree")->SetVisible(true);
+			this->FindSubControl(L"waimai_order_list_disagree")->SetVisible(false);
+		}
+		else
+		{
+			this->FindSubControl(L"waimai_order_list_agree")->SetVisible(false);
+			this->FindSubControl(L"waimai_order_list_disagree")->SetVisible(false);
+		}
+
+		this->FindSubControl(L"waimai_order_list_refund_status")->SetVisible(true);
+		std::wstring refund_status_text = L"退款状态:";
+		if (refund_status == "1")
+		{
+			refund_status_text += L"顾客申请退款,等待商家处理";
+		}
+		else if (refund_status == "2")
+		{
+			refund_status_text += L"退款成功,订单失败";
+		}
+		else if (refund_status == "3")
+		{
+			refund_status_text += L"商家已拒绝退款,等待顾客受理";
+		}
+		else if (refund_status == "4")
+		{
+			refund_status_text += L"退款失败,订单变为已确认";
+		}
+		else if (refund_status == "5")
+		{
+			refund_status_text += L"顾客再次发起退款,等待客服介入处理中";
+		}
+
+		this->FindSubControl(L"waimai_order_list_refund_status")->SetText(refund_status_text.c_str());
+	}
+}

+ 55 - 0
zhipuzi_pay_plugin/control/CWaimaiOrderItemUI.h

@@ -0,0 +1,55 @@
+#pragma once
+
+#include "../pch/pch.h"
+
+class CWaimaiOrderItemUI : public CHorizontalLayoutUI
+{
+public:
+	CWaimaiOrderItemUI();
+	~CWaimaiOrderItemUI();
+
+	void SetData(rapidjson::Value& orderinfo);
+
+	std::string getOrderID()
+	{
+		return m_orderid;
+	}
+
+	std::string getOrderNo()
+	{
+		return m_order_no;
+	}
+
+	void SetStatus(int status)
+	{
+		m_status = status;
+	}
+
+	void DoEvent(TEventUI& event)
+	{
+		if (event.Type == UIEVENT_BUTTONDOWN)
+		{
+			int a = 1;
+		}
+		CHorizontalLayoutUI::DoEvent(event);
+	}
+
+private:
+	std::string m_name;
+	std::string m_address;
+	std::string m_phone;
+	std::string m_price;
+	std::string m_order_no;
+	std::string m_init_date;
+
+	std::string m_is_selftake;
+	std::string m_delivery_date;
+	std::string m_deliverytime;
+
+	std::string m_restaurant_number;
+
+	std::string m_orderid;
+
+	int m_status = 1; //1:未处理 2:已确认 3:配送中 4:成功 5:失败 6:已取消 7:退款中
+};
+

+ 34 - 0
zhipuzi_pay_plugin/control/ControlEx.h

@@ -0,0 +1,34 @@
+#pragma once
+
+#include "../pch/pch.h"
+
+#include "CWaimaiOrderItemUI.h"
+#include "OrderListUI.h"
+#include "CWaimaiOrderInfoUI.h"
+#include "CSettingUI.h"
+
+class CDialogBuilderCallbackEx : public IDialogBuilderCallback
+{
+public:
+	CControlUI* CreateControl(LPCTSTR pstrClass)
+	{
+		if (_tcscmp(pstrClass, _T("WaimaiOrderList")) == 0)
+		{
+			return new OrderListUI;
+		}
+		else if (_tcscmp(pstrClass, _T("WaimaiOrderItem")) == 0)
+		{
+			return new CWaimaiOrderItemUI;
+		}
+		else if (_tcscmp(pstrClass, _T("WaimaiOrderInfo")) == 0)
+		{
+			return new CWaimaiOrderInfoUI;
+		}
+		else if (_tcscmp(pstrClass, _T("Setting")) == 0)
+		{
+			return new CSettingUI;
+		}
+
+		return NULL;
+	}
+};

+ 235 - 0
zhipuzi_pay_plugin/control/OrderListUI.cpp

@@ -0,0 +1,235 @@
+#include "../pch/pch.h"
+#include "OrderListUI.h"
+
+#include "CWaimaiOrderItemUI.h"
+
+#include "ControlEx.h"
+
+OrderListUI::OrderListUI()
+{
+	
+}
+
+OrderListUI::~OrderListUI()
+{
+	
+}
+
+void OrderListUI::Refresh()
+{
+	//开始转菊花
+	this->SetVisible(false);
+
+	m_pManager->FindControl(_T("main_orderlist_loading"))->SetVisible(true);
+
+	//启动一个线程,进行网络请求操作
+	OrderListStatus* status =  new OrderListStatus;
+	status->m_status = m_status;
+	status->m_page = m_page;
+
+	std::thread t(&OrderListUI::HandleRefresh, this, status);
+	t.detach();
+}
+
+void OrderListUI::HandleRefresh(OrderListStatus* status)
+{
+	std::string url;
+	if (status->m_status == 1)
+	{
+		url = "/waimaiorder/getopenlist";
+	}
+	else if (status->m_status == 2)
+	{
+		url = "/waimaiorder/getconfirmedlist";
+	}
+	else if (status->m_status == 3)
+	{
+		url = "/waimaiorder/getdeliverylist";
+	}
+	else if (status->m_status == 4)
+	{
+		url = "/waimaiorder/getsucceededlist";
+	}
+	else if (status->m_status == 5)
+	{
+		url = "/waimaiorder/getfailedlist";
+	}
+	else if (status->m_status == 6)
+	{
+		url = "/waimaiorder/getcancelledlist";
+	}
+	else if (status->m_status == 7)
+	{
+		url = "/waimaiorder/getrefundlist";
+	}
+
+	//请求外卖的未处理订单,直接用当前的page值去请求
+	std::map<string, string> params;
+	params["page"] = to_string(status->m_page);
+	std::string response;
+
+	CZhipuziHttpClient::Request(url.c_str(), params, response);
+
+	//走到这里,网络请求结束了,对比状态是否发生了改变
+	if (status->m_page != m_page || status->m_status != m_status)
+	{
+		//用户已经点击了其他状态,这个状态结果无效了,直接返回
+		delete status;
+		return;
+	}
+		
+	//将网络返回结果保存起来,等待消息处理重新渲染页面
+	m_response = response;
+
+	::PostMessage(m_pManager->GetPaintWindow(), WM_ORDERLIST_REFRESH, 0, 0);
+
+	delete status;
+}
+
+void OrderListUI::DoRefresh()
+{
+	//请求成功之后,清空之前的数据
+	this->RemoveAll();
+
+	rapidjson::Document document;
+	document.Parse(m_response.c_str());
+
+	if (document.HasParseError())
+	{
+		LOG_INFO("parse response error!");
+		return;
+	}
+
+	if (!document.HasMember("errcode") || !document.HasMember("errmsg") || !document.HasMember("data"))
+	{
+		LOG_INFO("json error!");
+		return;
+	}
+
+	rapidjson::Value& v_errcode = document["errcode"];
+	int errcode = v_errcode.GetInt();
+	if (errcode != 0)
+	{
+		LOG_INFO("response failed! message:" << document["errmsg"].GetString());
+		return;
+	}
+
+	//获得数据成功
+	rapidjson::Value& data = document["data"];
+
+	rapidjson::Value& v_count = data["count"];
+	string count = v_count.GetString();
+
+	//处理页数
+	int nCount = atoi(count.c_str());
+	m_total_page = (int)ceil(nCount / 20.0);
+	if (m_total_page < 1)
+	{
+		m_total_page = 1;
+	}
+
+	if (m_page <= 1)
+	{
+		m_page = 1;
+		CButtonUI* pControl = static_cast<CButtonUI*>(m_pManager->FindControl(_T("waimai_order_list_last")));
+		pControl->SetEnabled(false);
+	}
+	if (m_page >= m_total_page)
+	{
+		m_page = m_total_page;
+		CButtonUI* pControl = static_cast<CButtonUI*>(m_pManager->FindControl(_T("waimai_order_list_next")));
+		pControl->SetEnabled(false);
+	}
+
+	if (m_page > 1)
+	{
+		CButtonUI* pControl = static_cast<CButtonUI*>(m_pManager->FindControl(_T("waimai_order_list_last")));
+		pControl->SetEnabled(true);
+	}
+	if (m_page < m_total_page)
+	{
+		CButtonUI* pControl = static_cast<CButtonUI*>(m_pManager->FindControl(_T("waimai_order_list_next")));
+		pControl->SetEnabled(true);
+	}
+
+	CLabelUI* pControl = static_cast<CLabelUI*>(m_pManager->FindControl(_T("waimai_order_list_page")));
+	wstring pageinfo = _T("第 ") + CLewaimaiString::ANSIToUnicode(to_string(m_page)) + _T("页/共 ") + CLewaimaiString::ANSIToUnicode(to_string(m_total_page)) + _T("页");
+	pControl->SetText(pageinfo.c_str());
+
+	rapidjson::Value& v_rows = data["rows"];
+
+	for (rapidjson::SizeType i = 0; i < v_rows.Size(); ++i)
+	{
+		rapidjson::Value& v_row_i = v_rows[i];
+
+		//创建一个对象
+		CDialogBuilder builder;
+		CDialogBuilderCallbackEx cb;
+
+		CWaimaiOrderItemUI* pItem = static_cast<CWaimaiOrderItemUI*>(builder.Create(_T("waimai_order_item.xml"), (UINT)0, &cb, m_pManager));
+		if (pItem != NULL)
+		{
+			//初始化该对应的数据
+			pItem->SetStatus(m_status);
+
+			pItem->SetData(v_row_i);
+
+			this->Add(pItem);
+
+			pItem = NULL;
+		}
+		else
+		{
+			LOG_INFO("create waimai_order_item fail!");
+		}
+	}
+
+	//重置滚动条的位置
+	tagSIZE size;
+	size.cx = 0;
+	size.cy = 0;
+	this->SetScrollPos(size);
+
+	this->SetVisible(true);
+
+	m_pManager->FindControl(_T("main_orderlist_loading"))->SetVisible(false);
+}
+
+void OrderListUI::LastPage()
+{
+	m_page--;
+	if (m_page < 1)
+	{
+		m_page = 1;
+	}
+
+	if (m_page == 1)
+	{
+		CButtonUI* pControl = static_cast<CButtonUI*>(m_pManager->FindControl(_T("waimai_order_list_last")));
+		pControl->SetEnabled(false);
+	}
+
+	Refresh();
+}
+
+void OrderListUI::NextPage()
+{
+	m_page++;
+	if (m_page > m_total_page)
+	{
+		m_page = m_total_page;
+	}
+
+	if (m_page == m_total_page)
+	{
+		CButtonUI* pControl = static_cast<CButtonUI*>(m_pManager->FindControl(_T("waimai_order_list_next")));
+		pControl->SetEnabled(false);
+	}
+
+	Refresh();
+}
+
+void OrderListUI::DoEvent(TEventUI& event)
+{
+	CVerticalLayoutUI::DoEvent(event);
+}

+ 47 - 0
zhipuzi_pay_plugin/control/OrderListUI.h

@@ -0,0 +1,47 @@
+#pragma once
+
+class OrderListStatus
+{
+public:
+	int m_status;
+	int m_page;
+};
+
+class OrderListUI : public CVerticalLayoutUI
+{
+public:
+	OrderListUI();
+
+	~OrderListUI();
+
+    //刷新当前页面的内容,注意这个函数不会改变当前的订单状态以及“页数”
+    void Refresh();
+
+	void LastPage();
+
+	void NextPage();
+
+	void DoEvent(TEventUI& event);
+
+	void SetStatus(int status)
+	{
+		m_status = status;
+	}
+
+	void SetPage(int n)
+	{
+		m_page = n;
+	}
+
+	void HandleRefresh(OrderListStatus* status);
+
+	void DoRefresh();
+
+private:
+    int m_status = 1; //1:未处理 2:已确认 3:配送中 4:成功 5:失败 6:已取消 7:退款中
+	int m_page = 1;
+
+	int m_total_page; //总页数
+
+	std::string m_response;
+};

+ 395 - 0
zhipuzi_pay_plugin/helper/CLewaimaiString.cpp

@@ -0,0 +1,395 @@
+#include "../pch/pch.h"
+#include "CLewaimaiString.h"
+
+#include <boost/archive/iterators/base64_from_binary.hpp>
+#include <boost/archive/iterators/binary_from_base64.hpp>
+#include <boost/archive/iterators/transform_width.hpp>
+#include <string>
+#include <iostream>
+#include <sstream>
+
+using namespace std;
+using namespace boost::archive::iterators;
+
+
+unsigned char ToHex(unsigned char x)
+{
+    return  x > 9 ? x + 55 : x + 48;
+}
+
+unsigned char FromHex(unsigned char x)
+{
+    unsigned char y;
+
+    if(x >= 'A' && x <= 'Z')
+    {
+        y = x - 'A' + 10;
+    }
+
+    else if(x >= 'a' && x <= 'z')
+    {
+        y = x - 'a' + 10;
+    }
+
+    else if(x >= '0' && x <= '9')
+    {
+        y = x - '0';
+    }
+
+    else
+    {
+        assert(0);
+    }
+
+    return y;
+}
+
+CLewaimaiString::CLewaimaiString()
+{
+}
+
+
+CLewaimaiString::~CLewaimaiString()
+{
+}
+
+bool CLewaimaiString::base64_encode(const string& input, string* output)
+{
+    typedef base64_from_binary<transform_width<string::const_iterator, 6, 8>> Base64EncodeIterator;
+    stringstream result;
+
+    try
+    {
+        copy(Base64EncodeIterator(input.begin()), Base64EncodeIterator(input.end()), ostream_iterator<char>(result));
+    }
+
+    catch(...)
+    {
+        return false;
+    }
+
+    size_t equal_count = (3 - input.length() % 3) % 3;
+
+    for(size_t i = 0; i < equal_count; i++)
+    {
+        result.put('=');
+    }
+
+    *output = result.str();
+    return output->empty() == false;
+}
+
+bool CLewaimaiString::base64_decode(const string& input, string* output)
+{
+    typedef transform_width<binary_from_base64<string::const_iterator>, 8, 6> Base64DecodeIterator;
+    stringstream result;
+
+    try
+    {
+        copy(Base64DecodeIterator(input.begin()), Base64DecodeIterator(input.end()), ostream_iterator<char>(result));
+    }
+
+    catch(...)
+    {
+        return false;
+    }
+
+    *output = result.str();
+    return output->empty() == false;
+}
+
+void CLewaimaiString::trim(string& s)
+{
+    if(!s.empty())
+    {
+        s.erase(0, s.find_first_not_of(" "));
+        s.erase(s.find_last_not_of(" ") + 1);
+    }
+}
+
+std::string CLewaimaiString::UrlEncode(const std::string& str)
+{
+    std::string strTemp = "";
+    size_t length = str.length();
+
+    for(size_t i = 0; i < length; i++)
+    {
+        if(isalnum((unsigned char)str[i]) ||
+                (str[i] == '-') ||
+                (str[i] == '_') ||
+                (str[i] == '.') ||
+                (str[i] == '~'))
+        {
+            strTemp += str[i];
+        }
+
+        else if(str[i] == ' ')
+        {
+            strTemp += "+";
+        }
+
+        else
+        {
+            strTemp += '%';
+            strTemp += ToHex((unsigned char)str[i] >> 4);
+            strTemp += ToHex((unsigned char)str[i] % 16);
+        }
+    }
+
+    return strTemp;
+}
+
+std::string CLewaimaiString::UrlDecode(const std::string& str)
+{
+    std::string strTemp = "";
+    size_t length = str.length();
+
+    for(size_t i = 0; i < length; i++)
+    {
+        if(str[i] == '+')
+        {
+            strTemp += ' ';
+        }
+
+        else if(str[i] == '%')
+        {
+            assert(i + 2 < length);
+            unsigned char high = FromHex((unsigned char)str[++i]);
+            unsigned char low = FromHex((unsigned char)str[++i]);
+            strTemp += high * 16 + low;
+        }
+
+        else
+        {
+            strTemp += str[i];
+        }
+    }
+
+    return strTemp;
+}
+
+std::string CLewaimaiString::UnicodeToUTF8(const std::wstring& wstr)
+{
+    std::string ret;
+
+    try
+    {
+        std::wstring_convert< std::codecvt_utf8<wchar_t> > wcv;
+        ret = wcv.to_bytes(wstr);
+    }
+
+    catch(const std::exception& e)
+    {
+        std::cerr << e.what() << std::endl;
+    }
+
+    return ret;
+}
+
+std::wstring CLewaimaiString::UTF8ToUnicode(const std::string& str)
+{
+    std::wstring ret;
+
+    try
+    {
+        std::wstring_convert< std::codecvt_utf8<wchar_t> > wcv;
+        ret = wcv.from_bytes(str);
+    }
+
+    catch(const std::exception& e)
+    {
+        std::cerr << e.what() << std::endl;
+    }
+
+    return ret;
+}
+
+std::string CLewaimaiString::UnicodeToANSI(const std::wstring& wstr)
+{
+    unsigned len = wstr.size() * 4;
+	if (len == 0)
+	{
+		return "";
+	}
+
+    setlocale(LC_CTYPE, "");
+    char *p = new char[len];
+    wcstombs(p, wstr.c_str(), len);
+    std::string str1(p);
+    delete[] p;
+    return str1;
+}
+
+std::wstring CLewaimaiString::ANSIToUnicode(const std::string& str)
+{
+    unsigned len = str.size() * 2;// 预留字节数
+	if (len == 0)
+	{
+		return L"";
+	}
+
+    setlocale(LC_CTYPE, "");     //必须调用此函数
+    wchar_t *p = new wchar_t[len];// 申请一段内存存放转换后的字符串
+    mbstowcs(p, str.c_str(), len);// 转换
+    std::wstring str1(p);
+    delete[] p;// 释放申请的内存
+    return str1;
+}
+
+std::string CLewaimaiString::UTF8ToANSI(const std::string& str)
+{
+    return UnicodeToANSI(UTF8ToUnicode(str));
+}
+
+std::string CLewaimaiString::ANSIToUTF8(const std::string& str)
+{
+    return UnicodeToUTF8(ANSIToUnicode(str));
+}
+
+std::string CLewaimaiString::DoubleToString(const double value, unsigned int precisionAfterPoint)
+{
+    char str[256];
+
+    std::string pre = "%." + to_string(precisionAfterPoint) + "f";
+    sprintf(str, pre.c_str(), value);
+    string result = str;
+    return result;
+}
+
+bool CLewaimaiString::isIPAddressValid(const char* pszIPAddr)
+{
+    if(!pszIPAddr)
+    {
+        return false;    //若pszIPAddr为空
+    }
+
+    char IP1[100], cIP[4];
+    int len = strlen(pszIPAddr);
+    int i = 0, j = len - 1;
+    int k, m = 0, n = 0, num = 0;
+
+    //去除首尾空格(取出从i-1到j+1之间的字符):
+    while(pszIPAddr[i++] == ' ');
+
+    while(pszIPAddr[j--] == ' ');
+
+    for(k = i - 1; k <= j + 1; k++)
+    {
+        IP1[m++] = *(pszIPAddr + k);
+    }
+
+    IP1[m] = '\0';
+
+    char* p = IP1;
+
+    while(*p != '\0')
+    {
+        if(*p == ' ' || *p < '0' || *p > '9')
+        {
+            return false;
+        }
+
+        cIP[n++] = *p; //保存每个子段的第一个字符,用于之后判断该子段是否为0开头
+
+        int sum = 0;  //sum为每一子段的数值,应在0到255之间
+
+        while(*p != '.' && *p != '\0')
+        {
+            if(*p == ' ' || *p < '0' || *p > '9')
+            {
+                return false;
+            }
+
+            sum = sum * 10 + *p - 48;  //每一子段字符串转化为整数
+            p++;
+        }
+
+        if(*p == '.')
+        {
+            if((*(p - 1) >= '0' && *(p - 1) <= '9') && (*(p + 1) >= '0' && *(p + 1) <= '9')) //判断"."前后是否有数字,若无,则为无效IP,如“1.1.127.”
+            {
+                num++;    //记录“.”出现的次数,不能大于3
+            }
+
+            else
+            {
+                return false;
+            }
+        };
+
+        if((sum > 255) || (sum > 0 && cIP[0] == '0') || num > 3)
+        {
+            return false;    //若子段的值>255或为0开头的非0子段或“.”的数目>3,则为无效IP
+        }
+
+        if(*p != '\0')
+        {
+            p++;
+        }
+
+        n = 0;
+    }
+
+    if(num != 3)
+    {
+        return false;
+    }
+
+    return true;
+}
+
+vector<string> CLewaimaiString::Split(const string& in, const string& delim)
+{
+    vector<string> ret;
+
+    try
+    {
+        regex re{ delim };
+        return vector<string>
+        {
+            sregex_token_iterator(in.begin(), in.end(), re, -1),
+            sregex_token_iterator()
+        };
+    }
+
+    catch(const std::exception& e)
+    {
+        cout << "error:" << e.what() << std::endl;
+    }
+
+    return ret;
+}
+
+/*
+ *nNum是表示替换几个,默认为1表示替换第1个
+ **/
+int CLewaimaiString::Replace(std::wstring& strContent, std::wstring strReplace, std::wstring strDest, int nNum)
+{
+    int nCount = 0;
+
+    while(true)
+    {
+        size_t pos = strContent.find(strReplace);
+
+        if(pos != std::wstring::npos)
+        {
+            WCHAR pBuf[1] = { L'\0' };
+            strContent.replace(pos, strReplace.length(), pBuf, 0);
+            strContent.insert(pos, strDest);
+
+            nCount++;
+
+            if(nCount == nNum)
+            {
+                break;
+            }
+        }
+
+        else
+        {
+            break;
+        }
+    }
+
+    return 0;
+}

+ 44 - 0
zhipuzi_pay_plugin/helper/CLewaimaiString.h

@@ -0,0 +1,44 @@
+#pragma once
+
+#include <codecvt>
+#include <iostream>
+#include <sstream>
+#include <regex>
+#include <string>
+
+using namespace std;
+
+class CLewaimaiString
+{
+public:
+	CLewaimaiString();
+	~CLewaimaiString();
+
+	static bool base64_encode(const string& input, string* output);
+	static bool base64_decode(const string& input, string* output);
+
+	static void trim(string &s);
+
+	static std::string UnicodeToUTF8(const std::wstring & wstr);
+
+	static std::wstring UTF8ToUnicode(const std::string & str);
+
+	static std::string UnicodeToANSI(const std::wstring & wstr);
+
+	static std::wstring ANSIToUnicode(const std::string & str);
+
+	static std::string UTF8ToANSI(const std::string & str);
+
+	static std::string ANSIToUTF8(const std::string & str);
+
+	static std::string DoubleToString(const double value, unsigned int precisionAfterPoint);
+
+	static std::string UrlEncode(const std::string& str);
+	static std::string UrlDecode(const std::string& str);
+
+	static bool isIPAddressValid(const char* pszIPAddr);
+
+	static vector<string> Split(const string& in, const string& delim);
+
+	static int Replace(std::wstring& strContent, std::wstring strReplace, std::wstring strDest, int nNum = 1);
+};

+ 11 - 0
zhipuzi_pay_plugin/helper/CRandomHelper.cpp

@@ -0,0 +1,11 @@
+#include "../pch/pch.h"
+#include "CRandomHelper.h"
+
+CRandomHelper::CRandomHelper()
+{
+}
+
+
+CRandomHelper::~CRandomHelper()
+{
+}

+ 40 - 0
zhipuzi_pay_plugin/helper/CRandomHelper.h

@@ -0,0 +1,40 @@
+#pragma once
+
+class CRandomHelper
+{
+public:
+	CRandomHelper();
+	~CRandomHelper();
+
+	CRandomHelper(unsigned int seed)
+	{
+		next_seed = seed;
+	}
+
+	//生成0到1之间的随机数
+	inline double lewaimai_rand()
+	{
+		return (double)myrand() / 0x7fff;
+	}
+
+	//生成范围内的随机整数
+	inline int randInt(int begin, int end)
+	{
+		return begin + (myrand() % (end - begin + 1));
+	}
+
+	/* RAND_MAX assumed to be 32767 */
+	inline int myrand(void)
+	{
+		next_seed = next_seed * 1103515245 + 12345;
+		return((unsigned)(next_seed / 65536) % 32768);
+	}
+
+	inline void mysrand(unsigned int seed)
+	{
+		next_seed = seed;
+	}
+
+private:
+	unsigned long next_seed = 1;
+};

+ 32 - 0
zhipuzi_pay_plugin/helper/CSystem.cpp

@@ -0,0 +1,32 @@
+#include "../pch/pch.h"
+#include "CSystem.h"
+
+CSystem::CSystem()
+{
+}
+
+
+CSystem::~CSystem()
+{
+}
+
+
+int CSystem::get_CPU_core_num()
+{
+#ifdef _WIN32
+	SYSTEM_INFO info;
+	GetSystemInfo(&info);
+	return info.dwNumberOfProcessors;
+#else
+	return get_nprocs();
+#endif
+}
+
+void CSystem::my_sleep(int second)
+{
+#ifdef _WIN32
+	Sleep(second * 1000);
+#else
+	sleep(second);
+#endif
+}

+ 153 - 0
zhipuzi_pay_plugin/helper/CSystem.h

@@ -0,0 +1,153 @@
+#pragma once
+
+#include "../pch/pch.h"
+
+class CSystem
+{
+public:
+    CSystem();
+    ~CSystem();
+
+    static int get_CPU_core_num();
+
+    //程序休眠X秒
+    static void my_sleep(int second);
+
+	static std::wstring getExePath()
+	{
+		wchar_t exeFullPath[MAX_PATH]; // Full path
+		std::wstring strPath = L"";
+
+		GetModuleFileName(NULL, exeFullPath, MAX_PATH);
+		strPath = (wstring)exeFullPath;    // Get full path of the file
+
+		return strPath;
+	}
+
+    static std::wstring GetProgramDir()
+    {
+        wchar_t exeFullPath[MAX_PATH]; // Full path
+        std::wstring strPath = L"";
+
+        GetModuleFileName(NULL, exeFullPath, MAX_PATH);
+        strPath = (wstring)exeFullPath;    // Get full path of the file
+
+        int pos = strPath.find_last_of('\\', strPath.length());
+        return strPath.substr(0, pos);  // Return the directory without the file name
+    }
+
+    // 程序开机自动启动
+    static void autostart()
+    {
+        HKEY hKey;
+        wstring strRegPath = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
+
+        //1、找到系统的启动项
+        if(RegOpenKeyEx(HKEY_CURRENT_USER, strRegPath.c_str(), 0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS)  ///打开启动项
+        {
+            //2、得到本程序自身的全路径
+            TCHAR strExeFullDir[MAX_PATH];
+            GetModuleFileName(NULL, strExeFullDir, MAX_PATH);
+
+            //3、添加一个子Key,并设置值,"GISRestart"是应用程序名字(不加后缀.exe)
+            RegSetValueEx(hKey, L"智铺子收银软件", 0, REG_SZ, (LPBYTE)strExeFullDir, (lstrlen(strExeFullDir) + 1) * sizeof(TCHAR));
+
+            //4、关闭注册表
+            RegCloseKey(hKey);
+        }
+
+        else
+        {
+            cout << "系统参数错误, 不能随系统启动";
+        }
+    }
+
+    // 取消开机自动启动
+    static void cancelAutoStart()
+    {
+        HKEY hKey;
+        wstring strRegPath = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
+
+        //1、找到系统的启动项
+        if(RegOpenKeyEx(HKEY_CURRENT_USER, strRegPath.c_str(), 0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS)
+        {
+            //2、删除值
+            RegDeleteValue(hKey, L"智铺子收银软件");
+
+            //3、关闭注册表
+            RegCloseKey(hKey);
+        }
+    }
+
+	static bool IsAutoStart()
+	{
+		HKEY hKey;
+		wstring strRegPath = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
+
+		//1、找到系统的启动项
+		if (RegOpenKeyEx(HKEY_CURRENT_USER, strRegPath.c_str(), 0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS)
+		{
+			char dwValue[256];
+			DWORD dwSzType = REG_SZ;
+			DWORD dwSize = sizeof(dwValue);
+
+			if (::RegQueryValueEx(hKey, _T("智铺子收银软件"), 0, &dwSzType, (LPBYTE)&dwValue, &dwSize) != ERROR_SUCCESS)
+			{
+				return false;
+			}
+
+			//关闭注册表
+			RegCloseKey(hKey);
+
+			return true;
+		}
+
+		return false;
+	}
+
+    // 判断文件是否存在
+    static BOOL IsFileExist(const wstring& csFile)
+    {
+        DWORD dwAttrib = GetFileAttributes(csFile.c_str());
+        return INVALID_FILE_ATTRIBUTES != dwAttrib && 0 == (dwAttrib & FILE_ATTRIBUTE_DIRECTORY);
+    }
+
+    // 判断文件夹是否存在
+    static BOOL IsDirExist(const wstring& csDir)
+    {
+        DWORD dwAttrib = GetFileAttributes(csDir.c_str());
+        return INVALID_FILE_ATTRIBUTES != dwAttrib && 0 != (dwAttrib & FILE_ATTRIBUTE_DIRECTORY);
+    }
+
+    // 判断文件或文件夹是否存在
+    static BOOL IsPathExist(const wstring& csPath)
+    {
+        DWORD dwAttrib = GetFileAttributes(csPath.c_str());
+        return INVALID_FILE_ATTRIBUTES != dwAttrib;
+    }
+
+    static std::string GetVersion()
+    {
+        std::string r = "";
+
+        UINT sz = GetFileVersionInfoSize(getExePath().c_str(), 0);
+        if(sz != 0)
+        {
+            r.resize(sz, 0);
+            char* pBuf = NULL;
+            pBuf = new char[sz];
+            VS_FIXEDFILEINFO* pVsInfo;
+            if(GetFileVersionInfo(getExePath().c_str(), 0, sz, pBuf))
+            {
+                if(VerQueryValue(pBuf, L"\\", (void**)&pVsInfo, &sz))
+                {
+                    sprintf(pBuf, "%d.%d.%d.%d", HIWORD(pVsInfo->dwFileVersionMS), LOWORD(pVsInfo->dwFileVersionMS), HIWORD(pVsInfo->dwFileVersionLS), LOWORD(pVsInfo->dwFileVersionLS));
+                    r = pBuf;
+                }
+            }
+            delete pBuf;
+        }
+        return r;
+    }
+};
+

+ 350 - 0
zhipuzi_pay_plugin/helper/MD5.cpp

@@ -0,0 +1,350 @@
+#include "../pch/pch.h"
+#include "MD5.h"
+
+#include <stdio.h>
+
+// Constants for MD5Transform routine.
+#define S11 7
+#define S12 12
+#define S13 17
+#define S14 22
+#define S21 5
+#define S22 9
+#define S23 14
+#define S24 20
+#define S31 4
+#define S32 11
+#define S33 16
+#define S34 23
+#define S41 6
+#define S42 10
+#define S43 15
+#define S44 21
+
+///////////////////////////////////////////////
+
+// F, G, H and I are basic MD5 functions.
+inline MD5::uint4 MD5::F(uint4 x, uint4 y, uint4 z)
+{
+    return x & y | ~x & z;
+}
+
+inline MD5::uint4 MD5::G(uint4 x, uint4 y, uint4 z)
+{
+    return x & z | y & ~z;
+}
+
+inline MD5::uint4 MD5::H(uint4 x, uint4 y, uint4 z)
+{
+    return x ^ y ^ z;
+}
+
+inline MD5::uint4 MD5::I(uint4 x, uint4 y, uint4 z)
+{
+    return y ^ (x | ~z);
+}
+
+// rotate_left rotates x left n bits.
+inline MD5::uint4 MD5::rotate_left(uint4 x, int n)
+{
+    return (x << n) | (x >> (32 - n));
+}
+
+// FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
+// Rotation is separate from addition to prevent recomputation.
+inline void MD5::FF(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
+{
+    a = rotate_left(a + F(b, c, d) + x + ac, s) + b;
+}
+
+inline void MD5::GG(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
+{
+    a = rotate_left(a + G(b, c, d) + x + ac, s) + b;
+}
+
+inline void MD5::HH(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
+{
+    a = rotate_left(a + H(b, c, d) + x + ac, s) + b;
+}
+
+inline void MD5::II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
+{
+    a = rotate_left(a + I(b, c, d) + x + ac, s) + b;
+}
+
+//////////////////////////////////////////////
+
+// default ctor, just initailize
+MD5::MD5()
+{
+    init();
+}
+
+//////////////////////////////////////////////
+
+// nifty shortcut ctor, compute MD5 for string and finalize it right away
+MD5::MD5(const std::string &text)
+{
+    init();
+    update(text.c_str(), text.length());
+    finalize();
+}
+
+//////////////////////////////
+
+void MD5::init()
+{
+    finalized = false;
+
+    count[0] = 0;
+    count[1] = 0;
+
+    // load magic initialization constants.
+    state[0] = 0x67452301;
+    state[1] = 0xefcdab89;
+    state[2] = 0x98badcfe;
+    state[3] = 0x10325476;
+}
+
+//////////////////////////////
+
+// decodes input (unsigned char) into output (uint4). Assumes len is a multiple of 4.
+void MD5::decode(uint4 output[], const uint1 input[], size_type len)
+{
+    for(unsigned int i = 0, j = 0; j < len; i++, j += 4)
+        output[i] = ((uint4)input[j]) | (((uint4)input[j + 1]) << 8) |
+                    (((uint4)input[j + 2]) << 16) | (((uint4)input[j + 3]) << 24);
+}
+
+//////////////////////////////
+
+// encodes input (uint4) into output (unsigned char). Assumes len is
+// a multiple of 4.
+void MD5::encode(uint1 output[], const uint4 input[], size_type len)
+{
+    for(size_type i = 0, j = 0; j < len; i++, j += 4)
+    {
+        output[j] = input[i] & 0xff;
+        output[j + 1] = (input[i] >> 8) & 0xff;
+        output[j + 2] = (input[i] >> 16) & 0xff;
+        output[j + 3] = (input[i] >> 24) & 0xff;
+    }
+}
+
+//////////////////////////////
+
+// apply MD5 algo on a block
+void MD5::transform(const uint1 block[blocksize])
+{
+    uint4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
+    decode(x, block, blocksize);
+
+    /* Round 1 */
+    FF(a, b, c, d, x[0], S11, 0xd76aa478); /* 1 */
+    FF(d, a, b, c, x[1], S12, 0xe8c7b756); /* 2 */
+    FF(c, d, a, b, x[2], S13, 0x242070db); /* 3 */
+    FF(b, c, d, a, x[3], S14, 0xc1bdceee); /* 4 */
+    FF(a, b, c, d, x[4], S11, 0xf57c0faf); /* 5 */
+    FF(d, a, b, c, x[5], S12, 0x4787c62a); /* 6 */
+    FF(c, d, a, b, x[6], S13, 0xa8304613); /* 7 */
+    FF(b, c, d, a, x[7], S14, 0xfd469501); /* 8 */
+    FF(a, b, c, d, x[8], S11, 0x698098d8); /* 9 */
+    FF(d, a, b, c, x[9], S12, 0x8b44f7af); /* 10 */
+    FF(c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
+    FF(b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
+    FF(a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
+    FF(d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
+    FF(c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
+    FF(b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
+
+    /* Round 2 */
+    GG(a, b, c, d, x[1], S21, 0xf61e2562); /* 17 */
+    GG(d, a, b, c, x[6], S22, 0xc040b340); /* 18 */
+    GG(c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
+    GG(b, c, d, a, x[0], S24, 0xe9b6c7aa); /* 20 */
+    GG(a, b, c, d, x[5], S21, 0xd62f105d); /* 21 */
+    GG(d, a, b, c, x[10], S22, 0x2441453); /* 22 */
+    GG(c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
+    GG(b, c, d, a, x[4], S24, 0xe7d3fbc8); /* 24 */
+    GG(a, b, c, d, x[9], S21, 0x21e1cde6); /* 25 */
+    GG(d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
+    GG(c, d, a, b, x[3], S23, 0xf4d50d87); /* 27 */
+    GG(b, c, d, a, x[8], S24, 0x455a14ed); /* 28 */
+    GG(a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
+    GG(d, a, b, c, x[2], S22, 0xfcefa3f8); /* 30 */
+    GG(c, d, a, b, x[7], S23, 0x676f02d9); /* 31 */
+    GG(b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
+
+    /* Round 3 */
+    HH(a, b, c, d, x[5], S31, 0xfffa3942); /* 33 */
+    HH(d, a, b, c, x[8], S32, 0x8771f681); /* 34 */
+    HH(c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
+    HH(b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
+    HH(a, b, c, d, x[1], S31, 0xa4beea44); /* 37 */
+    HH(d, a, b, c, x[4], S32, 0x4bdecfa9); /* 38 */
+    HH(c, d, a, b, x[7], S33, 0xf6bb4b60); /* 39 */
+    HH(b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
+    HH(a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
+    HH(d, a, b, c, x[0], S32, 0xeaa127fa); /* 42 */
+    HH(c, d, a, b, x[3], S33, 0xd4ef3085); /* 43 */
+    HH(b, c, d, a, x[6], S34, 0x4881d05); /* 44 */
+    HH(a, b, c, d, x[9], S31, 0xd9d4d039); /* 45 */
+    HH(d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
+    HH(c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
+    HH(b, c, d, a, x[2], S34, 0xc4ac5665); /* 48 */
+
+    /* Round 4 */
+    II(a, b, c, d, x[0], S41, 0xf4292244); /* 49 */
+    II(d, a, b, c, x[7], S42, 0x432aff97); /* 50 */
+    II(c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
+    II(b, c, d, a, x[5], S44, 0xfc93a039); /* 52 */
+    II(a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
+    II(d, a, b, c, x[3], S42, 0x8f0ccc92); /* 54 */
+    II(c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
+    II(b, c, d, a, x[1], S44, 0x85845dd1); /* 56 */
+    II(a, b, c, d, x[8], S41, 0x6fa87e4f); /* 57 */
+    II(d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
+    II(c, d, a, b, x[6], S43, 0xa3014314); /* 59 */
+    II(b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
+    II(a, b, c, d, x[4], S41, 0xf7537e82); /* 61 */
+    II(d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
+    II(c, d, a, b, x[2], S43, 0x2ad7d2bb); /* 63 */
+    II(b, c, d, a, x[9], S44, 0xeb86d391); /* 64 */
+
+    state[0] += a;
+    state[1] += b;
+    state[2] += c;
+    state[3] += d;
+
+    // Zeroize sensitive information.
+    memset(x, 0, sizeof x);
+}
+
+//////////////////////////////
+
+// MD5 block update operation. Continues an MD5 message-digest
+// operation, processing another message block
+void MD5::update(const unsigned char input[], size_type length)
+{
+    // compute number of bytes mod 64
+    size_type index = count[0] / 8 % blocksize;
+
+    // Update number of bits
+    if((count[0] += (length << 3)) < (length << 3))
+    {
+        count[1]++;
+    }
+    count[1] += (length >> 29);
+
+    // number of bytes we need to fill in buffer
+    size_type firstpart = 64 - index;
+
+    size_type i;
+
+    // transform as many times as possible.
+    if(length >= firstpart)
+    {
+        // fill buffer first, transform
+        memcpy(&buffer[index], input, firstpart);
+        transform(buffer);
+
+        // transform chunks of blocksize (64 bytes)
+        for(i = firstpart; i + blocksize <= length; i += blocksize)
+        {
+            transform(&input[i]);
+        }
+
+        index = 0;
+    }
+    else
+    {
+        i = 0;
+    }
+
+    // buffer remaining input
+    memcpy(&buffer[index], &input[i], length - i);
+}
+
+//////////////////////////////
+
+// for convenience provide a verson with signed char
+void MD5::update(const char input[], size_type length)
+{
+    update((const unsigned char*)input, length);
+}
+
+//////////////////////////////
+
+// MD5 finalization. Ends an MD5 message-digest operation, writing the
+// the message digest and zeroizing the context.
+MD5& MD5::finalize()
+{
+    static unsigned char padding[64] =
+    {
+        0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+    };
+
+    if(!finalized)
+    {
+        // Save number of bits
+        unsigned char bits[8];
+        encode(bits, count, 8);
+
+        // pad out to 56 mod 64.
+        size_type index = count[0] / 8 % 64;
+        size_type padLen = (index < 56) ? (56 - index) : (120 - index);
+        update(padding, padLen);
+
+        // Append length (before padding)
+        update(bits, 8);
+
+        // Store state in digest
+        encode(digest, state, 16);
+
+        // Zeroize sensitive information.
+        memset(buffer, 0, sizeof buffer);
+        memset(count, 0, sizeof count);
+
+        finalized = true;
+    }
+
+    return *this;
+}
+
+//////////////////////////////
+
+// return hex representation of digest as string
+std::string MD5::hexdigest() const
+{
+    if(!finalized)
+    {
+        return "";
+    }
+
+    char buf[33];
+    for(int i = 0; i < 16; i++)
+    {
+        sprintf(buf + i * 2, "%02x", digest[i]);
+    }
+    buf[32] = 0;
+
+    return std::string(buf);
+}
+
+//////////////////////////////
+
+std::ostream& operator<<(std::ostream& out, MD5 md5)
+{
+    return out << md5.hexdigest();
+}
+
+//////////////////////////////
+
+std::string md5(const std::string str)
+{
+    MD5 md5 = MD5(str);
+
+    return md5.hexdigest();
+}

+ 47 - 0
zhipuzi_pay_plugin/helper/MD5.h

@@ -0,0 +1,47 @@
+#pragma once
+
+#include <string>
+#include <iostream>
+
+class MD5
+{
+public:
+    typedef unsigned int size_type; // must be 32bit
+
+    MD5();
+    MD5(const std::string& text);
+    void update(const unsigned char *buf, size_type length);
+    void update(const char *buf, size_type length);
+    MD5& finalize();
+    std::string hexdigest() const;
+    friend std::ostream& operator<<(std::ostream&, MD5 md5);
+
+private:
+    void init();
+    typedef unsigned char uint1; //  8bit
+    typedef unsigned int uint4;  // 32bit
+    enum { blocksize = 64 }; // VC6 won't eat a const static int here
+
+    void transform(const uint1 block[blocksize]);
+    static void decode(uint4 output[], const uint1 input[], size_type len);
+    static void encode(uint1 output[], const uint4 input[], size_type len);
+
+    bool finalized;
+    uint1 buffer[blocksize]; // bytes that didn't fit in last 64 byte chunk
+    uint4 count[2];   // 64bit counter for number of bits (lo, hi)
+    uint4 state[4];   // digest so far
+    uint1 digest[16]; // the result
+
+    // low level logic operations
+    static inline uint4 F(uint4 x, uint4 y, uint4 z);
+    static inline uint4 G(uint4 x, uint4 y, uint4 z);
+    static inline uint4 H(uint4 x, uint4 y, uint4 z);
+    static inline uint4 I(uint4 x, uint4 y, uint4 z);
+    static inline uint4 rotate_left(uint4 x, int n);
+    static inline void FF(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
+    static inline void GG(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
+    static inline void HH(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
+    static inline void II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
+};
+
+std::string md5(const std::string str);

+ 16 - 0
zhipuzi_pay_plugin/helper/define.h

@@ -0,0 +1,16 @@
+#pragma once
+
+#define WM_SHOWTASK 10001
+#define WM_ONCLOSE 10002
+
+#define WM_LOGIN_ERROR 10003
+#define WM_LOGIN_SUCCESS 10004
+#define WM_NEED_UPDATE 10005
+#define WM_UPDATEPROGRESS 10006
+#define WM_DOWNLOAD_FINISH 10007
+
+#define WM_ORDERLIST_REFRESH 10008
+
+#define WM_LOGIN_AGAIN_OUT 10009
+
+

+ 217 - 0
zhipuzi_pay_plugin/network/CHttpClient.cpp

@@ -0,0 +1,217 @@
+#include "../pch/pch.h"
+#include "CHttpClient.h"
+
+#include <curl/curl.h>
+
+CHttpClient::CHttpClient(void) :
+	m_bDebug(false)
+{
+
+}
+
+CHttpClient::~CHttpClient(void)
+{
+
+}
+
+static int OnDebug(CURL *, curl_infotype itype, char * pData, size_t size, void *)
+{
+	if (itype == CURLINFO_TEXT)
+	{
+		//printf("[TEXT]%s\n", pData);
+	}
+	else if (itype == CURLINFO_HEADER_IN)
+	{
+		printf("[HEADER_IN]%s\n", pData);
+	}
+
+	else if (itype == CURLINFO_HEADER_OUT)
+	{
+		printf("[HEADER_OUT]%s\n", pData);
+	}
+
+	else if (itype == CURLINFO_DATA_IN)
+	{
+		printf("[DATA_IN]%s\n", pData);
+	}
+
+	else if (itype == CURLINFO_DATA_OUT)
+	{
+		printf("[DATA_OUT]%s\n", pData);
+	}
+
+	return 0;
+}
+
+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;
+	}
+
+	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)
+{
+	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)
+{
+	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)
+{
+	CURLcode res;
+	CURL* curl = curl_easy_init();
+
+	if (NULL == curl)
+	{
+		return CURLE_FAILED_INIT;
+	}
+
+	if (m_bDebug)
+	{
+		curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
+		curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, OnDebug);
+	}
+
+	curl_easy_setopt(curl, CURLOPT_URL, strUrl.c_str());
+	curl_easy_setopt(curl, CURLOPT_POST, 1);
+	curl_easy_setopt(curl, CURLOPT_POSTFIELDS, strPost.c_str());
+	curl_easy_setopt(curl, CURLOPT_READFUNCTION, NULL);
+	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, OnWriteData);
+	curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&strResponse);
+	curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
+	//curl_easy_setopt(curl, CURLOPT_COOKIE, "lwm_gray_tag=rc");;
+
+	if (NULL == pCaPath)
+	{
+		curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
+		curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, false);
+	}
+
+	else
+	{
+		//缺省情况就是PEM,所以无需设置,另外支持DER
+		//curl_easy_setopt(curl,CURLOPT_SSLCERTTYPE,"PEM");
+		curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, true);
+		curl_easy_setopt(curl, CURLOPT_CAINFO, pCaPath);
+	}
+
+	curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 8);//连接超时,这个数值如果设置太短可能导致数据请求不到就断开了
+	curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10);//接收数据时超时设置,如果10秒内数据未接收完,直接退出
+	res = curl_easy_perform(curl);
+	curl_easy_cleanup(curl);
+	return res;
+}
+
+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;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////
+
+void CHttpClient::SetDebug(bool bDebug)
+{
+	m_bDebug = bDebug;
+}

+ 54 - 0
zhipuzi_pay_plugin/network/CHttpClient.h

@@ -0,0 +1,54 @@
+#pragma once
+
+using namespace std;
+
+class CHttpClient
+{
+public:
+	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);
+
+public:
+	void SetDebug(bool bDebug);
+
+private:
+	bool m_bDebug;
+};
+

+ 542 - 0
zhipuzi_pay_plugin/network/CMessagePush.cpp

@@ -0,0 +1,542 @@
+#include "../pch/pch.h"
+#include "CMessagePush.h"
+
+#include "../tool/CPosPrinter.h"
+#include "../order/CWaimaiOrder.h"
+
+#include "mmsystem.h"
+
+#include "PosMessage.h"
+
+CMessagePush::~CMessagePush()
+{
+
+}
+
+void CMessagePush::Start()
+{
+    m_is_work = true;
+
+    m_nStopNum = 0;
+
+    //心跳包
+    std::thread(&CMessagePush::KeepAlive, this).detach();
+
+    //接收消息
+    std::thread(&CMessagePush::ReceiveMessage, this).detach();
+
+    //处理声音提醒
+    std::thread(&CMessagePush::HandleVoice, this).detach();
+
+    //处理订单确认
+    std::thread(&CMessagePush::HandleConfirm, this).detach();
+
+    //处理打印
+    std::thread(&CMessagePush::HandlePrinter, this).detach();
+
+    //处理收银打印
+    std::thread(&CMessagePush::HandleShouyinPrinter, this).detach();
+
+    //处理厨房打印
+    std::thread(&CMessagePush::HandleChufangPrinter, this).detach();
+}
+
+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();
+}
+
+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();
+}
+
+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();
+}
+
+/*
+ *类型 1:新外卖订单 2:新外卖订单自动接单 3:外卖订单取消 4:外卖订单退款
+ **/
+void CMessagePush::AddVoice(int voice_type)
+{
+    m_voice_mutex.lock();
+
+    m_voice_queue.push(voice_type);
+
+    m_voice_mutex.unlock();
+}
+
+void CMessagePush::AddConfirm(std::string order_id)
+{
+    m_confirm_mutex.lock();
+
+    m_confirm_queue.push(order_id);
+
+    m_confirm_mutex.unlock();
+}
+
+void CMessagePush::AddPinter(std::string order_id, std::string order_no, int print_type)
+{
+    m_printer_mutex.lock();
+
+    WaimaiPinterInfo newPrinter;
+    newPrinter.order_id = order_id;
+    newPrinter.order_no = order_no;
+    newPrinter.print_type = print_type;
+
+    m_printer_queue.push(newPrinter);
+
+    m_printer_mutex.unlock();
+}
+
+void CMessagePush::AddShouyinPrinter(CWaimaiOrder order)
+{
+    m_shouyin_printer_mutex.lock();
+
+    m_shouyin_printer_queue.push(order);
+
+    m_shouyin_printer_mutex.unlock();
+}
+
+void CMessagePush::AddChufangPrinter(CWaimaiOrder order)
+{
+    m_chufang_printer_mutex.lock();
+
+    m_chufang_printer_queue.push(order);
+
+    m_chufang_printer_mutex.unlock();
+}
+
+void CMessagePush::HandleVoice()
+{
+    while(m_is_work)
+    {
+        m_voice_mutex.lock();
+
+        if(m_voice_queue.empty())
+        {
+            m_voice_mutex.unlock();
+
+            CSystem::my_sleep(1);
+            continue;
+        }
+
+        int voice_type = m_voice_queue.front();
+        m_voice_queue.pop();
+
+        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);
+        }
+
+        //8秒内最多播放一次
+        CSystem::my_sleep(8);
+    }
+
+    AddStopNum();
+}
+
+void CMessagePush::HandleConfirm()
+{
+    while(m_is_work)
+    {
+        m_confirm_mutex.lock();
+
+        if(m_confirm_queue.empty())
+        {
+            m_confirm_mutex.unlock();
+
+            CSystem::my_sleep(1);
+            continue;
+        }
+
+        std::string order_id = m_confirm_queue.front();
+        m_confirm_queue.pop();
+
+        m_confirm_mutex.unlock();
+
+        CWaimaiOrder newOrder;
+        newOrder.ConfirmeOrder(order_id);
+    }
+
+    AddStopNum();
+}
+
+void CMessagePush::HandlePrinter()
+{
+    while(m_is_work)
+    {
+        m_printer_mutex.lock();
+
+        if(m_printer_queue.empty())
+        {
+            m_printer_mutex.unlock();
+
+            CSystem::my_sleep(1);
+            continue;
+        }
+
+        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;
+
+        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);
+        }
+    }
+
+    AddStopNum();
+}
+
+void CMessagePush::HandleShouyinPrinter()
+{
+    while(m_is_work)
+    {
+        m_shouyin_printer_mutex.lock();
+
+        if(m_shouyin_printer_queue.empty())
+        {
+            m_shouyin_printer_mutex.unlock();
+
+            CSystem::my_sleep(1);
+            continue;
+        }
+
+        CWaimaiOrder order = m_shouyin_printer_queue.front();
+
+        m_shouyin_printer_queue.pop();
+
+        m_shouyin_printer_mutex.unlock();
+
+        CPosPrinter printer;
+        printer.PrintWaimaiOrderShouyin(order);
+    }
+
+    AddStopNum();
+}
+
+void CMessagePush::HandleChufangPrinter()
+{
+    while(m_is_work)
+    {
+        m_chufang_printer_mutex.lock();
+
+        if(m_chufang_printer_queue.empty())
+        {
+            m_chufang_printer_mutex.unlock();
+
+            CSystem::my_sleep(1);
+            continue;
+        }
+
+        CWaimaiOrder order = m_chufang_printer_queue.front();
+
+        m_chufang_printer_queue.pop();
+
+        m_chufang_printer_mutex.unlock();
+
+        CPosPrinter printer;
+        printer.PrintWaimaiOrderChufang(order);
+    }
+
+    AddStopNum();
+}
+
+void CMessagePush::AddStopNum()
+{
+    m_nStopNumMutex.lock();
+
+    m_nStopNum++;
+
+    m_nStopNumMutex.unlock();
+
+    if(m_nStopNum == 7)
+    {
+        //确认所有子线程都退出了,再删除自己
+        delete this;
+    }
+}

+ 92 - 0
zhipuzi_pay_plugin/network/CMessagePush.h

@@ -0,0 +1,92 @@
+#pragma once
+
+#include "../pch/pch.h"
+#include "../order/CWaimaiOrder.h"
+
+using boost::asio::ip::tcp;
+
+class CClientMessage
+{
+public:
+    int m_type; //消息类型 0:新的外卖订单
+
+    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:手动打印
+};
+
+class CMessagePush
+{
+public:
+    CMessagePush(HWND hwnd)
+        : socket_(m_io_context)
+    {
+        m_hwnd = hwnd;
+    }
+
+    ~CMessagePush();
+
+    //开始工作
+    void Start();
+
+    //停止工作
+    void Stop();
+
+    //发送心跳包
+    void KeepAlive();
+
+    //专门处理推送消息
+    void ReceiveMessage();
+
+    //队列处理
+    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);
+
+private:
+    void AddStopNum();
+
+private:
+    bool m_is_work;
+
+    int m_nStopNum = 0;
+    std::mutex m_nStopNumMutex;
+
+    boost::asio::io_context m_io_context;
+    tcp::socket socket_;
+
+    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::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;
+};
+

+ 238 - 0
zhipuzi_pay_plugin/network/CZhipuziHttpClient.cpp

@@ -0,0 +1,238 @@
+#include "../pch/pch.h"
+#include "CZhipuziHttpClient.h"
+
+#include "../helper/MD5.h"
+
+CZhipuziHttpClient CZhipuziHttpClient::m_client;
+
+CZhipuziHttpClient::CZhipuziHttpClient()
+{
+    m_username = CSetting::getUsername();
+    m_password = CSetting::getPassword();
+}
+
+
+CZhipuziHttpClient::~CZhipuziHttpClient()
+{
+}
+
+void CZhipuziHttpClient::Init(std::string username, std::string 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.RequestPingtai("/userlogin/userlogin", 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 || errcode < 0)
+        {
+            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;
+        }
+    }
+
+	rapidjson::Value& v_data = document["data"];
+
+	rapidjson::Value& v_version_type = v_data["version_type"];
+	m_client.m_version_type = v_version_type.GetString();
+
+	if (m_client.m_version_type == "1")
+	{
+		m_client.m_yewu_ur = "https://cyapi.zhipuzi.com/pos";
+	}
+	else
+	{
+		m_client.m_yewu_ur = "https://lsapi.zhipuzi.com/pos";
+	}
+
+	rapidjson::Value& v_lwm_sess_token = v_data["lwm_sess_token"];
+	m_client.lwm_sess_token = v_lwm_sess_token.GetString();
+
+    LOG_INFO("login success!");
+
+    return true;
+}
+
+bool CZhipuziHttpClient::Request(std::string url, std::map<string, string> params, std::string& response)
+{
+    std::string timestamp = to_string(time(NULL));
+    std::string nonce = "123456";
+
+    //先添加默认参数,用于计算签名
+    params["username"] = m_client.m_username;
+    params["nonce"] = nonce;
+    params["timestamp"] = timestamp;
+    params["url"] = m_client.m_yewu_ur + url;
+
+    //计算签名
+    std::string postString;
+    for(std::map<string, string>::iterator it = params.begin(); it != params.end();)
+    {
+        postString += it->first + "=" + it->second;
+
+        it++;
+
+        if(it != params.end())
+        {
+            postString += "&";
+        }
+    }
+
+    LOG_INFO("postString:" << postString.c_str());
+
+    //用于计算签名的临时变量
+    std::string password = md5(m_client.m_password);
+    transform(password.begin(), password.end(), password.begin(), ::toupper);
+
+    string tmp = postString + password;
+
+    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");
+
+    //未签名之前,不能进行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++;
+
+        if(it != params.end())
+        {
+            postString += "&";
+        }
+    }
+
+    LOG_INFO("postString:" << postString.c_str());
+
+    CHttpClient m_httpClient;
+    int ret = m_httpClient.Posts(m_client.m_yewu_ur + url, postString, response, NULL);
+
+    LOG_INFO("response:" << response.c_str());
+
+    if(ret == 0)
+    {
+        //ret为0表示没有出错
+        return true;
+    }
+
+    return false;
+}
+
+bool CZhipuziHttpClient::RequestPingtai(std::string url, std::map<string, string> params, std::string& response)
+{
+	std::string timestamp = to_string(time(NULL));
+	std::string nonce = "123456";
+
+	//先添加默认参数,用于计算签名
+	params["username"] = m_client.m_username;
+	params["nonce"] = nonce;
+	params["timestamp"] = timestamp;
+	params["url"] = m_client.m_pingtai_url + url;
+
+	params["timestamp"] = "1564301876";
+
+	//计算签名
+	std::string postString;
+	for (std::map<string, string>::iterator it = params.begin(); it != params.end();)
+	{
+		postString += it->first + "=" + it->second;
+
+		it++;
+
+		if (it != params.end())
+		{
+			postString += "&";
+		}
+	}
+
+	LOG_INFO("postString:" << postString.c_str());
+
+	//用于计算签名的临时变量
+	std::string password = md5(m_client.m_password);
+	transform(password.begin(), password.end(), password.begin(), ::toupper);
+
+	string tmp = postString + password;
+
+	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");
+
+	//未签名之前,不能进行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++;
+
+		if (it != params.end())
+		{
+			postString += "&";
+		}
+	}
+
+	LOG_INFO("postString:" << postString.c_str());
+
+	CHttpClient m_httpClient;
+	int ret = m_httpClient.Posts(m_client.m_pingtai_url + url, postString, response, NULL);
+
+	LOG_INFO("response:" << response.c_str());
+
+	if (ret == 0)
+	{
+		//ret为0表示没有出错
+		return true;
+	}
+
+	return false;
+}

+ 30 - 0
zhipuzi_pay_plugin/network/CZhipuziHttpClient.h

@@ -0,0 +1,30 @@
+#pragma once
+
+#include "CHttpClient.h"
+
+class CZhipuziHttpClient
+{
+public:
+    CZhipuziHttpClient();
+    ~CZhipuziHttpClient();
+
+public:
+    static void Init(std::string username, std::string password);
+
+    static bool Login(std::string& errmsg);
+
+    static bool Request(std::string url, std::map<string, string> params, std::string& response);
+	static bool RequestPingtai(std::string url, std::map<string, string> params, std::string& response);
+public:
+    static CZhipuziHttpClient m_client;
+
+private:
+    std::string m_username;
+    std::string m_password;
+
+    std::string m_pingtai_url = "https://pf-api.zhipuzi.com/pos";
+	std::string m_yewu_ur = "";
+
+	std::string m_version_type;
+	std::string lwm_sess_token;
+};

+ 10 - 0
zhipuzi_pay_plugin/network/PosMessage.h

@@ -0,0 +1,10 @@
+#pragma once
+
+class PosMessage
+{
+public:
+	enum { max_length = 1024 };
+	char data[max_length];
+
+	int m_length;
+};

+ 394 - 0
zhipuzi_pay_plugin/order/CWaimaiOrder.cpp

@@ -0,0 +1,394 @@
+#include "../pch/pch.h"
+#include "CWaimaiOrder.h"
+
+CWaimaiOrder::CWaimaiOrder()
+{
+}
+
+
+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::Request("/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::Request(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::Request(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::Request(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::Request(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::Request(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;
+}

+ 125 - 0
zhipuzi_pay_plugin/order/CWaimaiOrder.h

@@ -0,0 +1,125 @@
+#pragma once
+
+#include <string>
+#include <vector>
+
+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;
+};
+
+class CWaimaiOrderField
+{
+public:
+    std::string name;
+    std::string value;
+};
+
+class CWaimaiOrder
+{
+public:
+    CWaimaiOrder();
+    ~CWaimaiOrder();
+
+    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 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;
+};
+

+ 5 - 0
zhipuzi_pay_plugin/pch/pch.cpp

@@ -0,0 +1,5 @@
+// pch.cpp: 与预编译标头对应的源文件;编译成功所必需的
+
+#include "pch.h"
+
+// 一般情况下,忽略此文件,但如果你使用的是预编译标头,请保留它。

+ 92 - 0
zhipuzi_pay_plugin/pch/pch.h

@@ -0,0 +1,92 @@
+// 入门提示: 
+//   1. 使用解决方案资源管理器窗口添加/管理文件
+//   2. 使用团队资源管理器窗口连接到源代码管理
+//   3. 使用输出窗口查看生成输出和其他消息
+//   4. 使用错误列表窗口查看错误
+//   5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
+//   6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件
+
+#ifndef PCH_H
+#define PCH_H
+
+ /*
+ 标准库头文件
+ */
+#include <string>
+#include <vector>
+#include <list>
+#include <queue>
+#include <map>
+#include <algorithm>
+#include <limits>
+#include <thread>
+#include <chrono>
+#include <mutex>
+#include <stdexcept>  
+#include <exception>
+#include <cstdlib>
+#include <ctime>
+#include <cstring>
+#include <iostream>
+#include <fstream>
+#include <iomanip>
+#include <regex>
+
+using namespace std;
+
+/*
+ *boost库的头文件
+ **/
+#include <boost/asio.hpp>
+#include <boost/bind.hpp>
+
+/*
+ *操作系统相关的头文件
+ **/
+#ifdef _WIN32
+#include <windows.h>
+#include<io.h>
+#include <ShellAPI.h>
+#else
+#include <unistd.h>
+#include <sys/sysinfo.h>
+#endif
+
+#include <atltypes.h>
+#include <objbase.h>
+#include <zmouse.h>
+#include <exdisp.h>
+#include <comdef.h>
+
+ /*
+  *UI库用到的一些东西
+  **/
+#include <DuiLib/UIlib.h>
+using namespace DuiLib;
+
+#include "../resource/resource.h"
+
+//json库
+#include "rapidjson/document.h"
+#include "rapidjson/prettywriter.h"  
+#include "rapidjson/writer.h"
+#include "rapidjson/stringbuffer.h"
+
+using namespace rapidjson;
+
+/*
+ *常用的辅助函数
+ **/
+#include "../helper/define.h"
+#include "../helper/CRandomHelper.h"
+#include "../helper/CSystem.h"
+#include "../helper/CLewaimaiString.h"
+
+#include "../tool/CLewaimaiLog.h"
+#include "../tool/CLewaimaiTime.h"
+#include "../tool/CSqlite3.h"
+#include "../tool/CSetting.h"
+
+#include "../network/CZhipuziHttpClient.h"
+
+#endif //PCH_H

+ 17 - 0
zhipuzi_pay_plugin/resource/resource.h

@@ -0,0 +1,17 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ 生成的包含文件。
+// 供 zhipuzi_pay_plugin.rc 使用
+//
+#define IDI_ICON1                       101
+#define IDI_ICON_DUILIB                 101
+
+// Next default values for new objects
+// 
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE        102
+#define _APS_NEXT_COMMAND_VALUE         40001
+#define _APS_NEXT_CONTROL_VALUE         1001
+#define _APS_NEXT_SYMED_VALUE           101
+#endif
+#endif

BIN
zhipuzi_pay_plugin/resource/zhipuzi.ico


BIN
zhipuzi_pay_plugin/resource/zhipuzi_pay_plugin.aps


BIN
zhipuzi_pay_plugin/resource/zhipuzi_pay_plugin.rc


+ 49 - 0
zhipuzi_pay_plugin/tool/CLewaimaiLog.cpp

@@ -0,0 +1,49 @@
+#include "../pch/pch.h"
+#include "CLewaimaiLog.h"
+
+CLewaimaiLog::CLewaimaiLog()
+{
+	
+}
+
+CLewaimaiLog::~CLewaimaiLog()
+{
+	log4cplus::Logger::shutdown();
+}
+
+void CLewaimaiLog::Init()
+{
+	log4cplus::initialize();
+
+	//调试模式
+	helpers::LogLog::getLogLog()->setInternalDebugging(false);
+
+	wstring path = CSystem::GetProgramDir() + L"\\log\\pos.log";
+	wstring err_path = CSystem::GetProgramDir() + L"\\log\\pos_error.log";
+
+	SharedFileAppenderPtr append_1(
+		new RollingFileAppender(path.c_str(), 200 * 1024 * 1024, 100,
+			true, true));
+
+	SharedFileAppenderPtr append_2(
+		new RollingFileAppender(err_path.c_str(), 200 * 1024 * 1024, 100,
+			true, true));
+
+	append_1->setName(LOG4CPLUS_TEXT("lewaimai_dispatch"));
+	append_1->setLayout(std::auto_ptr<Layout>(new PatternLayout(LOG4CPLUS_TEXT("%D{%Y-%m-%d %H:%M:%S}[%p] - %m [%l]%n"))));
+	append_1->getloc();
+
+	append_2->setName(LOG4CPLUS_TEXT("lewaimai_dispatch_error"));
+	append_2->setLayout(std::auto_ptr<Layout>(new PatternLayout(LOG4CPLUS_TEXT("%D{%Y-%m-%d %H:%M:%S}[%p] - %m [%l]%n"))));
+	append_2->getloc();
+
+	Logger _Logger_info = Logger::getInstance(LOG4CPLUS_TEXT("lewaimai_dispatch"));
+	_Logger_info.addAppender(SharedAppenderPtr(append_1.get()));
+	//日志优先级从低到高ALL_LOG_LEVEL、TRACE_LOG_LEVEL、DEBUG_LOG_LEVEL、INFO_LOG_LEVEL、WARN_LOG_LEVEL、ERROR_LOG_LEVEL、FATAL_LOG_LEVEL、OFF_LOG_LEVEL
+	_Logger_info.setLogLevel(INFO_LOG_LEVEL);
+
+	Logger _Logger_error = Logger::getInstance(LOG4CPLUS_TEXT("lewaimai_dispatch_error"));
+	_Logger_error.addAppender(SharedAppenderPtr(append_2.get()));
+	//日志优先级从低到高ALL_LOG_LEVEL、TRACE_LOG_LEVEL、DEBUG_LOG_LEVEL、INFO_LOG_LEVEL、WARN_LOG_LEVEL、ERROR_LOG_LEVEL、FATAL_LOG_LEVEL、OFF_LOG_LEVEL
+	_Logger_error.setLogLevel(ERROR_LOG_LEVEL);
+}

+ 29 - 0
zhipuzi_pay_plugin/tool/CLewaimaiLog.h

@@ -0,0 +1,29 @@
+#pragma once
+
+#define LOG_TRACE(logs) LOG4CPLUS_TRACE(log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("lewaimai_dispatch")), logs)
+#define LOG_DEBUG(logs) LOG4CPLUS_DEBUG(log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("lewaimai_dispatch")), logs)
+#define LOG_INFO(logs) LOG4CPLUS_INFO(log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("lewaimai_dispatch")), logs)
+#define LOG_ERROR(logs) LOG4CPLUS_ERROR(log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("lewaimai_dispatch_error")), logs)
+
+/*
+日志库头文件
+*/
+#include <log4cplus/logger.h>
+#include <log4cplus/fileappender.h>
+#include <log4cplus/layout.h>
+#include <log4cplus/ndc.h>
+#include <log4cplus/helpers/loglog.h>
+#include <log4cplus/helpers/property.h>
+#include <log4cplus/loggingmacros.h>
+
+using namespace log4cplus;
+
+class CLewaimaiLog
+{
+public:
+	CLewaimaiLog();
+	~CLewaimaiLog();
+
+	void Init();
+};
+

+ 164 - 0
zhipuzi_pay_plugin/tool/CLewaimaiTime.cpp

@@ -0,0 +1,164 @@
+#include "../pch/pch.h"
+#include "CLewaimaiTime.h"
+
+
+CLewaimaiTime::CLewaimaiTime()
+{
+}
+
+
+CLewaimaiTime::~CLewaimaiTime()
+{
+}
+
+time_t CLewaimaiTime::StringToDatetime(string str)
+{
+	char *cha = (char*)str.data();             // 将string转换成char*。
+	tm tm_;                                    // 定义tm结构体。
+	int year, month, day, hour, minute, second;// 定义时间的各个int临时变量。
+	sscanf(cha, "%d-%d-%d %d:%d:%d", &year, &month, &day, &hour, &minute, &second);// 将string存储的日期时间,转换为int临时变量。
+	tm_.tm_year = year - 1900;                 // 年,由于tm结构体存储的是从1900年开始的时间,所以tm_year为int临时变量减去1900。
+	tm_.tm_mon = month - 1;                    // 月,由于tm结构体的月份存储范围为0-11,所以tm_mon为int临时变量减去1。
+	tm_.tm_mday = day;                         // 日。
+	tm_.tm_hour = hour;                        // 时。
+	tm_.tm_min = minute;                       // 分。
+	tm_.tm_sec = second;                       // 秒。
+	tm_.tm_isdst = 0;                          // 非夏令时。
+	time_t t_ = mktime(&tm_);                  // 将tm结构体转换成time_t格式。
+	return t_;                                 // 返回值。 
+}
+
+string CLewaimaiTime::DatetimeToString(time_t time)
+{
+	struct tm tm_;
+
+#ifdef _WIN32
+	localtime_s(&tm_, &time);                // 将time_t格式转换为tm结构体
+#else
+	localtime_r(&time, &tm_);                // 将time_t格式转换为tm结构体
+#endif
+
+	int year, month, day, hour, minute, second;// 定义时间的各个int临时变量。
+	year = tm_.tm_year + 1900;                // 临时变量,年,由于tm结构体存储的是从1900年开始的时间,所以临时变量int为tm_year加上1900。
+	month = tm_.tm_mon + 1;                   // 临时变量,月,由于tm结构体的月份存储范围为0-11,所以临时变量int为tm_mon加上1。
+	day = tm_.tm_mday;                        // 临时变量,日。
+	hour = tm_.tm_hour;                       // 临时变量,时。
+	minute = tm_.tm_min;                      // 临时变量,分。
+	second = tm_.tm_sec;                      // 临时变量,秒。
+	char yearStr[5], monthStr[3], dayStr[3], hourStr[3], minuteStr[3], secondStr[3];// 定义时间的各个char*变量。
+	sprintf(yearStr, "%d", year);              // 年。
+	sprintf(monthStr, "%d", month);            // 月。
+	sprintf(dayStr, "%d", day);                // 日。
+	sprintf(hourStr, "%d", hour);              // 时。
+	sprintf(minuteStr, "%d", minute);          // 分。
+	if (hourStr[1] == '\0')                  // 如果小时为一位,如5,则需要转换字符串为两位,如05。
+	{
+		hourStr[2] = '\0';
+		hourStr[1] = hourStr[0];
+		hourStr[0] = '0';
+	}
+	if (minuteStr[1] == '\0')                  // 如果分为一位,如5,则需要转换字符串为两位,如05。
+	{
+		minuteStr[2] = '\0';
+		minuteStr[1] = minuteStr[0];
+		minuteStr[0] = '0';
+	}
+	sprintf(secondStr, "%d", second);          // 秒。
+	if (secondStr[1] == '\0')                  // 如果秒为一位,如5,则需要转换字符串为两位,如05。
+	{
+		secondStr[2] = '\0';
+		secondStr[1] = secondStr[0];
+		secondStr[0] = '0';
+	}
+	char s[20];                                // 定义总日期时间char*变量。
+	sprintf(s, "%s-%s-%s %s:%s:%s", yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr);// 将年月日时分秒合并。
+	string str(s);                             // 定义string变量,并将总日期时间char*变量作为构造函数的参数传入。
+	return str;                                // 返回转换日期时间后的string变量。
+}
+
+string CLewaimaiTime::DatetimeToDateString(time_t time)
+{
+	struct tm tm_;
+
+#ifdef _WIN32
+	localtime_s(&tm_, &time);                // 将time_t格式转换为tm结构体
+#else
+	localtime_r(&time, &tm_);                // 将time_t格式转换为tm结构体
+#endif
+
+	int year, month, day, hour, minute, second;// 定义时间的各个int临时变量。
+	year = tm_.tm_year + 1900;                // 临时变量,年,由于tm结构体存储的是从1900年开始的时间,所以临时变量int为tm_year加上1900。
+	month = tm_.tm_mon + 1;                   // 临时变量,月,由于tm结构体的月份存储范围为0-11,所以临时变量int为tm_mon加上1。
+	day = tm_.tm_mday;                        // 临时变量,日。
+	hour = tm_.tm_hour;                       // 临时变量,时。
+	minute = tm_.tm_min;                      // 临时变量,分。
+	second = tm_.tm_sec;                      // 临时变量,秒。
+	char yearStr[5], monthStr[3], dayStr[3], hourStr[3], minuteStr[3], secondStr[3];// 定义时间的各个char*变量。
+	sprintf(yearStr, "%d", year);              // 年。
+	sprintf(monthStr, "%d", month);            // 月。
+	sprintf(dayStr, "%d", day);                // 日。
+	sprintf(hourStr, "%d", hour);              // 时。
+	sprintf(minuteStr, "%d", minute);          // 分。
+	if (hourStr[1] == '\0')                  // 如果小时为一位,如5,则需要转换字符串为两位,如05。
+	{
+		hourStr[2] = '\0';
+		hourStr[1] = hourStr[0];
+		hourStr[0] = '0';
+	}
+	if (minuteStr[1] == '\0')                  // 如果分为一位,如5,则需要转换字符串为两位,如05。
+	{
+		minuteStr[2] = '\0';
+		minuteStr[1] = minuteStr[0];
+		minuteStr[0] = '0';
+	}
+	sprintf(secondStr, "%d", second);          // 秒。
+	if (secondStr[1] == '\0')                  // 如果秒为一位,如5,则需要转换字符串为两位,如05。
+	{
+		secondStr[2] = '\0';
+		secondStr[1] = secondStr[0];
+		secondStr[0] = '0';
+	}
+	char s[11];                                // 定义总日期时间char*变量。
+	sprintf(s, "%s-%s-%s", yearStr, monthStr, dayStr);// 将年月日合并。
+	string str(s);                             // 定义string变量,并将总日期时间char*变量作为构造函数的参数传入。
+	return str;                                // 返回转换日期时间后的string变量。
+}
+
+string CLewaimaiTime::DatetimeToHourString(time_t time)
+{
+	struct tm tm_;
+
+#ifdef _WIN32
+	localtime_s(&tm_, &time);                // 将time_t格式转换为tm结构体
+#else
+	localtime_r(&time, &tm_);                // 将time_t格式转换为tm结构体
+#endif
+
+	int hour = tm_.tm_hour;
+
+	return to_string(hour);
+}
+
+#ifdef _WIN32
+std::chrono::steady_clock::time_point CLewaimaiTime::getTimeStamp()
+{
+	return std::chrono::high_resolution_clock::now();
+}
+
+float CLewaimaiTime::getTimeDiff(std::chrono::steady_clock::time_point start, std::chrono::steady_clock::time_point end)
+{
+	return std::chrono::duration<float, std::milli>(end - start).count();
+}
+#else
+std::chrono::_V2::system_clock::time_point CLewaimaiTime::getTimeStamp()
+{
+	return std::chrono::high_resolution_clock::now();
+}
+
+float CLewaimaiTime::getTimeDiff(std::chrono::_V2::system_clock::time_point start, std::chrono::_V2::system_clock::time_point end)
+{
+	return std::chrono::duration<float, std::milli>(end - start).count();
+}
+#endif
+
+

+ 29 - 0
zhipuzi_pay_plugin/tool/CLewaimaiTime.h

@@ -0,0 +1,29 @@
+#pragma once
+
+#include <ctime>
+
+class CLewaimaiTime
+{
+public:
+	CLewaimaiTime();
+	~CLewaimaiTime();
+
+	static time_t StringToDatetime(string str);
+	static string DatetimeToString(time_t time);
+
+	//将time转换成日期,不包含时间
+	static string DatetimeToDateString(time_t time);
+
+	//将time转换成小时数
+	static string DatetimeToHourString(time_t time);
+
+#ifdef _WIN32
+	static std::chrono::steady_clock::time_point getTimeStamp();
+	static float getTimeDiff(std::chrono::steady_clock::time_point start, std::chrono::steady_clock::time_point end);
+#else
+	static std::chrono::_V2::system_clock::time_point getTimeStamp();
+	static float getTimeDiff(std::chrono::_V2::system_clock::time_point start, std::chrono::_V2::system_clock::time_point end);
+#endif
+
+};
+

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 1663 - 0
zhipuzi_pay_plugin/tool/CPosPrinter.cpp


+ 88 - 0
zhipuzi_pay_plugin/tool/CPosPrinter.h

@@ -0,0 +1,88 @@
+#pragma once
+
+#include "../pch/pch.h"
+#include "../order/CWaimaiOrder.h"
+
+//SetupDiGetInterfaceDeviceDetail所需要的输出长度,定义足够大
+#define INTERFACE_DETAIL_SIZE	1024
+
+//设备数量上限,假设16台上限
+#define MAX_DEVICE 16
+
+//USB类的GUID
+//const GUID USB_GUID = {0xa5dcbf10, 0x6530, 0x11d2, {0x90, 0x1f, 0x00, 0xc0, 0x4f, 0xb9, 0x51, 0xed}};
+const GUID USB_GUID = { 0x28d78fad, 0x5a12, 0x11d1, {0xae, 0x5b, 0x00, 0x00, 0xf8, 0x03, 0xa8, 0xc2 } };
+
+//存储打印端口句柄的结构
+class PrinterHandle
+{
+public:
+    HANDLE hPort;
+    int type; //句柄类型 1:usb 2:并口 3:串口
+};
+
+class CPosPrinter
+{
+public:
+    CPosPrinter();
+    ~CPosPrinter();
+
+    void PrintWaimaiOrderShouyin(CWaimaiOrder& order);
+    void PrintWaimaiOrderChufang(CWaimaiOrder& order);
+
+    void InitUsb();
+    std::vector<std::wstring> getUsbDevices();
+
+private:
+    void InitBingkou();
+    void InitCom();
+
+    void InitShouyin();
+
+    void InitOneUsb(wstring usb_path);
+
+    int GetDevicePath(LPGUID lpGuid);
+    int GetPrinterType(wstring vid, wstring pid);
+
+    int WriteData(string meg);
+    int WriteBuf(const char* buf, int len);
+
+    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_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_CutPaper();
+    int POS_OutQRCode();
+
+    //字符空格计算的辅助函数
+    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);
+
+private:
+    std::vector<PrinterHandle> m_hPorts;
+
+    boost::asio::io_service m_io;
+    boost::asio::ip::tcp::socket m_socket;
+
+    //这个是当前的输出模式,是收银模式还是厨房打印模式
+    int m_type;
+
+    //usb打印机的描述
+    std::vector<std::wstring> m_usb_devices;
+};

+ 312 - 0
zhipuzi_pay_plugin/tool/CSetting.cpp

@@ -0,0 +1,312 @@
+#include "../pch/pch.h"
+#include "CSetting.h"
+
+#include "CSqlite3.h"
+
+std::map<std::string, std::string> CSetting::m_paramsMap;
+std::vector<ChufangPrinter> CSetting::m_chufang_printers;
+std::mutex CSetting::m_mutex;
+std::vector<FoodType> CSetting::m_foodtypes;
+std::map<std::string, std::string> CSetting::m_foodtype_id_name;
+std::map<string, string> CSetting::m_users;
+std::string CSetting::m_username;
+std::string CSetting::m_password;
+
+CSetting::CSetting()
+{
+}
+
+
+CSetting::~CSetting()
+{
+}
+
+void CSetting::SetParam(std::string name, std::string value, bool isSave)
+{
+    m_mutex.lock();
+
+    m_paramsMap[name] = value;
+
+    m_mutex.unlock();
+
+    if(isSave)
+    {
+        SaveParams();
+    }
+}
+
+std::string CSetting::GetParam(std::string name)
+{
+    m_mutex.lock();
+
+    std::string value = m_paramsMap[name];
+
+    m_mutex.unlock();
+
+    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();
+    }
+}
+
+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();
+    }
+}
+
+/*
+ *删除厨房打印机,默认会同步到数据库
+ **/
+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);
+
+            break;
+        }
+    }
+
+    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();
+}
+
+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_leixing = "setting_printer_leixing";
+	if (m_paramsMap.find(setting_printer_leixing) == m_paramsMap.end())
+	{
+		m_paramsMap[setting_printer_leixing] = "auto";
+	}
+
+	std::string setting_printer_usb = "setting_printer_usb";
+	if (m_paramsMap.find(setting_printer_usb) == m_paramsMap.end())
+	{
+		m_paramsMap[setting_printer_usb] = "";
+	}
+
+	std::string setting_printer_wangkou_ip = "setting_printer_wangkou_ip";
+	if (m_paramsMap.find(setting_printer_wangkou_ip) == m_paramsMap.end())
+	{
+		m_paramsMap[setting_printer_wangkou_ip] = "";
+	}
+
+    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);
+}
+
+void CSetting::SaveChufangPrinter()
+{
+    CSqlite3 sqllite;
+    sqllite.SaveChufangPrinter(m_chufang_printers);
+}
+
+void CSetting::SaveUsers()
+{
+    CSqlite3 sqllite;
+    sqllite.SaveUsers(m_users);
+}

+ 155 - 0
zhipuzi_pay_plugin/tool/CSetting.h

@@ -0,0 +1,155 @@
+#pragma once
+
+#include "../pch/pch.h"
+
+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;
+};
+
+class FoodType
+{
+public:
+    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();
+
+private:
+    static std::map<std::string, std::string> m_paramsMap;
+    static std::vector<ChufangPrinter> m_chufang_printers;
+
+    static std::mutex m_mutex;
+
+    static std::vector<FoodType> m_foodtypes;
+
+    //从商品分类的id到name的映射
+    static std::map<std::string, std::string> m_foodtype_id_name;
+
+    static std::map<string, string> m_users;
+
+    static std::string m_username;
+    static std::string m_password;
+};
+

+ 398 - 0
zhipuzi_pay_plugin/tool/CSqlite3.cpp

@@ -0,0 +1,398 @@
+#include "../pch/pch.h"
+#include "CSqlite3.h"
+
+#include "CSetting.h"
+
+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 path = CSystem::GetProgramDir() + L"\\db\\pos.db";
+    string s_path = CLewaimaiString::UnicodeToUTF8(path);
+
+    m_rc = sqlite3_open(s_path.c_str(), &m_db);
+
+    if(m_rc)
+    {
+        LOG_INFO("Can't open database: " << sqlite3_errmsg(m_db));
+        return;
+    }
+
+    else
+    {
+        LOG_INFO("Opened database successfully");
+    }
+}
+
+CSqlite3::~CSqlite3()
+{
+    if(m_db != NULL)
+    {
+        sqlite3_close(m_db);
+    }
+}
+
+bool CSqlite3::InitConfig()
+{
+    //检查有没有pos_config这个表,如果没有就创建
+    std::string sql = "SELECT COUNT(*) FROM sqlite_master where type = 'table' and name = 'pos_config';";
+    sqlite3_stmt* stmt = NULL;
+
+    if(sqlite3_prepare_v2(m_db, sql.c_str(), -1, &stmt, NULL) == SQLITE_OK)
+    {
+        if(sqlite3_step(stmt) == SQLITE_ROW)
+        {
+            int count = sqlite3_column_int(stmt, 0);
+
+            if(count == 0)
+            {
+                //说明没找到这个表,那么这个时候新建这个表,先释放前面的stmt
+                sqlite3_finalize(stmt);
+                stmt = NULL;
+
+                sql = "CREATE TABLE pos_config("  \
+                      "name  CHAR(100)  UNIQUE       NOT NULL," \
+                      "value CHAR(2000)              NOT NULL);";
+
+                if(sqlite3_prepare_v2(m_db, sql.c_str(), -1, &stmt, NULL) == SQLITE_OK)
+                {
+                    //执行该语句
+                    if(sqlite3_step(stmt) != SQLITE_DONE)
+                    {
+                        LOG_INFO("create table fail: " << sqlite3_errmsg(m_db));
+
+                        sqlite3_finalize(stmt);
+                        return false;
+                    }
+
+                    //走到这里就是表创建成功了
+                    LOG_INFO("create table success");
+                    sqlite3_finalize(stmt);
+                }
+
+                else
+                {
+                    LOG_INFO("create table prepare fail: " << sqlite3_errmsg(m_db));
+
+                    sqlite3_finalize(stmt);
+
+                    return false;
+                }
+            }
+
+            else
+            {
+                //说明已经有这个表了,就不用再创建了
+                sqlite3_finalize(stmt);
+            }
+
+            std::string sql = "SELECT * FROM pos_config;";
+            sqlite3_stmt* stmt = NULL;
+
+            if(sqlite3_prepare_v2(m_db, sql.c_str(), -1, &stmt, NULL) == SQLITE_OK)
+            {
+                while(sqlite3_step(stmt) == SQLITE_ROW)
+                {
+                    std::string name = (char*)sqlite3_column_text(stmt, 0);
+                    std::string value = (char*)sqlite3_column_text(stmt, 1);
+
+                    CSetting::SetParam(name, value, false);
+                }
+
+                sqlite3_finalize(stmt);
+            }
+
+            else
+            {
+                //异常情况
+                sqlite3_finalize(stmt);
+                return false;
+            }
+        }
+
+        else
+        {
+            //异常情况
+            sqlite3_finalize(stmt);
+            return false;
+        }
+    }
+
+    else
+    {
+        //异常情况
+        sqlite3_finalize(stmt);
+        return false;
+    }
+
+    sql = "SELECT COUNT(*) FROM sqlite_master where type = 'table' and name = 'pos_chufang_printer';";
+
+    //读取厨房打印机的参数
+    if(sqlite3_prepare_v2(m_db, sql.c_str(), -1, &stmt, NULL) == SQLITE_OK)
+    {
+        if(sqlite3_step(stmt) == SQLITE_ROW)
+        {
+            int count = sqlite3_column_int(stmt, 0);
+
+            if(count == 0)
+            {
+                //说明没找到这个表,那么这个时候新建这个表,先释放前面的stmt
+                sqlite3_finalize(stmt);
+                stmt = NULL;
+
+                sql = "CREATE TABLE pos_chufang_printer("  \
+                      "id         INTEGER          PRIMARY KEY AUTOINCREMENT,"\
+                      "date       CHAR(100)        NOT NULL," \
+                      "name       CHAR(100)        NOT NULL," \
+                      "ip         CHAR(100)        NOT NULL," \
+                      "guige      CHAR(100)        NOT NULL," \
+                      "fendan     CHAR(100)        NOT NULL," \
+                      "fenlei     CHAR(100)        NOT NULL," \
+                      "fenlei_ids CHAR(2000)              );";
+
+                if(sqlite3_prepare_v2(m_db, sql.c_str(), -1, &stmt, NULL) == SQLITE_OK)
+                {
+                    //执行该语句
+                    if(sqlite3_step(stmt) != SQLITE_DONE)
+                    {
+                        std::string err = sqlite3_errmsg(m_db);
+                        LOG_INFO("create table fail: " << err.c_str());
+
+                        sqlite3_finalize(stmt);
+                        return false;
+                    }
+
+                    //走到这里就是表创建成功了
+                    LOG_INFO("create table success");
+                    sqlite3_finalize(stmt);
+                }
+
+                else
+                {
+                    LOG_INFO("create table prepare fail: " << sqlite3_errmsg(m_db));
+
+                    sqlite3_finalize(stmt);
+
+                    return false;
+                }
+            }
+
+            else
+            {
+                //说明已经有这个表了,就不用再创建了
+                sqlite3_finalize(stmt);
+            }
+
+            std::string sql = "SELECT * FROM pos_chufang_printer;";
+            sqlite3_stmt* stmt = NULL;
+
+            if(sqlite3_prepare_v2(m_db, sql.c_str(), -1, &stmt, NULL) == SQLITE_OK)
+            {
+                while(sqlite3_step(stmt) == SQLITE_ROW)
+                {
+                    std::string date = (char*)sqlite3_column_text(stmt, 1);
+                    std::string name = (char*)sqlite3_column_text(stmt, 2);
+                    std::string ip = (char*)sqlite3_column_text(stmt, 3);
+                    std::string guige = (char*)sqlite3_column_text(stmt, 4);
+                    std::string fendan = (char*)sqlite3_column_text(stmt, 5);
+                    std::string fenlei = (char*)sqlite3_column_text(stmt, 6);
+                    std::string fenlei_ids = (char*)sqlite3_column_text(stmt, 7);
+
+                    //这里仅仅是把数据库内容读到内存,所以之类用false
+                    CSetting::AddChufangPrinter(date, name, ip, guige, fendan, fenlei, fenlei_ids, false);
+                }
+
+                sqlite3_finalize(stmt);
+            }
+
+            else
+            {
+                //异常情况
+                sqlite3_finalize(stmt);
+                return false;
+            }
+        }
+    }
+
+    sql = "SELECT COUNT(*) FROM sqlite_master where type = 'table' and name = 'pos_user';";
+
+    //读取厨房打印机的参数
+    if(sqlite3_prepare_v2(m_db, sql.c_str(), -1, &stmt, NULL) == SQLITE_OK)
+    {
+        if(sqlite3_step(stmt) == SQLITE_ROW)
+        {
+            int count = sqlite3_column_int(stmt, 0);
+
+            if(count == 0)
+            {
+                //说明没找到这个表,那么这个时候新建这个表,先释放前面的stmt
+                sqlite3_finalize(stmt);
+                stmt = NULL;
+
+                sql = "CREATE TABLE pos_user("  \
+                      "id         INTEGER          PRIMARY KEY AUTOINCREMENT,"\
+                      "username       CHAR(100)        NOT NULL," \
+                      "password         CHAR(100)        NOT NULL);";
+
+                if(sqlite3_prepare_v2(m_db, sql.c_str(), -1, &stmt, NULL) == SQLITE_OK)
+                {
+                    //执行该语句
+                    if(sqlite3_step(stmt) != SQLITE_DONE)
+                    {
+                        std::string err = sqlite3_errmsg(m_db);
+                        LOG_INFO("create table fail: " << err.c_str());
+
+                        sqlite3_finalize(stmt);
+                        return false;
+                    }
+
+                    //走到这里就是表创建成功了
+                    LOG_INFO("create table success");
+                    sqlite3_finalize(stmt);
+                }
+
+                else
+                {
+                    LOG_INFO("create table prepare fail: " << sqlite3_errmsg(m_db));
+
+                    sqlite3_finalize(stmt);
+
+                    return false;
+                }
+            }
+
+            else
+            {
+                //说明已经有这个表了,就不用再创建了
+                sqlite3_finalize(stmt);
+            }
+
+            std::string sql = "SELECT * FROM pos_user;";
+            sqlite3_stmt* stmt = NULL;
+
+            if(sqlite3_prepare_v2(m_db, sql.c_str(), -1, &stmt, NULL) == SQLITE_OK)
+            {
+                while(sqlite3_step(stmt) == SQLITE_ROW)
+                {
+                    std::string username = (char*)sqlite3_column_text(stmt, 1);
+                    std::string password = (char*)sqlite3_column_text(stmt, 2);
+
+                    //这里仅仅是把数据库内容读到内存,所以之类用false
+                    CSetting::SetUser(username, password);
+                }
+
+                sqlite3_finalize(stmt);
+            }
+
+            else
+            {
+                //异常情况
+                sqlite3_finalize(stmt);
+                return false;
+            }
+        }
+    }
+
+    return true;
+}
+
+bool CSqlite3::SaveParams(std::map<std::string, std::string>& params)
+{
+    int result = sqlite3_exec(m_db, "BEGIN;", 0, 0, 0);
+
+    std::string sql = "delete from pos_config;";
+    result = sqlite3_exec(m_db, sql.c_str(), 0, 0, 0);
+
+    for(std::map<std::string, std::string>::iterator it = params.begin(); it != params.end(); it++)
+    {
+        std::string name = it->first;
+        std::string value = it->second;
+
+        sql = "INSERT INTO pos_config (name, value) VALUES ('" + name + "','" + value + "');";
+        result = sqlite3_exec(m_db, sql.c_str(), 0, 0, 0);
+    }
+
+    result = sqlite3_exec(m_db, "COMMIT;", 0, 0, 0);
+
+    if(result == SQLITE_OK)
+    {
+        LOG_INFO("save params success");
+        return true;
+    }
+
+    LOG_INFO("save params fail");
+    return false;
+}
+
+bool CSqlite3::SaveChufangPrinter(std::vector<ChufangPrinter>& printers)
+{
+    int result = sqlite3_exec(m_db, "BEGIN;", 0, 0, 0);
+
+    std::string sql = "delete from pos_chufang_printer;";
+    result = sqlite3_exec(m_db, sql.c_str(), 0, 0, 0);
+
+    for(std::vector<ChufangPrinter>::iterator it = printers.begin(); it != printers.end(); it++)
+    {
+        std::string date = (*it).date;
+        std::string name = (*it).name;
+        std::string ip = (*it).ip;
+        std::string guige = (*it).guige;
+        std::string fendan = (*it).fendan;
+        std::string fenlei = (*it).fenlei;
+        std::string fenlei_ids = (*it).fenlei_ids;
+
+        sql = "INSERT INTO pos_chufang_printer (date, name, ip, guige, fendan, fenlei, fenlei_ids) VALUES ('" + date + "' ,'" + name + "','" + ip + "','" + guige + "','" + fendan + "','" + fenlei + "','" + fenlei_ids + "')";
+        result = sqlite3_exec(m_db, sql.c_str(), 0, 0, 0);
+    }
+
+    result = sqlite3_exec(m_db, "COMMIT;", 0, 0, 0);
+
+    if(result == SQLITE_OK)
+    {
+        LOG_INFO("save params success");
+        return true;
+    }
+
+    LOG_INFO("save params fail");
+    return false;
+}
+
+bool CSqlite3::SaveUsers(std::map<string, string> users)
+{
+    int result = sqlite3_exec(m_db, "BEGIN;", 0, 0, 0);
+
+    std::string sql = "delete from pos_user;";
+    result = sqlite3_exec(m_db, sql.c_str(), 0, 0, 0);
+
+    for(std::map<std::string, std::string>::iterator it = users.begin(); it != users.end(); it++)
+    {
+        std::string name = it->first;
+        std::string password = it->second;
+
+        sql = "INSERT INTO pos_user (username, password) VALUES ('" + name + "' ,'" + password + "')";
+        result = sqlite3_exec(m_db, sql.c_str(), 0, 0, 0);
+    }
+
+    result = sqlite3_exec(m_db, "COMMIT;", 0, 0, 0);
+
+    if(result == SQLITE_OK)
+    {
+        LOG_INFO("save params success");
+        return true;
+    }
+
+    LOG_INFO("save params fail");
+    return false;
+}

+ 35 - 0
zhipuzi_pay_plugin/tool/CSqlite3.h

@@ -0,0 +1,35 @@
+#pragma once
+
+#include <sqlite3/sqlite3.h>
+
+#include "CSetting.h"
+
+class CSqlite3
+{
+public:
+    CSqlite3();
+    ~CSqlite3();
+
+public:
+    bool InitConfig();
+
+    bool SaveParams(std::map<std::string, std::string>& params);
+
+    bool SaveChufangPrinter(std::vector<ChufangPrinter>& printers);
+
+    bool SaveUsers(std::map<string, string> users);
+
+    void Close()
+    {
+        if(m_db != NULL)
+        {
+            sqlite3_close(m_db);
+        }
+    }
+
+private:
+    int m_rc;
+
+    sqlite3* m_db = NULL;
+};
+

+ 103 - 0
zhipuzi_pay_plugin/wnd/CChufangSettingWnd.cpp

@@ -0,0 +1,103 @@
+#include "../pch/pch.h"
+#include "CChufangSettingWnd.h"
+
+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);
+
+    RECT rcClient;
+    ::GetClientRect(*this, &rcClient);
+
+    RECT rcCaption = m_pm.GetCaptionRect();
+    if(pt.x >= rcClient.left + rcCaption.left && pt.x < rcClient.right - rcCaption.right \
+            && pt.y >= rcCaption.top && pt.y < rcCaption.bottom)
+    {
+        CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(pt));
+        if(pControl && _tcscmp(pControl->GetClass(), DUI_CTR_BUTTON) != 0)
+        {
+            return HTCAPTION;
+        }
+    }
+
+    return HTCLIENT;
+}
+
+LRESULT 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);
+    }
+
+    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 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;
+}
+
+
+
+

+ 347 - 0
zhipuzi_pay_plugin/wnd/CChufangSettingWnd.h

@@ -0,0 +1,347 @@
+#pragma once
+
+#include "../pch/pch.h"
+#include "CMainWnd.h"
+
+class CChufangSettingWnd : public CWindowWnd, public INotifyUI, public IMessageFilterUI
+{
+public:
+    CChufangSettingWnd(int mode)
+    {
+        m_mode = mode;
+    }
+
+    void SetPrinterDate(std::string date)
+    {
+        m_printer_date = date;
+    }
+
+    LPCTSTR GetWindowClassName() const
+    {
+        return _T("UIChufangSettingFrame");
+    };
+
+    UINT GetClassStyle() const
+    {
+        return UI_CLASSSTYLE_DIALOG;
+    };
+
+    void OnFinalMessage(HWND /*hWnd*/)
+    {
+        //WindowImplBase::OnFinalMessage(hWnd);
+        m_pm.RemovePreMessageFilter(this);
+        delete this;
+    };
+
+    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);
+    }
+
+    void Notify(TNotifyUI& msg)
+    {
+        if(msg.sType == _T("click"))
+        {
+            DuiLib::CDuiString senderName = msg.pSender->GetName();
+
+            if(senderName == _T("chufang_setting_closebtn"))
+            {
+                Close(IDCANCEL);
+                return;
+            }
+            else if(senderName == _T("chufang_setting_save"))
+            {
+                //开始保存厨房打印机的数据
+                CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("chufang_setting_name")));
+                wstring wsName = pName->GetText();
+
+                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);
+
+                    return;
+                }
+
+                CComboUI* com = static_cast<CComboUI*>(m_pm.FindControl(_T("chufang_setting_guige")));
+                wstring wsGuige;
+                if(com->GetCurSel() == 0)
+                {
+                    wsGuige = L"58";
+                }
+                else
+                {
+                    wsGuige = L"80";
+                }
+
+                CCheckBoxUI* pFendan = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("chufang_setting_fendan")));
+                wstring wsFendan;
+                if(pFendan->IsSelected())
+                {
+                    wsFendan = L"1";
+                }
+                else
+                {
+                    wsFendan = L"0";
+                }
+
+                CCheckBoxUI* pFenlei = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("chufang_setting_fenlei")));
+                wstring wsFenlei;
+                if(pFenlei->IsSelected())
+                {
+                    wsFenlei = L"1";
+                }
+                else
+                {
+                    wsFenlei = L"0";
+                }
+
+                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));
+
+                    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 = fenlei_ids.substr(0, fenlei_ids.size() - 1);
+
+                //保存数据到数据库
+
+                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);
+
+                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;
+            }
+        }
+    }
+
+    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("chufang_printer_setting.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;
+
+    int m_mode; //为1表示新建,为2表示修改
+    std::string m_printer_date; //修改模式下的打印机的日期
+};
+

+ 609 - 0
zhipuzi_pay_plugin/wnd/CLoginWnd.cpp

@@ -0,0 +1,609 @@
+#include "../pch/pch.h"
+#include "CLoginWnd.h"
+#include "CUpdateWnd.h"
+
+#include "CMessageboxWnd.h"
+
+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);
+    }
+}
+
+void CLoginWnd::Notify(TNotifyUI& msg)
+{
+    if(msg.sType == _T("click"))
+    {
+        if(msg.pSender->GetName() == _T("closebtn"))
+        {
+            PostQuitMessage(0);
+            return;
+        }
+        else if(msg.pSender->GetName() == _T("loginBtn"))
+        {
+            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.sType == _T("itemselect"))
+    {
+        CDuiString name = msg.pSender->GetName();
+
+        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);
+
+            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());
+        }
+    }
+}
+
+LRESULT CLoginWnd::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("login.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 CLoginWnd::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+    bHandled = FALSE;
+    return 0;
+}
+
+/*
+ *这个是窗口被销毁的时候调用的
+ **/
+LRESULT CLoginWnd::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+    bHandled = FALSE;
+    return 0;
+}
+
+LRESULT CLoginWnd::OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+    if(::IsIconic(*this))
+    {
+        bHandled = FALSE;
+    }
+    return (wParam == 0) ? TRUE : FALSE;
+}
+
+LRESULT CLoginWnd::OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+    return 0;
+}
+
+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;
+}
+
+LRESULT CLoginWnd::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+    POINT pt;
+    pt.x = GET_X_LPARAM(lParam);
+    pt.y = GET_Y_LPARAM(lParam);
+    ::ScreenToClient(*this, &pt);
+
+    RECT rcClient;
+    ::GetClientRect(*this, &rcClient);
+
+    RECT rcCaption = m_pm.GetCaptionRect();
+    if(pt.x >= rcClient.left + rcCaption.left && pt.x < rcClient.right - rcCaption.right \
+            && pt.y >= rcCaption.top && pt.y < rcCaption.bottom)
+    {
+        CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(pt));
+        if(pControl && _tcscmp(pControl->GetClass(), DUI_CTR_BUTTON) != 0)
+        {
+            return HTCAPTION;
+        }
+    }
+
+    return HTCLIENT;
+}
+
+LRESULT CLoginWnd::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+    SIZE szRoundCorner = m_pm.GetRoundCorner();
+    if(!::IsIconic(*this) && (szRoundCorner.cx != 0 || szRoundCorner.cy != 0))
+    {
+        CDuiRect rcWnd;
+        ::GetWindowRect(*this, &rcWnd);
+        rcWnd.Offset(-rcWnd.left, -rcWnd.top);
+        rcWnd.right++;
+        rcWnd.bottom++;
+        HRGN hRgn = ::CreateRoundRectRgn(rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom, szRoundCorner.cx, szRoundCorner.cy);
+        ::SetWindowRgn(*this, hRgn, TRUE);
+        ::DeleteObject(hRgn);
+    }
+
+    bHandled = FALSE;
+    return 0;
+}
+
+LRESULT CLoginWnd::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_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;
+	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 CLoginWnd::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled)
+{
+	if (uMsg == WM_KEYDOWN)
+	{
+		if (wParam == VK_RETURN)
+		{
+			CEditUI* pEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("accountedit")));
+			if (pEdit->GetText().IsEmpty())
+			{
+				pEdit->SetFocus();
+			}
+			else
+			{
+				pEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("pwdedit")));
+				if (pEdit->GetText().IsEmpty())
+				{
+					pEdit->SetFocus();
+				}
+				else
+				{
+					this->HandleLogin();
+				}
+			}
+			return true;
+		}
+		else if (wParam == VK_ESCAPE)
+		{
+			PostQuitMessage(0);
+			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* 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);
+
+    //开启一个线程,开始处理登录
+    std::thread(&CLoginWnd::HandleLogin, this).detach();
+}
+
+void CLoginWnd::HandleLogin()
+{
+	CLabelUI* pLoginResultLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("loginresult")));
+
+	//真正登录前,先检测是否有需要更新
+	//std::map<string, string> params;
+
+	//std::string response;
+	//bool ret = CZhipuziHttpClient::Request("/version/getwindowsversion", params, response);
+	//if (!ret)
+	//{
+	//	pLoginResultLabel->SetText(std::wstring(_T("网络请求出错")).c_str());
+	//	pLoginResultLabel->SetVisible(true);
+
+	//	PostMessage(WM_LOGIN_ERROR);
+
+	//	return;
+	//}
+
+	//rapidjson::Document document;
+	//document.Parse(response.c_str());
+
+	//if (document.HasParseError())
+	//{
+	//	pLoginResultLabel->SetText(std::wstring(_T("服务器返回数据格式错误")).c_str());
+	//	pLoginResultLabel->SetVisible(true);
+
+	//	PostMessage(WM_LOGIN_ERROR);
+
+	//	return;
+	//}
+	//else
+	//{
+	//	if (!document.HasMember("errcode") || !document.HasMember("errmsg") || !document.HasMember("data"))
+	//	{
+	//		pLoginResultLabel->SetText(std::wstring(_T("服务器返回数据格式错误")).c_str());
+	//		pLoginResultLabel->SetVisible(true);
+
+	//		PostMessage(WM_LOGIN_ERROR);
+
+	//		return;
+	//	}
+
+	//	rapidjson::Value& v_errcode = document["errcode"];
+	//	int errcode = v_errcode.GetInt();
+	//	if (errcode != 0)
+	//	{
+	//		std::string errmsg = "response failed! message:" + string(document["errmsg"].GetString());
+	//		pLoginResultLabel->SetText(CLewaimaiString::UTF8ToUnicode(errmsg).c_str());
+	//		pLoginResultLabel->SetVisible(true);
+
+	//		PostMessage(WM_LOGIN_ERROR);
+
+	//		return;
+	//	}
+
+	//	rapidjson::Value& data = document["data"];
+
+	//	std::string newest_version = data["newest_version"].GetString();
+	//	m_update_url = data["url"].GetString();
+
+	//	if (newest_version > CSystem::GetVersion())
+	//	{
+	//		//说明有新版本,要更新
+	//		PostMessage(WM_NEED_UPDATE);
+	//		return;
+	//	}
+	//}
+
+	//判断账号密码是否正确
+	std::wstring account, password;
+	CEditUI* pAccountEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("accountedit")));
+	if (pAccountEdit)
+	{
+		account = pAccountEdit->GetText().GetData();
+	}
+
+	CEditUI* pPasswordEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("pwdedit")));
+	if (pPasswordEdit)
+	{
+		password = pPasswordEdit->GetText().GetData();
+	}
+
+	//把第1个中文冒号替换成英文冒号
+	CLewaimaiString::Replace(account, _T(":"), _T(":"), 1);
+
+	//LOG_INFO("account:" << account.c_str() << ", password:" << password.c_str());
+
+	string s_account = CLewaimaiString::UnicodeToUTF8(account);
+	string s_password = CLewaimaiString::UnicodeToUTF8(password);
+
+	CLewaimaiString::trim(s_account);
+	CLewaimaiString::trim(s_password);
+
+	if (s_account.compare("") == 0)
+	{
+		pLoginResultLabel->SetText(std::wstring(_T("用户名不能为空")).c_str());
+		pLoginResultLabel->SetVisible(true);
+
+		PostMessage(WM_LOGIN_ERROR);
+
+		return;
+	}
+
+	if (s_password.compare("") == 0)
+	{
+		pLoginResultLabel->SetText(std::wstring(_T("密码不能为空")).c_str());
+		pLoginResultLabel->SetVisible(true);
+
+		PostMessage(WM_LOGIN_ERROR);
+
+		return;
+	}
+
+	CZhipuziHttpClient::Init(s_account, s_password);
+
+	std::string errmsg;
+	bool res = CZhipuziHttpClient::Login(errmsg);
+
+	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;
+	}
+	else
+	{
+		//登录失败了
+		CLabelUI* pLoginResultLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("loginresult")));
+
+		pLoginResultLabel->SetText(std::wstring(_T("登录失败:") + CLewaimaiString::UTF8ToUnicode(errmsg)).c_str());
+		pLoginResultLabel->SetVisible(true);
+
+		PostMessage(WM_LOGIN_ERROR);
+	}
+}
+
+void CLoginWnd::LoginSuccess()
+{
+    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();
+
+    ::ShowWindow(*pFrame, SW_SHOWMAXIMIZED);
+
+    Close();
+}
+
+void CLoginWnd::LoginError()
+{
+    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);
+
+    CLabelUI* pLoginResultLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("loginresult")));
+    pLoginResultLabel->SetVisible(true);
+}
+
+void CLoginWnd::Update()
+{
+	CUpdateWnd* pFrame = new CUpdateWnd();
+	if (pFrame == NULL)
+	{
+		return;
+	}
+
+	TCHAR lpTempPathBuffer[MAX_PATH];
+	DWORD dwRetVal = GetTempPath(MAX_PATH, lpTempPathBuffer);
+
+	std::string url = m_update_url;
+	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();
+
+	::ShowWindow(*pFrame, SW_SHOWNORMAL);
+
+	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();
+}
+
+

+ 79 - 0
zhipuzi_pay_plugin/wnd/CLoginWnd.h

@@ -0,0 +1,79 @@
+#pragma once
+
+#include "../pch/pch.h"
+#include "CMainWnd.h"
+
+class CLoginWnd : public CWindowWnd, public INotifyUI, public IMessageFilterUI
+{
+public:
+    CLoginWnd()
+    {
+
+    }
+
+    LPCTSTR GetWindowClassName() const
+    {
+        return _T("UILoginFrame");
+    };
+
+    UINT GetClassStyle() const
+    {
+        return UI_CLASSSTYLE_DIALOG;
+    };
+
+    void OnFinalMessage(HWND /*hWnd*/)
+    {
+        //m_pm.RemovePreMessageFilter(this);
+        delete this;
+    };
+
+    void Init();
+
+    void SetMode(int mode)
+    {
+        m_mode = mode;
+    }
+
+    void Notify(TNotifyUI& msg);
+
+    LRESULT OnCreate(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 OnNcActivate(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 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);
+
+    void StartLogin();
+
+    void HandleLogin();
+
+    void LoginSuccess();
+
+    void LoginError();
+
+    void Update();
+
+    void ShowLoginAgainOut();
+
+public:
+    CPaintManagerUI m_pm;
+
+    std::string m_update_url;
+
+    //模式1:正常的展示登录页面 2:被人挤下线的
+    int m_mode = 1;
+};
+

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 2026 - 0
zhipuzi_pay_plugin/wnd/CMainWnd.cpp


+ 93 - 0
zhipuzi_pay_plugin/wnd/CMainWnd.h

@@ -0,0 +1,93 @@
+#pragma once
+
+#include "../pch/pch.h"
+
+#include "../control/CWaimaiOrderItemUI.h"
+#include "../order/CWaimaiOrder.h"
+#include "../tool/CPosPrinter.h"
+
+class CMessagePush;
+
+class CMainWnd : public CWindowWnd, public INotifyUI
+{
+public:
+    CMainWnd() { };
+
+    LPCTSTR GetWindowClassName() const
+    {
+        return _T("UIMainFrame");
+    };
+
+    UINT GetClassStyle() const
+    {
+        return CS_DBLCLKS;
+    };
+
+    void OnFinalMessage(HWND /*hWnd*/)
+    {
+        delete this;
+    };
+
+    void Init();
+
+    void OnPrepare()
+    {
+
+    }
+
+    void Notify(TNotifyUI& msg);
+
+    void HandleClickMsg(TNotifyUI& msg);
+    void HandleSelectChangeMsg(TNotifyUI& msg);
+    void HandleItemSelectMsg(TNotifyUI& msg);
+
+    void InitSettingStatus();
+
+    LRESULT OnCreate(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 OnNcActivate(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 OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+
+    LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+
+    LRESULT OnGetMinMaxInfo(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+
+    LRESULT OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+
+    LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
+
+    LRESULT OnOrderlistRefresh(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+
+    LRESULT OnLoginOut(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+
+    //添加托盘图标(初始化)
+    void AddTrayIcon();
+
+    //处理托盘图标上的事件
+    LRESULT OnTrayIcon(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+
+    void LoginOut(int mode);
+
+public:
+    CPaintManagerUI m_pm;
+
+private:
+    CButtonUI* m_pCloseBtn;
+    CButtonUI* m_pMaxBtn;
+    CButtonUI* m_pRestoreBtn;
+    CButtonUI* m_pMinBtn;
+
+    //定义托盘图标对象
+    NOTIFYICONDATA m_trayIcon;
+
+    CMessagePush* m_push = NULL;
+};

+ 103 - 0
zhipuzi_pay_plugin/wnd/CMessageboxWnd.cpp

@@ -0,0 +1,103 @@
+#include "../pch/pch.h"
+#include "CMessageboxWnd.h"
+
+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);
+
+    RECT rcClient;
+    ::GetClientRect(*this, &rcClient);
+
+    RECT rcCaption = m_pm.GetCaptionRect();
+    if(pt.x >= rcClient.left + rcCaption.left && pt.x < rcClient.right - rcCaption.right \
+            && pt.y >= rcCaption.top && pt.y < rcCaption.bottom)
+    {
+        CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(pt));
+        if(pControl && _tcscmp(pControl->GetClass(), DUI_CTR_BUTTON) != 0)
+        {
+            return HTCAPTION;
+        }
+    }
+
+    return HTCLIENT;
+}
+
+LRESULT 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);
+    }
+
+    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 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;
+}
+
+
+
+

+ 103 - 0
zhipuzi_pay_plugin/wnd/CMessageboxWnd.h

@@ -0,0 +1,103 @@
+#pragma once
+
+#include "../pch/pch.h"
+#include "CMainWnd.h"
+
+class CMessageboxWnd : public CWindowWnd, public INotifyUI, public IMessageFilterUI
+{
+public:
+    LPCTSTR GetWindowClassName() const
+    {
+        return _T("UIMessageboxFrame");
+    };
+
+    UINT GetClassStyle() const
+    {
+        return UI_CLASSSTYLE_DIALOG;
+    };
+
+    void OnFinalMessage(HWND /*hWnd*/)
+    {
+        //WindowImplBase::OnFinalMessage(hWnd);
+        m_pm.RemovePreMessageFilter(this);
+
+        //delete this;
+    };
+
+    void Init()
+    {
+
+    }
+
+    void Notify(TNotifyUI& msg)
+    {
+        if(msg.sType == _T("click"))
+        {
+            DuiLib::CDuiString senderName = msg.pSender->GetName();
+
+            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);
+
+        // 把自己的窗口句柄与窗口绘制管理器挂接在一起
+        m_pm.Init(m_hWnd);
+
+        m_pm.AddPreMessageFilter(this);
+
+        CDialogBuilder builder;
+
+        CControlUI* pRoot = builder.Create(_T("messagebox_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;
+};
+

+ 430 - 0
zhipuzi_pay_plugin/wnd/CUpdateWnd.cpp

@@ -0,0 +1,430 @@
+#include "../pch/pch.h"
+#include "CUpdateWnd.h"
+
+double CUpdateWnd::m_Percent;
+
+void CUpdateWnd::Init()
+{
+    std::thread(&CUpdateWnd::Run, this).detach();
+}
+
+void CUpdateWnd::Notify(TNotifyUI& msg)
+{
+    if(msg.sType == _T("click"))
+    {
+        if(msg.pSender->GetName() == _T("closebtn"))
+        {
+            PostQuitMessage(0);
+            return;
+        }
+
+        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();
+
+        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);
+
+            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());
+        }
+    }
+}
+
+LRESULT CUpdateWnd::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("update.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 CUpdateWnd::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+    bHandled = FALSE;
+    return 0;
+}
+
+/*
+ *这个是窗口被销毁的时候调用的
+ **/
+LRESULT CUpdateWnd::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+    bHandled = FALSE;
+    return 0;
+}
+
+LRESULT CUpdateWnd::OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+    if(::IsIconic(*this))
+    {
+        bHandled = FALSE;
+    }
+
+    return (wParam == 0) ? TRUE : FALSE;
+}
+
+LRESULT CUpdateWnd::OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+    return 0;
+}
+
+LRESULT CUpdateWnd::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;
+}
+
+LRESULT CUpdateWnd::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+    POINT pt;
+    pt.x = GET_X_LPARAM(lParam);
+    pt.y = GET_Y_LPARAM(lParam);
+    ::ScreenToClient(*this, &pt);
+
+    RECT rcClient;
+    ::GetClientRect(*this, &rcClient);
+
+    RECT rcCaption = m_pm.GetCaptionRect();
+
+    if(pt.x >= rcClient.left + rcCaption.left && pt.x < rcClient.right - rcCaption.right \
+            && pt.y >= rcCaption.top && pt.y < rcCaption.bottom)
+    {
+        CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(pt));
+
+        if(pControl && _tcscmp(pControl->GetClass(), DUI_CTR_BUTTON) != 0)
+        {
+            return HTCAPTION;
+        }
+    }
+
+    return HTCLIENT;
+}
+
+LRESULT CUpdateWnd::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+    SIZE szRoundCorner = m_pm.GetRoundCorner();
+
+    if(!::IsIconic(*this) && (szRoundCorner.cx != 0 || szRoundCorner.cy != 0))
+    {
+        CDuiRect rcWnd;
+        ::GetWindowRect(*this, &rcWnd);
+        rcWnd.Offset(-rcWnd.left, -rcWnd.top);
+        rcWnd.right++;
+        rcWnd.bottom++;
+        HRGN hRgn = ::CreateRoundRectRgn(rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom, szRoundCorner.cx, szRoundCorner.cy);
+        ::SetWindowRgn(*this, hRgn, TRUE);
+        ::DeleteObject(hRgn);
+    }
+
+    bHandled = FALSE;
+    return 0;
+}
+
+LRESULT CUpdateWnd::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_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;
+
+    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;
+
+    case WM_UPDATEPROGRESS:
+        lRes = OnRefresh(uMsg, wParam, lParam, bHandled);
+        break;
+    case  WM_DOWNLOAD_FINISH:
+        lRes = OnDownloadFinish(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 CUpdateWnd::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled)
+{
+    return false;
+}
+
+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;
+}
+
+double CUpdateWnd::getDownloadFileLength(std::string url)
+{
+    CURL* easy_handle = NULL;
+    int ret = CURLE_OK;
+    double size = -1;
+
+    do
+    {
+        easy_handle = curl_easy_init();
+
+        if(!easy_handle)
+        {
+            break;
+        }
+
+        // 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);
+        }
+
+        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
+
+        if(ret != CURLE_OK)
+        {
+            break;
+        }
+
+        ret = curl_easy_perform(easy_handle);
+
+
+        if(ret != CURLE_OK)
+        {
+            char s[100] = { 0 };
+            sprintf_s(s, sizeof(s), "error:%d:%s", ret, curl_easy_strerror(static_cast<CURLcode>(ret)));
+
+            break;
+        }
+
+        // size = -1 if no Content-Length return or Content-Length=0
+        ret = curl_easy_getinfo(easy_handle, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &size);
+
+        if(ret != CURLE_OK)
+        {
+            break;
+        }
+
+    } while(0);
+
+    curl_easy_cleanup(easy_handle);
+
+    return size;
+}
+
+void CUpdateWnd::Run()
+{
+    m_filepath = m_dir + GetFileNameFormUrl(m_url);
+
+    CURLcode res;
+
+    m_curl = curl_easy_init();
+
+    if(m_curl)
+    {
+
+        m_resumeByte = 0;
+
+        m_downloadFileLength = getDownloadFileLength(m_url);
+
+        if(m_resumeByte >= (int)m_downloadFileLength)
+        {
+            return;
+        }
+
+        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);
+        }
+
+        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);
+        curl_easy_setopt(m_curl, CURLOPT_NOPROGRESS, FALSE);
+        curl_easy_setopt(m_curl, CURLOPT_PROGRESSFUNCTION, my_progress_func);
+        curl_easy_setopt(m_curl, CURLOPT_PROGRESSDATA, NULL);//给下载进度回调函数传参数,在此是指针
+
+        res = curl_easy_perform(m_curl);
+
+        fclose(m_outfile);
+
+        curl_easy_cleanup(m_curl);
+    }
+
+    //走到这里,下载完成了
+    HWND hWnd = FindWindow(NULL, L"自动更新");
+
+    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 nWrite = fwrite(ptr, size, nmemb, stream);
+
+    if(nWrite == 0)
+    {
+        return CURL_WRITEFUNC_PAUSE;
+    }
+
+    else
+    {
+        return nWrite;
+    }
+}
+
+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;
+    }
+
+    HWND hWnd = FindWindow(NULL, L"自动更新");
+
+    if(hWnd)
+    {
+        ::PostMessage(hWnd, WM_UPDATEPROGRESS, 0, 0);
+    }
+
+    return 0;
+}
+
+size_t CUpdateWnd::nousecb(char* buffer, size_t x, size_t y, void* userdata)
+{
+    (void)buffer;
+    (void)userdata;
+    return x * y;
+}
+
+LRESULT CUpdateWnd::OnRefresh(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+    CProgressUI* pProgress = static_cast<CProgressUI*>(m_pm.FindControl(_T("update_progress")));
+
+    if(pProgress)
+    {
+        pProgress->SetValue((int)m_Percent);
+    }
+
+    return 0;
+}
+
+LRESULT CUpdateWnd::OnDownloadFinish(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+    HINSTANCE hNewExe = ShellExecuteA(NULL, "open", m_filepath.c_str(), NULL, NULL, SW_SHOW);
+
+    PostQuitMessage(0);
+
+    return 0;
+}

+ 94 - 0
zhipuzi_pay_plugin/wnd/CUpdateWnd.h

@@ -0,0 +1,94 @@
+#pragma once
+
+#include "../pch/pch.h"
+
+#include <curl/curl.h>
+
+class CUpdateWnd : public CWindowWnd, public INotifyUI, public IMessageFilterUI
+{
+public:
+
+    LPCTSTR GetWindowClassName() const
+    {
+        return _T("UIUpdateFrame");
+    };
+
+    UINT GetClassStyle() const
+    {
+        return UI_CLASSSTYLE_DIALOG;
+    };
+
+    void OnFinalMessage(HWND /*hWnd*/)
+    {
+        //m_pm.RemovePreMessageFilter(this);
+        delete this;
+    };
+
+    void InitData(std::string url, std::string dir)
+    {
+        m_url = url;
+        m_dir = dir;
+    }
+
+    void Init();
+
+    void Notify(TNotifyUI& msg);
+
+    LRESULT OnCreate(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 OnNcActivate(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 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);
+
+    LRESULT OnRefresh(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+
+    LRESULT OnDownloadFinish(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+
+    std::string GetFileNameFormUrl(std::string url);
+
+    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 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; //完成文件在本地的路径名
+
+    CURL* m_curl;//libcurl句柄
+
+    double m_downloadFileLength;//服务器文件长度
+
+    int m_resumeByte;//本地已下载的文件长度
+
+    FILE* m_outfile;//文件指针
+
+    std::string m_url;//下载地址
+
+    static double m_Percent;
+};
+

+ 103 - 0
zhipuzi_pay_plugin/wnd/CWaimaiOrderFailReasonWnd.cpp

@@ -0,0 +1,103 @@
+#include "../pch/pch.h"
+#include "CWaimaiOrderFailReasonWnd.h"
+
+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);
+
+    RECT rcClient;
+    ::GetClientRect(*this, &rcClient);
+
+    RECT rcCaption = m_pm.GetCaptionRect();
+    if(pt.x >= rcClient.left + rcCaption.left && pt.x < rcClient.right - rcCaption.right \
+            && pt.y >= rcCaption.top && pt.y < rcCaption.bottom)
+    {
+        CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(pt));
+        if(pControl && _tcscmp(pControl->GetClass(), DUI_CTR_BUTTON) != 0)
+        {
+            return HTCAPTION;
+        }
+    }
+
+    return HTCLIENT;
+}
+
+LRESULT 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);
+    }
+
+    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 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;
+}
+
+
+
+

+ 121 - 0
zhipuzi_pay_plugin/wnd/CWaimaiOrderFailReasonWnd.h

@@ -0,0 +1,121 @@
+#pragma once
+
+#include "../pch/pch.h"
+#include "CMainWnd.h"
+
+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);
+
+    LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled);
+
+public:
+    CPaintManagerUI m_pm;
+
+    std::string m_reason;
+};
+

+ 54 - 0
zhipuzi_pay_plugin/zhipuzi_pay_plugin.cpp

@@ -0,0 +1,54 @@
+#include "pch/pch.h"
+
+#include "wnd/CLoginWnd.h"
+
+#include <curl/curl.h>
+
+int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
+                      _In_opt_ HINSTANCE hPrevInstance,
+                      _In_ LPWSTR    lpCmdLine,
+                      _In_ int       nCmdShow)
+{
+    //初始化日志
+    CLewaimaiLog log;
+    log.Init();
+
+    //初始化系统设置
+	CSetting::Init();
+
+	//初始化curl
+	curl_global_init(CURL_GLOBAL_ALL);
+
+    //开始展示窗口
+    CPaintManagerUI::SetInstance(hInstance);
+#ifdef NDEBUG
+	CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath() + _T("skin"));
+	CPaintManagerUI::SetResourceZip(_T("skin.zpz"));
+#else
+	CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath() + _T("skin"));
+#endif
+
+    HRESULT Hr = ::CoInitialize(NULL);
+    if(FAILED(Hr))
+    {
+        return 0;
+    }
+
+    //先显示登录窗口
+    CLoginWnd* pLogin = new CLoginWnd();
+    if(pLogin == NULL)
+    {
+        return 0;
+    }
+
+    pLogin->Create(NULL, _T("智铺子收银软件登录"), UI_WNDSTYLE_DIALOG, 0, 0, 0, 0, 0, NULL);
+    pLogin->SetIcon(IDI_ICON_DUILIB);
+    pLogin->CenterWindow();
+    pLogin->ShowModal();
+
+    CPaintManagerUI::MessageLoop();
+
+    ::CoUninitialize();
+
+    return 0;
+}

+ 290 - 0
zhipuzi_pay_plugin/zhipuzi_pay_plugin.vcxproj

@@ -0,0 +1,290 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <VCProjectVersion>15.0</VCProjectVersion>
+    <ProjectGuid>{1D694BE0-D976-4F29-8997-3308ADFFF413}</ProjectGuid>
+    <Keyword>Win32Proj</Keyword>
+    <RootNamespace>zhipuzipayplugin</RootNamespace>
+    <WindowsTargetPlatformVersion>7.0</WindowsTargetPlatformVersion>
+    <ProjectName>zhipuzi_pay_plugin</ProjectName>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v141_xp</PlatformToolset>
+    <CharacterSet>Unicode</CharacterSet>
+    <UseOfMfc>false</UseOfMfc>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v141_xp</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v141_xp</PlatformToolset>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v141</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="Shared">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <LinkIncremental>true</LinkIncremental>
+    <OutDir>$(SolutionDir)temp\link\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
+    <IntDir>$(SolutionDir)temp\compile\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <LinkIncremental>true</LinkIncremental>
+    <OutDir>$(SolutionDir)temp\link\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
+    <IntDir>$(SolutionDir)temp\compile\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <LinkIncremental>false</LinkIncremental>
+    <OutDir>$(SolutionDir)temp\link\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
+    <IntDir>$(SolutionDir)temp\compile\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <LinkIncremental>false</LinkIncremental>
+    <OutDir>$(SolutionDir)temp\link\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
+    <IntDir>$(SolutionDir)temp\compile\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <ClCompile>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <SDLCheck>true</SDLCheck>
+      <PreprocessorDefinitions>_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_WIN32_WINNT=0x600;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <ConformanceMode>true</ConformanceMode>
+      <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+      <AdditionalIncludeDirectories>$(SolutionDir)include;$(ProjectDir)pch</AdditionalIncludeDirectories>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalOptions>/ignore:4099 %(AdditionalOptions)</AdditionalOptions>
+      <AdditionalLibraryDirectories>$(SolutionDir)lib\debug\grpc;$(SolutionDir)lib;$(SolutionDir)lib\debug</AdditionalLibraryDirectories>
+      <AdditionalDependencies>log4cplusUD.lib;aliyun-mns.lib;libcurl_debug.lib;libeay32.lib;ssleay32.lib;mysqlcppconn.lib;Dbghelp.lib;libprotobufd.lib;grpc.lib;grpc++.lib;cares.lib;gpr.lib;zlibd.lib;address_sorting.lib;ssl.lib;crypto.lib;DuiLib_ud.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <MinimumRequiredVersion>5.02</MinimumRequiredVersion>
+    </Link>
+    <PostBuildEvent>
+      <Command>mkdir $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\
+copy $(TargetPath) $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\
+copy $(SolutionDir)dll\debug\ $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\
+mkdir $(SolutionDir)bin\$(Platform)\$(Configuration)\conf\
+copy $(ProjectDir)conf\ $(SolutionDir)bin\$(Platform)\$(Configuration)\conf\</Command>
+    </PostBuildEvent>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <SDLCheck>true</SDLCheck>
+      <PreprocessorDefinitions>_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_WIN32_WINNT=0x600;LOG4CPLUS_DISABLE_DLL_RUNTIME_WARNING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <ConformanceMode>false</ConformanceMode>
+      <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+      <AdditionalIncludeDirectories>$(SolutionDir)include;$(ProjectDir)pch</AdditionalIncludeDirectories>
+      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+      <DisableSpecificWarnings>4099</DisableSpecificWarnings>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalLibraryDirectories>$(SolutionDir)lib\debug</AdditionalLibraryDirectories>
+      <AdditionalDependencies>dbghelp.lib;winmm.lib;setupapi.lib;AdvAPI32.lib;Shell32.lib;user32.lib;kernel32.lib;Gdi32.lib;libboost_date_time-vc141-mt-sgd-x32-1_70.lib;libboost_regex-vc141-mt-sgd-x32-1_70.lib;sqlite3.lib;libcurl.lib;DuiLib_ud.lib;log4cplusUD.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <IgnoreSpecificDefaultLibraries>
+      </IgnoreSpecificDefaultLibraries>
+      <Version>
+      </Version>
+    </Link>
+    <PostBuildEvent>
+      <Command>mkdir $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\
+mkdir $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\music\
+mkdir $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\icon\
+copy $(TargetPath) $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\
+copy $(SolutionDir)dll\debug\ $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\
+copy $(SolutionDir)res\music\ $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\music\
+copy $(SolutionDir)res\icon\ $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\icon\
+</Command>
+    </PostBuildEvent>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <SDLCheck>true</SDLCheck>
+      <PreprocessorDefinitions>NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_WIN32_WINNT=0x600;LOG4CPLUS_DISABLE_DLL_RUNTIME_WARNING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <ConformanceMode>false</ConformanceMode>
+      <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+      <AdditionalIncludeDirectories>$(SolutionDir)include;$(ProjectDir)pch</AdditionalIncludeDirectories>
+      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+      <DisableSpecificWarnings>4099</DisableSpecificWarnings>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalLibraryDirectories>$(SolutionDir)lib\release</AdditionalLibraryDirectories>
+      <AdditionalDependencies>dbghelp.lib;winmm.lib;setupapi.lib;AdvAPI32.lib;Shell32.lib;user32.lib;kernel32.lib;Gdi32.lib;sqlite3.lib;libcurl.lib;DuiLib_u.lib;log4cplusU.lib;version.lib;libboost_date_time-vc141-mt-s-x32-1_70.lib;libboost_regex-vc141-mt-s-x32-1_70.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+    <PostBuildEvent>
+      <Command>mkdir $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\
+mkdir $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\music\
+mkdir $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\icon\
+copy $(TargetPath) $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\
+copy $(SolutionDir)dll\release\ $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\
+copy $(SolutionDir)res\music\ $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\music\
+copy $(SolutionDir)res\icon\ $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\icon\
+</Command>
+    </PostBuildEvent>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <ClCompile>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <SDLCheck>true</SDLCheck>
+      <PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_WIN32_WINNT=0x600</PreprocessorDefinitions>
+      <ConformanceMode>true</ConformanceMode>
+      <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+      <AdditionalIncludeDirectories>$(SolutionDir)include;$(ProjectDir)pch</AdditionalIncludeDirectories>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <GenerateDebugInformation>false</GenerateDebugInformation>
+      <AdditionalLibraryDirectories>$(SolutionDir)lib\release\grpc;$(SolutionDir)lib;$(SolutionDir)lib\release</AdditionalLibraryDirectories>
+      <AdditionalDependencies>
+      </AdditionalDependencies>
+      <AdditionalOptions>/ignore:4099 %(AdditionalOptions)</AdditionalOptions>
+    </Link>
+    <PostBuildEvent>
+      <Command>mkdir $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\
+copy $(TargetPath) $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\
+copy $(SolutionDir)dll\release\ $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\
+mkdir $(SolutionDir)bin\$(Platform)\$(Configuration)\conf\
+copy $(ProjectDir)conf\ $(SolutionDir)bin\$(Platform)\$(Configuration)\conf\</Command>
+    </PostBuildEvent>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClInclude Include="wnd\CMessageboxWnd.h" />
+    <ClInclude Include="wnd\CUpdateWnd.h" />
+    <ClInclude Include="wnd\CWaimaiOrderFailReasonWnd.h" />
+    <ClInclude Include="network\PosMessage.h" />
+    <ClInclude Include="wnd\CChufangSettingWnd.h" />
+    <ClInclude Include="control\CWaimaiOrderInfoUI.h" />
+    <ClInclude Include="control\CSettingUI.h" />
+    <ClInclude Include="tool\CSetting.h" />
+    <ClInclude Include="tool\CSqlite3.h" />
+    <ClInclude Include="network\CMessagePush.h" />
+    <ClInclude Include="order\CWaimaiOrder.h" />
+    <ClInclude Include="tool\CPosPrinter.h" />
+    <ClInclude Include="control\CWaimaiOrderItemUI.h" />
+    <ClInclude Include="wnd\CMainWnd.h" />
+    <ClInclude Include="wnd\CLoginWnd.h" />
+    <ClInclude Include="helper\MD5.h" />
+    <ClInclude Include="network\CZhipuziHttpClient.h" />
+    <ClInclude Include="helper\CLewaimaiString.h" />
+    <ClInclude Include="helper\CRandomHelper.h" />
+    <ClInclude Include="helper\define.h" />
+    <ClInclude Include="network\CHttpClient.h" />
+    <ClInclude Include="control\ControlEx.h" />
+    <ClInclude Include="resource\resource.h" />
+    <ClInclude Include="tool\CLewaimaiLog.h" />
+    <ClInclude Include="pch\pch.h" />
+    <ClInclude Include="tool\CLewaimaiTime.h" />
+    <ClInclude Include="helper\CSystem.h" />
+    <ClInclude Include="control\OrderListUI.h" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="wnd\CMessageboxWnd.cpp" />
+    <ClCompile Include="wnd\CUpdateWnd.cpp" />
+    <ClCompile Include="wnd\CWaimaiOrderFailReasonWnd.cpp" />
+    <ClCompile Include="wnd\CChufangSettingWnd.cpp" />
+    <ClCompile Include="control\CWaimaiOrderInfoUI.cpp" />
+    <ClCompile Include="control\CSettingUI.cpp" />
+    <ClCompile Include="tool\CSetting.cpp" />
+    <ClCompile Include="tool\CSqlite3.cpp" />
+    <ClCompile Include="network\CMessagePush.cpp" />
+    <ClCompile Include="order\CWaimaiOrder.cpp" />
+    <ClCompile Include="tool\CPosPrinter.cpp" />
+    <ClCompile Include="control\CWaimaiOrderItemUI.cpp" />
+    <ClCompile Include="wnd\CMainWnd.cpp" />
+    <ClCompile Include="wnd\CLoginWnd.cpp" />
+    <ClCompile Include="helper\MD5.cpp" />
+    <ClCompile Include="network\CZhipuziHttpClient.cpp" />
+    <ClCompile Include="helper\CLewaimaiString.cpp" />
+    <ClCompile Include="helper\CRandomHelper.cpp" />
+    <ClCompile Include="helper\CSystem.cpp" />
+    <ClCompile Include="network\CHttpClient.cpp" />
+    <ClCompile Include="tool\CLewaimaiLog.cpp" />
+    <ClCompile Include="zhipuzi_pay_plugin.cpp" />
+    <ClCompile Include="pch\pch.cpp" />
+    <ClCompile Include="tool\CLewaimaiTime.cpp" />
+    <ClCompile Include="control\OrderListUI.cpp" />
+  </ItemGroup>
+  <ItemGroup>
+    <ResourceCompile Include="resource\zhipuzi_pay_plugin.rc" />
+  </ItemGroup>
+  <ItemGroup>
+    <Image Include="resource\zhipuzi.ico" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="resource\zhipuzi_pay_plugin.aps" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>

+ 196 - 0
zhipuzi_pay_plugin/zhipuzi_pay_plugin.vcxproj.filters

@@ -0,0 +1,196 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="源文件">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="头文件">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
+    </Filter>
+    <Filter Include="资源文件">
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="pch\pch.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="tool\CLewaimaiTime.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="helper\CSystem.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="tool\CLewaimaiLog.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="helper\CLewaimaiString.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="helper\CRandomHelper.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="helper\define.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="network\CHttpClient.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="network\CZhipuziHttpClient.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="helper\MD5.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="wnd\CLoginWnd.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="resource\resource.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="tool\CPosPrinter.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="order\CWaimaiOrder.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="network\CMessagePush.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="wnd\CMainWnd.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="control\ControlEx.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="control\CWaimaiOrderInfoUI.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="control\CWaimaiOrderItemUI.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="control\OrderListUI.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="control\CSettingUI.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="tool\CSqlite3.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="tool\CSetting.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="wnd\CChufangSettingWnd.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="network\PosMessage.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="wnd\CWaimaiOrderFailReasonWnd.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="wnd\CUpdateWnd.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="wnd\CMessageboxWnd.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="pch\pch.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="tool\CLewaimaiTime.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="tool\CLewaimaiLog.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="helper\CLewaimaiString.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="helper\CRandomHelper.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="helper\CSystem.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="network\CHttpClient.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="network\CZhipuziHttpClient.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="helper\MD5.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="wnd\CLoginWnd.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="tool\CPosPrinter.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="order\CWaimaiOrder.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="network\CMessagePush.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="wnd\CMainWnd.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="control\CWaimaiOrderInfoUI.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="control\OrderListUI.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="control\CWaimaiOrderItemUI.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="control\CSettingUI.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="tool\CSqlite3.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="tool\CSetting.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="wnd\CChufangSettingWnd.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="wnd\CWaimaiOrderFailReasonWnd.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="wnd\CUpdateWnd.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="wnd\CMessageboxWnd.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="zhipuzi_pay_plugin.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+  </ItemGroup>
+  <ItemGroup>
+    <Image Include="resource\zhipuzi.ico">
+      <Filter>资源文件</Filter>
+    </Image>
+  </ItemGroup>
+  <ItemGroup>
+    <ResourceCompile Include="resource\zhipuzi_pay_plugin.rc">
+      <Filter>资源文件</Filter>
+    </ResourceCompile>
+    <ResourceCompile Include="resource\zhipuzi_pay_plugin.rc">
+      <Filter>资源文件</Filter>
+    </ResourceCompile>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="resource\zhipuzi_pay_plugin.aps" />
+  </ItemGroup>
+</Project>

+ 28 - 0
zhipuzi_pay_plugin/zhipuzi_pay_plugin.vcxproj.user

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <ShowAllFiles>false</ShowAllFiles>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <LocalDebuggerCommand>$(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\$(TargetFileName)</LocalDebuggerCommand>
+    <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
+    <LocalDebuggerWorkingDirectory>$(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\</LocalDebuggerWorkingDirectory>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <LocalDebuggerCommand>$(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\$(TargetFileName)</LocalDebuggerCommand>
+    <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
+    <LocalDebuggerWorkingDirectory>$(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\</LocalDebuggerWorkingDirectory>
+    <LocalDebuggerDebuggerType>NativeOnly</LocalDebuggerDebuggerType>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <LocalDebuggerCommand>$(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\$(TargetFileName)</LocalDebuggerCommand>
+    <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
+    <LocalDebuggerWorkingDirectory>$(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\</LocalDebuggerWorkingDirectory>
+    <LocalDebuggerAttach>false</LocalDebuggerAttach>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <LocalDebuggerCommand>$(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\$(TargetFileName)</LocalDebuggerCommand>
+    <LocalDebuggerWorkingDirectory>$(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\</LocalDebuggerWorkingDirectory>
+    <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
+  </PropertyGroup>
+</Project>

+ 287 - 0
zhipuzi_pay_plugin/zhipuzi_pos_windows.vcxproj

@@ -0,0 +1,287 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <VCProjectVersion>15.0</VCProjectVersion>
+    <ProjectGuid>{1D694BE0-D976-4F29-8997-3308ADFFF413}</ProjectGuid>
+    <Keyword>Win32Proj</Keyword>
+    <RootNamespace>zhipuziposwindows</RootNamespace>
+    <WindowsTargetPlatformVersion>7.0</WindowsTargetPlatformVersion>
+    <ProjectName>zhipuzi_pos_windows</ProjectName>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v141_xp</PlatformToolset>
+    <CharacterSet>Unicode</CharacterSet>
+    <UseOfMfc>false</UseOfMfc>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v141_xp</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v141_xp</PlatformToolset>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v141</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="Shared">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <LinkIncremental>true</LinkIncremental>
+    <OutDir>$(SolutionDir)temp\link\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
+    <IntDir>$(SolutionDir)temp\compile\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <LinkIncremental>true</LinkIncremental>
+    <OutDir>$(SolutionDir)temp\link\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
+    <IntDir>$(SolutionDir)temp\compile\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <LinkIncremental>false</LinkIncremental>
+    <OutDir>$(SolutionDir)temp\link\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
+    <IntDir>$(SolutionDir)temp\compile\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <LinkIncremental>false</LinkIncremental>
+    <OutDir>$(SolutionDir)temp\link\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
+    <IntDir>$(SolutionDir)temp\compile\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <ClCompile>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <SDLCheck>true</SDLCheck>
+      <PreprocessorDefinitions>_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_WIN32_WINNT=0x600;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <ConformanceMode>true</ConformanceMode>
+      <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+      <AdditionalIncludeDirectories>$(SolutionDir)include;$(ProjectDir)pch</AdditionalIncludeDirectories>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalOptions>/ignore:4099 %(AdditionalOptions)</AdditionalOptions>
+      <AdditionalLibraryDirectories>$(SolutionDir)lib\debug\grpc;$(SolutionDir)lib;$(SolutionDir)lib\debug</AdditionalLibraryDirectories>
+      <AdditionalDependencies>log4cplusUD.lib;aliyun-mns.lib;libcurl_debug.lib;libeay32.lib;ssleay32.lib;mysqlcppconn.lib;Dbghelp.lib;libprotobufd.lib;grpc.lib;grpc++.lib;cares.lib;gpr.lib;zlibd.lib;address_sorting.lib;ssl.lib;crypto.lib;DuiLib_ud.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <MinimumRequiredVersion>5.02</MinimumRequiredVersion>
+    </Link>
+    <PostBuildEvent>
+      <Command>mkdir $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\
+copy $(TargetPath) $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\
+copy $(SolutionDir)dll\debug\ $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\
+mkdir $(SolutionDir)bin\$(Platform)\$(Configuration)\conf\
+copy $(ProjectDir)conf\ $(SolutionDir)bin\$(Platform)\$(Configuration)\conf\</Command>
+    </PostBuildEvent>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <SDLCheck>true</SDLCheck>
+      <PreprocessorDefinitions>_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_WIN32_WINNT=0x600;LOG4CPLUS_DISABLE_DLL_RUNTIME_WARNING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <ConformanceMode>false</ConformanceMode>
+      <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+      <AdditionalIncludeDirectories>$(SolutionDir)include;$(ProjectDir)pch</AdditionalIncludeDirectories>
+      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+      <DisableSpecificWarnings>4099</DisableSpecificWarnings>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalLibraryDirectories>$(SolutionDir)lib\debug</AdditionalLibraryDirectories>
+      <AdditionalDependencies>dbghelp.lib;winmm.lib;setupapi.lib;AdvAPI32.lib;Shell32.lib;user32.lib;kernel32.lib;Gdi32.lib;libboost_date_time-vc141-mt-sgd-x32-1_70.lib;libboost_regex-vc141-mt-sgd-x32-1_70.lib;sqlite3.lib;libcurl.lib;DuiLib_ud.lib;log4cplusUD.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <IgnoreSpecificDefaultLibraries>
+      </IgnoreSpecificDefaultLibraries>
+      <Version>
+      </Version>
+    </Link>
+    <PostBuildEvent>
+      <Command>mkdir $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\
+mkdir $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\music\
+mkdir $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\icon\
+copy $(TargetPath) $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\
+copy $(SolutionDir)dll\debug\ $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\
+copy $(SolutionDir)res\music\ $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\music\
+copy $(SolutionDir)res\icon\ $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\icon\
+</Command>
+    </PostBuildEvent>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <SDLCheck>true</SDLCheck>
+      <PreprocessorDefinitions>NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_WIN32_WINNT=0x600;LOG4CPLUS_DISABLE_DLL_RUNTIME_WARNING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <ConformanceMode>false</ConformanceMode>
+      <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+      <AdditionalIncludeDirectories>$(SolutionDir)include;$(ProjectDir)pch</AdditionalIncludeDirectories>
+      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+      <DisableSpecificWarnings>4099</DisableSpecificWarnings>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalLibraryDirectories>$(SolutionDir)lib\release</AdditionalLibraryDirectories>
+      <AdditionalDependencies>dbghelp.lib;winmm.lib;setupapi.lib;AdvAPI32.lib;Shell32.lib;user32.lib;kernel32.lib;Gdi32.lib;sqlite3.lib;libcurl.lib;DuiLib_u.lib;log4cplusU.lib;version.lib;libboost_date_time-vc141-mt-s-x32-1_70.lib;libboost_regex-vc141-mt-s-x32-1_70.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+    <PostBuildEvent>
+      <Command>mkdir $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\
+mkdir $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\music\
+mkdir $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\icon\
+copy $(TargetPath) $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\
+copy $(SolutionDir)dll\release\ $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\
+copy $(SolutionDir)res\music\ $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\music\
+copy $(SolutionDir)res\icon\ $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\icon\
+</Command>
+    </PostBuildEvent>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <ClCompile>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <SDLCheck>true</SDLCheck>
+      <PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_WIN32_WINNT=0x600</PreprocessorDefinitions>
+      <ConformanceMode>true</ConformanceMode>
+      <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+      <AdditionalIncludeDirectories>$(SolutionDir)include;$(ProjectDir)pch</AdditionalIncludeDirectories>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <GenerateDebugInformation>false</GenerateDebugInformation>
+      <AdditionalLibraryDirectories>$(SolutionDir)lib\release\grpc;$(SolutionDir)lib;$(SolutionDir)lib\release</AdditionalLibraryDirectories>
+      <AdditionalDependencies>
+      </AdditionalDependencies>
+      <AdditionalOptions>/ignore:4099 %(AdditionalOptions)</AdditionalOptions>
+    </Link>
+    <PostBuildEvent>
+      <Command>mkdir $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\
+copy $(TargetPath) $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\
+copy $(SolutionDir)dll\release\ $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\
+mkdir $(SolutionDir)bin\$(Platform)\$(Configuration)\conf\
+copy $(ProjectDir)conf\ $(SolutionDir)bin\$(Platform)\$(Configuration)\conf\</Command>
+    </PostBuildEvent>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClInclude Include="wnd\CMessageboxWnd.h" />
+    <ClInclude Include="wnd\CUpdateWnd.h" />
+    <ClInclude Include="wnd\CWaimaiOrderFailReasonWnd.h" />
+    <ClInclude Include="network\PosMessage.h" />
+    <ClInclude Include="wnd\CChufangSettingWnd.h" />
+    <ClInclude Include="control\CWaimaiOrderInfoUI.h" />
+    <ClInclude Include="control\CSettingUI.h" />
+    <ClInclude Include="tool\CSetting.h" />
+    <ClInclude Include="tool\CSqlite3.h" />
+    <ClInclude Include="network\CMessagePush.h" />
+    <ClInclude Include="order\CWaimaiOrder.h" />
+    <ClInclude Include="tool\CPosPrinter.h" />
+    <ClInclude Include="control\CWaimaiOrderItemUI.h" />
+    <ClInclude Include="wnd\CMainWnd.h" />
+    <ClInclude Include="wnd\CLoginWnd.h" />
+    <ClInclude Include="helper\MD5.h" />
+    <ClInclude Include="network\CZhipuziHttpClient.h" />
+    <ClInclude Include="helper\CLewaimaiString.h" />
+    <ClInclude Include="helper\CRandomHelper.h" />
+    <ClInclude Include="helper\define.h" />
+    <ClInclude Include="network\CHttpClient.h" />
+    <ClInclude Include="control\ControlEx.h" />
+    <ClInclude Include="resource\resource.h" />
+    <ClInclude Include="tool\CLewaimaiLog.h" />
+    <ClInclude Include="pch\pch.h" />
+    <ClInclude Include="tool\CLewaimaiTime.h" />
+    <ClInclude Include="helper\CSystem.h" />
+    <ClInclude Include="control\OrderListUI.h" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="wnd\CMessageboxWnd.cpp" />
+    <ClCompile Include="wnd\CUpdateWnd.cpp" />
+    <ClCompile Include="wnd\CWaimaiOrderFailReasonWnd.cpp" />
+    <ClCompile Include="wnd\CChufangSettingWnd.cpp" />
+    <ClCompile Include="control\CWaimaiOrderInfoUI.cpp" />
+    <ClCompile Include="control\CSettingUI.cpp" />
+    <ClCompile Include="tool\CSetting.cpp" />
+    <ClCompile Include="tool\CSqlite3.cpp" />
+    <ClCompile Include="network\CMessagePush.cpp" />
+    <ClCompile Include="order\CWaimaiOrder.cpp" />
+    <ClCompile Include="tool\CPosPrinter.cpp" />
+    <ClCompile Include="control\CWaimaiOrderItemUI.cpp" />
+    <ClCompile Include="wnd\CMainWnd.cpp" />
+    <ClCompile Include="wnd\CLoginWnd.cpp" />
+    <ClCompile Include="helper\MD5.cpp" />
+    <ClCompile Include="network\CZhipuziHttpClient.cpp" />
+    <ClCompile Include="helper\CLewaimaiString.cpp" />
+    <ClCompile Include="helper\CRandomHelper.cpp" />
+    <ClCompile Include="helper\CSystem.cpp" />
+    <ClCompile Include="network\CHttpClient.cpp" />
+    <ClCompile Include="tool\CLewaimaiLog.cpp" />
+    <ClCompile Include="zhipuzi_pos_windows.cpp" />
+    <ClCompile Include="pch\pch.cpp" />
+    <ClCompile Include="tool\CLewaimaiTime.cpp" />
+    <ClCompile Include="control\OrderListUI.cpp" />
+  </ItemGroup>
+  <ItemGroup>
+    <ResourceCompile Include="resource\zhipuzi_pos_windows.rc" />
+  </ItemGroup>
+  <ItemGroup>
+    <Image Include="resource\zhipuzi.ico" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>

+ 4 - 0
zhipuzi_pay_plugin/zhipuzi_pos_windows.vcxproj.user

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup />
+</Project>