Wx_distributionAction.class.php 6.3 KB

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