data.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764
  1. #pragma once
  2. #include <deque>
  3. #include <vector>
  4. #include <random>
  5. #include <fstream>
  6. #include <iostream>
  7. #include <boost/asio.hpp>
  8. #include <boost/thread.hpp>
  9. #include <boost/pfr.hpp>
  10. #include <boost/any.hpp>
  11. #include <boost/property_tree/ptree.hpp>
  12. #include <boost/property_tree/ini_parser.hpp>
  13. #include "bsoncxx/builder/stream/document.hpp"
  14. #include "mongocxx/instance.hpp"
  15. #include "mongocxx/uri.hpp"
  16. #include "mongocxx/client.hpp"
  17. #include <mongocxx/exception/exception.hpp>
  18. #include "bsoncxx/json.hpp"
  19. #include "rapidjson/document.h"
  20. #include "rapidjson/writer.h"
  21. #include "rapidjson/stringbuffer.h"
  22. #include <boost/filesystem.hpp>
  23. #include <unordered_set>
  24. #include <unordered_map>
  25. #include "funclib.hpp"
  26. #include "resource.h"
  27. #include <string>
  28. #include <sstream>
  29. #include <iostream>
  30. #pragma pack(1)
  31. //data define
  32. #define MSG_NUM 20
  33. #define HTTPLEN 30000
  34. #define HTTPSENDLEN 300000
  35. #define RECLEN 5000
  36. #define LEN_ACCOUNTS 32
  37. #define LEN_PASSWORD 33
  38. #define LEN_SEAT_PHONE 33 //固定电话或移动电话
  39. #define LEN_INFO 128
  40. #define LEN_IP 16 //IP长度
  41. #define LEN_ACTION 100 //操作行动
  42. #define LEN_ACTIONINFO 200 //操作描述
  43. #define LEN_AUTHCODE 32 //授权码
  44. #define LEN_AUTHKEY 32 //授权密码
  45. //msg define
  46. #define HTTPMIN 0 //http最小id
  47. #define HTTPREGUSER 1 //注册玩家账号
  48. #define HTTPUPDATEUSERSCORE 2 //更新玩家分数
  49. #define HTTPADMINKICKUSER 5 //管理员把玩家踢出房价
  50. #define HTTPADMINPROHIBITUSER 7 //管理员禁止管理员所属玩家
  51. #define HTTPGETUSERACCOUNT 8 //获取用户账号信息
  52. #define HTTPMODIFYUSERPWD 16 //修改玩家登录密码
  53. #define HTTPADMINPROHIBITMYUSER 20 //管理员禁止直属玩家
  54. #define HTTPLOOKUPCZ 21 //查询充值信息
  55. #define HTTPLOOKUPPLAYGAME 22 //查询游戏信息
  56. #define HTTPLOOKUPUSERPLAYSCORE 23 //查询玩家总下注和总赢回
  57. #define HTTPLACTIVEMSG 25 //程序激活消息
  58. #define HTTPLUPDATEUSERINGOT 26 //添加奖励码
  59. #define HTTPLBACKINGOT 27 //回退奖励码
  60. #define HTTPLOOKUPALLUSERPLAYSCORE 28 //查询所有玩家总下注和总赢回
  61. #define HTTPLOGINREEL 29 //登录真人视讯
  62. #define HTTPGENERATEREDEEMCODE 30 //兑换码
  63. #define HTTPMAX 31 //http最大id
  64. //game msg define
  65. #define MDM_CS_REGISTER 1
  66. #define MDM_CS_SERVICE_INFO 2
  67. #define SUB_CS_C_SERVER_UPDATESCORE 4
  68. #define SUB_CS_C_REGISTER_WEB 103
  69. static std::string g_chars(
  70. "abcdefghijklmnopqrstuvwxyz"
  71. "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  72. "1234567890");
  73. static std::string g_redeemcodechars(
  74. "ABCDEFGHJKLMNPQRSTUVWXYZ"
  75. "0123456789");
  76. //msg data
  77. typedef struct tagMsgBuffer
  78. {
  79. __int32 itype;
  80. __int32 idatasize;
  81. void *pdata;
  82. }MsgBuffer;
  83. typedef struct tagwritedata
  84. {
  85. __int64 sendallsize; //发送总长度
  86. __int64 completesize; //发送完成长度
  87. }writedata;
  88. typedef struct tag_socketmsg
  89. {
  90. int isize;
  91. void *pbuffer;
  92. tag_socketmsg()
  93. {
  94. isize = 0;
  95. pbuffer = nullptr;
  96. }
  97. }socketmsg;
  98. struct staticdata
  99. {
  100. bool m_bcreaditagent{ false };
  101. bool m_bsubmeter{ false };
  102. bool bTest{ false };
  103. std::string m_strgamelist{};
  104. std::string m_strsubgame{};
  105. std::map<std::string, std::string> m_mapregiongame{};
  106. std::string m_gameiconurl{};
  107. std::string m_strlogurl{};
  108. std::string m_strgameurl{};
  109. std::string m_strreturnurl{};
  110. std::vector<std::int32_t> m_veckindid{};
  111. std::unordered_map<std::int32_t, std::string> m_maparead;
  112. std::map<__int32, std::string> m_mapkindid2name;
  113. };
  114. enum EErrorCode
  115. {
  116. Err_ParamError = 1008, // 参数错误
  117. Err_No_Player = 1009, // 未找到玩家
  118. Err_No_Agent = 1010, // 未找到代理
  119. Err_No_IPWhite = 1011, // IP不在白名单
  120. Err_No_APIPermission = 1012, // 没有api权限
  121. Err_OnUpdate_DynamicPass = 1013, // 玩家动态密码更新出错
  122. Err_APIType_NotTrans = 1014, // 代理不是转账钱包
  123. Err_OutOfState_Agent = 1015, // 代理不是启用状态
  124. Err_Agent_LackInfo = 1016, // 代理信息不完整
  125. Err_Player_LackInfo = 1017, // 玩家信息不完整
  126. Err_Create_PlayerAccount = 1018, // 玩家账号生成失败
  127. Err_Create_PlayerIndex = 1019, // 玩家账号数据库索引生成失败
  128. Err_Create_UserIdDuplication = 1020, // 玩家id重复
  129. Err_Create_AlreadHasLoseWin = 1021, // 用户输赢表存在
  130. Err_Create_UserAccDuplication = 1022, // 玩家账号重复
  131. Err_Create_InsertUserInfo = 1023, // 数据库插入玩家信息失败
  132. Err_Create_InsertLoseWin = 1024, // 数据库插入输赢表失败
  133. Err_Token_Expiration = 1025, // Token已过期
  134. Err_PrizeLog_NotFound = 1026, // 游戏日志未找到
  135. Err_PrizeLog_AgentErr = 1027, // 游戏日志代理不正确
  136. Err_PrizeLog_NoQuestId = 1028, // 游戏日志没有桌号ID
  137. Err_PrizeLog_NoGID = 1029, // 游戏日志没有GID
  138. Err_ExeChangeRate_NotFound = 1030, // 汇率表未找到
  139. Err_NoSitInfo = 1031, // 站点信息未找到
  140. Err_NoGrandPrizePool = 1032, // 未找到血池信息
  141. Err_UpdateScore_OrderDuplication = 1033, // 玩家上下分订单重复
  142. Err_No_UrlPullGame = 1034, // 拉起游戏的url未配置
  143. Err_UpdateScore_OuOfLimit = 1035, // 更新玩家分数-分数超限制
  144. Err_Player_InGame = 1036, // 玩家正在游戏中
  145. Err_Trade_Forbid = 1037, // 禁止交易
  146. Err_Trade_UserScoreLack = 1038, // 玩家交易分数不足
  147. Err_QueryTime_TooLong = 1039, // 查询时间范围过大
  148. Err_Player_LoginElse = 1040, // 玩家其它地方登录
  149. Err_Player_TokenExpired = 1041, // 玩家Token过期
  150. Err_Player_NotOnline = 1042, // 玩家不在线
  151. Err_InnerError = 1043, // 内部错误
  152. Err_KeyNotExist = 1044, // code或key不存在
  153. Err_CreateUserNumberError = 1045, // 创建玩家的数量过大
  154. Err_UserScoreLessZero = 1046, // 玩家分数小于0
  155. Err_AgentScoreNotEnough = 1047, // 代理分数不足
  156. Err_ThreeAdminLackInfo = 1048, // 第三方平台信息不完整
  157. Err_AgentUpdateScoreFailed = 1049, // 商家更新分数失败
  158. Err_UserUpdateScoreFailed = 1050, // 玩家分数更新失败
  159. Err_UpdateScoreTrickyError = 1051, // 更新分数票据错误
  160. Err_UserIdNotMatchSpreadId = 1052, // 玩家id与代理id不匹配
  161. Err_LoseWinTableNotFound = 1053, // 玩家输赢表未找到
  162. Err_AgengtHasNoPlayer = 1054, // 代理下没有玩家
  163. Err_ScoreParamError = 1055, // 分数参数错误,小于0
  164. Err_OverQueryTimeLimit = 1056, // 查询时间超时
  165. Err_FreeGameStatue = 1057, // 活动状态不允许操作
  166. Err_FreeGamePlayerError = 1058, // 玩家列表参数错误
  167. Err_FreeGameMaxCount = 1059, // 代理创建的活动已达到5
  168. Err_RedeemLableDuplicate = 1060, // 兑换码标签重复
  169. Err_TRANS_FAILED = 1061, // 转账失败
  170. Err_GAMECURRENCY_NOTMATCH = 1062, // 游戏货币类型不对
  171. };
  172. struct reguser
  173. {
  174. std::string authcode{};
  175. std::string authkey{};
  176. std::int64_t score{0}; //获取分数
  177. std::string name{}; //玩家姓名
  178. std::string phone{}; //玩家电话
  179. std::string info{}; //玩家备注
  180. public:
  181. std::string getfieldvalue(std::int32_t index)
  182. {
  183. const char* value[] = { "authcode", "authkey", "score", "name", "phone", "info"};
  184. return value[index];
  185. }
  186. void getdata()
  187. {
  188. authcode = authcode.substr(0, LEN_AUTHCODE);
  189. authkey = authkey.substr(0, LEN_AUTHKEY);
  190. name = name.substr(0, LEN_ACCOUNTS);
  191. phone = phone.substr(0, LEN_SEAT_PHONE);
  192. info = info.substr(0, LEN_INFO);
  193. if (score < 0)
  194. {
  195. score = 0;
  196. }
  197. }
  198. bool datavalue()
  199. {
  200. if (authcode.empty() || authkey.empty())
  201. {
  202. return false;
  203. }
  204. return true;
  205. }
  206. };
  207. struct userscore
  208. {
  209. std::string authcode{};
  210. std::string authkey{};
  211. std::string account{}; //玩家账号
  212. std::int64_t score{0}; //玩家分数
  213. __int32 iwallet{ 0 }; //钱包类型
  214. public:
  215. std::string getfieldvalue(std::int32_t index)
  216. {
  217. const char* value[] = { "authcode", "authkey", "account", "score", "wallet"};
  218. return value[index];
  219. }
  220. void getdata()
  221. {
  222. authcode = authcode.substr(0, LEN_AUTHCODE);
  223. authkey = authkey.substr(0, LEN_AUTHKEY);
  224. }
  225. bool datavalue()
  226. {
  227. if (authcode.empty() || authkey.empty() || account.empty())
  228. {
  229. return false;
  230. }
  231. return true;
  232. }
  233. };
  234. struct kickuser
  235. {
  236. std::string authcode{}; //代理对外账号
  237. std::string authkey{}; //代理对外密码
  238. std::string acc{}; //代理名下玩家账号
  239. public:
  240. std::string getfieldvalue(std::int32_t index)
  241. {
  242. const char* value[] = { "authcode", "authkey", "acc" };
  243. return value[index];
  244. }
  245. void getdata()
  246. {
  247. authcode = authcode.substr(0, LEN_AUTHCODE);
  248. authkey = authkey.substr(0, LEN_AUTHKEY);
  249. acc = acc.substr(0, LEN_ACCOUNTS);
  250. }
  251. bool datavalue()
  252. {
  253. if (authcode.empty() || authkey.empty() || acc.empty())
  254. {
  255. return false;
  256. }
  257. return true;
  258. }
  259. };
  260. struct prohibituser
  261. {
  262. std::string authcode{};
  263. std::string authkey{};
  264. std::string account{}; //玩家账号
  265. std::int32_t state{2}; //-1是封号,0是解封
  266. public:
  267. std::string getfieldvalue(std::int32_t index)
  268. {
  269. const char* value[] = { "authcode", "authkey", "account", "state" };
  270. return value[index];
  271. }
  272. void getdata()
  273. {
  274. authcode = authcode.substr(0, LEN_AUTHCODE);
  275. authkey = authkey.substr(0, LEN_AUTHKEY);
  276. account = account.substr(0, LEN_ACCOUNTS);
  277. }
  278. bool datavalue()
  279. {
  280. if (authcode.empty() || authkey.empty() || account.empty() || (state != -1 && state != 0))
  281. {
  282. return false;
  283. }
  284. return true;
  285. }
  286. };
  287. struct adminprohibituser
  288. {
  289. std::string authcode{};
  290. std::string authkey{};
  291. std::int32_t state{2}; //-1是封号,0是解封
  292. public:
  293. std::string getfieldvalue(std::int32_t index)
  294. {
  295. const char* value[] = { "authcode", "authkey", "state" };
  296. return value[index];
  297. }
  298. void getdata()
  299. {
  300. authcode = authcode.substr(0, LEN_AUTHCODE);
  301. authkey = authkey.substr(0, LEN_AUTHKEY);
  302. }
  303. bool datavalue()
  304. {
  305. if (authcode.empty() || authkey.empty() || (state != -1 && state != 0))
  306. {
  307. return false;
  308. }
  309. return true;
  310. }
  311. };
  312. struct sellbuyscoreinfo
  313. {
  314. std::string authcode{};
  315. std::string authkey{};
  316. std::int64_t ipagenum{0};
  317. std::int64_t begintime{0};
  318. std::int64_t endtime{0};
  319. std::int64_t iuserid{};
  320. std::int64_t iagentid{};
  321. public:
  322. std::string getfieldvalue(std::int32_t index)
  323. {
  324. const char* value[] = { "authcode", "authkey", "pagenum", "begintime", "endtime", "userid", "agentid"};
  325. return value[index];
  326. }
  327. void getdata()
  328. {
  329. authcode = authcode.substr(0, LEN_AUTHCODE);
  330. authkey = authkey.substr(0, LEN_AUTHKEY);
  331. }
  332. bool datavalue()
  333. {
  334. if (authcode.empty() || authkey.empty() || ipagenum < 0 || begintime <= 0 || endtime <= 0 || endtime < begintime || iuserid < 0 || iagentid < 0)
  335. {
  336. return false;
  337. }
  338. return true;
  339. }
  340. };
  341. struct playinfo
  342. {
  343. std::string authcode{};
  344. std::string authkey{};
  345. std::int64_t iuserid{}; //玩家账号
  346. std::int32_t igametype{};
  347. std::int32_t ipagesize{ 10 };
  348. std::int32_t ipagenum{0};
  349. std::int64_t begintime{0};
  350. std::int64_t endtime{0};
  351. public:
  352. std::string getfieldvalue(std::int32_t index)
  353. {
  354. const char* value[] = { "authcode", "authkey", "userid", "gametype", "pagesize", "pagenum", "begintime", "endtime"};
  355. return value[index];
  356. }
  357. void getdata()
  358. {
  359. authcode = authcode.substr(0, LEN_AUTHCODE);
  360. authkey = authkey.substr(0, LEN_AUTHKEY);
  361. }
  362. bool datavalue()
  363. {
  364. if (authcode.empty() || authkey.empty() || iuserid < 0 || igametype < 0 || ipagesize > 50 || ipagenum < 0 || begintime <= 0 || endtime <= 0 || endtime < begintime)
  365. {
  366. return false;
  367. }
  368. return true;
  369. }
  370. };
  371. struct getaccount
  372. {
  373. std::string authcode{};
  374. std::string authkey{};
  375. std::string account{}; //玩家账号
  376. public:
  377. std::string getfieldvalue(std::int32_t index)
  378. {
  379. const char* value[] = { "authcode", "authkey", "account" };
  380. return value[index];
  381. }
  382. void getdata()
  383. {
  384. authcode = authcode.substr(0, LEN_AUTHCODE);
  385. authkey = authkey.substr(0, LEN_AUTHKEY);
  386. account = account.substr(0, LEN_ACCOUNTS);
  387. }
  388. bool datavalue()
  389. {
  390. if (authcode.empty() || authkey.empty() || account.empty())
  391. {
  392. return false;
  393. }
  394. return true;
  395. }
  396. };
  397. struct playscoreinfo
  398. {
  399. std::string authcode{};
  400. std::string authkey{};
  401. std::string account{}; //玩家账号
  402. std::int64_t begintime{0};
  403. std::int64_t endtime{0};
  404. public:
  405. std::string getfieldvalue(std::int32_t index)
  406. {
  407. const char* value[] = { "authcode", "authkey", "account", "begintime", "endtime"};
  408. return value[index];
  409. }
  410. void getdata()
  411. {
  412. authcode = authcode.substr(0, LEN_AUTHCODE);
  413. authkey = authkey.substr(0, LEN_AUTHKEY);
  414. }
  415. bool datavalue()
  416. {
  417. if (authcode.empty() || authkey.empty() || account.length() < 6 || begintime <= 0 || endtime <= 0 || endtime < begintime)
  418. {
  419. return false;
  420. }
  421. return true;
  422. }
  423. };
  424. struct updateingot
  425. {
  426. std::string authcode;
  427. std::string authkey;
  428. std::string account; //玩家账号
  429. std::int64_t score; //添加奖励码个数,负数表明vip赠送出去
  430. public:
  431. std::string getfieldvalue(std::int32_t index)
  432. {
  433. const char* value[] = { "authcode", "authkey", "account", "score" };
  434. return value[index];
  435. }
  436. void getdata()
  437. {
  438. authcode = authcode.substr(0, LEN_AUTHCODE);
  439. authkey = authkey.substr(0, LEN_AUTHKEY);
  440. account = account.substr(0, LEN_ACCOUNTS);
  441. }
  442. bool datavalue()
  443. {
  444. if (authcode.empty() || authkey.empty() || account.length() < 6)
  445. {
  446. return false;
  447. }
  448. return true;
  449. }
  450. };
  451. struct backingot
  452. {
  453. std::string authcode{};
  454. std::string authkey{};
  455. std::string account{}; //玩家账号
  456. std::int64_t score{0}; //回退奖励码个数,负数表明vip赠送出去
  457. public:
  458. std::string getfieldvalue(std::int32_t index)
  459. {
  460. const char* value[] = { "authcode", "authkey", "account", "score" };
  461. return value[index];
  462. }
  463. void getdata()
  464. {
  465. authcode = authcode.substr(0, LEN_AUTHCODE);
  466. authkey = authkey.substr(0, LEN_AUTHKEY);
  467. account = account.substr(0, LEN_ACCOUNTS);
  468. }
  469. bool datavalue()
  470. {
  471. if (authcode.empty() || authkey.empty() || account.length() < 6)
  472. {
  473. return false;
  474. }
  475. return true;
  476. }
  477. };
  478. struct activemsg
  479. {
  480. __int64 activecode; //激活码
  481. char activekey[LEN_AUTHKEY];
  482. };
  483. //game msg data
  484. struct CMD_CS_C_RegisterWeb
  485. {
  486. TCHAR szServerAddr[32]; //服务地址
  487. };
  488. struct CMD_CS_C_UpdateScoreEx
  489. {
  490. DWORD dwUserID; //用户标识
  491. LONGLONG addscore;
  492. WORD wgameserverid;
  493. DWORD dwGameContextID;
  494. DWORD dwLoginContextID;
  495. };
  496. struct adminlogin
  497. {
  498. char authcode[LEN_AUTHCODE];
  499. char authkey[LEN_AUTHKEY];
  500. char account[LEN_ACCOUNTS]; //玩家账号
  501. char pwd[LEN_PASSWORD]; //玩家密码
  502. char pwd2[LEN_PASSWORD]; //商家二级密码
  503. char ip[LEN_IP]; //登录IP地址
  504. };
  505. struct userinfo
  506. {
  507. std::string authcode{};
  508. std::string authkey{};
  509. std::string account{}; //玩家账号
  510. std::string pwd{}; //玩家密码
  511. public:
  512. std::string getfieldvalue(std::int32_t index)
  513. {
  514. const char* value[] = { "authcode", "authkey", "account", "pwdnew" };
  515. return value[index];
  516. }
  517. void getdata()
  518. {
  519. authcode = authcode.substr(0, LEN_AUTHCODE);
  520. authkey = authkey.substr(0, LEN_AUTHKEY);
  521. account = account.substr(0, LEN_ACCOUNTS);
  522. pwd = pwd.substr(0, LEN_PASSWORD);
  523. }
  524. bool datavalue()
  525. {
  526. if (authcode.empty() || authkey.empty() || account.empty() || pwd.length() < 6)
  527. {
  528. return false;
  529. }
  530. return true;
  531. }
  532. };
  533. struct allplayscoreinfo
  534. {
  535. std::string authcode{};
  536. std::string authkey{};
  537. std::int32_t ipagenum{0};
  538. std::int64_t begintime{0};
  539. std::int64_t endtime{0};
  540. public:
  541. std::string getfieldvalue(std::int32_t index)
  542. {
  543. const char* value[] = { "authcode", "authkey", "pagenum", "begintime", "endtime" };
  544. return value[index];
  545. }
  546. void getdata()
  547. {
  548. authcode = authcode.substr(0, LEN_AUTHCODE);
  549. authkey = authkey.substr(0, LEN_AUTHKEY);
  550. }
  551. bool datavalue()
  552. {
  553. if (authcode.empty() || authkey.empty() || ipagenum < 0 || begintime <= 0 || endtime <= 0 || endtime < begintime)
  554. {
  555. return false;
  556. }
  557. return true;
  558. }
  559. };
  560. struct gameuserlog
  561. {
  562. __int64 dbquestid;
  563. std::string account;
  564. std::string servername;
  565. __int32 serverid;
  566. std::string betscore;
  567. std::string winscore;
  568. std::string userscore;
  569. std::string gamelog;
  570. __int64 inserttime;
  571. };
  572. struct taggameuserlog {
  573. __int32 ret;
  574. std::string info;
  575. __int64 allrecordnum;
  576. __int64 recordnum;
  577. __int64 curpagenum;
  578. __int64 allpagenum;
  579. std::vector<gameuserlog> userlog{};
  580. };
  581. //踢出玩家
  582. struct CMD_CS_C_DelOnlineUser
  583. {
  584. DWORD dwUserID;
  585. WORD wserverid;
  586. DWORD dwGameContextID;
  587. };
  588. struct reelplayuser
  589. {
  590. std::string struseracc{}; //玩家
  591. std::string strcert{}; //玩家密钥
  592. __int32 ikindid=0;
  593. public:
  594. std::string getfieldvalue(std::int32_t index)
  595. {
  596. const char* value[] = { "useracc", "cert", "kindid"};
  597. return value[index];
  598. }
  599. void getdata()
  600. {
  601. }
  602. bool datavalue()
  603. {
  604. if (strcert.empty() || struseracc.empty() || 0== ikindid)
  605. {
  606. return false;
  607. }
  608. return true;
  609. }
  610. };
  611. enum ERedeemCodeType
  612. {
  613. ERCT_ONLY = 1, // 唯一码
  614. ERCT_SHRE = 2, // 共享码
  615. ERCT_MAX,
  616. };
  617. struct sRedeemCodeGenerate
  618. {
  619. std::string authcode{};
  620. std::string authkey{};
  621. std::string info = ""; // lable
  622. __int32 iquantity = 0; // 生成数量
  623. __int32 icodetype = 1; // ERedeemCodeType
  624. __int32 iexchangelimit = 1; // 兑换次数
  625. __int32 iaccountlimit = 1; // 账号兑换次数
  626. __int64 iscore = 0;
  627. __int64 istarttime = 0;
  628. __int64 iendtime = 0;
  629. public:
  630. std::string getfieldvalue(std::int32_t index)
  631. {
  632. const char* value[] = { "authcode", "authkey", "info", "quantity", "type","exchangelimit", "accountlimit", "score", "st", "et" };
  633. return value[index];
  634. }
  635. bool datavalue()
  636. {
  637. if (info.empty() || authcode.empty() || authkey.empty() || (icodetype == 2 && iexchangelimit < 2) || istarttime > iendtime || iscore < 1 || iaccountlimit < 1 || iquantity < 1)
  638. {
  639. return false;
  640. }
  641. return true;
  642. }
  643. void getdata()
  644. {
  645. }
  646. };
  647. #pragma pack()