|
- <?php
- /**
- *
- * ============================================================================
- * * 版权所有 蜘蛛出行 * *
- * 网站地址: http://www.zhizhuchuxing.com
- * ----------------------------------------------------------------------------
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
- * 使用;不允许对程序代码以任何形式任何目的的再发布。
- * ============================================================================
- * Author By: 张帅
- * PhpStorm RunsService.php
- * Create By 2016/11/15 11:56 $
- */
-
- namespace Trip\Service;
-
-
- use Trip\Model\OperaLine;
-
- class RunsService
- {
- /**
- * Function Description:获取普通列表(不带分页)
- * Function Name: getCommonRunsList
- * @param $run_date
- * @param $start_area_id
- * @param $end_area_id
- *
- * @return array
- *
- * @author 张帅
- */
- public function getCommonRunsList($run_date,$start_area_id,$end_area_id){
- $opera_line = new OperaLine();
- $db_list = $opera_line->getRunsList($run_date,$start_area_id,$end_area_id);
- if($db_list['flag'] == 0 || count($db_list['data']) == 0){
- return $db_list;
- }else{
- $db_list['data'] = $this->execRunsList($db_list['data']);
- return $db_list;
- }
-
- }
-
- /**
- * Function Description:获取推荐列表
- * Function Name: getRecommendRunsList
- * @param $run_date
- * @param $start_area_id
- * @param $end_area_id
- *
- * @return array
- *
- * @author 张帅
- */
- public function getRecommendRunsList($run_date,$start_area_id,$end_area_id){
- $opera_line = new OperaLine();
- $db_list = $opera_line->getRunsList($run_date,$start_area_id,$end_area_id);
- if($db_list['flag'] == 0 || count($db_list['data']) == 0){
- return $db_list;
- }else{
- $db_list['data'] = $this->execRunsList($db_list['data']);
- return $db_list;
- }
- }
-
- /**
- * Function Description:获取普通列表(分页)
- * Function Name: getCommonPageRunsList
- * @param $run_date
- * @param $start_area_id
- * @param $end_area_id
- * @param $page_size
- * @param $current_page
- *
- * @return array
- *
- * @author 张帅
- */
- public function getCommonPageRunsList($run_date,$start_area_id,$end_area_id,$page_size,$current_page){
- $opera_line = new OperaLine();
- $db_list = $opera_line->getPageRunsList($run_date,$start_area_id,$end_area_id,$page_size,$current_page);
- if(!$db_list['flag'] || count($db_list['data']['common_list']) == 0){
- return $db_list;
- }else{
- $db_list['data']['common_list'] = $this->execRunsList($db_list['data']['common_list']);
- return $db_list;
- }
- }
-
- /**
- * Function Description:处理从数据库得到的数组
- * Function Name: execRunsList
- * @param $db_list
- *
- *
- * @author 张帅
- */
- public function execRunsList($db_list){
- $base_service = new BaseService();
- $station_base = $base_service->getPoiInfoArr();
- $poi_info = $station_base['poi_info'];
- foreach ($db_list as $key => $vel){
- $start_poi_type = explode(',',$poi_info[$vel['start_area_id']]['poi_type']);
- $end_poi_type = explode(',',$poi_info[$vel['end_area_id']]['poi_type']);
- if($start_poi_type == 0 || $end_poi_type == 0){
- $db_list[$key]['line_type'] = '255';
- }
- if(in_array(377,$start_poi_type) && in_array(377,$end_poi_type)){
- $db_list[$key]['line_type'] = '319';
- }
- if(in_array(27,$start_poi_type) || in_array(27,$end_poi_type)){
- $db_list[$key]['line_type'] = '318';
- }
- if($vel['start_area_id'] == 3240 || $vel['end_area_id'] == 3240){
- $db_list[$key]['line_type'] = '379';
- }
- if(in_array(7,$start_poi_type) || in_array(7,$end_poi_type)){
- $db_list[$key]['line_type'] = '380';
- if(in_array(7,$start_poi_type)){
- $db_list[$key]['air_type'] = 'jie';
- }
- if(in_array(7,$end_poi_type)){
- $db_list[$key]['air_type'] = 'song';
- }
- }else{
- $db_list[$key]['air_type'] = '';
- }
- if($vel['total_time']<=0){
- $vel['total_time'] = 24*60+$vel['total_time'];
- }
- $hours = intval($vel['total_time']/60);
- $min = $vel['total_time']%60;
- $db_list[$key]['total_time'] = $hours . '时' . $min . '分';
- $db_list[$key]['line_no'] = '';
- $db_list[$key]['line_remark'] = '';
- $db_list[$key]['price'] = ceil($db_list[$key]['price']);
- }
- return $db_list;
- }
-
- }
|