public function queryAction() { $model = new \Think\Model(); $brand_id = get_brand_id(); $time = date('Y-m'); $user_id = is_user_login(); $time = I("time"); if (empty($time)) { $start_month = I("start_month"); if (empty($start_month)) { $this->error("请输入月份时间!"); } else { $start_time = $start_month . "-01 00:00:00"; $end_time = $start_month . "-31 23:59:59"; } } else { $start_time = I("start_time"); $end_time = I("end_time"); if (empty($start_time)) { $this->error("请输入开始时间!"); } if (empty($end_time)) { $this->error("请输入终止时间!"); } } $ret = ChannelService::getInstance()->getStatistics($user_id, $start_time, $end_time); $this->ajaxReturn(array("status" => 1, "statistics" => $ret)); }
public function queryAction() { $club_id = get_club_id(); // $username = M("UserExtension")->field("name_cn")->find($user_id); // $this->assign("username",$username); // $model = new \Think\Model() ; $user_id = I("user_id"); // $condition=array("b.brand_id"=>$brand_id,"a.id"=>"b.id","a.id"=>"c.uid"); // $users= $model->where("a.id=b.id and a.id=c.uid and b.brand_id=$brand_id and c.group_id=18")->table(array("yoga_user_extension"=>"a","yoga_user"=>"b","yoga_auth_group_access"=>"c"))->field("a.id,a.name_cn")->select(); // $this->assign("users",$users); if (empty($user_id)) { $time = I("time"); if ($time == 0) { $start_time = I("start_time"); if (empty($start_time)) { $this->error("请输入开始时间!"); } $ret = ChannelService::getInstance()->getOneMonthStatistics($club_id, $start_time); $this->ajaxReturn(array("status" => 1, "statistics" => $ret)); } else { $start_time = I("start_time"); if (empty($start_time)) { $this->error("请输入开始时间!"); } $end_time = I("end_time"); if (empty($end_time)) { $this->error("请输入终止时间!"); } $ret = ChannelService::getInstance()->getMonthStatistics($club_id, $start_time, $end_time); $this->ajaxReturn(array("status" => 1, "statistics" => $ret)); } } else { $time = I("time"); if ($time == 0) { $start_time = I("start_time"); if (empty($start_time)) { $this->error("请输入开始时间!"); } $ret = ChannelService::getInstance()->getUserOneMonthStatistics($user_id, $start_time); $this->ajaxReturn(array("status" => 1, "statistics" => $ret)); } else { $start_time = I("start_time"); if (empty($start_time)) { $this->error("请输入开始时间!"); } $end_time = I("end_time"); if (empty($end_time)) { $this->error("请输入终止时间!"); } $ret = ChannelService::getInstance()->getUserMonthStatistics($user_id, $start_time, $end_time); $this->ajaxReturn(array("status" => 1, "statistics" => $ret)); } } }
public function queryAction() { $model = new \Think\Model(); $brand_id = get_brand_id(); $time = date('Y-m'); // $sql="select b.id, b.name,b.level,count(a.channel_id) as protential,COALESCE(sum(a.is_member),0) as mcount from yoga_channel b left join yoga_member_basic a on b.brand_id=$brand_id and a.channel_id!=0 and a.channel_id=b.id "; $user_id = I("user_id"); if (!empty($user_id)) { // $sql.=" and a.recommend_id=$user_id"; } $time = I("time"); if (empty($time)) { $start_month = I("start_month"); if (empty($start_month)) { $this->error("请输入月份时间!"); } else { $start_time = $start_month . "-01 00:00:00"; $end_time = $start_month . "-31 23:59:59"; // $sql.=" and a.create_time>='{$start_time}' and a.create_time<='{$end_time}'"; } } else { $start_time = I("start_time"); $end_time = I("end_time"); if (empty($start_time)) { $this->error("请输入开始时间!"); } if (empty($end_time)) { $this->error("请输入终止时间!"); } // $sql.=" and a.create_time>='{$start_time}' and a.create_time<='{$end_time}'"; } // $sql .=" group by b.id order by protential desc"; // $ret = $model->query($sql); $ret = ChannelService::getInstance()->getStatistics($user_id, $start_time, $end_time); $this->ajaxReturn(array("status" => 1, "statistics" => $ret)); }
protected function _initialize() { define('UID', is_user_login()); if (!UID) { // 还没登录 跳转到登录页面 $this->redirect('Home/Index/index'); } if (!IS_AJAX) { Cookie('__lastpage__', Cookie('__thispage__')); Cookie('__thispage__', $_SERVER['REQUEST_URI']); } $loginuser = getLoginUser(); $this->user = $loginuser['UserExtension']['name_cn']; $this->assign("useravatar", "/Public/uploads/em_avatar/" . $loginuser['UserExtension']['avatar']); $isMc = D("User")->isMc(UID); $isChannel = D("User")->isChannel(UID); $isReception = D("User")->isReception(UID); if (empty($isReception)) { $isReception = 0; } if ($isMc) { $start_time = date("Y-m"); $st = McService::getInstance()->getUserOneMonthStatistics(UID, $start_time); if (!empty($st)) { $this->mc_protential_persent = ceil($st[0]["protential_value"] * 10000 / $st[0]["protential_plan"]) / 100; $this->mc_transform_persent = ceil($st[0]["transform_value"] * 10000 / $st[0]["transform_plan"]) / 100; $this->mc_protential_value = $st[0]["protential_value"]; $this->mc_protential_plan = $st[0]["protential_plan"]; $this->mc_transform_value = $st[0]["transform_value"]; $this->mc_transform_plan = $st[0]["transform_plan"]; } else { $isMc = 0; } } if ($isChannel) { $start_time = date("Y-m"); $st = ChannelService::getInstance()->getUserOneMonthStatistics(UID, $start_time); if (!empty($st)) { $this->channel_protential_persent = ceil($st[0]["protential_value"] * 10000 / $st[0]["protential_plan"]) / 100; $this->channel_channel_persent = ceil($st[0]["channel_value"] * 10000 / $st[0]["channel_plan"]) / 100; $this->channel_channel_value = $st[0]["channel_value"]; $this->channel_channel_plan = $st[0]["channel_plan"]; $this->channel_protential_value = $st[0]["protential_value"]; $this->channel_protential_plan = $st[0]["protential_plan"]; } else { $isChannel = 0; } } $this->isReception = $isReception; $this->show_plan = $isMc || $isChannel; $this->isMc = $isMc; $this->uid = UID; $this->club_id = get_club_id(); $this->isChannel = $isChannel; $this->checkRole(); //通知 $model = D("Notice"); $brand_id = get_brand_id(); $ret = $model->getLatestNotice($brand_id); $this->notice = nl2br($ret['content']); if (!IS_AJAX) { $this->loadMenus(); } }