Tg_distributionAction.class.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Fanwe 方维直播系统
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: 云淡风轻(1956838968@qq.com)
  8. // +----------------------------------------------------------------------
  9. class Tg_distributionAction extends AuthAction
  10. {
  11. //首页
  12. public function index()
  13. {
  14. if (trim($_REQUEST['nick_name']) != '') {
  15. $where = " and u.nick_name like '%" . trim($_REQUEST['nick_name']) . "%'";
  16. }
  17. if (trim($_REQUEST['mobile']) != '') {
  18. $where .= "and u.mobile like '%" . trim($_REQUEST['mobile']) . "%'";
  19. }
  20. if (intval($_REQUEST['id']) != '') {
  21. $where .= "and u.id =" . intval($_REQUEST['id']) . "";
  22. }
  23. // $sql = "select u1.id,u1.nick_name,u1.mobile,sum(u3.first_distreibution_money+u3.second_distreibution_money) as num from ".DB_PREFIX."user as u1,".DB_PREFIX."game_distribution as u3 where u1.id=u3.user_id $where GROUP BY u1.game_distribution_top_id";
  24. $pre = DB_PREFIX;
  25. $sql = "SELECT
  26. u.id,
  27. u.nick_name,
  28. u.mobile,
  29. ifnull(a.num, 0) AS num,
  30. b.count
  31. FROM
  32. {$pre}user AS u
  33. LEFT JOIN (
  34. SELECT
  35. a1.id,
  36. SUM(
  37. a2.first_distreibution_money + a2.second_distreibution_money
  38. ) AS num
  39. FROM
  40. {$pre}user AS a1,
  41. {$pre}game_distribution AS a2
  42. WHERE
  43. a1.id = a2.user_id
  44. {$where}
  45. GROUP BY
  46. a1.game_distribution_top_id
  47. ) AS a ON a.id = u.id
  48. LEFT JOIN (
  49. SELECT
  50. a1.game_distribution_top_id id,
  51. count(1) count
  52. FROM
  53. {$pre}user AS a1
  54. GROUP BY
  55. a1.game_distribution_top_id
  56. ) AS b ON b.id = u.id
  57. WHERE
  58. u.id = u.game_distribution_top_id";
  59. $model = M('user');
  60. $user_list = $model->query($sql);
  61. $this->assign('user_list', $user_list);
  62. $this->display();
  63. }
  64. //游戏分销
  65. public function yx_distribution()
  66. {
  67. $root = $this->getRoot();
  68. $this->assign('sum_money', intval($root['sum_money']));
  69. $this->assign('sum_distribution', intval($root['sum_distribution']));
  70. $this->display();
  71. }
  72. //游戏消费
  73. public function yx_consumption()
  74. {
  75. $root = $this->getRoot();
  76. $this->assign('sum_bet', intval($root['sum_bet']));
  77. $this->assign('sum_gain', intval($root['sum_gain']));
  78. $this->display();
  79. }
  80. //礼物分销
  81. public function lw_distribution()
  82. {
  83. $root = $this->getRoot();
  84. $this->assign('sum_money', intval($root['sum_money']));
  85. $this->assign('sum_distribution', intval($root['sum_distribution']));
  86. $this->display();
  87. }
  88. //礼物消费
  89. public function lw_consumption()
  90. {
  91. $this->assign('total_diamonds', intval($root['total_diamonds']));
  92. $this->display();
  93. }
  94. public function getRoot()
  95. {
  96. $root = $this->getRoot();
  97. $id = $_REQUEST['id'];
  98. fanwe_require(APP_ROOT_PATH . 'mapi/lib/core/NewModel.class.php');
  99. NewModel::$lib = APP_ROOT_PATH . 'mapi/lib/';
  100. $type = intval($_REQUEST['type']); //0游戏分销,1礼物分销,2游戏消费,3礼物消费
  101. $year = intval($_REQUEST['year']);
  102. $month = intval($_REQUEST['month']);
  103. $user_id = intval($_REQUEST['user_id']);
  104. $game_log_id = intval($_REQUEST['game_log_id']);
  105. if (!isset($_REQUEST['is_group'])) {
  106. $_REQUEST['is_group'] = 1;
  107. }
  108. $where = [];
  109. $y = date('Y');
  110. $m = date('m');
  111. if (!($year && $month)) {
  112. $year = $y;
  113. $month = $m;
  114. }
  115. $start = strtotime("{$year}-{$month}-1 00:00:00");
  116. $end = strtotime('+1 month', $start);
  117. $where['l.create_time'] = ['between', [$start, $end]];
  118. if ($user_id) {
  119. $where['d.id'] = $user_id;
  120. }
  121. if ($game_log_id) {
  122. $where['l.game_log_id'] = $game_log_id;
  123. }
  124. $d = NewModel::build('user')->field('game_distribution_top_id topid')->selectOne(['id' => $id]);
  125. if ($d['topid']) {
  126. $model = NewModel::build('game_distribution');
  127. switch ($type) {
  128. case 1:
  129. $root = $model->childPropDistribution($id, $where, intval($_REQUEST['is_group']));
  130. break;
  131. case 2:
  132. $root = $model->childGame($id, $where, intval($_REQUEST['is_group']));
  133. break;
  134. case 3:
  135. unset($where['l.create_time']);
  136. unset($where['l.game_log_id']);
  137. $root = $model->childProp($id, $where, $start, intval($_REQUEST['is_group']));
  138. break;
  139. default:
  140. $root = $model->childGameDistribution($id, $where, intval($_REQUEST['is_group']));
  141. break;
  142. }
  143. }
  144. $root['type'] = $type;
  145. $root['page_title'] = "个人中心-游戏分销";
  146. $root['year'] = $year;
  147. $root['month'] = $month;
  148. $root['user_id'] = $user_id;
  149. $root['game_log_id'] = $game_log_id;
  150. $root['years'] = range($y, $y - 5);
  151. $root['months'] = range(1, 12);
  152. $root['act'] = 'game_distribution';
  153. $this->assign("is_group", $_REQUEST['is_group']);
  154. $this->assign("year", $root['year']);
  155. $this->assign("month", $root['month']);
  156. $this->assign("years", $root['years']);
  157. $this->assign("months", $root['months']);
  158. $this->assign('list', $root['list']);
  159. $this->assign('sum_first', intval($root['sum_first']));
  160. $this->assign('sum_second', intval($root['sum_second']));
  161. $this->assign('sum_child', intval($root['sum_child']));
  162. }
  163. }