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.
 
 
 
 
 
 

143 lines
4.8 KiB

  1. <?php
  2. /**
  3. *
  4. * ============================================================================
  5. * * 版权所有 蜘蛛出行 * *
  6. * 网站地址: http://www.zhizhuchuxing.com
  7. * ----------------------------------------------------------------------------
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
  9. * 使用;不允许对程序代码以任何形式任何目的的再发布。
  10. * ============================================================================
  11. * Author By: 张帅
  12. * PhpStorm RunsService.php
  13. * Create By 2016/11/15 11:56 $
  14. */
  15. namespace Trip\Service;
  16. use Trip\Model\OperaLine;
  17. class RunsService
  18. {
  19. /**
  20. * Function Description:获取普通列表(不带分页)
  21. * Function Name: getCommonRunsList
  22. * @param $run_date
  23. * @param $start_area_id
  24. * @param $end_area_id
  25. *
  26. * @return array
  27. *
  28. * @author 张帅
  29. */
  30. public function getCommonRunsList($run_date,$start_area_id,$end_area_id){
  31. $opera_line = new OperaLine();
  32. $db_list = $opera_line->getRunsList($run_date,$start_area_id,$end_area_id);
  33. if($db_list['flag'] == 0 || count($db_list['data']) == 0){
  34. return $db_list;
  35. }else{
  36. $db_list['data'] = $this->execRunsList($db_list['data']);
  37. return $db_list;
  38. }
  39. }
  40. /**
  41. * Function Description:获取推荐列表
  42. * Function Name: getRecommendRunsList
  43. * @param $run_date
  44. * @param $start_area_id
  45. * @param $end_area_id
  46. *
  47. * @return array
  48. *
  49. * @author 张帅
  50. */
  51. public function getRecommendRunsList($run_date,$start_area_id,$end_area_id){
  52. $opera_line = new OperaLine();
  53. $db_list = $opera_line->getRunsList($run_date,$start_area_id,$end_area_id);
  54. if($db_list['flag'] == 0 || count($db_list['data']) == 0){
  55. return $db_list;
  56. }else{
  57. $db_list['data'] = $this->execRunsList($db_list['data']);
  58. return $db_list;
  59. }
  60. }
  61. /**
  62. * Function Description:获取普通列表(分页)
  63. * Function Name: getCommonPageRunsList
  64. * @param $run_date
  65. * @param $start_area_id
  66. * @param $end_area_id
  67. * @param $page_size
  68. * @param $current_page
  69. *
  70. * @return array
  71. *
  72. * @author 张帅
  73. */
  74. public function getCommonPageRunsList($run_date,$start_area_id,$end_area_id,$page_size,$current_page){
  75. $opera_line = new OperaLine();
  76. $db_list = $opera_line->getPageRunsList($run_date,$start_area_id,$end_area_id,$page_size,$current_page);
  77. if(!$db_list['flag'] || count($db_list['data']['common_list']) == 0){
  78. return $db_list;
  79. }else{
  80. $db_list['data']['common_list'] = $this->execRunsList($db_list['data']['common_list']);
  81. return $db_list;
  82. }
  83. }
  84. /**
  85. * Function Description:处理从数据库得到的数组
  86. * Function Name: execRunsList
  87. * @param $db_list
  88. *
  89. *
  90. * @author 张帅
  91. */
  92. public function execRunsList($db_list){
  93. $base_service = new BaseService();
  94. $station_base = $base_service->getPoiInfoArr();
  95. $poi_info = $station_base['poi_info'];
  96. foreach ($db_list as $key => $vel){
  97. $start_poi_type = explode(',',$poi_info[$vel['start_area_id']]['poi_type']);
  98. $end_poi_type = explode(',',$poi_info[$vel['end_area_id']]['poi_type']);
  99. if($start_poi_type == 0 || $end_poi_type == 0){
  100. $db_list[$key]['line_type'] = '255';
  101. }
  102. if(in_array(377,$start_poi_type) && in_array(377,$end_poi_type)){
  103. $db_list[$key]['line_type'] = '319';
  104. }
  105. if(in_array(27,$start_poi_type) || in_array(27,$end_poi_type)){
  106. $db_list[$key]['line_type'] = '318';
  107. }
  108. if($vel['start_area_id'] == 3240 || $vel['end_area_id'] == 3240){
  109. $db_list[$key]['line_type'] = '379';
  110. }
  111. if(in_array(7,$start_poi_type) || in_array(7,$end_poi_type)){
  112. $db_list[$key]['line_type'] = '380';
  113. if(in_array(7,$start_poi_type)){
  114. $db_list[$key]['air_type'] = 'jie';
  115. }
  116. if(in_array(7,$end_poi_type)){
  117. $db_list[$key]['air_type'] = 'song';
  118. }
  119. }else{
  120. $db_list[$key]['air_type'] = '';
  121. }
  122. if($vel['total_time']<=0){
  123. $vel['total_time'] = 24*60+$vel['total_time'];
  124. }
  125. $hours = intval($vel['total_time']/60);
  126. $min = $vel['total_time']%60;
  127. $db_list[$key]['total_time'] = $hours . '时' . $min . '分';
  128. $db_list[$key]['line_no'] = '';
  129. $db_list[$key]['line_remark'] = '';
  130. $db_list[$key]['price'] = ceil($db_list[$key]['price']);
  131. }
  132. return $db_list;
  133. }
  134. }