|
- <?php
- /**
- *
- * ============================================================================
- * * 版权所有 蜘蛛出行 * *
- * 网站地址: http://www.zhizhuchuxing.com
- * ----------------------------------------------------------------------------
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
- * 使用;不允许对程序代码以任何形式任何目的的再发布。
- * ============================================================================
- * Author By: 张帅
- * PhpStorm BaseArea.php
- * Create By 2016/11/11 17:14 $
- */
-
- namespace Trip\Model;
-
-
- use Base\Tool\DbTable;
- use Util\Util\Util;
-
- class BaseArea extends DbTable
- {
- public $db = 'CST';
- public $tab = 'base_area';
-
- /**
- * Function Description:获取所有线路中开始POI-结束POI的连接关系
- * Function Name: getPoiId
- *
- * @return array
- *
- * @author 张帅
- */
- public function getPoiId()
- {
- $siteContantConfig = Util::getSiteContantsConfig();
- $sql = '' . 'SELECT
- start_area,
- (SELECT poi_type FROM base_area WHERE id = start_area) as start_poi_type,
- end_area,
- (SELECT poi_type FROM base_area WHERE id = end_area) as end_poi_type
- FROM
- (
- SELECT
- SUBSTRING_INDEX(SUBSTRING_INDEX(b.start_area, \',\', sequence.help_topic_id),\',\' ,-1) AS start_area,
- SUBSTRING_INDEX(SUBSTRING_INDEX(b.end_area, \',\', sequence1.help_topic_id),\',\' ,-1) AS end_area
- FROM
- (select help_topic_id from mysql.help_topic where help_topic_id between 1 and 20 ) as sequence,
- (select help_topic_id from mysql.help_topic where help_topic_id between 1 and 20 )as sequence1,
- (
- SELECT @id := @id +1 as id,
- if(length(start_parent)=0,start_area_id,concat(start_area_id,\',\',start_parent)) as start_area,
- if(length(end_parent)=0,end_area_id,concat(end_area_id,\',\',end_parent)) as end_area
- FROM (
- SELECT distinct
- t.start_station_area_id as start_area_id,
- replace(substring(v1.parent_area_id_list,2,length(v1.parent_area_id_list)-2),\'}{\',\',\') AS start_parent,
- t.end_station_area_id as end_area_id,
- replace(substring(v2.parent_area_id_list,2,length(v2.parent_area_id_list)-2),\'}{\',\',\') AS end_parent
- FROM
- opera_line AS l,
- opera_tickets AS t,
- base_area_view as v1,
- base_area_view as v2
- WHERE
- l.line_id = t.line_id
- and l.org_id ' . $siteContantConfig['show_line_org'] . '
- and v1.area_id = t.start_station_area_id
- and v2.area_id = t.end_station_area_id
- AND l.cancel_flag = 0
- AND l.if_disabled = 0
- AND l.line_type in(255,256)
- AND l.is_onsale = 1
- AND t.cancel_flag = 0
- AND t.start_station_area_id != 0
- AND t.end_station_area_id != 0
- ) a, (select @id:= 0) as i
- ) b
- WHERE
- sequence.help_topic_id BETWEEN 1 AND ( SELECT 1 + LENGTH(b.start_area) - LENGTH(REPLACE(b.start_area, \',\', \'\')))
- AND sequence1.help_topic_id BETWEEN 1 AND ( SELECT 1 + LENGTH(b.end_area) - LENGTH(REPLACE(b.end_area, \',\', \'\')))
- GROUP BY
- SUBSTRING_INDEX(SUBSTRING_INDEX(b.start_area, \',\', sequence.help_topic_id),\',\' ,-1),
- SUBSTRING_INDEX(SUBSTRING_INDEX(b.end_area, \',\', sequence1.help_topic_id),\',\' ,-1)
- )as tb';
- $result = $this->fetchAll($sql);
- if ($result) {
- return Util::returnArrSu('', $result);
- } else {
- return Util::returnArrEr('数据库错误');
- }
- }
-
- /**
- * Function Description:获取poi详情
- * Function Name: getPoiInfo
- * @param $poi_id
- *
- * @return array
- *
- * @author 张帅
- */
- public function getPoiInfo($poi_id)
- {
- $sql = '' . 'SELECT
- a.id as area_id,
- a.area_name,
- a.poi_type,
- REPLACE(substring(v.parent_area_id_list,2,length(v.parent_area_id_list)-2),\'}{\',\',\') AS parent_area_id,
- REPLACE(REPLACE(substring(v.parent_area_name_list,2),\'}{\',\',\'),\'}\',\'\') AS parent_area_name
- FROM
- base_area AS a,
- base_area_view AS v
- WHERE
- a.id = v.area_id
- AND a.id in (' . $poi_id . ')';
- $result = $this->fetchAll($sql);
- if ($result) {
- return Util::returnArrSu('', $result);
- } else {
- return Util::returnArrEr('数据库错误');
- }
- }
-
- }
|