CDianneiOrderInfoPageUI.cpp 10 KB

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