ソースを参照

修复打印的一个bug

zhangyang 6 年 前
コミット
d62f115f58

BIN
bin/Win32/Debug/lewaimai_pos_windows/db/pos.db


BIN
bin/Win32/Debug/lewaimai_pos_windows/lewaimai_pos_windows.exe


+ 2 - 0
bin/Win32/Debug/lewaimai_pos_windows/skin/waimaiorder_info.xml

@@ -79,6 +79,8 @@
 				
 				<Button name="waimai_order_info_page_agree" float="true" pos="50,108,200,146" text="同意退款" textcolor="#FFFF0FFFF" />
 				<Button name="waimai_order_info_page_disagree" float="true" pos="50,156,200,192" text="拒绝退款" textcolor="#FFFFFFFF" 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'" />
+				
+				<Button name="waimai_order_info_page_refund" float="true" pos="50,108,200,146" text="退款" textcolor="#FFFFFFFF" 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'" />
 			</HorizontalLayout>
 		</HorizontalLayout>
 	</WaimaiOrderInfo>

+ 49 - 14
lewaimai_pos_windows/control/CWaimaiOrderInfoUI.cpp

@@ -326,6 +326,8 @@ void CWaimaiOrderInfoUI::Refresh(CWaimaiOrder& order)
 	CButtonUI* agree_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_agree")));
 	CButtonUI* disagree_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_disagree")));
 
+	CButtonUI* refund_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_refund")));
+
 	CLabelUI *pRefundStatus = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_refund_status")));
 
 	int refundHeight = 0;
@@ -338,6 +340,8 @@ void CWaimaiOrderInfoUI::Refresh(CWaimaiOrder& order)
 		agree_button->SetVisible(false);
 		disagree_button->SetVisible(false);
 
+		refund_button->SetVisible(false);
+
 		pRefundStatus->SetVisible(false);
 	}
 	else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("已确认")) == 0)
@@ -349,6 +353,8 @@ void CWaimaiOrderInfoUI::Refresh(CWaimaiOrder& order)
 		agree_button->SetVisible(false);
 		disagree_button->SetVisible(false);
 
+		refund_button->SetVisible(false);
+
 		pRefundStatus->SetVisible(false);
 	}
 	else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("交易成功")) == 0)
@@ -360,6 +366,8 @@ void CWaimaiOrderInfoUI::Refresh(CWaimaiOrder& order)
 		agree_button->SetVisible(false);
 		disagree_button->SetVisible(false);
 
+		refund_button->SetVisible(false);
+
 		pRefundStatus->SetVisible(false);
 	}
 	else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("交易失败")) == 0)
@@ -371,7 +379,43 @@ void CWaimaiOrderInfoUI::Refresh(CWaimaiOrder& order)
 		agree_button->SetVisible(false);
 		disagree_button->SetVisible(false);
 
-		pRefundStatus->SetVisible(false);
+		std::string refund_status = m_order.m_refund_status;
+
+		if (CLewaimaiString::UTF8ToUnicode(order.m_pay_type) != L"货到付款")
+		{
+			pRefundStatus->SetVisible(true);
+			refundHeight = 30;
+
+			std::wstring refund_status_text = L"退款状态:";
+			if (refund_status == "0")
+			{
+				refund_button->SetVisible(true);
+				refund_status_text += L"未处理";
+			}
+			else if (refund_status == "10")
+			{
+				refund_button->SetVisible(false);
+				refund_status_text += L"退款处理中,等待退款结果";
+			}
+			else if (refund_status == "11")
+			{
+				refund_button->SetVisible(false);
+				refund_status_text += L"退款已完成";
+			}
+			else if (refund_status == "12")
+			{
+				refund_button->SetVisible(false);
+				refund_status_text += L"退款失败,原因:" + CLewaimaiString::UTF8ToUnicode(order.m_refund_failed_reason);
+			}
+
+			pRefundStatus->SetText(refund_status_text.c_str());
+		}
+		else
+		{
+			refund_button->SetVisible(false);
+
+			pRefundStatus->SetVisible(false);
+		}		
 	}
 	else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("已取消")) == 0)
 	{
@@ -382,6 +426,8 @@ void CWaimaiOrderInfoUI::Refresh(CWaimaiOrder& order)
 		agree_button->SetVisible(false);
 		disagree_button->SetVisible(false);
 
+		refund_button->SetVisible(false);
+
 		pRefundStatus->SetVisible(false);
 	}
 	else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("退款中")) == 0)
@@ -407,8 +453,9 @@ void CWaimaiOrderInfoUI::Refresh(CWaimaiOrder& order)
 			disagree_button->SetVisible(false);
 		}
 
-		pRefundStatus->SetVisible(true);
+		refund_button->SetVisible(false);
 
+		pRefundStatus->SetVisible(true);
 		refundHeight = 30;
 
 		std::wstring refund_status_text = L"退款状态:";
@@ -432,18 +479,6 @@ void CWaimaiOrderInfoUI::Refresh(CWaimaiOrder& order)
 		{
 			refund_status_text += L"顾客再次发起退款,等待客服介入处理中";
 		}
-		else if (refund_status == "10")
-		{
-			refund_status_text += L"退款处理中,等待退款结果";
-		}
-		else if (refund_status == "11")
-		{
-			refund_status_text += L"退款已完成";
-		}
-		else if (refund_status == "12")
-		{
-			refund_status_text += L"退款失败,原因:" + CLewaimaiString::UTF8ToUnicode(order.m_refund_failed_reason);
-		}
 
 		pRefundStatus->SetText(refund_status_text.c_str());
 	}

+ 47 - 5
lewaimai_pos_windows/order/CWaimaiOrder.cpp

