Przeglądaj źródła

完成套餐和优惠计算

张洋 4 lat temu
rodzic
commit
e92159644a

BIN
bin/Win32/Debug/zhipuzi_pos_windows/dump/2021-11-17-20-09-46.dmp


BIN
bin/Win32/Debug/zhipuzi_pos_windows/dump/2021-11-17-20-11-13.dmp


+ 3 - 3
bin/Win32/Debug/zhipuzi_pos_windows/skin/diandan_page.xml

@@ -33,9 +33,9 @@
 							<ListHeaderItem text="金额" width="60" align="left" />
 						</List>
 						
-						<HorizontalLayout height="70">
-							
-							<Control></Control>
+						<HorizontalLayout name="diandan_page_youhui_tishi_layout" height="40" bkcolor="#FFFBEEEE" visible="false">
+							<Label name="diandan_page_youhui_tishi" text="已优惠10元" textcolor="#FFFF3838" padding="25,0,0,0" width="300" hegiht="40"></Label>
+							<Button name="btn_diandan_chakanyouhui" text="查看优惠>" heiht="30" width="80" padding="5,0,25,0" textcolor="#FF3CB371" normalimage="" hotimage="" pushedimage="" bordersize="0" bkcolor="#00FFFFFF"></Button>
 						</HorizontalLayout>
 					</VerticalLayout>
 					

+ 68 - 0
bin/Win32/Debug/zhipuzi_pos_windows/skin/youhui_show_dlg.xml

@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Window size="502,600" caption="0,0,0,36" roundcorner="4,4" >
+	<Font id="0" name="微软雅黑" size="22" />
+	
+	<VerticalLayout bkcolor="#FFFFFFFF" bordersize="1" bordercolor="#FFE8E8E8">
+		<HorizontalLayout height="50" inset="10,2,10,0">
+			<Label name="memo_dlg_title" text="优惠明细" align="center" valign="center" padding="0,20,0,0" font="0"/>
+		</HorizontalLayout>
+		
+		<VerticalLayout padding="0,20,0,0">
+			<HorizontalLayout height="40">
+				<Label name="shangpinquan" text="商品券优惠:" width="250" align="right"></Label>
+				<Label name="shangpinquan_value" text="0元" width="230" align="left"></Label>
+			</HorizontalLayout>
+			
+			<HorizontalLayout height="40">
+				<Label name="cika" text="次卡优惠:" width="250" align="right"></Label>
+				<Label name="cika_value" text="0元" width="230" align="left"></Label>
+			</HorizontalLayout>
+			
+			<HorizontalLayout height="40">
+				<Label name="shangpinhuiyuan" text="商品会员价优惠:" width="250" align="right"></Label>
+				<Label name="shangpinhuiyuan_value" text="0元" width="230" align="left"></Label>
+			</HorizontalLayout>
+			
+			<HorizontalLayout height="40">
+				<Label name="zhengdanzhekou" text="整单折扣优惠:" width="250" align="right"></Label>
+				<Label name="zhengdanzhekou_value" text="0元" width="230" align="left"></Label>
+			</HorizontalLayout>
+			
+			<HorizontalLayout height="40">
+				<Label name="huiyuanzhengdanzhekou" text="会员整单折扣优惠:" width="250" align="right"></Label>
+				<Label name="huiyuanzhengdanzhekou_value" text="0元" width="230" align="left"></Label>
+			</HorizontalLayout>
+			
+			<HorizontalLayout height="40">
+				<Label name="quanyika" text="权益卡优惠:" width="250" align="right"></Label>
+				<Label name="quanyika_value" text="0元" width="230" align="left"></Label>
+			</HorizontalLayout>
+			
+			<HorizontalLayout height="40">
+				<Label name="manjian" text="满减优惠:" width="250" align="right"></Label>
+				<Label name="manjian_value" text="0元" width="230" align="left"></Label>
+			</HorizontalLayout>
+			
+			<HorizontalLayout height="40">
+				<Label name="youhuiquan" text="优惠券优惠:" width="250" align="right"></Label>
+				<Label name="youhuiquan_value" text="0元" width="230" align="left"></Label>
+			</HorizontalLayout>
+			
+			<HorizontalLayout height="40">
+				<Label name="rengongyouhui" text="人工优惠:" width="250" align="right"></Label>
+				<Label name="rengongyouhui_value" text="0元" width="230" align="left"></Label>
+			</HorizontalLayout>
+			
+			<HorizontalLayout height="40">
+				<Label name="moling" text="抹零优惠:" width="250" align="right"></Label>
+				<Label name="moling_value" text="0元" width="230" align="left"></Label>
+			</HorizontalLayout>
+		</VerticalLayout>
+		
+		<HorizontalLayout height="56" valign="center" padding="0,30,0,20">
+			<Control />
+			<Button name="quit" align="center" width="100" height="45" padding="0,20,0,0" text="关闭" normalimage="file='Btn_White.png' corner='5,5,5,5'" hotimage="file='Btn_White_Hover.png' corner='5,5,5,5'" pushedimage="file='Btn_White_Click.png' corner='5,5,5,5'" />
+			<Control />
+		</HorizontalLayout>
+	</VerticalLayout>
+</Window>

+ 571 - 65
zhipuzi_pos_windows/page/CDiandanPageUI.cpp

@@ -7,6 +7,7 @@
 
 #include "../wnd/CDiandanNatureWnd.h"
 #include "../wnd/CMemoWnd.h"
+#include "../wnd/CYouhuiShowWnd.h"
 
 CDiandanPageUI::CDiandanPageUI()
 {
@@ -70,9 +71,13 @@ void CDiandanPageUI::InitJiesuanInfo()
 
 	//再初始化加价
 	m_jiajia = 0;
+	CEditUI* pJiajiaEdit = static_cast<CEditUI*>(this->FindSubControl(_T("diandan_jiesuan_jiajia_value")));
+	pJiajiaEdit->SetText(L"0");
 
 	//初始化优惠
-	m_youhui = 0;
+	m_rengong_youhui = 0;
+	CEditUI* pYouhuiEdit = static_cast<CEditUI*>(this->FindSubControl(_T("diandan_jiesuan_youhui_value")));
+	pYouhuiEdit->SetText(L"0");
 
 	//优惠券
 	m_is_youhuiquan = false;
@@ -88,6 +93,8 @@ void CDiandanPageUI::InitJiesuanInfo()
 
 	//抹零
 	m_moling_type = 0;
+	CCheckBoxUI* pMolingCheck = static_cast<CCheckBoxUI*>(this->FindSubControl(_T("diandan_jiesuan_moling_bumoling")));
+	pMolingCheck->Selected(true, false);
 
 	CHorizontalLayoutUI* pZhifufangshiLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("diandan_jiesuan_zhifufangshi_layout")));
 
@@ -283,6 +290,10 @@ void CDiandanPageUI::InitJiesuanInfo()
 			num++;
 		}
 	}
+
+	//调整区域高度
+	int lastRow = (num -  1) / 3 + 1;
+	pZhifufangshiLayout->SetFixedHeight(lastRow * 105);
 }
 
 //处理按钮点击类事件
@@ -332,6 +343,11 @@ void CDiandanPageUI::HandleClickMsg(TNotifyUI& msg)
 		//点击继续加菜
 		this->JixuJiacai();
 	}
+	else if (name == L"btn_diandan_chakanyouhui")
+	{
+		//点击查看优惠
+		this->ClickChakanYouhui();
+	}
 }
 
 //处理option切换事件
@@ -458,31 +474,50 @@ void CDiandanPageUI::AddDiandanOrderItemShow(int index)
 
 	pList->Add(pEle);
 
-	CLabelUI* pName = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_name")));
-	pName->SetText(CLewaimaiString::UTF8ToUnicode(item.food_name).c_str());
+	if (item.m_is_taocan)
+	{
+		CLabelUI* pName = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_name")));
+		pName->SetText(CLewaimaiString::UTF8ToUnicode(item.foodpackage_name).c_str());
 
-	CLabelUI* pNum = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_num")));
-	pNum->SetText(CLewaimaiString::UTF8ToUnicode(item.num).c_str());
+		CLabelUI* pNum = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_num")));
+		pNum->SetText(CLewaimaiString::UTF8ToUnicode(item.num).c_str());
 
-	CLabelUI* pPrice = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_price")));
-	pPrice->SetText(CLewaimaiString::UTF8ToUnicode(item.show_price).c_str());
+		CLabelUI* pPrice = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_price")));
+		pPrice->SetText(CLewaimaiString::UTF8ToUnicode(item.show_price).c_str());
+
+		CLabelUI* pNature = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_nature")));
 
-	CLabelUI* pNature = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_nature")));
-	if (item.is_nature)
-	{
 		pEle->SetFixedHeight(84);
 		pNature->SetVisible(true);
 		pNature->SetText(CLewaimaiString::UTF8ToUnicode(item.getNatureShow()).c_str());
 	}
 	else
 	{
-		pEle->SetFixedHeight(42);
-		pNature->SetVisible(false);
-	}
+		CLabelUI* pName = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_name")));
+		pName->SetText(CLewaimaiString::UTF8ToUnicode(item.food_name).c_str());
 
-	//更新总价显示
-	CLabelUI* pTotalPrice = static_cast<CLabelUI*>(this->FindSubControl(_T("diandan_page_totalprice")));
-	pTotalPrice->SetText((L"总价:¥" + CLewaimaiString::UTF8ToUnicode(m_cur_diandan_order.getTotalPriceShow())).c_str());
+		CLabelUI* pNum = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_num")));
+		pNum->SetText(CLewaimaiString::UTF8ToUnicode(item.num).c_str());
+
+		CLabelUI* pPrice = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_price")));
+		pPrice->SetText(CLewaimaiString::UTF8ToUnicode(item.show_price).c_str());
+
+		CLabelUI* pNature = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_nature")));
+		if (item.is_nature)
+		{
+			pEle->SetFixedHeight(84);
+			pNature->SetVisible(true);
+			pNature->SetText(CLewaimaiString::UTF8ToUnicode(item.getNatureShow()).c_str());
+		}
+		else
+		{
+			pEle->SetFixedHeight(42);
+			pNature->SetVisible(false);
+		}
+	}
+	
+	//更新结算信息
+	UpdateJiesuanInfo();
 }
 
 void CDiandanPageUI::UpdateDiandanOrderItemShow(int index)
