DataFix.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <?php
  2. /**
  3. * DataFix.php UTF-8
  4. * 数据修复
  5. *
  6. * @date : 2018/10/29 15:20
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : wuyonghong <wyh@huosdk.com>
  10. * @version : HuoMp 1.0
  11. */
  12. namespace console\index\controller;
  13. use huo\controller\member\MemCache;
  14. use huo\controller\request\Channel;
  15. use huo\controller\request\Device;
  16. use huo\controller\request\Game;
  17. use huo\controller\request\Mem;
  18. use huo\model\log\MemLoginLogModel;
  19. use huo\model\member\MemberModel;
  20. use huo\model\order\OrderModel;
  21. use think\console\Command;
  22. use think\console\Input;
  23. use think\console\Output;
  24. class DataFix extends Command {
  25. protected $rq_data = [];
  26. protected $g_i;
  27. protected function configure() {
  28. $this->setName('datafix')->setDescription('数据生成');
  29. }
  30. public function index() {
  31. // $this->create();
  32. // $this->login();
  33. // $this->charge();
  34. echo 'test';
  35. exit;
  36. }
  37. /**
  38. * /www/wdlinux/php/bin/php /mini/think datafix
  39. *
  40. * @param Input $input
  41. * @param Output $output
  42. *
  43. * @return int|null|void
  44. */
  45. protected function execute(Input $input, Output $output) {
  46. $this->create();
  47. $this->login();
  48. }
  49. /**
  50. * 添加游戏
  51. */
  52. public function addGame() {
  53. }
  54. /**
  55. * 创建账号
  56. *
  57. */
  58. public function create() {
  59. // $_map['create_time'] = ['between', ['1527782400', '2527782400']];
  60. $_map = [];
  61. $_data = (new MemberModel())->with('ext')->where($_map)->field(
  62. 'id,username,app_id,create_time,status,update_time'
  63. )->select();
  64. $_cnt = 0;
  65. foreach ($_data as $_k => $_v) {
  66. $_v = $_v->toArray();
  67. /* 登陆授权队列 */
  68. $_device_rq = new \huo\controller\request\Device();
  69. $_game_rq = new \huo\controller\request\Game();
  70. $_channel_rq = new \huo\controller\request\Channel();
  71. $_mem_rq = new \huo\controller\request\Mem();
  72. $_device_rq->setIp($_v['reg_ip']);
  73. $_channel_rq->setCh($_v['agent_id']);
  74. $_mem_rq->setMemId($_v['id']);
  75. $_mem_rq->setRegTime($_v['create_time']);
  76. $_mem_rq->setLoginTime($_v['create_time']);
  77. $_mem_rq->setStatus($_v['status']);
  78. (new \huo\controller\queue\Mem($_v['app_id']))->create(
  79. $_device_rq, $_game_rq, $_channel_rq, $_mem_rq
  80. );
  81. $_cnt++;
  82. }
  83. $this->g_i += $_cnt;
  84. print_r($_cnt.' create ok'.PHP_EOL);
  85. }
  86. /**
  87. * 玩家登陆
  88. */
  89. public function login() {
  90. $_cnt = 0;
  91. for ($_i = 0; $_i <= 0; $_i++) {
  92. $_date = '2018-1'.$_i;
  93. $_data = (new MemLoginLogModel())->computeTable($_date)->where('mem_id>0')->select();
  94. foreach ($_data as $_k => $_v) {
  95. $_v = $_v->toArray();
  96. $_mem_data = MemCache::ins()->getInfoById($_v['mem_id']);
  97. /* 登陆队列 */
  98. $_device_rq = new \huo\controller\request\Device();
  99. $_game_rq = new \huo\controller\request\Game();
  100. $_channel_rq = new \huo\controller\request\Channel();
  101. $_mem_rq = new \huo\controller\request\Mem();
  102. $_device_rq->setIp($_v['ip']);
  103. $_channel_rq->setCh($_v['agent_id']);
  104. $_mem_rq->setMemId($_v['mem_id']);
  105. $_mem_rq->setRegTime($_v['reg_time']);
  106. $_status = $_mem_data['status'];
  107. $_mem_rq->setStatus($_status);
  108. $_mem_rq->setLoginTime($_v['create_time']);
  109. (new \huo\controller\queue\Mem($_v['app_id']))->online(
  110. $_device_rq, $_game_rq, $_channel_rq, $_mem_rq
  111. );
  112. $_cnt++;
  113. }
  114. }
  115. $this->g_i += $_cnt;
  116. print_r($_cnt.' login ok'.PHP_EOL);
  117. }
  118. /**
  119. * 玩家充值
  120. */
  121. public function charge() {
  122. $_map['status'] = 2;
  123. $_order_ids = (new OrderModel())->where($_map)->limit(0, 100000)->order('id asc')->column('order_id');
  124. foreach ($_order_ids as $_k => $order_id) {
  125. print_r($order_id.' ');
  126. (new \huo\controller\queue\Order())->fromSdkOrder($order_id);
  127. }
  128. $this->g_i += count($_order_ids);
  129. $_map['order_id'] = ['in', $_order_ids];
  130. print_r((new OrderModel())->where($_map)->order('id asc')->sum('amount'));
  131. print_r(PHP_EOL.'g_i='.$this->g_i);
  132. }
  133. /**
  134. * @return Device
  135. */
  136. public function setDeviceData() {
  137. $_device = new Device();
  138. return $_device;
  139. }
  140. /**
  141. * @return Game
  142. */
  143. public function setGameData() {
  144. $_game = new Game();
  145. return $_game;
  146. }
  147. /**
  148. * @return Channel
  149. *
  150. */
  151. public function setChannelData() {
  152. $_channel = new Channel();
  153. return $_channel;
  154. }
  155. /**
  156. * 设置玩家入参
  157. *
  158. * @param bool $is_reg
  159. *
  160. * @return Mem
  161. */
  162. public function setMemData($is_reg = false) {
  163. $_mem = new Mem();
  164. return $_mem;
  165. }
  166. }