Commit 3dae89576ed60c11056634da05f0e621472b6807

Authored by liuye
1 parent e3d9764a

feat<central_clearing_system>:调整下单流程,未完成,剩余支付打印接口未调

central_clearing_system/Config/menu_res_auth_cfg.json
... ... @@ -6,19 +6,19 @@
6 6 {"res_id":2, "auth_id":1010, "icon":"", "index":[1]},
7 7 {"res_id":20001, "auth_id":101001, "icon":"user_manage.ico", "index":[1, 0]},
8 8 {"res_id":20002, "auth_id":101002, "icon":"role_manage.ico", "index":[1, 1]},
9   - {"res_id":20003, "auth_id":101003, "icon":"role_manage.ico", "index":[1, 2]},
10   - {"res_id":30001, "auth_id":103001, "icon":"role_manage.ico", "index":[2]},
  9 + {"res_id":20003, "auth_id":101003, "icon":"trade.ico", "index":[1, 2]},
  10 + {"res_id":30001, "auth_id":103001, "icon":"trade.ico", "index":[2]},
11 11 {"res_id":4, "auth_id":1020, "icon":"", "index":[3]},
12   - {"res_id":40001, "auth_id":102001, "icon":"user_manage.ico", "index":[3, 0]},
13   - {"res_id":40002, "auth_id":102002, "icon":"user_manage.ico", "index":[3, 1]},
14   - {"res_id":40003, "auth_id":102003, "icon":"user_manage.ico", "index":[3, 2]},
15   - {"res_id":40004, "auth_id":102004, "icon":"user_manage.ico", "index":[3, 3]},
16   - {"res_id":40005, "auth_id":102005, "icon":"user_manage.ico", "index":[3, 4]},
  12 + {"res_id":40001, "auth_id":102001, "icon":"trade.ico", "index":[3, 0]},
  13 + {"res_id":40002, "auth_id":102002, "icon":"trade.ico", "index":[3, 1]},
  14 + {"res_id":40003, "auth_id":102003, "icon":"trade.ico", "index":[3, 2]},
  15 + {"res_id":40004, "auth_id":102004, "icon":"trade.ico", "index":[3, 3]},
  16 + {"res_id":40005, "auth_id":102005, "icon":"trade.ico", "index":[3, 4]},
17 17 {"res_id":5, "auth_id":1040, "icon":"", "index":[4]},
18   - {"res_id":50001, "auth_id":104001, "icon":"user_manage.ico", "index":[4, 0]},
19   - {"res_id":50002, "auth_id":104002, "icon":"user_manage.ico", "index":[4, 1]},
20   - {"res_id":50003, "auth_id":104003, "icon":"user_manage.ico", "index":[4, 2]},
21   - {"res_id":50004, "auth_id":104004, "icon":"user_manage.ico", "index":[4, 3]},
22   - {"res_id":11001, "auth_id":0, "icon":"exit.ico", "index":[]},
23   - {"res_id":11002, "auth_id":0, "icon":"modify_account_pwd.ico","index":[]}
  18 + {"res_id":50001, "auth_id":104001, "icon":"trade.ico", "index":[4, 0]},
  19 + {"res_id":50002, "auth_id":104002, "icon":"trade.ico", "index":[4, 1]},
  20 + {"res_id":50003, "auth_id":104003, "icon":"trade.ico", "index":[4, 2]},
  21 + {"res_id":50004, "auth_id":104004, "icon":"trade.ico", "index":[4, 3]},
  22 + {"res_id":11001, "auth_id":0, "icon":"exit.ico", "index":[]},
  23 + {"res_id":11002, "auth_id":0, "icon":"modify_account_pwd.ico", "index":[]}
