Browse Source

code merge

game 1 month ago
parent
commit
11befbf6c7
2 changed files with 9 additions and 9 deletions
  1. 6 6
      webapi/webapi/HttpSocket.cpp
  2. 3 3
      webapi/webapi/data.h

+ 6 - 6
webapi/webapi/HttpSocket.cpp

@@ -801,7 +801,7 @@ std::string HttpSocket::regaccount(std::map<std::string, std::string> getdata)
 	auto userbuilder = bsoncxx::builder::stream::document{};
 	userbuilder << "userid" << userid << "gameid" << gameid << "areaid" << iareaid << "devicetype" << izero32 << "name" << strname.c_str() << "state" << izero32 << "usertype" << izero32
 		<< "userright" << izero32 << "score" << iscore << "insurescore" << izero64 << "spreaderid" << adminuserid << "spreaderidall" << strspreaderidall.c_str()
-		<< "logontime" << izero64 << "account" << straccount.c_str() << "nickname" << straccount.c_str() << "faceid" << izero32
+		<< "logontime" << izero64 << "account" << straccount.c_str() << "webuser" << straccount.c_str() << "nickname" << straccount.c_str() << "faceid" << izero32
 		<< "logonpwd" << strpwd.c_str() << "insurepwd" << strpwd.c_str() << "lastlogonmachineid" << strmac.c_str()
 		<< "regstermachineid" << strmac.c_str() << "lastlogonip" << registerip.c_str() << "registerlogonip" << registerip.c_str() << "registerdate" << inserttime
 		<< "dynamicpass" << strmac.c_str() << "mobilephone" << strmobilephone.c_str() << "info" << strinfo.c_str();
@@ -976,8 +976,8 @@ std::string HttpSocket::updateuserscore(std::map<std::string, std::string> getda
 
 
 	//用户不存在不减商家的分数
-	auto firstuser = m_pcoll->find_one(bsoncxx::builder::stream::document{} << "userid" << tuserscore.iuserid << bsoncxx::builder::stream::finalize);
-	if (!firstuser || firstuser->view()["spreaderid"])
+	auto firstuser = m_pcoll->find_one(bsoncxx::builder::stream::document{} << "account" << tuserscore.account.c_str() << bsoncxx::builder::stream::finalize);
+	if (!firstuser || !firstuser->view()["spreaderid"])
 	{
 		strret = funclib::rettojson(11, "user is not exist");
 		return strret;
@@ -1240,7 +1240,7 @@ std::string HttpSocket::updateuserscore(std::map<std::string, std::string> getda
 		}
 
 		//用户不存在不能下分
-		auto userretscore = m_pcoll->find_one(bsoncxx::builder::stream::document{} << "userid" << tuserscore.iuserid << bsoncxx::builder::stream::finalize);
+		auto userretscore = m_pcoll->find_one(bsoncxx::builder::stream::document{} << "account" << tuserscore.account.c_str() << bsoncxx::builder::stream::finalize);
 		if (!userretscore || !userretscore->view()["userid"])
 		{
 			strret = funclib::rettojson(Err_No_Player, "user isnot exist");
@@ -1249,7 +1249,7 @@ std::string HttpSocket::updateuserscore(std::map<std::string, std::string> getda
 
 
 		//玩家在玩游戏不能下分
-		auto vipuser = m_pplayuseronline->find_one(bsoncxx::builder::stream::document{} << "userid" << tuserscore.iuserid << bsoncxx::builder::stream::finalize);
+		auto vipuser = m_pplayuseronline->find_one(bsoncxx::builder::stream::document{} << "account" << tuserscore.account.c_str() << bsoncxx::builder::stream::finalize);
 		if (vipuser)
 		{
 			strret = funclib::rettojson(Err_Player_InGame, "user is playing");
@@ -1305,7 +1305,7 @@ std::string HttpSocket::updateuserscore(std::map<std::string, std::string> getda
 
 		//减用户分数
 		tuserscore.score = -1 * tuserscore.score;
-		auto usercriteria = make_document(kvp("userid", tuserscore.iuserid));
+		auto usercriteria = make_document(kvp("account", tuserscore.account.c_str()));
 		auto userupdate = make_document(kvp("$inc", make_document(kvp("score", tuserscore.score))));
 		auto tempscore = m_pcoll->find_one_and_update(usercriteria.view(), userupdate.view());
 		if (!tempscore)

+ 3 - 3
webapi/webapi/data.h

@@ -222,13 +222,13 @@ struct userscore
 {
 	std::string authcode{};
 	std::string authkey{};
-	std::int64_t iuserid{};			//玩家账号
+	std::string account{};			//玩家账号
 	std::int64_t score{0};			//玩家分数
 
 public:
 	std::string getfieldvalue(std::int32_t index)
 	{
-		const char* value[] = { "authcode", "authkey", "userid", "score"};
+		const char* value[] = { "authcode", "authkey", "account", "score"};
 		return value[index];
 	}
 
@@ -241,7 +241,7 @@ public:
 	bool datavalue()
 	{
 
-		if (authcode.empty() || authkey.empty() || iuserid < 0)
+		if (authcode.empty() || authkey.empty() || account.empty())
 		{
 			return false;
 		}