Browse Source

微信支付的优化

zhangyang 4 years ago
parent
commit
f944b91e74

BIN
bin/Win32/Debug/zhipuzi_pos_windows/dump/2021-11-27-00-50-39.dmp


BIN
bin/Win32/Debug/zhipuzi_pos_windows/skin/qrcode_attention.png


+ 17 - 25
bin/Win32/Debug/zhipuzi_pos_windows/skin/weixinzhifu_shoukuan_wnd.xml

@@ -1,38 +1,30 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<Window size="520,410" caption="0,0,0,44" roundcorner="4,4" >
+<Window size="620,544" caption="0,0,0,44" roundcorner="4,4" >
 	<Font id="0" name="微软雅黑" size="24" />
 	<Font id="1" name="微软雅黑" size="40" />
-	<Font id="2" name="微软雅黑" size="18" />
+	<Font id="2" name="微软雅黑" size="20" />
 	<Font id="3" name="微软雅黑" size="32" />
 	<VerticalLayout bkimage="shoukuan_bkg.png" >
 		<HorizontalLayout name="shoukuan_title_bkg" height="44" bkcolor="0xFF3CB371">
 			<Label name="shoukuan_version" text="收款" height="44" align="center" valign="center" padding="0,0,0,0" textcolor="#FFFFFFFF" font="2"/>
+			<Button name="closebtn" padding="0,13,15,0" width="16" height="16" tooltip="关闭" normalimage="file='close_normal.png'" hotimage="file='close_hover.png'" pushedimage="file='close_normal.png'"/>
 		</HorizontalLayout>
 		
-		<VerticalLayout visible="true" name="shoukuan_before_pay_layout" height="290" padding="0,20,0,0">
-			<HorizontalLayout name="shoukuan_money_input_layout" height="60" padding="0,15,0,0">
-				<Label height="40" padding="190,20,0,10" name="shoukuan_before_pay_huobi" text="¥" font="0" textcolor="0xFF3CB371"></Label>
-				<Edit name="money_edit" float="true" pos="223,0,400,60" font="1" textcolor="0xFF3CB371" bkcolor="0xFFFCFCFC" nativebkcolor="0xFFFCFCFC"/>
+		<VerticalLayout visible="true" name="shoukuan_before_pay_layout" height="500" padding="0,20,0,0">			
+			<HorizontalLayout name="shoukuan_money_show_layout" height="50" padding="0,15,0,15">
+				<Label text="¥" font="0" textcolor="0xFF3CB371" float="true" pos="250,24,265,50"/>
+				<Label name="shoukuan_money_show_money" font="1" textcolor="0xFF3CB371" float="true" pos="275,12,550,48"/>
 			</HorizontalLayout>
 			
-			<HorizontalLayout name="shoukuan_money_show_layout" height="50" padding="0,15,0,15" visible="false">
-				<Label text="¥" font="0" textcolor="0xFF3CB371" float="true" pos="200,24,215,50"/>
-				<Label name="shoukuan_money_show_money" font="1" textcolor="0xFF3CB371" float="true" pos="225,12,500,48"/>
-			</HorizontalLayout>
-			
-			<HorizontalLayout height="50" padding="0,15,0,0">
-				<Label text="付款码:" font="2" float="true" pos="100,12,180,40"/>
-				<Edit name="fukuanma_edit" float="true" pos="183,12,400,48" normalimage="file='Chat_InputBox_BG.png' corner='4,4,4,4'" hotimage="file='Chat_InputBox_BG_Hover.png' corner='4,4,4,4'" />
-			</HorizontalLayout>
-			
-			<HorizontalLayout height="60" padding="0,30,0,0">
+			<HorizontalLayout padding="0,20,0,0" height="129">
 				<Control></Control>
