CWaimaiOrderInfoUI.cpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  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. //开始处理骑手信息
  158. if (atoi(order.m_courier_id.c_str()) > 0)
  159. {
  160. //有人接单了
  161. this->FindSubControl(_T("waimai_order_info_page_qishouinfo"))->SetVisible(true);
  162. std::wstring qishou_name = L"骑手姓名:" + CLewaimaiString::UTF8ToUnicode(order.m_courier_name);
  163. this->FindSubControl(_T("waimai_order_info_page_qishou_name"))->SetText(qishou_name.c_str());
  164. std::wstring qishou_phone = L"骑手电话:" + CLewaimaiString::UTF8ToUnicode(order.m_courier_phone);
  165. this->FindSubControl(_T("waimai_order_info_page_qishou_phone"))->SetText(qishou_phone.c_str());
  166. std::wstring qishou_type;
  167. if (order.m_courier_type == "3")
  168. {
  169. qishou_type = L"骑手类型:快服务骑手";
  170. }
  171. else if (order.m_courier_type == "5")
  172. {
  173. qishou_type = L"骑手类型:达达骑手";
  174. }
  175. else
  176. {
  177. qishou_type = L"骑手类型:商家自配送骑手";
  178. }
  179. this->FindSubControl(_T("waimai_order_info_page_qishou_type"))->SetText(qishou_type.c_str());
  180. }
  181. else
  182. {
  183. this->FindSubControl(_T("waimai_order_info_page_qishouinfo"))->SetVisible(false);
  184. }
  185. if (order.m_is_selftake == "1")
  186. {
  187. CLabelUI *pDeliveryType = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_delivery_type")));
  188. wstring wsDeliveryType = _T("配送方式:到店自取(取餐号:") + CLewaimaiString::UTF8ToUnicode(order.m_take_food_code) + _T(")");
  189. pDeliveryType->SetText(wsDeliveryType.c_str());
  190. }
  191. else
  192. {
  193. CLabelUI *pDeliveryType = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_delivery_type")));
  194. wstring wsDeliveryType = _T("配送方式:外卖配送");
  195. pDeliveryType->SetText(wsDeliveryType.c_str());
  196. }
  197. CLabelUI *pType = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_type")));
  198. wstring wsType = _T("订单来源:") + CLewaimaiString::UTF8ToUnicode(order.m_from_type);
  199. pType->SetText(wsType.c_str());
  200. //预设选项
  201. CVerticalLayoutUI* pLayout = static_cast<CVerticalLayoutUI *>(this->FindSubControl(_T("waimai_order_info_page_field")));
  202. pLayout->RemoveAll();
  203. if (order.m_order_field.size() > 1)
  204. {
  205. for (std::vector<CWaimaiOrderField>::iterator it = order.m_order_field.begin(); it != order.m_order_field.end() - 1; it++)
  206. {
  207. wstring order_field = CLewaimaiString::UTF8ToUnicode((*it).name) + L":" + CLewaimaiString::UTF8ToUnicode((*it).value);
  208. CLabelUI* newField = new CLabelUI();
  209. newField->SetText(order_field.c_str());
  210. newField->SetFixedHeight(30);
  211. pLayout->Add(newField);
  212. }
  213. //这里预设选项默认有一个配送时间,所以要减1
  214. pLayout->SetFixedHeight((order.m_order_field.size() - 1) * 30);
  215. pLayout->SetVisible(true);
  216. }
  217. else
  218. {
  219. pLayout->SetVisible(false);
  220. }
  221. //配送时间
  222. wstring delivery_date;
  223. if (order.m_is_selftake == "1")
  224. {
  225. delivery_date = L"自取时间:" + CLewaimaiString::UTF8ToUnicode(order.m_delivery_date);
  226. }
  227. else
  228. {
  229. delivery_date = L"配送时间:" + CLewaimaiString::UTF8ToUnicode(order.m_delivery_date);
  230. }
  231. CLabelUI *pTime = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_delivery_time")));
  232. pTime->SetText(delivery_date.c_str());
  233. CLabelUI *pPayType = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_pay_type")));
  234. wstring wsPayType = _T("付款方式:") + CLewaimaiString::UTF8ToUnicode(order.m_pay_type);
  235. pPayType->SetText(wsPayType.c_str());
  236. //右侧按钮的控制
  237. CButtonUI* confirm_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_confirme")));
  238. CButtonUI* success_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_success")));
  239. CButtonUI* fail_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_fail")));
  240. CButtonUI* agree_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_agree")));
  241. CButtonUI* disagree_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_disagree")));
  242. CLabelUI *pRefundStatus = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_refund_status")));
  243. if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("未处理")) == 0)
  244. {
  245. confirm_button->SetVisible(true);
  246. success_button->SetVisible(false);
  247. fail_button->SetVisible(true);
  248. agree_button->SetVisible(false);
  249. disagree_button->SetVisible(false);
  250. pRefundStatus->SetVisible(false);
  251. }
  252. else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("已确认")) == 0)
  253. {
  254. confirm_button->SetVisible(false);
  255. success_button->SetVisible(true);
  256. fail_button->SetVisible(true);
  257. agree_button->SetVisible(false);
  258. disagree_button->SetVisible(false);
  259. pRefundStatus->SetVisible(false);
  260. }
  261. else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("交易成功")) == 0)
  262. {
  263. confirm_button->SetVisible(false);
  264. success_button->SetVisible(false);
  265. fail_button->SetVisible(false);
  266. agree_button->SetVisible(false);
  267. disagree_button->SetVisible(false);
  268. pRefundStatus->SetVisible(false);
  269. }
  270. else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("交易失败")) == 0)
  271. {
  272. confirm_button->SetVisible(false);
  273. success_button->SetVisible(false);
  274. fail_button->SetVisible(false);
  275. agree_button->SetVisible(false);
  276. disagree_button->SetVisible(false);
  277. pRefundStatus->SetVisible(false);
  278. }
  279. else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("已取消")) == 0)
  280. {
  281. confirm_button->SetVisible(false);
  282. success_button->SetVisible(false);
  283. fail_button->SetVisible(false);
  284. agree_button->SetVisible(false);
  285. disagree_button->SetVisible(false);
  286. pRefundStatus->SetVisible(false);
  287. }
  288. else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("退款中")) == 0)
  289. {
  290. confirm_button->SetVisible(false);
  291. success_button->SetVisible(false);
  292. fail_button->SetVisible(false);
  293. std::string refund_status = m_order.m_refund_status;
  294. if (refund_status == "1")
  295. {
  296. agree_button->SetVisible(true);
  297. disagree_button->SetVisible(true);
  298. }
  299. else if (refund_status == "5")
  300. {
  301. agree_button->SetVisible(true);
  302. disagree_button->SetVisible(false);
  303. }
  304. else
  305. {
  306. agree_button->SetVisible(false);
  307. disagree_button->SetVisible(false);
  308. }
  309. pRefundStatus->SetVisible(true);
  310. std::wstring refund_status_text = L"退款状态:";
  311. if (refund_status == "1")
  312. {
  313. refund_status_text += L"顾客申请退款,等待商家处理";
  314. }
  315. else if (refund_status == "2")
  316. {
  317. refund_status_text += L"退款成功,订单失败";
  318. }
  319. else if (refund_status == "3")
  320. {
  321. refund_status_text += L"商家已拒绝退款,等待顾客受理";
  322. }
  323. else if (refund_status == "4")
  324. {
  325. refund_status_text += L"退款失败,订单变为已确认";
  326. }
  327. else if (refund_status == "5")
  328. {
  329. refund_status_text += L"顾客再次发起退款,等待客服介入处理中";
  330. }
  331. pRefundStatus->SetText(refund_status_text.c_str());
  332. }
  333. }