张洋 преди 3 години
родител
ревизия
518b53638a
променени са 2 файла, в които са добавени 147 реда и са изтрити 1 реда
  1. 1 1
      bin/Win32/Debug/zhipuzi_pos_windows/skin/zhengcan_diandan_page.xml
  2. 146 0
      zhipuzi_pos_windows/zhipuzi/CZhengcanOrder.cpp

+ 1 - 1
bin/Win32/Debug/zhipuzi_pos_windows/skin/zhengcan_diandan_page.xml

@@ -4,7 +4,7 @@
 		<VerticalLayout name="page_layout">
 			<HorizontalLayout height="60" bkcolor="#FFFFFFFF">
 				<Button name="diandan_page_return" tooltip="返回" width="38" height="38" padding="10,11,0,0" normalimage="file='zhengcan_back.png'" hotimage="" pushedimage=""/>
-				<Label name="diandan_page_table_name" text="" font="28" textcolor="#FF1087FF" width="130" heiht="30" padding="10,10,10,10"></Label>
+				<Label name="diandan_page_table_name" text="" font="28" textcolor="#FF1087FF" width="300" heiht="30" padding="10,10,10,10"></Label>
 			</HorizontalLayout>
 			
 			<Control height="1" bkcolor="#FFEBE8E8"></Control>

+ 146 - 0
zhipuzi_pos_windows/zhipuzi/CZhengcanOrder.cpp

@@ -1,5 +1,6 @@
 #include "../pch/pch.h"
 #include "CZhengcanOrder.h"
+#include "../tool/CSqlite3.h"
 
 void CZhengcanOrder::RefreshDiandanInfo()
 {
@@ -68,11 +69,21 @@ double CZhengcanOrder::getTotalPrice()
 {
 	double total_price_show = 0;
 
+	//先计算当前已点的商品
 	for (std::vector<CZhengcanOrderItem>::iterator it = m_items.begin(); it != m_items.end(); it++)
 	{
 		total_price_show += std::stod((*it).show_price);
 	}
 
+	//再计算已下单商品
+	for (std::vector<CZhengcanOrderHistoryXiadan>::iterator it = m_order_history_array.begin(); it != m_order_history_array.end(); it++)
+	{
+		for (std::vector<CZhengcanOrderItem>::iterator it1 = it->m_items.begin(); it1 != it->m_items.end(); it1++)
+		{
+			total_price_show += std::stod((*it1).show_price);
+		}
+	}
+
 	return total_price_show;
 }
 
@@ -255,6 +266,32 @@ bool CZhengcanOrder::UseShangpinquan(std::string shangpinquan_food_id, double& y
 		}
 	}
 
+	//继续在已下单的订单里面找
+	for (std::vector<CZhengcanOrderHistoryXiadan>::iterator it = m_order_history_array.begin(); it != m_order_history_array.end(); it++)
+	{
+		for (std::vector<CZhengcanOrderItem>::iterator it1 = it->m_items.begin(); it1 != it->m_items.end(); it1++)
+		{
+			CZhengcanOrderItem curItem = *it1;
+
+			if (curItem.m_is_taocan == false && curItem.food_id == shangpinquan_food_id)
+			{
+				//找到了可以使用的商品
+				if (atof(curItem.num.c_str()) > 0.99999)
+				{
+					//如果当前份数大于1,那么抵扣价格就是商品单价
+					youhui_value = atof(curItem.price.c_str());
+				}
+				else
+				{
+					//如果当前份数不足1份,那么就抵扣价格就是单价乘以数量
+					youhui_value = atof(curItem.price.c_str()) * atof(curItem.num.c_str());
+				}
+
+				return true;
+			}
+		}
+	}
+
 	return false;
 }
 
@@ -305,6 +342,55 @@ bool CZhengcanOrder::UseCikaDikou(std::string cika_food_id, double& youhui_value
 		}
 	}
 