@@ -493,31 +528,50 @@ void CDiandanPageUI::UpdateDiandanOrderItemShow(int index)
 
 	CListContainerElementUI* pEle = static_cast<CListContainerElementUI*>(pList->GetItemAt(index));
 
-	CLabelUI* pName = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_name")));
-	pName->SetText(CLewaimaiString::UTF8ToUnicode(item.food_name).c_str());
+	if (item.m_is_taocan)
+	{
+		CLabelUI* pName = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_name")));
+		pName->SetText(CLewaimaiString::UTF8ToUnicode(item.foodpackage_name).c_str());
 
-	CLabelUI* pNum = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_num")));
-	pNum->SetText(CLewaimaiString::UTF8ToUnicode(item.num).c_str());
+		CLabelUI* pNum = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_num")));
+		pNum->SetText(CLewaimaiString::UTF8ToUnicode(item.num).c_str());
 
-	CLabelUI* pPrice = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_price")));
-	pPrice->SetText(CLewaimaiString::UTF8ToUnicode(item.show_price).c_str());
+		CLabelUI* pPrice = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_price")));
+		pPrice->SetText(CLewaimaiString::UTF8ToUnicode(item.show_price).c_str());
+
+		CLabelUI* pNature = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_nature")));
 
-	CLabelUI* pNature = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_nature")));
-	if (item.is_nature)
-	{
 		pEle->SetFixedHeight(84);
 		pNature->SetVisible(true);
 		pNature->SetText(CLewaimaiString::UTF8ToUnicode(item.getNatureShow()).c_str());
 	}
 	else
 	{
-		pEle->SetFixedHeight(42);
-		pNature->SetVisible(false);
+		CLabelUI* pName = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_name")));
+		pName->SetText(CLewaimaiString::UTF8ToUnicode(item.food_name).c_str());
+
+		CLabelUI* pNum = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_num")));
+		pNum->SetText(CLewaimaiString::UTF8ToUnicode(item.num).c_str());
+
+		CLabelUI* pPrice = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_price")));
+		pPrice->SetText(CLewaimaiString::UTF8ToUnicode(item.show_price).c_str());
+
+		CLabelUI* pNature = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_nature")));
+		if (item.is_nature)
+		{
+			pEle->SetFixedHeight(84);
+			pNature->SetVisible(true);
+			pNature->SetText(CLewaimaiString::UTF8ToUnicode(item.getNatureShow()).c_str());
+		}
+		else
+		{
+			pEle->SetFixedHeight(42);
+			pNature->SetVisible(false);
+		}
 	}
 
-	//更新总价显示
-	CLabelUI* pTotalPrice = static_cast<CLabelUI*>(this->FindSubControl(_T("diandan_page_totalprice")));
-	pTotalPrice->SetText((L"总价:¥" + CLewaimaiString::UTF8ToUnicode(m_cur_diandan_order.getTotalPriceShow())).c_str());
+	//更新结算信息
+	UpdateJiesuanInfo();
 }
 
 void CDiandanPageUI::DelDiandanOrderItemShow(int index)
@@ -526,9 +580,8 @@ void CDiandanPageUI::DelDiandanOrderItemShow(int index)
 
 	pList->RemoveAt(index);
 
-	//更新总价显示
-	CLabelUI* pTotalPrice = static_cast<CLabelUI*>(this->FindSubControl(_T("diandan_page_totalprice")));
-	pTotalPrice->SetText((L"总价:¥" + CLewaimaiString::UTF8ToUnicode(m_cur_diandan_order.getTotalPriceShow())).c_str());
+	//更新结算信息
+	UpdateJiesuanInfo();
 }
 
 void CDiandanPageUI::ClearDiandanOrderItemShow()
@@ -537,9 +590,308 @@ void CDiandanPageUI::ClearDiandanOrderItemShow()
 
 	pList->RemoveAll();
 