24 24 ]
25 25 \ No newline at end of file
... ...
central_clearing_system/Config/url_cfg.json
1 1 {
2 2 "protocol": "http",
3 3 "host": "xtrade.esc.diligrp.com",
4   - "port": 80,
  4 + "port": 8080,
5 5 "main_path": "/iset/oauth/clientInitMain.iset",
6 6 "login_path": "/iset/oauth/login.auth",
7 7 "logout_path": "/iset/oauth/logout.auth",
... ...
central_clearing_system/ETradeClient.rc
... ... @@ -258,7 +258,7 @@ BEGIN
258 258 LTEXT "总计金额:",IDC_PAY_STATIC_TOTAL_MONEY,18,20,41,8
259 259 LTEXT "",IDC_PAY_STATIC_MONEY,73,20,8,8
260 260 LTEXT "密 码:",IDC_PAY_STATIC_PASSWORD,18,50,31,8
261   - EDITTEXT IDC_PAY_EDIT_PASSWORD,56,46,40,14,ES_MULTILINE | ES_AUTOHSCROLL
  261 + EDITTEXT IDC_PAY_EDIT_PASSWORD,56,46,40,14,ES_PASSWORD | ES_AUTOHSCROLL
262 262 PUSHBUTTON "输入密码(&A)",IDC_PAY_BUTTON_PASSWORD,151,51,71,18
263 263 PUSHBUTTON "关闭(&S)",IDC_PAY_BUTTON_CLOSE,155,94,67,17
264 264 PUSHBUTTON "付款(&F)",IDC_PAY_BUTTON_PAY,72,94,67,17
... ... @@ -337,7 +337,6 @@ BEGIN
337 337  
338 338 IDD_DIALOG_PLACE_ORDER, DIALOG
339 339 BEGIN
340   - MOCKUP, 1, 50, -25, -30, "C:\Users\WangGY\Desktop\TIM图片20180918183513.png"
341 340 RIGHTMARGIN, 337
342 341 HORZGUIDE, 67
343 342 END
... ...
central_clearing_system/ETradeClient/hardware/hardware_cmd.cpp
... ... @@ -52,6 +52,8 @@ namespace StatusCode
52 52 static const std::string PWD_MACHINE_GET_KEY_FAILED = "402"; // 从加密机读取密钥失败.
53 53  
54 54 static const std::string BANK_CARD_READ_CARD_NUM_FAILED = "501"; // 读取银行卡卡号失败.
  55 +
  56 + static const std::string PRINT_PARSE_DATA_FAILED = "601"; //解析打印数据失败
55 57 }
56 58  
57 59 namespace EncryptTools
... ... @@ -1277,12 +1279,17 @@ StylusPrinterCmd::Reply StylusPrinterCmd::Execute(const std::string&amp; input)
1277 1279 {
1278 1280 LOG_TRACE(L"开始打印");
1279 1281 Reply reply;
  1282 + reply.error_code = StatusCode::OK;
1280 1283  
1281 1284 std::vector<OrderInfo> comm_vector;
1282 1285 do
1283 1286 {
1284 1287 LOG_TRACE(L"解析打印数据!");
1285   - ParseInput(const_cast<std::string&>(input), comm_vector);
  1288 + reply.error_code = ParseInput(const_cast<std::string&>(input), comm_vector);
  1289 + if (reply.error_code.compare(StatusCode::OK) != 0)
  1290 + {
  1291 + break;
  1292 + }
1286 1293 Print(comm_vector);
1287 1294 } while (0);
1288 1295  
... ... @@ -1517,9 +1524,9 @@ static const std::string JSON_TAG_TRADE_TOTAL_MONEY = &quot;totalMoney&quot;;
1517 1524 static const std::string JSON_TAG_TRADE_PRODUCTS = "products";
1518 1525  
1519 1526  
1520   -bool StylusPrinterCmd::ParseInput(std::string &input, std::vector<OrderInfo> &order_vector)
  1527 +std::string StylusPrinterCmd::ParseInput(std::string &input, std::vector<OrderInfo> &order_vector)
1521 1528 {
1522   - int result = 0;
  1529 + std::string result = StatusCode::OK;
1523 1530  
1524 1531 namespace PT = boost::property_tree;
1525 1532 try //Parse the configuration file
... ... @@ -1535,22 +1542,22 @@ bool StylusPrinterCmd::ParseInput(std::string &amp;input, std::vector&lt;OrderInfo&gt; &amp;or
1535 1542 {
1536 1543 OrderInfo order;
1537 1544 order.doc_name = title.c_str();
1538   - order.statements_no = v.second.get<std::string>(JSON_TAG_STATEMENT_ID).c_str();
1539   - order.trade_time = v.second.get<std::string>(JSON_TAG_TRADE_TIME).c_str();
1540   - order.buyer_name = v.second.get<std::string>(JSON_TAG_TRADE_BUYER_NAME).c_str();
1541   - order.seller_name = v.second.get<std::string>(JSON_TAG_TRADE_SELLER_NAME).c_str();
1542   - order.settlement_clerk = v.second.get<std::string>(JSON_TAG_TRADE_USER_NAME).c_str();
1543   - order.total_money = v.second.get<std::string>(JSON_TAG_TRADE_TOTAL_MONEY).c_str();
  1545 + order.statements_no = str_2_wstr(v.second.get<std::string>(JSON_TAG_STATEMENT_ID)).c_str();
  1546 + order.trade_time = str_2_wstr(v.second.get<std::string>(JSON_TAG_TRADE_TIME)).c_str();
  1547 + order.buyer_name = str_2_wstr(v.second.get<std::string>(JSON_TAG_TRADE_BUYER_NAME)).c_str();
  1548 + order.seller_name = str_2_wstr(v.second.get<std::string>(JSON_TAG_TRADE_SELLER_NAME)).c_str();
  1549 + order.settlement_clerk = str_2_wstr(v.second.get<std::string>(JSON_TAG_TRADE_USER_NAME)).c_str();
  1550 + order.total_money = str_2_wstr(v.second.get<std::string>(JSON_TAG_TRADE_TOTAL_MONEY)).c_str();
1544 1551  
1545 1552 PT::ptree products_ptree = v.second.get_child(JSON_TAG_TRADE_PRODUCTS);
1546 1553 BOOST_FOREACH(PT::ptree::value_type &v, products_ptree)
1547 1554 {
1548 1555 CommInfo comm_info;
1549 1556 comm_info.comm_id = v.second.get<long>(JSON_TAG_ORDER_ID);
1550   - comm_info.comm_name = v.second.get<std::string>(JSON_TAG_PRODUCT_NAME).c_str();
1551   - comm_info.price = v.second.get<std::string>(JSON_TAG_PRICE).c_str();
1552   - comm_info.count = v.second.get<std::string>(JSON_TAG_AMOUNT).c_str();
1553   - comm_info.total_money = v.second.get<std::string>(JSON_TAG_MONEY).c_str();
  1557 + comm_info.comm_name = str_2_wstr(v.second.get<std::string>(JSON_TAG_PRODUCT_NAME)).c_str();
  1558 + comm_info.price = str_2_wstr(v.second.get<std::string>(JSON_TAG_PRICE)).c_str();
  1559 + comm_info.count = str_2_wstr(v.second.get<std::string>(JSON_TAG_AMOUNT)).c_str();
  1560 + comm_info.total_money = str_2_wstr(v.second.get<std::string>(JSON_TAG_MONEY)).c_str();
1554 1561 order.comm_vector.push_back(comm_info);
1555 1562 }
1556 1563 order_vector.push_back(order);
... ... @@ -1559,7 +1566,7 @@ bool StylusPrinterCmd::ParseInput(std::string &amp;input, std::vector&lt;OrderInfo&gt; &amp;or
1559 1566 catch (...)
1560 1567 {
1561 1568 LOG_ERROR(L"解析服务器返回的打印信息时出错!请确认返回数据不为空,返回的数据格式为正确的Json格式!");
1562   - result = 1000;
  1569 + result = StatusCode::PRINT_PARSE_DATA_FAILED;
1563 1570 }
1564 1571 return result;
1565 1572 }
1566 1573 \ No newline at end of file
... ...
central_clearing_system/ETradeClient/mfc_ui/pay_dlg.cpp
... ... @@ -55,6 +55,7 @@ BEGIN_MESSAGE_MAP(PayDlg, CDialogEx)
55 55 ON_BN_CLICKED(IDC_PAY_BUTTON_CLOSE, &PayDlg::OnBnClickedPayButtonClose)
56 56 ON_BN_CLICKED(IDC_PAY_BUTTON_PAY, &PayDlg::OnBnClickedPayButtonPay)
57 57 ON_WM_CTLCOLOR()
  58 + ON_BN_CLICKED(IDC_PAY_BUTTON_PASSWORD, &PayDlg::OnBnClickedPayButtonPassword)
58 59 END_MESSAGE_MAP()
59 60  
60 61  
... ... @@ -120,6 +121,8 @@ void PayDlg::SetCtrlPos()
120 121 CRect dlg_rect;
121 122 GetClientRect(&dlg_rect);
122 123  
  124 + ctrl_rect.top = ctrl_rect.bottom + 10;
  125 + ctrl_rect.bottom = ctrl_rect.top + StaticHeigth;
123 126 ctrl_rect.left = 30;
124 127 ctrl_rect.right = dlg_rect.right - 30;
125 128 error_msg_static_.MoveWindow(&ctrl_rect);
... ... @@ -148,13 +151,18 @@ void PayDlg::OnBnClickedPayButtonClose()
148 151 CDialogEx::OnCancel();
149 152 }
150 153  
  154 +#include "etradeclient/hardware/hardware_cmd.h"
  155 +#include "etradeclient/boost_patch/property_tree/json_parser.hpp"
  156 +#include "ETradeClient/utility/logging.h"
151 157  
152 158 void PayDlg::OnBnClickedPayButtonPay()
153 159 {
  160 +
  161 + CString error_msg;
  162 +
154 163 std::string statement_data;
155 164 do
156 165 {
157   - CString error_msg;
158 166 const uint32_t kHTTPOK = 200;
159 167 WinHttp win_http;
160 168 auto& url_cfg = URLConfig::Instance();
... ... @@ -205,13 +213,13 @@ void PayDlg::OnBnClickedPayButtonPay()
205 213 std::stringstream ss;
206 214 ss << response_body;
207 215 PT::read_json(ss, ptree);
208   - if (ptree.get<int>("code") == 0)
  216 + if (ptree.get<long>("code") == 0)
209 217 {
210 218 statement_data = ptree.get<std::string>("data");
211 219 }
212 220 else
213 221 {
214   - error_msg = ptree.get<std::string>("message").c_str();
  222 + error_msg = str_2_wstr(ptree.get<std::string>("message")).c_str();
215 223 break;
216 224 }
217 225  
... ... @@ -224,10 +232,16 @@ void PayDlg::OnBnClickedPayButtonPay()
224 232 }
225 233 } while (0);
226 234  
227   - auto printer_device = StylusPrinterCmd();
228   - HardwareCmd::Reply reply = printer_device.Execute(statement_data);
229   -
230   - CDialogEx::OnCancel();
  235 + if (!error_msg.IsEmpty())
  236 + {
  237 + SetErrorMsg(error_msg);
  238 + }
  239 + else if (!statement_data.empty())
  240 + {
  241 + auto printer_device = StylusPrinterCmd();
  242 + HardwareCmd::Reply reply = printer_device.Execute(statement_data);
  243 + CDialogEx::OnCancel();
  244 + }
231 245 }
232 246  
233 247 void PayDlg::SetErrorMsg(CString error)
... ... @@ -250,3 +264,48 @@ HBRUSH PayDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
250 264  
251 265 return hbr;
252 266 }
  267 +
  268 +
  269 +void PayDlg::OnBnClickedPayButtonPassword()
  270 +{
  271 + auto pin_pad = ReadPINPadCmd();
  272 + HardwareCmd::Reply reply = pin_pad.Execute("");
  273 + CString error_msg;
  274 + do
  275 + {
  276 + if (reply.error_code.compare("") != 0)
  277 + {
  278 + if (reply.error_code.compare("100") == 0)
  279 + {
  280 + error_msg = L"连接密码键盘失败";
  281 + }
  282 + else if (reply.error_code.compare("101") == 0)
  283 + {
  284 + error_msg = L"用户密码输入超时";
  285 + }
  286 + else if (reply.error_code.compare("102") == 0)
  287 + {
  288 + error_msg = L"用户取消密码输入";
  289 + }
  290 + else if (reply.error_code.compare("103") == 0)
  291 + {
  292 + error_msg = L"读取密码失败";
  293 + }
  294 + else
  295 + {
  296 + error_msg = L"读卡失败";
  297 + }
  298 + std::wstring log = L"支付时输入密码错误,错误码:" + str_2_wstr(reply.error_code);
  299 + LOG_ERROR(log);
  300 + break;
  301 + }
  302 +
  303 + boost::property_tree::ptree password_child = reply.data.get_child("password");
  304 + std::string password = password_child.data();
  305 + password_edit_.SetWindowText(CString(password.c_str()));
  306 + } while (0);
  307 + if (!error_msg.IsEmpty())
  308 + {
  309 + SetErrorMsg(error_msg);
  310 + }
  311 +}
... ...
central_clearing_system/ETradeClient/mfc_ui/pay_dlg.h
1 1 #pragma once
2 2 #include "afxwin.h"
  3 +#include "etrade_edit_control.h"
3 4  
4 5  
5 6 // PayDlg ¶Ô»°¿ò
... ... @@ -33,7 +34,7 @@ private:
33 34 CStatic total_money_static_;
34 35 CStatic real_money_static_;
35 36 CStatic password_static_;
36   - CEdit password_edit_;
  37 + CEditBox password_edit_;
37 38 CButton pay_button_;
38 39 CButton close_button_;
39 40 CButton password_button_;
... ... @@ -42,4 +43,6 @@ private:
42 43 long statement_id_;
43 44 CString total_money_;
44 45 int card_type_;
  46 +public:
  47 + afx_msg void OnBnClickedPayButtonPassword();
45 48 };
... ...
central_clearing_system/ETradeClient/mfc_ui/place_order_dlg.cpp
... ... @@ -356,10 +356,11 @@ HBRUSH PlaceOrderDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
356 356  
357 357 void PlaceOrderDlg::OnBnClickedButtonPay()
358 358 {
  359 + SetErrorMsg(CString(L""));
359 360 int row_count = product_list_.GetRowCount();
360   - if (row_count == 0)
  361 + if (row_count == 1)
361 362 {
362   - SetErrorMsg(CString(L"订单信息为空"));
  363 + SetErrorMsg(CString(L"订单信息为空"));
363 364 return;
364 365 }
365 366  
... ... @@ -378,19 +379,22 @@ void PlaceOrderDlg::OnBnClickedButtonPay()
378 379 };
379 380 std::vector<Order> orders_list;
380 381 Order current_order;
381   - for (int row = 0; row < row_count; ++row)
  382 + for (int row = 1; row < row_count; ++row)
