CDianneiOrderInfoPageUI.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. #include "../pch/pch.h"
  2. #include "CDianneiOrderInfoPageUI.h"
  3. #include "../control/ControlEx.h"
  4. #include "../wnd/CMainWnd.h"
  5. #include "../print/CPosPrinter.h"
  6. CDianneiOrderInfoPageUI::CDianneiOrderInfoPageUI()
  7. {
  8. }
  9. CDianneiOrderInfoPageUI::~CDianneiOrderInfoPageUI()
  10. {
  11. }
  12. //初始化当前页面的展示,处理默认展示效果,在页面被加载的时候调用
  13. void CDianneiOrderInfoPageUI::InitShow()
  14. {
  15. //请求服务器,获取订单数据
  16. CDiandanOrder order;
  17. order.InitData(m_order_id);
  18. //刷新订单详情页数据
  19. this->SetDate(order);
  20. this->Refresh(order);
  21. }
  22. //处理按钮点击类事件
  23. void CDianneiOrderInfoPageUI::HandleClickMsg(TNotifyUI& msg)
  24. {
  25. CDuiString name = msg.pSender->GetName();
  26. if (name == _T("diannei_order_info_page_return"))
  27. {
  28. m_pMainWnd->SwitchPage(CMainWnd::DIANNEIDINGDAN);
  29. }
  30. else if (name == _T("diannei_order_info_page_print"))
  31. {
  32. CPosPrinter printer;
  33. printer.PrintDiandanOrder(this->m_order.m_order_id);
  34. }
  35. else if (name == _T("diannei_order_info_page_refund"))
  36. {
  37. std::string diannei_order_id = this->m_order.m_order_id;
  38. CDiandanOrder order;
  39. bool ret = order.Refund(diannei_order_id);
  40. if (ret)
  41. {
  42. //订单设为成功,这里怎么处理
  43. //请求服务器,获取订单数据
  44. CDiandanOrder new_order;
  45. new_order.InitData(diannei_order_id);
  46. //刷新订单详情页数据
  47. this->SetDate(new_order);
  48. this->Refresh(new_order);
  49. }
  50. }
  51. }
  52. //处理option切换事件
  53. void CDianneiOrderInfoPageUI::HandleSelectChangeMsg(TNotifyUI& msg)
  54. {
  55. }
  56. //处理下拉框、radio的切换事件
  57. void CDianneiOrderInfoPageUI::HandleItemSelectMsg(TNotifyUI& msg)
  58. {
  59. }
  60. //处理编辑框输入内容改变事件
  61. void CDianneiOrderInfoPageUI::HandleTextChangedMsg(TNotifyUI& msg)
  62. {
  63. }
  64. //处理扫码枪捕捉到的扫码信息
  65. void CDianneiOrderInfoPageUI::HandleTextCapture(std::string content)
  66. {
  67. }
  68. //刷新当前页面的内容,注意这个函数不会改变当前的订单状态以及“页数”
  69. void CDianneiOrderInfoPageUI::SetDate(CDiandanOrder& order)
  70. {
  71. m_order = order;
  72. }
  73. void CDianneiOrderInfoPageUI::Refresh(CDiandanOrder& order)
  74. {
  75. std::wstring order_no_show = L"订单号:" + CLewaimaiString::UTF8ToUnicode(order.show_trade_no);
  76. this->FindSubControl(_T("diannei_order_info_page_order_num"))->SetText(order_no_show.c_str());
  77. //商品详情的渲染
  78. CListUI* pFoodList = static_cast<CListUI*>(this->FindSubControl(_T("diannei_order_info_page_foodlist")));
  79. pFoodList->RemoveAll();
  80. int show_num = 0;
  81. for (std::vector<CDiandanOrderItemPrint>::iterator it = order.m_items_print.begin(); it != order.m_items_print.end(); it++)
  82. {
  83. if (it->is_taocan_item == true)
  84. {
  85. //套餐的详情不展示
  86. continue;
  87. }
  88. std::string food_name = (*it).m_food_name;
  89. std::string food_price = (*it).m_item_price;
  90. std::string quantity = (*it).m_quantity;
  91. CDialogBuilder builder;
  92. CListContainerElementUI* pEle = static_cast<CListContainerElementUI *>(builder.Create(_T("diannei_order_info_page_listitem.xml"), (UINT)0, NULL, m_pManager));
  93. CLabelUI *pName = static_cast<CLabelUI *>(pEle->FindSubControl(_T("diannei_order_info_page_listitem_foodname")));
  94. pName->SetText(CLewaimaiString::UTF8ToUnicode(food_name).c_str());
  95. CLabelUI *pQuantity = static_cast<CLabelUI *>(pEle->FindSubControl(_T("diannei_order_info_page_listitem_quantity")));
  96. pQuantity->SetText(CLewaimaiString::UTF8ToUnicode(quantity).c_str());
  97. CLabelUI *pPrice = static_cast<CLabelUI *>(pEle->FindSubControl(_T("diannei_order_info_page_listitem_price")));
  98. pPrice->SetText(CLewaimaiString::UTF8ToUnicode(food_price).c_str());
  99. pFoodList->Add(pEle);
  100. show_num++;
  101. }
  102. //重设商品列表的高度
  103. int order_item_height = (show_num + 1) * 30;
  104. pFoodList->SetFixedHeight(order_item_height);
  105. CLabelUI *pMemo = static_cast<CLabelUI *>(this->FindSubControl(_T("dianneiorder_info_page_memo")));
  106. wstring memo = _T("备注:") + CLewaimaiString::UTF8ToUnicode(order.m_memo);
  107. pMemo->SetText(memo.c_str());
  108. //开始展示各种费用
  109. CVerticalLayoutUI* pFeesLayout = static_cast<CVerticalLayoutUI *>(this->FindSubControl(_T("diannei_order_info_page_fees")));
  110. pFeesLayout->RemoveAll();
  111. int fees_num = 0;
  112. if (atof(order.m_shangpinquan_youhui.c_str()) > 0)
  113. {
  114. CLabelUI *pFee = new CLabelUI;
  115. pFee->SetFixedHeight(38);
  116. wstring delivery_fee = L"商品券优惠金额:" + CLewaimaiString::UTF8ToUnicode(order.m_shangpinquan_youhui);
  117. pFee->SetText(delivery_fee.c_str());
  118. pFeesLayout->Add(pFee);
  119. fees_num++;
  120. }
  121. if (atof(order.m_cika_youhui.c_str()) > 0)
  122. {
  123. CLabelUI *pFee = new CLabelUI;
  124. pFee->SetFixedHeight(38);
  125. wstring delivery_fee = L"次卡优惠金额:" + CLewaimaiString::UTF8ToUnicode(order.m_cika_youhui);
  126. pFee->SetText(delivery_fee.c_str());
  127. pFeesLayout->Add(pFee);
  128. fees_num++;
  129. }
  130. if (atof(order.m_total_member_youhui.c_str()) > 0)
  131. {
  132. CLabelUI *pFee = new CLabelUI;
  133. pFee->SetFixedHeight(38);
  134. wstring delivery_fee = L"商品会员价优惠金额:" + CLewaimaiString::UTF8ToUnicode(order.m_total_member_youhui);
  135. pFee->SetText(delivery_fee.c_str());
  136. pFeesLayout->Add(pFee);
  137. fees_num++;
  138. }
  139. if (atof(order.m_zhekou_youhui.c_str()) > 0)
  140. {
  141. CLabelUI *pFee = new CLabelUI;
  142. pFee->SetFixedHeight(38);
  143. wstring delivery_fee = L"整单折扣优惠金额:" + CLewaimaiString::UTF8ToUnicode(order.m_zhekou_youhui);
  144. pFee->SetText(delivery_fee.c_str());
  145. pFeesLayout->Add(pFee);
  146. fees_num++;
  147. }
  148. if (atof(order.m_member_zhekou_youhui.c_str()) > 0)
  149. {
  150. CLabelUI *pFee = new CLabelUI;
  151. pFee->SetFixedHeight(38);
  152. wstring delivery_fee = L"会员折扣优惠金额:" + CLewaimaiString::UTF8ToUnicode(order.m_member_zhekou_youhui);
  153. pFee->SetText(delivery_fee.c_str());
  154. pFeesLayout->Add(pFee);
  155. fees_num++;
  156. }
  157. if (atof(order.m_quanyika_youhui.c_str()) > 0)
  158. {
  159. CLabelUI *pFee = new CLabelUI;
  160. pFee->SetFixedHeight(38);
  161. wstring delivery_fee = L"权益卡优惠金额:" + CLewaimaiString::UTF8ToUnicode(order.m_quanyika_youhui);
  162. pFee->SetText(delivery_fee.c_str());
  163. pFeesLayout->Add(pFee);
  164. fees_num++;
  165. }
  166. if (atof(order.m_manjian_youhui.c_str()) > 0)
  167. {
  168. CLabelUI *pFee = new CLabelUI;
  169. pFee->SetFixedHeight(38);
  170. wstring delivery_fee = L"满减优惠金额:" + CLewaimaiString::UTF8ToUnicode(order.m_manjian_youhui);
  171. pFee->SetText(delivery_fee.c_str());
  172. pFeesLayout->Add(pFee);
  173. fees_num++;
  174. }
  175. if (atof(order.m_youhuiquan_youhui.c_str()) > 0)
  176. {
  177. CLabelUI *pFee = new CLabelUI;
  178. pFee->SetFixedHeight(38);
  179. wstring delivery_fee = L"优惠券优惠金额:" + CLewaimaiString::UTF8ToUnicode(order.m_youhuiquan_youhui);
  180. pFee->SetText(delivery_fee.c_str());
  181. pFeesLayout->Add(pFee);
  182. fees_num++;
  183. }
  184. if (atof(order.m_rengong_youhui.c_str()) > 0)
  185. {
  186. CLabelUI *pFee = new CLabelUI;
  187. pFee->SetFixedHeight(38);
  188. wstring delivery_fee = L"人工优惠金额:" + CLewaimaiString::UTF8ToUnicode(order.m_rengong_youhui);
  189. pFee->SetText(delivery_fee.c_str());
  190. pFeesLayout->Add(pFee);
  191. fees_num++;
  192. }
  193. if (atof(order.m_dabao_money.c_str()) > 0)
  194. {
  195. CLabelUI *pFee = new CLabelUI;
  196. pFee->SetFixedHeight(38);
  197. wstring delivery_fee = L"打包费金额:" + CLewaimaiString::UTF8ToUnicode(order.m_dabao_money);
  198. pFee->SetText(delivery_fee.c_str());
  199. pFeesLayout->Add(pFee);
  200. fees_num++;
  201. }
  202. if (atof(order.m_jiajia.c_str()) > 0)
  203. {
  204. CLabelUI *pFee = new CLabelUI;
  205. pFee->SetFixedHeight(38);
  206. wstring delivery_fee = L"加价金额:" + CLewaimaiString::UTF8ToUnicode(order.m_jiajia);
  207. pFee->SetText(delivery_fee.c_str());
  208. pFeesLayout->Add(pFee);
  209. fees_num++;
  210. }
  211. if (atof(order.m_moling_youhui.c_str()) > 0)
  212. {
  213. CLabelUI *pFee = new CLabelUI;
  214. pFee->SetFixedHeight(38);
  215. wstring delivery_fee = L"抹零优惠金额:" + CLewaimaiString::UTF8ToUnicode(order.m_moling_youhui);
  216. pFee->SetText(delivery_fee.c_str());
  217. pFeesLayout->Add(pFee);
  218. fees_num++;
  219. }
  220. int fees_height;
  221. if (fees_num == 0)
  222. {
  223. pFeesLayout->SetVisible(false);
  224. this->FindSubControl(_T("diannei_order_info_page_fees_line"))->SetVisible(false);
  225. fees_height = 0;
  226. }
  227. else
  228. {
  229. pFeesLayout->SetVisible(true);
  230. this->FindSubControl(_T("diannei_order_info_page_fees_line"))->SetVisible(true);
  231. pFeesLayout->SetFixedHeight(fees_num * 38);
  232. fees_height = fees_num * 38;
  233. }
  234. CLabelUI *pTotalPrice = static_cast<CLabelUI *>(this->FindSubControl(_T("diannei_order_info_page_totalprice")));
  235. wstring price = L"总计:¥" + CLewaimaiString::UTF8ToUnicode(order.m_total_price);
  236. pTotalPrice->SetText(price.c_str());
  237. int nTotalHeight = order_item_height + fees_height + 173;
  238. this->FindSubControl(_T("diannei_order_info_page_layout_1"))->SetFixedHeight(nTotalHeight);
  239. //开始显示顾客信息
  240. std::wstring qucanma_show = L"取餐码:" + CLewaimaiString::UTF8ToUnicode(order.take_food_code);
  241. this->FindSubControl(_T("diannei_order_info_page_qucanma"))->SetText(qucanma_show.c_str());
  242. std::wstring canpai_show = L"桌号:" + CLewaimaiString::UTF8ToUnicode(order.m_canpai);
  243. this->FindSubControl(_T("diannei_order_info_page_zhuohao"))->SetText(canpai_show.c_str());
  244. std::wstring renshu_show = L"人数:" + CLewaimaiString::UTF8ToUnicode(order.m_renshu);
  245. this->FindSubControl(_T("diannei_order_info_page_renshu"))->SetText(renshu_show.c_str());
  246. std::wstring order_date_show = L"下单时间:" + CLewaimaiString::UTF8ToUnicode(order.init_time);
  247. this->FindSubControl(_T("diannei_order_info_page_init_date"))->SetText(order_date_show.c_str());
  248. //开始处理订单信息
  249. std::wstring laiyuan;
  250. if (order.order_from == 1)
  251. {
  252. laiyuan = L"收银机下单";
  253. }
  254. else if (order.order_from == 2)
  255. {
  256. laiyuan = L"商家app下单";
  257. }
  258. else if (order.order_from == 3)
  259. {
  260. laiyuan = L"扫码下单";
  261. }
  262. CLabelUI *pType = static_cast<CLabelUI *>(this->FindSubControl(_T("diannei_order_info_page_type")));
  263. wstring wsType = _T("订单来源:") + laiyuan;
  264. pType->SetText(wsType.c_str());
  265. CLabelUI *pPayType = static_cast<CLabelUI *>(this->FindSubControl(_T("diannei_order_info_page_pay_type")));
  266. wstring wsPayType = _T("付款方式:") + CLewaimaiString::UTF8ToUnicode(order.shoukuan_type);
  267. pPayType->SetText(wsPayType.c_str());
  268. CLabelUI *pRefund = static_cast<CLabelUI *>(this->FindSubControl(_T("diannei_order_info_page_refund_status")));
  269. if (order.is_refund == "1")
  270. {
  271. wstring wsPayType = _T("退款状态:已退款");
  272. pRefund->SetText(wsPayType.c_str());
  273. }
  274. else
  275. {
  276. wstring wsPayType = _T("退款状态:未退款");
  277. pRefund->SetText(wsPayType.c_str());
  278. }
  279. this->FindSubControl(_T("diannei_order_info_page_layout_3"))->SetFixedHeight(211);
  280. //退款按钮
  281. CButtonUI* refund_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("diannei_order_info_page_refund")));
  282. if (order.is_refund == "1")
  283. {
  284. refund_button->SetVisible(false);
  285. }
  286. else
  287. {
  288. refund_button->SetVisible(true);
  289. }
  290. }