-	//更新总价显示
+	//更新结算信息
+	UpdateJiesuanInfo();
+}
+
+void CDiandanPageUI::UpdateJiesuanInfo()
+{
+	//先按所有的价格公式规则,计算一次价格
+	//(基础商品价格+属性价格-商品券-次卡(抵扣金额、抵扣商品)-会员商品优惠)*店铺折扣*分等级会员折扣*权益卡折扣*次卡折扣-满减优惠-次卡满减-优惠券+加价-优惠-抹零+开台费+打包费+茶位费
+	
+	//先计算基础商品价格(不包含任何优惠活动等情况下的实际金额,已包含商品属性价格)
+	double jichu_price = m_cur_diandan_order.getTotalPrice();
+	
+	//这个是临时变量,表示每次优惠过后的实时价格
+	double cur_price = jichu_price;
+
+	double totol_youhui = 0;
+
+	//判断是否有商品券,如果有的话把金额抵扣掉
+	m_shangpinquan_youhui = 0;
+	if (m_is_shangpinquan)
+	{
+		//判断当前购物车商品,是否有满足对应商品券使用要求的
+		bool ret = m_cur_diandan_order.UseShangpinquan(m_shangpinquan_foodid, m_shangpinquan_youhui);
+
+		totol_youhui += m_shangpinquan_youhui;
+	}
+
+	//判断次卡
+	m_cika_youhui = 0;
+	if (m_is_cika)
+	{
+		//对次卡进行处理
+		if (m_cika_deduct_type == "0")
+		{
+		}
+		else if (m_cika_deduct_type == "1")
+		{
+		}
+		else if (m_cika_deduct_type == "2")
+		{
+			m_cika_youhui = atof(m_cika_offer_value.c_str());
+		}
+		else if (m_cika_deduct_type == "3")
+		{
+			//这种情况是次卡跟商品券一样抵扣商品\
+			
+			bool ret;
+			if (m_is_shangpinquan && m_shangpinquan_foodid == m_cika_bind_foods_id)
+			{
+				ret = m_cur_diandan_order.UseCikaDikou(m_cika_bind_foods_id, m_cika_youhui, true);
+			}
+			else
+			{
+				ret = m_cur_diandan_order.UseCikaDikou(m_cika_bind_foods_id, m_cika_youhui, false);
+			}
+		}
+
+		totol_youhui += m_cika_youhui;
+	}
+
+	//判断会员商品优惠
+	
+	//先按假数据
+	m_is_member = true;
+	m_member_level = 1;
+
+	m_total_member_youhui = 0;
+	
+	if (m_is_member)
+	{
+		m_total_member_youhui = m_cur_diandan_order.getTotalMemberYouhui(m_member_level);
+	}
+	totol_youhui += m_total_member_youhui;
+
+	//再判断整单折扣
+	cur_price = jichu_price - totol_youhui;
+
+	double old_cur_price = cur_price;
+
+	CEditUI* pZhekouEdit = static_cast<CEditUI*>(this->FindSubControl(_T("diandan_jiesuan_zhekou_value")));
+	wstring ws_zhekou = pZhekouEdit->GetText();
+	int zhekouValue = atoi(CLewaimaiString::UnicodeToUTF8(ws_zhekou).c_str());
+
+	cur_price = (double)(cur_price * zhekouValue) / 100.00;
+
+	m_zhekou_youhui = old_cur_price - cur_price;
+
+	totol_youhui += m_zhekou_youhui;
+
+	//再判断分等级会员折扣
+	m_member_zhekou_youhui = 0;
+	m_member_level_id = "3138";
+
+	std::vector<DiscountInfo> member_discount_info = CShopinfo::m_shopinfo.m_discount_info;
+
+	for (std::vector<DiscountInfo>::iterator it = member_discount_info.begin(); it != member_discount_info.end(); it++)
+	{
+		DiscountInfo info = *it;
+		if (info.level_id == m_member_level_id)
+		{
+			if (info.is_discount == "1")
+			{
+				double member_discount = atof(info.discount_value.c_str());
+
+				//这里最多是10折
+				double old_cur_price_member_discount = cur_price;
+
+				cur_price = (double)(cur_price * member_discount) / 10.00;
+
+				m_member_zhekou_youhui = old_cur_price_member_discount - cur_price;
+
+				totol_youhui += m_member_zhekou_youhui;
+
+				break;
+			}
+			
+		}
+	}
+
+	//再判断权益卡折扣
+	m_quanyika_youhui = 0;
+	if (m_is_quanyika == true)
+	{
+		if (CShopinfo::m_shopinfo.m_is_eq_card_discount == "1")
+		{
+			double quanyika_zhekou = atof(CShopinfo::m_shopinfo.m_eq_card_discount_value.c_str());
+
+			//这里最多是10折
+			double old_cur_price_quanyika_discount = cur_price;
+
+			cur_price = (double)(cur_price * quanyika_zhekou) / 10.00;
+
+			m_quanyika_youhui = old_cur_price_quanyika_discount - cur_price;
+
+			totol_youhui += m_quanyika_youhui;
+		}
+	}
+
+	//次卡折扣
+	if (m_is_cika)
+	{
+		//对次卡进行处理
+		if (m_cika_deduct_type == "0")
+		{
+			double cika_zhekou = atof(m_cika_discount_value.c_str());
+
+			//这里最多是10折
+			double old_cur_price_cika_discount = cur_price;
+
+			cur_price = (double)(cur_price * cika_zhekou) / 10.00;
+
+			m_cika_youhui = old_cur_price_cika_discount - cur_price;
+
+			totol_youhui += m_cika_youhui;
+		}
+	}
+
+	//满减优惠
+	m_manjian_youhui = 0;
+
+	if (CShopinfo::m_shopinfo.m_open_promotion == "1")
+	{
+		//开启了满减,进行判断
+
+		std::vector<Promotion> promotion = CShopinfo::m_shopinfo.m_promotion;
+
+		for (std::vector<Promotion>::iterator it = promotion.begin(); it != promotion.end(); it++)
+		{
+			Promotion cur = *it;
+
+			if (jichu_price >= cur.amount)
+			{
+				m_manjian_youhui = cur.discount;
+
+				totol_youhui += m_manjian_youhui;
+
+				cur_price -= m_manjian_youhui;
+
+				break;
+			}
+		}
+	}
+
+	//次卡满减
+	if (m_is_cika)
+	{
+		//对次卡进行处理
+		if (m_cika_deduct_type == "1")
+		{
+			std::vector<std::string> manjian = CLewaimaiString::Split(m_cika_full_reduce_value, ",");
+
+			double amount = atof(manjian[0].c_str());
+			double value = atof(manjian[1].c_str());
+
+			if (jichu_price >= amount)
+			{
+				m_cika_youhui = value;
+
+				totol_youhui += m_cika_youhui;
+
+				cur_price -= m_cika_youhui;
+			}
+		}
+	}
+
+	//优惠券
+	m_youhuiquan_youhui = 0;
+
+	if (m_is_youhuiquan)
+	{
+		time_t deadline = CLewaimaiTime::StringToDatetime(m_coupon_deadline);
+		time_t now = time(NULL);
+		if (deadline > now)
+		{
+			if (jichu_price >= atof(m_coupon_basic_price.c_str()))
+			{
+				m_youhuiquan_youhui = atof(m_coupon_value.c_str());
+
+				totol_youhui += m_youhuiquan_youhui;
+
+				cur_price -= m_youhuiquan_youhui;
+			}
+		}
+	}	
+
+	//加价
+	m_jiajia = 0;
+	CEditUI* pJiajiaEdit = static_cast<CEditUI*>(this->FindSubControl(_T("diandan_jiesuan_jiajia_value")));
+	wstring ws_jiajia = pJiajiaEdit->GetText();
+	m_jiajia = atof(CLewaimaiString::UnicodeToUTF8(ws_jiajia).c_str());
+
+	cur_price += m_jiajia;
+	
+	//人工优惠
+	m_rengong_youhui = 0;
+
+	CEditUI* pYouhuiEdit = static_cast<CEditUI*>(this->FindSubControl(_T("diandan_jiesuan_youhui_value")));
+	wstring ws_rengong_youhui = pYouhuiEdit->GetText();
+	m_rengong_youhui = atof(CLewaimaiString::UnicodeToUTF8(ws_rengong_youhui).c_str());
+
+	totol_youhui += m_rengong_youhui;
+
+	cur_price -= m_rengong_youhui;
+
+	//开台费
+	m_kaitai = 0;
+
+	//打包费
+
+	//茶位费
+	m_chawei = 0;
+
+	//抹零
+	m_moling_youhui = 0;
+
+	if (m_moling_type == 0)
+	{
+
+	}
+	else if (m_moling_type == 1)
+	{
+		double new_price = (int)(cur_price * 10) / 10.0;
+
+		m_moling_youhui = cur_price - new_price;
+		totol_youhui += m_moling_youhui;
+
+		cur_price = new_price;
+	}
+	else if (m_moling_type == 2)
+	{
+		double new_price = (int)(cur_price);
+
+		m_moling_youhui = cur_price - new_price;
+		totol_youhui += m_moling_youhui;
+
+		cur_price = new_price;
+	}
+
+	//至此优惠全部处理完了,开始刷新各个地方的展示
+
+	//先刷新优惠展示
+	CHorizontalLayoutUI* pYouhuiLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("diandan_page_youhui_tishi_layout")));
+	CLabelUI* pYouhuiLabel = static_cast<CLabelUI*>(this->FindSubControl(_T("diandan_page_youhui_tishi")));
+
+	if (totol_youhui > 0)
+	{
+		wstring youhuilabel = L"已优惠 " + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(totol_youhui, 2)) + L" 元";
+		pYouhuiLabel->SetText(youhuilabel.c_str());
+
+		pYouhuiLayout->SetVisible(true);
+	}
+	else
+	{
+		pYouhuiLayout->SetVisible(false);
+	}
+
+	//再刷新总价展示
 	CLabelUI* pTotalPrice = static_cast<CLabelUI*>(this->FindSubControl(_T("diandan_page_totalprice")));
-	pTotalPrice->SetText((L"总价:¥" + CLewaimaiString::UTF8ToUnicode(m_cur_diandan_order.getTotalPriceShow())).c_str());
+	pTotalPrice->SetText((L"总价:¥" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(cur_price, 2))).c_str());
+
+	//再刷新账单明细展示
+
 }
 
 void CDiandanPageUI::ClickFoodAction()
@@ -549,6 +901,63 @@ void CDiandanPageUI::ClickFoodAction()
 	if (is_taocan)
 	{
 		//点击套餐之后的处理逻辑
+		CFoodpackage foodpackageinfo = m_cur_click_food_item->GetFoodpackageInfo();
+
+		CDiandanOrderItem clickItem;
+
+		clickItem.foodpackage_id = foodpackageinfo.id;
+		clickItem.foodpackage_name = foodpackageinfo.name;
+		clickItem.price = foodpackageinfo.price;
+		clickItem.is_dabao = false;
+		clickItem.dabao_money = foodpackageinfo.dabao_money;
+		clickItem.num = "1";
+
+		//把当前点击商品的信息,保存到orderitem里面,方便后面修改规格的时候使用
+		clickItem.SetFoodpackageInfo(m_cur_click_food_item->GetFoodpackageInfo());
+		clickItem.SetIsTaocan(true);
+
+		//先弹框进行选择属性
+		CDiandanNatureWnd* pNatureFrame = new CDiandanNatureWnd(1);
+		pNatureFrame->SetFoodItemUI(m_cur_click_food_item);
+
+		if (pNatureFrame != NULL)
+		{
+			pNatureFrame->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
+			pNatureFrame->SetIcon(IDI_ICON_DUILIB);
+			pNatureFrame->CenterWindow();
+			UINT ret = pNatureFrame->ShowModal();
+
+			if (ret == IDOK)
+			{
+				//保存选择的属性
+				std::vector<FoodNatureSelectValue> natureSelectedArray = pNatureFrame->GetNatureSelectedArray();
+				clickItem.natureSelectedArray = natureSelectedArray;
+
+				delete pNatureFrame;
+			}
+			else
+			{
+				delete pNatureFrame;
+
+				return;
+			}
+		}
+
+		//商品没有商品属性
+		bool is_add_new = false;
+
+		int index = m_cur_diandan_order.AddItem(clickItem, is_add_new);
+
+		if (is_add_new)
+		{
+			//说明是新增了一项,要刷新一下购物车展示
+			this->AddDiandanOrderItemShow(index);
+		}
+		else
+		{
+			//没有新增,而是修改了一项
+			this->UpdateDiandanOrderItemShow(index);
+		}
 	}
 	else
 	{
@@ -561,15 +970,50 @@ void CDiandanPageUI::ClickFoodAction()
 		clickItem.food_name = foodinfo.name;
 		clickItem.type_id = foodinfo.type_id;
 		clickItem.price = foodinfo.price;
-		clickItem.is_dabao = "";
-		clickItem.num = "1";
-		clickItem.is_foodpackage = "0";
-		clickItem.is_weight = "0";
+		clickItem.is_dabao = false;
+		clickItem.dabao_money = foodinfo.dabao_money;
+		clickItem.num = "1"; 
+
+		if (foodinfo.member_price_used == "1")
+		{
+			clickItem.is_member_price_used = true;
+		}
+		else
+		{
+			clickItem.is_member_price_used = false;
+		}
+		
+		//处理会员价的json
+		std::string member_price_json = foodinfo.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 = member_price_info["id"].GetString();
+			newPirce.level = member_price_info["level"].GetString();
+			newPirce.price = member_price_info["price"].GetString();
+
+			clickItem.m_member_price.push_back(newPirce);
+		}
+
+		if (foodinfo.is_weight == "1")
+		{
+			clickItem.is_weight = true;
+		}
+		else
+		{
+			clickItem.is_weight = false;
+		}
 
 		//把当前点击商品的信息,保存到orderitem里面,方便后面修改规格的时候使用
 		clickItem.SetFoodInfo(m_cur_click_food_item->GetFoodInfo());
