Kaynağa Gözat

明天再接着调试退款的

zhangyang 6 yıl önce
ebeveyn
işleme
3355cebf13

+ 72 - 0
bin/Win32/Debug/zhipuzi_pay_plugin/skin/tuikuan_wnd.xml

@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Window size="520,410" 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="3" name="微软雅黑" size="32" />
+	<VerticalLayout bkimage="tuikuan_bkg.png" >
+		<HorizontalLayout name="tuikuan_title_bkg" height="44" bkcolor="0xFF3CB371">
+			<Label name="tuikuan_version" text="退款" height="44" align="center" valign="center" padding="0,0,0,0" textcolor="#FFFFFFFF" font="2"/>
+		</HorizontalLayout>
+		
+		<VerticalLayout visible="true" name="tuikuan_before_pay_layout" height="290" padding="0,20,0,0">
+			<HorizontalLayout name="tuikuan_money_input_layout" height="60" padding="0,15,0,0">
+				<Label height="40" padding="190,20,0,10" name="tuikuan_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"/>
+			</HorizontalLayout>
+			
+			<HorizontalLayout name="tuikuan_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="tuikuan_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="tuikuanma_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">
+				<Control></Control>
+				<Button name="tuikuanBtn" 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></Control>
+			</HorizontalLayout>	
+
+			<HorizontalLayout height="50" padding="0,20,0,0">
+				<Control></Control>
+				<Label name="tuikuanresult" font="2" width="400" height="50" multiline="true" text="" visible="false" textcolor="#FF0000" align="center" />
+				<Control></Control>
+			</HorizontalLayout>			
+		</VerticalLayout>
+		
+		<VerticalLayout name="tuikuan_pay_success_layout" visible="false">
+			<HorizontalLayout name="tuikuan_pay_success_logo_wx" height="100" padding="0,20,0,0" visible="false">
+				<Control></Control>
+				<Control bkimage="wx_logo.png" width="100" height="100" align="center"></Control>
+				<Control></Control>
+			</HorizontalLayout>
+			
+			<HorizontalLayout name="tuikuan_pay_success_logo_zhifubao" height="100" padding="0,20,0,0" visible="false">
+				<Control></Control>
+				<Control bkimage="zhifubao_logo.png"  width="100" height="100" align="center"></Control>
+				<Control></Control>
+			</HorizontalLayout>
+			
+			<Label height="40" padding="0,20,0,20" name="tuikuan_pay_success_money" text="成功收款:" font="3" textcolor="0xFF3CB371" align="center"></Label>
+			
+			<Label height="60" padding="20,30,20,0" name="shouyin_pay_success_attention" text="按任意键关闭窗口" font="2" textcolor="0xFF808080" multiline="true" align="center" />
+		</VerticalLayout>
+		
+		<VerticalLayout name="tuikuan_pay_fail_layout" visible="false">
+			<HorizontalLayout height="100" padding="0,20,0,0">
+				<Control></Control>
+				<Control bkimage="pay_fail.png" width="100" height="100" align="center"></Control>
+				<Control></Control>
+			</HorizontalLayout>
+			
+			<Label height="40" padding="0,20,0,20" name="tuikuan_pay_fail_money" text="订单支付失败" font="3" textcolor="0xFFD33E3A" align="center"></Label>
+			
+			<Label height="60" padding="20,30,20,0" name="shouyin_pay_fail_attention" text="" font="2" textcolor="0xFF808080" multiline="true" align="center" />
+		</VerticalLayout>
+    </VerticalLayout>
+</Window>

BIN
bin/Win32/Debug/zhipuzi_pay_plugin/zpzDll.dll


BIN
lib/debug/zpzDll.lib


+ 4 - 0
zhipuzi_pay_plugin/wnd/CMenuWnd.cpp

@@ -43,6 +43,10 @@ void CMenuWnd::Notify(TNotifyUI& msg)
 		{
 			m_valueWnd->ShowShoukuan();
 		}
+		else if (name == L"value_menu_tuikuan")
+		{
+			m_valueWnd->ShowTuikuan();
+		}
 	}
 }
 

+ 611 - 0
zhipuzi_pay_plugin/wnd/CTuikuanWnd.cpp

@@ -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);
+	}
+}
+

+ 91 - 0
zhipuzi_pay_plugin/wnd/CTuikuanWnd.h

@@ -0,0 +1,91 @@
+#pragma once
+
+#include "../pch/pch.h"
+
+class CTuikuanWnd : public CWindowWnd, public INotifyUI, public IMessageFilterUI
+{
+public:
+	CTuikuanWnd()
+	{
+
+	}
+
+	LPCTSTR GetWindowClassName() const
+	{
+		return _T("UITuikuanFrame");
+	};
+
+	UINT GetClassStyle() const
+	{
+		return UI_CLASSSTYLE_DIALOG;
+	};
+
+	void OnFinalMessage(HWND /*hWnd*/)
+	{
+		//m_pm.RemovePreMessageFilter(this);
+		delete this;
+	};
+
+	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 OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+
+	LRESULT OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+
+	LRESULT OnTuikuanSuccess(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+
+	LRESULT OnTuikuanFail(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 InitMoney(std::wstring value);
+
+	void UpdateFocus();
+
+	//点击确认,开始执行收款
+	void StartTuikuan();
+
+	//处理收款
+	void HandleTuikuan();
+
+public:
+	CPaintManagerUI m_pm;
+
+	bool m_is_money_init = false;
+	std::wstring m_money;
+
+	std::wstring m_tuikuanma;
+	int m_tuikuanma_type; //付款码类型 1:微信支付 2:支付宝 3:其他的
+
+	//收款状态 0:未开始 1:请求发给服务器了,但是暂时还没得到反馈 2:查询密码中 3:成功 4:失败 5:正在取消支付
+	int m_shoukuan_status = 0;
+
+	std::string m_order_no;
+	std::string m_trade_no;
+
+	std::string m_fail_message;
+
+	//窗口关闭的定时器时间
+	int m_timer_now = 3;
+};
+

+ 45 - 0
zhipuzi_pay_plugin/wnd/CValueWnd.cpp

@@ -607,6 +607,51 @@ void CValueWnd::ShowShoukuan()
 	}
 }
 
