|
@@ -1,4 +1,4 @@
|
|
|
-#include "../pch/pch.h"
|
|
|
|
|
|
|
+#include "../pch/pch.h"
|
|
|
#include "CShoukuanWnd.h"
|
|
#include "CShoukuanWnd.h"
|
|
|
|
|
|
|
|
#include "CValueWnd.h"
|
|
#include "CValueWnd.h"
|
|
@@ -32,7 +32,7 @@ LRESULT CShoukuanWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
|
|
|
styleValue &= ~WS_CAPTION;
|
|
styleValue &= ~WS_CAPTION;
|
|
|
::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
|
|
::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
|
|
|
|
|
|
|
|
- // 把自己的窗口句柄与窗口绘制管理器挂接在一起
|
|
|
|
|
|
|
+ // 把自己的窗口句柄与窗口绘制管理器挂接在一起
|
|
|
m_pm.Init(m_hWnd);
|
|
m_pm.Init(m_hWnd);
|
|
|
|
|
|
|
|
m_pm.AddPreMessageFilter(this);
|
|
m_pm.AddPreMessageFilter(this);
|
|
@@ -42,10 +42,10 @@ LRESULT CShoukuanWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
|
|
|
CControlUI* pRoot = builder.Create(_T("shoukuan_wnd.xml"), (UINT)0, NULL, &m_pm);
|
|
CControlUI* pRoot = builder.Create(_T("shoukuan_wnd.xml"), (UINT)0, NULL, &m_pm);
|
|
|
ASSERT(pRoot && "Failed to parse XML");
|
|
ASSERT(pRoot && "Failed to parse XML");
|
|
|
|
|
|
|
|
- // 把这些控件绘制到本窗口上
|
|
|
|
|
|
|
+ // 鎶婅繖浜涙帶浠剁粯鍒跺埌鏈�獥鍙d笂
|
|
|
m_pm.AttachDialog(pRoot);
|
|
m_pm.AttachDialog(pRoot);
|
|
|
|
|
|
|
|
- // 把自己加入到CPaintManagerUI的m_aNotifiers数组中,用于处理Notify函数
|
|
|
|
|
|
|
+ // 鎶婅嚜宸卞姞鍏ュ埌CPaintManagerUI鐨刴_aNotifiers鏁扮粍涓�紝鐢ㄤ簬澶勭悊Notify鍑芥暟
|
|
|
m_pm.AddNotifier(this);
|
|
m_pm.AddNotifier(this);
|
|
|
|
|
|
|
|
Init();
|
|
Init();
|
|
@@ -60,7 +60,7 @@ LRESULT CShoukuanWnd::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHa
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
|
- *这个是窗口被销毁的时候调用的
|
|
|
|
|
|
|
+ *杩欎釜鏄�獥鍙h�閿€姣佺殑鏃跺€欒皟鐢ㄧ殑
|
|
|
**/
|
|
**/
|
|
|
LRESULT CShoukuanWnd::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
LRESULT CShoukuanWnd::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
{
|
|
{
|
|
@@ -174,6 +174,15 @@ LRESULT CShoukuanWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
case WM_SHOUKUAN_UPDATE_FOCUS:
|
|
case WM_SHOUKUAN_UPDATE_FOCUS:
|
|
|
lRes = OnShoukuanUpdateFocus(uMsg, wParam, lParam, bHandled);
|
|
lRes = OnShoukuanUpdateFocus(uMsg, wParam, lParam, bHandled);
|
|
|
break;
|
|
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;
|
|
|
default:
|
|
default:
|
|
|
bHandled = FALSE;
|
|
bHandled = FALSE;
|
|
|
}
|
|
}
|
|
@@ -248,7 +257,7 @@ void CShoukuanWnd::UpdateFocus()
|
|
|
{
|
|
{
|
|
|
if (m_is_money_init == false)
|
|
if (m_is_money_init == false)
|
|
|
{
|
|
{
|
|
|
- //如果没初始化,这个时候有2个编辑框,不能抢焦点
|
|
|
|
|
|
|
+ //濡傛灉娌″垵濮嬪寲锛岃繖涓�椂鍊欐湁2涓�紪杈戞�锛屼笉鑳芥姠鐒︾偣
|
|
|
CEditUI* pMoneyEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("money_edit")));
|
|
CEditUI* pMoneyEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("money_edit")));
|
|
|
|
|
|
|
|
pMoneyEdit->SetFocus();
|
|
pMoneyEdit->SetFocus();
|
|
@@ -261,11 +270,37 @@ void CShoukuanWnd::UpdateFocus()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+LRESULT CShoukuanWnd::OnShoukuanNeedPassword(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
|
+{
|
|
|
|
|
+ CLabelUI* pFukuanEdit = static_cast<CLabelUI*>(m_pm.FindControl(_T("shoukuan_paying_status")));
|
|
|
|
|
+ pFukuanEdit->SetText(L"用户支付中,需要输入密码");
|
|
|
|
|
+
|
|
|
|
|
+ //需要用户输入密码,开始查询状态
|
|
|
|
|
+ std::thread(&CShoukuanWnd::HandleShoukuanPassword, this).detach();
|
|
|
|
|
+
|
|
|
|
|
+ bHandled = true;
|
|
|
|
|
+ return 0;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+LRESULT CShoukuanWnd::OnShoukuanSuccess(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
|
+{
|
|
|
|
|
+ CVerticalLayoutUI* paying_layout = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("shoukuan_paying_layout")));
|
|
|
|
|
+ paying_layout->SetVisible(false);
|
|
|
|
|
+
|
|
|
|
|
+ bHandled = true;
|
|
|
|
|
+ return 0;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+LRESULT CShoukuanWnd::OnShoukuanFail(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
|
+{
|
|
|
|
|
+ return 0;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
void CShoukuanWnd::StartShoukuan()
|
|
void CShoukuanWnd::StartShoukuan()
|
|
|
{
|
|
{
|
|
|
CLabelUI* pLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("shoukuanresult")));
|
|
CLabelUI* pLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("shoukuanresult")));
|
|
|
|
|
|
|
|
- //检查收款金额
|
|
|
|
|
|
|
+ //检查收款金额
|
|
|
if (m_is_money_init == false)
|
|
if (m_is_money_init == false)
|
|
|
{
|
|
{
|
|
|
CEditUI* pMoneyEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("money_edit")));
|
|
CEditUI* pMoneyEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("money_edit")));
|
|
@@ -273,7 +308,7 @@ void CShoukuanWnd::StartShoukuan()
|
|
|
|
|
|
|
|
if (m_money == L"")
|
|
if (m_money == L"")
|
|
|
{
|
|
{
|
|
|
- pLabel->SetText(L"收款金额不能为空,请重新输入!");
|
|
|
|
|
|
|
+ pLabel->SetText(L"收款金额不能为空,请重新输入!");
|
|
|
pLabel->SetVisible(true);
|
|
pLabel->SetVisible(true);
|
|
|
|
|
|
|
|
return;
|
|
return;
|
|
@@ -281,14 +316,14 @@ void CShoukuanWnd::StartShoukuan()
|
|
|
|
|
|
|
|
if (m_money == L"0.00")
|
|
if (m_money == L"0.00")
|
|
|
{
|
|
{
|
|
|
- pLabel->SetText(L"收款金额不能为 0 元,请重新输入!");
|
|
|
|
|
|
|
+ pLabel->SetText(L"收款金额不能为 0 元,请重新输入!");
|
|
|
pLabel->SetVisible(true);
|
|
pLabel->SetVisible(true);
|
|
|
|
|
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //先判断收款码的格式是否正确
|
|
|
|
|
|
|
+ //先判断收款码的格式是否正确
|
|
|
CEditUI* pFukuanmaEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("fukuanma_edit")));
|
|
CEditUI* pFukuanmaEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("fukuanma_edit")));
|
|
|
std::wstring ws_Fukuanma = pFukuanmaEdit->GetText();
|
|
std::wstring ws_Fukuanma = pFukuanmaEdit->GetText();
|
|
|
std::string s_Fukuanma = CLewaimaiString::UnicodeToUTF8(ws_Fukuanma);
|
|
std::string s_Fukuanma = CLewaimaiString::UnicodeToUTF8(ws_Fukuanma);
|
|
@@ -296,7 +331,7 @@ void CShoukuanWnd::StartShoukuan()
|
|
|
int length = s_Fukuanma.size();
|
|
int length = s_Fukuanma.size();
|
|
|
if (length != 18)
|
|
if (length != 18)
|
|
|
{
|
|
{
|
|
|
- pLabel->SetText(L"收款码格式不对,请检查后重新输入!");
|
|
|
|
|
|
|
+ pLabel->SetText(L"收款码格式不对,请检查后重新输入!");
|
|
|
pLabel->SetVisible(true);
|
|
pLabel->SetVisible(true);
|
|
|
|
|
|
|
|
return;
|
|
return;
|
|
@@ -307,8 +342,8 @@ void CShoukuanWnd::StartShoukuan()
|
|
|
char c = *(s_Fukuanma.c_str() + i);
|
|
char c = *(s_Fukuanma.c_str() + i);
|
|
|
if (isdigit(c) == 0)
|
|
if (isdigit(c) == 0)
|
|
|
{
|
|
{
|
|
|
- //不是数字
|
|
|
|
|
- pLabel->SetText(L"收款码格式不对,请检查后重新输入!");
|
|
|
|
|
|
|
+ //涓嶆槸鏁板瓧
|
|
|
|
|
+ pLabel->SetText(L"收款码格式不对,请检查后重新输入!");
|
|
|
pLabel->SetVisible(true);
|
|
pLabel->SetVisible(true);
|
|
|
|
|
|
|
|
return;
|
|
return;
|
|
@@ -328,7 +363,7 @@ void CShoukuanWnd::StartShoukuan()
|
|
|
&& s_Fukuanma.find("29") == s_Fukuanma.npos \
|
|
&& s_Fukuanma.find("29") == s_Fukuanma.npos \
|
|
|
&& s_Fukuanma.find("30") == s_Fukuanma.npos)
|
|
&& s_Fukuanma.find("30") == s_Fukuanma.npos)
|
|
|
{
|
|
{
|
|
|
- pLabel->SetText(L"收款码格式不对,请检查后重新输入!");
|
|
|
|
|
|
|
+ pLabel->SetText(L"收款码格式不对,请检查后重新输入!");
|
|
|
pLabel->SetVisible(true);
|
|
pLabel->SetVisible(true);
|
|
|
|
|
|
|
|
return;
|
|
return;
|
|
@@ -336,17 +371,30 @@ void CShoukuanWnd::StartShoukuan()
|
|
|
|
|
|
|
|
m_fukuanma = ws_Fukuanma;
|
|
m_fukuanma = ws_Fukuanma;
|
|
|
|
|
|
|
|
- //开启一个线程,开始处理登录
|
|
|
|
|
|
|
+ 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(&CShoukuanWnd::HandleShoukuan, this).detach();
|
|
std::thread(&CShoukuanWnd::HandleShoukuan, this).detach();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void CShoukuanWnd::HandleShoukuan()
|
|
void CShoukuanWnd::HandleShoukuan()
|
|
|
{
|
|
{
|
|
|
- //生成随机的order_no
|
|
|
|
|
|
|
+ //鐢熸垚闅忔満鐨刼rder_no
|
|
|
|
|
|
|
|
std::map<string, string> params;
|
|
std::map<string, string> params;
|
|
|
|
|
|
|
|
params["order_no"] = CRandomHelper::GetRandString(20);
|
|
params["order_no"] = CRandomHelper::GetRandString(20);
|
|
|
|
|
+ m_order_no = params["order_no"];
|
|
|
|
|
+
|
|
|
params["yingshou_value"] = CLewaimaiString::UnicodeToUTF8(m_money);
|
|
params["yingshou_value"] = CLewaimaiString::UnicodeToUTF8(m_money);
|
|
|
params["shishou_value"] = CLewaimaiString::UnicodeToUTF8(m_money);
|
|
params["shishou_value"] = CLewaimaiString::UnicodeToUTF8(m_money);
|
|
|
params["zhaoling_value"] = to_string(0);
|
|
params["zhaoling_value"] = to_string(0);
|
|
@@ -355,6 +403,8 @@ void CShoukuanWnd::HandleShoukuan()
|
|
|
|
|
|
|
|
std::string response;
|
|
std::string response;
|
|
|
|
|
|
|
|
|
|
+ m_shoukuan_status = 1;
|
|
|
|
|
+
|
|
|
std::string url = "/shouyin/sendorder";
|
|
std::string url = "/shouyin/sendorder";
|
|
|
CZhipuziHttpClient::Request(url.c_str(), params, response);
|
|
CZhipuziHttpClient::Request(url.c_str(), params, response);
|
|
|
|
|
|
|
@@ -382,7 +432,90 @@ void CShoukuanWnd::HandleShoukuan()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
rapidjson::Value& data = document["data"];
|
|
rapidjson::Value& data = document["data"];
|
|
|
- rapidjson::Value& v_count = data["count"];
|
|
|
|
|
|
|
+ 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;
|
|
|
|
|
+
|
|
|
|
|
+ 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);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void CShoukuanWnd::HandleShoukuanPassword()
|
|
|
|
|
+{
|
|
|
|
|
+ std::map<string, string> params;
|
|
|
|
|
+
|
|
|
|
|
+ params["trade_no"] = m_trade_no;
|
|
|
|
|
+
|
|
|
|
|
+ while (m_shoukuan_status == 2)
|
|
|
|
|
+ {
|
|
|
|
|
+ std::string response;
|
|
|
|
|
+
|
|
|
|
|
+ std::string url = "/shouyin/queryorderstatus";
|
|
|
|
|
+ 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);
|
|
|
|
|
+
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ Sleep(1000);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void CShoukuanWnd::ShoukuanSuccess()
|
|
void CShoukuanWnd::ShoukuanSuccess()
|