-		clickItem.SetFoodpackageInfo(m_cur_click_food_item->GetFoodpackageInfo());
-		clickItem.SetIsTaocan(m_cur_click_food_item->GetIsTaocan());
+		clickItem.SetIsTaocan(false);
 
 		if (foodinfo.is_nature == "1")
 		{
@@ -687,39 +1131,73 @@ void CDiandanPageUI::ClickGuige()
 		return;
 	}
 
-	bool is_nature = m_cur_diandan_order.getDiandanOrderItem(nIndex).is_nature;
-	if (!is_nature)
-	{
-		//当前商品没有商品属性
-		return;
-	}
-
-	//弹出属性框,开始重新选择属性
-	CDiandanNatureWnd* pNatureFrame = new CDiandanNatureWnd(2);
-	pNatureFrame->SetDiandanOrderItem(m_cur_diandan_order.getDiandanOrderItem(nIndex));
-
-	if (pNatureFrame != NULL)
+	bool is_taocan = m_cur_diandan_order.getDiandanOrderItem(nIndex).m_is_taocan;
+	if (is_taocan)
 	{
-		pNatureFrame->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
-		pNatureFrame->SetIcon(IDI_ICON_DUILIB);
-		pNatureFrame->CenterWindow();
-		UINT ret = pNatureFrame->ShowModal();
+		//弹出属性框,开始重新选择属性
+		CDiandanNatureWnd* pNatureFrame = new CDiandanNatureWnd(2);
+		pNatureFrame->SetDiandanOrderItem(m_cur_diandan_order.getDiandanOrderItem(nIndex));
 
-		if (ret == IDOK)
+		if (pNatureFrame != NULL)
 		{
-			//保存选择的属性
-			std::vector<FoodNatureSelectValue> natureSelectedArray = pNatureFrame->GetNatureSelectedArray();
-			m_cur_diandan_order.UpdateItemGuige(nIndex, natureSelectedArray);
+			pNatureFrame->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
+			pNatureFrame->SetIcon(IDI_ICON_DUILIB);
+			pNatureFrame->CenterWindow();
+			UINT ret = pNatureFrame->ShowModal();
 
-			delete pNatureFrame;
+			if (ret == IDOK)
+			{
+				//保存选择的属性
+				std::vector<FoodNatureSelectValue> natureSelectedArray = pNatureFrame->GetNatureSelectedArray();
+				m_cur_diandan_order.UpdateItemGuige(nIndex, natureSelectedArray);
+
+				delete pNatureFrame;
 
-			//然后要刷新这个item的显示
-			this->UpdateDiandanOrderItemShow(nIndex);
+				//然后要刷新这个item的显示
+				this->UpdateDiandanOrderItemShow(nIndex);
+			}
+			else
+			{
+				return;
+			}
 		}
-		else
+	}
+	else
+	{
+		bool is_nature = m_cur_diandan_order.getDiandanOrderItem(nIndex).is_nature;
+		if (!is_nature)
 		{
+			//当前商品没有商品属性
 			return;
 		}
+
+		//弹出属性框,开始重新选择属性
+		CDiandanNatureWnd* pNatureFrame = new CDiandanNatureWnd(2);
+		pNatureFrame->SetDiandanOrderItem(m_cur_diandan_order.getDiandanOrderItem(nIndex));
+
+		if (pNatureFrame != NULL)
+		{
+			pNatureFrame->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
+			pNatureFrame->SetIcon(IDI_ICON_DUILIB);
+			pNatureFrame->CenterWindow();
+			UINT ret = pNatureFrame->ShowModal();
+
+			if (ret == IDOK)
+			{
+				//保存选择的属性
+				std::vector<FoodNatureSelectValue> natureSelectedArray = pNatureFrame->GetNatureSelectedArray();
+				m_cur_diandan_order.UpdateItemGuige(nIndex, natureSelectedArray);
+
+				delete pNatureFrame;
+
+				//然后要刷新这个item的显示
+				this->UpdateDiandanOrderItemShow(nIndex);
+			}
+			else
+			{
+				return;
+			}
+		}
 	}
 }
 
@@ -803,4 +1281,32 @@ void CDiandanPageUI::JixuJiacai()
 	//隐藏继续加菜的按钮
 	CButtonUI* pJiacaiBtn = static_cast<CButtonUI*>(this->FindSubControl(_T("btn_diandan_jixujiacai")));
 	pJiacaiBtn->SetVisible(false);
+}
+
+void CDiandanPageUI::ClickChakanYouhui()
+{
+	//弹框展示所有的优惠
+	CYouhuiShowWnd* pYouhuiDlg = new CYouhuiShowWnd();
+
+	if (pYouhuiDlg != NULL)
+	{
+		pYouhuiDlg->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
+		pYouhuiDlg->SetIcon(IDI_ICON_DUILIB);
+		pYouhuiDlg->CenterWindow();
+
+		pYouhuiDlg->SetYouhuiValue(m_shangpinquan_youhui, m_cika_youhui, m_total_member_youhui, m_zhekou_youhui, m_member_zhekou_youhui, m_quanyika_youhui, m_manjian_youhui, m_youhuiquan_youhui, m_rengong_youhui, m_moling_youhui);
+
+		UINT ret = pYouhuiDlg->ShowModal();
+
+		if (ret == IDOK)
+		{
+			
+		}
+		else
+		{
+			delete pYouhuiDlg;
+
+			return;
+		}
+	}
 }

+ 53 - 3
zhipuzi_pos_windows/page/CDiandanPageUI.h

@@ -33,7 +33,7 @@ public:
 
 	void InitFoodtypeShow();
 
-	//刷新商品展示
+	//根据当前选择的分类,刷新商品展示
 	void RefreshFoodlist();
 
 	//添加一个新的商品到购物车展示
@@ -48,6 +48,9 @@ public:
 	//清空购物车中所有商品的展示
 	void ClearDiandanOrderItemShow();
 
+	//任何可以引起价格变化的,比如添加、修改、删除商品,或者修改优惠等,需要重新计算总价格,刷新结算账单等地方的显示,都要调用这个方法
+	void UpdateJiesuanInfo();
+
 	//点击某一个商品的item之后的处理逻辑
 	void ClickFoodAction();
 
@@ -75,6 +78,9 @@ public:
 	//点击继续加菜之后的逻辑
 	void JixuJiacai();
 
+	//点击查看优惠
+	void ClickChakanYouhui();
+
 private:
 	CTileLayoutUI* m_foodLayout;
 	CHorizontalLayoutUI* m_foodtypeLayout;
@@ -96,23 +102,67 @@ private:
 
 	//下面是结算相关信息
 	double m_discount;
+	double m_zhekou_youhui;
 
+	//人工加价
 	double m_jiajia;
-	double m_youhui;
+
+	//人工优惠
+	double m_rengong_youhui;
+
+	//开台费
+	double m_kaitai;
+
+	//茶位费
+	double m_chawei;
+
+	//打包费
+	double m_dabao;
 
 	//优惠券
 	bool m_is_youhuiquan;
+	std::string m_youhuiquan_id;
+	std::string m_coupon_basic_price;
+	std::string m_coupon_deadline;
+	std::string m_coupon_value;
+	double m_youhuiquan_youhui;
 
 	//商品券
-	bool m_is_shangpinquan;
+	bool m_is_shangpinquan; //是否核销的商品券
+	std::string m_shangpinquan_id;
+	std::string m_shangpinquan_name;
+	std::string m_shangpinquan_foodid;
+	double m_shangpinquan_youhui; //商品券优惠金额
 
 	//次卡
 	bool m_is_cika;
+	std::string m_cika_id;
+	std::string m_cika_deduct_type; //次卡优惠类型,0=>折扣,1=>满减,2=>抵扣,3=>指定商品兑换
+	std::string m_cika_discount; //折扣信息
+	std::string m_cika_discount_value; //折扣打折值
+	std::string m_cika_full_reduce; //满减信息
+	std::string m_cika_full_reduce_value; //满减,例如 200,100中间逗号隔开
+	std::string m_cika_offer;
+	std::string m_cika_offer_value;
+	std::string m_cika_bind_foods_id;
+	double m_cika_youhui;
 
 	//权益卡
 	bool m_is_quanyika;
+	double m_quanyika_youhui;
 
 	//抹零 0:不抹零 1:抹零到角 2:抹零到元
 	int m_moling_type;
+	double m_moling_youhui;
+
+	bool m_is_member;
+	std::string m_member_level;
+	std::string m_member_level_id;
+
+	double m_total_member_youhui; //会员商品优惠
+	double m_member_zhekou_youhui; //会员店铺折扣优惠
+
+	//满减
+	double m_manjian_youhui;
 };
 

+ 56 - 2
zhipuzi_pos_windows/tool/CSqlite3.cpp

@@ -1055,6 +1055,8 @@ std::vector<CFood> CSqlite3::GetFoodByTypeid(std::string type_id, bool is_shouyi
 		sql += " AND type_id = '" + type_id + "'";
 	}
 
+	sql += " ORDER BY tag";
+
 	sqlite3_stmt * stmt = NULL;
 
 	if (sqlite3_prepare_v2(m_db, sql.c_str(), -1, &stmt, NULL) == SQLITE_OK)