-				<Button name="shoukuanBtn" text="确认" font="2" textcolor="#FFFFFFFF" height="50" width="150" padding="0,0,0,0" tooltip="点击这里确认收款" normalimage="file='Btn_Green.png' corner='5,5,5,5'" hotimage="file='Btn_Green_Hover.png' corner='5,5,5,5'" pushedimage="file='Btn_Green_Click.png' corner='5,5,5,5'" />
-				<Button name="closebtn" text="关闭" font="2" textcolor="#FFFFFFFF" height="50" width="150" padding="20,0,0,0" tooltip="点击这里取消收款" normalimage="file='Btn_Red.png' corner='5,5,5,5'" hotimage="file='Btn_Red_Hover.png' corner='5,5,5,5'" pushedimage="file='Btn_Red_Click.png' corner='5,5,5,5'" />
+				<Control bkimage="qrcode_attention.png" width="129" height="127"></Control>
 				<Control></Control>
-			</HorizontalLayout>	
+			</HorizontalLayout>
+			
+			<Label text="请扫描顾客付款二维码" align="center" padding="0,30,0,0" height="40" font="0"></Label>
 
-			<HorizontalLayout height="50" padding="0,20,0,0">
+			<HorizontalLayout height="50" padding="0,30,0,0">
 				<Control></Control>
 				<Label name="shoukuanresult" font="2" width="400" height="50" multiline="true" text="" visible="false" textcolor="#FF0000" align="center" />
 				<Control></Control>
@@ -54,19 +46,19 @@
 			
 			<Label height="40" padding="0,10,0,10" name="shoukuan_paying_money" text="收款金额:" font="3" textcolor="0xFF3CB371" align="center"></Label>
 			
-			<Label height="32" padding="0,10,0,10" name="shoukuan_paying_status" text="请求支付中..." font="2" textcolor="0xFF3CB371" align="center"></Label>
+			<Label height="32" padding="0,20,0,10" name="shoukuan_paying_status" text="请求支付中..." font="2" textcolor="0xFF3CB371" align="center"></Label>
 			
 			<Label height="60" padding="20,30,20,0" name="shouyin_paying_attention" text="如果用户没有支付成功,则请确认客户不再进行支付时再关闭此窗口,按【Esc】取消本次支付" font="2" textcolor="0xFF808080" multiline="true" align="center" />
 		</VerticalLayout>
 		
 		<VerticalLayout name="shoukuan_pay_success_layout" visible="false">
-			<HorizontalLayout name="shoukuan_pay_success_logo_wx" height="100" padding="0,20,0,0" visible="false">
+			<HorizontalLayout name="shoukuan_pay_success_logo_wx" height="100" padding="0,40,0,0" visible="false">
 				<Control></Control>
 				<Control bkimage="wx_logo.png" width="100" height="100" align="center"></Control>
 				<Control></Control>
 			</HorizontalLayout>
 			
-			<HorizontalLayout name="shoukuan_pay_success_logo_zhifubao" height="100" padding="0,20,0,0" visible="false">
+			<HorizontalLayout name="shoukuan_pay_success_logo_zhifubao" height="100" padding="0,40,0,0" visible="false">
 				<Control></Control>
 				<Control bkimage="zhifubao_logo.png"  width="100" height="100" align="center"></Control>
 				<Control></Control>
@@ -78,7 +70,7 @@
 		</VerticalLayout>
 		
 		<VerticalLayout name="shoukuan_pay_fail_layout" visible="false">
-			<HorizontalLayout height="100" padding="0,20,0,0">
+			<HorizontalLayout height="100" padding="0,40,0,0">
 				<Control></Control>
 				<Control bkimage="pay_fail.png" width="100" height="100" align="center"></Control>
 				<Control></Control>

+ 20 - 106
zhipuzi_pos_windows/wnd/CWeixinzhifuShoukuanWnd.cpp

@@ -21,10 +21,6 @@ void CWeixinzhifuShoukuanWnd::Notify(TNotifyUI& msg)
 			Close(IDCANCEL);
 			return;
 		}
-		else if (msg.pSender->GetName() == _T("shoukuanBtn"))
-		{
-			StartShoukuan();
-		}
 	}
 }
 