+	//继续在已下单的订单里面找
+	for (std::vector<CZhengcanOrderHistoryXiadan>::iterator it = m_order_history_array.begin(); it != m_order_history_array.end(); it++)
+	{
+		for (std::vector<CZhengcanOrderItem>::iterator it1 = it->m_items.begin(); it1 != it->m_items.end(); it1++)
+		{
+			CZhengcanOrderItem curItem = *it1;
+
+			if (curItem.m_is_taocan == false && curItem.food_id == cika_food_id)
+			{
+				//找到了可以使用的商品
+				if (is_shangpinquan_dikou)
+				{
+					if (atof(curItem.num.c_str()) > 1.99999)
+					{
+						//如果当前份数大于2,那么抵扣价格就是商品单价
+						youhui_value = atof(curItem.price.c_str());
+					}
+					else if (atof(curItem.num.c_str()) > 0.99999)
+					{
+						//如果当前份数不足2份,但是大于1份,那么就抵扣价格就是单价乘以数量
+						youhui_value = atof(curItem.price.c_str()) * (atof(curItem.num.c_str()) - 1);
+					}
+					else
+					{
+						//如果当前份数不足1份,那么已经被商品券抵扣了,次卡不再抵扣
+						youhui_value = 0;
+
+						return false;
+					}
+				}
+				else
+				{
+					if (atof(curItem.num.c_str()) > 0.99999)
+					{
+						//如果当前份数大于1,那么抵扣价格就是商品单价
+						youhui_value = atof(curItem.price.c_str());
+					}
+					else
+					{
+						//如果当前份数不足1份,那么就抵扣价格就是单价乘以数量
+						youhui_value = atof(curItem.price.c_str()) * atof(curItem.num.c_str());
+					}
+				}
+
+				return true;
+			}
+		}
+	}
+
 	return false;
 }
 
@@ -321,6 +407,19 @@ double CZhengcanOrder::getTotalMemberYouhui(std::string member_level)
 		total_youhui += item_youhui;
 	}
 
+	//继续在已下单的订单里面找
+	for (std::vector<CZhengcanOrderHistoryXiadan>::iterator it = m_order_history_array.begin(); it != m_order_history_array.end(); it++)
+	{
+		for (std::vector<CZhengcanOrderItem>::iterator it1 = it->m_items.begin(); it1 != it->m_items.end(); it1++)
+		{
+			CZhengcanOrderItem curItem = *it1;
+
+			double item_youhui = curItem.getMemberYouhui(member_level);
+
+			total_youhui += item_youhui;
+		}
+	}
+
 	return total_youhui;
 }
 
@@ -528,6 +627,53 @@ bool CZhengcanOrder::InitData(std::string order_id)
 			newItem.jiacai_no = CLewaimaiJson::ToString(foodinfo["jiacai_no"]);
 			newItem.is_tuicai = CLewaimaiJson::ToString(foodinfo["is_tuicai"]);
 
+			//从数据库里读这个商品的信息,获取会员价信息
+			CFood foodinfo_bendi;
+			CSqlite3 sqlite;
+			bool ret = sqlite.GetFoodById(newItem.food_id, foodinfo_bendi);
+			if (ret == true)
+			{
+				if (foodinfo_bendi.member_price_used == "1")
+				{
+					newItem.is_member_price_used = true;
+				}
+				else
+				{
+					newItem.is_member_price_used = false;
+				}
+
+				//处理会员价的json
+				std::string member_price_json = foodinfo_bendi.member_price_json;
+
+				rapidjson::Document document;
+				document.Parse(member_price_json.c_str());
+
+				rapidjson::Value& member_price = document;
+				for (rapidjson::SizeType i = 0; i < member_price.Size(); ++i)
+				{
+					rapidjson::Value& member_price_info = member_price[i];
+
+					MemberPrice newPirce;
+					newPirce.id = CLewaimaiJson::ToString(member_price_info["id"]);
+					newPirce.level = CLewaimaiJson::ToString(member_price_info["level"]);
+
+					if (member_price_info["price"].IsString())
+					{
+						newPirce.price = member_price_info["price"].GetString();
+					}
+					else
+					{
+						newPirce.price = to_string(member_price_info["price"].GetDouble());
+					}
+
+					newItem.m_member_price.push_back(newPirce);
+				}
+			}
+			else
+			{
+				newItem.is_member_price_used = false;
+			}
+
 			newItem.UpdateShowPrice();
 
 			newHistoryXiadan.m_items.push_back(newItem);