@@ -1111,11 +1113,11 @@ std::vector<CFoodpackage> CSqlite3::GetFoodpackages(bool is_shouyinji_show)
 
 	if (is_shouyinji_show)
 	{
-		sql = "SELECT * FROM pos_foodpackage WHERE is_shouyinji_show = '1'";
+		sql = "SELECT * FROM pos_foodpackage WHERE is_shouyinji_show = '1' ORDER BY tag";
 	}
 	else
 	{
-		sql = "SELECT * FROM pos_foodpackage";
+		sql = "SELECT * FROM pos_foodpackage ORDER BY tag";
 	}
 
 	sqlite3_stmt * stmt = NULL;
@@ -1153,4 +1155,56 @@ std::vector<CFoodpackage> CSqlite3::GetFoodpackages(bool is_shouyinji_show)
 	}
 
 	return data;
+}
+
+bool CSqlite3::GetFoodById(std::string food_id, CFood& newFood)
+{
+	bool is_found = false;
+
+	std::string sql = "SELECT * FROM pos_food WHERE id = '" + food_id + "'";
+
+	sqlite3_stmt * stmt = NULL;
+
+	if (sqlite3_prepare_v2(m_db, sql.c_str(), -1, &stmt, NULL) == SQLITE_OK)
+	{
+		while (sqlite3_step(stmt) == SQLITE_ROW)
+		{
+			is_found = true;
+
+			newFood.id = (char*)sqlite3_column_text(stmt, 0);
+			newFood.shop_id = (char*)sqlite3_column_text(stmt, 1);
+			newFood.name = (char*)sqlite3_column_text(stmt, 2);
+			newFood.price = (char*)sqlite3_column_text(stmt, 3);
+			newFood.tag = (char*)sqlite3_column_text(stmt, 4);
+			newFood.status = (char*)sqlite3_column_text(stmt, 5);
+			newFood.type_id = (char*)sqlite3_column_text(stmt, 6);
+			newFood.is_dabao = (char*)sqlite3_column_text(stmt, 7);
+			newFood.dabao_money = (char*)sqlite3_column_text(stmt, 8);
+			newFood.is_nature = (char*)sqlite3_column_text(stmt, 9);
+			newFood.nature = (char*)sqlite3_column_text(stmt, 10);
+			newFood.autostocknum = (char*)sqlite3_column_text(stmt, 11);
+			newFood.goods_img = (char*)sqlite3_column_text(stmt, 12);
+			newFood.unit = (char*)sqlite3_column_text(stmt, 13);
+			newFood.barcode = (char*)sqlite3_column_text(stmt, 14);
+			newFood.member_price_used = (char*)sqlite3_column_text(stmt, 15);
+			newFood.member_price = (char*)sqlite3_column_text(stmt, 16);
+			newFood.buying_price = (char*)sqlite3_column_text(stmt, 17);
+			newFood.stock = (char*)sqlite3_column_text(stmt, 18);
+			newFood.stockvalid = (char*)sqlite3_column_text(stmt, 19);
+			newFood.stock_warning = (char*)sqlite3_column_text(stmt, 20);
+			newFood.is_shouyinji_show = (char*)sqlite3_column_text(stmt, 21);
+			newFood.expiration_date = (char*)sqlite3_column_text(stmt, 22);
+			newFood.is_weight = (char*)sqlite3_column_text(stmt, 23);
+			newFood.member_price_json = (char*)sqlite3_column_text(stmt, 24);
+		}
+
+		sqlite3_finalize(stmt);
+	}
+	else
+	{
+		//Òì³£Çé¿ö
+		sqlite3_finalize(stmt);
+	}
+
+	return is_found;
 }

+ 3 - 0
zhipuzi_pos_windows/tool/CSqlite3.h

@@ -41,6 +41,9 @@ public:
 	std::vector<CFood> GetFoodByTypeid(std::string type_id, bool is_shouyinji_show = true);
 	std::vector<CFoodpackage> GetFoodpackages(bool is_shouyinji_show = true);
 
+	//通过商品ID查找商品,如果找到返回true,找不到返回false
+	bool GetFoodById(std::string food_id, CFood& newFood);
+
 private:
 	bool ExeSQl(std::string sql);
 

+ 129 - 45
zhipuzi_pos_windows/wnd/CDiandanNatureWnd.cpp

@@ -25,69 +25,153 @@ void CDiandanNatureWnd::Init()
 		foodpackageinfo = m_DiandanOrderItem.GetFoodpackageInfo();
 	}
 
-	//当前展示的是普通商品
-	std::string nature = foodinfo.nature;
+	if (is_taocan == true)
+	{
+		//当前展示的是套餐
+		std::string nature = foodpackageinfo.nature;
 
-	rapidjson::Document document;
-	document.Parse(nature.c_str());
+		rapidjson::Document document;
+		document.Parse(nature.c_str());
 
-	if (document.HasParseError())
-	{
-		//属性json报错,直接不处理了
-		Close(IDCANCEL);
-		return;
-	}
+		if (document.HasParseError())
+		{
+			//属性json报错,直接不处理了
+			Close(IDCANCEL);
+			return;
+		}
 
-	CVerticalLayoutUI* pNatureLayout = static_cast<CVerticalLayoutUI*>(this->m_pm.FindControl(_T("diandan_nature_layout")));
+		CVerticalLayoutUI* pNatureLayout = static_cast<CVerticalLayoutUI*>(this->m_pm.FindControl(_T("diandan_nature_layout")));
 
-	std::vector<FoodNatureSelectValue> natureSelectedArray;
-	if (m_mode == 2)
-	{
-		//这个是修改属性才有,要把属性弹框初始化为这个里面的选项			
-		natureSelectedArray = m_DiandanOrderItem.natureSelectedArray;
-	}		
+		std::vector<FoodNatureSelectValue> natureSelectedArray;
+		if (m_mode == 2)
+		{
+			//这个是修改属性才有,要把属性弹框初始化为这个里面的选项			
+			natureSelectedArray = m_DiandanOrderItem.natureSelectedArray;
+		}
 
-	rapidjson::Value& data = document;
-	for (rapidjson::SizeType i = 0; i < data.Size(); ++i)
-	{
-		//创建一个属性控件
-		CDialogBuilder builder;
-		CDialogBuilderCallbackEx cb;
-		CDiandanNatureItemUI* pItem = static_cast<CDiandanNatureItemUI*>(builder.Create(_T("diandan_nature_item.xml"), (UINT)0, &cb, &m_pm));
+		rapidjson::Value& data = document;
+		for (rapidjson::SizeType i = 0; i < data.Size(); ++i)
+		{
+			//创建一个属性控件
+			CDialogBuilder builder;
+			CDialogBuilderCallbackEx cb;
+			CDiandanNatureItemUI* pItem = static_cast<CDiandanNatureItemUI*>(builder.Create(_T("diandan_nature_item.xml"), (UINT)0, &cb, &m_pm));
 
-		//要先Add,子控件才能调用SetPos
-		pNatureLayout->Add(pItem);
+			//要先Add,子控件才能调用SetPos
+			pNatureLayout->Add(pItem);
 
-		m_natureitems.push_back(pItem);
+			m_natureitems.push_back(pItem);
 
-		//这里面的是属性名字信息
-		rapidjson::Value& natureinfo = data[i];
+			//这里面的是属性名字信息
+			rapidjson::Value& natureinfo = data[i];
 
-		std::string name = natureinfo["name"].GetString();
-		std::string limit_choose = natureinfo["limit_choose"].GetString();
+			std::string name = natureinfo["name"].GetString();
 
-		rapidjson::Value& value = natureinfo["value"];
+			rapidjson::Value& value = natureinfo["value"];
 
-		for (rapidjson::SizeType j = 0; j < value.Size(); ++j)
-		{
-			FoodNatureValue newvalueItem;
+			for (rapidjson::SizeType j = 0; j < value.Size(); ++j)
+			{
+				FoodNatureValue newvalueItem;
+
+				//套餐里面保存的是当前商品的ID
+				std::string food_id = value[j].GetString();;
 
-			newvalueItem.name = value[j]["name"].GetString();
-			newvalueItem.value = value[j]["value"].GetInt();
+				//要根据商品ID找出商品的名字
+				CFood foodinfo;
+				CSqlite3 sqlite;
+				bool is_found = sqlite.GetFoodById(food_id, foodinfo);
+				if (!is_found)
+				{
+					continue;
+				}
 
-			pItem->addNatureValue(newvalueItem);
-		}			
+				newvalueItem.name = foodinfo.name;
 
-		pItem->SetNatureName(name);
-		pItem->SetNatureNameNum(i);
+				//套餐的每个商品没有独立价格
+				newvalueItem.value = 0;
+
+				pItem->addNatureValue(newvalueItem);
+			}
 
-		if (m_mode == 1)
+			pItem->SetNatureName(name);
+			pItem->SetNatureNameNum(i);
+
+			if (m_mode == 1)
+			{
+				pItem->ShowNatureValue(0);
+			}
+			else
+			{
+				pItem->ShowNatureValue(natureSelectedArray[i].nature_select_index);
+			}
+		}
+	}
+	else
+	{
+		//当前展示的是普通商品
+		std::string nature = foodinfo.nature;
+
+		rapidjson::Document document;
+		document.Parse(nature.c_str());
+
+		if (document.HasParseError())
 		{
-			pItem->ShowNatureValue(0);
+			//属性json报错,直接不处理了
+			Close(IDCANCEL);
+			return;
 		}
-		else
+
+		CVerticalLayoutUI* pNatureLayout = static_cast<CVerticalLayoutUI*>(this->m_pm.FindControl(_T("diandan_nature_layout")));
+
+		std::vector<FoodNatureSelectValue> natureSelectedArray;
+		if (m_mode == 2)
 		{
-			pItem->ShowNatureValue(natureSelectedArray[i].nature_select_index);
+			//这个是修改属性才有,要把属性弹框初始化为这个里面的选项			
+			natureSelectedArray = m_DiandanOrderItem.natureSelectedArray;
+		}
+
+		rapidjson::Value& data = document;
+		for (rapidjson::SizeType i = 0; i < data.Size(); ++i)
+		{
+			//创建一个属性控件
+			CDialogBuilder builder;
+			CDialogBuilderCallbackEx cb;
+			CDiandanNatureItemUI* pItem = static_cast<CDiandanNatureItemUI*>(builder.Create(_T("diandan_nature_item.xml"), (UINT)0, &cb, &m_pm));
+
+			//要先Add,子控件才能调用SetPos
+			pNatureLayout->Add(pItem);
+
+			m_natureitems.push_back(pItem);
+
+			//这里面的是属性名字信息
+			rapidjson::Value& natureinfo = data[i];
+
+			std::string name = natureinfo["name"].GetString();
+			std::string limit_choose = natureinfo["limit_choose"].GetString();
+
+			rapidjson::Value& value = natureinfo["value"];
+
+			for (rapidjson::SizeType j = 0; j < value.Size(); ++j)
+			{
+				FoodNatureValue newvalueItem;
+
+				newvalueItem.name = value[j]["name"].GetString();
+				newvalueItem.value = value[j]["value"].GetInt();
+
+				pItem->addNatureValue(newvalueItem);
+			}
+
+			pItem->SetNatureName(name);
+			pItem->SetNatureNameNum(i);
+
+			if (m_mode == 1)
+			{
+				pItem->ShowNatureValue(0);
+			}
+			else
+			{
+				pItem->ShowNatureValue(natureSelectedArray[i].nature_select_index);
+			}
 		}
 	}
 }

