CWaimaiOrderInfoUI.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. #include "../pch/pch.h"
  2. #include "CWaimaiOrderInfoUI.h"
  3. #include "ControlEx.h"
  4. void CWaimaiOrderInfoUI::DoEvent(TEventUI& event)
  5. {
  6. CVerticalLayoutUI::DoEvent(event);
  7. }
  8. void CWaimaiOrderInfoUI::Refresh(CWaimaiOrder& order)
  9. {
  10. std::wstring liushuihao_show = L"#" + CLewaimaiString::UTF8ToUnicode(order.m_restaurant_number);
  11. this->FindSubControl(_T("waimai_order_info_page_liushuihao"))->SetText(liushuihao_show.c_str());
  12. std::wstring order_no_show = L"订单号:" + CLewaimaiString::UTF8ToUnicode(order.m_order_no);
  13. this->FindSubControl(_T("waimai_order_info_page_order_no"))->SetText(order_no_show.c_str());
  14. //商品详情的渲染
  15. CListUI* pFoodList = static_cast<CListUI*>(this->FindSubControl(_T("waimai_order_info_page_foodlist")));
  16. pFoodList->RemoveAll();
  17. for (std::vector<CWaimaiOrderItem>::iterator it = order.m_order_items.begin(); it != order.m_order_items.end(); it++)
  18. {
  19. std::string food_name = (*it).m_food_name;
  20. std::string food_price = (*it).m_item_price;
  21. std::string quantity = (*it).m_quantity;
  22. CDialogBuilder builder;
  23. CListContainerElementUI* pEle = static_cast<CListContainerElementUI *>(builder.Create(_T("waimai_order_info_page_listitem.xml"), (UINT)0, NULL, m_pManager));
  24. CLabelUI *pName = static_cast<CLabelUI *>(pEle->FindSubControl(_T("waimai_order_info_page_listitem_foodname")));
  25. pName->SetText(CLewaimaiString::UTF8ToUnicode(food_name).c_str());
  26. CLabelUI *pQuantity = static_cast<CLabelUI *>(pEle->FindSubControl(_T("waimai_order_info_page_listitem_quantity")));
  27. pQuantity->SetText(CLewaimaiString::UTF8ToUnicode(quantity).c_str());
  28. CLabelUI *pPrice = static_cast<CLabelUI *>(pEle->FindSubControl(_T("waimai_order_info_page_listitem_price")));
  29. pPrice->SetText(CLewaimaiString::UTF8ToUnicode(food_price).c_str());
  30. pFoodList->Add(pEle);
  31. }
  32. //重设商品列表的高度
  33. pFoodList->SetFixedHeight((order.m_order_items.size() + 1) * 30);
  34. CLabelUI *pMemo = static_cast<CLabelUI *>(this->FindSubControl(_T("waimaorder_info_page_memo")));
  35. wstring memo = _T("备注:") + CLewaimaiString::UTF8ToUnicode(order.m_memo);
  36. pMemo->SetText(memo.c_str());
  37. //开始展示各种费用
  38. CVerticalLayoutUI* pFeesLayout = static_cast<CVerticalLayoutUI *>(this->FindSubControl(_T("waimai_order_info_page_fees")));
  39. pFeesLayout->RemoveAll();
  40. int fees_num = 0;
  41. if (order.m_delivery > 0)
  42. {
  43. CLabelUI *pDlieveryFee = new CLabelUI;
  44. pDlieveryFee->SetFixedHeight(30);
  45. wstring delivery_fee = L"配送费:" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString((double)order.m_delivery, 2));
  46. pDlieveryFee->SetText(delivery_fee.c_str());
  47. pFeesLayout->Add(pDlieveryFee);
  48. fees_num++;
  49. }
  50. if (order.m_is_dabao == "1")
  51. {
  52. CLabelUI *pDabaoFee = new CLabelUI;
  53. pDabaoFee->SetFixedHeight(30);
  54. wstring dabao_fee = L"打包费:" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString((double)order.m_delivery, 2));
  55. pDabaoFee->SetText(dabao_fee.c_str());
  56. pFeesLayout->Add(pDabaoFee);
  57. fees_num++;
  58. }
  59. //增值服务费
  60. if (order.m_addservie.size() > 0)
  61. {
  62. for (std::vector<CWaimaiOrderField>::iterator it = order.m_addservie.begin(); it != order.m_addservie.end(); it++)
  63. {
  64. wstring addservice = CLewaimaiString::UTF8ToUnicode((*it).name) + L":" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString((double)atof((*it).value.c_str()), 2));
  65. CLabelUI* newField = new CLabelUI();
  66. newField->SetText(addservice.c_str());
  67. newField->SetFixedHeight(30);
  68. pFeesLayout->Add(newField);
  69. fees_num++;
  70. }
  71. }
  72. //店铺折扣
  73. if (order.m_discount < 10)
  74. {
  75. CLabelUI *pDiscountFee = new CLabelUI;
  76. pDiscountFee->SetFixedHeight(30);
  77. wstring discount = L"店铺折扣:" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString((double)order.m_discount, 2)) + L"折";
  78. pDiscountFee->SetText(discount.c_str());
  79. pFeesLayout->Add(pDiscountFee);
  80. fees_num++;
  81. }
  82. //会员优惠
  83. if (order.m_is_member_discount == "1")
  84. {
  85. CLabelUI *pMemberFee = new CLabelUI;
  86. pMemberFee->SetFixedHeight(30);
  87. wstring memberfee = L"会员优惠:-" + CLewaimaiString::UTF8ToUnicode(order.m_member_discount);
  88. pMemberFee->SetText(memberfee.c_str());
  89. pFeesLayout->Add(pMemberFee);
  90. fees_num++;
  91. }
  92. //首单优惠
  93. if (order.m_is_firstcut == "1")
  94. {
  95. CLabelUI *pFirstCut = new CLabelUI;
  96. pFirstCut->SetFixedHeight(30);
  97. wstring firstcut = L"首单优惠:-" + CLewaimaiString::UTF8ToUnicode(order.m_firstcut_value);
  98. pFirstCut->SetText(firstcut.c_str());
  99. pFeesLayout->Add(pFirstCut);
  100. fees_num++;
  101. }
  102. //满减
  103. string::size_type position = order.m_promotion.find(":");
  104. if (position != order.m_promotion.npos)
  105. {
  106. CLabelUI *pManjian = new CLabelUI;
  107. pManjian->SetFixedHeight(30);
  108. string promotion_value;
  109. promotion_value.assign(order.m_promotion, position + 1);
  110. wstring promotion = L"满减优惠:-" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString((double)(atof(promotion_value.c_str())), 2));
  111. pManjian->SetText(promotion.c_str());
  112. pFeesLayout->Add(pManjian);
  113. fees_num++;
  114. }
  115. //优惠券
  116. if (order.m_coupon > 0)
  117. {
  118. CLabelUI *pCoupon = new CLabelUI;
  119. pCoupon->SetMaxHeight(30);
  120. wstring coupon = L"优惠券:-" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString((double)order.m_coupon, 2));
  121. pCoupon->SetText(coupon.c_str());
  122. pFeesLayout->Add(pCoupon);
  123. fees_num++;
  124. }
  125. //商品券
  126. if (atof(order.m_goods_coupon_value.c_str()) > 0.0001)
  127. {
  128. CLabelUI *pGoodsCoupon = new CLabelUI;
  129. pGoodsCoupon->SetFixedHeight(30);
  130. wstring goods_coupon = L"商品券:-" + CLewaimaiString::UTF8ToUnicode(order.m_goods_coupon_value);
  131. pGoodsCoupon->SetText(goods_coupon.c_str());
  132. pFeesLayout->Add(pGoodsCoupon);
  133. fees_num++;
  134. }
  135. if (fees_num == 0)
  136. {
  137. pFeesLayout->SetVisible(false);
  138. this->FindSubControl(_T("waimai_order_info_page_fees_line"))->SetVisible(false);
  139. }
  140. else
  141. {
  142. pFeesLayout->SetVisible(true);
  143. this->FindSubControl(_T("waimai_order_info_page_fees_line"))->SetVisible(true);
  144. pFeesLayout->SetFixedHeight(fees_num * 30);
  145. }
  146. CLabelUI *pTotalPrice = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_totalprice")));
  147. wstring price = L"总计:¥" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(order.m_price, 2));
  148. pTotalPrice->SetText(price.c_str());
  149. std::wstring name_show = L"姓名:" + CLewaimaiString::UTF8ToUnicode(order.m_customer_name);
  150. this->FindSubControl(_T("waimai_order_info_page_name"))->SetText(name_show.c_str());
  151. std::wstring phone_show = L"电话:" + CLewaimaiString::UTF8ToUnicode(order.m_phone);
  152. this->FindSubControl(_T("waimai_order_info_page_phone"))->SetText(phone_show.c_str());
  153. std::wstring address_show = L"地址:" + CLewaimaiString::UTF8ToUnicode(order.m_address);
  154. this->FindSubControl(_T("waimai_order_info_page_address"))->SetText(address_show.c_str());
  155. std::wstring order_date_show = L"下单时间:" + CLewaimaiString::UTF8ToUnicode(order.m_order_date);
  156. this->FindSubControl(_T("waimai_order_info_page_init_date"))->SetText(order_date_show.c_str());
  157. if (order.m_is_selftake == "1")
  158. {
  159. CLabelUI *pDeliveryType = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_delivery_type")));
  160. wstring wsDeliveryType = _T("配送方式:到店自取(取餐号:") + CLewaimaiString::UTF8ToUnicode(order.m_take_food_code) + _T(")");
  161. pDeliveryType->SetText(wsDeliveryType.c_str());
  162. }
  163. else
  164. {
  165. CLabelUI *pDeliveryType = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_delivery_type")));
  166. wstring wsDeliveryType = _T("配送方式:外卖配送");
  167. pDeliveryType->SetText(wsDeliveryType.c_str());
  168. }
  169. CLabelUI *pType = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_type")));
  170. wstring wsType = _T("订单来源:") + CLewaimaiString::UTF8ToUnicode(order.m_from_type);
  171. pType->SetText(wsType.c_str());
  172. //预设选项
  173. CVerticalLayoutUI* pLayout = static_cast<CVerticalLayoutUI *>(this->FindSubControl(_T("waimai_order_info_page_field")));
  174. pLayout->RemoveAll();
  175. if (order.m_order_field.size() > 1)
  176. {
  177. for (std::vector<CWaimaiOrderField>::iterator it = order.m_order_field.begin(); it != order.m_order_field.end() - 1; it++)
  178. {
  179. wstring order_field = CLewaimaiString::UTF8ToUnicode((*it).name) + L":" + CLewaimaiString::UTF8ToUnicode((*it).value);
  180. CLabelUI* newField = new CLabelUI();
  181. newField->SetText(order_field.c_str());
  182. newField->SetFixedHeight(30);
  183. pLayout->Add(newField);
  184. }
  185. }
  186. pLayout->SetFixedHeight(order.m_order_field.size() * 30);
  187. //配送时间
  188. wstring delivery_date;
  189. if (order.m_is_selftake == "1")
  190. {
  191. delivery_date = L"自取时间:" + CLewaimaiString::UTF8ToUnicode(order.m_delivery_date);
  192. }
  193. else
  194. {
  195. delivery_date = L"配送时间:" + CLewaimaiString::UTF8ToUnicode(order.m_delivery_date);
  196. }
  197. CLabelUI *pTime = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_delivery_time")));
  198. pTime->SetText(delivery_date.c_str());
  199. CLabelUI *pPayType = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_pay_type")));
  200. wstring wsPayType = _T("付款方式:") + CLewaimaiString::UTF8ToUnicode(order.m_pay_type);
  201. pPayType->SetText(wsPayType.c_str());
  202. //右侧按钮的控制
  203. CButtonUI* confirm_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_confirme")));
  204. CButtonUI* success_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_success")));
  205. CButtonUI* fail_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_fail")));
  206. CButtonUI* agree_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_agreee")));
  207. CButtonUI* disagree_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_disagree")));
  208. if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("未处理")) == 0)
  209. {
  210. confirm_button->SetVisible(true);
  211. success_button->SetVisible(false);
  212. fail_button->SetVisible(true);
  213. agree_button->SetVisible(false);
  214. disagree_button->SetVisible(false);
  215. }
  216. else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("已确认")) == 0)
  217. {
  218. confirm_button->SetVisible(false);
  219. success_button->SetVisible(true);
  220. fail_button->SetVisible(true);
  221. agree_button->SetVisible(false);
  222. disagree_button->SetVisible(false);
  223. }
  224. else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("交易成功")) == 0)
  225. {
  226. confirm_button->SetVisible(false);
  227. success_button->SetVisible(false);
  228. fail_button->SetVisible(false);
  229. agree_button->SetVisible(false);
  230. disagree_button->SetVisible(false);
  231. }
  232. else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("交易失败")) == 0)
  233. {
  234. confirm_button->SetVisible(false);
  235. success_button->SetVisible(false);
  236. fail_button->SetVisible(false);
  237. agree_button->SetVisible(false);
  238. disagree_button->SetVisible(false);
  239. }
  240. else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("已取消")) == 0)
  241. {
  242. confirm_button->SetVisible(false);
  243. success_button->SetVisible(false);
  244. fail_button->SetVisible(false);
  245. agree_button->SetVisible(false);
  246. disagree_button->SetVisible(false);
  247. }
  248. else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("退款中")) == 0)
  249. {
  250. confirm_button->SetVisible(false);
  251. success_button->SetVisible(false);
  252. fail_button->SetVisible(false);
  253. agree_button->SetVisible(true);
  254. disagree_button->SetVisible(true);
  255. }
  256. }