@@ -238,7 +238,7 @@ bool CWaimaiOrder::SuccessOrder(std::string order_id)
 
 bool CWaimaiOrder::FailOrder(std::string order_id, std::string reason)
 {
-	std::string url = "/waimaiorder/orderfail";
+	std::string url = "/order/orderfail";
 
 	//请求外卖的未处理订单
 	std::map<string, string> params;
@@ -315,8 +315,8 @@ bool CWaimaiOrder::AgreeRefund(std::string order_id)
 
 	//获得数据成功
 	rapidjson::Value& data = document["data"];
-	rapidjson::Value& v_count = data["count"];
-	string count = v_count.GetString();
+
+	order_id = data["order_id"].GetString();
 
 	return true;
 }
@@ -357,8 +357,50 @@ bool CWaimaiOrder::DisagreeRefund(std::string order_id)
 
 	//获得数据成功
 	rapidjson::Value& data = document["data"];
-	rapidjson::Value& v_count = data["count"];
-	string count = v_count.GetString();
+	
+	order_id = data["order_id"].GetString();
+
+	return true;
+}
+
+bool CWaimaiOrder::Refund(std::string order_id)
+{
+	std::string url = "/order/lewaimairefund";
+
+	//请求外卖的未处理订单
+	std::map<string, string> params;
+	params["order_id"] = order_id;
+	std::string response;
+
+	CLewaimaiHttpClient::Request(url.c_str(), params, response);
+
+	rapidjson::Document document;
+	document.Parse(response.c_str());
+
+	if (document.HasParseError())
+	{
+		LOG_INFO("parse response error!");
+		return false;
+	}
+
+	if (!document.HasMember("errcode") || !document.HasMember("errmsg") || !document.HasMember("data"))
+	{
+		LOG_INFO("json error!");
+		return false;
+	}
+
+	rapidjson::Value& v_errcode = document["errcode"];
+	int errcode = v_errcode.GetInt();
+	if (errcode != 0)
+	{
+		LOG_INFO("response failed! message:" << document["errmsg"].GetString());
+		return false;
+	}
+
+	//获得数据成功
+	rapidjson::Value& data = document["data"];
+	
+	order_id = data["order_id"].GetString();
 
 	return true;
 }

+ 2 - 0
lewaimai_pos_windows/order/CWaimaiOrder.h

@@ -36,6 +36,8 @@ public:
 	bool AgreeRefund(std::string order_id);
 	bool DisagreeRefund(std::string order_id);
 
+	bool Refund(std::string order_id);
+
 public:
 	std::string m_order_id;
 	std::string m_shop_id;

+ 28 - 6
lewaimai_pos_windows/tool/CPosPrinter.cpp

@@ -220,9 +220,20 @@ void CPosPrinter::PrintWaimaiOrderShouyin(CWaimaiOrder& order)
             }
 
             std::string firstLine = m_names[0];
-            std::string priceShow = HandleFoodItemPrice(food_price, 2);
-            std::string quantityShow = HandleFoodQuantity(quantity, 2);
-            std::string priceTotalShow = HandleFoodTotalPrice(food_total_price, 2);
+
+			int nGuige;
+			if (guige == "58")
+			{
+				nGuige = 1;
+			}
+			else
+			{
+				nGuige = 2;
+			}
+
+            std::string priceShow = HandleFoodItemPrice(food_price, nGuige);
+            std::string quantityShow = HandleFoodQuantity(quantity, nGuige);
+            std::string priceTotalShow = HandleFoodTotalPrice(food_total_price, nGuige);
 
             std::string firstLineShow = firstLine + priceShow + quantityShow + priceTotalShow;
 
@@ -467,9 +478,20 @@ void CPosPrinter::PrintWaimaiOrderChufang(CWaimaiOrder& order)
                 }
 
                 std::string firstLine = m_names[0];
-                std::string priceShow = HandleFoodItemPrice(food_price, 2);
-                std::string quantityShow = HandleFoodQuantity(quantity, 2);
-                std::string priceTotalShow = HandleFoodTotalPrice(food_total_price, 2);
+                
+				int nGuige;
+				if (guige == "58")
+				{
+					nGuige = 1;
+				}
+				else
+				{
+					nGuige = 2;
+				}
+
+				std::string priceShow = HandleFoodItemPrice(food_price, nGuige);
+				std::string quantityShow = HandleFoodQuantity(quantity, nGuige);
+				std::string priceTotalShow = HandleFoodTotalPrice(food_total_price, nGuige);
 
                 std::string firstLineShow = firstLine + priceShow + quantityShow + priceTotalShow;
 

+ 23 - 0
lewaimai_pos_windows/wnd/CMainWnd.cpp

@@ -427,6 +427,29 @@ void CMainWnd::HandleClickMsg(TNotifyUI& msg)
         }
     }
 
+	else if (name == _T("waimai_order_info_page_refund"))
+	{
+		CWaimaiOrderInfoUI* order_info_page = static_cast<CWaimaiOrderInfoUI*>(m_pm.FindControl(_T("waimaiorder_info_page")));
+
+		std::string waimai_order_id = order_info_page->m_order.m_order_id;
+		std::string waimai_order_no = order_info_page->m_order.m_order_no;
+
+		CWaimaiOrder order;
+		bool ret = order.Refund(waimai_order_id);
+
+		if (ret)
+		{
+			//订单设为成功,这里怎么处理
+			//请求服务器,获取订单数据
+			CWaimaiOrder new_order;
+			new_order.InitData(waimai_order_id, waimai_order_no);
+
+			//刷新订单详情页数据
+			order_info_page->SetDate(new_order);
+			order_info_page->Refresh(new_order);
+		}
+	}
+
     //开始处理设置页面的
     else if(name == _T("setting_is_new_waimai_voice"))
     {