+ 179 - 0
zhipuzi_pos_windows/wnd/CYouhuiShowWnd.cpp

@@ -0,0 +1,179 @@
+#include "../pch/pch.h"
+#include "CYouhuiShowWnd.h"
+
+LRESULT CYouhuiShowWnd::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 CYouhuiShowWnd::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 CYouhuiShowWnd::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_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;
+	default:
+		bHandled = FALSE;
+	}
+	if (bHandled)
+	{
+		return lRes;
+	}
+	if (m_pm.MessageHandler(uMsg, wParam, lParam, lRes))
+	{
+		return lRes;
+	}
+	return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
+}
+
+LRESULT CYouhuiShowWnd::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled)
+{
+	if (uMsg == WM_KEYDOWN)
+	{
+		if (wParam == VK_RETURN)
+		{
+			return true;
+		}
+		else if (wParam == VK_ESCAPE)
+		{
+			return true;
+		}
+	}
+	return false;
+}
+
+LRESULT CYouhuiShowWnd::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("youhui_show_dlg.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;
+}
+
+void CYouhuiShowWnd::Notify(TNotifyUI& msg)
+{
+	if (msg.sType == _T("click"))
+	{
+		DuiLib::CDuiString senderName = msg.pSender->GetName();
+
+		if (senderName == _T("quit"))
+		{
+			Close(IDCANCEL);
+			return;
+		}
+	}
+}
+
+void CYouhuiShowWnd::Init()
+{
+
+}
+
+void CYouhuiShowWnd::SetYouhuiValue(double shangpinquan_youhui, double cika_youhui, double huiyiuan_shangpin_youhui, double zhekou_youhui, double huiyuan_zhekou_youhui, \
+	double quanyika_youhui, double manjian_youhui, double youhuiquan_youhui, double rengong_youhui, double moling_youhui)
+{
+	CLabelUI* pContent = static_cast<CLabelUI*>(m_pm.FindControl(_T("shangpinquan_value")));
+	pContent->SetText((CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(shangpinquan_youhui, 2)) + L"元").c_str());
+
+	pContent = static_cast<CLabelUI*>(m_pm.FindControl(_T("cika_value")));
+	pContent->SetText((CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(cika_youhui, 2)) + L"元").c_str());
+
+	pContent = static_cast<CLabelUI*>(m_pm.FindControl(_T("shangpinhuiyuan_value")));
+	pContent->SetText((CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(huiyiuan_shangpin_youhui, 2)) + L"元").c_str());
+
+	pContent = static_cast<CLabelUI*>(m_pm.FindControl(_T("zhengdanzhekou_value")));
+	pContent->SetText((CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(zhekou_youhui, 2)) + L"元").c_str());
+
+	pContent = static_cast<CLabelUI*>(m_pm.FindControl(_T("huiyuanzhengdanzhekou_value")));
+	pContent->SetText((CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(huiyuan_zhekou_youhui, 2)) + L"元").c_str());
+
+	pContent = static_cast<CLabelUI*>(m_pm.FindControl(_T("quanyika_value")));
+	pContent->SetText((CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(quanyika_youhui, 2)) + L"元").c_str());
+
+	pContent = static_cast<CLabelUI*>(m_pm.FindControl(_T("manjian_value")));
+	pContent->SetText((CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(manjian_youhui, 2)) + L"元").c_str());
+
+	pContent = static_cast<CLabelUI*>(m_pm.FindControl(_T("youhuiquan_value")));
+	pContent->SetText((CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(youhuiquan_youhui, 2)) + L"元").c_str());
+
+	pContent = static_cast<CLabelUI*>(m_pm.FindControl(_T("rengongyouhui_value")));
+	pContent->SetText((CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(rengong_youhui, 2)) + L"元").c_str());
+
+	pContent = static_cast<CLabelUI*>(m_pm.FindControl(_T("moling_value")));
+	pContent->SetText((CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(moling_youhui, 2)) + L"元").c_str());
+}

+ 66 - 0
zhipuzi_pos_windows/wnd/CYouhuiShowWnd.h

@@ -0,0 +1,66 @@
+#pragma once
+
+#include "../pch/pch.h"
+#include "CMainWnd.h"
+
+class CYouhuiShowWnd : public CWindowWnd, public INotifyUI, public IMessageFilterUI
+{
+public:
+	LPCTSTR GetWindowClassName() const
+	{
+		return _T("UIMemoWndFrame");
+	};
+
+	UINT GetClassStyle() const
+	{
+		return UI_CLASSSTYLE_DIALOG;
+	};
+
+	void OnFinalMessage(HWND /*hWnd*/)
+	{
+		//WindowImplBase::OnFinalMessage(hWnd);
+		m_pm.RemovePreMessageFilter(this);
+
+		//delete this;
+	};
+
+	void Init();
+
+	void SetYouhuiValue(double shangpinquan_youhui, double cika_youhui, double huiyiuan_shangpin_youhui, double zhekou_youhui, double huiyuan_zhekou_youhui,\
+		double quanyika_youhui, double manjian_youhui, double youhuiquan_youhui, double rengong_youhui, double moling_youhui);
+
+	void Notify(TNotifyUI& msg);
+
+	LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+
+	LRESULT OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+	{
+		if (::IsIconic(*this))
+		{
+			bHandled = FALSE;
+		}
+		return (wParam == 0) ? TRUE : FALSE;
+	}
+
+	LRESULT OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+	{
+		return 0;
+	}
+
+	LRESULT OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+	{
+		return 0;
+	}
+
+	LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+
+	LRESULT OnSize(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);
+
+public:
+	CPaintManagerUI m_pm;
+};
+

+ 114 - 25
zhipuzi_pos_windows/zhipuzi/CDiandanOrder.cpp

@@ -8,9 +8,30 @@ int CDiandanOrder::getItemNum()
 
 std::string CDiandanOrder::getTotalPriceShow()
 {
+	double total_price_show = 0;
+
+	for (std::vector<CDiandanOrderItem>::iterator it = m_items.begin(); it != m_items.end(); it++)
+	{
+		total_price_show += std::stod((*it).show_price);
+	}
+
+	m_total_price_show = CLewaimaiString::DoubleToString(total_price_show, 2);
+
 	return m_total_price_show;
 }
 
+double CDiandanOrder::getTotalPrice()
+{
+	double total_price_show = 0;
+
+	for (std::vector<CDiandanOrderItem>::iterator it = m_items.begin(); it != m_items.end(); it++)
+	{
+		total_price_show += std::stod((*it).show_price);
+	}
+
+	return total_price_show;
+}
+
 CDiandanOrderItem CDiandanOrder::getDiandanOrderItem(int index)
 {
 	return m_items[index];
@@ -56,8 +77,6 @@ int CDiandanOrder::AddItem(CDiandanOrderItem newitem, bool& is_add_new)
 
 		m_items[index].UpdateShowPrice();
 
-		UpdateTotalPriceShow();
-
 		is_add_new = false;
 	}
 	else
@@ -67,8 +86,6 @@ int CDiandanOrder::AddItem(CDiandanOrderItem newitem, bool& is_add_new)
 
 		m_items[index].UpdateShowPrice();
 
-		UpdateTotalPriceShow();
-
 		is_add_new = true;
 	}
 
@@ -82,18 +99,6 @@ void CDiandanOrder::UpdateItemGuige(int index, std::vector<FoodNatureSelectValue
 	this->UpdateGuigePrice(index);
 }
 