@@ -266,7 +262,7 @@ LRESULT CWeixinzhifuShoukuanWnd::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM
 		{
 			if (m_shoukuan_status == 0)
 			{
-				StartShoukuan();
+				
 			}
 			else if (m_shoukuan_status == 1 || m_shoukuan_status == 2 || m_shoukuan_status == 5)
 			{
@@ -331,41 +327,20 @@ LRESULT CWeixinzhifuShoukuanWnd::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM
 
 void CWeixinzhifuShoukuanWnd::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 CWeixinzhifuShoukuanWnd::InitFukuanma(std::string fukuanma)
 {
-	std::wstring ws_fukuanma = CLewaimaiString::UTF8ToUnicode(fukuanma);
-
-	CLabelUI* pFukuanmaLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("fukuanma_edit")));
-	if (pFukuanmaLabel)
-	{
-		pFukuanmaLabel->SetText(ws_fukuanma.c_str());
-	}
+	m_fukuanma = fukuanma;
 
-	std::string shoukuan_setting_mianqueren = CSetting::GetParam("shoukuan_setting_mianqueren");
-	if (shoukuan_setting_mianqueren == "1")
-	{
-		if (m_is_money_init)
-		{
-			//如果金额也是初始化好的,可以直接支付了
-			this->StartShoukuan();
-		}
-	}
+	this->StartShoukuan();
 }
 
 void CWeixinzhifuShoukuanWnd::SetCommonParams(std::map<string, string> params)
@@ -375,25 +350,7 @@ void CWeixinzhifuShoukuanWnd::SetCommonParams(std::map<string, string> params)
 
 void CWeixinzhifuShoukuanWnd::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("fukuanma_edit")));
-
-		pFukuanEdit->SetFocus();
-	}
+	
 }
 
 LRESULT CWeixinzhifuShoukuanWnd::OnShoukuanNeedPassword(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
@@ -417,20 +374,11 @@ LRESULT CWeixinzhifuShoukuanWnd::OnShoukuanNeedPassword(UINT uMsg, WPARAM wParam
 
 LRESULT CWeixinzhifuShoukuanWnd::OnShoukuanSuccess(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
 {
-	//判断是否要打印
-	/*
-	int dayinji_setting_auto_print = atoi(CSetting::GetParam("system_setting_dayinji_setting_auto_print").c_str());
-	if (dayinji_setting_auto_print == 1)
-	{
-		m_valueWnd->PrintZhifu(m_out_trade_no);
-	}
-	}*/
-
 	//播放收款成功的金额
-	//if (CSetting::GetParam("shoukuan_setting_yuyinbobao") == "1")
-	//{
+	if (CSetting::GetParam("setting_is_new_diannei_voice") == "1")
+	{
 		std::thread(&CWeixinzhifuShoukuanWnd::ReadShoukuanValue, this).detach();
-	//}
+	}
 
 	CVerticalLayoutUI* paying_layout = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("shoukuan_paying_layout")));
 	paying_layout->SetVisible(false);
@@ -472,10 +420,10 @@ LRESULT CWeixinzhifuShoukuanWnd::OnShoukuanFail(UINT uMsg, WPARAM wParam, LPARAM
 {
 	wstring path = CSystem::GetProgramDir() + L"\\music\\pay_fail.wav";
 
-	//if (CSetting::GetParam("shoukuan_setting_yuyinbobao") == "1")
-	//{
+	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);
@@ -505,42 +453,8 @@ void CWeixinzhifuShoukuanWnd::StartShoukuan()
 {
 	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("fukuanma_edit")));
-	std::wstring ws_Fukuanma = pFukuanmaEdit->GetText();
-	std::string s_Fukuanma = CLewaimaiString::UnicodeToUTF8(ws_Fukuanma);
+	std::string s_Fukuanma = m_fukuanma;
 
 	int length = s_Fukuanma.size();
 	if (length != 18 && length != 19)
@@ -597,8 +511,6 @@ void CWeixinzhifuShoukuanWnd::StartShoukuan()
 		return;
 	}
 
-	m_fukuanma = ws_Fukuanma;
-
 	//全部验证通过,就可以开始修改状态了
 	m_shoukuan_status = 1;
 
@@ -616,7 +528,7 @@ void CWeixinzhifuShoukuanWnd::StartShoukuan()
 	std::wstring valueInfo = L"付款金额:¥" + m_money;
 	pMoneyPaying->SetText(valueInfo.c_str());
 
-	//开启一个线程,开始处理登录
+	//开启一个线程,开始处理收款
 	std::thread(&CWeixinzhifuShoukuanWnd::HandleShoukuan, this).detach();
 }
 
