diff --git a/Application/Home/Controller/PromoteController.class.php b/Application/Home/Controller/PromoteController.class.php index 037cb7b5f..10c8c8194 100644 --- a/Application/Home/Controller/PromoteController.class.php +++ b/Application/Home/Controller/PromoteController.class.php @@ -100,24 +100,48 @@ class PromoteController extends BaseController $page = $this->ajax_page($count, 20, 'seach'); $this->assign("_page", $page); - $user_count = M("user", "tab_")->where("promote_id=" . get_pid())->count(); - $total_money = $this->pay_total(0, 0); - $today_add_user_money = $this->pay_total(1); - $month_add_user_money = $this->pay_total(3); + + $promote = M("promote","tab_")->field("parent_id,grand_id")->where("id=".get_pid())->find(); + $promoteId = array(get_pid()); + + if ($promote['parent_id'] == 1) { + $promoteId = M("promote", "tab_")->field('id')->where("parent_id=" . get_pid()." or grand_id=". get_pid())->select(); + $promoteId = array_column($promoteId,'id'); + array_push($promoteId,get_pid()); + } elseif ($promote['parent_id'] > 0 && $promote['grand_id'] == 0) { + $promoteId = M("promote", "tab_")->field('id')->where("parent_id=" . get_pid())->select(); + $promoteId = array_column($promoteId,'id'); + array_push($promoteId,get_pid()); + } + $promoteId = implode(',',$promoteId); + if ($promoteId) { + $user_count = M("user", "tab_")->where("promote_id IN({$promoteId})")->count(); + } else { + $user_count = 0; + } + + + $total_money = $this->pay_total(0, 0,$promoteId); + $today_add_user_money = $this->pay_total(1,1,$promoteId); + $month_add_user_money = $this->pay_total(3,1,$promoteId); $yesterday_start = mktime(0, 0, 0, date('m'), date('d') - 1, date('Y')); $yesterday_end = mktime(0, 0, 0, date('m'), date('d'), date('Y')); $yesterday_user_regist_count = M("user", "tab_")->where( - array("promote_id" => get_pid(), + array("promote_id" => array('in',$promoteId), "register_time" => array("BETWEEN", array($yesterday_start, $yesterday_end)))) ->count(); - $yesterday_total_money = $this->pay_total(5, 0); - $yesterday_regist_user_count = M("user", "tab_") - ->where(array("promote_id" => get_pid(), - "register_time" => array("BETWEEN", array($yesterday_start, $yesterday_end)))) + + $yesterday_total_money = $this->pay_total(5, 0,$promoteId); + + $today_start = mktime(0, 0, 0, date('m'), date('d'), date('Y')); + $today_end = mktime(0, 0, 0, date('m'), date('d') + 1, date('Y')) - 1; + $today_regist_user_count = M("user", "tab_") + ->where(array("promote_id" => array('in',$promoteId), + "register_time" => array("BETWEEN", array($today_start, $today_end)))) ->count(); + $today_total_money = $this->pay_total(1, 0,$promoteId); - $yesterday_total_money = $this->pay_total(1, 0); $this->assign("user_count", $user_count); $this->assign("total_money", $total_money); $this->assign("today_add_user_money", $today_add_user_money); @@ -126,6 +150,8 @@ class PromoteController extends BaseController $this->assign("yesterday_total_money", $yesterday_total_money); $this->assign("yesterday_regist_user_count", $yesterday_regist_user_count); $this->assign("yesterday_total_money", $yesterday_total_money); + $this->assign("today_regist_user_count", $today_regist_user_count); + $this->assign("today_total_money", $today_total_money); $this->assign("menu_list", $quick_menu_list); $this->assign("gg_list", $gg_list); @@ -141,7 +167,7 @@ class PromoteController extends BaseController $this->display(); } - private function pay_total($type = 0, $newadd = 1) + private function pay_total($type = 0, $newadd = 1,$promoteId="") { if ($_REQUEST['promote_id'] === null || $_REQUEST['promote_id'] === '0') { $map['parent_id'] = get_pid(); @@ -155,7 +181,7 @@ class PromoteController extends BaseController } else { $ids = array($_REQUEST['promote_id']); } - $where['spend.promote_id'] = array('in', $ids); + $where['spend.promote_id'] = array('in', $promoteId); $where['spend.pay_status'] = 1; $where['spend.is_check'] = array('NEQ', 2); switch ($type) { @@ -206,6 +232,7 @@ class PromoteController extends BaseController $where['user.register_time'] = array("BETWEEN", array($start, $end)); } } + if ($newadd == 1) { $total = M('spend as spend', "tab_")->field("SUM(spend.pay_amount) as amount")->join("right join tab_user user on user.id=spend.user_id")->where($where)->select(); } else { diff --git a/Application/Home/View/default/Promote/index.html b/Application/Home/View/default/Promote/index.html index 4e2065a3c..1fa99f383 100644 --- a/Application/Home/View/default/Promote/index.html +++ b/Application/Home/View/default/Promote/index.html @@ -13,8 +13,8 @@