|
@@ -0,0 +1,1282 @@
|
|
|
|
|
+#include "../pch/pch.h"
|
|
|
|
|
+#include "CYubaozhuangbiaoqianPageUI.h"
|
|
|
|
|
+
|
|
|
|
|
+#include "../control/ControlEx.h"
|
|
|
|
|
+#include "../tool/CSqlite3.h"
|
|
|
|
|
+
|
|
|
|
|
+#include "../wnd/CDiandanNatureWnd.h"
|
|
|
|
|
+#include "../wnd/CMemoWnd.h"
|
|
|
|
|
+#include "../wnd/CYouhuiShowWnd.h"
|
|
|
|
|
+#include "../wnd/CMemberLoginWnd.h"
|
|
|
|
|
+#include "../wnd/CSaomaYouhuiquanWnd.h"
|
|
|
|
|
+#include "../wnd/CSaomaShangpinquanWnd.h"
|
|
|
|
|
+#include "../wnd/CSaomaCikaWnd.h"
|
|
|
|
|
+#include "../wnd/CSaomaQuanyikaWnd.h"
|
|
|
|
|
+#include "../wnd/CCanpaiWnd.h"
|
|
|
|
|
+#include "../wnd/CWeixinzhifuShoukuanWnd.h"
|
|
|
|
|
+#include "../wnd/CHuiyuanShoukuanWnd.h"
|
|
|
|
|
+#include "../wnd/CXianjinShoukuanWnd.h"
|
|
|
|
|
+#include "../wnd/CFulikaShoukuanWnd.h"
|
|
|
|
|
+#include "../wnd/CZidingyiShoukuanWnd.h"
|
|
|
|
|
+#include "../wnd/CChengzhongWnd.h"
|
|
|
|
|
+#include "../wnd/CGuadanWnd.h"
|
|
|
|
|
+#include "../wnd/CNumInputWnd.h"
|
|
|
|
|
+#include "../wnd/CHuiyuanInfoShowWnd.h"
|
|
|
|
|
+
|
|
|
|
|
+#include "../print/CPosPrinter.h"
|
|
|
|
|
+
|
|
|
|
|
+#include "../tool/CShuangpingTool.h"
|
|
|
|
|
+
|
|
|
|
|
+#include "../worker/CChengzhongWorker.h"
|
|
|
|
|
+#include "../worker/CDiandanAIShibieWorker.h"
|
|
|
|
|
+
|
|
|
|
|
+CYubaozhuangbiaoqianPageUI::CYubaozhuangbiaoqianPageUI()
|
|
|
|
|
+{
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+CYubaozhuangbiaoqianPageUI::~CYubaozhuangbiaoqianPageUI()
|
|
|
|
|
+{
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void CYubaozhuangbiaoqianPageUI::InitControl()
|
|
|
|
|
+{
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+//初始化当前页面的展示,处理默认展示效果,在页面被加载的时候调用
|
|
|
|
|
+void CYubaozhuangbiaoqianPageUI::InitShow()
|
|
|
|
|
+{
|
|
|
|
|
+ //先初始化商品分类
|
|
|
|
|
+ this->InitFoodtypeShow();
|
|
|
|
|
+
|
|
|
|
|
+ //再初始化商品显示
|
|
|
|
|
+ this->InitFoodShow();
|
|
|
|
|
+
|
|
|
|
|
+ CHorizontalLayoutUI* chegnzhongLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("diandan_page_chengzhong_layout")));
|
|
|
|
|
+ if (CSetting::GetInstance()->GetParam("setting_dianzicheng_is_lianjie") == "0")
|
|
|
|
|
+ {
|
|
|
|
|
+ chegnzhongLayout->SetVisible(false);
|
|
|
|
|
+
|
|
|
|
|
+ m_is_dianzicheng_lianjie = false;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ chegnzhongLayout->SetVisible(true);
|
|
|
|
|
+
|
|
|
|
|
+ m_is_dianzicheng_lianjie = true;
|
|
|
|
|
+
|
|
|
|
|
+ //刷新一下重量显示
|
|
|
|
|
+ this->HandleChengzhongValueChange();
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void CYubaozhuangbiaoqianPageUI::RefreshShow()
|
|
|
|
|
+{
|
|
|
|
|
+ //初始化商品显示(因为这里要刷新商品库存状态)
|
|
|
|
|
+ this->InitFoodShow();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void CYubaozhuangbiaoqianPageUI::InitFoodtypeShow()
|
|
|
|
|
+{
|
|
|
|
|
+ //初始化商品渲染相关的信息
|
|
|
|
|
+ m_foodtypeLayout = static_cast<CContainerUI*>(this->FindSubControl(_T("diandan_fenlei_layout")));
|
|
|
|
|
+ m_foodtypeLayout->RemoveAll();
|
|
|
|
|
+
|
|
|
|
|
+ std::string is_ai_shibie = CSetting::GetInstance()->GetParam("setting_is_ai_recognition_open");
|
|
|
|
|
+ if (is_ai_shibie == "1")
|
|
|
|
|
+ {
|
|
|
|
|
+ m_is_ai_shibie = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ m_is_ai_shibie = false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ CSqlite3 sqlite;
|
|
|
|
|
+ m_nFoodpackageNum = sqlite.GetFoodpackageNum();
|
|
|
|
|
+ m_types = sqlite.GetFoodtypes(); //只包含收银机显示的分类
|
|
|
|
|
+
|
|
|
|
|
+ if (m_is_ai_shibie == true)
|
|
|
|
|
+ {
|
|
|
|
|
+ m_cur_type_id = "ai";
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (m_nFoodpackageNum > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ //默认选中的分类是商品套餐
|
|
|
|
|
+ m_cur_type_id = "taocan";
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ //没有套餐,默认选中第一个商品分类
|
|
|
|
|
+ if (m_types.size() > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ m_cur_type_id = m_types[0].id;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ m_curFoodtypeOption = NULL;
|
|
|
|
|
+
|
|
|
|
|
+ if (is_ai_shibie == "1")
|
|
|
|
|
+ {
|
|
|
|
|
+ CDialogBuilder builder;
|
|
|
|
|
+ CDialogBuilderCallbackEx cb;
|
|
|
|
|
+
|
|
|
|
|
+ CFoodtypeOptionUI* pItem = static_cast<CFoodtypeOptionUI*>(builder.Create(_T("foodtype_option.xml"), (UINT)0, &cb, m_pManager));
|
|
|
|
|
+
|
|
|
|
|
+ pItem->SetName(L"AI识别结果");
|
|
|
|
|
+ pItem->SetTypeId("ai");
|
|
|
|
|
+ pItem->SetGroup(L"diandan_foodtype");
|
|
|
|
|
+
|
|
|
|
|
+ m_foodtypeLayout->Add(pItem);
|
|
|
|
|
+
|
|
|
|
|
+ if (m_cur_type_id == "ai")
|
|
|
|
|
+ {
|
|
|
|
|
+ m_curFoodtypeOption = pItem;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //先判断有没有套餐分类
|
|
|
|
|
+ if (m_nFoodpackageNum > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ CDialogBuilder builder;
|
|
|
|
|
+ CDialogBuilderCallbackEx cb;
|
|
|
|
|
+
|
|
|
|
|
+ CFoodtypeOptionUI* pItem = static_cast<CFoodtypeOptionUI*>(builder.Create(_T("foodtype_option.xml"), (UINT)0, &cb, m_pManager));
|
|
|
|
|
+
|
|
|
|
|
+ pItem->SetName(L"商品套餐");
|
|
|
|
|
+ pItem->SetTypeId("taocan");
|
|
|
|
|
+ pItem->SetTaocan();
|
|
|
|
|
+ pItem->SetGroup(L"diandan_foodtype");
|
|
|
|
|
+
|
|
|
|
|
+ m_foodtypeLayout->Add(pItem);
|
|
|
|
|
+
|
|
|
|
|
+ if (m_cur_type_id == "taocan")
|
|
|
|
|
+ {
|
|
|
|
|
+ m_curFoodtypeOption = pItem;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //接下来开始处理商品分类
|
|
|
|
|
+ for (std::vector<CFoodType>::iterator it = m_types.begin(); it != m_types.end(); it++)
|
|
|
|
|
+ {
|
|
|
|
|
+ CFoodType type = *it;
|
|
|
|
|
+
|
|
|
|
|
+ CDialogBuilder builder;
|
|
|
|
|
+ CDialogBuilderCallbackEx cb;
|
|
|
|
|
+
|
|
|
|
|
+ CFoodtypeOptionUI* pItem = static_cast<CFoodtypeOptionUI*>(builder.Create(_T("foodtype_option.xml"), (UINT)0, &cb, m_pManager));
|
|
|
|
|
+
|
|
|
|
|
+ pItem->SetName(CLewaimaiString::UTF8ToUnicode(type.name));
|
|
|
|
|
+ pItem->SetTypeId(type.id);
|
|
|
|
|
+ pItem->SetGroup(L"diandan_foodtype");
|
|
|
|
|
+
|
|
|
|
|
+ m_foodtypeLayout->Add(pItem);
|
|
|
|
|
+
|
|
|
|
|
+ if (m_cur_type_id == type.id)
|
|
|
|
|
+ {
|
|
|
|
|
+ m_curFoodtypeOption = pItem;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (m_curFoodtypeOption != NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ m_curFoodtypeOption->Selected(true, true);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ UpdateFoodtypePos();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void CYubaozhuangbiaoqianPageUI::UpdateFoodtypePos()
|
|
|
|
|
+{
|
|
|
|
|
+ int nFoodtypeNum = m_types.size();
|
|
|
|
|
+
|
|
|
|
|
+ if (m_is_ai_shibie == true)
|
|
|
|
|
+ {
|
|
|
|
|
+ nFoodtypeNum++;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (m_nFoodpackageNum > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ nFoodtypeNum++;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //添加支付方式
|
|
|
|
|
+ int nWidth = m_nPageWidth;
|
|
|
|
|
+ if (nWidth == 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //根据宽度计算每行显示的数量
|
|
|
|
|
+ int nMeihangNum = (nWidth - 381) / 140;
|
|
|
|
|
+
|
|
|
|
|
+ int num = 0;
|
|
|
|
|
+
|
|
|
|
|
+ CContainerUI* pFenleiLayout = static_cast<CContainerUI*>(this->FindSubControl(_T("diandan_fenlei_layout")));
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < nFoodtypeNum; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ CFoodtypeOptionUI* curItem = static_cast<CFoodtypeOptionUI*>(pFenleiLayout->GetItemAt(i));
|
|
|
|
|
+
|
|
|
|
|
+ int curRow = num / nMeihangNum + 1;
|
|
|
|
|
+ int curCol = num % nMeihangNum + 1;
|
|
|
|
|
+
|
|
|
|
|
+ RECT rect;
|
|
|
|
|
+ rect.left = (curCol - 1) * 140 + 10;
|
|
|
|
|
+ rect.right = rect.left + 130;
|
|
|
|
|
+ rect.top = (curRow - 1) * 52 + 10;
|
|
|
|
|
+ rect.bottom = rect.top + 42;
|
|
|
|
|
+
|
|
|
|
|
+ // 强制设置固定大小和位置
|
|
|
|
|
+ SIZE size;
|
|
|
|
|
+ size.cx = rect.left;
|
|
|
|
|
+ size.cy = rect.top;
|
|
|
|
|
+
|
|
|
|
|
+ curItem->SetFixedXY(size);
|
|
|
|
|
+ curItem->SetFixedWidth(rect.right - rect.left);
|
|
|
|
|
+ curItem->SetFixedHeight(rect.bottom - rect.top);
|
|
|
|
|
+
|
|
|
|
|
+ num++;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //调整区域高度
|
|
|
|
|
+ int lastRow = (num - 1) / nMeihangNum + 1;
|
|
|
|
|
+ pFenleiLayout->SetFixedHeight(lastRow * 52 + 10);
|
|
|
|
|
+
|
|
|
|
|
+ //处理滚动条问题
|
|
|
|
|
+ CVerticalLayoutUI* pFenleiScrollLayout = static_cast<CVerticalLayoutUI*>(this->FindSubControl(_T("diandan_fenlei_layout_scrolllayout")));
|
|
|
|
|
+ if (lastRow > 2)
|
|
|
|
|
+ {
|
|
|
|
|
+ lastRow = 2;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ pFenleiScrollLayout->SetFixedHeight(lastRow * 52 + 10);
|
|
|
|
|
+
|
|
|
|
|
+ SIZE size;
|
|
|
|
|
+ size.cx = 0;
|
|
|
|
|
+ size.cy = 0;
|
|
|
|
|
+ pFenleiScrollLayout->SetScrollPos(size);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void CYubaozhuangbiaoqianPageUI::InitFoodShow()
|
|
|
|
|
+{
|
|
|
|
|
+ std::string setting_xianshi_is_youtu = CSetting::GetInstance()->GetParam("setting_xianshi_is_youtu");
|
|
|
|
|
+
|
|
|
|
|
+ m_foodLayout = static_cast<CTileLayoutUI*>(this->FindSubControl(_T("diandan_foodlist")));
|
|
|
|
|
+ m_foodLayout->RemoveAll();
|
|
|
|
|
+
|
|
|
|
|
+ std::wstring xml_name;
|
|
|
|
|
+
|
|
|
|
|
+ if (setting_xianshi_is_youtu == "1")
|
|
|
|
|
+ {
|
|
|
|
|
+ SIZE itemsize;
|
|
|
|
|
+ itemsize.cx = 130;
|
|
|
|
|
+ itemsize.cy = 200;
|
|
|
|
|
+ m_foodLayout->SetItemSize(itemsize);
|
|
|
|
|
+
|
|
|
|
|
+ xml_name = _T("diandan_fooditem_youtu.xml");
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (setting_xianshi_is_youtu == "2")
|
|
|
|
|
+ {
|
|
|
|
|
+ SIZE itemsize;
|
|
|
|
|
+ itemsize.cx = 230;
|
|
|
|
|
+ itemsize.cy = 90;
|
|
|
|
|
+ m_foodLayout->SetItemSize(itemsize);
|
|
|
|
|
+
|
|
|
|
|
+ xml_name = _T("diandan_fooditem_youtu_2.xml");
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (setting_xianshi_is_youtu == "3")
|
|
|
|
|
+ {
|
|
|
|
|
+ SIZE itemsize;
|
|
|
|
|
+ itemsize.cx = 140;
|
|
|
|
|
+ itemsize.cy = 120;
|
|
|
|
|
+ m_foodLayout->SetItemSize(itemsize);
|
|
|
|
|
+
|
|
|
|
|
+ xml_name = _T("diandan_fooditem_youtu_3.xml");
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ SIZE itemsize;
|
|
|
|
|
+ itemsize.cx = 140;
|
|
|
|
|
+ itemsize.cy = 100;
|
|
|
|
|
+ m_foodLayout->SetItemSize(itemsize);
|
|
|
|
|
+
|
|
|
|
|
+ xml_name = _T("diandan_fooditem_wutu.xml");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //如果当前一个分类都没有,那么就不处理了
|
|
|
|
|
+ if (m_cur_type_id == "")
|
|
|
|
|
+ {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (m_cur_type_id == "ai")
|
|
|
|
|
+ {
|
|
|
|
|
+ //把AI识别的结果展示出来
|
|
|
|
|
+ std::string ai_name = CDiandanAIShibieWorker::GetInstance()->GetShibieFoodname();
|
|
|
|
|
+ if (ai_name == "Unknown" || ai_name == "")
|
|
|
|
|
+ {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ CSqlite3 sqlite;
|
|
|
|
|
+ std::vector<CFood> foodlist = sqlite.GetFoodByFoodname(ai_name);
|
|
|
|
|
+
|
|
|
|
|
+ for (std::vector<CFood>::iterator it = foodlist.begin(); it != foodlist.end(); it++)
|
|
|
|
|
+ {
|
|
|
|
|
+ CFood food = *it;
|
|
|
|
|
+
|
|
|
|
|
+ CDialogBuilder builder;
|
|
|
|
|
+ CDialogBuilderCallbackEx cb;
|
|
|
|
|
+
|
|
|
|
|
+ CDiandanFoodItemUI* pItem = static_cast<CDiandanFoodItemUI*>(builder.Create(xml_name.c_str(), (UINT)0, &cb, m_pManager));
|
|
|
|
|
+
|
|
|
|
|
+ m_foodLayout->Add(pItem);
|
|
|
|
|
+
|
|
|
|
|
+ pItem->SetYoutuModel(setting_xianshi_is_youtu);
|
|
|
|
|
+ pItem->SetFoodInfo(food);
|
|
|
|
|
+ pItem->UpdateShow();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (m_cur_type_id == "taocan")
|
|
|
|
|
+ {
|
|
|
|
|
+ //选择的是套餐分类
|
|
|
|
|
+ CSqlite3 sqlite;
|
|
|
|
|
+ std::vector<CFoodpackage> foodlist = sqlite.GetFoodpackages(true);
|
|
|
|
|
+
|
|
|
|
|
+ for (std::vector<CFoodpackage>::iterator it = foodlist.begin(); it != foodlist.end(); it++)
|
|
|
|
|
+ {
|
|
|
|
|
+ CFoodpackage food = *it;
|
|
|
|
|
+
|
|
|
|
|
+ CDialogBuilder builder;
|
|
|
|
|
+ CDialogBuilderCallbackEx cb;
|
|
|
|
|
+
|
|
|
|
|
+ CDiandanFoodItemUI* pItem = static_cast<CDiandanFoodItemUI*>(builder.Create(xml_name.c_str(), (UINT)0, &cb, m_pManager));
|
|
|
|
|
+
|
|
|
|
|
+ m_foodLayout->Add(pItem);
|
|
|
|
|
+
|
|
|
|
|
+ pItem->SetYoutuModel(setting_xianshi_is_youtu);
|
|
|
|
|
+ pItem->SetFoodpackageInfo(food);
|
|
|
|
|
+ pItem->UpdateShow();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (m_cur_type_id == "sousuo")
|
|
|
|
|
+ {
|
|
|
|
|
+ if (CLewaimaiString::is_only_number(m_sousuo_foodname))
|
|
|
|
|
+ {
|
|
|
|
|
+ //说明是纯数字,按商品条码来搜索
|
|
|
|
|
+ CSqlite3 sqlite;
|
|
|
|
|
+ CFood food;
|
|
|
|
|
+
|
|
|
|
|
+ bool ret = sqlite.GetFoodByBarcode(m_sousuo_foodname, food);
|
|
|
|
|
+
|
|
|
|
|
+ if (ret)
|
|
|
|
|
+ {
|
|
|
|
|
+ CDialogBuilder builder;
|
|
|
|
|
+ CDialogBuilderCallbackEx cb;
|
|
|
|
|
+
|
|
|
|
|
+ CDiandanFoodItemUI* pItem = static_cast<CDiandanFoodItemUI*>(builder.Create(xml_name.c_str(), (UINT)0, &cb, m_pManager));
|
|
|
|
|
+
|
|
|
|
|
+ m_foodLayout->Add(pItem);
|
|
|
|
|
+
|
|
|
|
|
+ pItem->SetYoutuModel(setting_xianshi_is_youtu);
|
|
|
|
|
+ pItem->SetFoodInfo(food);
|
|
|
|
|
+ pItem->UpdateShow();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ //当商品名字来搜索
|
|
|
|
|
+ CSqlite3 sqlite;
|
|
|
|
|
+ std::vector<CFood> foodlist = sqlite.GetFoodByFoodname(m_sousuo_foodname);
|
|
|
|
|
+
|
|
|
|
|
+ for (std::vector<CFood>::iterator it = foodlist.begin(); it != foodlist.end(); it++)
|
|
|
|
|
+ {
|
|
|
|
|
+ CFood food = *it;
|
|
|
|
|
+
|
|
|
|
|
+ CDialogBuilder builder;
|
|
|
|
|
+ CDialogBuilderCallbackEx cb;
|
|
|
|
|
+
|
|
|
|
|
+ CDiandanFoodItemUI* pItem = static_cast<CDiandanFoodItemUI*>(builder.Create(xml_name.c_str(), (UINT)0, &cb, m_pManager));
|
|
|
|
|
+
|
|
|
|
|
+ m_foodLayout->Add(pItem);
|
|
|
|
|
+
|
|
|
|
|
+ pItem->SetYoutuModel(setting_xianshi_is_youtu);
|
|
|
|
|
+ pItem->SetFoodInfo(food);
|
|
|
|
|
+ pItem->UpdateShow();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ //选择的是普通商品分类
|
|
|
|
|
+ CSqlite3 sqlite;
|
|
|
|
|
+ std::vector<CFood> foodlist = sqlite.GetFoodByTypeid(m_cur_type_id);
|
|
|
|
|
+
|
|
|
|
|
+ for (std::vector<CFood>::iterator it = foodlist.begin(); it != foodlist.end(); it++)
|
|
|
|
|
+ {
|
|
|
|
|
+ CFood food = *it;
|
|
|
|
|
+
|
|
|
|
|
+ CDialogBuilder builder;
|
|
|
|
|
+ CDialogBuilderCallbackEx cb;
|
|
|
|
|
+
|
|
|
|
|
+ CDiandanFoodItemUI* pItem = static_cast<CDiandanFoodItemUI*>(builder.Create(xml_name.c_str(), (UINT)0, &cb, m_pManager));
|
|
|
|
|
+
|
|
|
|
|
+ m_foodLayout->Add(pItem);
|
|
|
|
|
+
|
|
|
|
|
+ pItem->SetYoutuModel(setting_xianshi_is_youtu);
|
|
|
|
|
+ pItem->SetFoodInfo(food);
|
|
|
|
|
+ pItem->UpdateShow();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+//处理按钮点击类事件
|
|
|
|
|
+void CYubaozhuangbiaoqianPageUI::HandleClickMsg(TNotifyUI& msg)
|
|
|
|
|
+{
|
|
|
|
|
+ CDuiString name = msg.pSender->GetName();
|
|
|
|
|
+
|
|
|
|
|
+ if (name == L"diandan_fooditem")
|
|
|
|
|
+ {
|
|
|
|
|
+ CDiandanFoodItemUI* fooditemUI = static_cast<CDiandanFoodItemUI*>(msg.pSender);
|
|
|
|
|
+
|
|
|
|
|
+ m_cur_click_food_item = fooditemUI;
|
|
|
|
|
+
|
|
|
|
|
+ this->ClickFoodAction();
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (name == L"diandan_food_search_clear")
|
|
|
|
|
+ {
|
|
|
|
|
+ CEditUI* m_pEdit = static_cast<CEditUI*>(m_pManager->FindControl(_T("diandan_food_search_edit")));
|
|
|
|
|
+ m_pEdit->SetText(L"");
|
|
|
|
|
+
|
|
|
|
|
+ StopSerachFood();
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (name == L"btn_diandan_qianxiang")
|
|
|
|
|
+ {
|
|
|
|
|
+ CPosPrinter printer;
|
|
|
|
|
+ printer.OpenQianxiang();
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (name == L"diandan_page_chengzhong_zhiling")
|
|
|
|
|
+ {
|
|
|
|
|
+ this->ZhiLing();
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (name == L"diandan_page_chengzhong_qupi")
|
|
|
|
|
+ {
|
|
|
|
|
+ this->Qupi();
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+//处理option切换事件
|
|
|
|
|
+void CYubaozhuangbiaoqianPageUI::HandleSelectChangeMsg(TNotifyUI& msg)
|
|
|
|
|
+{
|
|
|
|
|
+ CDuiString name = msg.pSender->GetName();
|
|
|
|
|
+
|
|
|
|
|
+ COptionUI* curOption = static_cast<COptionUI*>(msg.pSender);
|
|
|
|
|
+ std::wstring groupname = curOption->GetGroup();
|
|
|
|
|
+
|
|
|
|
|
+ if (groupname == L"diandan_foodtype")
|
|
|
|
|
+ {
|
|
|
|
|
+ //商品分类切换
|
|
|
|
|
+ CFoodtypeOptionUI* typeUI = static_cast<CFoodtypeOptionUI*>(curOption);
|
|
|
|
|
+ std::string id = typeUI->GetTypeId();
|
|
|
|
|
+
|
|
|
|
|
+ if (m_cur_type_id != id)
|
|
|
|
|
+ {
|
|
|
|
|
+ //切换了商品分类
|
|
|
|
|
+ m_curFoodtypeOption = static_cast<CFoodtypeOptionUI*>(msg.pSender);
|
|
|
|
|
+ m_cur_type_id = id;
|
|
|
|
|
+
|
|
|
|
|
+ this->InitFoodShow();
|
|
|
|
|
+
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+//处理下拉框、radio的切换事件
|
|
|
|
|
+void CYubaozhuangbiaoqianPageUI::HandleItemSelectMsg(TNotifyUI& msg)
|
|
|
|
|
+{
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+//处理编辑框输入内容改变事件
|
|
|
|
|
+void CYubaozhuangbiaoqianPageUI::HandleTextChangedMsg(TNotifyUI& msg)
|
|
|
|
|
+{
|
|
|
|
|
+ CDuiString name = msg.pSender->GetName();
|
|
|
|
|
+
|
|
|
|
|
+ if (name == L"diandan_food_search_edit")
|
|
|
|
|
+ {
|
|
|
|
|
+ //商品搜索框的输入事件
|
|
|
|
|
+ CEditUI* m_pEdit = static_cast<CEditUI*>(m_pManager->FindControl(_T("diandan_food_search_edit")));
|
|
|
|
|
+ std::wstring ws_Value = m_pEdit->GetText();
|
|
|
|
|
+ std::string strValue = CLewaimaiString::UnicodeToUTF8(ws_Value);
|
|
|
|
|
+
|
|
|
|
|
+ if (strValue.length() == 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ //搜索词被清空了,退出搜索
|
|
|
|
|
+ this->StopSerachFood();
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ //搜索词没清空,进入搜索
|
|
|
|
|
+ this->StartSearchFood(strValue);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+//处理扫码枪捕捉到的扫码信息
|
|
|
|
|
+void CYubaozhuangbiaoqianPageUI::HandleTextCapture(std::string content)
|
|
|
|
|
+{
|
|
|
|
|
+ if (content == "")
|
|
|
|
|
+ {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (m_is_show_modal_wnd == true)
|
|
|
|
|
+ {
|
|
|
|
|
+ m_curModalWnd->HandleTextCapture(content);
|
|
|
|
|
+
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //没有任何弹框,那么就是按扫描商品条码来处理
|
|
|
|
|
+ bool ret = this->SaomiaoBarcode(content);
|
|
|
|
|
+ if (ret == true)
|
|
|
|
|
+ {
|
|
|
|
|
+ //已经找到了条码,那么就处理完了
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (content.length() != 12 && content.length() != 13 && content.length() != 17 && content.length() != 18)
|
|
|
|
|
+ {
|
|
|
|
|
+ //位数不对,那肯定不是称重条码
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ //如果没有找到条码,就找一下是不是称重的标签秤的码,这个时候要对码进行各种分析了
|
|
|
|
|
+ ret = this->BiaoqianchengSaomaBarcode(content);
|
|
|
|
|
+ if (ret == true)
|
|
|
|
|
+ {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+bool CYubaozhuangbiaoqianPageUI::HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
|
+{
|
|
|
|
|
+ if (uMsg == WM_AI_RECOGNITION_SUCCESS)
|
|
|
|
|
+ {
|
|
|
|
|
+ HandleDiandanAIShibieResult();
|
|
|
|
|
+
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (uMsg == WM_CHENGZHONG_SUCCESS)
|
|
|
|
|
+ {
|
|
|
|
|
+ HandleChengzhongValueChange();
|
|
|
|
|
+
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return false;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void CYubaozhuangbiaoqianPageUI::ClickFoodAction()
|
|
|
|
|
+{
|
|
|
|
|
+ bool is_taocan = m_cur_click_food_item->GetIsTaocan();
|
|
|
|
|
+
|
|
|
|
|
+ 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);
|
|
|
|
|
+
|
|
|
|
|
+ if (m_is_show_modal_wnd == true)
|
|
|
|
|
+ {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //先弹框进行选择属性
|
|
|
|
|
+ CDiandanNatureWnd* pNatureFrame = new CDiandanNatureWnd(1);
|
|
|
|
|
+ pNatureFrame->SetFoodItemUI(m_cur_click_food_item);
|
|
|
|
|
+
|
|
|
|
|
+ if (pNatureFrame != NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ m_is_show_modal_wnd = true;
|
|
|
|
|
+ m_curModalWnd = pNatureFrame;
|
|
|
|
|
+
|
|
|
|
|
+ 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;
|
|
|
|
|
+
|
|
|
|
|
+ m_is_show_modal_wnd = false;
|
|
|
|
|
+ delete pNatureFrame;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ m_is_show_modal_wnd = false;
|
|
|
|
|
+ delete pNatureFrame;
|
|
|
|
|
+
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //商品没有商品属性
|
|
|
|
|
+ bool is_add_new = false;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ //点击普通商品之后的处理逻辑
|
|
|
|
|
+ CFood foodinfo = m_cur_click_food_item->GetFoodInfo();
|
|
|
|
|
+
|
|
|
|
|
+ if (foodinfo.stockvalid == "1" && atof(foodinfo.stock.c_str()) < 0.001)
|
|
|
|
|
+ {
|
|
|
|
|
+ //库存为0了,不做任何处理
|
|
|
|
|
+ m_pMainWnd->ShowToast(L"该商品已售完");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ CDiandanOrderItem clickItem;
|
|
|
|
|
+
|
|
|
|
|
+ clickItem.food_id = foodinfo.id;
|
|
|
|
|
+ clickItem.food_name = foodinfo.name;
|
|
|
|
|
+ clickItem.type_id = foodinfo.type_id;
|
|
|
|
|
+ clickItem.price = foodinfo.price;
|
|
|
|
|
+ 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 = CLewaimaiJson::ToString(member_price_info["id"]);
|
|
|
|
|
+ newPirce.level = CLewaimaiJson::ToString(member_price_info["level"]);
|
|
|
|
|
+ newPirce.price = CLewaimaiJson::ToString(member_price_info["price"]);
|
|
|
|
|
+
|
|
|
|
|
+ clickItem.m_member_price.push_back(newPirce);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //把当前点击商品的信息,保存到orderitem里面,方便后面修改规格的时候使用
|
|
|
|
|
+ clickItem.SetFoodInfo(m_cur_click_food_item->GetFoodInfo());
|
|
|
|
|
+ clickItem.SetIsTaocan(false);
|
|
|
|
|
+
|
|
|
|
|
+ if (foodinfo.is_weight == "1")
|
|
|
|
|
+ {
|
|
|
|
|
+ if (m_is_dianzicheng_lianjie == false)
|
|
|
|
|
+ {
|
|
|
|
|
+ //设置中心未连接电子秤
|
|
|
|
|
+ m_pMainWnd->ShowToast(L"未连接电子秤,请检查连接设置");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ clickItem.is_weight = true;
|
|
|
|
|
+
|
|
|
|
|
+ //这里要判断是直接区域称重,还是先弹框再称重
|
|
|
|
|
+ CLabelUI* pLabel = static_cast<CLabelUI*>(this->FindSubControl(_T("diandan_page_label_chengzhong_value")));
|
|
|
|
|
+ std::wstring ws_weight_value = pLabel->GetText();
|
|
|
|
|
+ std::string s_weight_value = CLewaimaiString::UnicodeToUTF8(ws_weight_value);
|
|
|
|
|
+ if (atof(s_weight_value.c_str()) < 0.001)
|
|
|
|
|
+ {
|
|
|
|
|
+ //如果重量为0了,说明还没有称重,这时候要弹出称重框进行称重
|
|
|
|
|
+ if (m_is_show_modal_wnd == true)
|
|
|
|
|
+ {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //这里要弹出称重框,不弹属性框
|
|
|
|
|
+ CChengzhongWnd* pChengzhongFrame = new CChengzhongWnd();
|
|
|
|
|
+
|
|
|
|
|
+ if (pChengzhongFrame != NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ m_is_show_modal_wnd = true;
|
|
|
|
|
+ m_curModalWnd = pChengzhongFrame;
|
|
|
|
|
+
|
|
|
|
|
+ pChengzhongFrame->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
|
|
|
|
|
+ pChengzhongFrame->SetIcon(IDI_ICON_DUILIB);
|
|
|
|
|
+ pChengzhongFrame->CenterWindow();
|
|
|
|
|
+
|
|
|
|
|
+ pChengzhongFrame->SetTitle(CLewaimaiString::UTF8ToUnicode(foodinfo.name));
|
|
|
|
|
+
|
|
|
|
|
+ UINT ret = pChengzhongFrame->ShowModal();
|
|
|
|
|
+
|
|
|
|
|
+ if (ret == IDOK)
|
|
|
|
|
+ {
|
|
|
|
|
+ std::string weight = pChengzhongFrame->m_weight;
|
|
|
|
|
+ if (atof(weight.c_str()) < 0.001)
|
|
|
|
|
+ {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ clickItem.num = weight;
|
|
|
|
|
+
|
|
|
|
|
+ m_is_show_modal_wnd = false;
|
|
|
|
|
+ delete pChengzhongFrame;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ m_is_show_modal_wnd = false;
|
|
|
|
|
+ delete pChengzhongFrame;
|
|
|
|
|
+
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ //如果重量不为0了,说明已经称重了,这时候直接使用这个重量
|
|
|
|
|
+ clickItem.num = s_weight_value;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ clickItem.is_weight = false;
|
|
|
|
|
+
|
|
|
|
|
+ if (foodinfo.is_nature == "1")
|
|
|
|
|
+ {
|
|
|
|
|
+ //商品有商品属性
|
|
|
|
|
+ clickItem.is_nature = true;
|
|
|
|
|
+
|
|
|
|
|
+ if (m_is_show_modal_wnd == true)
|
|
|
|
|
+ {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //先弹框进行选择属性
|
|
|
|
|
+ CDiandanNatureWnd* pNatureFrame = new CDiandanNatureWnd(1);
|
|
|
|
|
+ pNatureFrame->SetFoodItemUI(m_cur_click_food_item);
|
|
|
|
|
+
|
|
|
|
|
+ if (pNatureFrame != NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ m_is_show_modal_wnd = true;
|
|
|
|
|
+ m_curModalWnd = pNatureFrame;
|
|
|
|
|
+
|
|
|
|
|
+ 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;
|
|
|
|
|
+
|
|
|
|
|
+ m_is_show_modal_wnd = false;
|
|
|
|
|
+ delete pNatureFrame;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ m_is_show_modal_wnd = false;
|
|
|
|
|
+ delete pNatureFrame;
|
|
|
|
|
+
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //商品没有商品属性
|
|
|
|
|
+ bool is_add_new = false;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+//扫描了商品条码的逻辑处理
|
|
|
|
|
+bool CYubaozhuangbiaoqianPageUI::SaomiaoBarcode(std::string barcode)
|
|
|
|
|
+{
|
|
|
|
|
+ CSqlite3 sqlite;
|
|
|
|
|
+
|
|
|
|
|
+ CFood foodinfo;
|
|
|
|
|
+ bool ret = sqlite.GetFoodByBarcode(barcode, foodinfo);
|
|
|
|
|
+
|
|
|
|
|
+ if (ret == false)
|
|
|
|
|
+ {
|
|
|
|
|
+ //说明没找到对应的商品条码
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //这里说明找到了,那么处理添加购物车逻辑,扫码的情况下,这里不管有没有属性,都按没属性处理,不管有没有称重都按没称重处理(以后标签秤可能会修改)
|
|
|
|
|
+
|
|
|
|
|
+ if (foodinfo.stockvalid == "1" && atof(foodinfo.stock.c_str()) < 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ //库存为0了,不做任何处理
|
|
|
|
|
+ m_pMainWnd->ShowToast(L"该商品已售完");
|
|
|
|
|
+
|
|
|
|
|
+ //只要找到了就返回true
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ CDiandanOrderItem clickItem;
|
|
|
|
|
+
|
|
|
|
|
+ clickItem.food_id = foodinfo.id;
|
|
|
|
|
+ clickItem.food_name = foodinfo.name;
|
|
|
|
|
+ clickItem.type_id = foodinfo.type_id;
|
|
|
|
|
+ clickItem.price = foodinfo.price;
|
|
|
|
|
+ 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 = CLewaimaiJson::ToString(member_price_info["id"]);
|
|
|
|
|
+ newPirce.level = CLewaimaiJson::ToString(member_price_info["level"]);
|
|
|
|
|
+ newPirce.price = CLewaimaiJson::ToString(member_price_info["price"]);
|
|
|
|
|
+
|
|
|
|
|
+ clickItem.m_member_price.push_back(newPirce);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //把当前点击商品的信息,保存到orderitem里面,方便后面修改规格的时候使用
|
|
|
|
|
+ clickItem.SetFoodInfo(foodinfo);
|
|
|
|
|
+ clickItem.SetIsTaocan(false);
|
|
|
|
|
+
|
|
|
|
|
+ clickItem.is_weight = false;
|
|
|
|
|
+ clickItem.is_nature = false;
|
|
|
|
|
+
|
|
|
|
|
+ //商品没有商品属性
|
|
|
|
|
+ bool is_add_new = false;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return true;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+bool CYubaozhuangbiaoqianPageUI::BiaoqianchengSaomaBarcode(std::string barcode)
|
|
|
|
|
+{
|
|
|
|
|
+ //先根据设置,分辨条码格式
|
|
|
|
|
+ std::string bianma;
|
|
|
|
|
+ std::string money;
|
|
|
|
|
+ std::string weight;
|
|
|
|
|
+ std::string jiaoyan;
|
|
|
|
|
+
|
|
|
|
|
+ std::string setting_tiaomacheng_geshi = CSetting::GetInstance()->GetParam("setting_tiaomacheng_geshi");
|
|
|
|
|
+ if (setting_tiaomacheng_geshi == "1")
|
|
|
|
|
+ {
|
|
|
|
|
+ if (barcode.length() != 12 && barcode.length() != 13)
|
|
|
|
|
+ {
|
|
|
|
|
+ //与该模式长度不匹配
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (barcode.length() == 12)
|
|
|
|
|
+ {
|
|
|
|
|
+ barcode = CLewaimaiString::BuZifuLeft(barcode, 1, '0');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //13位【FWWWWWWEEEEEC】
|
|
|
|
|
+ bianma = barcode.substr(1, 6);
|
|
|
|
|
+ money = barcode.substr(7, 5);
|
|
|
|
|
+ jiaoyan = barcode.substr(12, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (setting_tiaomacheng_geshi == "2")
|
|
|
|
|
+ {
|
|
|
|
|
+ if (barcode.length() != 12 && barcode.length() != 13)
|
|
|
|
|
+ {
|
|
|
|
|
+ //与该模式长度不匹配
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (barcode.length() == 12)
|
|
|
|
|
+ {
|
|
|
|
|
+ barcode = CLewaimaiString::BuZifuLeft(barcode, 1, '0');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //13位【FWWWWWWNNNNNC】
|
|
|
|
|
+ bianma = barcode.substr(1, 6);
|
|
|
|
|
+ weight = barcode.substr(7, 5);
|
|
|
|
|
+ jiaoyan = barcode.substr(12, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (setting_tiaomacheng_geshi == "3")
|
|
|
|
|
+ {
|
|
|
|
|
+ if (barcode.length() != 12 && barcode.length() != 13)
|
|
|
|
|
+ {
|
|
|
|
|
+ //与该模式长度不匹配
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (barcode.length() == 12)
|
|
|
|
|
+ {
|
|
|
|
|
+ barcode = CLewaimaiString::BuZifuLeft(barcode, 1, '0');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //13位【FFWWWWWEEEEEC】
|
|
|
|
|
+ bianma = barcode.substr(2, 5);
|
|
|
|
|
+ money = barcode.substr(7, 5);
|
|
|
|
|
+ jiaoyan = barcode.substr(12, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (setting_tiaomacheng_geshi == "4")
|
|
|
|
|
+ {
|
|
|
|
|
+ if (barcode.length() != 12 && barcode.length() != 13)
|
|
|
|
|
+ {
|
|
|
|
|
+ //与该模式长度不匹配
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (barcode.length() == 12)
|
|
|
|
|
+ {
|
|
|
|
|
+ barcode = CLewaimaiString::BuZifuLeft(barcode, 1, '0');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //13位【FFWWWWWNNNNNC】
|
|
|
|
|
+ bianma = barcode.substr(2, 5);
|
|
|
|
|
+ weight = barcode.substr(7, 5);
|
|
|
|
|
+ jiaoyan = barcode.substr(12, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (setting_tiaomacheng_geshi == "5")
|
|
|
|
|
+ {
|
|
|
|
|
+ if (barcode.length() != 17 && barcode.length() != 18)
|
|
|
|
|
+ {
|
|
|
|
|
+ //与该模式长度不匹配
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (barcode.length() == 17)
|
|
|
|
|
+ {
|
|
|
|
|
+ barcode = CLewaimaiString::BuZifuLeft(barcode, 1, '0');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //18位【FWWWWWWEEEEENNNNNC】
|
|
|
|
|
+ bianma = barcode.substr(1, 6);
|
|
|
|
|
+ money = barcode.substr(7, 5);
|
|
|
|
|
+ weight = barcode.substr(12, 5);
|
|
|
|
|
+ jiaoyan = barcode.substr(17, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (setting_tiaomacheng_geshi == "6")
|
|
|
|
|
+ {
|
|
|
|
|
+ if (barcode.length() != 17 && barcode.length() != 18)
|
|
|
|
|
+ {
|
|
|
|
|
+ //与该模式长度不匹配
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (barcode.length() == 17)
|
|
|
|
|
+ {
|
|
|
|
|
+ barcode = CLewaimaiString::BuZifuLeft(barcode, 1, '0');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //18位【FWWWWWWNNNNNEEEEEC】
|
|
|
|
|
+ bianma = barcode.substr(1, 6);
|
|
|
|
|
+ weight = barcode.substr(7, 5);
|
|
|
|
|
+ money = barcode.substr(12, 5);
|
|
|
|
|
+ jiaoyan = barcode.substr(17, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (setting_tiaomacheng_geshi == "7")
|
|
|
|
|
+ {
|
|
|
|
|
+ if (barcode.length() != 17 && barcode.length() != 18)
|
|
|
|
|
+ {
|
|
|
|
|
+ //与该模式长度不匹配
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (barcode.length() == 17)
|
|
|
|
|
+ {
|
|
|
|
|
+ barcode = CLewaimaiString::BuZifuLeft(barcode, 1, '0');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //18位【FFWWWWWEEEEENNNNNC】
|
|
|
|
|
+ bianma = barcode.substr(2, 5);
|
|
|
|
|
+ money = barcode.substr(7, 5);
|
|
|
|
|
+ weight = barcode.substr(12, 5);
|
|
|
|
|
+ jiaoyan = barcode.substr(17, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (setting_tiaomacheng_geshi == "8")
|
|
|
|
|
+ {
|
|
|
|
|
+ if (barcode.length() != 17 && barcode.length() != 18)
|
|
|
|
|
+ {
|
|
|
|
|
+ //与该模式长度不匹配
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (barcode.length() == 17)
|
|
|
|
|
+ {
|
|
|
|
|
+ barcode = CLewaimaiString::BuZifuLeft(barcode, 1, '0');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //18位【FFWWWWWNNNNNEEEEEC】
|
|
|
|
|
+ bianma = barcode.substr(2, 5);
|
|
|
|
|
+ weight = barcode.substr(7, 5);
|
|
|
|
|
+ money = barcode.substr(12, 5);
|
|
|
|
|
+ jiaoyan = barcode.substr(17, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //先检查编码是否存在,如果编码不存在直接返回false
|
|
|
|
|
+ int i_bianma = atoi(bianma.c_str());
|
|
|
|
|
+ if (i_bianma < 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ CFood foodinfo;
|
|
|
|
|
+
|
|
|
|
|
+ CSqlite3 sqlite;
|
|
|
|
|
+ bool ret = sqlite.GetFoodByPluBianma(std::to_string(i_bianma), foodinfo);
|
|
|
|
|
+ if (ret == false)
|
|
|
|
|
+ {
|
|
|
|
|
+ //没找到这个商品
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //走到这里是找到商品了,那么就开始计算价格和重量
|
|
|
|
|
+ double d_money = 0;
|
|
|
|
|
+ double d_weight = 0;
|
|
|
|
|
+
|
|
|
|
|
+ //如果有价格,优先用价格
|
|
|
|
|
+ if (money.length() > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ //这个出来的单位是分,要把单位转成元
|
|
|
|
|
+ d_money = atof(money.c_str());
|
|
|
|
|
+
|
|
|
|
|
+ d_money = d_money / 100;
|
|
|
|
|
+
|
|
|
|
|
+ //根据价格计算重量
|
|
|
|
|
+ d_weight = d_money / atof(foodinfo.price.c_str());
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (weight.length() > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ //这个单位是克,要转化成千克
|
|
|
|
|
+ d_weight = atof(weight.c_str());
|
|
|
|
|
+
|
|
|
|
|
+ d_weight = d_weight / 1000;
|
|
|
|
|
+
|
|
|
|
|
+ //有重量了,其实不需要计算价格,价格加到购物车的时候会自己计算
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ //价格和重量都没有,这是异常情况
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (foodinfo.stockvalid == "1" && atof(foodinfo.stock.c_str()) < d_weight)
|
|
|
|
|
+ {
|
|
|
|
|
+ //库存为0了,不做任何处理
|
|
|
|
|
+ m_pMainWnd->ShowToast(L"该商品已售完");
|
|
|
|
|
+
|
|
|
|
|
+ //只要找到了就返回true
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ CDiandanOrderItem clickItem;
|
|
|
|
|
+
|
|
|
|
|
+ clickItem.food_id = foodinfo.id;
|
|
|
|
|
+ clickItem.food_name = foodinfo.name;
|
|
|
|
|
+ clickItem.type_id = foodinfo.type_id;
|
|
|
|
|
+ clickItem.price = foodinfo.price;
|
|
|
|
|
+ clickItem.is_dabao = false;
|
|
|
|
|
+ clickItem.dabao_money = foodinfo.dabao_money;
|
|
|
|
|
+ clickItem.num = CLewaimaiString::DoubleToString(d_weight, 3); //重量保留3位小数
|
|
|
|
|
+
|
|
|
|
|
+ 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);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //把当前点击商品的信息,保存到orderitem里面,方便后面修改规格的时候使用
|
|
|
|
|
+ clickItem.SetFoodInfo(foodinfo);
|
|
|
|
|
+ clickItem.SetIsTaocan(false);
|
|
|
|
|
+
|
|
|
|
|
+ clickItem.is_weight = true;
|
|
|
|
|
+ clickItem.is_nature = false;
|
|
|
|
|
+
|
|
|
|
|
+ //商品没有商品属性
|
|
|
|
|
+ bool is_add_new = false;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return true;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+//开始搜索某个商品名字
|
|
|
|
|
+void CYubaozhuangbiaoqianPageUI::StartSearchFood(std::string foodname)
|
|
|
|
|
+{
|
|
|
|
|
+ //展示删除按钮
|
|
|
|
|
+ CButtonUI* pClear = static_cast<CButtonUI*>(this->FindSubControl(_T("diandan_food_search_clear")));
|
|
|
|
|
+ pClear->SetVisible(true);
|
|
|
|
|
+
|
|
|
|
|
+ //隐藏商品分类展示
|
|
|
|
|
+ CVerticalLayoutUI* pFoodtype = static_cast<CVerticalLayoutUI*>(this->FindSubControl(_T("diandan_fenlei_layout_scrolllayout")));
|
|
|
|
|
+ pFoodtype->SetVisible(false);
|
|
|
|
|
+
|
|
|
|
|
+ if (m_cur_type_id != "sousuo")
|
|
|
|
|
+ {
|
|
|
|
|
+ m_type_id_before_sousuo = m_cur_type_id;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ m_cur_type_id = "sousuo";
|
|
|
|
|
+
|
|
|
|
|
+ m_sousuo_foodname = foodname;
|
|
|
|
|
+
|
|
|
|
|
+ CLabelUI* pTishi = static_cast<CLabelUI*>(this->FindSubControl(_T("diandan_food_search_tishi")));
|
|
|
|
|
+ pTishi->SetVisible(false);
|
|
|
|
|
+
|
|
|
|
|
+ this->InitFoodShow();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+//停止搜索商品
|
|
|
|
|
+void CYubaozhuangbiaoqianPageUI::StopSerachFood()
|
|
|
|
|
+{
|
|
|
|
|
+ //隐藏删除按钮
|
|
|
|
|
+ CButtonUI* pClear = static_cast<CButtonUI*>(this->FindSubControl(_T("diandan_food_search_clear")));
|
|
|
|
|
+ pClear->SetVisible(false);
|
|
|
|
|
+
|
|
|
|
|
+ //展示商品分类展示
|
|
|
|
|
+ CVerticalLayoutUI* pFoodtype = static_cast<CVerticalLayoutUI*>(this->FindSubControl(_T("diandan_fenlei_layout_scrolllayout")));
|
|
|
|
|
+ pFoodtype->SetVisible(true);
|
|
|
|
|
+
|
|
|
|
|
+ m_cur_type_id = m_type_id_before_sousuo;
|
|
|
|
|
+
|
|
|
|
|
+ CLabelUI* pTishi = static_cast<CLabelUI*>(this->FindSubControl(_T("diandan_food_search_tishi")));
|
|
|
|
|
+ pTishi->SetVisible(true);
|
|
|
|
|
+
|
|
|
|
|
+ this->InitFoodShow();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void CYubaozhuangbiaoqianPageUI::SetPos(RECT rc, bool bNeedInvalidate)
|
|
|
|
|
+{
|
|
|
|
|
+ m_nPageWidth = rc.right - rc.left;
|
|
|
|
|
+
|
|
|
|
|
+ if (m_nPageWidth + 91 < 1260)
|
|
|
|
|
+ {
|
|
|
|
|
+ //小屏幕上,默认隐藏优惠区域
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ //this->XianshiYouhui();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //更新分类位置
|
|
|
|
|
+ UpdateFoodtypePos();
|
|
|
|
|
+
|
|
|
|
|
+ CContainerUI::SetPos(rc, bNeedInvalidate);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void CYubaozhuangbiaoqianPageUI::HandleDiandanAIShibieResult()
|
|
|
|
|
+{
|
|
|
|
|
+ if (m_cur_type_id == "ai")
|
|
|
|
|
+ {
|
|
|
|
|
+ this->InitFoodShow();
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void CYubaozhuangbiaoqianPageUI::HandleChengzhongValueChange()
|
|
|
|
|
+{
|
|
|
|
|
+ std::string weight = CChengzhongWorker::GetInstance()->GetWeight();
|
|
|
|
|
+
|
|
|
|
|
+ CControlUI* pWendingStatus = static_cast<CControlUI*>(this->FindSubControl(_T("diandan_page_status_chengzhong_wending")));
|
|
|
|
|
+ if (CChengzhongWorker::GetInstance()->GetIsWending() == true)
|
|
|
|
|
+ {
|
|
|
|
|
+ pWendingStatus->SetBkImage(L"deng_on.png");
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ pWendingStatus->SetBkImage(L"deng_off.png");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ CLabelUI* pLabel = static_cast<CLabelUI*>(this->FindSubControl(_T("diandan_page_label_chengzhong_value")));
|
|
|
|
|
+ pLabel->SetText(CLewaimaiString::UTF8ToUnicode(weight).c_str());
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void CYubaozhuangbiaoqianPageUI::ZhiLing()
|
|
|
|
|
+{
|
|
|
|
|
+ std::string setting_dianzicheng_xinghao = CSetting::GetInstance()->GetParam("setting_dianzicheng_xinghao");
|
|
|
|
|
+ if (setting_dianzicheng_xinghao == "dahua_acs")
|
|
|
|
|
+ {
|
|
|
|
|
+ m_pMainWnd->ShowToast(L"大华ACS电子秤不支持置零操作,请在秤上操作");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ CChengzhongWorker::GetInstance()->Zhiling();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void CYubaozhuangbiaoqianPageUI::Qupi()
|
|
|
|
|
+{
|
|
|
|
|
+ std::string setting_dianzicheng_xinghao = CSetting::GetInstance()->GetParam("setting_dianzicheng_xinghao");
|
|
|
|
|
+ if (setting_dianzicheng_xinghao == "dahua_acs")
|
|
|
|
|
+ {
|
|
|
|
|
+ m_pMainWnd->ShowToast(L"大华ACS电子秤不支持去皮操作,请在秤上操作");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ CChengzhongWorker::GetInstance()->Qupi();
|
|
|
|
|
+}
|