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