You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

126 lines
6.0 KiB

  1. <?php
  2. /**
  3. *
  4. * ============================================================================
  5. * * 版权所有 蜘蛛出行 * *
  6. * 网站地址: http://www.zhizhuchuxing.com
  7. * ----------------------------------------------------------------------------
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
  9. * 使用;不允许对程序代码以任何形式任何目的的再发布。
  10. * ============================================================================
  11. * Author By: 张帅
  12. * PhpStorm BaseArea.php
  13. * Create By 2016/11/11 17:14 $
  14. */
  15. namespace Trip\Model;
  16. use Base\Tool\DbTable;
  17. use Util\Util\Util;
  18. class BaseArea extends DbTable
  19. {
  20. public $db = 'CST';
  21. public $tab = 'base_area';
  22. /**
  23. * Function Description:获取所有线路中开始POI-结束POI的连接关系
  24. * Function Name: getPoiId
  25. *
  26. * @return array
  27. *
  28. * @author 张帅
  29. */
  30. public function getPoiId()
  31. {
  32. $siteContantConfig = Util::getSiteContantsConfig();
  33. $sql = '' . 'SELECT
  34. start_area,
  35. (SELECT poi_type FROM base_area WHERE id = start_area) as start_poi_type,
  36. end_area,
  37. (SELECT poi_type FROM base_area WHERE id = end_area) as end_poi_type
  38. FROM
  39. (
  40. SELECT
  41. SUBSTRING_INDEX(SUBSTRING_INDEX(b.start_area, \',\', sequence.help_topic_id),\',\' ,-1) AS start_area,
  42. SUBSTRING_INDEX(SUBSTRING_INDEX(b.end_area, \',\', sequence1.help_topic_id),\',\' ,-1) AS end_area
  43. FROM
  44. (select help_topic_id from mysql.help_topic where help_topic_id between 1 and 20 ) as sequence,
  45. (select help_topic_id from mysql.help_topic where help_topic_id between 1 and 20 )as sequence1,
  46. (
  47. SELECT @id := @id +1 as id,
  48. if(length(start_parent)=0,start_area_id,concat(start_area_id,\',\',start_parent)) as start_area,
  49. if(length(end_parent)=0,end_area_id,concat(end_area_id,\',\',end_parent)) as end_area
  50. FROM (
  51. SELECT distinct
  52. t.start_station_area_id as start_area_id,
  53. replace(substring(v1.parent_area_id_list,2,length(v1.parent_area_id_list)-2),\'}{\',\',\') AS start_parent,
  54. t.end_station_area_id as end_area_id,
  55. replace(substring(v2.parent_area_id_list,2,length(v2.parent_area_id_list)-2),\'}{\',\',\') AS end_parent
  56. FROM
  57. opera_line AS l,
  58. opera_tickets AS t,
  59. base_area_view as v1,
  60. base_area_view as v2
  61. WHERE
  62. l.line_id = t.line_id
  63. and l.org_id ' . $siteContantConfig['show_line_org'] . '
  64. and v1.area_id = t.start_station_area_id
  65. and v2.area_id = t.end_station_area_id
  66. AND l.cancel_flag = 0
  67. AND l.if_disabled = 0
  68. AND l.line_type in(255,256)
  69. AND l.is_onsale = 1
  70. AND t.cancel_flag = 0
  71. AND t.start_station_area_id != 0
  72. AND t.end_station_area_id != 0
  73. ) a, (select @id:= 0) as i
  74. ) b
  75. WHERE
  76. sequence.help_topic_id BETWEEN 1 AND ( SELECT 1 + LENGTH(b.start_area) - LENGTH(REPLACE(b.start_area, \',\', \'\')))
  77. AND sequence1.help_topic_id BETWEEN 1 AND ( SELECT 1 + LENGTH(b.end_area) - LENGTH(REPLACE(b.end_area, \',\', \'\')))
  78. GROUP BY
  79. SUBSTRING_INDEX(SUBSTRING_INDEX(b.start_area, \',\', sequence.help_topic_id),\',\' ,-1),
  80. SUBSTRING_INDEX(SUBSTRING_INDEX(b.end_area, \',\', sequence1.help_topic_id),\',\' ,-1)
  81. )as tb';
  82. $result = $this->fetchAll($sql);
  83. if ($result) {
  84. return Util::returnArrSu('', $result);
  85. } else {
  86. return Util::returnArrEr('数据库错误');
  87. }
  88. }
  89. /**
  90. * Function Description:获取poi详情
  91. * Function Name: getPoiInfo
  92. * @param $poi_id
  93. *
  94. * @return array
  95. *
  96. * @author 张帅
  97. */
  98. public function getPoiInfo($poi_id)
  99. {
  100. $sql = '' . 'SELECT
  101. a.id as area_id,
  102. a.area_name,
  103. a.poi_type,
  104. REPLACE(substring(v.parent_area_id_list,2,length(v.parent_area_id_list)-2),\'}{\',\',\') AS parent_area_id,
  105. REPLACE(REPLACE(substring(v.parent_area_name_list,2),\'}{\',\',\'),\'}\',\'\') AS parent_area_name
  106. FROM
  107. base_area AS a,
  108. base_area_view AS v
  109. WHERE
  110. a.id = v.area_id
  111. AND a.id in (' . $poi_id . ')';
  112. $result = $this->fetchAll($sql);
  113. if ($result) {
  114. return Util::returnArrSu('', $result);
  115. } else {
  116. return Util::returnArrEr('数据库错误');
  117. }
  118. }
  119. }