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.
 
 
 
 
 
 

284 lines
8.7 KiB

  1. <?php
  2. /**
  3. *
  4. * ============================================================================
  5. * * 版权所有 蜘蛛出行 * *
  6. * 网站地址: http://www.zhizhuchuxing.com
  7. * ----------------------------------------------------------------------------
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
  9. * 使用;不允许对程序代码以任何形式任何目的的再发布。
  10. * ============================================================================
  11. * Author By: 娄梦宁
  12. * PhpStorm AroundModel.php
  13. * Create By 2016/11/10 14:57 $
  14. */
  15. namespace Trip\Model;
  16. use Base\Tool\DbTable;
  17. use Util\Util\Util;
  18. use Trip\Service\BaseService;
  19. class TripModel extends DbTable
  20. {
  21. public $db = 'CST';
  22. /**
  23. * Function Description:获取首页周边游列表
  24. * Function Name: getAroud
  25. *
  26. * @return array
  27. *
  28. * @author 娄梦宁
  29. */
  30. public function getAroud()
  31. {
  32. $sql = '' . "SELECT
  33. a.line_sub_type AS type,
  34. a.line_name AS zname,
  35. a.LINE_DESCRIBE AS tickdes,
  36. b.IMG_URL AS img,
  37. b.PRODUCT_ID AS pro_id,
  38. round(c.CUS_PRICE) AS price
  39. FROM
  40. opera_line a
  41. LEFT JOIN base_img b ON b.PRODUCT_ID = a.line_id
  42. LEFT JOIN opera_tickets c ON c.LINE_ID = a.LINE_ID
  43. WHERE
  44. a.cancel_flag = 0
  45. AND b.cancel_flag = 0
  46. and c.cancel_flag=0
  47. AND b.img_type = 369
  48. AND a.line_type = 369
  49. AND c.SEAT_TYPE = 72
  50. AND c.HUMAN_TYPE in (159,334)
  51. GROUP BY
  52. a.line_id
  53. ORDER BY
  54. a.DISP_ORDER DESC
  55. LIMIT 5";
  56. $result = $this->fetchAll($sql);
  57. if ($result === false) {
  58. return Util::returnArrEr('获取首页周边游列表失败!');
  59. } else {
  60. return Util::returnArrSu('', $result);
  61. }
  62. }
  63. /**
  64. * Function Description:获取首页顶部图片列表
  65. * Function Name: getRecom
  66. *
  67. * @return array
  68. *
  69. * @author 娄梦宁
  70. */
  71. public function getRecom()
  72. {
  73. $sql = '' . "SELECT
  74. IMG_URL AS img,
  75. IMG_JUMP_URL AS toUrl,
  76. IMG_REMARK as title
  77. FROM
  78. base_img
  79. WHERE
  80. cancel_flag = 0
  81. AND img_type = 373
  82. AND PRODUCT_ID = 0
  83. ORDER BY
  84. seq_id desc
  85. ";
  86. $result = $this->fetchAll($sql);
  87. if (count($result) == 0) {
  88. return Util::returnArrEr('获取首页顶部图片列表失败!');
  89. } else {
  90. return Util::returnArrSu('', $result);
  91. }
  92. }
  93. /**
  94. * Function Description:获取迪士尼接驳列表
  95. * Function Name: getDsn
  96. *
  97. * @return array
  98. *
  99. * @author 娄梦宁
  100. */
  101. public function getDsn()
  102. {
  103. $linestr = $this->getAlldsnjb();
  104. $sql = '' . "SELECT
  105. MAX(start_minutes) - MIN(START_minutes) AS bus_time,
  106. substring_index(line_name, '-', 1) AS dsnstart,
  107. substring_index(line_name, '-' ,- 1) AS dsnend,
  108. CUS_PRICE AS price,
  109. c.start_station_area_id as start_id,
  110. c.end_station_area_id as end_id
  111. FROM
  112. opera_station a
  113. LEFT JOIN opera_line b ON a.line_id = b.line_id
  114. LEFT JOIN opera_tickets c ON a.line_id = c.line_id
  115. WHERE
  116. c.SEAT_TYPE = 72
  117. and b.line_type=256
  118. AND c.HUMAN_TYPE in (159,334)
  119. AND a.line_id IN ($linestr)
  120. GROUP BY
  121. a.line_id
  122. order by
  123. DISP_ORDER desc
  124. limit 2
  125. ";
  126. $result = $this->fetchAll($sql);
  127. $sql1 = ''.'select cus_price from opera_tickets where LINE_ID = 451804 limit 1';
  128. $result1 = $this ->fetchOne($sql1);
  129. $result[0]['bus_time'] = '50';
  130. $result[0]['dsnend'] = '上海迪士尼';
  131. $result[0]['end_id'] = '100437';
  132. $result[0]['start_id'] = '100457';
  133. $result[0]['price'] = $result1;
  134. $result[0]['dsnstart'] = '上海佘山茂御臻品之选酒店';
  135. if ($result === false) {
  136. return Util::returnArrEr('获取迪士尼接驳列表失败!');
  137. } else {
  138. foreach ($result as $key => $val) {
  139. $result[$key]['bus_time'] = $this->minstr($result[$key]['bus_time']);
  140. }
  141. return Util::returnArrSu('', $result);
  142. }
  143. }
  144. /**
  145. * Function Description:获取景区直通列表
  146. * Function Name: getScenic
  147. *
  148. * @return array
  149. *
  150. * @author 娄梦宁
  151. */
  152. public function getScenic()
  153. {
  154. $linestr = $this->getAlljqzt();
  155. $sql = '' . " SELECT
  156. a.line_name AS zname,
  157. b.IMG_URL AS img,
  158. b.product_id AS pro_id,
  159. MAX(start_minutes) - MIN(START_minutes) AS bus_time,
  160. a.line_describe AS car_type,
  161. round(d.CUS_PRICE) AS price,
  162. d.start_station_area_id as start_id,
  163. d.end_station_area_id as end_id,
  164. a.DISP_ORDER as ifRecommend
  165. FROM
  166. opera_line a
  167. LEFT JOIN base_img b ON a.line_id = b.product_id
  168. LEFT JOIN opera_station c ON a.line_id = c.line_id
  169. INNER JOIN opera_tickets d ON d.line_id = a.line_id
  170. WHERE
  171. a.line_id IN ($linestr)
  172. AND a.cancel_flag = 0
  173. AND b.cancel_flag = 0
  174. AND c.cancel_flag = 0
  175. AND d.cancel_flag = 0
  176. AND d.SEAT_TYPE = 72
  177. AND d.HUMAN_TYPE in (159,334)
  178. GROUP BY
  179. a.line_id
  180. order by
  181. DISP_ORDER desc";
  182. $result = $this->fetchAll($sql);
  183. if ($result === false) {
  184. return Util::returnArrEr('获取景区直通列表失败!');
  185. } else {
  186. foreach ($result as $key => $val) {
  187. $result[$key]['bus_time'] = $this->minstr($result[$key]['bus_time']);
  188. $result[$key]['car_type'] = "豪华大巴";
  189. }
  190. return Util::returnArrSu('', $result);
  191. }
  192. }
  193. /**
  194. * Function Description:获取所有景区直通线路,返回英文逗号分隔的线路集合
  195. * Function Name: getAlljqzt
  196. *
  197. *
  198. * @author 娄梦宁
  199. */
  200. public function getAlljqzt()
  201. {
  202. $arr = new BaseService();
  203. $area = $arr->getPoiInfoArr();
  204. $area = $area['poi_group'][318];
  205. $str = '';
  206. foreach ($area as $val) {
  207. $a = $val['start_area'];
  208. $b = $val['end_area'];
  209. $str .= " (START_STATION_AREA_ID=$a and END_STATION_AREA_ID=$b) or";
  210. }
  211. $str = rtrim($str, 'or');
  212. $sql = '' . "select DISTINCT line_id from opera_tickets where $str and cancel_flag=0";
  213. $result = $this->fetchAll($sql);
  214. $linestr = '';
  215. foreach ($result as $val) {
  216. $linestr .= $val['line_id'] . ',';
  217. }
  218. $linestr = rtrim($linestr, ',');
  219. return $linestr;
  220. }
  221. /**
  222. * Function Description:获取所有迪士尼接驳,返回英文逗号分隔的线路集合
  223. * Function Name: getAlljqzt
  224. *
  225. *
  226. * @author 娄梦宁
  227. */
  228. public function getAlldsnjb()
  229. {
  230. $arr = new BaseService();
  231. $area = $arr->getPoiInfoArr();
  232. $area = $area['poi_group'][379];
  233. $str = '';
  234. foreach ($area as $val) {
  235. $a = $val['start_area'];
  236. $b = $val['end_area'];
  237. $str .= " (START_STATION_AREA_ID=$a and END_STATION_AREA_ID=$b) or";
  238. }
  239. $str = rtrim($str, 'or');
  240. $sql = '' . "select DISTINCT line_id from opera_tickets where $str and cancel_flag=0";
  241. $result = $this->fetchAll($sql);
  242. $linestr = '';
  243. foreach ($result as $val) {
  244. $linestr .= $val['line_id'] . ',';
  245. }
  246. $linestr = rtrim($linestr, ',');
  247. return $linestr;
  248. }
  249. /**
  250. * Des:分钟转换 字符串 类似2小时30分钟
  251. * Name: minstr
  252. * @param $minutes
  253. * @return int|string
  254. * @author 娄梦宁
  255. */
  256. public function minstr($minutes)
  257. {
  258. if ($minutes < 0) {
  259. $result = 0;
  260. } elseif ($minutes < 60) {
  261. $result = $minutes . "分钟";
  262. } else {
  263. $hours = floor($minutes / 60);
  264. $minunt = $minutes % 60;
  265. if ($minunt != 0) {
  266. $result = $hours . "时" . $minunt . "分";
  267. } else {
  268. $result = $hours . "小时";
  269. }
  270. }
  271. return $result;
  272. }
  273. }