CWaimaiOrderInfoUI.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  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. 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. //商品券
  127. if (atof(order.m_goods_coupon_value.c_str()) > 0.0001)
  128. {
  129. CLabelUI *pGoodsCoupon = new CLabelUI;
  130. pGoodsCoupon->SetFixedHeight(30);
  131. wstring goods_coupon = L"商品券:-" + CLewaimaiString::UTF8ToUnicode(order.m_goods_coupon_value);
  132. pGoodsCoupon->SetText(goods_coupon.c_str());
  133. pFeesLayout->Add(pGoodsCoupon);
  134. fees_num++;
  135. }
  136. int fees_height;
  137. if (fees_num == 0)
  138. {
  139. pFeesLayout->SetVisible(false);
  140. this->FindSubControl(_T("waimai_order_info_page_fees_line"))->SetVisible(false);
  141. fees_height = 0;
  142. }
  143. else
  144. {
  145. pFeesLayout->SetVisible(true);
  146. this->FindSubControl(_T("waimai_order_info_page_fees_line"))->SetVisible(true);
  147. pFeesLayout->SetFixedHeight(fees_num * 30);
  148. fees_height = fees_num * 30;
  149. }
  150. CLabelUI *pTotalPrice = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_totalprice")));
  151. wstring price = L"总计:¥" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(order.m_price, 2));
  152. pTotalPrice->SetText(price.c_str());
  153. int nTotalHeight = order_item_height + fees_height + 133;
  154. this->FindSubControl(_T("waimai_order_info_page_layout_1"))->SetFixedHeight(nTotalHeight);
  155. //开始显示顾客信息
  156. std::wstring name_show = L"姓名:" + CLewaimaiString::UTF8ToUnicode(order.m_customer_name);
  157. this->FindSubControl(_T("waimai_order_info_page_name"))->SetText(name_show.c_str());
  158. std::wstring phone_show = L"电话:" + CLewaimaiString::UTF8ToUnicode(order.m_phone);
  159. this->FindSubControl(_T("waimai_order_info_page_phone"))->SetText(phone_show.c_str());
  160. std::wstring address_show = L"地址:" + CLewaimaiString::UTF8ToUnicode(order.m_address);
  161. this->FindSubControl(_T("waimai_order_info_page_address"))->SetText(address_show.c_str());
  162. std::wstring order_date_show = L"下单时间:" + CLewaimaiString::UTF8ToUnicode(order.m_order_date);
  163. this->FindSubControl(_T("waimai_order_info_page_init_date"))->SetText(order_date_show.c_str());
  164. //开始处理骑手信息
  165. if (atoi(order.m_courier_id.c_str()) > 0)
  166. {
  167. //有人接单了
  168. this->FindSubControl(_T("waimai_order_info_page_qishouinfo"))->SetVisible(true);
  169. std::wstring qishou_name = L"骑手姓名:" + CLewaimaiString::UTF8ToUnicode(order.m_courier_name);
  170. this->FindSubControl(_T("waimai_order_info_page_qishou_name"))->SetText(qishou_name.c_str());
  171. std::wstring qishou_phone = L"骑手电话:" + CLewaimaiString::UTF8ToUnicode(order.m_courier_phone);
  172. this->FindSubControl(_T("waimai_order_info_page_qishou_phone"))->SetText(qishou_phone.c_str());
  173. std::wstring qishou_type;
  174. if (order.m_courier_type == "3")
  175. {
  176. qishou_type = L"骑手类型:快服务骑手";
  177. }
  178. else if (order.m_courier_type == "5")
  179. {
  180. qishou_type = L"骑手类型:达达骑手";
  181. }
  182. else
  183. {
  184. qishou_type = L"骑手类型:商家自配送骑手";
  185. }
  186. this->FindSubControl(_T("waimai_order_info_page_qishou_type"))->SetText(qishou_type.c_str());
  187. }
  188. else
  189. {
  190. this->FindSubControl(_T("waimai_order_info_page_qishouinfo"))->SetVisible(false);
  191. }
  192. //开始处理订单信息
  193. if (order.m_is_selftake == "1")
  194. {
  195. CLabelUI *pDeliveryType = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_delivery_type")));
  196. wstring wsDeliveryType = _T("配送方式:到店自取(取餐号:") + CLewaimaiString::UTF8ToUnicode(order.m_take_food_code) + _T(")");
  197. pDeliveryType->SetText(wsDeliveryType.c_str());
  198. }
  199. else
  200. {
  201. CLabelUI *pDeliveryType = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_delivery_type")));
  202. wstring wsDeliveryType = _T("配送方式:外卖配送");
  203. pDeliveryType->SetText(wsDeliveryType.c_str());
  204. }
  205. CLabelUI *pStatus = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_status")));
  206. wstring wsStatus = _T("订单状态:") + CLewaimaiString::UTF8ToUnicode(order.m_order_status);
  207. if (CLewaimaiString::UTF8ToUnicode(order.m_order_status) == _T("交易失败"))
  208. {
  209. wsStatus += _T(",失败原因:") + CLewaimaiString::UTF8ToUnicode(order.m_failed_reason);
  210. }
  211. pStatus->SetText(wsStatus.c_str());
  212. CLabelUI *pType = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_type")));
  213. wstring wsType = _T("订单来源:") + CLewaimaiString::UTF8ToUnicode(order.m_from_type);
  214. pType->SetText(wsType.c_str());
  215. //预设选项
  216. CVerticalLayoutUI* pLayout = static_cast<CVerticalLayoutUI *>(this->FindSubControl(_T("waimai_order_info_page_field")));
  217. pLayout->RemoveAll();
  218. int order_filed_height;
  219. if (order.m_order_field.size() > 1)
  220. {
  221. for (std::vector<CWaimaiOrderField>::iterator it = order.m_order_field.begin(); it != order.m_order_field.end() - 1; it++)
  222. {
  223. wstring order_field = CLewaimaiString::UTF8ToUnicode((*it).name) + L":" + CLewaimaiString::UTF8ToUnicode((*it).value);
  224. CLabelUI* newField = new CLabelUI();
  225. newField->SetText(order_field.c_str());
  226. newField->SetFixedHeight(30);
  227. pLayout->Add(newField);
  228. }
  229. //这里预设选项默认有一个配送时间,所以要减1
  230. pLayout->SetFixedHeight((order.m_order_field.size() - 1) * 30);
  231. order_filed_height = (order.m_order_field.size() - 1) * 30;
  232. pLayout->SetVisible(true);
  233. }
  234. else
  235. {
  236. order_filed_height = 0;
  237. pLayout->SetVisible(false);
  238. }
  239. //配送时间
  240. wstring delivery_date;
  241. if (order.m_is_selftake == "1")
  242. {
  243. delivery_date = L"自取时间:" + CLewaimaiString::UTF8ToUnicode(order.m_delivery_date);
  244. }
  245. else
  246. {
  247. delivery_date = L"配送时间:" + CLewaimaiString::UTF8ToUnicode(order.m_delivery_date);
  248. }
  249. CLabelUI *pTime = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_delivery_time")));
  250. pTime->SetText(delivery_date.c_str());
  251. CLabelUI *pPayType = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_pay_type")));
  252. wstring wsPayType = _T("付款方式:") + CLewaimaiString::UTF8ToUnicode(order.m_pay_type);
  253. pPayType->SetText(wsPayType.c_str());
  254. if (CLewaimaiString::UTF8ToUnicode(order.m_pay_type) == L"货到付款")
  255. {
  256. this->FindSubControl(_T("waimai_order_info_page_huodaofukuan"))->SetVisible(true);
  257. }
  258. else
  259. {
  260. this->FindSubControl(_T("waimai_order_info_page_huodaofukuan"))->SetVisible(false);
  261. }
  262. //右侧按钮的控制
  263. CButtonUI* confirm_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_confirme")));
  264. CButtonUI* success_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_success")));
  265. CButtonUI* fail_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_fail")));
  266. CButtonUI* agree_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_agree")));
  267. CButtonUI* disagree_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_disagree")));
  268. CButtonUI* refund_button = static_cast<CButtonUI *>(m_pManager->FindControl(_T("waimai_order_info_page_refund")));
  269. CLabelUI *pRefundStatus = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_refund_status")));
  270. int refundHeight = 0;
  271. if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("未处理")) == 0)
  272. {
  273. confirm_button->SetVisible(true);
  274. success_button->SetVisible(false);
  275. fail_button->SetVisible(true);
  276. agree_button->SetVisible(false);
  277. disagree_button->SetVisible(false);
  278. refund_button->SetVisible(false);
  279. pRefundStatus->SetVisible(false);
  280. }
  281. else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("已确认")) == 0)
  282. {
  283. confirm_button->SetVisible(false);
  284. success_button->SetVisible(true);
  285. fail_button->SetVisible(true);
  286. agree_button->SetVisible(false);
  287. disagree_button->SetVisible(false);
  288. refund_button->SetVisible(false);
  289. pRefundStatus->SetVisible(false);
  290. }
  291. else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("交易成功")) == 0)
  292. {
  293. confirm_button->SetVisible(false);
  294. success_button->SetVisible(false);
  295. fail_button->SetVisible(false);
  296. agree_button->SetVisible(false);
  297. disagree_button->SetVisible(false);
  298. refund_button->SetVisible(false);
  299. pRefundStatus->SetVisible(false);
  300. }
  301. else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("交易失败")) == 0)
  302. {
  303. confirm_button->SetVisible(false);
  304. success_button->SetVisible(false);
  305. fail_button->SetVisible(false);
  306. agree_button->SetVisible(false);
  307. disagree_button->SetVisible(false);
  308. std::string refund_status = m_order.m_refund_status;
  309. if (CLewaimaiString::UTF8ToUnicode(order.m_pay_type) != L"货到付款")
  310. {
  311. pRefundStatus->SetVisible(true);
  312. refundHeight = 30;
  313. std::wstring refund_status_text = L"退款状态:";
  314. if (refund_status == "0")
  315. {
  316. refund_button->SetVisible(true);
  317. refund_status_text += L"未处理";
  318. }
  319. else if (refund_status == "10")
  320. {
  321. refund_button->SetVisible(false);
  322. refund_status_text += L"退款处理中,等待退款结果";
  323. }
  324. else if (refund_status == "11")
  325. {
  326. refund_button->SetVisible(false);
  327. refund_status_text += L"退款已完成";
  328. }
  329. else if (refund_status == "12")
  330. {
  331. refund_button->SetVisible(false);
  332. refund_status_text += L"退款失败,原因:" + CLewaimaiString::UTF8ToUnicode(order.m_refund_failed_reason);
  333. }
  334. pRefundStatus->SetText(refund_status_text.c_str());
  335. }
  336. else
  337. {
  338. refund_button->SetVisible(false);
  339. pRefundStatus->SetVisible(false);
  340. }
  341. }
  342. else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("已取消")) == 0)
  343. {
  344. confirm_button->SetVisible(false);
  345. success_button->SetVisible(false);
  346. fail_button->SetVisible(false);
  347. agree_button->SetVisible(false);
  348. disagree_button->SetVisible(false);
  349. refund_button->SetVisible(false);
  350. pRefundStatus->SetVisible(false);
  351. }
  352. else if (_tcscmp(CLewaimaiString::UTF8ToUnicode(order.m_order_status).c_str(), _T("退款中")) == 0)
  353. {
  354. confirm_button->SetVisible(false);
  355. success_button->SetVisible(false);
  356. fail_button->SetVisible(false);
  357. refund_button->SetVisible(false);
  358. std::string refund_status = m_order.m_refund_status;
  359. if (refund_status == "1")
  360. {
  361. agree_button->SetVisible(true);
  362. disagree_button->SetVisible(true);
  363. }
  364. else if (refund_status == "5")
  365. {
  366. agree_button->SetVisible(true);
  367. disagree_button->SetVisible(false);
  368. }
  369. else
  370. {
  371. agree_button->SetVisible(false);
  372. disagree_button->SetVisible(false);
  373. }
  374. pRefundStatus->SetVisible(true);
  375. refundHeight = 30;
  376. std::wstring refund_status_text = L"退款状态:";
  377. if (refund_status == "1")
  378. {
  379. refund_status_text += L"顾客申请退款,等待商家处理";
  380. }
  381. else if (refund_status == "2")
  382. {
  383. refund_status_text += L"退款成功,订单失败";
  384. }
  385. else if (refund_status == "3")
  386. {
  387. refund_status_text += L"商家已拒绝退款,等待顾客受理";
  388. }
  389. else if (refund_status == "4")
  390. {
  391. refund_status_text += L"退款失败,订单变为已确认";
  392. }
  393. else if (refund_status == "5")
  394. {
  395. refund_status_text += L"顾客再次发起退款,等待客服介入处理中";
  396. }
  397. pRefundStatus->SetText(refund_status_text.c_str());
  398. }
  399. int configMemoHeight = 0;
  400. CLabelUI *pConfigmemo = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_configmemo")));
  401. if (m_order.m_configmemo != "")
  402. {
  403. configMemoHeight = 30;
  404. wstring configMemo = L"商家备注:" + CLewaimaiString::UTF8ToUnicode(order.m_configmemo);
  405. pConfigmemo->SetText(configMemo.c_str());
  406. pConfigmemo->SetVisible(true);
  407. }
  408. else
  409. {
  410. configMemoHeight = 0;
  411. pConfigmemo->SetVisible(false);
  412. }
  413. this->FindSubControl(_T("waimai_order_info_page_layout_3"))->SetFixedHeight(order_filed_height + refundHeight + configMemoHeight + 181);
  414. }