+void CValueWnd::ShowTuikuan()
+{
+	if (m_is_show_tuikuan == true)
+	{
+		return;
+	}
+
+	pMenu->ShowWindow(false);
+
+	CTuikuanWnd* pTuikuanWnd = new CTuikuanWnd;
+	if (pTuikuanWnd != NULL)
+	{
+		pTuikuanWnd->Create(NULL, _T(""), UI_WNDSTYLE_DIALOG, WS_EX_TOOLWINDOW);
+		pTuikuanWnd->SetIcon(IDI_ICON_DUILIB);
+		pTuikuanWnd->CenterWindow();
+		::SetWindowPos(pTuikuanWnd->GetHWND(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
+
+		m_is_show_tuikuan = true;
+		m_tuikuanWnd = pTuikuanWnd;
+		m_tuikuanHWND = pTuikuanWnd->GetHWND();
+
+		//只要金额不为0,就初始化
+		if (false)
+		{
+			std::string format_string = CLewaimaiString::DoubleToString(atof(utf8_watch_value.c_str()), 2);
+			m_watchValue = CLewaimaiString::UTF8ToUnicode(format_string);
+			pTuikuanWnd->InitMoney(m_watchValue);
+		}
+
+		UINT ret = pTuikuanWnd->ShowModal();
+
+		m_is_show_tuikuan = false;
+		m_tuikuanWnd = NULL;
+		m_tuikuanHWND = NULL;
+
+		if (ret == IDOK)
+		{
+
+		}
+		else if (ret == IDCANCEL)
+		{
+		}
+	}
+}
+
 void CValueWnd::AddTrayIcon()
 {
     memset(&m_trayIcon, 0, sizeof(NOTIFYICONDATA));

+ 8 - 0
zhipuzi_pay_plugin/wnd/CValueWnd.h

@@ -61,6 +61,9 @@ public:
 	//显示收款界面
 	void ShowShoukuan();
 
+	//显示退款界面
+	void ShowTuikuan();
+
 	//添加托盘图标(初始化)
 	void AddTrayIcon();
 
@@ -120,6 +123,11 @@ private:
 	CShoukuanWnd* m_shoukuanWnd = NULL;
 	HWND m_shoukuanHWND = NULL;
 
+	//退款窗口的参数
+	bool m_is_show_tuikuan = false;
+	CShoukuanWnd* m_tuikuanWnd = NULL;
+	HWND m_tuikuanHWND = NULL;
+
 	//设置窗口是否已经展示
 	bool m_is_show_setting = false;
 	CSystemSettingWnd* m_settingWnd;

+ 2 - 0
zhipuzi_pay_plugin/zhipuzi_pay_plugin.vcxproj

@@ -224,6 +224,7 @@ copy $(ProjectDir)conf\ $(SolutionDir)bin\$(Platform)\$(Configuration)\conf\</Co
   </ItemDefinitionGroup>
   <ItemGroup>
     <ClInclude Include="control\CMenuItemUI.h" />
+    <ClInclude Include="wnd\CTuikuanWnd.h" />
     <ClInclude Include="helper\CSpeech.h" />
     <ClInclude Include="wnd\CShoukuanWnd.h" />
     <ClInclude Include="helper\CBitmapHelper.h" />
@@ -268,6 +269,7 @@ copy $(ProjectDir)conf\ $(SolutionDir)bin\$(Platform)\$(Configuration)\conf\</Co
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="control\CMenuItemUI.cpp" />
+    <ClCompile Include="wnd\CTuikuanWnd.cpp" />
     <ClCompile Include="helper\CSpeech.cpp" />
     <ClCompile Include="wnd\CShoukuanWnd.cpp" />
     <ClCompile Include="helper\CBitmapHelper.cpp" />

+ 6 - 0
zhipuzi_pay_plugin/zhipuzi_pay_plugin.vcxproj.filters

@@ -141,6 +141,9 @@
     <ClInclude Include="helper\CSpeech.h">
       <Filter>头文件</Filter>
     </ClInclude>
+    <ClInclude Include="wnd\CTuikuanWnd.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="pch\pch.cpp">
@@ -260,6 +263,9 @@
     <ClCompile Include="helper\CSpeech.cpp">
       <Filter>源文件</Filter>
     </ClCompile>
+    <ClCompile Include="wnd\CTuikuanWnd.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <Image Include="resource\zhipuzi.ico">