-void CDiandanOrder::UpdateTotalPriceShow()
-{
-	double total_price_show = 0;
-
-	for (std::vector<CDiandanOrderItem>::iterator it = m_items.begin(); it != m_items.end(); it++)
-	{
-		total_price_show += std::stod((*it).show_price);
-	}
-
-	m_total_price_show = CLewaimaiString::DoubleToString(total_price_show, 2);
-}
-
 //给某一项添加一个数量
 void CDiandanOrder::AddNum(int index)
 {
@@ -113,8 +118,6 @@ void CDiandanOrder::AddNum(int index)
 	}
 
 	m_items[index].UpdateShowPrice();
-
-	UpdateTotalPriceShow();
 }
 
 //给某一项减少一个数量,返回值为true表示商品本删掉了,也就是为0份;如果为false表示没被删掉
@@ -129,7 +132,6 @@ bool CDiandanOrder::DelNum(int index)
 	{
 		//已经减为0了,那么就删掉这个item
 		m_items.erase(m_items.begin() + index);
-		UpdateTotalPriceShow();
 
 		return true;
 	}
@@ -148,8 +150,6 @@ bool CDiandanOrder::DelNum(int index)
 		m_items[index].UpdateShowPrice();
 	}
 
-	UpdateTotalPriceShow();
-
 	return false;
 }
 
