|
@@ -24,6 +24,7 @@ bool comparegamelist(const rapidjson::Value& a, const rapidjson::Value& b)
|
|
|
}
|
|
|
|
|
|
|
|
|
+std::uint32_t HttpSocket::m_gucurid = 0;
|
|
|
HttpSocket::HttpSocket()
|
|
|
{
|
|
|
m_random = std::default_random_engine(time(NULL));
|
|
@@ -80,9 +81,15 @@ HttpSocket::HttpSocket()
|
|
|
*m_pvipconfigure = (*m_pvipuserdb)["vipconfigure"];
|
|
|
*m_pgamelist = (*m_platform)["gamelist"];
|
|
|
|
|
|
+ m_strshahead = "X-REQUEST-SIGN";
|
|
|
+ m_strshaheadcontent = "6e4c91001979851a97c2b5360f044ff67b48e186d6ecd4394532851bffdeeae9";
|
|
|
+ m_ucurid = m_gucurid++;
|
|
|
+
|
|
|
+ m_psendhttp = weblib::httpini();
|
|
|
+
|
|
|
//获取gamelist
|
|
|
funcmsg fun1 = std::bind(&HttpSocket::getgamelist, this, std::placeholders::_1);
|
|
|
- m_callmsg.insert(make_pair("/api/game/gamelist", fun1));
|
|
|
+ m_callmsg.insert(make_pair("api/game/gamelist", fun1));
|
|
|
}
|
|
|
|
|
|
HttpSocket::~HttpSocket()
|
|
@@ -92,6 +99,7 @@ HttpSocket::~HttpSocket()
|
|
|
|
|
|
void HttpSocket::stopmsg()
|
|
|
{
|
|
|
+ weblib::delhttp(m_psendhttp);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -111,7 +119,7 @@ void HttpSocket::init()
|
|
|
|
|
|
|
|
|
|
|
|
-bool HttpSocket::postmsg(std::function<void(std::string&)> funhttpmsg, std::map<std::string, std::string> getdata)
|
|
|
+bool HttpSocket::postmsg(std::function<void(std::string&, int)> funhttpmsg, std::map<std::string, std::string> getdata)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
@@ -185,12 +193,17 @@ bool HttpSocket::postmsg(std::function<void(std::string&)> funhttpmsg, std::map<
|
|
|
{
|
|
|
strtojson = getalluserplayscoreinfo(getdata);
|
|
|
}
|
|
|
+ //登录真人视讯
|
|
|
+ else if (itype == HTTPLOGINREEL)
|
|
|
+ {
|
|
|
+ reelplay(getdata, funhttpmsg);
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- funhttpmsg(strtojson);
|
|
|
+ funhttpmsg(strtojson, 200);
|
|
|
return true;
|
|
|
}
|
|
|
else
|
|
@@ -212,7 +225,8 @@ bool HttpSocket::postmsg(std::function<void(std::string&)> funhttpmsg, std::map<
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- funhttpmsg(strtojson);
|
|
|
+
|
|
|
+ funhttpmsg(strtojson, 200);
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
@@ -221,7 +235,8 @@ bool HttpSocket::postmsg(std::function<void(std::string&)> funhttpmsg, std::map<
|
|
|
}
|
|
|
|
|
|
std::string strerror{ "{\"error\":1}" };
|
|
|
- funhttpmsg(strerror);
|
|
|
+ int iret = -1;
|
|
|
+ funhttpmsg(strerror, iret);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -920,7 +935,7 @@ std::string HttpSocket::regaccount(std::map<std::string, std::string> getdata)
|
|
|
}
|
|
|
|
|
|
//玩家更新分数
|
|
|
-std::string HttpSocket::updateuserscore(std::map<std::string, std::string> getdata, std::function<void(std::string&)>& dofun)
|
|
|
+std::string HttpSocket::updateuserscore(std::map<std::string, std::string> getdata, std::function<void(std::string&, int)>& dofun)
|
|
|
{
|
|
|
userscore tuserscore;
|
|
|
getvaluedata(getdata, tuserscore);
|
|
@@ -1414,7 +1429,7 @@ std::string HttpSocket::updateuserscore(std::map<std::string, std::string> getda
|
|
|
}
|
|
|
|
|
|
//把玩家踢出游戏
|
|
|
-std::string HttpSocket::adminhituser(std::map<std::string, std::string> getdata, std::function<void(std::string&)>& dofun)
|
|
|
+std::string HttpSocket::adminhituser(std::map<std::string, std::string> getdata, std::function<void(std::string&, int)>& dofun)
|
|
|
{
|
|
|
kickuser tkickuser;
|
|
|
getvaluedata(getdata, tkickuser);
|
|
@@ -1521,7 +1536,7 @@ std::string HttpSocket::adminhituser(std::map<std::string, std::string> getdata,
|
|
|
thttpinfo.strtarget = "webapi/deluser";
|
|
|
thttpinfo.strjson = funclib::doctojson(docgame);
|
|
|
|
|
|
- m_gamemsg(thttpinfo, std::move([this, iuserid, iserverid, icontextid, dofun = std::move(dofun)](std::string strdata)mutable
|
|
|
+ m_gamemsg(thttpinfo, std::move([this, iuserid, iserverid, icontextid, dofun = std::move(dofun)](std::string &strdata, int iret)mutable
|
|
|
{
|
|
|
//踢出成功
|
|
|
std::string strtojson = funclib::rettojson(-1, "ok");
|
|
@@ -1531,13 +1546,13 @@ std::string HttpSocket::adminhituser(std::map<std::string, std::string> getdata,
|
|
|
std::function<void()> tfun = [this, iuserid, iserverid, icontextid, dofun = std::move(dofun), strtojson]() mutable{
|
|
|
auto finduserview = make_document(kvp("userid", iuserid), kvp("serverid", iserverid), kvp("contextid", icontextid));
|
|
|
m_pplayuseronline->delete_one(finduserview.view());
|
|
|
- dofun(strtojson);
|
|
|
+ dofun(strtojson, 200);
|
|
|
};
|
|
|
m_postmsg(std::move(tfun));
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- dofun(strtojson);
|
|
|
+ dofun(strtojson, 200);
|
|
|
}));
|
|
|
|
|
|
return {};
|
|
@@ -2157,11 +2172,11 @@ std::string HttpSocket::playgameinfo(std::map<std::string, std::string> getdata)
|
|
|
|
|
|
userspreadid = finduser->view()["spreaderid"].get_int64();
|
|
|
|
|
|
- /*if (iadminuserid != userspreadid)
|
|
|
+ if (iadminuserid != userspreadid)
|
|
|
{
|
|
|
strret = funclib::rettojson(Err_Player_LackInfo, "the account does not belong to you");
|
|
|
return strret;
|
|
|
- }*/
|
|
|
+ }
|
|
|
|
|
|
auto vipuser = m_pvipuser->find_one(bsoncxx::builder::stream::document{} << "userid" << iadminuserid << bsoncxx::builder::stream::finalize);
|
|
|
if (!vipuser)
|
|
@@ -3247,4 +3262,307 @@ std::string HttpSocket::getalluserplayscoreinfo(std::map<std::string, std::strin
|
|
|
|
|
|
//NEWLOG(INFO, "msglog") << strret;
|
|
|
return strret;
|
|
|
+}
|
|
|
+
|
|
|
+std::string HttpSocket::reelplay(std::map<std::string, std::string> getdata, std::function<void(std::string&, int)>& dofun)
|
|
|
+{
|
|
|
+ reelplayuser treelplayuser;
|
|
|
+ getvaluedata(getdata, treelplayuser);
|
|
|
+
|
|
|
+ std::string strret;
|
|
|
+
|
|
|
+ m_writelog("--------------------reelplay-------------------------");
|
|
|
+
|
|
|
+ bool bret = treelplayuser.datavalue();
|
|
|
+ if (!bret)
|
|
|
+ {
|
|
|
+ strret = funclib::rettojson(Err_ParamError, "param erro");
|
|
|
+ return strret;
|
|
|
+ }
|
|
|
+
|
|
|
+ std::int32_t iareaid{ 0 };
|
|
|
+ std::int64_t ispreaderid{ 0 };
|
|
|
+ //验证代理是否存在
|
|
|
+ auto findagentview = make_document(kvp("account", treelplayuser.strextension1.c_str()), kvp("cert", treelplayuser.strcert.c_str()));
|
|
|
+ auto vipuser = m_pvipuser->find_one(findagentview.view());
|
|
|
+ if (!vipuser || !vipuser->view()["userid"] || !vipuser->view()["areaid"] || !vipuser->view()["apitype"])
|
|
|
+ {
|
|
|
+ strret = funclib::errotojson(Err_No_Agent);
|
|
|
+ return strret;
|
|
|
+ }
|
|
|
+
|
|
|
+ iareaid = vipuser->view()["areaid"].get_int32();
|
|
|
+ ispreaderid = vipuser->view()["areaid"].get_int32();
|
|
|
+
|
|
|
+ std::int32_t userstate = 1;
|
|
|
+ if (vipuser && vipuser->view()["state"])
|
|
|
+ {
|
|
|
+ userstate = vipuser->view()["state"].get_int32();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (userstate != 0)
|
|
|
+ {
|
|
|
+ strret = funclib::rettojson(Err_OutOfState_Agent, "agent statue error");
|
|
|
+ return strret;
|
|
|
+ }
|
|
|
+
|
|
|
+ std::int32_t iapitype = vipuser->view()["apitype"].get_int32();
|
|
|
+ if (iapitype != 2)
|
|
|
+ {
|
|
|
+ strret = funclib::rettojson(Err_OutOfState_Agent, "agent type error");
|
|
|
+ return strret;
|
|
|
+ }
|
|
|
+
|
|
|
+ auto findwebuser = make_document(kvp("account", treelplayuser.struseracc.c_str()));
|
|
|
+ auto findneuserdata = m_pcoll->find_one(findwebuser.view());
|
|
|
+ if (!findneuserdata)
|
|
|
+ {
|
|
|
+ //用户账号存在
|
|
|
+ strret = funclib::errotojson(Err_No_Player);
|
|
|
+ return strret;
|
|
|
+ }
|
|
|
+
|
|
|
+ std::int64_t iscore{ 0 };
|
|
|
+ if (findneuserdata && findneuserdata->view()["score"])
|
|
|
+ {
|
|
|
+ iscore = findneuserdata->view()["score"].get_int64();
|
|
|
+ }
|
|
|
+ std::string struseracc = treelplayuser.struseracc;
|
|
|
+
|
|
|
+ createreeluser(struseracc, iscore, dofun);
|
|
|
+
|
|
|
+ return {};
|
|
|
+}
|
|
|
+
|
|
|
+void HttpSocket::sendreelmsg(std::string stronly, std::string strtarget, std::string strjson, std::function<void(std::string, int)>&& dofun)
|
|
|
+{
|
|
|
+ weblib::httpinfo thttpinfo;
|
|
|
+ thttpinfo.strurl = "https://transfer-wallet-service.stage.iconic-21.com";
|
|
|
+// thttpinfo.strurl = "http://127.0.0.1:6000";
|
|
|
+ thttpinfo.strtarget = strtarget;
|
|
|
+ thttpinfo.stronly = stronly;
|
|
|
+ std::string strshaheadcontent = m_strshaheadcontent + strjson;
|
|
|
+ strshaheadcontent = sha256_to_base16(strshaheadcontent);
|
|
|
+ thttpinfo.addheadinfo.insert(std::make_pair(m_strshahead, strshaheadcontent));
|
|
|
+ thttpinfo.strjson = strjson;
|
|
|
+
|
|
|
+ std::stringstream sss;
|
|
|
+ sss << "strurl=" << thttpinfo.strurl << " strtarget=" << strtarget << " strshaheadcontent=" << strshaheadcontent << " strjson=" << strjson;
|
|
|
+ m_writelog(sss.str());
|
|
|
+
|
|
|
+ weblib::sendhttp(m_psendhttp, std::move(thttpinfo), std::move(dofun));
|
|
|
+}
|
|
|
+
|
|
|
+//检查玩家钱包
|
|
|
+void HttpSocket::checkreeluserbalance(std::string struseracc, std::int64_t iscore)
|
|
|
+{
|
|
|
+ rapidjson::Document doc;
|
|
|
+ doc.SetObject();
|
|
|
+ rapidjson::Document::AllocatorType& allocator = doc.GetAllocator();
|
|
|
+
|
|
|
+ doc.AddMember("casino", rapidjson::Value("luckybet777", allocator), allocator);
|
|
|
+ doc.AddMember("playerId", rapidjson::Value(struseracc.c_str(), allocator), allocator);
|
|
|
+ //std::string strjson{ "{\"casino\":\"luckybet777\",\"playerId\":\"testPlayer_5\",\"currency\":\"EUR\",\"country\":\"US\"}" };
|
|
|
+
|
|
|
+ std::string strjson = funclib::doctojson(doc);
|
|
|
+ std::string strtarget = "v2/tw/balance";
|
|
|
+}
|
|
|
+
|
|
|
+//创建玩家
|
|
|
+void HttpSocket::createreeluser(std::string struseracc, std::int64_t iscore, std::function<void(std::string&, int)>& dofun)
|
|
|
+{
|
|
|
+ m_writelog("--------------------createreeluser-------------------------");
|
|
|
+ rapidjson::Document doc;
|
|
|
+ doc.SetObject();
|
|
|
+ rapidjson::Document::AllocatorType& allocator = doc.GetAllocator();
|
|
|
+
|
|
|
+ doc.AddMember("casino", rapidjson::Value("luckybet777", allocator), allocator);
|
|
|
+ doc.AddMember("playerId", rapidjson::Value(struseracc.c_str(), allocator), allocator);
|
|
|
+ doc.AddMember("currency", rapidjson::Value("EUR", allocator), allocator);
|
|
|
+ doc.AddMember("country", rapidjson::Value("US", allocator), allocator);
|
|
|
+ //std::string strjson{ "{\"casino\":\"luckybet777\",\"playerId\":\"testPlayer_5\",\"currency\":\"EUR\",\"country\":\"US\"}" };
|
|
|
+
|
|
|
+ std::string strjson = funclib::doctojson(doc);
|
|
|
+ std::string strtarget = "v2/tw/createPlayer";
|
|
|
+
|
|
|
+ //创建玩家
|
|
|
+ sendreelmsg(struseracc, strtarget, strjson, std::move([this, struseracc, iscore, dofun](std::string strdata, int iret) {
|
|
|
+
|
|
|
+ std::stringstream strlog;
|
|
|
+ strlog << "创建玩家: iret=" << iret << " strdata=" << strdata;
|
|
|
+ m_writelog(strlog.str());
|
|
|
+
|
|
|
+ bool bhaveuser{ false };
|
|
|
+ if (iret == 200)
|
|
|
+ {
|
|
|
+ rettype::type tret{ rettype::type::ini };
|
|
|
+ rapidjson::Document docdata;
|
|
|
+ rapidjson::ParseResult ok = docdata.Parse(strdata.c_str());
|
|
|
+ if (ok)
|
|
|
+ {
|
|
|
+ std::string strstatus{};
|
|
|
+ tret = funclib::getjsonvalue(docdata, "status", strstatus);
|
|
|
+ if (tret == rettype::type::exist)
|
|
|
+ {
|
|
|
+ if (strstatus == "ok")
|
|
|
+ {
|
|
|
+ bhaveuser = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //玩家创建成功
|
|
|
+ if (bhaveuser)
|
|
|
+ {
|
|
|
+ reelusertrans(struseracc, iscore, dofun);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::string strret = funclib::errotojson(-1);
|
|
|
+ dofun(strret, 200);
|
|
|
+ }
|
|
|
+
|
|
|
+ }));
|
|
|
+}
|
|
|
+
|
|
|
+void HttpSocket::reelusertrans(std::string struseracc, std::int64_t iscore, std::function<void(std::string&, int)> dofun)
|
|
|
+{
|
|
|
+ m_writelog("--------------------reelusertrans-------------------------");
|
|
|
+ if (iscore > 0)
|
|
|
+ {
|
|
|
+ rapidjson::Document doc;
|
|
|
+ doc.SetObject();
|
|
|
+ rapidjson::Document::AllocatorType& allocator = doc.GetAllocator();
|
|
|
+
|
|
|
+ std::string strscore = funclib::getdouble(iscore);
|
|
|
+ std::string strtransid = funclib::getonlytoken(1, m_ucurid);
|
|
|
+
|
|
|
+ doc.AddMember("casino", rapidjson::Value("luckybet777", allocator), allocator);
|
|
|
+ doc.AddMember("playerId", rapidjson::Value(struseracc.c_str(), allocator), allocator);
|
|
|
+ doc.AddMember("transactionId", rapidjson::Value(strtransid.c_str(), allocator), allocator);
|
|
|
+ doc.AddMember("amount", rapidjson::Value(strscore.c_str(), allocator), allocator);
|
|
|
+ std::string strjson = funclib::doctojson(doc);
|
|
|
+ std::string strtarget = "v2/tw/transfer";
|
|
|
+
|
|
|
+ sendreelmsg(struseracc, strtarget, strjson, std::move([this, struseracc, dofun, iscore](std::string strdata, int iret) {
|
|
|
+
|
|
|
+ std::stringstream strlog;
|
|
|
+ strlog << "转账: iscore=" << iscore << " iret=" << iret << " strdata=" << strdata;
|
|
|
+ m_writelog(strlog.str());
|
|
|
+
|
|
|
+ double dscore{ 0 };
|
|
|
+ bool bscore{ false };
|
|
|
+ if (iret == 200)
|
|
|
+ {
|
|
|
+ rettype::type tret{ rettype::type::ini };
|
|
|
+ rapidjson::Document docdata;
|
|
|
+ rapidjson::ParseResult ok = docdata.Parse(strdata.c_str());
|
|
|
+ if (ok)
|
|
|
+ {
|
|
|
+ tret = funclib::getjsonvalue(docdata, "balance", dscore);
|
|
|
+ if (tret == rettype::type::exist)
|
|
|
+ {
|
|
|
+ bscore = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::string strscore{};
|
|
|
+ tret = funclib::getjsonvalue(docdata, "balance", strscore);
|
|
|
+ if (tret == rettype::type::exist)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ dscore = std::stod(strscore);
|
|
|
+ bscore = true;
|
|
|
+ }
|
|
|
+ catch (const std::exception&)
|
|
|
+ {
|
|
|
+ bscore = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //转账成功
|
|
|
+ if (bscore)
|
|
|
+ {
|
|
|
+ //执行扣分操作
|
|
|
+ m_postmsg(std::move([this]() {
|
|
|
+
|
|
|
+ //验证代理是否存在
|
|
|
+ //auto findagentview = make_document(kvp("account", treelplayuser.strextension1.c_str()), kvp("cert", treelplayuser.strcert.c_str()));
|
|
|
+ //auto vipuser = m_pvipuser->find_one(findagentview.view());
|
|
|
+ //if (!vipuser || !vipuser->view()["userid"] || !vipuser->view()["areaid"] || !vipuser->view()["apitype"])
|
|
|
+ //{
|
|
|
+ //strret = funclib::errotojson(Err_No_Agent);
|
|
|
+ //return strret;
|
|
|
+ //}
|
|
|
+
|
|
|
+ }));
|
|
|
+ //直接拉取游戏
|
|
|
+ getreelgameurl(struseracc, dofun);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::string strret = funclib::errotojson(-1);
|
|
|
+ dofun(strret, 200);
|
|
|
+ }
|
|
|
+
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ m_writelog("iscore = 0, 直接拉取游戏");
|
|
|
+ //直接拉取游戏
|
|
|
+ getreelgameurl(struseracc, dofun);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//拉取游戏
|
|
|
+void HttpSocket::getreelgameurl(std::string struseracc, std::function<void(std::string&, int)> dofun)
|
|
|
+{
|
|
|
+ m_writelog("--------------------getreelgameurl-------------------------");
|
|
|
+ rapidjson::Document doc;
|
|
|
+ doc.SetObject();
|
|
|
+ rapidjson::Document::AllocatorType& allocator = doc.GetAllocator();
|
|
|
+
|
|
|
+ //cashier:URL for opening the cashier on Casino site when a player has no funds.
|
|
|
+ //homepage:URL for returning to Lobby page on Casino site. This link is used for Exit button in mobile version of games.
|
|
|
+ //{"casino":"whitebom","playerId":"testPlayer_1","launchAlias":"launch_main_rol_01","language":"en","cashier":"https://cashier.com","homepage":"https://home.com"}
|
|
|
+ std::string strtransid = funclib::getonlytoken(1, m_ucurid);
|
|
|
+ doc.AddMember("casino", rapidjson::Value("luckybet777", allocator), allocator);
|
|
|
+ doc.AddMember("playerId", rapidjson::Value(struseracc.c_str(), allocator), allocator);
|
|
|
+ doc.AddMember("launchAlias", rapidjson::Value("launch_main_rol_01", allocator), allocator);
|
|
|
+ doc.AddMember("language", rapidjson::Value("en", allocator), allocator);
|
|
|
+ doc.AddMember("cashier", rapidjson::Value("https://cashier.com", allocator), allocator);
|
|
|
+ doc.AddMember("homepage", rapidjson::Value("https://home.com", allocator), allocator);
|
|
|
+
|
|
|
+ std::string strjson = funclib::doctojson(doc);
|
|
|
+ std::string strtarget = "v2/tw/startGame";
|
|
|
+
|
|
|
+ sendreelmsg(struseracc, strtarget, strjson, std::move([this, struseracc, dofun](std::string strdata, int iret) {
|
|
|
+
|
|
|
+ std::stringstream strlog;
|
|
|
+ strlog << "拉取游戏: iret=" << iret << " strdata=" << strdata;
|
|
|
+ m_writelog(strlog.str());
|
|
|
+
|
|
|
+ if (iret == 200)
|
|
|
+ {
|
|
|
+ rettype::type tret{ rettype::type::ini };
|
|
|
+ rapidjson::Document docdata;
|
|
|
+ rapidjson::ParseResult ok = docdata.Parse(strdata.c_str());
|
|
|
+ if (ok)
|
|
|
+ {
|
|
|
+ dofun(strdata, 200);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::string strret = funclib::errotojson(-1);
|
|
|
+ dofun(strret, 200);
|
|
|
+ }
|
|
|
+
|
|
|
+ }));
|
|
|
}
|