|
@@ -198,56 +198,67 @@ struct stUserInfo
|
|
};
|
|
};
|
|
static map<string, stUserInfo> map_acctouserinfo;
|
|
static map<string, stUserInfo> map_acctouserinfo;
|
|
|
|
|
|
|
|
+
|
|
|
|
+static bool bAllPageDone = false; //这次请求是否请求完所有分页
|
|
void HttpSocket::init()
|
|
void HttpSocket::init()
|
|
{
|
|
{
|
|
|
|
+ static __int64 itimefrom = 0;
|
|
|
|
+ static __int64 itimeto = 0;
|
|
|
|
+ static __int32 ipage = 0;
|
|
|
|
+
|
|
|
|
+ getsynctime(itimefrom, itimeto, ipage, bAllPageDone);
|
|
while (true)
|
|
while (true)
|
|
{
|
|
{
|
|
- static __int64 iLastTime = 0;
|
|
|
|
- if (funclib::gettimestamp() - iLastTime < 1000)
|
|
|
|
- this_thread::sleep_for(milliseconds(iLastTime + 1000 - funclib::gettimestamp()));
|
|
|
|
-
|
|
|
|
- auto tp = system_clock::time_point(milliseconds(funclib::gettimestamp()));
|
|
|
|
- auto secs = duration_cast<seconds>(tp.time_since_epoch()).count();
|
|
|
|
-
|
|
|
|
- auto isecondFrom = secs - 60;//上一分钟
|
|
|
|
- if (iLastTime == 0) // 第一次启动拉24小时
|
|
|
|
|
|
+ static __int64 inowtime = funclib::gettimestamp();
|
|
|
|
+ if (itimeto == 0)
|
|
{
|
|
{
|
|
- int64_t hour = secs / 3600;
|
|
|
|
- isecondFrom = (hour - 24) * 3600;
|
|
|
|
|
|
+ itimeto = inowtime - 1000;
|
|
|
|
+ itimefrom = itimeto - 1000;
|
|
}
|
|
}
|
|
- iLastTime = funclib::gettimestamp();
|
|
|
|
- auto prev_hour_tp = system_clock::time_point(seconds(isecondFrom));
|
|
|
|
- auto next_hour_tp = system_clock::time_point(seconds(secs + 60)); // 下一分钟
|
|
|
|
- string datafrom = to_iso8601_utc_string(prev_hour_tp);
|
|
|
|
- string datatto = to_iso8601_utc_string(next_hour_tp);
|
|
|
|
-
|
|
|
|
- getgamehistory(datafrom, datatto, 0);
|
|
|
|
|
|
+ else if (inowtime - itimeto < 1000)
|
|
|
|
+ {
|
|
|
|
+ if(!bAllPageDone)
|
|
|
|
+ continue;
|
|
|
|
+ this_thread::sleep_for(milliseconds(itimeto + 1000 - inowtime));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (bAllPageDone)
|
|
|
|
+ ipage = 0;
|
|
|
|
+ bAllPageDone = false;
|
|
|
|
+
|
|
|
|
+ itimefrom = itimeto;
|
|
|
|
+ itimeto = funclib::gettimestamp();
|
|
|
|
+
|
|
|
|
+ auto pid = std::this_thread::get_id();
|
|
|
|
+ getgamehistory(itimefrom, itimeto, ipage);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//拉取日志
|
|
//拉取日志
|
|
-void HttpSocket::getgamehistory(string dataFrom, string dataTo, __int32 ifirstpage)
|
|
|
|
|
|
+void HttpSocket::getgamehistory(__int64 itimefrom, __int64 itimeto, __int32 ifirstpage)
|
|
{
|
|
{
|
|
m_writelog("--------------------getgamehistory-------------------------");
|
|
m_writelog("--------------------getgamehistory-------------------------");
|
|
|
|
|
|
__int32 ipage = ifirstpage;
|
|
__int32 ipage = ifirstpage;
|
|
__int32 inextpage = 0;
|
|
__int32 inextpage = 0;
|
|
- __int32 ipagesize = 500;
|
|
|
|
|
|
+ __int32 ipagesize = 1;
|
|
|
|
|
|
rapidjson::Document doc;
|
|
rapidjson::Document doc;
|
|
doc.SetObject();
|
|
doc.SetObject();
|
|
rapidjson::Document::AllocatorType& allocator = doc.GetAllocator();
|
|
rapidjson::Document::AllocatorType& allocator = doc.GetAllocator();
|
|
|
|
|
|
|
|
+ string datefrom = to_iso8601_utc_string(system_clock::time_point(seconds(itimefrom / 1000)));
|
|
|
|
+ string dateto = to_iso8601_utc_string(system_clock::time_point(seconds(itimeto / 1000)));
|
|
doc.AddMember("casino", rapidjson::Value("luckybet777", allocator), allocator);
|
|
doc.AddMember("casino", rapidjson::Value("luckybet777", allocator), allocator);
|
|
doc.AddMember("page", ipage, allocator);
|
|
doc.AddMember("page", ipage, allocator);
|
|
doc.AddMember("size", ipagesize, allocator);
|
|
doc.AddMember("size", ipagesize, allocator);
|
|
- doc.AddMember("dateFrom", rapidjson::Value(dataFrom.c_str(), allocator), allocator);
|
|
|
|
- doc.AddMember("dateTo", rapidjson::Value(dataTo.c_str(), allocator), allocator);
|
|
|
|
|
|
+ doc.AddMember("dateFrom", rapidjson::Value(datefrom.c_str(), allocator), allocator);
|
|
|
|
+ doc.AddMember("dateTo", rapidjson::Value(dateto.c_str(), allocator), allocator);
|
|
|
|
|
|
string strjson = funclib::doctojson(doc);
|
|
string strjson = funclib::doctojson(doc);
|
|
string strtarget = "v2/tw/getGameHistory";
|
|
string strtarget = "v2/tw/getGameHistory";
|
|
|
|
|
|
- sendreelmsg("luckybet777", strtarget, strjson, move([this, ipage, ipagesize, dataFrom, dataTo](string strdata, int iret) {
|
|
|
|
|
|
+ sendreelmsg("luckybet777", strtarget, strjson, move([this, ipage, ipagesize, itimefrom, itimeto](string strdata, int iret) {
|
|
if (iret == 200)
|
|
if (iret == 200)
|
|
{
|
|
{
|
|
rettype::type tret{ rettype::type::ini };
|
|
rettype::type tret{ rettype::type::ini };
|
|
@@ -266,6 +277,11 @@ void HttpSocket::getgamehistory(string dataFrom, string dataTo, __int32 ifirstpa
|
|
double_t dwinmul = 0;
|
|
double_t dwinmul = 0;
|
|
if (ok)
|
|
if (ok)
|
|
{
|
|
{
|
|
|
|
+
|
|
|
|
+ static int itotalsize = 0;
|
|
|
|
+ if (docdata.HasMember("total"))
|
|
|
|
+ itotalsize = docdata["total"].GetInt();
|
|
|
|
+
|
|
rapidjson::Value arrbets(rapidjson::kArrayType);
|
|
rapidjson::Value arrbets(rapidjson::kArrayType);
|
|
if (docdata.HasMember("records") && docdata["records"].IsArray())
|
|
if (docdata.HasMember("records") && docdata["records"].IsArray())
|
|
{
|
|
{
|
|
@@ -295,10 +311,10 @@ void HttpSocket::getgamehistory(string dataFrom, string dataTo, __int32 ifirstpa
|
|
continue;
|
|
continue;
|
|
|
|
|
|
stronlyid = recorditem["id"].GetString();
|
|
stronlyid = recorditem["id"].GetString();
|
|
- auto findrecord = make_document(kvp("onlyid", stronlyid.c_str()), kvp("brandid", ibrandid));
|
|
|
|
- auto result = m_pgameprizelog->find_one(findrecord.view());
|
|
|
|
- if (result)
|
|
|
|
- continue; // 重复
|
|
|
|
|
|
+ //auto findrecord = make_document(kvp("onlyid", stronlyid.c_str()), kvp("brandid", ibrandid));
|
|
|
|
+ //auto result = m_pgameprizelog->find_one(findrecord.view());
|
|
|
|
+ //if (result)
|
|
|
|
+ // continue; // 重复
|
|
|
|
|
|
straccount = recorditem["playerId"].GetString();
|
|
straccount = recorditem["playerId"].GetString();
|
|
stUserInfo stuserinfo = map_acctouserinfo[straccount];
|
|
stUserInfo stuserinfo = map_acctouserinfo[straccount];
|
|
@@ -345,8 +361,14 @@ void HttpSocket::getgamehistory(string dataFrom, string dataTo, __int32 ifirstpa
|
|
m_pgameprizelog->insert_one(recorddoc.view());
|
|
m_pgameprizelog->insert_one(recorddoc.view());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (docdata.HasMember("total") && (ipage + 1) * ipagesize < docdata["total"].GetInt())
|
|
|
|
- getgamehistory(dataFrom, dataTo, ipage+1);
|
|
|
|
|
|
+
|
|
|
|
+ if((ipage + 1) * ipagesize >= itotalsize)
|
|
|
|
+ bAllPageDone = true;
|
|
|
|
+
|
|
|
|
+ setsynctime(itimefrom, itimeto, ipage + 1, bAllPageDone);
|
|
|
|
+
|
|
|
|
+ if(!bAllPageDone)
|
|
|
|
+ getgamehistory(itimefrom, itimeto, ipage + 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}));
|
|
}));
|
|
@@ -374,6 +396,31 @@ void HttpSocket::sendreelmsg(string stronly, string strtarget, string strjson, f
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+void HttpSocket::getsynctime(__int64& itimefrom, __int64& itimeto, __int32& ipage, bool& bdone)
|
|
|
|
+{
|
|
|
|
+ itimefrom = 0;
|
|
|
|
+ itimeto = 0;
|
|
|
|
+ ipage = 0;
|
|
|
|
+ auto finddeveloper = m_pthirddeveloper->find_one(make_document(kvp("id", 2)));
|
|
|
|
+ if (finddeveloper && finddeveloper->view()["logtimefrom"] && finddeveloper->view()["logtimeto"] &&
|
|
|
|
+ finddeveloper->view()["logpage"] && finddeveloper->view()["logdone"])
|
|
|
|
+ {
|
|
|
|
+ itimefrom = finddeveloper->view()["logtimefrom"].get_int64();
|
|
|
|
+ itimeto = finddeveloper->view()["logtimeto"].get_int64();
|
|
|
|
+ ipage = finddeveloper->view()["logpage"].get_int32();
|
|
|
|
+ bdone = finddeveloper->view()["logdone"].get_bool();
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+void HttpSocket::setsynctime(__int64 itimefrom, __int64 itimeto, __int32 ipage, bool bdone)
|
|
|
|
+{
|
|
|
|
+ m_pthirddeveloper->find_one_and_update(make_document(kvp("id", 2)),
|
|
|
|
+ make_document(kvp("$set" , make_document(kvp("logtimefrom", itimefrom), kvp("logtimeto", itimeto), kvp("logpage", ipage), kvp("logdone", bdone)))));
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
///////////////////////////////////////// JsonToBson///////////////////////////////////////////
|
|
///////////////////////////////////////// JsonToBson///////////////////////////////////////////
|
|
// 主转换函数(处理JSON对象)
|
|
// 主转换函数(处理JSON对象)
|