382 383 {
383   - std::string card = wstr_2_str(product_list_.GetItemText(row, 0));
  384 + std::string card = wstr_2_str(std::wstring(product_list_.GetItemText(row, 0)));
384 385 if (card.compare(current_order.seller_card) != 0)
385 386 {
386   - orders_list.push_back(current_order);
  387 + if (row != 1)
  388 + {
  389 + orders_list.push_back(current_order);
  390 + }
387 391 current_order.comm_vec.clear();
388 392 current_order.seller_card = card;
389 393 }
390 394  
391 395 Comm comm_info;
392 396 CGridCellBase* product_cell = product_list_.GetCell(row, 2);
393   - comm_info.product_id == product_cell->product_id;
  397 + comm_info.product_id = product_cell->product_id;
394 398 comm_info.price = wstr_2_str(product_list_.GetItemText(row, 3));
395 399 comm_info.amount = wstr_2_str(product_list_.GetItemText(row, 4));
396 400 comm_info.unit = product_list_.GetItemText(row, 5).Compare(L"斤") == 0 ? "1" : "2";
... ... @@ -398,6 +402,7 @@ void PlaceOrderDlg::OnBnClickedButtonPay()
398 402  
399 403 current_order.comm_vec.push_back(comm_info);
400 404 }
  405 + orders_list.push_back(current_order);
