CWaimaiOrderInfoUI.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  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_num);
  13. this->FindSubControl(_T("waimai_order_info_page_order_num"))->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. int order_item_height = (order.m_order_items.size() + 1) * 30;
  34. pFoodList->SetFixedHeight(order_item_height);
  35. CLabelUI *pMemo = static_cast<CLabelUI *>(this->FindSubControl(_T("waimaorder_info_page_memo")));
  36. wstring memo = _T("备注:") + CLewaimaiString::UTF8ToUnicode(order.m_memo);
  37. pMemo->SetText(memo.c_str());
  38. //开始展示各种费用
  39. CVerticalLayoutUI* pFeesLayout = static_cast<CVerticalLayoutUI *>(this->FindSubControl(_T("waimai_order_info_page_fees")));
  40. pFeesLayout->RemoveAll();
  41. int fees_num = 0;
  42. if (order.m_delivery > 0)
  43. {
  44. CLabelUI *pDlieveryFee = new CLabelUI;
  45. pDlieveryFee->SetFixedHeight(30);
  46. wstring delivery_fee = L"配送费:" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString((double)order.m_delivery, 2));
  47. pDlieveryFee->SetText(delivery_fee.c_str());
  48. pFeesLayout->Add(pDlieveryFee);
  49. fees_num++;
  50. }
  51. if (order.m_is_dabao == "1")
  52. {
  53. CLabelUI *pDabaoFee = new CLabelUI;
  54. pDabaoFee->SetFixedHeight(30);
  55. wstring dabao_fee = L"打包费:" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString((double)order.m_delivery, 2));
  56. pDabaoFee->SetText(dabao_fee.c_str());
  57. pFeesLayout->Add(pDabaoFee);
  58. fees_num++;
  59. }
  60. //增值服务费
  61. if (order.m_addservie.size() > 0)
  62. {
  63. for (std::vector<CWaimaiOrderField>::iterator it = order.m_addservie.begin(); it != order.m_addservie.end(); it++)
  64. {
  65. wstring addservice = CLewaimaiString::UTF8ToUnicode((*it).name) + L":" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString((double)atof((*it).value.c_str()), 2));
  66. CLabelUI* newField = new CLabelUI();
  67. newField->SetText(addservice.c_str());
  68. newField->SetFixedHeight(30);
  69. pFeesLayout->Add(newField);
  70. fees_num++;
  71. }
  72. }
  73. //店铺折扣
  74. if (order.m_discount < 10)
  75. {
  76. CLabelUI *pDiscountFee = new CLabelUI;
  77. pDiscountFee->SetFixedHeight(30);
  78. wstring discount = L"店铺折扣:" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString((double)order.m_discount, 2)) + L"折";
  79. pDiscountFee->SetText(discount.c_str());
  80. pFeesLayout->Add(pDiscountFee);
  81. fees_num++;
  82. }
  83. //会员优惠
  84. if (order.m_is_member_discount == "1")
  85. {
  86. CLabelUI *pMemberFee = new CLabelUI;
  87. pMemberFee->SetFixedHeight(30);
  88. wstring memberfee = L"会员优惠:-" + CLewaimaiString::UTF8ToUnicode(order.m_member_discount);
  89. pMemberFee->SetText(memberfee.c_str());
  90. pFeesLayout->Add(pMemberFee);
  91. fees_num++;
  92. }
  93. //首单优惠
  94. if (order.m_is_firstcut == "1")
  95. {
  96. CLabelUI *pFirstCut = new CLabelUI;
  97. pFirstCut->SetFixedHeight(30);
  98. wstring firstcut = L"首单优惠:-" + CLewaimaiString::UTF8ToUnicode(order.m_firstcut_value);
  99. pFirstCut->SetText(firstcut.c_str());
  100. pFeesLayout->Add(pFirstCut);
  101. fees_num++;
  102. }
  103. //满减
  104. string::size_type position = order.m_promotion.find(":");
  105. if (position != order.m_promotion.npos)
  106. {
  107. CLabelUI *pManjian = new CLabelUI;
  108. pManjian->SetFixedHeight(30);
  109. string promotion_value;
  110. promotion_value.assign(order.m_promotion, position + 1);
  111. wstring promotion = L"满减优惠:-" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString((double)(atof(promotion_value.c_str())), 2));
  112. pManjian->SetText(promotion.c_str());
  113. pFeesLayout->Add(pManjian);
  114. fees_num++;
  115. }
  116. //优惠券
  117. if (order.m_coupon > 0)
  118. {
  119. CLabelUI *pCoupon = new CLabelUI;
  120. pCoupon->SetMaxHeight(30);
  121. wstring coupon = L"优惠券:-" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString((double)order.m_coupon, 2));
  122. pCoupon->SetText(coupon.c_str());
  123. pFeesLayout->Add(pCoupon);
  124. fees_num++;
  125. }
  126. int fees_height;
  127. if (fees_num == 0)
  128. {
  129. pFeesLayout->SetVisible(false);
  130. this->FindSubControl(_T("waimai_order_info_page_fees_line"))->SetVisible(false);
  131. fees_height = 0;
  132. }
  133. else
  134. {
  135. pFeesLayout->SetVisible(true);
  136. this->FindSubControl(_T("waimai_order_info_page_fees_line"))->SetVisible(true);
  137. pFeesLayout->SetFixedHeight(fees_num * 30);
  138. fees_height = fees_num * 30;
  139. }
  140. CLabelUI *pTotalPrice = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_totalprice")));
  141. wstring price = L"总计:¥" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(order.m_price, 2));
  142. pTotalPrice->SetText(price.c_str());
  143. int nTotalHeight = order_item_height + fees_height + 133;
  144. this->FindSubControl(_T("waimai_order_info_page_layout_1"))->SetFixedHeight(nTotalHeight);
  145. //开始显示顾客信息
  146. std::wstring name_show = L"姓名:" + CLewaimaiString::UTF8ToUnicode(order.m_customer_name);
  147. this->FindSubControl(_T("waimai_order_info_page_name"))->SetText(name_show.c_str());
  148. std::wstring phone_show = L"电话:" + CLewaimaiString::UTF8ToUnicode(order.m_phone);
  149. this->FindSubControl(_T("waimai_order_info_page_phone"))->SetText(phone_show.c_str());
  150. std::wstring address_show = L"地址:" + CLewaimaiString::UTF8ToUnicode(order.m_address);
  151. this->FindSubControl(_T("waimai_order_info_page_address"))->SetText(address_show.c_str());
  152. std::wstring order_date_show = L"下单时间:" + CLewaimaiString::UTF8ToUnicode(order.m_order_date);
  153. this->FindSubControl(_T("waimai_order_info_page_init_date"))->SetText(order_date_show.c_str());
  154. //开始处理骑手信息
  155. if (atoi(order.m_courier_id.c_str()) > 0)
  156. {
  157. //有人接单了
  158. this->FindSubControl(_T("waimai_order_info_page_qishouinfo"))->SetVisible(true);
  159. std::wstring qishou_name = L"骑手姓名:" + CLewaimaiString::UTF8ToUnicode(order.m_courier_name);
  160. this->FindSubControl(_T("waimai_order_info_page_qishou_name"))->SetText(qishou_name.c_str());
  161. std::wstring qishou_phone = L"骑手电话:" + CLewaimaiString::UTF8ToUnicode(order.m_courier_phone);
  162. this->FindSubControl(_T("waimai_order_info_page_qishou_phone"))->SetText(qishou_phone.c_str());
  163. std::wstring qishou_type = L"骑手类型:商家自配送骑手";
  164. this->FindSubControl(_T("waimai_order_info_page_qishou_type"))->SetText(qishou_type.c_str());
  165. }
  166. else
  167. {
  168. this->FindSubControl(_T("waimai_order_info_page_qishouinfo"))->SetVisible(false);
  169. }
  170. //开始处理订单信息
  171. if (order.m_is_selftake == "1")
  172. {
  173. CLabelUI *pDeliveryType = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_delivery_type")));
  174. wstring wsDeliveryType = _T("配送方式:到店自取");
  175. pDeliveryType->SetText(wsDeliveryType.c_str());
  176. }
  177. else
  178. {
  179. std::wstring wsDeliveryMode;
  180. if (order.m_delivery_mode == "1")
  181. {
  182. wsDeliveryMode = L"(平台专送)";
  183. }
  184. else if (order.m_delivery_mode == "2")
  185. {
  186. wsDeliveryMode = L"(商家自配送)";
  187. }
  188. CLabelUI *pDeliveryType = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_delivery_type")));
  189. wstring wsDeliveryType = _T("配送方式:外卖配送") + wsDeliveryMode;
  190. pDeliveryType->SetText(wsDeliveryType.c_str());
  191. }
  192. CLabelUI *pStatus = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_status")));
  193. wstring wsStatus = _T("订单状态:") + CLewaimaiString::UTF8ToUnicode(order.m_order_status);
  194. if (CLewaimaiString::UTF8ToUnicode(order.m_order_status) == _T("交易失败"))
  195. {
  196. wsStatus += _T(",失败原因:") + CLewaimaiString::UTF8ToUnicode(order.m_failed_reason);
  197. }
  198. pStatus->SetText(wsStatus.c_str());
  199. CLabelUI *pType = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_type")));
  200. wstring wsType = _T("订单来源:") + CLewaimaiString::UTF8ToUnicode(order.m_from_type);
  201. pType->SetText(wsType.c_str());
  202. //预设选项
  203. CVerticalLayoutUI* pLayout = static_cast<CVerticalLayoutUI *>(this->FindSubControl(_T("waimai_order_info_page_field")));
  204. pLayout->RemoveAll();
  205. int order_filed_height;
  206. if (order.m_order_field.size() > 1)
  207. {
  208. for (std::vector<CWaimaiOrderField>::iterator it = order.m_order_field.begin(); it != order.m_order_field.end() - 1; it++)
  209. {
  210. wstring order_field = CLewaimaiString::UTF8ToUnicode((*it).name) + L":" + CLewaimaiString::UTF8ToUnicode((*it).value);
  211. CLabelUI* newField = new CLabelUI();
  212. newField->SetText(order_field.c_str());
  213. newField->SetFixedHeight(30);
  214. pLayout->Add(newField);
  215. }
  216. //这里预设选项默认有一个配送时间,所以要减1
  217. pLayout->SetFixedHeight((order.m_order_field.size() - 1) * 30);
  218. order_filed_height = (order.m_order_field.size() - 1) * 30;
  219. pLayout->SetVisible(true);
  220. }
  221. else
  222. {
  223. order_filed_height = 0;
  224. pLayout->SetVisible(false);
  225. }
  226. //配送时间
  227. wstring delivery_date;
  228. if (order.m_is_selftake == "1")
  229. {
  230. delivery_date = L"自取时间:" + CLewaimaiString::UTF8ToUnicode(order.m_delivery_date);
  231. }
  232. else
  233. {
  234. delivery_date = L"配送时间:" + CLewaimaiString::UTF8ToUnicode(order.m_delivery_date);
  235. }
  236. CLabelUI *pTime = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_delivery_time")));
  237. pTime->SetText(delivery_date.c_str());
  238. CLabelUI *pPayType = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_pay_type")));
  239. wstring wsPayType = _T("付款方式:") + CLewaimaiString::UTF8ToUnicode(order.m_pay_type);
  240. pPayType->SetText(wsPayType.c_str());
  241. if (CLewaimaiString::UTF8ToUnicode(order.m_pay_type) != L"货到付款")
  242. {
  243. this->FindSubControl(_T("waimai_order_info_page_huodaofukuan"))->SetVisible(true);
  244. }
  245. else
  246. {
  247. this->FindSubControl(_T("waimai_order_info_page_huodaofukuan"))->SetVisible(false);
  248. }
  249. //右侧按钮的控制
  250. CButtonUI* confirm_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_confirme")));
  251. CButtonUI* success_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_success")));
  252. CButtonUI* fail_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_fail")));
  253. CButtonUI* agree_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_agree")));
  254. CButtonUI* disagree_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_disagree")));
  255. CButtonUI* refund_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_refund")));
  256. CLabelUI *pRefundStatus = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_refund_status")));
  257. int refundHeight = 0;
  258. if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("未处理")) == 0)
  259. {
  260. confirm_button->SetVisible(true);
  261. success_button->SetVisible(false);
  262. fail_button->SetVisible(true);
  263. agree_button->SetVisible(false);
  264. disagree_button->SetVisible(false);
  265. refund_button->SetVisible(false);
  266. pRefundStatus->SetVisible(false);
  267. }
  268. else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("已确认")) == 0)
  269. {
  270. confirm_button->SetVisible(false);
  271. success_button->SetVisible(true);
  272. fail_button->SetVisible(true);
  273. agree_button->SetVisible(false);
  274. disagree_button->SetVisible(false);
  275. refund_button->SetVisible(false);
  276. pRefundStatus->SetVisible(false);
  277. }
  278. else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("交易成功")) == 0)
  279. {
  280. confirm_button->SetVisible(false);
  281. success_button->SetVisible(false);
  282. fail_button->SetVisible(false);
  283. agree_button->SetVisible(false);
  284. disagree_button->SetVisible(false);
  285. refund_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. agree_button->SetVisible(false);
  294. disagree_button->SetVisible(false);
  295. std::string refund_status = m_order.m_refund_status;
  296. if (CLewaimaiString::UTF8ToUnicode(order.m_pay_type) != L"货到付款")
  297. {
  298. pRefundStatus->SetVisible(true);
  299. refundHeight = 30;
  300. std::wstring refund_status_text = L"退款状态:";
  301. if (refund_status == "0")
  302. {
  303. refund_button->SetVisible(true);
  304. refund_status_text += L"未处理";
  305. }
  306. else if (refund_status == "10")
  307. {
  308. refund_button->SetVisible(false);
  309. refund_status_text += L"退款处理中,等待退款结果";
  310. }
  311. else if (refund_status == "11")
  312. {
  313. refund_button->SetVisible(false);
  314. refund_status_text += L"退款已完成";
  315. }
  316. else if (refund_status == "12")
  317. {
  318. refund_button->SetVisible(false);
  319. refund_status_text += L"退款失败,原因:" + CLewaimaiString::UTF8ToUnicode(order.m_refund_failed_reason);
  320. }
  321. pRefundStatus->SetText(refund_status_text.c_str());
  322. }
  323. else
  324. {
  325. refund_button->SetVisible(false);
  326. pRefundStatus->SetVisible(false);
  327. }
  328. }
  329. else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("已取消")) == 0)
  330. {
  331. confirm_button->SetVisible(false);
  332. success_button->SetVisible(false);
  333. fail_button->SetVisible(false);
  334. agree_button->SetVisible(false);
  335. disagree_button->SetVisible(false);
  336. refund_button->SetVisible(false);
  337. pRefundStatus->SetVisible(false);
  338. }
  339. else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("退款中")) == 0)
  340. {
  341. confirm_button->SetVisible(false);
  342. success_button->SetVisible(false);
  343. fail_button->SetVisible(false);
  344. std::string refund_status = m_order.m_refund_status;
  345. if (refund_status == "1")
  346. {
  347. agree_button->SetVisible(true);
  348. disagree_button->SetVisible(true);
  349. }
  350. else if (refund_status == "5")
  351. {
  352. agree_button->SetVisible(true);
  353. disagree_button->SetVisible(false);
  354. }
  355. else
  356. {
  357. agree_button->SetVisible(false);
  358. disagree_button->SetVisible(false);
  359. }
  360. refund_button->SetVisible(false);
  361. pRefundStatus->SetVisible(true);
  362. refundHeight = 30;
  363. std::wstring refund_status_text = L"退款状态:";
  364. if (refund_status == "1")
  365. {
  366. refund_status_text += L"顾客申请退款,等待商家处理";
  367. }
  368. else if (refund_status == "2")
  369. {
  370. refund_status_text += L"退款成功,订单失败";
  371. }
  372. else if (refund_status == "3")
  373. {
  374. refund_status_text += L"商家已拒绝退款,等待顾客受理";
  375. }
  376. else if (refund_status == "4")
  377. {
  378. refund_status_text += L"退款失败,订单变为已确认";
  379. }
  380. else if (refund_status == "5")
  381. {
  382. refund_status_text += L"顾客再次发起退款,等待客服介入处理中";
  383. }
  384. pRefundStatus->SetText(refund_status_text.c_str());
  385. }
  386. //如果是平台专送模式,商家不能设为成功和失败
  387. if (order.m_delivery_mode == "1")
  388. {
  389. success_button->SetVisible(false);
  390. fail_button->SetVisible(false);
  391. }
  392. int configMemoHeight = 0;
  393. CLabelUI *pConfigmemo = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_configmemo")));
  394. if (m_order.m_configmemo != "")
  395. {
  396. configMemoHeight = 30;
  397. wstring configMemo = L"商家备注:" + CLewaimaiString::UTF8ToUnicode(order.m_configmemo);
  398. pConfigmemo->SetText(configMemo.c_str());
  399. pConfigmemo->SetVisible(true);
  400. }
  401. else
  402. {
  403. configMemoHeight = 0;
  404. pConfigmemo->SetVisible(false);
  405. }
  406. this->FindSubControl(_T("waimai_order_info_page_layout_3"))->SetFixedHeight(order_filed_height + refundHeight + configMemoHeight + 181);
  407. }