diff --git a/Application/Admin/Controller/PlatformController.class.php b/Application/Admin/Controller/PlatformController.class.php index 9333d2a96..abaea3399 100644 --- a/Application/Admin/Controller/PlatformController.class.php +++ b/Application/Admin/Controller/PlatformController.class.php @@ -417,7 +417,131 @@ class PlatformController extends ThinkController $this->assign('total', $total); $this->display(); } + //TODO: function promotepay_statistics($p = 0) + { + $page = intval($p); + $page = $page ? $page : 1; //默认显示第一页数据 + $arraypage = $page; + if (isset($_REQUEST['row'])) { + $row = $_REQUEST['row']; + } else { + $row = 10; + } + $map1['promote_id'] = $map['promote_id'] = array('egt', 0); + $spend = M('Spend', 'tab_'); + if (!empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { + $map['create_time'] = ['between', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399)]; + $pay_time = " between " . strtotime($_REQUEST['timestart']) . " and " . (strtotime($_REQUEST['timeend']) + 86399) . " "; + unset($_REQUEST['timestart']); + unset($_REQUEST['timeend']); + } elseif (!empty($_REQUEST['timestart']) && empty($_REQUEST['timeend'])) { + $map['create_time'] = ['between', array(strtotime($_REQUEST['timestart']), time())]; + $pay_time = " between " . strtotime($_REQUEST['timestart']) . " and " . time() . " "; + unset($_REQUEST['timestart']); + } elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { + $map['create_time'] = ['elt', strtotime($_REQUEST['timeend']) + 86399]; + $pay_time = " between 0 and " . (strtotime($_REQUEST['timeend']) + 86399) . " "; + unset($_REQUEST['timeend']); + } else { + $pay_time = " between 0 and " . time(); + } + $map1['pay_status'] = $map['pay_status'] = 1; + $today = total(1); + $week = total(2); + $mounth = total(3); + unset( $map['create_time']); + + //获取所有会长 + $promote_map = "`chain` = '/'"; + if (isset($_REQUEST['promote_id'])) { + $promote_map = "`chain` = '%/{$_REQUEST['promote_id']}/%' OR id = {$_REQUEST['promote_id']}"; + } + + $promote = M("promote","tab_")->field("id,account")->page($page,$row)->where($promote_map)->select(); + $pcount = M("promote","tab_")->field("count(*) acount")->where($promote_map)->find()['acount']; + + // var_dump( $promote); + $data =array(); + for ($i=0; $i < count($promote); $i++) { + # code... + $proid = M("promote","tab_")->field("id")->where("`chain` like '%/{$promote[$i]['id']}/%'")->select(); + $str = ''; + for($k=0; $kfield(' + floor(sum(IF(pay_time ' . $pay_time . ',pay_amount,0))*100) as count, + floor(sum(IF(pay_time ' . $today . ',pay_amount,0))*100) as today, + floor(sum(IF(pay_time ' . $week . ',pay_amount,0))*100) as week, + floor(sum(IF(pay_time ' . $mounth . ',pay_amount,0))*100) as mounth') + ->where($map) + ->where("pay_time".$pay_time) + ->find(); + $dbdata['promote_account'] = $promote[$i]['account']; + } else { + $dbdata = $spend + ->field(' + floor(sum(IF(pay_time ' . $pay_time . ',pay_amount,0))*100) as count, + floor(sum(IF(pay_time ' . $today . ',pay_amount,0))*100) as today, + floor(sum(IF(pay_time ' . $week . ',pay_amount,0))*100) as week, + floor(sum(IF(pay_time ' . $mounth . ',pay_amount,0))*100) as mounth') + ->where($map) + ->where("pay_time".$pay_time) + ->find(); + $dbdata['promote_account'] = $promote[$i]['account']; + } + $data[] = $dbdata; + } + $count = count($data); + foreach ($data as $key => $value) { + $value['count'] ?: 0; + $value['today'] ?: 0; + $value['week'] ?: 0; + $value['mounth'] ?: 0; + static $i = 0; + $i++; + $data[$key]['rand'] = $i; + $data[$key]['count'] = $value['count'] / 100; + $data[$key]['today'] = $value['today'] / 100; + $data[$key]['week'] = $value['week'] / 100; + $data[$key]['mounth'] = $value['mounth'] / 100; + } + + $total = $this->data_total($data); + $this->assign('total', $total); + if ($_REQUEST['data_order'] != '') { + $data_order = reset(explode(',', $_REQUEST['data_order'])); + $data_order_type = end(explode(',', $_REQUEST['data_order'])); + $this->assign('userarpu_order', $data_order); + $this->assign('userarpu_order_type', $data_order_type); + } + + $page = set_pagination($pcount, $row); + if ($page) { + $this->assign('_page', $page); + } + + $data = my_sort($data, $data_order_type, (int)$data_order); + + $size = $row;//每页显示的记录数 + $pnum = ceil(count($data) / $size); //总页数,ceil()函数用于求大于数字的最小整数 + $this->meta_title = '渠道充值统计列表'; + $this->assign('list_data', $data); + $this->display(); + + } + function promotepay_statistics_1($p = 0) { $page = intval($p); $page = $page ? $page : 1; //默认显示第一页数据 @@ -504,10 +628,9 @@ class PlatformController extends ThinkController unset($_REQUEST['promote_id']); } $data = $spend->field('t.pid as promote_id,t.promote_account,sum(a.scount) AS count,sum(a.today) AS today,sum(a. WEEK) AS WEEK,sum(a.mounth) AS mounth') - ->join("INNER JOIN (SELECT tp2.*, tp1.id AS pid, tp1.account as promote_account FROM tab_promote tp1 LEFT JOIN tab_promote tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp1.id = tp2.id where $promote_map ) AS t ON promote_id = t.id or promote_id = t.pid") + ->join("inner JOIN (SELECT tp2.*, tp1.id AS pid, tp1.account as promote_account FROM tab_promote tp1 LEFT JOIN tab_promote tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') where $promote_map ) AS t ON promote_id = t.id or promote_id = t.pid") ->where($condition)->table('(' . $data . ') as a')->group('t.pid')->order('count desc,a.ordertime')->select(); $count = count($data); - foreach ($data as $key => $value) { static $i = 0; $i++; diff --git a/Application/Admin/Controller/SpendController.class.php b/Application/Admin/Controller/SpendController.class.php index 945cc790f..ade87c965 100644 --- a/Application/Admin/Controller/SpendController.class.php +++ b/Application/Admin/Controller/SpendController.class.php @@ -100,6 +100,7 @@ class SpendController extends ThinkController $map = '1 = 2'; $map1 = $map; } + echo (D(self::model_name)->where($map1)->fetchSql(true)->sum('pay_amount')); $total = null_to_0(D(self::model_name)->where($map1)->sum('pay_amount')); $ttotal = null_to_0(D(self::model_name)->where('pay_time' . total(1))->where(array('pay_status' => 1))->sum('pay_amount')); $ytotal = null_to_0(D(self::model_name)->where('pay_time' . total(5))->where(array('pay_status' => 1))->sum('pay_amount')); diff --git a/Application/Admin/View/Platform/promotepay_statistics.html b/Application/Admin/View/Platform/promotepay_statistics.html index 44b9b0151..97b07c39c 100644 --- a/Application/Admin/View/Platform/promotepay_statistics.html +++ b/Application/Admin/View/Platform/promotepay_statistics.html @@ -96,7 +96,7 @@ 累计充值 - 排行榜 + 今日充值 @@ -121,7 +121,7 @@ {$data['promote_account']} {$data.count} - {$data.rand}{$data.rand}{$data.rand}{$data.rand} + {$data.today} {$data.week} {$data.mounth} @@ -131,7 +131,7 @@ 汇总 {$total.sum_count} - --- + {$total.sum_today} {$total.sum_week} {$total.sum_mounth}