Index.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php
  2. namespace console\index\controller;
  3. use huo\controller\request\Channel;
  4. use huo\controller\request\Device;
  5. use huo\controller\request\Game;
  6. use huo\controller\request\Mem;
  7. use huo\model\log\MemLoginLogModel;
  8. use huo\model\member\MemberModel;
  9. use huo\model\order\OrderModel;
  10. use think\Controller;
  11. class Index extends Controller {
  12. protected $rq_data = [];
  13. protected $g_i;
  14. public function index() {
  15. // $this->create();
  16. // $this->login();
  17. // $this->charge();
  18. echo 'test';
  19. exit;
  20. }
  21. /**
  22. * 添加游戏
  23. */
  24. public function addGame() {
  25. }
  26. /**
  27. * 创建账号
  28. *
  29. * @throws \think\db\exception\DataNotFoundException
  30. * @throws \think\db\exception\ModelNotFoundException
  31. * @throws \think\exception\DbException
  32. */
  33. public function create() {
  34. $_map['create_time'] = ['between', ['1527782400', '2527782400']];
  35. $_map = [];
  36. $_data = (new MemberModel())->with('ext')->where($_map)->field('id,username,app_id,create_time,update_time')
  37. ->select();
  38. $_cnt = 0;
  39. foreach ($_data as $_k => $_v) {
  40. $_v = $_v->toArray();
  41. print_r($_v['id'].' ');
  42. // print_r('<br>');
  43. $_game_rq = $this->setGameData();
  44. $_channel_rq = $this->setChannelData();
  45. $_device_rq = $this->setDeviceData();
  46. $_mem_rq = $this->setMemData();
  47. $_mem_rq->setMemId($_v['id']);
  48. /* 异步处理数据 */
  49. $_mem_rq->setRegTime($_v['create_time']);
  50. $_mem_rq->setLoginTime($_v['ext']['last_login_time']);
  51. $_channel_rq->setCh($_v['agent_id']);
  52. $_game_rq->setHAppId($_v['app_id']);
  53. (new \huo\controller\queue\Mem($_game_rq->getHAppId()))->create(
  54. $_device_rq, $_game_rq, $_channel_rq, $_mem_rq
  55. );
  56. $_cnt++;
  57. }
  58. $this->g_i += $_cnt;
  59. print_r('create ok'.PHP_EOL.$_cnt);
  60. }
  61. /**
  62. * 玩家登陆
  63. *
  64. * @throws \think\db\exception\DataNotFoundException
  65. * @throws \think\db\exception\ModelNotFoundException
  66. * @throws \think\exception\DbException
  67. */
  68. public function login() {
  69. $_cnt = 0;
  70. for ($_i = 5; $_i < 7; $_i++) {
  71. $_date = '2018-0'.$_i;
  72. $_data = (new MemLoginLogModel())->computeTable($_date)->where('mem_id>0')->select();
  73. foreach ($_data as $_k => $_v) {
  74. $_v = $_v->toArray();
  75. print_r($_v['id'].' ');
  76. $_game_rq = $this->setGameData();
  77. $_channel_rq = $this->setChannelData();
  78. $_device_rq = $this->setDeviceData();
  79. $_mem_rq = $this->setMemData();
  80. /* 异步处理数据 */
  81. $_mem_rq->setMemId($_v['mem_id']);
  82. $_mem_rq->setMgMemId($_v['mg_mem_id']);
  83. $_mem_rq->setRegTime($_v['reg_time']);
  84. $_mem_rq->setLoginTime($_v['create_time']);
  85. $_channel_rq->setCh($_v['agent_id']);
  86. $_game_rq->setHAppId($_v['app_id']);
  87. (new \huo\controller\queue\Mem($_game_rq->getHAppId()))->online(
  88. $_device_rq, $_game_rq, $_channel_rq, $_mem_rq
  89. );
  90. $_cnt++;
  91. }
  92. }
  93. $this->g_i += $_cnt;
  94. print_r('login ok'.PHP_EOL.$_cnt);
  95. }
  96. /**
  97. * 玩家充值
  98. */
  99. public function charge() {
  100. $_map['status'] = 2;
  101. $_order_ids = (new OrderModel())->where($_map)->limit(0, 100000)->order('id asc')->column('order_id');
  102. foreach ($_order_ids as $_k => $order_id) {
  103. print_r($order_id.' ');
  104. (new \huo\controller\queue\Order())->fromSdkOrder($order_id);
  105. }
  106. $this->g_i += count($_order_ids);
  107. $_map['order_id'] = ['in', $_order_ids];
  108. print_r((new OrderModel())->where($_map)->order('id asc')->sum('amount'));
  109. print_r(PHP_EOL.'g_i='.$this->g_i);
  110. }
  111. /**
  112. * @return Device
  113. */
  114. public function setDeviceData() {
  115. $_device = new Device();
  116. return $_device;
  117. }
  118. /**
  119. * @return Game
  120. */
  121. public function setGameData() {
  122. $_game = new Game();
  123. return $_game;
  124. }
  125. /**
  126. * @return Channel
  127. *
  128. */
  129. public function setChannelData() {
  130. $_channel = new Channel();
  131. return $_channel;
  132. }
  133. /**
  134. * 设置玩家入参
  135. *
  136. * @param bool $is_reg
  137. *
  138. * @return Mem
  139. */
  140. public function setMemData($is_reg = false) {
  141. $_mem = new Mem();
  142. return $_mem;
  143. }
  144. }