401 406  
402 407 CString buyer_card;
403 408 buyer_card_edit_.GetWindowText(buyer_card);
... ... @@ -412,7 +417,7 @@ void PlaceOrderDlg::OnBnClickedButtonPay()
412 417 auto& url_cfg = URLConfig::Instance();
413 418 win_http.ConnectHost(url_cfg.Host(), url_cfg.Port(), url_cfg.IsHttps());
414 419 std::string url = url_cfg.GetSubmitOrdersPath();
415   - auto& request = win_http.OpenRequest(WinHttp::Method::POST, url);
  420 + auto& request = win_http.OpenRequest(WinHttp::Method::JSONPOST, url);
416 421  
417 422 std::string post_data = "{\"paymentType\":1,\"cardNo\":\"" + wstr_2_str(buyer_card) + "\",\"orders\":[";
418 423 for (auto iter_order : orders_list)
... ... @@ -429,7 +434,6 @@ void PlaceOrderDlg::OnBnClickedButtonPay()
429 434 post_data.erase(post_data.end() - 1);
430 435 post_data += "]}";
431 436  
432   -
433 437 request.SetPostData(post_data);
434 438 if (url_cfg.IsHttps())
435 439 {
... ... @@ -442,7 +446,7 @@ void PlaceOrderDlg::OnBnClickedButtonPay()
442 446 if (kHTTPOK != status_code)
443 447 {
444 448 std::string err_msg = "网络请求错误! 错误码: " + std::to_string(status_code);
445   - LOG_ERROR(str_2_wstr(err_msg.c_str()));
  449 + LOG_ERROR(CString(err_msg.c_str()).GetBuffer());
446 450 error_msg = err_msg.c_str();
447 451 break;
448 452 }
... ... @@ -462,7 +466,7 @@ void PlaceOrderDlg::OnBnClickedButtonPay()
462 466 std::stringstream ss;
463 467 ss << response_body;
464 468 PT::read_json(ss, ptree);
465   - if (ptree.get<int>("code") == 0)
  469 + if (ptree.get<long>("code") == 0)
466 470 {
467 471 PT::ptree statement_data = ptree.get_child("data");
468 472 statement_id = statement_data.get<long>("statementId");
... ... @@ -470,7 +474,8 @@ void PlaceOrderDlg::OnBnClickedButtonPay()
470 474 }
471 475 else
472 476 {
473   - error_msg = ptree.get<std::string>("message").c_str();
  477 + std::wstring error = str_2_wstr(ptree.get<std::string>("message"));
  478 + error_msg = error.c_str();
474 479 break;
475 480 }
476 481  
... ... @@ -489,7 +494,7 @@ void PlaceOrderDlg::OnBnClickedButtonPay()
489 494 }
490 495 else
491 496 {
492   - EmptyCtrl();
  497 + EmptyCtrl(true);
493 498 SetCtrlInitData();
494 499 InitList();
495 500 comm_id_index_;
... ... @@ -639,7 +644,7 @@ void PlaceOrderDlg::OnAcceleratorEnter()
639 644 product_list_.SetItemFormat(row_index, index, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
640 645 }
641 646  
642   - EmptyCtrl();
  647 + EmptyCtrl(false);
643 648 SortList();
644 649  
645 650 CString subtotal;
... ... @@ -696,6 +701,8 @@ void PlaceOrderDlg::SetErrorMsg(CString &amp;error)
696 701  
697 702 LRESULT PlaceOrderDlg::OnEditKillFocus(WPARAM wParam, LPARAM lParam)
698 703 {
  704 + SetErrorMsg(CString(L""));
  705 +
699 706 int dlg_id = wParam;
700 707  
701 708 CString text;
... ... @@ -734,17 +741,17 @@ LRESULT PlaceOrderDlg::OnEditKillFocus(WPARAM wParam, LPARAM lParam)
734 741 comm_num_edit_.SetEditRed(true);
735 742 break;
736 743 }
737   - CString buyer_card;
738   - buyer_card_edit_.GetWindowText(buyer_card);
739   - bool result = GetCommName(text, buyer_card, name, product_id_);
  744 + CString seller_card;
  745 + card_edit_.GetWindowText(seller_card);
  746 + bool result = GetCommName(text, seller_card, name, product_id_);
740 747 if (result)
741 748 {
742   - name_edit_.SetWindowText(name);
  749 + comm_name_edit_.SetWindowText(name);
743 750 comm_num_edit_.SetEditRed(false);
744 751 }
745 752 else
746 753 {
747   - SetErrorMsg(name);
  754 + //SetErrorMsg(name);
748 755 comm_num_edit_.SetEditRed(true);
749 756 }
750 757  
... ... @@ -852,18 +859,18 @@ bool PlaceOrderDlg::GetCardName(CString &amp;num, CString &amp;name, int type)
852 859 std::stringstream ss;
853 860 ss << response_body;
854 861 PT::read_json(ss, ptree);
855   - std::string res = ptree.get<std::string>("code");
856   - card_res = res.compare(0) == 0 ? true : false;
857   - if (!card_res)
  862 + long res = ptree.get<long>("code");
  863 + card_res = res == 0 ? true : false;
  864 + if (card_res)
858 865 {
859 866 PT::ptree card_data = ptree.get_child("data");
860   - name = card_data.get<std::string>("name").c_str();
  867 + name = str_2_wstr(card_data.get<std::string>("name")).c_str();
861 868 buyer_card_type_ = card_data.get<int>("category");
862 869 }
863 870 else
864 871 {
865   - std::string error_msg = ptree.get<std::string>("message");
866   - name = CString(error_msg.c_str());
  872 + std::wstring error_msg = str_2_wstr(ptree.get<std::string>("message"));
  873 + name = error_msg.c_str();
867 874 result = false;
868 875 break;
869 876 }
... ... @@ -883,8 +890,9 @@ bool PlaceOrderDlg::GetCardName(CString &amp;num, CString &amp;name, int type)
883 890  
884 891 bool PlaceOrderDlg::GetCommName(CString &num, CString& card, CString &name, CString &product_id)
885 892 {
  893 + SetErrorMsg(CString(L""));
886 894 bool result = true;
887   -
  895 + CString error_msg;
888 896 LOG_TRACE(_T("获取商品名称!"));
889 897 do
890 898 {
... ... @@ -906,15 +914,16 @@ bool PlaceOrderDlg::GetCommName(CString &amp;num, CString&amp; card, CString &amp;name, CStr
906 914 {
907 915 std::string err_msg = "网络请求错误! 错误码: " + std::to_string(status_code);
908 916 LOG_ERROR(str_2_wstr(err_msg.c_str()));
909   - name = CString(L"网络请求错误!");
  917 + error_msg = CString(L"网络请求错误!");
910 918 result = false;
911 919 break;
912 920 }
913 921 std::string response_body = request.ReadResponseBody();
  922 +
914 923 if (response_body.empty())
915 924 {
916 925 LOG_ERROR(L"获取服务器响应数据失败,请确保网络连接正常!");
917   - name = CString(L"获取服务器响应数据失败,请确保网络连接正常!");
  926 + error_msg = CString(L"获取服务器响应数据失败,请确保网络连接正常!");
918 927 result = false;
919 928 break;
920 929 }
... ... @@ -927,19 +936,19 @@ bool PlaceOrderDlg::GetCommName(CString &amp;num, CString&amp; card, CString &amp;name, CStr
927 936 std::stringstream ss;
928 937 ss << response_body;
929 938 PT::read_json(ss, ptree);
930   - std::string res = ptree.get<std::string>("code");
931   - card_res = res.compare(0) == 0 ? true : false;
932   - if (!card_res)
  939 + long res = ptree.get<long>("code");
  940 + card_res = res == 0 ? true : false;
  941 + if (card_res)
933 942 {
934 943 PT::ptree card_data = ptree.get_child("data");
935   - name = ptree.get<std::string>("productName").c_str();
936   - long id = ptree.get<long>("id");
  944 + name = str_2_wstr(card_data.get<std::string>("name")).c_str();
  945 + long id = card_data.get<long>("id");
937 946 product_id.Format(L"%ld", id);
938 947 }
939 948 else
940 949 {
941   - std::string error_msg = ptree.get<std::string>("message");
942   - name = CString(error_msg.c_str());
  950 + std::wstring error_msg = str_2_wstr(ptree.get<std::string>("message"));
  951 + error_msg = CString(error_msg.c_str());
943 952 result = false;
944 953 break;
945 954 }
... ... @@ -954,6 +963,11 @@ bool PlaceOrderDlg::GetCommName(CString &amp;num, CString&amp; card, CString &amp;name, CStr
954 963 }
955 964 } while (0);
956 965  
  966 + if (!error_msg.IsEmpty())
  967 + {
  968 + SetErrorMsg(error_msg);
  969 + }
  970 +
957 971 return result;
958 972 }
959 973  
... ... @@ -1102,7 +1116,7 @@ void PlaceOrderDlg::SortList()
1102 1116 product_list_.Invalidate(TRUE);
1103 1117 }
1104 1118  
1105   -void PlaceOrderDlg::EmptyCtrl()
  1119 +void PlaceOrderDlg::EmptyCtrl(bool is_empty_buyer)
1106 1120 {
1107 1121 card_edit_.SetWindowText(L"8888");
1108 1122 name_edit_.SetWindowText(L"");
... ... @@ -1115,16 +1129,21 @@ void PlaceOrderDlg::EmptyCtrl()
1115 1129 price_edit_.SetWindowText(L"");
1116 1130 count_edit_.SetWindowText(L"");
1117 1131  
1118   - buyer_card_edit_.SetWindowTextW(L"");
1119   - buyer_name_edit_.SetWindowTextW(L"");
1120   - total_real_money_static_.SetWindowTextW(L"0.00");
  1132 + if (is_empty_buyer)
  1133 + {
  1134 + buyer_card_edit_.SetWindowTextW(L"");
  1135 + buyer_name_edit_.SetWindowTextW(L"");
  1136 + total_real_money_static_.SetWindowTextW(L"0.00");
  1137 + }
  1138 +
1121 1139  
1122 1140 card_edit_.SetSel(4, 4);
1123 1141 }
1124 1142  
1125 1143 void PlaceOrderDlg::OnBnClickedButtonSwipCard()
1126 1144 {
1127   - EmptyCtrl();
  1145 + SetErrorMsg(CString(L""));
  1146 + EmptyCtrl(true);
1128 1147 InitList();
1129 1148 pay_button_.EnableWindow(FALSE);
1130 1149  
... ...
central_clearing_system/ETradeClient/mfc_ui/place_order_dlg.h
... ... @@ -72,7 +72,7 @@ private:
72 72 void SetCtrlInitData();
73 73 void InitList();
74 74 void SortList();
75   - void EmptyCtrl();
  75 + void EmptyCtrl(bool is_empty_buyer);
76 76 void EnableCtrl(bool is_enable);
77 77  
78 78 int GetCommIndex();
... ...
central_clearing_system/ETradeClient/utility/url_config.cpp
... ... @@ -97,6 +97,7 @@ void URLConfig::ModifyCfg(bool is_https, uint16_t port)
97 97 root.put("user_msg_path", m_user_msg_path);
98 98 root.put("modify_pwd_path", m_modify_pwd_path);
99 99 root.put("get_card_name_path", m_get_card_name_path);
  100 + root.put("get_seller_card_path", m_get_seller_card_path);
100 101 root.put("get_product_name_path", m_get_product_path);
101 102 root.put("submit_orders_path", m_submit_orders_path);
102 103 root.put("finish_order_path", m_finish_order_path);
... ... @@ -190,5 +191,5 @@ std::string URLConfig::GetSubmitOrdersPath() const
190 191 }
191 192 std::string URLConfig::GetSellerCardPath() const
192 193 {
193   - return m_get_seller_path;
  194 + return m_get_seller_card_path;
194 195 }
195 196 \ No newline at end of file
... ...
central_clearing_system/ETradeClient/utility/url_config.h
... ... @@ -51,7 +51,6 @@ private:
51 51 std::string m_modify_pwd_path;
52 52 std::string m_get_card_name_path;
53 53 std::string m_get_seller_card_path;
54   - std::string m_get_seller_path;
55 54 std::string m_get_product_path;
56 55 std::string m_submit_orders_path;
57 56 std::string m_finish_order_path;
... ...
central_clearing_system/ETradeClient/utility/win_http.cpp
... ... @@ -270,6 +270,9 @@ void WinHttp::Request::Send()
270 270 case Method::POST:
271 271 Post();
272 272 break;
  273 + case Method::JSONPOST:
  274 + JsonPost();
  275 + break;
273 276 default:
274 277 return;
275 278 }
... ... @@ -369,6 +372,22 @@ void WinHttp::Request::Post()
369 372 }
370 373 }
371 374  
  375 +void WinHttp::Request::JsonPost()
  376 +{
  377 + // Send a request.
  378 + if (!WinHttpSendRequest(m_request,
  379 + L"Content-Type: application/json; charset=UTF-8", // headers.
  380 + -1,
  381 + const_cast<char*>(m_post_data.c_str()),
  382 + m_post_data.size(),
  383 + m_post_data.size(),
  384 + 0))
  385 + {
  386 + std::string err_msg("发送WinHttp Post请求失败!错误代码:" + std::to_string(GetLastError()));
  387 + throw std::exception(err_msg.c_str());
  388 + }
  389 +}
  390 +
