|
- <?php
- /**
- * 首页及其他页面数据读取
- * ============================================================================
- * * 版权所有 蜘蛛出行 * *
- * 网站地址: http://www.zhizhuchuxing.com
- * ----------------------------------------------------------------------------
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
- * 使用;不允许对程序代码以任何形式任何目的的再发布。
- * ============================================================================
- * Author By: 倪宗锋
- * PhpStorm HomeController.php
- * Create By 2017/6/20 16:19 $
- */
-
- namespace zzcx\controllers\home;
-
-
- use common\util\Util;
- use yii\web\Controller;
- use zzcx\service\home\Home;
-
- class HomeController extends Controller
- {
-
- public $service = null;
-
- /**
- * Des:获取service
- * Name: service
- * @return Home
- * @author 倪宗锋
- */
- public function service()
- {
- if ($this->service == null) {
- $this->service = new Home();
- }
- return $this->service;
- }
-
- /**
- * Des:获取热门搜索
- * Name: actionGetHot
- * @return string
- * @author 倪宗锋
- */
- public function actionGetHot()
- {
- $return = $this->service()->getHost();
-
- return Util::returnJsSu('', ['list' => $return]);
- }
-
- /**
- * Des:获取查询列表
- * Name: actionSearch
- * @return string
- * @author 倪宗锋
- */
- public function actionSearch()
- {
- $param = [
- 'prod_name' => $this->_post('prod_name', ''),//查询关键字
- ];
- $return = $this->service()->search($param);
- if ($return['flag'] == false) {
- return Util::returnJsEr($return['msg']);
- }
- return Util::returnJsSu('', $return['data'], $return['url'], $return['code']);
- }
-
-
-
-
- /**
- * Des:首页数据
- * Name: actionSearch
- * @return string
- * @author zhangsq
- */
- public function actionHomeList()
- {
- $result = $this->service()->getHomeList();
- return json_encode($result);
- }
-
- /**
- * Des:首页数据
- * Name: actionSearch
- * @return string
- * @author zhangsq
- */
- public function actionProdList()
- {
- $prodIds = $this->_post('prodIds', '');//查询关键字
- $result = $this->service()->getProdList($prodIds);
- return Util::returnJsSu('', $result['data']);
- }
-
- /**
- * Des:获取底部菜单
- * Name: actionGetBottom
- * @return string
- * @author 倪宗锋
- */
- public function actionGetBottom()
- {
- $config = require APP_PATH . '/config/home_' . YII_ENV . '_config.php';
- //底部菜单
- $bottom_menu = $config['bottom_menu'];
- return Util::returnJsSu('', ['list' => $bottom_menu]);
- }
-
- /**
- * Des:获取热门搜索poi
- * Name: actionGetHostStations
- * @return string
- * @author 倪宗锋
- */
- public function actionGetHotStation()
- {
- $param = [
- 'station_id' => $this->_post('station_id', ''),//已选站点ID
- 'inout_type' => $this->_post('inout_type', 'in'),//上下车类型 上in,下out
- 'category_id' => $this->_post('category_id', '')//菜单ID
- ];
- $return = $this->service()->getHotStation($param);
- return Util::returnJsSu('', $return);
-
- }
-
- /**
- * Des:获取站点列表
- * Name: actionGetStation
- * @return string
- * @author 倪宗锋
- */
- public function actionGetStation()
- {
- $param = [
- 'poi_type' => $this->_post('poi_type', ''),//站点类型
- 'station_id' => $this->_post('station_id', ''),//已选站点ID
- 'inout_type' => $this->_post('inout_type', 'in'),//上下车类型 上in,下out
- 'category_id' => $this->_post('category_id', ''),//菜单ID
- 'poi_name' => trim($this->_post('poi_name', '')),//搜索的关键字
- ];
- $return = $this->service()->getStation($param);//获取站点列表
- return Util::returnJsSu('', $return);
- }
-
- /**
- * Des:根据POI获取产品列表
- * Name: actionGetProdByPoi
- * @return string
- * @author 倪宗锋
- */
- public function actionGetProdByPoi()
- {
-
- $params = [
- 'init_flag' => $this->_post('init_flag', 0),
- 'poi' => $this->_post('poi', ''),//景区POI
- 'cate_id' => $this->_post('cate_id', 1),//菜单ID
- 'date' => $this->_post('date', date('Y-m-d', time())),//日期
- 'other_poi' => $this->_post('other_poi', 0),//另一个POI
- 'start_station_arr' => $this->_post('start_station_arr', ''),//起始站点数组
- 'end_station_arr' => $this->_post('end_station_arr', ''),//终点站点数组
- ];
- #获取最近有班次的日期
- $new_run_date = $this->service()->getNewRunDate($params);
- $params['date'] = $new_run_date;
- $return = $this->service()->getProdByPoi($params);//根据POI获取产品列表
-
- if ($params['start_station_arr'] != '') {
- //根据所选的起始站点处理数据集
- $start_station_arr = explode(',', $params['start_station_arr']);
- foreach ($return['data']['ticket'] as $key => $value) {
- // if($value['poi_id']==$params['poi']){
- foreach ($value['ticket_list'] as $k => $val) {
- if (!in_array($val['start_res_id'], $start_station_arr)) {
- unset($return['data']['ticket'][$key]['ticket_list'][$k]);
- }
- }
- // }
- }
- }
- if ($params['end_station_arr'] != '') {
- //根据所选的起始站点处理数据集
- $end_station_arr = explode(',', $params['end_station_arr']);
- foreach ($return['data']['ticket'] as $key => $value) {
- foreach ($value['ticket_list'] as $k => $val) {
- if (!in_array($val['end_res_id'], $end_station_arr)) {
- unset($return['data']['ticket'][$key]['ticket_list'][$k]);
- }
- }
-
- }
- }
- $today = date("Y-m-d");
- switch ($new_run_date) {
- case $today:
- $date_name = '(今天)';break;
- case date('Y-m-d',strtotime("+1 day")):
- $date_name = '(明天)';break;
- case date('Y-m-d',strtotime("+2 day")):
- $date_name = '(后天)';break;
- default:
- $date_name = '';
- }
- $return['data']['date'] = [
- 'date' => $new_run_date,
- 'date_name' => $date_name,
- 'year' => date('Y', strtotime($new_run_date)),
- 'month' => date('n', strtotime($new_run_date)),
- 'day' => date('d', strtotime($new_run_date)),
- ];
- if ($return['flag'] == false) {
- return Util::returnJsEr($return['msg']);
- } else {
- return Util::returnJsSu('', $return['data']);
- }
- }
-
-
- }
|