| | |
| | | return SubscriptCodesResult({ fresults ,updateTime }); |
| | | } |
| | | |
| | | SubscriptCodesResult NetworkApi::get_huaxin_position_subscript_codes() |
| | | { |
| | | rapidjson::StringBuffer buf; |
| | | rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(buf); |
| | | writer.StartObject(); |
| | | writer.Key("type"); |
| | | writer.String("get_huaxin_position_subscript_codes"); |
| | | writer.Key("data"); |
| | | writer.StartObject(); |
| | | writer.EndObject(); |
| | | writer.EndObject(); |
| | | const char* json_content = buf.GetString(); |
| | | string result = base_trade_request(std::string(json_content)); |
| | | rapidjson::GenericDocument<rapidjson::UTF16<>> doc = JsonUtil::parseUTF16(result); |
| | | std::list<CodeInfo> fresults; |
| | | CString updateTime = L""; |
| | | if (doc.IsObject() && doc[L"code"].GetInt() == 0) { |
| | | |
| | | for (int i = 0; i < doc[L"data"][L"list"].GetArray().Size(); i++) { |
| | | auto arr = doc[L"data"][L"list"].GetArray()[i].GetArray(); |
| | | CString code = arr[0].GetString(); |
| | | CString codeName = arr[1].IsNull() ? L"δ֪" : arr[1].GetString(); |
| | | CodeInfo ci = CodeInfo({ code ,codeName }); |
| | | fresults.push_back(ci); |
| | | } |
| | | updateTime = doc[L"data"][L"update_time"].GetString(); |
| | | } |
| | | return SubscriptCodesResult({ fresults ,updateTime }); |
| | | } |
| | | |
| | | string NetworkApi::export_l2_data(CString code) |
| | | { |
| | | |
| | |
| | | rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(buf); |
| | | writer.StartObject(); |
| | | writer.Key("type"); |
| | | writer.String("common"); |
| | | writer.String("get_buy1_info"); |
| | | writer.Key("data"); |
| | | writer.StartObject(); |
| | | writer.Key("ctype"); |
| | | writer.String("get_buy1_info"); |
| | | writer.Key("code"); |
| | | writer.String(code.c_str()); |
| | | writer.EndObject(); |
| | |
| | | return result; |
| | | } |
| | | |
| | | void NetworkApi::set_per_code_buy_money(int money) |
| | | { |
| | | rapidjson::StringBuffer buf; |
| | | rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(buf); |
| | | writer.StartObject(); |
| | | writer.Key("type"); |
| | | writer.String("common"); |
| | | writer.Key("data"); |
| | | writer.StartObject(); |
| | | writer.Key("ctype"); |
| | | writer.String("set_per_code_buy_money"); |
| | | writer.Key("money"); |
| | | writer.Int(money); |
| | | writer.EndObject(); |
| | | writer.EndObject(); |
| | | const char* json_content = buf.GetString(); |
| | | string result = base_request(std::string(json_content)); |
| | | auto root = JsonUtil::parseUTF16(result); |
| | | if (root.IsObject()) { |
| | | if (root[L"code"] != 0) { |
| | | throw wstring(root[L"msg"].GetString()); |
| | | } |
| | | } |
| | | else { |
| | | throw wstring(L"网络请求错误"); |
| | | } |
| | | } |
| | | |
| | | int NetworkApi::get_per_code_buy_money() |
| | | { |
| | | rapidjson::StringBuffer buf; |
| | | rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(buf); |
| | | writer.StartObject(); |
| | | writer.Key("type"); |
| | | writer.String("common"); |
| | | writer.Key("data"); |
| | | writer.StartObject(); |
| | | writer.Key("ctype"); |
| | | writer.String("get_per_code_buy_money"); |
| | | writer.EndObject(); |
| | | writer.EndObject(); |
| | | const char* json_content = buf.GetString(); |
| | | string result = base_request(std::string(json_content)); |
| | | auto root=JsonUtil::parseUTF16(result); |
| | | if (root.IsObject()) { |
| | | if (root[L"code"].GetInt() == 0) { |
| | | return root[L"data"][L"money"].GetInt(); |
| | | } |
| | | else { |
| | | |
| | | throw wstring(root[L"msg"].GetString()); |
| | | } |
| | | |
| | | } |
| | | else { |
| | | throw wstring(L"网络请求出错"); |
| | | } |
| | | } |
| | | |
| | | string NetworkApi::get_l2_deal_price(string code) |
| | | { |
| | | rapidjson::StringBuffer buf; |
| | | rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(buf); |
| | | writer.StartObject(); |
| | | writer.Key("type"); |
| | | writer.String("common"); |
| | | writer.Key("data"); |
| | | writer.StartObject(); |
| | | writer.Key("ctype"); |
| | | writer.String("get_l2_deal_price"); |
| | | writer.Key("code"); |
| | | writer.String(code.c_str()); |
| | | writer.EndObject(); |
| | | writer.EndObject(); |
| | | const char* json_content = buf.GetString(); |
| | | string result = base_request(std::string(json_content)); |
| | | return result; |
| | | } |
| | | |
| | | |
| | | string NetworkApi::repaire_task() |
| | | { |
| | | rapidjson::StringBuffer buf; |
| | | rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(buf); |
| | | writer.StartObject(); |
| | | writer.Key("type"); |
| | | writer.String("common"); |
| | | writer.Key("data"); |
| | | writer.StartObject(); |
| | | writer.Key("ctype"); |
| | | writer.String("repaire_task"); |
| | | writer.EndObject(); |
| | | writer.EndObject(); |
| | | const char* json_content = buf.GetString(); |
| | | string result = base_request(std::string(json_content)); |
| | | return result; |
| | | } |
| | | |
| | | string NetworkApi::list_delegate_records(CString updateTime,bool canCancel) |
| | | { |
| | | rapidjson::StringBuffer buf; |