CZhengcanOrderInfoPageUI.cpp 10 KB

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