|
|
@@ -0,0 +1,1270 @@
|
|
|
+#include "../pch/pch.h"
|
|
|
+#include "CHuiyuanChongzhiWnd.h"
|
|
|
+
|
|
|
+#include "CMessageboxWnd.h"
|
|
|
+
|
|
|
+#include "../helper/CSpeech.h"
|
|
|
+
|
|
|
+#include "../helper/MD5.h"
|
|
|
+
|
|
|
+#define WM_TIMER_WND_CLOSE 200001
|
|
|
+
|
|
|
+void CHuiyuanChongzhiWnd::Init()
|
|
|
+{
|
|
|
+ //::SetWindowPos(m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
|
|
|
+}
|
|
|
+
|
|
|
+void CHuiyuanChongzhiWnd::Notify(TNotifyUI& msg)
|
|
|
+{
|
|
|
+ DuiLib::CDuiString senderName = msg.pSender->GetName();
|
|
|
+
|
|
|
+ if (msg.sType == _T("click"))
|
|
|
+ {
|
|
|
+ DuiLib::CDuiString senderName = msg.pSender->GetName();
|
|
|
+
|
|
|
+ if (msg.pSender->GetName() == _T("closebtn"))
|
|
|
+ {
|
|
|
+ StartClose();
|
|
|
+ }
|
|
|
+ else if (msg.pSender->GetName() == _T("shoukuanBtn"))
|
|
|
+ {
|
|
|
+ StartShoukuan();
|
|
|
+ }
|
|
|
+ else if (msg.pSender->GetName() == L"xianjin_kuaijie_50")
|
|
|
+ {
|
|
|
+ //这里直接SetText,不会触发textchange事件
|
|
|
+ CEditUI* pContent = static_cast<CEditUI*>(m_pm.FindControl(_T("chongzhi_edit")));
|
|
|
+ pContent->SetText(L"50");
|
|
|
+
|
|
|
+ pContent->SetFocus();
|
|
|
+ }
|
|
|
+ else if (msg.pSender->GetName() == L"xianjin_kuaijie_100")
|
|
|
+ {
|
|
|
+ CEditUI* pContent = static_cast<CEditUI*>(m_pm.FindControl(_T("chongzhi_edit")));
|
|
|
+ pContent->SetText(L"100");
|
|
|
+
|
|
|
+ pContent->SetFocus();
|
|
|
+ }
|
|
|
+ else if (msg.pSender->GetName() == L"xianjin_kuaijie_200")
|
|
|
+ {
|
|
|
+ CEditUI* pContent = static_cast<CEditUI*>(m_pm.FindControl(_T("chongzhi_edit")));
|
|
|
+ pContent->SetText(L"200");
|
|
|
+
|
|
|
+ pContent->SetFocus();
|
|
|
+ }
|
|
|
+ else if (msg.pSender->GetName() == L"xianjin_kuaijie_500")
|
|
|
+ {
|
|
|
+ CEditUI* pContent = static_cast<CEditUI*>(m_pm.FindControl(_T("chongzhi_edit")));
|
|
|
+ pContent->SetText(L"500");
|
|
|
+
|
|
|
+ pContent->SetFocus();
|
|
|
+ }
|
|
|
+ else if (msg.pSender->GetName() == L"xianjin_kuaijie_1000")
|
|
|
+ {
|
|
|
+ CEditUI* pContent = static_cast<CEditUI*>(m_pm.FindControl(_T("chongzhi_edit")));
|
|
|
+ pContent->SetText(L"1000");
|
|
|
+
|
|
|
+ pContent->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_1")
|
|
|
+ {
|
|
|
+ CEditUI* curEdit;
|
|
|
+
|
|
|
+ CEditUI* pChongzhi = static_cast<CEditUI*>(m_pm.FindControl(_T("chongzhi_edit")));
|
|
|
+ CEditUI* pZengsong = static_cast<CEditUI*>(m_pm.FindControl(_T("zengsong_edit")));
|
|
|
+ if (m_inputType == 1)
|
|
|
+ {
|
|
|
+ curEdit = pChongzhi;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ curEdit = pZengsong;
|
|
|
+ }
|
|
|
+ wstring wsReason = curEdit->GetText();
|
|
|
+
|
|
|
+ wsReason += L"1";
|
|
|
+
|
|
|
+ curEdit->SetText(wsReason.c_str());
|
|
|
+ curEdit->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_2")
|
|
|
+ {
|
|
|
+ CEditUI* curEdit;
|
|
|
+
|
|
|
+ CEditUI* pChongzhi = static_cast<CEditUI*>(m_pm.FindControl(_T("chongzhi_edit")));
|
|
|
+ CEditUI* pZengsong = static_cast<CEditUI*>(m_pm.FindControl(_T("zengsong_edit")));
|
|
|
+ if (m_inputType == 1)
|
|
|
+ {
|
|
|
+ curEdit = pChongzhi;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ curEdit = pZengsong;
|
|
|
+ }
|
|
|
+ wstring wsReason = curEdit->GetText();
|
|
|
+
|
|
|
+ wsReason += L"2";
|
|
|
+
|
|
|
+ curEdit->SetText(wsReason.c_str());
|
|
|
+ curEdit->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_3")
|
|
|
+ {
|
|
|
+ CEditUI* curEdit;
|
|
|
+
|
|
|
+ CEditUI* pChongzhi = static_cast<CEditUI*>(m_pm.FindControl(_T("chongzhi_edit")));
|
|
|
+ CEditUI* pZengsong = static_cast<CEditUI*>(m_pm.FindControl(_T("zengsong_edit")));
|
|
|
+ if (m_inputType == 1)
|
|
|
+ {
|
|
|
+ curEdit = pChongzhi;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ curEdit = pZengsong;
|
|
|
+ }
|
|
|
+ wstring wsReason = curEdit->GetText();
|
|
|
+
|
|
|
+ wsReason += L"3";
|
|
|
+
|
|
|
+ curEdit->SetText(wsReason.c_str());
|
|
|
+ curEdit->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_4")
|
|
|
+ {
|
|
|
+ CEditUI* curEdit;
|
|
|
+
|
|
|
+ CEditUI* pChongzhi = static_cast<CEditUI*>(m_pm.FindControl(_T("chongzhi_edit")));
|
|
|
+ CEditUI* pZengsong = static_cast<CEditUI*>(m_pm.FindControl(_T("zengsong_edit")));
|
|
|
+ if (m_inputType == 1)
|
|
|
+ {
|
|
|
+ curEdit = pChongzhi;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ curEdit = pZengsong;
|
|
|
+ }
|
|
|
+ wstring wsReason = curEdit->GetText();
|
|
|
+
|
|
|
+ wsReason += L"4";
|
|
|
+
|
|
|
+ curEdit->SetText(wsReason.c_str());
|
|
|
+ curEdit->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_5")
|
|
|
+ {
|
|
|
+ CEditUI* curEdit;
|
|
|
+
|
|
|
+ CEditUI* pChongzhi = static_cast<CEditUI*>(m_pm.FindControl(_T("chongzhi_edit")));
|
|
|
+ CEditUI* pZengsong = static_cast<CEditUI*>(m_pm.FindControl(_T("zengsong_edit")));
|
|
|
+ if (m_inputType == 1)
|
|
|
+ {
|
|
|
+ curEdit = pChongzhi;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ curEdit = pZengsong;
|
|
|
+ }
|
|
|
+ wstring wsReason = curEdit->GetText();
|
|
|
+
|
|
|
+ wsReason += L"5";
|
|
|
+
|
|
|
+ curEdit->SetText(wsReason.c_str());
|
|
|
+ curEdit->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_6")
|
|
|
+ {
|
|
|
+ CEditUI* curEdit;
|
|
|
+
|
|
|
+ CEditUI* pChongzhi = static_cast<CEditUI*>(m_pm.FindControl(_T("chongzhi_edit")));
|
|
|
+ CEditUI* pZengsong = static_cast<CEditUI*>(m_pm.FindControl(_T("zengsong_edit")));
|
|
|
+ if (m_inputType == 1)
|
|
|
+ {
|
|
|
+ curEdit = pChongzhi;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ curEdit = pZengsong;
|
|
|
+ }
|
|
|
+ wstring wsReason = curEdit->GetText();
|
|
|
+
|
|
|
+ wsReason += L"6";
|
|
|
+
|
|
|
+ curEdit->SetText(wsReason.c_str());
|
|
|
+ curEdit->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_7")
|
|
|
+ {
|
|
|
+ CEditUI* curEdit;
|
|
|
+
|
|
|
+ CEditUI* pChongzhi = static_cast<CEditUI*>(m_pm.FindControl(_T("chongzhi_edit")));
|
|
|
+ CEditUI* pZengsong = static_cast<CEditUI*>(m_pm.FindControl(_T("zengsong_edit")));
|
|
|
+ if (m_inputType == 1)
|
|
|
+ {
|
|
|
+ curEdit = pChongzhi;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ curEdit = pZengsong;
|
|
|
+ }
|
|
|
+ wstring wsReason = curEdit->GetText();
|
|
|
+
|
|
|
+ wsReason += L"7";
|
|
|
+
|
|
|
+ curEdit->SetText(wsReason.c_str());
|
|
|
+ curEdit->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_8")
|
|
|
+ {
|
|
|
+ CEditUI* curEdit;
|
|
|
+
|
|
|
+ CEditUI* pChongzhi = static_cast<CEditUI*>(m_pm.FindControl(_T("chongzhi_edit")));
|
|
|
+ CEditUI* pZengsong = static_cast<CEditUI*>(m_pm.FindControl(_T("zengsong_edit")));
|
|
|
+ if (m_inputType == 1)
|
|
|
+ {
|
|
|
+ curEdit = pChongzhi;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ curEdit = pZengsong;
|
|
|
+ }
|
|
|
+ wstring wsReason = curEdit->GetText();
|
|
|
+
|
|
|
+ wsReason += L"8";
|
|
|
+
|
|
|
+ curEdit->SetText(wsReason.c_str());
|
|
|
+ curEdit->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_9")
|
|
|
+ {
|
|
|
+ CEditUI* curEdit;
|
|
|
+
|
|
|
+ CEditUI* pChongzhi = static_cast<CEditUI*>(m_pm.FindControl(_T("chongzhi_edit")));
|
|
|
+ CEditUI* pZengsong = static_cast<CEditUI*>(m_pm.FindControl(_T("zengsong_edit")));
|
|
|
+ if (m_inputType == 1)
|
|
|
+ {
|
|
|
+ curEdit = pChongzhi;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ curEdit = pZengsong;
|
|
|
+ }
|
|
|
+ wstring wsReason = curEdit->GetText();
|
|
|
+
|
|
|
+ wsReason += L"9";
|
|
|
+
|
|
|
+ curEdit->SetText(wsReason.c_str());
|
|
|
+ curEdit->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_0")
|
|
|
+ {
|
|
|
+ CEditUI* curEdit;
|
|
|
+
|
|
|
+ CEditUI* pChongzhi = static_cast<CEditUI*>(m_pm.FindControl(_T("chongzhi_edit")));
|
|
|
+ CEditUI* pZengsong = static_cast<CEditUI*>(m_pm.FindControl(_T("zengsong_edit")));
|
|
|
+ if (m_inputType == 1)
|
|
|
+ {
|
|
|
+ curEdit = pChongzhi;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ curEdit = pZengsong;
|
|
|
+ }
|
|
|
+ wstring wsReason = curEdit->GetText();
|
|
|
+
|
|
|
+ wsReason += L"0";
|
|
|
+
|
|
|
+ curEdit->SetText(wsReason.c_str());
|
|
|
+ curEdit->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_x")
|
|
|
+ {
|
|
|
+ CEditUI* curEdit;
|
|
|
+
|
|
|
+ CEditUI* pChongzhi = static_cast<CEditUI*>(m_pm.FindControl(_T("chongzhi_edit")));
|
|
|
+ CEditUI* pZengsong = static_cast<CEditUI*>(m_pm.FindControl(_T("zengsong_edit")));
|
|
|
+ if (m_inputType == 1)
|
|
|
+ {
|
|
|
+ curEdit = pChongzhi;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ curEdit = pZengsong;
|
|
|
+ }
|
|
|
+ wstring wsReason = curEdit->GetText();
|
|
|
+
|
|
|
+ wsReason = wsReason.substr(0, wsReason.length() - 1);
|
|
|
+
|
|
|
+ curEdit->SetText(wsReason.c_str());
|
|
|
+ curEdit->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_dian")
|
|
|
+ {
|
|
|
+ CEditUI* curEdit;
|
|
|
+
|
|
|
+ CEditUI* pChongzhi = static_cast<CEditUI*>(m_pm.FindControl(_T("chongzhi_edit")));
|
|
|
+ CEditUI* pZengsong = static_cast<CEditUI*>(m_pm.FindControl(_T("zengsong_edit")));
|
|
|
+ if (m_inputType == 1)
|
|
|
+ {
|
|
|
+ curEdit = pChongzhi;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ curEdit = pZengsong;
|
|
|
+ }
|
|
|
+ wstring wsReason = curEdit->GetText();
|
|
|
+
|
|
|
+ wsReason += L".";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (msg.sType == _T("textchanged"))
|
|
|
+ {
|
|
|
+ if (senderName == L"chongzhi_edit")
|
|
|
+ {
|
|
|
+ //只能输入数字,其他的全部删除
|
|
|
+ CEditUI* m_pEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("chongzhi_edit")));
|
|
|
+ if (!m_pEdit->GetText().IsEmpty())
|
|
|
+ {
|
|
|
+ wstring ws_Value = m_pEdit->GetText();
|
|
|
+ string strValue = CLewaimaiString::UnicodeToUTF8(ws_Value);
|
|
|
+
|
|
|
+ for (size_t nIndex = 0; nIndex < strValue.length(); nIndex++)
|
|
|
+ {
|
|
|
+ unsigned char tmp = strValue.at(nIndex);
|
|
|
+ if ((tmp > 57 || tmp < 48) && tmp != 46)
|
|
|
+ {
|
|
|
+ //ASCII码不是数字的都过滤掉
|
|
|
+ strValue = strValue.substr(0, nIndex);
|
|
|
+
|
|
|
+ m_pEdit->SetText(CLewaimaiString::UTF8ToUnicode(strValue).c_str());
|
|
|
+ m_pEdit->SetSel(strValue.length(), strValue.length());//重设给光标设置位置
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (senderName == L"zengsong_edit")
|
|
|
+ {
|
|
|
+ //只能输入数字,其他的全部删除
|
|
|
+ CEditUI* m_pEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("zengsong_edit")));
|
|
|
+ if (!m_pEdit->GetText().IsEmpty())
|
|
|
+ {
|
|
|
+ wstring ws_Value = m_pEdit->GetText();
|
|
|
+ string strValue = CLewaimaiString::UnicodeToUTF8(ws_Value);
|
|
|
+
|
|
|
+ for (size_t nIndex = 0; nIndex < strValue.length(); nIndex++)
|
|
|
+ {
|
|
|
+ unsigned char tmp = strValue.at(nIndex);
|
|
|
+ if ((tmp > 57 || tmp < 48) && tmp != 46)
|
|
|
+ {
|
|
|
+ //ASCII码不是数字的都过滤掉
|
|
|
+ strValue = strValue.substr(0, nIndex);
|
|
|
+
|
|
|
+ m_pEdit->SetText(CLewaimaiString::UTF8ToUnicode(strValue).c_str());
|
|
|
+ m_pEdit->SetSel(strValue.length(), strValue.length());//重设给光标设置位置
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (msg.sType == L"windowinit")
|
|
|
+ {
|
|
|
+ m_pm.SetNextTabControl(false);
|
|
|
+
|
|
|
+ CEditUI* pFukuanEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("chongzhi_edit")));
|
|
|
+ pFukuanEdit->SetFocus();
|
|
|
+ }
|
|
|
+ else if (msg.sType == _T("setfocus"))
|
|
|
+ {
|
|
|
+ if (senderName == L"chongzhi_edit")
|
|
|
+ {
|
|
|
+ m_inputType = 1;
|
|
|
+ }
|
|
|
+ else if (senderName == L"zengsong_edit")
|
|
|
+ {
|
|
|
+ m_inputType = 2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+LRESULT CHuiyuanChongzhiWnd::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("huiyuan_chongzhi_wnd.xml"), (UINT)0, NULL, &m_pm);
|
|
|
+ ASSERT(pRoot && "Failed to parse XML");
|
|
|
+
|
|
|
+ // 把这些控件绘制到本窗口上
|
|
|
+ m_pm.AttachDialog(pRoot);
|
|
|
+
|
|
|
+ // 把自己加入到CPaintManagerUI的m_aNotifiers数组中,用于处理Notify函数
|
|
|
+ m_pm.AddNotifier(this);
|
|
|
+
|
|
|
+ Init();
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+LRESULT CHuiyuanChongzhiWnd::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
+{
|
|
|
+ //销毁定时器
|
|
|
+ KillTimer(m_hWnd, WM_TIMER_WND_CLOSE);
|
|
|
+
|
|
|
+ bHandled = FALSE;
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ *这个是窗口被销毁的时候调用的
|
|
|
+ **/
|
|
|
+LRESULT CHuiyuanChongzhiWnd::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
+{
|
|
|
+ bHandled = FALSE;
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+LRESULT CHuiyuanChongzhiWnd::OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
+{
|
|
|
+ if (::IsIconic(*this))
|
|
|
+ {
|
|
|
+ bHandled = FALSE;
|
|
|
+ }
|
|
|
+
|
|
|
+ return (wParam == 0) ? TRUE : FALSE;
|
|
|
+}
|
|
|
+
|
|
|
+LRESULT CHuiyuanChongzhiWnd::OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
+{
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+LRESULT CHuiyuanChongzhiWnd::OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
+{
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+LRESULT CHuiyuanChongzhiWnd::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 CHuiyuanChongzhiWnd::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 CHuiyuanChongzhiWnd::OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
+{
|
|
|
+ bHandled = TRUE;
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+LRESULT CHuiyuanChongzhiWnd::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
+{
|
|
|
+ if (wParam != WM_TIMER_WND_CLOSE)
|
|
|
+ {
|
|
|
+ bHandled = FALSE;
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (m_shoukuan_status == 0 || m_shoukuan_status == 1)
|
|
|
+ {
|
|
|
+ }
|
|
|
+ else if (m_shoukuan_status == 2)
|
|
|
+ {
|
|
|
+ }
|
|
|
+ else if (m_shoukuan_status == 3)
|
|
|
+ {
|
|
|
+ m_timer_now--;
|
|
|
+
|
|
|
+ if (m_timer_now > 0)
|
|
|
+ {
|
|
|
+ CLabelUI* attention = static_cast<CLabelUI*>(m_pm.FindControl(_T("shouyin_pay_success_attention")));
|
|
|
+ std::wstring ws_attention = L"按任意键关闭窗口," + to_wstring(m_timer_now) + L" 秒后自动关闭";
|
|
|
+ attention->SetText(ws_attention.c_str());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Close(IDOK);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (m_shoukuan_status == 4)
|
|
|
+ {
|
|
|
+ m_timer_now--;
|
|
|
+
|
|
|
+ if (m_timer_now > 0)
|
|
|
+ {
|
|
|
+ CLabelUI* pFailMessage = static_cast<CLabelUI*>(m_pm.FindControl(_T("shouyin_pay_fail_attention")));
|
|
|
+
|
|
|
+ std::wstring ws_fail_message = L"失败信息:" + m_fail_message + L",按任意键关闭窗口,";
|
|
|
+ std::wstring ws_attention = ws_fail_message + to_wstring(m_timer_now) + L" 秒后自动关闭";
|
|
|
+
|
|
|
+ pFailMessage->SetText(ws_attention.c_str());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Close(IDCANCEL);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ bHandled = TRUE;
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+LRESULT CHuiyuanChongzhiWnd::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_MOUSEHOVER:
|
|
|
+ lRes = OnMouseMove(uMsg, wParam, lParam, bHandled);
|
|
|
+ break;
|
|
|
+ case WM_SHOUKUAN_STATUS_NEEDPASSWORD:
|
|
|
+ lRes = OnShoukuanNeedPassword(uMsg, wParam, lParam, bHandled);
|
|
|
+ break;
|
|
|
+ case WM_SHOUKUAN_STATUS_SUCCESS:
|
|
|
+ lRes = OnShoukuanSuccess(uMsg, wParam, lParam, bHandled);
|
|
|
+ break;
|
|
|
+ case WM_SHOUKUAN_STATUS_FAIL:
|
|
|
+ lRes = OnShoukuanFail(uMsg, wParam, lParam, bHandled);
|
|
|
+ break;
|
|
|
+ case WM_TIMER:
|
|
|
+ lRes = OnTimer(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 CHuiyuanChongzhiWnd::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled)
|
|
|
+{
|
|
|
+ if (uMsg == WM_KEYDOWN)
|
|
|
+ {
|
|
|
+ if (wParam == VK_RETURN)
|
|
|
+ {
|
|
|
+ if (m_shoukuan_status == 0)
|
|
|
+ {
|
|
|
+ StartShoukuan();
|
|
|
+ }
|
|
|
+ else if (m_shoukuan_status == 1 || m_shoukuan_status == 2 || m_shoukuan_status == 5)
|
|
|
+ {
|
|
|
+ //正在支付的过程中,这个时候按Enter键,不做任何处理
|
|
|
+ }
|
|
|
+ else if (m_shoukuan_status == 3)
|
|
|
+ {
|
|
|
+ //已经明确成功或者失败了,那么久直接关闭就可以了
|
|
|
+ Close(IDOK);
|
|
|
+ }
|
|
|
+ else if (m_shoukuan_status == 4)
|
|
|
+ {
|
|
|
+ //Close(IDCANCEL);
|
|
|
+ StartShoukuan();
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else if (wParam == VK_ESCAPE)
|
|
|
+ {
|
|
|
+ StartClose();
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (m_shoukuan_status == 3)
|
|
|
+ {
|
|
|
+ Close(IDOK);
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else if (m_shoukuan_status == 4)
|
|
|
+ {
|
|
|
+ //Close(IDCANCEL);
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+LRESULT CHuiyuanChongzhiWnd::OnShoukuanNeedPassword(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
+{
|
|
|
+ wstring path = CSystem::GetProgramDir() + L"\\music\\pay_password.wav";
|
|
|
+
|
|
|
+ if (CSetting::GetParam("shoukuan_setting_yuyinbobao") == "1")
|
|
|
+ {
|
|
|
+ PlaySound(path.c_str(), NULL, SND_FILENAME | SND_ASYNC);
|
|
|
+ }
|
|
|
+
|
|
|
+ CLabelUI* pFukuanEdit = static_cast<CLabelUI*>(m_pm.FindControl(_T("shoukuan_paying_status")));
|
|
|
+ pFukuanEdit->SetText(L"用户支付中,需要输入密码");
|
|
|
+
|
|
|
+ //需要用户输入密码,开始查询状态
|
|
|
+ std::thread(&CHuiyuanChongzhiWnd::HandleShoukuanPassword, this).detach();
|
|
|
+
|
|
|
+ bHandled = TRUE;
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+LRESULT CHuiyuanChongzhiWnd::OnShoukuanSuccess(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
+{
|
|
|
+ //播放充值成功的金额
|
|
|
+ if (CSetting::GetParam("setting_is_new_diannei_voice") == "1")
|
|
|
+ {
|
|
|
+ std::thread(&CHuiyuanChongzhiWnd::ReadShoukuanValue, this).detach();
|
|
|
+ }
|
|
|
+
|
|
|
+ CVerticalLayoutUI* paying_layout = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("shoukuan_paying_layout")));
|
|
|
+ paying_layout->SetVisible(false);
|
|
|
+
|
|
|
+ CVerticalLayoutUI* pay_success_layout = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("shoukuan_pay_success_layout")));
|
|
|
+ pay_success_layout->SetVisible(true);
|
|
|
+
|
|
|
+ CLabelUI* pMoneyPaySuccess = static_cast<CLabelUI*>(m_pm.FindControl(_T("shoukuan_pay_success_money")));
|
|
|
+
|
|
|
+ std::wstring valueInfo = L"成功充值:¥" + CLewaimaiString::UTF8ToUnicode(m_chongzhi);
|
|
|
+ pMoneyPaySuccess->SetText(valueInfo.c_str());
|
|
|
+
|
|
|
+ CLabelUI* attention = static_cast<CLabelUI*>(m_pm.FindControl(_T("shouyin_pay_success_attention")));
|
|
|
+ std::wstring ws_attention = L"按任意键关闭窗口," + to_wstring(m_timer_now) + L" 秒后自动关闭";
|
|
|
+ attention->SetText(ws_attention.c_str());
|
|
|
+
|
|
|
+ SetTimer(m_hWnd, WM_TIMER_WND_CLOSE, 1000, NULL);
|
|
|
+
|
|
|
+ SetFocus(m_hWnd);
|
|
|
+
|
|
|
+ bHandled = TRUE;
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+LRESULT CHuiyuanChongzhiWnd::OnShoukuanFail(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
+{
|
|
|
+ wstring path = CSystem::GetProgramDir() + L"\\music\\pay_fail.wav";
|
|
|
+
|
|
|
+ if (CSetting::GetParam("setting_is_new_diannei_voice") == "1")
|
|
|
+ {
|
|
|
+ PlaySound(path.c_str(), NULL, SND_FILENAME | SND_ASYNC);
|
|
|
+ }
|
|
|
+
|
|
|
+ CVerticalLayoutUI* paying_layout = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("shoukuan_paying_layout")));
|
|
|
+ paying_layout->SetVisible(false);
|
|
|
+
|
|
|
+ CVerticalLayoutUI* before_pay_layout = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("shoukuan_before_pay_layout")));
|
|
|
+ before_pay_layout->SetVisible(true);
|
|
|
+
|
|
|
+ CLabelUI* pLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("shoukuanresult")));
|
|
|
+ pLabel->SetText((L"充值失败:" + m_fail_message).c_str());
|
|
|
+ pLabel->SetVisible(true);
|
|
|
+
|
|
|
+ SetFocus(m_hWnd);
|
|
|
+
|
|
|
+ bHandled = TRUE;
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+void CHuiyuanChongzhiWnd::StartShoukuan()
|
|
|
+{
|
|
|
+ CLabelUI* pLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("shoukuanresult")));
|
|
|
+
|
|
|
+ CEditUI* pChongzhiEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("chongzhi_edit")));
|
|
|
+ std::wstring ws_chongzhi = pChongzhiEdit->GetText();
|
|
|
+ m_chongzhi = CLewaimaiString::UnicodeToUTF8(ws_chongzhi);
|
|
|
+
|
|
|
+ CEditUI* pZengsongEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("zengsong_edit")));
|
|
|
+ std::wstring ws_zengsong = pZengsongEdit->GetText();
|
|
|
+ m_zengsong = CLewaimaiString::UnicodeToUTF8(ws_zengsong);
|
|
|
+
|
|
|
+ double chongzhi_value = atof(m_chongzhi.c_str());
|
|
|
+ double zengsong_value = atof(m_zengsong.c_str());
|
|
|
+
|
|
|
+ //检查充值金额
|
|
|
+ if (chongzhi_value < 0.01)
|
|
|
+ {
|
|
|
+ pLabel->SetText(L"充值金额错误,请重新输入!");
|
|
|
+ pLabel->SetVisible(true);
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (chongzhi_value > 50000)
|
|
|
+ {
|
|
|
+ pLabel->SetText(L"充值金额不能大于5万");
|
|
|
+ pLabel->SetVisible(true);
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (zengsong_value > 50000)
|
|
|
+ {
|
|
|
+ pLabel->SetText(L"赠送金额不能大于5万");
|
|
|
+ pLabel->SetVisible(true);
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //不加这个的话,edit按回车之后样式有问题
|
|
|
+ SetFocus(m_hWnd);
|
|
|
+
|
|
|
+ if (m_shoukuan_type == 1)
|
|
|
+ {
|
|
|
+ //微信支付,等待扫码
|
|
|
+ CVerticalLayoutUI* before_pay_layout = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("shoukuan_before_pay_layout")));
|
|
|
+ before_pay_layout->SetVisible(false);
|
|
|
+
|
|
|
+ CVerticalLayoutUI* tishi_layout = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("shoukuan_tishi_layout")));
|
|
|
+ tishi_layout->SetVisible(true);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //现金等,直接开始调用接口,以后做
|
|
|
+ m_shoukuan_status = 1;
|
|
|
+
|
|
|
+ CVerticalLayoutUI* before_pay_layout = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("shoukuan_before_pay_layout")));
|
|
|
+ before_pay_layout->SetVisible(false);
|
|
|
+
|
|
|
+ CVerticalLayoutUI* paying_layout = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("shoukuan_paying_layout")));
|
|
|
+ paying_layout->SetVisible(true);
|
|
|
+
|
|
|
+ CLabelUI* pMoneyPaying = static_cast<CLabelUI*>(m_pm.FindControl(_T("shoukuan_paying_money")));
|
|
|
+
|
|
|
+ std::wstring valueInfo = L"充值金额:¥" + CLewaimaiString::UTF8ToUnicode(m_chongzhi);
|
|
|
+ pMoneyPaying->SetText(valueInfo.c_str());
|
|
|
+
|
|
|
+ //开启一个线程,开始处理登录
|
|
|
+ std::thread(&CHuiyuanChongzhiWnd::HandleShoukuan, this).detach();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void CHuiyuanChongzhiWnd::HandleShoukuan()
|
|
|
+{
|
|
|
+ //先获取会员充值的token
|
|
|
+ std::string token;
|
|
|
+
|
|
|
+ std::map<std::string, std::string> params;
|
|
|
+ std::string response;
|
|
|
+
|
|
|
+ std::string url = "/member/getpaytoken";
|
|
|
+ bool ret = CZhipuziHttpClient::Request(url.c_str(), params, response);
|
|
|
+ if (ret == false)
|
|
|
+ {
|
|
|
+ m_shoukuan_status = 4;
|
|
|
+
|
|
|
+ m_fail_message = L"请求服务器失败,请检查网络设置!";
|
|
|
+
|
|
|
+ SendMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ rapidjson::Document document;
|
|
|
+ document.Parse(response.c_str());
|
|
|
+
|
|
|
+ if (document.HasParseError())
|
|
|
+ {
|
|
|
+ LOG_INFO("parse response error!");
|
|
|
+ m_shoukuan_status = 4;
|
|
|
+
|
|
|
+ m_fail_message = L"服务器错误";
|
|
|
+
|
|
|
+ SendMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!document.HasMember("errcode") || !document.HasMember("errmsg"))
|
|
|
+ {
|
|
|
+ LOG_INFO("json error!");
|
|
|
+ m_shoukuan_status = 4;
|
|
|
+
|
|
|
+ m_fail_message = L"服务器错误";
|
|
|
+
|
|
|
+ SendMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ rapidjson::Value& v_errcode = document["errcode"];
|
|
|
+ int errcode = v_errcode.GetInt();
|
|
|
+ if (errcode != 0)
|
|
|
+ {
|
|
|
+ LOG_INFO("response failed! message:" << document["errmsg"].GetString());
|
|
|
+ m_shoukuan_status = 4;
|
|
|
+
|
|
|
+ std::string errmsg = document["errmsg"].GetString();
|
|
|
+ m_fail_message = CLewaimaiString::UTF8ToUnicode(errmsg);
|
|
|
+
|
|
|
+ SendMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!document.HasMember("data"))
|
|
|
+ {
|
|
|
+ LOG_INFO("json error!");
|
|
|
+ m_shoukuan_status = 4;
|
|
|
+
|
|
|
+ m_fail_message = L"服务器错误";
|
|
|
+
|
|
|
+ SendMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ rapidjson::Value& data = document["data"];
|
|
|
+
|
|
|
+ token = data["token"].GetString();
|
|
|
+
|
|
|
+ std::map<std::string, std::string> params_2;
|
|
|
+ params_2["member_id"] = m_member_id;
|
|
|
+ params_2["card_no"] = m_member_card_no;
|
|
|
+ params_2["token"] = token;
|
|
|
+ params_2["pay_money"] = m_chongzhi;
|
|
|
+ params_2["zengsong_money"] = m_zengsong;
|
|
|
+
|
|
|
+ params_2["yingshou_value"] = m_chongzhi;
|
|
|
+ params_2["shishou_value"] = m_chongzhi;
|
|
|
+ params_2["zhaoling_value"] = "0";
|
|
|
+ params_2["zhifu_code"] = m_fukuanma;
|
|
|
+
|
|
|
+ if (m_shoukuan_type == 1)
|
|
|
+ {
|
|
|
+ params_2["zhifu_type"] = "7";
|
|
|
+ }
|
|
|
+
|
|
|
+ std::string response_2;
|
|
|
+
|
|
|
+ std::string url_2 = "/member/newpay";
|
|
|
+ bool ret_2 = CZhipuziHttpClient::Request(url_2.c_str(), params_2, response_2);
|
|
|
+ if (ret_2 == false)
|
|
|
+ {
|
|
|
+ m_shoukuan_status = 4;
|
|
|
+
|
|
|
+ m_fail_message = L"请求服务器失败,请检查网络设置!";
|
|
|
+
|
|
|
+ SendMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ rapidjson::Document document_2;
|
|
|
+ document_2.Parse(response_2.c_str());
|
|
|
+
|
|
|
+ if (document_2.HasParseError())
|
|
|
+ {
|
|
|
+ LOG_INFO("parse response error!");
|
|
|
+ m_shoukuan_status = 4;
|
|
|
+
|
|
|
+ m_fail_message = L"服务器错误";
|
|
|
+
|
|
|
+ SendMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!document_2.HasMember("errcode") || !document_2.HasMember("errmsg"))
|
|
|
+ {
|
|
|
+ LOG_INFO("json error!");
|
|
|
+ m_shoukuan_status = 4;
|
|
|
+
|
|
|
+ m_fail_message = L"服务器错误";
|
|
|
+
|
|
|
+ SendMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ rapidjson::Value& v_errcode_2 = document_2["errcode"];
|
|
|
+ int errcode_2 = v_errcode_2.GetInt();
|
|
|
+ if (errcode_2 != 0)
|
|
|
+ {
|
|
|
+ LOG_INFO("response failed! message:" << document["errmsg"].GetString());
|
|
|
+ m_shoukuan_status = 4;
|
|
|
+
|
|
|
+ std::string errmsg = document["errmsg"].GetString();
|
|
|
+ m_fail_message = CLewaimaiString::UTF8ToUnicode(errmsg);
|
|
|
+
|
|
|
+ SendMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!document_2.HasMember("data"))
|
|
|
+ {
|
|
|
+ LOG_INFO("json error!");
|
|
|
+ m_shoukuan_status = 4;
|
|
|
+
|
|
|
+ m_fail_message = L"服务器错误";
|
|
|
+
|
|
|
+ SendMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ rapidjson::Value& data_2 = document_2["data"];
|
|
|
+ rapidjson::Value& status = data_2["status"];
|
|
|
+
|
|
|
+ std::string s_status = status.GetString();
|
|
|
+
|
|
|
+ if (s_status == "success")
|
|
|
+ {
|
|
|
+ //支付成功
|
|
|
+ m_shoukuan_status = 3;
|
|
|
+
|
|
|
+ SendMessage(WM_SHOUKUAN_STATUS_SUCCESS, 0, 0);
|
|
|
+ }
|
|
|
+ else if (s_status == "fail")
|
|
|
+ {
|
|
|
+ //支付失败
|
|
|
+ m_shoukuan_status = 4;
|
|
|
+
|
|
|
+ m_fail_message = CLewaimaiString::UTF8ToUnicode(data["message"].GetString());
|
|
|
+
|
|
|
+ SendMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
|
|
|
+ }
|
|
|
+ else if (s_status == "password")
|
|
|
+ {
|
|
|
+ m_shoukuan_status = 2;
|
|
|
+
|
|
|
+ m_trade_no = data["trade_no"].GetString();
|
|
|
+
|
|
|
+ //需要查询支付状态
|
|
|
+ SendMessage(WM_SHOUKUAN_STATUS_NEEDPASSWORD, 0, 0);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ m_shoukuan_status = 4;
|
|
|
+
|
|
|
+ m_fail_message = L"服务器错误";
|
|
|
+
|
|
|
+ SendMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void CHuiyuanChongzhiWnd::HandleShoukuanPassword()
|
|
|
+{
|
|
|
+ std::map<string, string> params;
|
|
|
+
|
|
|
+ params["trade_no"] = m_trade_no;
|
|
|
+
|
|
|
+ while (m_shoukuan_status == 2)
|
|
|
+ {
|
|
|
+ std::string response;
|
|
|
+
|
|
|
+ std::string url = "/member/queryorderstatus";
|
|
|
+ bool ret = CZhipuziHttpClient::Request(url.c_str(), params, response);
|
|
|
+ if (ret == false)
|
|
|
+ {
|
|
|
+ m_shoukuan_status = 4;
|
|
|
+
|
|
|
+ m_fail_message = L"请求服务器失败,请检查网络设置!";
|
|
|
+
|
|
|
+ SendMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ rapidjson::Document document;
|
|
|
+ document.Parse(response.c_str());
|
|
|
+
|
|
|
+ if (document.HasParseError())
|
|
|
+ {
|
|
|
+ LOG_INFO("parse response error!");
|
|
|
+ m_shoukuan_status = 4;
|
|
|
+
|
|
|
+ m_fail_message = L"服务器错误";
|
|
|
+
|
|
|
+ SendMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!document.HasMember("errcode") || !document.HasMember("errmsg") || !document.HasMember("data"))
|
|
|
+ {
|
|
|
+ LOG_INFO("json error!");
|
|
|
+ m_shoukuan_status = 4;
|
|
|
+
|
|
|
+ m_fail_message = L"服务器错误";
|
|
|
+
|
|
|
+ SendMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ rapidjson::Value& v_errcode = document["errcode"];
|
|
|
+ int errcode = v_errcode.GetInt();
|
|
|
+ if (errcode != 0)
|
|
|
+ {
|
|
|
+ LOG_INFO("response failed! message:" << document["errmsg"].GetString());
|
|
|
+ m_shoukuan_status = 4;
|
|
|
+
|
|
|
+ m_fail_message = L"服务器错误";
|
|
|
+
|
|
|
+ SendMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ rapidjson::Value& data = document["data"];
|
|
|
+ rapidjson::Value& status = data["status"];
|
|
|
+
|
|
|
+ std::string s_status = status.GetString();
|
|
|
+
|
|
|
+ if (s_status == "success")
|
|
|
+ {
|
|
|
+ //支付成功
|
|
|
+ m_shoukuan_status = 3;
|
|
|
+
|
|
|
+ SendMessage(WM_SHOUKUAN_STATUS_SUCCESS, 0, 0);
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ else if (s_status == "closed")
|
|
|
+ {
|
|
|
+ //表示顾客那边出问题,已经失败了
|
|
|
+ m_shoukuan_status = 4;
|
|
|
+
|
|
|
+ m_fail_message = L"顾客取消支付,请重新扫码充值";
|
|
|
+
|
|
|
+ SendMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ else if (s_status == "fail")
|
|
|
+ {
|
|
|
+ //这个只是表示状态未知
|
|
|
+ Sleep(1000);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ m_shoukuan_status = 4;
|
|
|
+
|
|
|
+ m_fail_message = L"服务器错误";
|
|
|
+
|
|
|
+ SendMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void CHuiyuanChongzhiWnd::CancelShoukuanPassword()
|
|
|
+{
|
|
|
+ m_shoukuan_status = 5;
|
|
|
+
|
|
|
+ std::thread(&CHuiyuanChongzhiWnd::HandleCancelShoukuan, this).detach();
|
|
|
+}
|
|
|
+
|
|
|
+void CHuiyuanChongzhiWnd::HandleCancelShoukuan()
|
|
|
+{
|
|
|
+ std::map<string, string> params;
|
|
|
+
|
|
|
+ params["trade_no"] = "";
|
|
|
+
|
|
|
+ std::string response;
|
|
|
+
|
|
|
+ std::string url = "/member/closeorder";
|
|
|
+ bool ret = CZhipuziHttpClient::Request(url.c_str(), params, response);
|
|
|
+ if (ret == false)
|
|
|
+ {
|
|
|
+ m_shoukuan_status = 4;
|
|
|
+
|
|
|
+ m_fail_message = L"请求服务器失败,请检查网络设置!";
|
|
|
+
|
|
|
+ SendMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ rapidjson::Document document;
|
|
|
+ document.Parse(response.c_str());
|
|
|
+
|
|
|
+ if (document.HasParseError())
|
|
|
+ {
|
|
|
+ LOG_INFO("parse response error!");
|
|
|
+ m_shoukuan_status = 4;
|
|
|
+
|
|
|
+ m_fail_message = L"服务器错误";
|
|
|
+
|
|
|
+ SendMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!document.HasMember("errcode") || !document.HasMember("errmsg") || !document.HasMember("data"))
|
|
|
+ {
|
|
|
+ LOG_INFO("json error!");
|
|
|
+ m_shoukuan_status = 4;
|
|
|
+
|
|
|
+ m_fail_message = L"服务器错误";
|
|
|
+
|
|
|
+ SendMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ rapidjson::Value& v_errcode = document["errcode"];
|
|
|
+ int errcode = v_errcode.GetInt();
|
|
|
+ if (errcode != 0)
|
|
|
+ {
|
|
|
+ LOG_INFO("response failed! message:" << document["errmsg"].GetString());
|
|
|
+ m_shoukuan_status = 4;
|
|
|
+
|
|
|
+ m_fail_message = L"服务器错误";
|
|
|
+
|
|
|
+ SendMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ rapidjson::Value& data = document["data"];
|
|
|
+ rapidjson::Value& status = data["status"];
|
|
|
+
|
|
|
+ std::string s_status = status.GetString();
|
|
|
+
|
|
|
+ if (s_status == "success")
|
|
|
+ {
|
|
|
+ //取消成功,订单变为失败状态
|
|
|
+ m_shoukuan_status = 4;
|
|
|
+
|
|
|
+ m_fail_message = L"商家取消充值";
|
|
|
+ SendMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ m_shoukuan_status = 4;
|
|
|
+
|
|
|
+ m_fail_message = L"服务器错误";
|
|
|
+
|
|
|
+ SendMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
|
|
|
+}
|
|
|
+
|
|
|
+void CHuiyuanChongzhiWnd::StartClose()
|
|
|
+{
|
|
|
+ if (m_shoukuan_status == 0)
|
|
|
+ {
|
|
|
+ //还没开始支付,直接退出
|
|
|
+ Close(IDCANCEL);
|
|
|
+ }
|
|
|
+ else if (m_shoukuan_status == 1 || m_shoukuan_status == 5)
|
|
|
+ {
|
|
|
+ //不能做任何处理
|
|
|
+ }
|
|
|
+ else if (m_shoukuan_status == 2)
|
|
|
+ {
|
|
|
+ //查询密码的过程中,取消充值
|
|
|
+ CancelShoukuanPassword();
|
|
|
+ }
|
|
|
+ else if (m_shoukuan_status == 3)
|
|
|
+ {
|
|
|
+ Sleep(100);
|
|
|
+ Close(IDOK);
|
|
|
+ }
|
|
|
+ else if (m_shoukuan_status == 4)
|
|
|
+ {
|
|
|
+ Sleep(100);
|
|
|
+ Close(IDCANCEL);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void CHuiyuanChongzhiWnd::ReadShoukuanValue()
|
|
|
+{
|
|
|
+ CSpeech::SpeakNum(1, m_chongzhi);
|
|
|
+}
|
|
|
+
|
|
|
+void CHuiyuanChongzhiWnd::HandleTextCapture(std::string content)
|
|
|
+{
|
|
|
+ m_fukuanma = content;
|
|
|
+
|
|
|
+ if (m_shoukuan_status == 0)
|
|
|
+ {
|
|
|
+ m_shoukuan_status = 1;
|
|
|
+
|
|
|
+ CVerticalLayoutUI* before_pay_layout = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("shoukuan_before_pay_layout")));
|
|
|
+ before_pay_layout->SetVisible(false);
|
|
|
+
|
|
|
+ CVerticalLayoutUI* tishi_layout = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("shoukuan_tishi_layout")));
|
|
|
+ tishi_layout->SetVisible(false);
|
|
|
+
|
|
|
+ CVerticalLayoutUI* paying_layout = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("shoukuan_paying_layout")));
|
|
|
+ paying_layout->SetVisible(true);
|
|
|
+
|
|
|
+ CLabelUI* pMoneyPaying = static_cast<CLabelUI*>(m_pm.FindControl(_T("shoukuan_paying_money")));
|
|
|
+
|
|
|
+ std::wstring valueInfo = L"充值金额:¥" + CLewaimaiString::UTF8ToUnicode(m_chongzhi);
|
|
|
+ pMoneyPaying->SetText(valueInfo.c_str());
|
|
|
+
|
|
|
+ //开启一个线程,开始处理登录
|
|
|
+ std::thread(&CHuiyuanChongzhiWnd::HandleShoukuan, this).detach();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void CHuiyuanChongzhiWnd::SetCurBalance(std::string balance)
|
|
|
+{
|
|
|
+ m_cur_balance = balance;
|
|
|
+
|
|
|
+ CLabelUI* pCurBalance = static_cast<CLabelUI*>(m_pm.FindControl(_T("huiyuan_chongzhi_curbalance")));
|
|
|
+ pCurBalance->SetText((L"当前余额:" + CLewaimaiString::UTF8ToUnicode(m_cur_balance)).c_str());
|
|
|
+}
|