|
|
@@ -0,0 +1,611 @@
|
|
|
+#include "../pch/pch.h"
|
|
|
+#include "CTuikuanWnd.h"
|
|
|
+
|
|
|
+#include "CValueWnd.h"
|
|
|
+
|
|
|
+#include "CMessageboxWnd.h"
|
|
|
+
|
|
|
+#include "../helper/CSpeech.h"
|
|
|
+
|
|
|
+#define WM_TIMER_WND_CLOSE 200001
|
|
|
+
|
|
|
+void CTuikuanWnd::Init()
|
|
|
+{
|
|
|
+ //CSpeech::MSSSpeak(L"欢迎使用智铺子收银插件!");
|
|
|
+}
|
|
|
+
|
|
|
+void CTuikuanWnd::Notify(TNotifyUI& msg)
|
|
|
+{
|
|
|
+ if (msg.sType == _T("click"))
|
|
|
+ {
|
|
|
+ if (msg.pSender->GetName() == _T("closebtn"))
|
|
|
+ {
|
|
|
+ Close();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else if (msg.pSender->GetName() == _T("shoukuanBtn"))
|
|
|
+ {
|
|
|
+ StartTuikuan();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+LRESULT CTuikuanWnd::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("tuikuan_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 CTuikuanWnd::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
+{
|
|
|
+ //销毁定时器
|
|
|
+ KillTimer(m_hWnd, WM_TIMER_WND_CLOSE);
|
|
|
+
|
|
|
+ bHandled = FALSE;
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ *这个是窗口被销毁的时候调用的
|
|
|
+ **/
|
|
|
+LRESULT CTuikuanWnd::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
+{
|
|
|
+ bHandled = FALSE;
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+LRESULT CTuikuanWnd::OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
+{
|
|
|
+ if (::IsIconic(*this))
|
|
|
+ {
|
|
|
+ bHandled = FALSE;
|
|
|
+ }
|
|
|
+
|
|
|
+ return (wParam == 0) ? TRUE : FALSE;
|
|
|
+}
|
|
|
+
|
|
|
+LRESULT CTuikuanWnd::OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
+{
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+LRESULT CTuikuanWnd::OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
+{
|
|
|
+ UpdateFocus();
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+LRESULT CTuikuanWnd::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 CTuikuanWnd::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 CTuikuanWnd::OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
+{
|
|
|
+ bHandled = TRUE;
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+LRESULT CTuikuanWnd::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();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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"失败信息:" + CLewaimaiString::UTF8ToUnicode(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();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ bHandled = TRUE;
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+LRESULT CTuikuanWnd::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_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 CTuikuanWnd::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled)
|
|
|
+{
|
|
|
+ if (uMsg == WM_KEYDOWN)
|
|
|
+ {
|
|
|
+ if (wParam == VK_RETURN)
|
|
|
+ {
|
|
|
+ if (m_shoukuan_status == 0)
|
|
|
+ {
|
|
|
+ StartTuikuan();
|
|
|
+ }
|
|
|
+ else if (m_shoukuan_status == 1 || m_shoukuan_status == 2 || m_shoukuan_status == 5)
|
|
|
+ {
|
|
|
+ //正在支付的过程中,这个时候按Enter键,不做任何处理
|
|
|
+ }
|
|
|
+ else if (m_shoukuan_status == 3 || m_shoukuan_status == 4)
|
|
|
+ {
|
|
|
+ //已经明确成功或者失败了,那么久直接关闭就可以了
|
|
|
+ Close();
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else if (wParam == VK_ESCAPE)
|
|
|
+ {
|
|
|
+ if (m_shoukuan_status == 0)
|
|
|
+ {
|
|
|
+ //还没开始支付,按Esc直接退出
|
|
|
+ Close();
|
|
|
+ }
|
|
|
+ else if (m_shoukuan_status == 1 || m_shoukuan_status == 5)
|
|
|
+ {
|
|
|
+ //不能做任何处理
|
|
|
+ }
|
|
|
+ else if (m_shoukuan_status == 2)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ else if (m_shoukuan_status == 3 || m_shoukuan_status == 4)
|
|
|
+ {
|
|
|
+ //已经明确成功或者失败了,那么久直接关闭就可以了
|
|
|
+ Close();
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (m_shoukuan_status == 3 || m_shoukuan_status == 4)
|
|
|
+ {
|
|
|
+ //已经明确成功或者失败了,那么久直接关闭就可以了
|
|
|
+ Close();
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+void CTuikuanWnd::InitMoney(std::wstring value)
|
|
|
+{
|
|
|
+ CHorizontalLayoutUI* pInputLayout = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("shoukuan_money_input_layout")));
|
|
|
+ pInputLayout->SetVisible(false);
|
|
|
+
|
|
|
+ CHorizontalLayoutUI* pShowLayout = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("shoukuan_money_show_layout")));
|
|
|
+ pShowLayout->SetVisible(true);
|
|
|
+
|
|
|
+ CLabelUI* pMoneyLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("shoukuan_money_show_money")));
|
|
|
+ if (pMoneyLabel)
|
|
|
+ {
|
|
|
+ pMoneyLabel->SetText(value.c_str());
|
|
|
+ }
|
|
|
+
|
|
|
+ m_is_money_init = true;
|
|
|
+ m_money = value;
|
|
|
+}
|
|
|
+
|
|
|
+void CTuikuanWnd::UpdateFocus()
|
|
|
+{
|
|
|
+ if (m_is_money_init == false)
|
|
|
+ {
|
|
|
+ //如果没初始化,这个时候有2个编辑框,不能抢焦点
|
|
|
+ CEditUI* pMoneyEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("money_edit")));
|
|
|
+
|
|
|
+ pMoneyEdit->SetFocus();
|
|
|
+
|
|
|
+ //下一个焦点的,就设置为这个控件
|
|
|
+ m_pm.SetFocusNeeded(pMoneyEdit);
|
|
|
+
|
|
|
+ //这个干嘛的不知道,但是不加好像不行
|
|
|
+ m_pm.SetNextTabControl(false);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ CEditUI* pFukuanEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("tuikuanma_edit")));
|
|
|
+
|
|
|
+ pFukuanEdit->SetFocus();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+LRESULT CTuikuanWnd::OnTuikuanSuccess(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
+{
|
|
|
+ wstring path = CSystem::GetProgramDir() + L"\\music\\pay_success.wav";
|
|
|
+ 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* 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"成功收款:¥" + m_money;
|
|
|
+ pMoneyPaySuccess->SetText(valueInfo.c_str());
|
|
|
+
|
|
|
+ CHorizontalLayoutUI* wx_logo = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("shoukuan_pay_success_logo_wx")));
|
|
|
+ CHorizontalLayoutUI* zhifubao_logo = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("shoukuan_pay_success_logo_zhifubao")));
|
|
|
+ if (m_tuikuanma_type == 1)
|
|
|
+ {
|
|
|
+ wx_logo->SetVisible(true);
|
|
|
+ zhifubao_logo->SetVisible(false);
|
|
|
+ }
|
|
|
+ else if (m_tuikuanma_type == 2)
|
|
|
+ {
|
|
|
+ wx_logo->SetVisible(false);
|
|
|
+ zhifubao_logo->SetVisible(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 CTuikuanWnd::OnTuikuanFail(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
+{
|
|
|
+ wstring path = CSystem::GetProgramDir() + L"\\music\\pay_fail.wav";
|
|
|
+ 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* pay_fail_layout = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("shoukuan_pay_fail_layout")));
|
|
|
+ pay_fail_layout->SetVisible(true);
|
|
|
+
|
|
|
+ CHorizontalLayoutUI* title_layout = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("shoukuan_title_bkg")));
|
|
|
+ title_layout->SetBkColor(0xFFD33E3A);
|
|
|
+
|
|
|
+ CLabelUI* pFailMessage = static_cast<CLabelUI*>(m_pm.FindControl(_T("shouyin_pay_fail_attention")));
|
|
|
+
|
|
|
+ std::wstring ws_fail_message = L"失败信息:" + CLewaimaiString::UTF8ToUnicode(m_fail_message) + L",按任意键关闭窗口,";
|
|
|
+ std::wstring ws_attention = ws_fail_message + to_wstring(m_timer_now) + L" 秒后自动关闭";
|
|
|
+
|
|
|
+ pFailMessage->SetText(ws_attention.c_str());
|
|
|
+
|
|
|
+ SetTimer(m_hWnd, WM_TIMER_WND_CLOSE, 1000, NULL);
|
|
|
+
|
|
|
+ SetFocus(m_hWnd);
|
|
|
+
|
|
|
+ bHandled = TRUE;
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+void CTuikuanWnd::StartTuikuan()
|
|
|
+{
|
|
|
+ CLabelUI* pLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("shoukuanresult")));
|
|
|
+
|
|
|
+ //检查收款金额
|
|
|
+ if (m_is_money_init == false)
|
|
|
+ {
|
|
|
+ CEditUI* pMoneyEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("money_edit")));
|
|
|
+ m_money = pMoneyEdit->GetText();
|
|
|
+
|
|
|
+ if (m_money == L"")
|
|
|
+ {
|
|
|
+ pLabel->SetText(L"收款金额不能为空,请重新输入!");
|
|
|
+ pLabel->SetVisible(true);
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (m_money == L"0.00")
|
|
|
+ {
|
|
|
+ pLabel->SetText(L"收款金额不能为 0 元,请重新输入!");
|
|
|
+ pLabel->SetVisible(true);
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ double money_value = atof(CLewaimaiString::UnicodeToUTF8(m_money).c_str());
|
|
|
+ if (!money_value || money_value < 0.01)
|
|
|
+ {
|
|
|
+ pLabel->SetText(L"收款金额错误,请重新输入!");
|
|
|
+ pLabel->SetVisible(true);
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //先判断收款码的格式是否正确
|
|
|
+ CEditUI* pFukuanmaEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("tuikuanma_edit")));
|
|
|
+ std::wstring ws_Fukuanma = pFukuanmaEdit->GetText();
|
|
|
+ std::string s_Fukuanma = CLewaimaiString::UnicodeToUTF8(ws_Fukuanma);
|
|
|
+
|
|
|
+ int length = s_Fukuanma.size();
|
|
|
+ if (length != 18)
|
|
|
+ {
|
|
|
+ pLabel->SetText(L"收款码格式不对,请检查后重新输入!");
|
|
|
+ pLabel->SetVisible(true);
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < length; i++)
|
|
|
+ {
|
|
|
+ char c = *(s_Fukuanma.c_str() + i);
|
|
|
+ if (isdigit(c) == 0)
|
|
|
+ {
|
|
|
+ //不是数字
|
|
|
+ pLabel->SetText(L"收款码格式不对,请检查后重新输入!");
|
|
|
+ pLabel->SetVisible(true);
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (s_Fukuanma.find("10") == 0 \
|
|
|
+ || s_Fukuanma.find("11") == 0 \
|
|
|
+ || s_Fukuanma.find("12") == 0 \
|
|
|
+ || s_Fukuanma.find("13") == 0 \
|
|
|
+ || s_Fukuanma.find("14") == 0 \
|
|
|
+ || s_Fukuanma.find("15") == 0)
|
|
|
+ {
|
|
|
+ //微信付款码
|
|
|
+ m_tuikuanma_type = 1;
|
|
|
+ }
|
|
|
+ else if (s_Fukuanma.find("25") == 0 \
|
|
|
+ || s_Fukuanma.find("26") == 0 \
|
|
|
+ || s_Fukuanma.find("27") == 0 \
|
|
|
+ || s_Fukuanma.find("28") == 0 \
|
|
|
+ || s_Fukuanma.find("29") == 0 \
|
|
|
+ || s_Fukuanma.find("30") == 0)
|
|
|
+ {
|
|
|
+ //支付宝付款码
|
|
|
+ m_tuikuanma_type = 2;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ pLabel->SetText(L"收款码格式不对,请检查后重新输入!");
|
|
|
+ pLabel->SetVisible(true);
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ m_tuikuanma = ws_Fukuanma;
|
|
|
+
|
|
|
+ //全部验证通过,就可以开始修改状态了
|
|
|
+ m_shoukuan_status = 1;
|
|
|
+
|
|
|
+ //不加这个的话,edit按回车之后样式有问题
|
|
|
+ SetFocus(m_hWnd);
|
|
|
+
|
|
|
+ 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"付款金额:¥" + m_money;
|
|
|
+ pMoneyPaying->SetText(valueInfo.c_str());
|
|
|
+
|
|
|
+ //开启一个线程,开始处理登录
|
|
|
+ std::thread(&CTuikuanWnd::HandleTuikuan, this).detach();
|
|
|
+}
|
|
|
+
|
|
|
+void CTuikuanWnd::HandleTuikuan()
|
|
|
+{
|
|
|
+ //生成随机的order_no
|
|
|
+
|
|
|
+ std::map<string, string> params;
|
|
|
+
|
|
|
+ params["order_no"] = CRandomHelper::GetRandString(20);
|
|
|
+ m_order_no = params["order_no"];
|
|
|
+
|
|
|
+ params["yingshou_value"] = CLewaimaiString::UnicodeToUTF8(m_money);
|
|
|
+ params["shishou_value"] = CLewaimaiString::UnicodeToUTF8(m_money);
|
|
|
+ params["zhaoling_value"] = to_string(0);
|
|
|
+ params["zhifu_type"] = to_string(7);
|
|
|
+ params["zhifu_code"] = CLewaimaiString::UnicodeToUTF8(m_tuikuanma);
|
|
|
+
|
|
|
+ std::string response;
|
|
|
+
|
|
|
+ std::string url = "/shouyin/sendorder";
|
|
|
+ CZhipuziHttpClient::Request(url.c_str(), params, response);
|
|
|
+
|
|
|
+ rapidjson::Document document;
|
|
|
+ document.Parse(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& status = data["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 = 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);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|