|
@@ -1021,10 +1021,20 @@ std::string HttpSocket::updateuserscore(std::map<std::string, std::string> getda
|
|
|
return strret;
|
|
|
}
|
|
|
|
|
|
+ __int64 iuserscore = firstuser->view()["score"].get_int64();
|
|
|
+ __int32 iusertype = firstuser->view()["usertype"].get_int32();
|
|
|
+ __int32 inewwallettype = -1;
|
|
|
+ if (iuserscore == 0)
|
|
|
+ inewwallettype = tuserscore.iwallet;
|
|
|
+ if (iuserscore > 0 && iusertype != tuserscore.iwallet)
|
|
|
+ {
|
|
|
+ strret = funclib::rettojson(Err_GAMECURRENCY_NOTMATCH, "user wallet type error");
|
|
|
+ return strret;
|
|
|
+ }
|
|
|
+
|
|
|
__int64 iuserid = 0;
|
|
|
__int64 inserttime = funclib::gettimestamp();
|
|
|
__int64 ilocaltime = funclib::getlocaltimestamp();
|
|
|
- __int64 vipscore = vipuser->view()["score"].get_int64();
|
|
|
__int64 beforeuserscore = 0;
|
|
|
__int64 useringot = 0;
|
|
|
__int64 beforespreaderscore = 0;
|
|
@@ -1033,6 +1043,9 @@ std::string HttpSocket::updateuserscore(std::map<std::string, std::string> getda
|
|
|
__int64 tradescore = 0;
|
|
|
// type=1商家送分给玩家;type=2商家给玩家收分
|
|
|
__int32 itype = 0;
|
|
|
+ __int64 vipscore = vipuser->view()["score"].get_int64();
|
|
|
+ if (tuserscore.iwallet == 2)
|
|
|
+ vipscore = vipuser->view()["freescore"] ? vipuser->view()["freescore"].get_int64() : 0;
|
|
|
std::string strusername;
|
|
|
std::string struseraccount;
|
|
|
std::string struserip;
|
|
@@ -1040,6 +1053,7 @@ std::string HttpSocket::updateuserscore(std::map<std::string, std::string> getda
|
|
|
std::string strspreaderaccount;
|
|
|
std::string strspreaderip;
|
|
|
std::string strwebonlyuser{};
|
|
|
+ std::string strwallet = tuserscore.iwallet == 2 ? "freescore" : "score";
|
|
|
|
|
|
//商家送分
|
|
|
if (tuserscore.score < 0)
|
|
@@ -1063,7 +1077,7 @@ std::string HttpSocket::updateuserscore(std::map<std::string, std::string> getda
|
|
|
|
|
|
//减商家分数
|
|
|
auto criteria = make_document(kvp("userid", adminuserid));
|
|
|
- auto update = make_document(kvp("$inc", make_document(kvp("score", tuserscore.score))));
|
|
|
+ auto update = make_document(kvp("$inc", make_document(kvp(strwallet, tuserscore.score))));
|
|
|
auto retscore = m_pvipuser->find_one_and_update(criteria.view(), update.view());
|
|
|
if (!retscore)
|
|
|
{
|
|
@@ -1077,7 +1091,7 @@ std::string HttpSocket::updateuserscore(std::map<std::string, std::string> getda
|
|
|
return strret;
|
|
|
}
|
|
|
|
|
|
- beforespreaderscore = retscore->view()["score"].get_int64();
|
|
|
+ beforespreaderscore = retscore->view()[strwallet] ? retscore->view()[strwallet].get_int64() : 0;
|
|
|
strspreadername = retscore->view()["name"].get_utf8().value.data();
|
|
|
strspreaderaccount = retscore->view()["account"].get_utf8().value.data();
|
|
|
if(retscore->view()["loginip"])
|
|
@@ -1089,7 +1103,11 @@ std::string HttpSocket::updateuserscore(std::map<std::string, std::string> getda
|
|
|
tuserscore.score = -1 * tuserscore.score;
|
|
|
tradescore = tuserscore.score;
|
|
|
auto usercriteria = make_document(kvp("userid", iuserid));
|
|
|
- auto userupdate = make_document(kvp("$inc", make_document(kvp("score", tuserscore.score))));
|
|
|
+ //auto userupdate = make_document(kvp("$inc", make_document(kvp("score", tuserscore.score))));
|
|
|
+ document userupdate;
|
|
|
+ userupdate.append(kvp("$inc", make_document(kvp("score", tuserscore.score))));
|
|
|
+ if (inewwallettype > -1)
|
|
|
+ userupdate.append(kvp("$set", make_document(kvp("usertype", inewwallettype))));
|
|
|
auto userretscore = m_pcoll->find_one_and_update(usercriteria.view(), userupdate.view());
|
|
|
if (!userretscore)
|
|
|
{
|
|
@@ -1186,7 +1204,7 @@ std::string HttpSocket::updateuserscore(std::map<std::string, std::string> getda
|
|
|
auto builder = bsoncxx::builder::stream::document{};
|
|
|
builder << "userid" << iuserid << "name" << strusername.c_str() << "useraccount" << struseraccount.c_str() << "userip" << struserip.c_str()
|
|
|
<< "spreaderid" << adminuserid << "spreadername" << strspreadername.c_str() << "spreaderaccount" << strspreaderaccount.c_str()
|
|
|
- << "spreaderip" << strspreaderip.c_str() << "beforeuserscore" << beforeuserscore << "beforespreaderscore" << beforespreaderscore
|
|
|
+ << "spreaderip" << strspreaderip.c_str() << "beforeuserscore" << beforeuserscore << "beforespreaderscore" << beforespreaderscore << "usertype" << tuserscore.iwallet
|
|
|
<< "afteruserscore" << afteruserscore << "afterspreaderscore" << afterspreaderscore << "type" << itype << "tradescore" << tradescore << "inserttime" << inserttime;
|
|
|
m_pusertradeinfo->insert_one(builder.view());
|
|
|
}
|
|
@@ -1307,7 +1325,7 @@ std::string HttpSocket::updateuserscore(std::map<std::string, std::string> getda
|
|
|
return strret;
|
|
|
}
|
|
|
|
|
|
- beforespreaderscore = firstadmin->view()["score"].get_int64();
|
|
|
+ beforespreaderscore = firstadmin->view()[strwallet] ? firstadmin->view()[strwallet].get_int64() : 0;
|
|
|
strspreadername = firstadmin->view()["name"].get_utf8().value.data();
|
|
|
strspreaderaccount = firstadmin->view()["account"].get_utf8().value.data();
|
|
|
strspreaderip = firstadmin->view()["loginip"].get_utf8().value.data();
|
|
@@ -1335,7 +1353,7 @@ std::string HttpSocket::updateuserscore(std::map<std::string, std::string> getda
|
|
|
m_plosewincoll->find_one_and_update(usercriteria.view(), xiafenupdate.view());
|
|
|
|
|
|
auto admincriteria = make_document(kvp("userid", adminuserid));
|
|
|
- auto adminupdate = make_document(kvp("$inc", make_document(kvp("score", tradescore))));
|
|
|
+ auto adminupdate = make_document(kvp("$inc", make_document(kvp(strwallet, tradescore))));
|
|
|
auto adminretscore = m_pvipuser->find_one_and_update(admincriteria.view(), adminupdate.view());
|
|
|
if (!adminretscore)
|
|
|
{
|
|
@@ -1395,7 +1413,7 @@ std::string HttpSocket::updateuserscore(std::map<std::string, std::string> getda
|
|
|
auto builder = bsoncxx::builder::stream::document{};
|
|
|
builder << "userid" << iuserid << "name" << strusername.c_str() << "useraccount" << struseraccount.c_str() << "userip" << struserip.c_str()
|
|
|
<< "spreaderid" << adminuserid << "spreadername" << strspreadername.c_str() << "spreaderaccount" << strspreaderaccount.c_str() << "spreaderip" << strspreaderip.c_str()
|
|
|
- << "beforeuserscore" << beforeuserscore << "beforespreaderscore" << beforespreaderscore << "afteruserscore" << afteruserscore
|
|
|
+ << "beforeuserscore" << beforeuserscore << "beforespreaderscore" << beforespreaderscore << "afteruserscore" << afteruserscore << "usertype" << tuserscore.iwallet
|
|
|
<< "afterspreaderscore" << afterspreaderscore << "type" << itype << "tradescore" << tradescore << "inserttime" << inserttime;
|
|
|
auto result = m_pusertradeinfo->insert_one(builder.view());
|
|
|
|
|
@@ -1798,9 +1816,14 @@ std::string HttpSocket::getuseraccount(std::map<std::string, std::string> getdat
|
|
|
iscore = finduser->view()["score"].get_int64();
|
|
|
iscore -= iingot;
|
|
|
}
|
|
|
-
|
|
|
strscore = getdouble(iscore);
|
|
|
|
|
|
+ __int32 iusertype = 0;
|
|
|
+ if (finduser->view()["usertype"])
|
|
|
+ {
|
|
|
+ iusertype = finduser->view()["usertype"].get_int32();
|
|
|
+ }
|
|
|
+
|
|
|
istate = 0;
|
|
|
if (finduser->view()["state"])
|
|
|
{
|
|
@@ -1809,6 +1832,7 @@ std::string HttpSocket::getuseraccount(std::map<std::string, std::string> getdat
|
|
|
|
|
|
doc.AddMember("ingot", rapidjson::Value(stringot.c_str(), allocator), allocator);
|
|
|
doc.AddMember("score", rapidjson::Value(strscore.c_str(), allocator), allocator);
|
|
|
+ doc.AddMember("wallet", iusertype, allocator);
|
|
|
|
|
|
if (!istate)
|
|
|
{
|
|
@@ -3313,8 +3337,7 @@ std::string HttpSocket::reelplay(std::map<std::string, std::string> getdata, std
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if ((iusertype == 0 && setcurrency.end() == setcurrency.find(1)) || // 不支持真金
|
|
|
- (iusertype == 2 && setcurrency.end() == setcurrency.find(3))) // 不支持免费币
|
|
|
+ if (iusertype == 2 || (iusertype == 0 && setcurrency.end() == setcurrency.find(1))) // 不支持免费币
|
|
|
{
|
|
|
dofun(funclib::rettojson(Err_GAMECURRENCY_NOTMATCH, "currency type error"), 200);
|
|
|
return "";
|