|
@@ -57,6 +57,7 @@ HttpSocket::HttpSocket()
|
|
|
m_pgameprizelog = boost::make_shared<mongocxx::collection>();
|
|
|
m_pvipconfigure = boost::make_shared<mongocxx::collection>();
|
|
|
m_pgamelist = boost::make_shared<mongocxx::collection>();
|
|
|
+ m_pthirdtranslog = boost::make_shared<mongocxx::collection>();
|
|
|
|
|
|
*m_pdb = (*m_pclient)["accounts"];
|
|
|
*m_gamelog = (*m_pclient)["gamelog"];
|
|
@@ -80,6 +81,7 @@ HttpSocket::HttpSocket()
|
|
|
*m_pthreeadmin = (*m_pvipuserdb)["threeadmin"];
|
|
|
*m_pvipconfigure = (*m_pvipuserdb)["vipconfigure"];
|
|
|
*m_pgamelist = (*m_platform)["gamelist"];
|
|
|
+ *m_pthirdtranslog = (*m_gamelog)["thirdtranslog"];
|
|
|
|
|
|
m_strshahead = "X-REQUEST-SIGN";
|
|
|
m_strshaheadcontent = "6e4c91001979851a97c2b5360f044ff67b48e186d6ecd4394532851bffdeeae9";
|
|
@@ -198,6 +200,10 @@ bool HttpSocket::postmsg(std::function<void(std::string&, int)> funhttpmsg, std:
|
|
|
{
|
|
|
reelplay(getdata, funhttpmsg);
|
|
|
}
|
|
|
+ else if (itype == HTTPLOGOUTREEL)
|
|
|
+ {
|
|
|
+ reellogout(getdata, funhttpmsg);
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
return false;
|
|
@@ -3281,49 +3287,19 @@ std::string HttpSocket::reelplay(std::map<std::string, std::string> getdata, std
|
|
|
bool bret = treelplayuser.datavalue();
|
|
|
if (!bret)
|
|
|
{
|
|
|
- strret = funclib::rettojson(Err_ParamError, "param erro");
|
|
|
- return strret;
|
|
|
+ dofun(funclib::rettojson(Err_ParamError, "param erro"), 200);
|
|
|
+ return "";
|
|
|
}
|
|
|
|
|
|
std::int32_t iareaid{ 0 };
|
|
|
std::int64_t ispreaderid{ 0 };
|
|
|
- //验证代理是否存在
|
|
|
- //auto findagentview = make_document(kvp("account", treelplayuser.strextension1.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()), kvp("dynamicpass", treelplayuser.strcert.c_str()));
|
|
|
auto findneuserdata = m_pcoll->find_one(findwebuser.view());
|
|
|
if (!findneuserdata)
|
|
|
{
|
|
|
- //用户账号存在
|
|
|
- strret = funclib::errotojson(Err_No_Player);
|
|
|
- return strret;
|
|
|
+ dofun(funclib::rettojson(Err_No_Player, "param erro"), 200);
|
|
|
+ return "";
|
|
|
}
|
|
|
|
|
|
std::int64_t iscore{ 0 };
|
|
@@ -3331,9 +3307,7 @@ std::string HttpSocket::reelplay(std::map<std::string, std::string> getdata, std
|
|
|
{
|
|
|
iscore = findneuserdata->view()["score"].get_int64();
|
|
|
}
|
|
|
- std::string struseracc = treelplayuser.struseracc;
|
|
|
-
|
|
|
- createreeluser(struseracc, treelplayuser.ikindid, iscore, dofun);
|
|
|
+ createreeluser(treelplayuser.struseracc, treelplayuser.ikindid, iscore, dofun);
|
|
|
|
|
|
return {};
|
|
|
}
|
|
@@ -3358,7 +3332,7 @@ void HttpSocket::sendreelmsg(std::string stronly, std::string strtarget, std::st
|
|
|
}
|
|
|
|
|
|
//检查玩家钱包
|
|
|
-void HttpSocket::checkreeluserbalance(std::string struseracc, std::int64_t iscore)
|
|
|
+void HttpSocket::checkreeluserbalance(std::string struseracc, std::function<void(std::string&, int)> dofun)
|
|
|
{
|
|
|
rapidjson::Document doc;
|
|
|
doc.SetObject();
|
|
@@ -3370,10 +3344,47 @@ void HttpSocket::checkreeluserbalance(std::string struseracc, std::int64_t iscor
|
|
|
|
|
|
std::string strjson = funclib::doctojson(doc);
|
|
|
std::string strtarget = "v2/tw/balance";
|
|
|
+
|
|
|
+ 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)
|
|
|
+ {
|
|
|
+ double dscore{ 0 };
|
|
|
+ std::string strscore{};
|
|
|
+ tret = funclib::getjsonvalue(docdata, "balance", strscore);
|
|
|
+ if (tret == rettype::type::exist)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ dscore = std::stod(strscore);
|
|
|
+ reeltranstouser(struseracc, (std::int64_t)dscore, dofun);
|
|
|
+ }
|
|
|
+ catch (const std::exception&)
|
|
|
+ {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::string strret = funclib::errotojson(-1);
|
|
|
+ dofun(strret, 200);
|
|
|
+ }
|
|
|
+
|
|
|
+ }));
|
|
|
}
|
|
|
|
|
|
//创建玩家
|
|
|
-void HttpSocket::createreeluser(std::string struseracc, __int32 ikindid, std::int64_t iscore, std::function<void(std::string&, int)>& dofun)
|
|
|
+void HttpSocket::createreeluser(std::string struseracc, __int32 ikindid, std::int64_t iscore, std::function<void(std::string&, int)> dofun)
|
|
|
{
|
|
|
m_writelog("--------------------createreeluser-------------------------");
|
|
|
rapidjson::Document doc;
|
|
@@ -3423,8 +3434,7 @@ void HttpSocket::createreeluser(std::string struseracc, __int32 ikindid, std::in
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- std::string strret = funclib::errotojson(-1);
|
|
|
- dofun(strret, 200);
|
|
|
+ dofun(funclib::rettojson(Err_Create_PlayerAccount, "create user failed"), 200);
|
|
|
}
|
|
|
|
|
|
}));
|
|
@@ -3449,7 +3459,7 @@ void HttpSocket::reelusertrans(std::string struseracc, __int32 ikindid, std::int
|
|
|
std::string strjson = funclib::doctojson(doc);
|
|
|
std::string strtarget = "v2/tw/transfer";
|
|
|
|
|
|
- sendreelmsg(struseracc, strtarget, strjson, std::move([this, struseracc, dofun, iscore, ikindid](std::string strdata, int iret) {
|
|
|
+ sendreelmsg(struseracc, strtarget, strjson, std::move([this, struseracc, dofun, iscore, ikindid, strtransid](std::string strdata, int iret) {
|
|
|
|
|
|
std::stringstream strlog;
|
|
|
strlog << "转账: iscore=" << iscore << " iret=" << iret << " strdata=" << strdata;
|
|
@@ -3492,26 +3502,15 @@ void HttpSocket::reelusertrans(std::string struseracc, __int32 ikindid, std::int
|
|
|
//转账成功
|
|
|
if (bscore)
|
|
|
{
|
|
|
- //执行扣分操作
|
|
|
- m_postmsg(std::move([this, struseracc, iscore, ikindid]() {
|
|
|
- auto findwebuser = make_document(kvp("account", struseracc.c_str()));
|
|
|
- auto findneuserdata = m_pcoll->find_one(findwebuser.view());
|
|
|
- if (findneuserdata)
|
|
|
- {
|
|
|
- __int64 itradescore = iscore * -1;
|
|
|
- auto scoreupdate = make_document(kvp("$inc", make_document(kvp("score", itradescore))));
|
|
|
- m_pcoll->find_one_and_update(findneuserdata->view(), scoreupdate.view());
|
|
|
- }
|
|
|
- }));
|
|
|
- //直接拉取游戏
|
|
|
- getreelgameurl(struseracc, ikindid, dofun);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- std::string strret = funclib::errotojson(-1);
|
|
|
- dofun(strret, 200);
|
|
|
- }
|
|
|
-
|
|
|
+ // 更新玩家分数
|
|
|
+ if (updateusertrans(struseracc, ikindid, strtransid, iscore*-1))
|
|
|
+ {
|
|
|
+ //直接拉取游戏
|
|
|
+ getreelgameurl(struseracc, ikindid, dofun);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dofun(funclib::rettojson(Err_TRANS_FAILED, "trans failed"), 200);
|
|
|
}));
|
|
|
}
|
|
|
else
|
|
@@ -3522,6 +3521,7 @@ void HttpSocket::reelusertrans(std::string struseracc, __int32 ikindid, std::int
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
//拉取游戏
|
|
|
void HttpSocket::getreelgameurl(std::string struseracc, __int32 ikindid, std::function<void(std::string&, int)> dofun)
|
|
|
{
|
|
@@ -3558,14 +3558,196 @@ void HttpSocket::getreelgameurl(std::string struseracc, __int32 ikindid, std::fu
|
|
|
rapidjson::ParseResult ok = docdata.Parse(strdata.c_str());
|
|
|
if (ok)
|
|
|
{
|
|
|
+ auto& allocator = docdata.GetAllocator();
|
|
|
+ docdata.AddMember("ret", -1, allocator);
|
|
|
+ docdata.AddMember("info", rapidjson::Value("ok", allocator), allocator);
|
|
|
+ //dofun(funclib::doctojson(docdata), 200);
|
|
|
dofun(strdata, 200);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- std::string strret = funclib::errotojson(-1);
|
|
|
- dofun(strret, 200);
|
|
|
+ dofun(funclib::errotojson(iret), 200);
|
|
|
}
|
|
|
|
|
|
}));
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+// 更新玩家转账后分数
|
|
|
+bool HttpSocket::updateusertrans(std::string struseracc, __int32 ikindid, std::string strtransid, std::int64_t iscore)
|
|
|
+{
|
|
|
+ auto findtradelog = m_pthirdtranslog->find_one(make_document(kvp("transid", strtransid.c_str())));
|
|
|
+ if (findtradelog)
|
|
|
+ {
|
|
|
+ std::stringstream strlog;
|
|
|
+ strlog << "更新玩家转账后分数, 重复交易, acc=" << struseracc << " tradescore=" << iscore << "kindid=" << ikindid << "trasid=" << strtransid;
|
|
|
+ m_writelog(strlog.str());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ //执行更新分数
|
|
|
+ m_postmsg(std::move([this, struseracc, iscore, ikindid, strtransid]() {
|
|
|
+ auto findwebuser = make_document(kvp("account", struseracc.c_str()));
|
|
|
+ auto findneuserdata = m_pcoll->find_one(findwebuser.view());
|
|
|
+ if (findneuserdata && findneuserdata->view()["score"])
|
|
|
+ {
|
|
|
+ __int64 ibeforeuserscore = findneuserdata->view()["score"].get_int64();
|
|
|
+ auto scoreupdate = make_document(kvp("$inc", make_document(kvp("score", iscore))));
|
|
|
+ auto result = m_pcoll->find_one_and_update(findneuserdata->view(), scoreupdate.view());
|
|
|
+ if (result)
|
|
|
+ {
|
|
|
+ __int64 inserttime = funclib::gettimestamp();
|
|
|
+ __int64 iafteruserscore = 0;
|
|
|
+ if(result->view()["score"])
|
|
|
+ iafteruserscore = result->view()["score"].get_int64();
|
|
|
+ document updatedoc;
|
|
|
+ updatedoc.append(kvp("useraccount", struseracc.c_str()), kvp("kindid", ikindid), kvp("transid", strtransid.c_str()), kvp("tradescore", iscore),
|
|
|
+ kvp("beforeuserscore", ibeforeuserscore), kvp("afteruserscore", iafteruserscore), kvp("inserttime", inserttime));
|
|
|
+
|
|
|
+ m_pthirdtranslog->insert_one(updatedoc.view());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ std::stringstream strlog;
|
|
|
+ strlog << "更新玩家转账后分数失败, acc=" << struseracc << " tradescore=" << iscore << "kindid=" << ikindid << "trasid=" << strtransid;
|
|
|
+ m_writelog(strlog.str());
|
|
|
+ }));
|
|
|
+
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+//踢玩家下真人视讯平台
|
|
|
+void HttpSocket::reellogout(std::map<std::string, std::string> getdata, std::function<void(std::string&, int)> dofun)
|
|
|
+{
|
|
|
+ string struseracc = "";
|
|
|
+ string strcert = "";
|
|
|
+ auto& findacc = getdata.find("useracc");
|
|
|
+ if (findacc != getdata.end())
|
|
|
+ {
|
|
|
+ struseracc = findacc->second;
|
|
|
+ }
|
|
|
+
|
|
|
+ auto& findcert = getdata.find("cert");
|
|
|
+ if (findcert != getdata.end())
|
|
|
+ {
|
|
|
+ strcert = findcert->second;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (struseracc.empty() || strcert.empty())
|
|
|
+ {
|
|
|
+ return dofun(funclib::rettojson(Err_ParamError, "param erro"), 200);
|
|
|
+ }
|
|
|
+
|
|
|
+ auto findwebuser = make_document(kvp("account", struseracc.c_str()), kvp("dynamicpass", strcert.c_str()));
|
|
|
+ auto findneuserdata = m_pcoll->find_one(findwebuser.view());
|
|
|
+ if (!findneuserdata)
|
|
|
+ {
|
|
|
+ dofun(funclib::rettojson(Err_No_Player, "param erro"), 200);
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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/terminateSession";
|
|
|
+
|
|
|
+ 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)
|
|
|
+ {
|
|
|
+ checkreeluserbalance(struseracc, dofun);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }));
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+//三方转账到玩家
|
|
|
+void HttpSocket::reeltranstouser(std::string struseracc, std::int64_t iscore, std::function<void(std::string&, int)> dofun)
|
|
|
+{
|
|
|
+ m_writelog("--------------------reeltranstouser-------------------------");
|
|
|
+ if (iscore > 0)
|
|
|
+ {
|
|
|
+ rapidjson::Document doc;
|
|
|
+ doc.SetObject();
|
|
|
+ rapidjson::Document::AllocatorType& allocator = doc.GetAllocator();
|
|
|
+
|
|
|
+ iscore = iscore * -1 * 10000;
|
|
|
+ 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, strtransid](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)
|
|
|
+ {
|
|
|
+ // 更新玩家分数
|
|
|
+ updateusertrans(struseracc, 0, strtransid, iscore * -1);
|
|
|
+ dofun(funclib::rettojson(-1, "success"), 200);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ dofun(funclib::rettojson(Err_TRANS_FAILED, "trans failed"), 200);
|
|
|
+ }));
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|