Skip to content

Commit

Permalink
version4.0
Browse files Browse the repository at this point in the history
用户评价,管理员,景区管理员登陆,每月人数
  • Loading branch information
Yurisa committed Sep 25, 2017
1 parent 4107ee5 commit a3cdc60
Show file tree
Hide file tree
Showing 69 changed files with 999 additions and 144,329 deletions.
32 changes: 32 additions & 0 deletions Application/Home/Controller/AdminController.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
namespace Home\Controller;

use Home\Controller\CommonController;
use Org\Util\Upload;
use Org\Util\Image;
use Think\Controller;

class AdminController extends CommonController {

public function getadmindata(){
$ad_id = session("admin.id");
if(!empty($ad_id)){
$admin['admin'] = M('admin')->where("ad_id='%s'",array($ad_id))->find();
// var_dump($admin);
$this->json(1,'ok',$admin);
}else{
$this->json(0,'未登录');
}
}

public function getarea_admindata(){
$ad_id = session("area_admin.id");
if(!empty($ad_id)){
$area_admin['area_admin'] = M('area_admin')->where("ad_id='%s'",array($ad_id))->find();
// var_dump($admin);
$this->json(1,'ok',$area_admin);
}else{
$this->json(0,'未登录');
}
}
}
40 changes: 40 additions & 0 deletions Application/Home/Controller/AdminRegController.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
namespace Home\Controller;

use Home\Controller\CommonController;
use Org\Util\String;
use Org\Util\Match;
use Think\Controller;

class AdminRegController extends CommonController{
public function _construct(){

}

public function loginUser(){
$ad_id = I('post.ad_id');
$ad_password = I('post.ad_password');
$admindata = M('admin')->where("ad_id = '%s'",array($ad_id))->find();
if(!empty($admindata)){
if($admindata['ad_password'] == $ad_password){
session("admin.id",$admindata['ad_id']);
session("admin.name",$admindata['ad_name']);
$this->json(1,'ok');
}
$this->json(0,'登录失败,账号或密码错误');
}
}

/**
* 退出登陆
*/

public function loginOut()
{
session('admin', NULL);
$this->json(1,'退出成功');
exit();
}


}
37 changes: 37 additions & 0 deletions Application/Home/Controller/AreaadminRegController.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
namespace Home\Controller;

use Home\Controller\CommonController;
use Org\Util\String;
use Org\Util\Match;
use Think\Controller;

class AreaadminRegController extends CommonController{
public function _construct(){

}
public function loginUser(){
$ad_id = I('post.ad_id');
$ad_password = I('post.ad_password');
$admindata = M('area_admin')->where("ad_id = '%s'",array($ad_id))->find();
if(!empty($admindata)){
if($admindata['ad_password'] == $ad_password){
session("area_admin.id",$admindata['ad_id']);
session("area_admin.name",$admindata['ad_name']);
$this->json(1,'ok',$admindata);
}
$this->json(0,'登录失败,账号或密码错误');
}
}

/**
* 退出登陆
*/

public function loginOut()
{
session('area_admin', NULL);
$this->json(1,'退出成功');
exit();
}
}
75 changes: 75 additions & 0 deletions Application/Home/Controller/MainController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,12 @@ public function gettourrank(){
$res['touristarea'] = $touristarea;
$this->json(1,'ok',$res);
}

/*
*
*获取所有民族
*
*/

public function getallnation(){
$nation = M('nation')->select();
Expand All @@ -1303,5 +1309,74 @@ public function getallnation(){
// print_r($res);
$this->json(1,'ok',$res);
}


/*
*
*获取用户评价
*
*/

public function userevaluate(){
$u_id = session("user.id");
$t_id = I('post.t_id');
$data = array(
"price" => I('post.price'),
"service" => I('post.service'),
"traffic" => I('post.traffic'),
"environment" => I('post.environment'),
);
M('h_go')->where("u_id = %d and t_id = %d",array($u_id,$t_id))->save($data);
$this->json(1,'ok');
}

/*
*
*获取所有景区的各项数据的平均水平
*
*/

public function getalltouravgscore(){
$Model = new \Think\Model();
$data = $Model->query("select avg(score) as score,avg(price) as price,avg(service) as service, avg(environment) as environment,avg(traffic) as traffic from h_go");
// print_r($data);
$data[0]['popularity'] = (string)(($data[0]['score']+$data[0]['price']+$data[0]['service']+$data[0]['environment']+$data[0]['traffic'])/5);
$this->json(1,'ok',$data[0]);
}

/*
*
*获取根据景区ID的各项数据的平均水平
*
*/

public function gettourscorebytid(){
$t_id = $_GET['t_id'];
$Model = new \Think\Model();
$data = $Model->query("select avg(score) as score,avg(price) as price,avg(service) as service, avg(environment) as environment,avg(traffic) as traffic from h_go group by t_id having t_id = '{$t_id}'");
$data[0]['popularity'] =(string)( ($data[0]['score']+$data[0]['price']+$data[0]['service']+$data[0]['environment']+$data[0]['traffic'])/5);
$this->json(1,'ok',$data[0]);
}

/*
*
*获取根据景区ID的每月人数
*
*/

public function geteverymonthpersonnum(){
$Model = new \Think\Model();
$t_id = $_GET['t_id'];
$data = array();
$thismonth = date('m');
for($i = $thismonth ; $i>=1; $i--){
$beginThismonth=mktime(0,0,0,$i,1,date('Y'));
$endThismonth=mktime(23,59,59,$i,date('t'),date('Y'));
$month = "month"+$i;
$arr = $Model->query("select count(*) as personnum from historyperson where starttime > {$beginThismonth} and starttime < {$endThismonth} group by t_id having t_id = '{$t_id}'");
$arr[0]['month'] = intval($i);
array_push($data,$arr[0]);
}
$this->json(1,'ok',$data);
}
}
Loading

0 comments on commit a3cdc60

Please sign in to comment.