@@ -625,7 +537,7 @@ void CWeixinzhifuShoukuanWnd::HandleShoukuan()
 	//生成随机的order_no
 
 	m_commonParams["zhifu_type"] = to_string(7);
-	m_commonParams["zhifu_code"] = CLewaimaiString::UnicodeToUTF8(m_fukuanma);
+	m_commonParams["zhifu_code"] = m_fukuanma;
 
 	std::string response;
 
@@ -707,7 +619,7 @@ void CWeixinzhifuShoukuanWnd::HandleShoukuan()
 		m_take_food_code = data["take_food_code"].GetString();
 		m_show_trade_no = data["show_trade_no"].GetString();
 
-		m_out_trade_no = data["trade_no"].GetString();
+		m_trade_no = data["trade_no"].GetString();
 
 		SendMessage(WM_SHOUKUAN_STATUS_SUCCESS, 0, 0);
 	}
@@ -724,7 +636,7 @@ void CWeixinzhifuShoukuanWnd::HandleShoukuan()
 	{
 		m_shoukuan_status = 2;
 
-		m_out_trade_no = data["out_trade_no"].GetString();
+		m_trade_no = data["trade_no"].GetString();
 
 		//需要查询支付状态
 		SendMessage(WM_SHOUKUAN_STATUS_NEEDPASSWORD, 0, 0);
@@ -743,7 +655,7 @@ void CWeixinzhifuShoukuanWnd::HandleShoukuanPassword()
 {
 	std::map<string, string> params;
 
-	params["trade_no"] = m_out_trade_no;
+	params["trade_no"] = m_trade_no;
 
 	while (m_shoukuan_status == 2)
 	{
@@ -815,7 +727,7 @@ void CWeixinzhifuShoukuanWnd::HandleShoukuanPassword()
 			m_take_food_code = data["take_food_code"].GetString();
 			m_show_trade_no = data["show_trade_no"].GetString();
 
-			m_out_trade_no = data["out_trade_no"].GetString();
+			m_trade_no = data["trade_no"].GetString();
 
 			SendMessage(WM_SHOUKUAN_STATUS_SUCCESS, 0, 0);
 
@@ -860,7 +772,7 @@ void CWeixinzhifuShoukuanWnd::HandleCancelShoukuan()
 {
 	std::map<string, string> params;
 
-	params["trade_no"] = m_out_trade_no;
+	params["trade_no"] = m_trade_no;
 
 	std::string response;
 
@@ -953,5 +865,7 @@ void CWeixinzhifuShoukuanWnd::ReadShoukuanValue()
 //处理键盘捕捉结果
 void CWeixinzhifuShoukuanWnd::HandleTextCapture(std::string content)
 {
+	m_fukuanma = content;
 
+	StartShoukuan();
 }

+ 4 - 4
zhipuzi_pos_windows/wnd/CWeixinzhifuShoukuanWnd.h

@@ -94,10 +94,10 @@ public:
 public:
 	CPaintManagerUI m_pm;
 
-	bool m_is_money_init = false;
+	//金额是否初始化
 	std::wstring m_money;
 
-	std::wstring m_fukuanma;
+	std::string m_fukuanma;
 	int m_fukuanma_type; //付款码类型 1:微信支付 2:支付宝 3:其他的
 
 
@@ -107,13 +107,13 @@ public:
 	std::wstring m_fail_message;
 
 	//窗口关闭的定时器时间
-	int m_timer_now = 4;
+	int m_timer_now = 3;
 
 	std::map<string, string> m_commonParams;
 
 	//支付成功返回的字段
 	std::string m_kucun_string;
-	std::string m_out_trade_no;
+	std::string m_trade_no;
 	std::string m_take_food_code;
 	std::string m_show_trade_no;
 };