|
@@ -5,6 +5,25 @@
|
|
|
mongocxx::instance g_instance{};
|
|
|
using namespace bsoncxx::builder::basic;
|
|
|
|
|
|
+
|
|
|
+bool comparegamelist(const rapidjson::Value& a, const rapidjson::Value& b)
|
|
|
+{
|
|
|
+ if (!a.HasMember("SortID") || !strcmp(a["SortID"].GetString(), "-1"))
|
|
|
+ return false;
|
|
|
+ if (!b.HasMember("SortID") || !strcmp(b["SortID"].GetString(), "-1"))
|
|
|
+ return true;
|
|
|
+
|
|
|
+ std::string stra = a["SortID"].GetString();
|
|
|
+ std::string strb = b["SortID"].GetString();
|
|
|
+
|
|
|
+ if (stra.empty() || strb.empty())
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return std::stoi(a["SortID"].GetString()) < std::stoi(b["SortID"].GetString());
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
HttpSocket::HttpSocket()
|
|
|
{
|
|
|
m_random = std::default_random_engine(time(NULL));
|
|
@@ -14,7 +33,9 @@ HttpSocket::HttpSocket()
|
|
|
std::string strkkk3 = "mongodb://127.0.0.1:27017";
|
|
|
m_puri = boost::make_shared<mongocxx::uri>(strkkk3.c_str());
|
|
|
}
|
|
|
+
|
|
|
m_pclient = boost::make_shared <mongocxx::client>(*m_puri);
|
|
|
+ m_platform = boost::make_shared<mongocxx::database>();
|
|
|
m_pdb = boost::make_shared<mongocxx::database>();
|
|
|
m_gamelog = boost::make_shared<mongocxx::database>();
|
|
|
m_pvipuserdb = boost::make_shared<mongocxx::database>();
|
|
@@ -34,9 +55,11 @@ HttpSocket::HttpSocket()
|
|
|
m_pthreeadmin = boost::make_shared<mongocxx::collection>();
|
|
|
m_pgameprizelog = boost::make_shared<mongocxx::collection>();
|
|
|
m_pvipconfigure = boost::make_shared<mongocxx::collection>();
|
|
|
+ m_pgamelist = boost::make_shared<mongocxx::collection>();
|
|
|
|
|
|
*m_pdb = (*m_pclient)["accounts"];
|
|
|
*m_gamelog = (*m_pclient)["gamelog"];
|
|
|
+ *m_platform = (*m_pclient)["platform"];
|
|
|
|
|
|
*m_pvipuserdb = (*m_pclient)["vipuser"];
|
|
|
*m_pallindex = (*m_pdb)["allindex"];
|
|
@@ -55,6 +78,11 @@ HttpSocket::HttpSocket()
|
|
|
*m_puserdatainfo = (*m_gamelog)["userdatainfo"];
|
|
|
*m_pthreeadmin = (*m_pvipuserdb)["threeadmin"];
|
|
|
*m_pvipconfigure = (*m_pvipuserdb)["vipconfigure"];
|
|
|
+ *m_pgamelist = (*m_platform)["gamelist"];
|
|
|
+
|
|
|
+ //获取gamelist
|
|
|
+ funcmsg fun1 = std::bind(&HttpSocket::getgamelist, this, std::placeholders::_1);
|
|
|
+ m_callmsg.insert(make_pair("/api/game/gamelist", fun1));
|
|
|
}
|
|
|
|
|
|
HttpSocket::~HttpSocket()
|
|
@@ -66,45 +94,22 @@ void HttpSocket::stopmsg()
|
|
|
{
|
|
|
}
|
|
|
|
|
|
-std::string HttpSocket::getuseraccount(std::int32_t iregion)
|
|
|
+
|
|
|
+void HttpSocket::init()
|
|
|
{
|
|
|
- std::string straccount = "";
|
|
|
- __int32 iac = 0;
|
|
|
- for (iac = 0; iac < 10000; iac++)
|
|
|
- {
|
|
|
- std::stringstream strtempaccount;
|
|
|
- std::stringstream strnum;
|
|
|
- if (iregion > 0 && iregion < 10)
|
|
|
- {
|
|
|
- strtempaccount << "0" << iregion;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- strtempaccount << iregion;
|
|
|
- }
|
|
|
|
|
|
- std::uniform_int_distribution<__int64> disrand(1, 100000000);
|
|
|
- __int64 irand = disrand(m_random);
|
|
|
- strnum << irand;
|
|
|
- __int32 ilen = strnum.str().length();
|
|
|
- ilen = 8 - ilen;
|
|
|
- for (int i = 0; i < ilen; i++)
|
|
|
- {
|
|
|
- strtempaccount << "0";
|
|
|
- }
|
|
|
- strtempaccount << strnum.str();
|
|
|
- auto finduser = m_pcoll->find_one(bsoncxx::builder::stream::document{} << "account" << strtempaccount.str().c_str() << bsoncxx::builder::stream::finalize);
|
|
|
- if (finduser)
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
- straccount = strtempaccount.str();
|
|
|
- return straccount;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ makegamelist(m_staticdata);
|
|
|
}
|
|
|
+ catch (const std::exception&)
|
|
|
+ {
|
|
|
|
|
|
- return straccount;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
bool HttpSocket::postmsg(std::function<void(std::string&)> funhttpmsg, std::map<std::string, std::string> getdata)
|
|
|
{
|
|
|
try
|
|
@@ -186,6 +191,27 @@ bool HttpSocket::postmsg(std::function<void(std::string&)> funhttpmsg, std::map<
|
|
|
|
|
|
funhttpmsg(strtojson);
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ const auto& findpathkey = getdata.find("path_key");
|
|
|
+ if (findpathkey != getdata.end())
|
|
|
+ {
|
|
|
+ auto& funmsg = m_callmsg.find(findpathkey->second);
|
|
|
+ if (funmsg != m_callmsg.end())
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ strtojson = funmsg->second(getdata);
|
|
|
+ }
|
|
|
+ catch (std::exception& e)
|
|
|
+ {
|
|
|
+ //NEWLOG(INFO, "msglog") << e.what();
|
|
|
+ strtojson = "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ funhttpmsg(strtojson);
|
|
|
+ }
|
|
|
}
|
|
|
catch (std::exception& e)
|
|
|
{
|
|
@@ -194,6 +220,342 @@ bool HttpSocket::postmsg(std::function<void(std::string&)> funhttpmsg, std::map<
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+void HttpSocket::makegamelist(staticdata& tstaticdata)
|
|
|
+{
|
|
|
+ tstaticdata = m_staticdata;
|
|
|
+ tstaticdata.m_maparead.clear();
|
|
|
+ std::int32_t iareaid = 0;
|
|
|
+ std::string strcode = "";
|
|
|
+ //auto findarea = m_pexechangerate->find({});
|
|
|
+ //for (const auto& doc : findarea)
|
|
|
+ //{
|
|
|
+ // iareaid = doc["areaid"].get_int32();
|
|
|
+ // strcode = doc["code"].get_utf8().value.data();
|
|
|
+ // tstaticdata.m_maparead.insert(std::make_pair(iareaid, strcode));
|
|
|
+ //}
|
|
|
+
|
|
|
+ //std::string strip{};
|
|
|
+ //boost::property_tree::ptree pt;
|
|
|
+ //try
|
|
|
+ //{
|
|
|
+ // boost::property_tree::ini_parser::read_ini("d:\\game\\config.ini", pt);
|
|
|
+ // strip = pt.get<std::string>("ip.wkey");
|
|
|
+ // //NEWLOG(INFO, "clienterro") << "ip=" << strip;
|
|
|
+ //}
|
|
|
+ //catch (const std::exception& e)
|
|
|
+ //{
|
|
|
+ // //NEWLOG(INFO, "clienterro") << "ip=" << strip;
|
|
|
+ //}
|
|
|
+
|
|
|
+
|
|
|
+ //获取url
|
|
|
+ std::int32_t iurlname = 9;
|
|
|
+ auto findurl = make_document(kvp("name", iurlname));
|
|
|
+ auto urlinfo = m_pallindex->find_one(findurl.view());
|
|
|
+ if (urlinfo && urlinfo->view()["url"])
|
|
|
+ {
|
|
|
+ tstaticdata.m_strgameurl = urlinfo->view()["url"].get_utf8().value.data();
|
|
|
+ }
|
|
|
+
|
|
|
+ rapidjson::Document gamelist;
|
|
|
+ gamelist.SetObject();
|
|
|
+ rapidjson::Document::AllocatorType& allocator = gamelist.GetAllocator();
|
|
|
+
|
|
|
+ rapidjson::Document subgame;
|
|
|
+ subgame.SetObject();
|
|
|
+ rapidjson::Document::AllocatorType& suballocator = subgame.GetAllocator();
|
|
|
+
|
|
|
+ auto pgamelist = m_pgamelist->find_one({});
|
|
|
+ if (pgamelist)
|
|
|
+ {
|
|
|
+ std::string strgameicourl = "";
|
|
|
+ bsoncxx::document::view subdoc = pgamelist->view()["data"].get_document().value;
|
|
|
+
|
|
|
+ if (subdoc["test"] && 1 == subdoc["test"].get_int32()) // 测试环境
|
|
|
+ tstaticdata.bTest = true;
|
|
|
+
|
|
|
+ gamelist.AddMember("downloadurl", rapidjson::Value(subdoc["downloadurl"].get_utf8().value.data(), allocator), allocator);
|
|
|
+ gamelist.AddMember("android_url", rapidjson::Value(subdoc["android_url"].get_utf8().value.data(), allocator), allocator);
|
|
|
+ gamelist.AddMember("resversion", rapidjson::Value(subdoc["resversion"].get_utf8().value.data(), allocator), allocator);
|
|
|
+ gamelist.AddMember("baseversion", rapidjson::Value(subdoc["baseversion"].get_utf8().value.data(), allocator), allocator);
|
|
|
+ if (subdoc["zib"])
|
|
|
+ gamelist.AddMember("zib", subdoc["zib"].get_int32(), allocator);
|
|
|
+ if (subdoc["s3"])
|
|
|
+ gamelist.AddMember("s3", rapidjson::Value(subdoc["s3"].get_utf8().value.data(), allocator), allocator);
|
|
|
+
|
|
|
+ if (subdoc["uploadurl"])
|
|
|
+ {
|
|
|
+ gamelist.AddMember("uploadurl", rapidjson::Value(subdoc["uploadurl"].get_utf8().value.data(), allocator), allocator);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (subdoc["return_url"])
|
|
|
+ {
|
|
|
+ tstaticdata.m_strreturnurl = subdoc["return_url"].get_utf8().value.data();
|
|
|
+ gamelist.AddMember("return_url", rapidjson::Value(tstaticdata.m_strreturnurl.c_str(), allocator), allocator);
|
|
|
+ subgame.AddMember("return_url", rapidjson::Value(tstaticdata.m_strreturnurl.c_str(), allocator), allocator);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (tstaticdata.bTest)//添加测试key
|
|
|
+ gamelist.AddMember("key", rapidjson::Value("3F6AE262B8F2255EF7EB", allocator), allocator);
|
|
|
+ if (subdoc["logurl"])
|
|
|
+ {
|
|
|
+ tstaticdata.m_strlogurl = subdoc["logurl"].get_utf8().value.data();
|
|
|
+ gamelist.AddMember("logurl", rapidjson::Value(tstaticdata.m_strlogurl.c_str(), allocator), allocator);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (subdoc["gameicourl"])
|
|
|
+ {
|
|
|
+ strgameicourl = subdoc["gameicourl"].get_utf8().value.data();
|
|
|
+ tstaticdata.m_gameiconurl = strgameicourl;
|
|
|
+ subgame.AddMember("gameicourl", rapidjson::Value(strgameicourl.c_str(), allocator), allocator);
|
|
|
+ gamelist.AddMember("gameicourl", rapidjson::Value(strgameicourl.c_str(), allocator), allocator);
|
|
|
+ }
|
|
|
+
|
|
|
+ //创建数组
|
|
|
+ rapidjson::Value kindidArray(rapidjson::kArrayType);
|
|
|
+ rapidjson::Value subgameArray(rapidjson::kArrayType);
|
|
|
+ std::int32_t ikindid = 0;
|
|
|
+ std::string strkindid{};
|
|
|
+
|
|
|
+ auto tempview = subdoc["gamelist"].get_array().value;
|
|
|
+ for (const bsoncxx::array::element& msg : tempview)
|
|
|
+ {
|
|
|
+ if (msg.type() == bsoncxx::type::k_document)
|
|
|
+ {
|
|
|
+ bsoncxx::document::view ksubdoc = msg.get_document().value;
|
|
|
+ rapidjson::Document subgamedoc;
|
|
|
+ subgamedoc.SetObject();
|
|
|
+ rapidjson::Document::AllocatorType& ksubgamedocallocator = subgamedoc.GetAllocator();
|
|
|
+
|
|
|
+ rapidjson::Document kindiddoc;
|
|
|
+ kindiddoc.SetObject();
|
|
|
+ rapidjson::Document::AllocatorType& kallocator = kindiddoc.GetAllocator();
|
|
|
+
|
|
|
+ strkindid = ksubdoc["KindID"].get_utf8().value.data();
|
|
|
+ kindiddoc.AddMember("KindID", rapidjson::Value(strkindid.c_str(), kallocator), kallocator);
|
|
|
+
|
|
|
+ ikindid = 0;
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ ikindid = std::stoi(strkindid);
|
|
|
+ }
|
|
|
+ catch (std::exception& e)
|
|
|
+ {
|
|
|
+ ikindid = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ std::string strkindname = ksubdoc["KindName"].get_utf8().value.data();
|
|
|
+ std::string strsubgid = "";
|
|
|
+ if (ksubdoc["GID"] && ikindid != 0)
|
|
|
+ {
|
|
|
+ strsubgid = ksubdoc["GID"].get_utf8().value.data();
|
|
|
+ if (strsubgid.empty())
|
|
|
+ continue;
|
|
|
+ if (!strgameicourl.empty())
|
|
|
+ {
|
|
|
+ std::string strgametype = ksubdoc["gametype"].get_utf8().value.data();
|
|
|
+ subgamedoc.AddMember("gid", rapidjson::Value(strsubgid.c_str(), ksubgamedocallocator), ksubgamedocallocator);
|
|
|
+ subgamedoc.AddMember("name", rapidjson::Value(ksubdoc["KindName"].get_utf8().value.data(), ksubgamedocallocator), ksubgamedocallocator);
|
|
|
+ subgamedoc.AddMember("gametype", rapidjson::Value(strgametype.c_str(), ksubgamedocallocator), ksubgamedocallocator);
|
|
|
+
|
|
|
+ if (ksubdoc["SubLogo"])
|
|
|
+ {
|
|
|
+ std::string strsubicon = ksubdoc["SubLogo"].get_utf8().value.data();
|
|
|
+ kindiddoc.AddMember("SubLogo", rapidjson::Value(strsubicon.c_str(), kallocator), kallocator);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ kindiddoc.AddMember("GID", rapidjson::Value(strsubgid.c_str(), kallocator), kallocator);
|
|
|
+ }
|
|
|
+
|
|
|
+ kindiddoc.AddMember("KindName", rapidjson::Value(strkindname.c_str(), kallocator), kallocator);
|
|
|
+ kindiddoc.AddMember("ModuleName", rapidjson::Value(ksubdoc["ModuleName"].get_utf8().value.data(), kallocator), kallocator);
|
|
|
+ kindiddoc.AddMember("ResVersion", rapidjson::Value(ksubdoc["ResVersion"].get_utf8().value.data(), kallocator), kallocator);
|
|
|
+
|
|
|
+ if (ksubdoc["SortID"])
|
|
|
+ {
|
|
|
+ kindiddoc.AddMember("SortID", rapidjson::Value(ksubdoc["SortID"].get_utf8().value.data(), kallocator), kallocator);
|
|
|
+ subgamedoc.AddMember("SortID", rapidjson::Value(ksubdoc["SortID"].get_utf8().value.data(), ksubgamedocallocator), ksubgamedocallocator);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ksubdoc["hot"])
|
|
|
+ {
|
|
|
+ subgamedoc.AddMember("hot", ksubdoc["hot"].get_int32(), ksubgamedocallocator);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ksubdoc["new"])
|
|
|
+ {
|
|
|
+ subgamedoc.AddMember("new", ksubdoc["new"].get_int32(), ksubgamedocallocator);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ksubdoc["brand"])
|
|
|
+ {
|
|
|
+ std::string sbrand = ksubdoc["brand"].get_utf8().value.data();
|
|
|
+ kindiddoc.AddMember("brand", rapidjson::Value(sbrand.c_str(), kallocator), kallocator);
|
|
|
+ subgamedoc.AddMember("brand", rapidjson::Value(sbrand.c_str(), ksubgamedocallocator), ksubgamedocallocator);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (subdoc["gametype"])
|
|
|
+ {
|
|
|
+ kindiddoc.AddMember("gametype", rapidjson::Value(ksubdoc["gametype"].get_utf8().value.data(), kallocator), kallocator);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ksubdoc["SubLogo"])
|
|
|
+ {
|
|
|
+ kindiddoc.AddMember("SubLogo", rapidjson::Value(ksubdoc["SubLogo"].get_utf8().value.data(), kallocator), kallocator);
|
|
|
+ subgamedoc.AddMember("SubLogo", rapidjson::Value(ksubdoc["SubLogo"].get_utf8().value.data(), ksubgamedocallocator), ksubgamedocallocator);
|
|
|
+ }
|
|
|
+
|
|
|
+ //把文档加入数组
|
|
|
+ rapidjson::Value element(rapidjson::kObjectType);
|
|
|
+ element.CopyFrom(kindiddoc, allocator);
|
|
|
+ kindidArray.PushBack(element, allocator);
|
|
|
+
|
|
|
+ rapidjson::Value subgameelement(rapidjson::kObjectType);
|
|
|
+ subgameelement.CopyFrom(subgamedoc, suballocator);
|
|
|
+ subgameArray.PushBack(subgameelement, suballocator);
|
|
|
+
|
|
|
+ if (subgamedoc.HasMember("gid"))
|
|
|
+ {
|
|
|
+ std::string strGid = subgamedoc["gid"].GetString();
|
|
|
+ // 序列化JSON对象到StringBuffer
|
|
|
+ rapidjson::StringBuffer buffer;
|
|
|
+ rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
|
|
|
+ subgamedoc.Accept(writer);
|
|
|
+ tstaticdata.m_mapregiongame[strGid] = std::string(buffer.GetString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ rapidjson::Document sortedkindidArray;
|
|
|
+ sortedkindidArray.SetArray();
|
|
|
+ // 排序
|
|
|
+ {
|
|
|
+ std::vector<const rapidjson::Value*> gameListVector;
|
|
|
+ for (int i = 0; i < kindidArray.Size(); ++i) {
|
|
|
+ gameListVector.push_back(&kindidArray[i]);
|
|
|
+ }
|
|
|
+ std::sort(gameListVector.begin(), gameListVector.end(), [](const rapidjson::Value* a, const rapidjson::Value* b) { return comparegamelist(*a, *b); });
|
|
|
+
|
|
|
+ for (const rapidjson::Value* game : gameListVector) {
|
|
|
+ if (!game->HasMember("GID"))
|
|
|
+ continue;
|
|
|
+ rapidjson::Value element(rapidjson::kObjectType);
|
|
|
+ element.CopyFrom(*game, allocator);
|
|
|
+ sortedkindidArray.PushBack(element, allocator);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ gamelist.AddMember("gamelist", sortedkindidArray, allocator);
|
|
|
+
|
|
|
+
|
|
|
+ rapidjson::Document sortedsubgameArray;
|
|
|
+ sortedsubgameArray.SetArray();
|
|
|
+ // 排序
|
|
|
+ {
|
|
|
+ std::vector<const rapidjson::Value*> gameListVector;
|
|
|
+ for (int i = 0; i < subgameArray.Size(); ++i) {
|
|
|
+ gameListVector.push_back(&subgameArray[i]);
|
|
|
+ }
|
|
|
+ std::sort(gameListVector.begin(), gameListVector.end(), [](const rapidjson::Value* a, const rapidjson::Value* b) { return comparegamelist(*a, *b); });
|
|
|
+
|
|
|
+ for (const rapidjson::Value* game : gameListVector) {
|
|
|
+ rapidjson::Value element(rapidjson::kObjectType);
|
|
|
+ element.CopyFrom(*game, suballocator);
|
|
|
+ sortedsubgameArray.PushBack(element, suballocator);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ subgame.AddMember("gamelist", sortedsubgameArray, suballocator);
|
|
|
+ subgame.AddMember("gameurl", rapidjson::Value(tstaticdata.m_strgameurl.c_str(), allocator), suballocator);
|
|
|
+ }
|
|
|
+
|
|
|
+ gamelist.AddMember("shareurl", rapidjson::Value(tstaticdata.m_strgameurl.c_str(), allocator), allocator);
|
|
|
+
|
|
|
+ std::string strgamelist = funclib::doctojson(gamelist);
|
|
|
+ tstaticdata.m_strsubgame = funclib::doctojson(subgame);
|
|
|
+ std::stringstream strsss;
|
|
|
+ std::string strbase64encode;
|
|
|
+ funclib::Base64Encode(strgamelist, strbase64encode);
|
|
|
+
|
|
|
+ byte tbyte;
|
|
|
+ byte ttemp;
|
|
|
+ std::deque<byte> bstemp;
|
|
|
+ bstemp.clear();
|
|
|
+ for (auto tchar : strbase64encode)
|
|
|
+ {
|
|
|
+ tbyte = tchar;
|
|
|
+ tbyte = ~tbyte;
|
|
|
+ ttemp = tbyte;
|
|
|
+
|
|
|
+ tbyte = ((ttemp & 0xf0) >> 4) | ((tbyte & 0x0f) << 4);
|
|
|
+ bstemp.push_front(tbyte);
|
|
|
+ }
|
|
|
+
|
|
|
+ std::stringstream sss;
|
|
|
+ for (auto& tchar : bstemp)
|
|
|
+ {
|
|
|
+ strsss << tchar;
|
|
|
+ }
|
|
|
+
|
|
|
+ tstaticdata.m_strgamelist = strsss.str();
|
|
|
+
|
|
|
+ if (!tstaticdata.bTest) // 正式环境屏蔽接口
|
|
|
+ {
|
|
|
+ m_callmsg.erase("/api/game/popularizesit");
|
|
|
+ m_callmsg.erase("/api/game/popularizelogin");
|
|
|
+ m_callmsg.erase("/api/game/popularizegetkey");
|
|
|
+ m_callmsg.erase("/api/game/popularizegetcurrency");
|
|
|
+ }
|
|
|
+
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+//获得游戏列表
|
|
|
+std::string HttpSocket::getgamelist(std::map<std::string, std::string> getdata)
|
|
|
+{
|
|
|
+ return m_staticdata.m_strgamelist;
|
|
|
+}
|
|
|
+
|
|
|
+std::string HttpSocket::getuseraccount(std::int32_t iregion)
|
|
|
+{
|
|
|
+ std::string straccount = "";
|
|
|
+ __int32 iac = 0;
|
|
|
+ for (iac = 0; iac < 10000; iac++)
|
|
|
+ {
|
|
|
+ std::stringstream strtempaccount;
|
|
|
+ std::stringstream strnum;
|
|
|
+ if (iregion > 0 && iregion < 10)
|
|
|
+ {
|
|
|
+ strtempaccount << "0" << iregion;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ strtempaccount << iregion;
|
|
|
+ }
|
|
|
+
|
|
|
+ std::uniform_int_distribution<__int64> disrand(1, 100000000);
|
|
|
+ __int64 irand = disrand(m_random);
|
|
|
+ strnum << irand;
|
|
|
+ __int32 ilen = strnum.str().length();
|
|
|
+ ilen = 8 - ilen;
|
|
|
+ for (int i = 0; i < ilen; i++)
|
|
|
+ {
|
|
|
+ strtempaccount << "0";
|
|
|
+ }
|
|
|
+ strtempaccount << strnum.str();
|
|
|
+ auto finduser = m_pcoll->find_one(bsoncxx::builder::stream::document{} << "account" << strtempaccount.str().c_str() << bsoncxx::builder::stream::finalize);
|
|
|
+ if (finduser)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ straccount = strtempaccount.str();
|
|
|
+ return straccount;
|
|
|
+ }
|
|
|
+
|
|
|
+ return straccount;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
//玩家账号注册
|
|
|
std::string HttpSocket::regaccount(std::map<std::string, std::string> getdata)
|
|
|
{
|