123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764 |
- #pragma once
- #include <deque>
- #include <vector>
- #include <random>
- #include <fstream>
- #include <iostream>
- #include <boost/asio.hpp>
- #include <boost/thread.hpp>
- #include <boost/pfr.hpp>
- #include <boost/any.hpp>
- #include <boost/property_tree/ptree.hpp>
- #include <boost/property_tree/ini_parser.hpp>
- #include "bsoncxx/builder/stream/document.hpp"
- #include "mongocxx/instance.hpp"
- #include "mongocxx/uri.hpp"
- #include "mongocxx/client.hpp"
- #include <mongocxx/exception/exception.hpp>
- #include "bsoncxx/json.hpp"
- #include "rapidjson/document.h"
- #include "rapidjson/writer.h"
- #include "rapidjson/stringbuffer.h"
- #include <boost/filesystem.hpp>
- #include <unordered_set>
- #include <unordered_map>
- #include "funclib.hpp"
- #include "resource.h"
- #include <string>
- #include <sstream>
- #include <iostream>
- #pragma pack(1)
- //data define
- #define MSG_NUM 20
- #define HTTPLEN 30000
- #define HTTPSENDLEN 300000
- #define RECLEN 5000
- #define LEN_ACCOUNTS 32
- #define LEN_PASSWORD 33
- #define LEN_SEAT_PHONE 33 //固定电话或移动电话
- #define LEN_INFO 128
- #define LEN_IP 16 //IP长度
- #define LEN_ACTION 100 //操作行动
- #define LEN_ACTIONINFO 200 //操作描述
- #define LEN_AUTHCODE 32 //授权码
- #define LEN_AUTHKEY 32 //授权密码
- //msg define
- #define HTTPMIN 0 //http最小id
- #define HTTPREGUSER 1 //注册玩家账号
- #define HTTPUPDATEUSERSCORE 2 //更新玩家分数
- #define HTTPADMINKICKUSER 5 //管理员把玩家踢出房价
- #define HTTPADMINPROHIBITUSER 7 //管理员禁止管理员所属玩家
- #define HTTPGETUSERACCOUNT 8 //获取用户账号信息
- #define HTTPMODIFYUSERPWD 16 //修改玩家登录密码
- #define HTTPADMINPROHIBITMYUSER 20 //管理员禁止直属玩家
- #define HTTPLOOKUPCZ 21 //查询充值信息
- #define HTTPLOOKUPPLAYGAME 22 //查询游戏信息
- #define HTTPLOOKUPUSERPLAYSCORE 23 //查询玩家总下注和总赢回
- #define HTTPLACTIVEMSG 25 //程序激活消息
- #define HTTPLUPDATEUSERINGOT 26 //添加奖励码
- #define HTTPLBACKINGOT 27 //回退奖励码
- #define HTTPLOOKUPALLUSERPLAYSCORE 28 //查询所有玩家总下注和总赢回
- #define HTTPLOGINREEL 29 //登录真人视讯
- #define HTTPGENERATEREDEEMCODE 30 //兑换码
- #define HTTPMAX 31 //http最大id
- //game msg define
- #define MDM_CS_REGISTER 1
- #define MDM_CS_SERVICE_INFO 2
- #define SUB_CS_C_SERVER_UPDATESCORE 4
- #define SUB_CS_C_REGISTER_WEB 103
- static std::string g_chars(
- "abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "1234567890");
- static std::string g_redeemcodechars(
- "ABCDEFGHJKLMNPQRSTUVWXYZ"
- "0123456789");
- //msg data
- typedef struct tagMsgBuffer
- {
- __int32 itype;
- __int32 idatasize;
- void *pdata;
- }MsgBuffer;
- typedef struct tagwritedata
- {
- __int64 sendallsize; //发送总长度
- __int64 completesize; //发送完成长度
- }writedata;
- typedef struct tag_socketmsg
- {
- int isize;
- void *pbuffer;
- tag_socketmsg()
- {
- isize = 0;
- pbuffer = nullptr;
- }
- }socketmsg;
- struct staticdata
- {
- bool m_bcreaditagent{ false };
- bool m_bsubmeter{ false };
- bool bTest{ false };
- std::string m_strgamelist{};
- std::string m_strsubgame{};
- std::map<std::string, std::string> m_mapregiongame{};
- std::string m_gameiconurl{};
- std::string m_strlogurl{};
- std::string m_strgameurl{};
- std::string m_strreturnurl{};
- std::vector<std::int32_t> m_veckindid{};
- std::unordered_map<std::int32_t, std::string> m_maparead;
- std::map<__int32, std::string> m_mapkindid2name;
- };
- enum EErrorCode
- {
- Err_ParamError = 1008, // 参数错误
- Err_No_Player = 1009, // 未找到玩家
- Err_No_Agent = 1010, // 未找到代理
- Err_No_IPWhite = 1011, // IP不在白名单
- Err_No_APIPermission = 1012, // 没有api权限
- Err_OnUpdate_DynamicPass = 1013, // 玩家动态密码更新出错
- Err_APIType_NotTrans = 1014, // 代理不是转账钱包
- Err_OutOfState_Agent = 1015, // 代理不是启用状态
- Err_Agent_LackInfo = 1016, // 代理信息不完整
- Err_Player_LackInfo = 1017, // 玩家信息不完整
- Err_Create_PlayerAccount = 1018, // 玩家账号生成失败
- Err_Create_PlayerIndex = 1019, // 玩家账号数据库索引生成失败
- Err_Create_UserIdDuplication = 1020, // 玩家id重复
- Err_Create_AlreadHasLoseWin = 1021, // 用户输赢表存在
- Err_Create_UserAccDuplication = 1022, // 玩家账号重复
- Err_Create_InsertUserInfo = 1023, // 数据库插入玩家信息失败
- Err_Create_InsertLoseWin = 1024, // 数据库插入输赢表失败
- Err_Token_Expiration = 1025, // Token已过期
- Err_PrizeLog_NotFound = 1026, // 游戏日志未找到
- Err_PrizeLog_AgentErr = 1027, // 游戏日志代理不正确
- Err_PrizeLog_NoQuestId = 1028, // 游戏日志没有桌号ID
- Err_PrizeLog_NoGID = 1029, // 游戏日志没有GID
- Err_ExeChangeRate_NotFound = 1030, // 汇率表未找到
- Err_NoSitInfo = 1031, // 站点信息未找到
- Err_NoGrandPrizePool = 1032, // 未找到血池信息
- Err_UpdateScore_OrderDuplication = 1033, // 玩家上下分订单重复
- Err_No_UrlPullGame = 1034, // 拉起游戏的url未配置
- Err_UpdateScore_OuOfLimit = 1035, // 更新玩家分数-分数超限制
- Err_Player_InGame = 1036, // 玩家正在游戏中
- Err_Trade_Forbid = 1037, // 禁止交易
- Err_Trade_UserScoreLack = 1038, // 玩家交易分数不足
- Err_QueryTime_TooLong = 1039, // 查询时间范围过大
- Err_Player_LoginElse = 1040, // 玩家其它地方登录
- Err_Player_TokenExpired = 1041, // 玩家Token过期
- Err_Player_NotOnline = 1042, // 玩家不在线
- Err_InnerError = 1043, // 内部错误
- Err_KeyNotExist = 1044, // code或key不存在
- Err_CreateUserNumberError = 1045, // 创建玩家的数量过大
- Err_UserScoreLessZero = 1046, // 玩家分数小于0
- Err_AgentScoreNotEnough = 1047, // 代理分数不足
- Err_ThreeAdminLackInfo = 1048, // 第三方平台信息不完整
- Err_AgentUpdateScoreFailed = 1049, // 商家更新分数失败
- Err_UserUpdateScoreFailed = 1050, // 玩家分数更新失败
- Err_UpdateScoreTrickyError = 1051, // 更新分数票据错误
- Err_UserIdNotMatchSpreadId = 1052, // 玩家id与代理id不匹配
- Err_LoseWinTableNotFound = 1053, // 玩家输赢表未找到
- Err_AgengtHasNoPlayer = 1054, // 代理下没有玩家
- Err_ScoreParamError = 1055, // 分数参数错误,小于0
- Err_OverQueryTimeLimit = 1056, // 查询时间超时
- Err_FreeGameStatue = 1057, // 活动状态不允许操作
- Err_FreeGamePlayerError = 1058, // 玩家列表参数错误
- Err_FreeGameMaxCount = 1059, // 代理创建的活动已达到5
- Err_RedeemLableDuplicate = 1060, // 兑换码标签重复
- Err_TRANS_FAILED = 1061, // 转账失败
- Err_GAMECURRENCY_NOTMATCH = 1062, // 游戏货币类型不对
- };
- struct reguser
- {
- std::string authcode{};
- std::string authkey{};
- std::int64_t score{0}; //获取分数
- std::string name{}; //玩家姓名
- std::string phone{}; //玩家电话
- std::string info{}; //玩家备注
- public:
- std::string getfieldvalue(std::int32_t index)
- {
- const char* value[] = { "authcode", "authkey", "score", "name", "phone", "info"};
- return value[index];
- }
- void getdata()
- {
- authcode = authcode.substr(0, LEN_AUTHCODE);
- authkey = authkey.substr(0, LEN_AUTHKEY);
- name = name.substr(0, LEN_ACCOUNTS);
- phone = phone.substr(0, LEN_SEAT_PHONE);
- info = info.substr(0, LEN_INFO);
- if (score < 0)
- {
- score = 0;
- }
- }
- bool datavalue()
- {
- if (authcode.empty() || authkey.empty())
- {
- return false;
- }
- return true;
- }
- };
- struct userscore
- {
- std::string authcode{};
- std::string authkey{};
- std::string account{}; //玩家账号
- std::int64_t score{0}; //玩家分数
- __int32 iwallet{ 0 }; //钱包类型
- public:
- std::string getfieldvalue(std::int32_t index)
- {
- const char* value[] = { "authcode", "authkey", "account", "score", "wallet"};
- return value[index];
- }
- void getdata()
- {
- authcode = authcode.substr(0, LEN_AUTHCODE);
- authkey = authkey.substr(0, LEN_AUTHKEY);
- }
- bool datavalue()
- {
- if (authcode.empty() || authkey.empty() || account.empty())
- {
- return false;
- }
- return true;
- }
- };
- struct kickuser
- {
- std::string authcode{}; //代理对外账号
- std::string authkey{}; //代理对外密码
- std::string acc{}; //代理名下玩家账号
- public:
- std::string getfieldvalue(std::int32_t index)
- {
- const char* value[] = { "authcode", "authkey", "acc" };
- return value[index];
- }
- void getdata()
- {
- authcode = authcode.substr(0, LEN_AUTHCODE);
- authkey = authkey.substr(0, LEN_AUTHKEY);
- acc = acc.substr(0, LEN_ACCOUNTS);
- }
- bool datavalue()
- {
- if (authcode.empty() || authkey.empty() || acc.empty())
- {
- return false;
- }
- return true;
- }
- };
- struct prohibituser
- {
- std::string authcode{};
- std::string authkey{};
- std::string account{}; //玩家账号
- std::int32_t state{2}; //-1是封号,0是解封
- public:
- std::string getfieldvalue(std::int32_t index)
- {
- const char* value[] = { "authcode", "authkey", "account", "state" };
- return value[index];
- }
- void getdata()
- {
- authcode = authcode.substr(0, LEN_AUTHCODE);
- authkey = authkey.substr(0, LEN_AUTHKEY);
- account = account.substr(0, LEN_ACCOUNTS);
- }
- bool datavalue()
- {
- if (authcode.empty() || authkey.empty() || account.empty() || (state != -1 && state != 0))
- {
- return false;
- }
- return true;
- }
- };
- struct adminprohibituser
- {
- std::string authcode{};
- std::string authkey{};
- std::int32_t state{2}; //-1是封号,0是解封
- public:
- std::string getfieldvalue(std::int32_t index)
- {
- const char* value[] = { "authcode", "authkey", "state" };
- return value[index];
- }
- void getdata()
- {
- authcode = authcode.substr(0, LEN_AUTHCODE);
- authkey = authkey.substr(0, LEN_AUTHKEY);
- }
- bool datavalue()
- {
- if (authcode.empty() || authkey.empty() || (state != -1 && state != 0))
- {
- return false;
- }
- return true;
- }
- };
- struct sellbuyscoreinfo
- {
- std::string authcode{};
- std::string authkey{};
- std::int64_t ipagenum{0};
- std::int64_t begintime{0};
- std::int64_t endtime{0};
- std::int64_t iuserid{};
- std::int64_t iagentid{};
- public:
- std::string getfieldvalue(std::int32_t index)
- {
- const char* value[] = { "authcode", "authkey", "pagenum", "begintime", "endtime", "userid", "agentid"};
- return value[index];
- }
- void getdata()
- {
- authcode = authcode.substr(0, LEN_AUTHCODE);
- authkey = authkey.substr(0, LEN_AUTHKEY);
- }
- bool datavalue()
- {
- if (authcode.empty() || authkey.empty() || ipagenum < 0 || begintime <= 0 || endtime <= 0 || endtime < begintime || iuserid < 0 || iagentid < 0)
- {
- return false;
- }
- return true;
- }
- };
- struct playinfo
- {
- std::string authcode{};
- std::string authkey{};
- std::int64_t iuserid{}; //玩家账号
- std::int32_t igametype{};
- std::int32_t ipagesize{ 10 };
- std::int32_t ipagenum{0};
- std::int64_t begintime{0};
- std::int64_t endtime{0};
- public:
- std::string getfieldvalue(std::int32_t index)
- {
- const char* value[] = { "authcode", "authkey", "userid", "gametype", "pagesize", "pagenum", "begintime", "endtime"};
- return value[index];
- }
- void getdata()
- {
- authcode = authcode.substr(0, LEN_AUTHCODE);
- authkey = authkey.substr(0, LEN_AUTHKEY);
- }
- bool datavalue()
- {
- if (authcode.empty() || authkey.empty() || iuserid < 0 || igametype < 0 || ipagesize > 50 || ipagenum < 0 || begintime <= 0 || endtime <= 0 || endtime < begintime)
- {
- return false;
- }
- return true;
- }
- };
- struct getaccount
- {
- std::string authcode{};
- std::string authkey{};
- std::string account{}; //玩家账号
- public:
- std::string getfieldvalue(std::int32_t index)
- {
- const char* value[] = { "authcode", "authkey", "account" };
- return value[index];
- }
- void getdata()
- {
- authcode = authcode.substr(0, LEN_AUTHCODE);
- authkey = authkey.substr(0, LEN_AUTHKEY);
- account = account.substr(0, LEN_ACCOUNTS);
- }
- bool datavalue()
- {
- if (authcode.empty() || authkey.empty() || account.empty())
- {
- return false;
- }
- return true;
- }
- };
- struct playscoreinfo
- {
- std::string authcode{};
- std::string authkey{};
- std::string account{}; //玩家账号
- std::int64_t begintime{0};
- std::int64_t endtime{0};
- public:
- std::string getfieldvalue(std::int32_t index)
- {
- const char* value[] = { "authcode", "authkey", "account", "begintime", "endtime"};
- return value[index];
- }
- void getdata()
- {
- authcode = authcode.substr(0, LEN_AUTHCODE);
- authkey = authkey.substr(0, LEN_AUTHKEY);
- }
- bool datavalue()
- {
- if (authcode.empty() || authkey.empty() || account.length() < 6 || begintime <= 0 || endtime <= 0 || endtime < begintime)
- {
- return false;
- }
- return true;
- }
- };
- struct updateingot
- {
- std::string authcode;
- std::string authkey;
- std::string account; //玩家账号
- std::int64_t score; //添加奖励码个数,负数表明vip赠送出去
- public:
- std::string getfieldvalue(std::int32_t index)
- {
- const char* value[] = { "authcode", "authkey", "account", "score" };
- return value[index];
- }
- void getdata()
- {
- authcode = authcode.substr(0, LEN_AUTHCODE);
- authkey = authkey.substr(0, LEN_AUTHKEY);
- account = account.substr(0, LEN_ACCOUNTS);
- }
- bool datavalue()
- {
- if (authcode.empty() || authkey.empty() || account.length() < 6)
- {
- return false;
- }
- return true;
- }
- };
- struct backingot
- {
- std::string authcode{};
- std::string authkey{};
- std::string account{}; //玩家账号
- std::int64_t score{0}; //回退奖励码个数,负数表明vip赠送出去
- public:
- std::string getfieldvalue(std::int32_t index)
- {
- const char* value[] = { "authcode", "authkey", "account", "score" };
- return value[index];
- }
- void getdata()
- {
- authcode = authcode.substr(0, LEN_AUTHCODE);
- authkey = authkey.substr(0, LEN_AUTHKEY);
- account = account.substr(0, LEN_ACCOUNTS);
- }
- bool datavalue()
- {
- if (authcode.empty() || authkey.empty() || account.length() < 6)
- {
- return false;
- }
- return true;
- }
- };
- struct activemsg
- {
- __int64 activecode; //激活码
- char activekey[LEN_AUTHKEY];
- };
- //game msg data
- struct CMD_CS_C_RegisterWeb
- {
- TCHAR szServerAddr[32]; //服务地址
- };
- struct CMD_CS_C_UpdateScoreEx
- {
- DWORD dwUserID; //用户标识
- LONGLONG addscore;
- WORD wgameserverid;
- DWORD dwGameContextID;
- DWORD dwLoginContextID;
- };
- struct adminlogin
- {
- char authcode[LEN_AUTHCODE];
- char authkey[LEN_AUTHKEY];
- char account[LEN_ACCOUNTS]; //玩家账号
- char pwd[LEN_PASSWORD]; //玩家密码
- char pwd2[LEN_PASSWORD]; //商家二级密码
- char ip[LEN_IP]; //登录IP地址
- };
- struct userinfo
- {
- std::string authcode{};
- std::string authkey{};
- std::string account{}; //玩家账号
- std::string pwd{}; //玩家密码
- public:
- std::string getfieldvalue(std::int32_t index)
- {
- const char* value[] = { "authcode", "authkey", "account", "pwdnew" };
- return value[index];
- }
- void getdata()
- {
- authcode = authcode.substr(0, LEN_AUTHCODE);
- authkey = authkey.substr(0, LEN_AUTHKEY);
- account = account.substr(0, LEN_ACCOUNTS);
- pwd = pwd.substr(0, LEN_PASSWORD);
- }
- bool datavalue()
- {
- if (authcode.empty() || authkey.empty() || account.empty() || pwd.length() < 6)
- {
- return false;
- }
- return true;
- }
- };
- struct allplayscoreinfo
- {
- std::string authcode{};
- std::string authkey{};
- std::int32_t ipagenum{0};
- std::int64_t begintime{0};
- std::int64_t endtime{0};
- public:
- std::string getfieldvalue(std::int32_t index)
- {
- const char* value[] = { "authcode", "authkey", "pagenum", "begintime", "endtime" };
- return value[index];
- }
- void getdata()
- {
- authcode = authcode.substr(0, LEN_AUTHCODE);
- authkey = authkey.substr(0, LEN_AUTHKEY);
- }
- bool datavalue()
- {
- if (authcode.empty() || authkey.empty() || ipagenum < 0 || begintime <= 0 || endtime <= 0 || endtime < begintime)
- {
- return false;
- }
- return true;
- }
- };
- struct gameuserlog
- {
- __int64 dbquestid;
- std::string account;
- std::string servername;
- __int32 serverid;
- std::string betscore;
- std::string winscore;
- std::string userscore;
- std::string gamelog;
- __int64 inserttime;
- };
- struct taggameuserlog {
- __int32 ret;
- std::string info;
- __int64 allrecordnum;
- __int64 recordnum;
- __int64 curpagenum;
- __int64 allpagenum;
- std::vector<gameuserlog> userlog{};
- };
- //踢出玩家
- struct CMD_CS_C_DelOnlineUser
- {
- DWORD dwUserID;
- WORD wserverid;
- DWORD dwGameContextID;
- };
- struct reelplayuser
- {
- std::string struseracc{}; //玩家
- std::string strcert{}; //玩家密钥
- __int32 ikindid=0;
- public:
- std::string getfieldvalue(std::int32_t index)
- {
- const char* value[] = { "useracc", "cert", "kindid"};
- return value[index];
- }
- void getdata()
- {
- }
- bool datavalue()
- {
- if (strcert.empty() || struseracc.empty() || 0== ikindid)
- {
- return false;
- }
- return true;
- }
- };
- enum ERedeemCodeType
- {
- ERCT_ONLY = 1, // 唯一码
- ERCT_SHRE = 2, // 共享码
- ERCT_MAX,
- };
- struct sRedeemCodeGenerate
- {
- std::string authcode{};
- std::string authkey{};
- std::string info = ""; // lable
- __int32 iquantity = 0; // 生成数量
- __int32 icodetype = 1; // ERedeemCodeType
- __int32 iexchangelimit = 1; // 兑换次数
- __int32 iaccountlimit = 1; // 账号兑换次数
- __int64 iscore = 0;
- __int64 istarttime = 0;
- __int64 iendtime = 0;
- public:
- std::string getfieldvalue(std::int32_t index)
- {
- const char* value[] = { "authcode", "authkey", "info", "quantity", "type","exchangelimit", "accountlimit", "score", "st", "et" };
- return value[index];
- }
- bool datavalue()
- {
- if (info.empty() || authcode.empty() || authkey.empty() || (icodetype == 2 && iexchangelimit < 2) || istarttime > iendtime || iscore < 1 || iaccountlimit < 1 || iquantity < 1)
- {
- return false;
- }
- return true;
- }
- void getdata()
- {
- }
- };
- #pragma pack()
|