@@ -158,25 +158,114 @@ void CDiandanOrder::Remove(int index)
 {
 	//已经减为0了,那么就删掉这个item
 	m_items.erase(m_items.begin() + index);
-	UpdateTotalPriceShow();
 }
 
 //更新了某项的规格,那么重新刷新显示和价格
 void CDiandanOrder::UpdateGuigePrice(int index)
 {
 	m_items[index].UpdateShowPrice();
-
-	UpdateTotalPriceShow();
 }
 
 //清空商品
 void CDiandanOrder::Clear()
 {
 	m_items.clear();
-	UpdateTotalPriceShow();
 }
 
 void CDiandanOrder::SetMemo(std::string memo)
 {
 	m_memo = memo;
+}
+
+bool CDiandanOrder::UseShangpinquan(std::string shangpinquan_food_id, double& youhui_value)
+{
+	for (std::vector<CDiandanOrderItem>::iterator it = m_items.begin(); it != m_items.end(); it++)
+	{
+		CDiandanOrderItem curItem = *it;
+
+		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;
+}
+
+bool CDiandanOrder::UseCikaDikou(std::string cika_food_id, double& youhui_value, bool is_shangpinquan_dikou)
+{
+	for (std::vector<CDiandanOrderItem>::iterator it = m_items.begin(); it != m_items.end(); it++)
+	{
+		CDiandanOrderItem curItem = *it;
+
+		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;
+}
+
+double CDiandanOrder::getTotalMemberYouhui(std::string member_level)
+{
+	double total_youhui = 0;
+
+	for (std::vector<CDiandanOrderItem>::iterator it = m_items.begin(); it != m_items.end(); it++)
+	{
+		CDiandanOrderItem curItem = *it;
+
+		double item_youhui = curItem.getMemberYouhui(member_level);
+
+		total_youhui += item_youhui;
+	}
+
+	return total_youhui;
 }

+ 12 - 144
zhipuzi_pos_windows/zhipuzi/CDiandanOrder.h

@@ -8,148 +8,7 @@
 #include "../zhipuzi/CFood.h"
 #include "../zhipuzi/CFoodpackage.h"
 
-/**
- * 订单中的一个商品
- */
-class CDiandanOrderItem
-{
-public:
-	std::string food_id;
-	std::string food_name;
-	std::string type_id;
-
-	//这个是商品的基础价格
-	std::string price;
-	std::string is_dabao;
-	std::string num;
-	std::string is_foodpackage;
-	std::string is_weight;
-
-	bool is_nature = false;
-
-	//这个用来存储所有属性选择的信息,每个属性选择的是第几个,什么价格等等
-	std::vector<FoodNatureSelectValue> natureSelectedArray;
-
-	//这个是商品对外展示的价格,根据数量和属性来计算的
-	std::string show_price;
-
-private:
-	CFood m_foodinfo;
-	CFoodpackage m_foodpackageinfo;
-
-	bool m_is_taocan = false;
-
-public:
-
-	bool operator==(CDiandanOrderItem& t)
-	{
-		if (this->food_id != t.food_id)
-		{
-			return false;
-		}
-
-		if (this->is_nature != t.is_nature)
-		{
-			return false;
-		}
-
-		int i = 0;
-		for (std::vector<FoodNatureSelectValue>::iterator it = this->natureSelectedArray.begin(); it != this->natureSelectedArray.end(); it++)
-		{
-			if ((*it).nature_name != t.natureSelectedArray[i].nature_name)
-			{
-				return false;
-			}
-
-			if ((*it).nature_select_index != t.natureSelectedArray[i].nature_select_index)
-			{
-				return false;
-			}
-
-			i++;
-		}
-
-		return true;
-	}
-
-	void CDiandanOrderItem::SetFoodInfo(CFood info)
-	{
-		m_foodinfo = info;
-	}
-
-	void CDiandanOrderItem::SetFoodpackageInfo(CFoodpackage info)
-	{
-		m_foodpackageinfo = info;
-
-		m_is_taocan = true;
-	}
-
-	void CDiandanOrderItem::SetIsTaocan(bool is_taocan)
-	{
-		m_is_taocan = is_taocan;
-	}
-
-	CFood CDiandanOrderItem::GetFoodInfo()
-	{
-		return m_foodinfo;
-	}
-
-	CFoodpackage CDiandanOrderItem::GetFoodpackageInfo()
-	{
-		return m_foodpackageinfo;
-	}
-
-	bool CDiandanOrderItem::GetIsTaocan()
-	{
-		return m_is_taocan;
-	}
-	
-	//根据当前选中的商品属性,重新设置price字段值
-	void UpdateShowPrice()
-	{
-		if (!is_nature)
-		{
-			show_price = CLewaimaiString::DoubleToString(std::stod(price) * std::stod(num), 2);
-		}
-		else
-		{
-			int nature_price = 0;
-			for (std::vector<FoodNatureSelectValue>::iterator it = this->natureSelectedArray.begin(); it != this->natureSelectedArray.end(); it++)
-			{
-				nature_price += (*it).nature_select_value;
-			}
-
-			double new_price = std::stod(price) + nature_price;
-
-			show_price = CLewaimaiString::DoubleToString(new_price * std::stod(num), 2);
-		}
-	}
-
-	//获取用于展示的属性名字
-	std::string getNatureShow()
-	{
-		if (!is_nature)
-		{
-			return "";
-		}
-
-		std::string show = "";
-		size_t i = 0;
-		for (std::vector<FoodNatureSelectValue>::iterator it = this->natureSelectedArray.begin(); it != this->natureSelectedArray.end(); it++)
-		{
-			show += (*it).nature_select_name;
-
-			if (i < natureSelectedArray.size() - 1)
-			{
-				show += CLewaimaiString::UnicodeToUTF8(L"、");
-			}
-
-			i++;
-		}
-
-		return show;
-	}
-};
+#include "CDiandanOrderItem.h"
 
 /**
  * 点单里面的一个“订单”,每个选中的商品被加入订单,通过订单数据来计算价格,渲染界面,提交订单也是通过这个数据来提交
@@ -172,6 +31,8 @@ public:
 
 	std::string getTotalPriceShow();
 
+	double getTotalPrice();
+
 	CDiandanOrderItem getDiandanOrderItem(int index);
 
 	//这个函数的逻辑是选择一个新商品的时候,与已有商品进行对比,看看是加一个新的商品,还是对已有商品增加数量
@@ -180,8 +41,6 @@ public:
 
 	void UpdateItemGuige(int index, std::vector<FoodNatureSelectValue>& natureSelectedArray);
 
-	void UpdateTotalPriceShow();
-
 	//给某一项添加一个数量
 	void AddNum(int index);
 
@@ -198,4 +57,13 @@ public:
 	void Clear();
 
 	void SetMemo(std::string memo);
+
+	//判断某个商品券是否能使用,如果可以返回true,如果不行返回false,youhui_value是对应的商品券优惠金额
+	bool UseShangpinquan(std::string shangpinquan_food_id, double& youhui_value);
+
+	//判断某个次卡是否能使用,如果可以返回true,如果不行返回false,youhui_value是对应的商品券优惠金额
+	//is_shangpinquan_dikou 同一个商品,是否被商品券抵扣过了,用于商品券和次卡抵扣同一个商品时候的处理
+	bool UseCikaDikou(std::string cika_food_id, double& youhui_value, bool is_shangpinquan_dikou);
+
+	double getTotalMemberYouhui(std::string member_level);
 };

+ 197 - 0
zhipuzi_pos_windows/zhipuzi/CDiandanOrderItem.cpp

@@ -0,0 +1,197 @@
+#include "../pch/pch.h"
+#include "CDiandanOrderItem.h"
+
+bool CDiandanOrderItem::operator==(CDiandanOrderItem& t)
+{
+	if (this->m_is_taocan != t.m_is_taocan)
+	{
+		return false;
+	}
+
+	if (this->m_is_taocan == true)
+	{
+		if (this->foodpackage_id != t.foodpackage_id)
+		{
+			return false;
+		}
+
+		int i = 0;
+		for (std::vector<FoodNatureSelectValue>::iterator it = this->natureSelectedArray.begin(); it != this->natureSelectedArray.end(); it++)
+		{
+			if ((*it).nature_name != t.natureSelectedArray[i].nature_name)
+			{
+				return false;
+			}
+
+			if ((*it).nature_select_index != t.natureSelectedArray[i].nature_select_index)
+			{
+				return false;
+			}
+
+			i++;
+		}
+	}
+	else
+	{
+		if (this->food_id != t.food_id)
+		{
+			return false;
+		}
+
+		if (this->is_nature != t.is_nature)
+		{
+			return false;
+		}
+
+		if (this->is_nature == true)
+		{
+			int i = 0;
+			for (std::vector<FoodNatureSelectValue>::iterator it = this->natureSelectedArray.begin(); it != this->natureSelectedArray.end(); it++)
+			{
+				if ((*it).nature_name != t.natureSelectedArray[i].nature_name)
+				{
+					return false;
+				}
+
+				if ((*it).nature_select_index != t.natureSelectedArray[i].nature_select_index)
+				{
+					return false;
+				}
+
+				i++;
+			}
+		}
+	}
+
+	return true;
+}
+
+void CDiandanOrderItem::SetFoodInfo(CFood info)
+{
+	m_foodinfo = info;
+}
+
+void CDiandanOrderItem::SetFoodpackageInfo(CFoodpackage info)
+{
+	m_foodpackageinfo = info;
+
+	m_is_taocan = true;
+}
+
+void CDiandanOrderItem::SetIsTaocan(bool is_taocan)
+{
+	m_is_taocan = is_taocan;
+}
+
+CFood CDiandanOrderItem::GetFoodInfo()
+{
+	return m_foodinfo;
+}
+
+CFoodpackage CDiandanOrderItem::GetFoodpackageInfo()
+{
+	return m_foodpackageinfo;
+}
+
+bool CDiandanOrderItem::GetIsTaocan()
+{
+	return m_is_taocan;
+}
+
+//根据当前选中的商品属性、是否打包、会员价、是否使用商品券等,计算商品的展示价格
+void CDiandanOrderItem::UpdateShowPrice()
+{
+	if (m_is_taocan == true)
+	{
+		show_price = CLewaimaiString::DoubleToString(std::stod(price) * std::stod(num), 2);
+	}
+	else
+	{
+		if (!is_nature)
+		{
+			show_price = CLewaimaiString::DoubleToString(std::stod(price) * std::stod(num), 2);
+		}
+		else
+		{
+			int nature_price = 0;
+			for (std::vector<FoodNatureSelectValue>::iterator it = this->natureSelectedArray.begin(); it != this->natureSelectedArray.end(); it++)
+			{
+				nature_price += (*it).nature_select_value;
+			}
+
+			double new_price = std::stod(price) + nature_price;
+
+			show_price = CLewaimaiString::DoubleToString(new_price * std::stod(num), 2);
+		}
+	}
+}
+
+//获取用于展示的属性名字
+std::string CDiandanOrderItem::getNatureShow()
+{
+	std::string show = "";
+
+	if (m_is_taocan)
+	{
+		size_t i = 0;
+		for (std::vector<FoodNatureSelectValue>::iterator it = this->natureSelectedArray.begin(); it != this->natureSelectedArray.end(); it++)
+		{
+			show += (*it).nature_select_name;
+
+			if (i < natureSelectedArray.size() - 1)
+			{
+				show += CLewaimaiString::UnicodeToUTF8(L"、");
+			}
+
+			i++;
+		}
+	}
+	else
+	{
+		if (!is_nature)
+		{
+			return "";
+		}
+
+		size_t i = 0;
+		for (std::vector<FoodNatureSelectValue>::iterator it = this->natureSelectedArray.begin(); it != this->natureSelectedArray.end(); it++)
+		{
+			show += (*it).nature_select_name;
+
+			if (i < natureSelectedArray.size() - 1)
+			{
+				show += CLewaimaiString::UnicodeToUTF8(L"、");
+			}
+
+			i++;
+		}
+	}
+
+	return show;
+}
+
+double CDiandanOrderItem::getMemberYouhui(std::string member_level)
+{
+	if (is_member_price_used == false)
+	{
+		return 0;
+	}
+
+	for (std::vector<MemberPrice>::iterator it = m_member_price.begin(); it != m_member_price.end(); it++)
+	{
+		MemberPrice cur = *it;
+
+		if (cur.level == member_level)
+		{
+			double member_food_price = atof(cur.price.c_str());
+
+			double yuan_price = atof(price.c_str());
+
+			double chajia =  (yuan_price - member_food_price) * atof(num.c_str());
+
+			return chajia;
+		}
+	}
+
+	return 0;
+}

+ 81 - 0
zhipuzi_pos_windows/zhipuzi/CDiandanOrderItem.h

@@ -0,0 +1,81 @@
+#pragma once
+
+#include "../zhipuzi/CFood.h"
+#include "../zhipuzi/CFoodpackage.h"
+
+#include "../control/CDiandanNatureItemUI.h"
+
+class MemberPrice
+{
+public:
+	std::string id;
+	std::string level;
+	std::string price;
+};
+
+/**
+ * 订单中的一个商品
+ */
+class CDiandanOrderItem
+{
+public:
+	//是否套餐的Item,因为目前套餐和普通商品都是用同一个Item类
+	bool m_is_taocan = false;
+
+	//普通商品才有的信息
+	std::string food_id;
+	std::string food_name;
+	std::string type_id;
+	bool is_weight = false;
+
+	bool is_nature = false;
+
+	//会员价
+	bool is_member_price_used;
+	std::vector<MemberPrice> m_member_price;
+
+	//套餐才有的信息
+	std::string foodpackage_id;
+	std::string foodpackage_name;
+
+	//这个是套餐和普通商品共有的信息
+	std::string price;
+	bool is_dabao = false;
+	std::string dabao_money;
+	std::string num;
+
+	//这个用来存储所有属性选择的信息,每个属性选择的是第几个,什么价格等等
+	std::vector<FoodNatureSelectValue> natureSelectedArray;
+
+	//这个是商品对外展示的价格,根据数量和属性来计算的
+	std::string show_price;
+
+private:
+	CFood m_foodinfo;
+	CFoodpackage m_foodpackageinfo;
+
+public:
+
+	bool operator==(CDiandanOrderItem& t);
+
+	void SetFoodInfo(CFood info);
+
+	void SetFoodpackageInfo(CFoodpackage info);
+
+	void SetIsTaocan(bool is_taocan);
+
+	CFood GetFoodInfo();
+
+	CFoodpackage GetFoodpackageInfo();
+
+	bool GetIsTaocan();
+
+	//根据当前选中的商品属性、是否打包、会员价、是否使用商品券等,计算商品的展示价格
+	void UpdateShowPrice();
+
+	//获取用于展示的属性名字
+	std::string getNatureShow();
+
+	//根据当前会员等级,计算该商品的会员优惠金额
+	double getMemberYouhui(std::string member_level);
+};

+ 3 - 0
zhipuzi_pos_windows/zhipuzi/CShopinfo.h

@@ -128,10 +128,13 @@ public:
 	std::string m_discountlimitmember;
 	std::string m_open_addservice;
 	std::vector<AddService> m_addservice;
+
 	std::string m_open_promotion;
 	std::vector<Promotion> m_promotion;
+
 	std::string m_is_eq_card_discount;
 	std::string m_eq_card_discount_value;
+
 	std::vector<DiscountInfo> m_discount_info;
 	std::string m_is_only_promotion;
 	std::string m_is_only_discount;

+ 4 - 0
zhipuzi_pos_windows/zhipuzi_pos_windows.vcxproj

@@ -225,6 +225,8 @@ copy $(ProjectDir)conf\ $(SolutionDir)bin\$(Platform)\$(Configuration)\conf\</Co
     </PostBuildEvent>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClInclude Include="wnd\CYouhuiShowWnd.h" />
+    <ClInclude Include="zhipuzi\CDiandanOrderItem.h" />
     <ClInclude Include="zhipuzi\CShopinfo.h" />
     <ClInclude Include="wnd\CMemoWnd.h" />
     <ClInclude Include="control\CDiandanNatureItemUI.h" />
@@ -272,6 +274,8 @@ copy $(ProjectDir)conf\ $(SolutionDir)bin\$(Platform)\$(Configuration)\conf\</Co
     <ClInclude Include="helper\CSystem.h" />
   </ItemGroup>
   <ItemGroup>
+    <ClCompile Include="wnd\CYouhuiShowWnd.cpp" />
+    <ClCompile Include="zhipuzi\CDiandanOrderItem.cpp" />
     <ClCompile Include="zhipuzi\CShopinfo.cpp" />
     <ClCompile Include="wnd\CMemoWnd.cpp" />
     <ClCompile Include="control\CDiandanNatureItemUI.cpp" />

+ 12 - 0
zhipuzi_pos_windows/zhipuzi_pos_windows.vcxproj.filters

@@ -150,6 +150,12 @@
     <ClInclude Include="zhipuzi\CShopinfo.h">
       <Filter>头文件</Filter>
     </ClInclude>
+    <ClInclude Include="zhipuzi\CDiandanOrderItem.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="wnd\CYouhuiShowWnd.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="pch\pch.cpp">
@@ -263,6 +269,12 @@
     <ClCompile Include="zhipuzi\CShopinfo.cpp">
       <Filter>源文件</Filter>
     </ClCompile>
+    <ClCompile Include="zhipuzi\CDiandanOrderItem.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="wnd\CYouhuiShowWnd.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <Image Include="resource\zhipuzi.ico">