372 391 void WinHttp::Request::QuerySingleHeader(std::wstring& header, uint32_t query_info_flag, DWORD* header_idx) const
373 392 {
374 393 DWORD buff_len = 0;
... ...
central_clearing_system/ETradeClient/utility/win_http.h
... ... @@ -32,6 +32,7 @@ public:
32 32 {
33 33 GET = 0,
34 34 POST,
  35 + JSONPOST
35 36 };
36 37  
37 38 typedef std::list<Cookie> Cookies;
... ... @@ -63,6 +64,7 @@ public:
63 64  
64 65 void Get();
65 66 void Post();
  67 + void JsonPost();
66 68  
67 69 // Refer to: https://msdn.microsoft.com/en-us/library/aa384070%28v=vs.85%29.aspx
68 70 void QuerySingleHeader(std::wstring& header, uint32_t query_info_flag, DWORD* header_idx) const;
... ...
central_clearing_system/Resource.h
... ... @@ -69,41 +69,33 @@
69 69 #define IDC_PAY_BUTTON_PAY 1052
70 70 #define IDC_PAY_STATIC_REAL_MONEY 1053
71 71 #define IDC_STATIC_ERROR_MSG 1054
72   -
73 72 #define ID_ORDER 10001
74 73 #define ID_STATEMENT_MANAGE 10002
75 74 #define ID_ORDERFORM_MANAGE 10003
76   -
77 75 #define ID_EXIT 11001
78 76 #define ID_MODIFY_PASSWORD 11002
79   -
80 77 #define ID_COMM_REGIST 20001
81 78 #define ID_COMM_DISTRIB 20002
82 79 #define ID_QUERY_MANAGE 20003
83   -
84 80 #define ID_SPECIAL_HANDLE 30001
85   -
  81 +#define ID_MENU_DELETE 32846
  82 +#define ID_POPMENU_LIST 32848
  83 +#define ID_POPMENU_DELETE 32850
  84 +#define ID_ACCELERATOR_TAB 32851
  85 +#define ID_ACCELERATOR_ENTER 32852
  86 +#define ID_ACCELERATOR_UP 32854
  87 +#define ID_ACCELERATOR_DOWN 32855
  88 +#define ID_ACCELERATOR_F11 32857
86 89 #define ID_POINT_RULE 40001
87 90 #define ID_CATEGORY_RULE 40002
88 91 #define ID_AGREEMENT 40003
89 92 #define ID_TAPE_HANDLE 40004
90 93 #define ID_CREDIT 40005
91   -
92 94 #define ID_USER_MANAGE 50001
93 95 #define ID_ROLE_MANAGE 50002
94 96 #define ID_PARAM_SET 50003
95 97 #define ID_LOG 50004
96 98  
97   -#define ID_MENU_DELETE 32846
98   -#define ID_POPMENU_LIST 32848
99   -#define ID_POPMENU_DELETE 32850
100   -#define ID_ACCELERATOR_TAB 32851
101   -#define ID_ACCELERATOR_ENTER 32852
102   -#define ID_ACCELERATOR_UP 32854
103   -#define ID_ACCELERATOR_DOWN 32855
104   -#define ID_ACCELERATOR_F11 32857
105   -
106   -
107 99 // Next default values for new objects
108 100 //
109 101 #ifdef APSTUDIO_INVOKED
... ...