Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 
 

674 Zeilen
29 KiB

  1. <?php
  2. /**
  3. *
  4. * ============================================================================
  5. * * 版权所有 蜘蛛出行 * *
  6. * 网站地址: http://www.zhizhuchuxing.com
  7. * ----------------------------------------------------------------------------
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
  9. * 使用;不允许对程序代码以任何形式任何目的的再发布。
  10. * ============================================================================
  11. * Author By: 倪宗锋
  12. * PhpStorm Home.php
  13. * Create By 2017/6/20 19:47 $
  14. */
  15. namespace zzcx\service\home;
  16. use common\models\BaseArea;
  17. use common\models\BusTicket;
  18. use common\models\CmsCategoryExtra;
  19. use common\models\CmsCategoryProd;
  20. use common\models\ProdCategory;
  21. use common\util\Util;
  22. use common\util\zh2py;
  23. class Home
  24. {
  25. /**
  26. * Des:获取热门搜索
  27. * Name: getHost
  28. * @return array
  29. * @author 倪宗锋
  30. */
  31. public function getHost()
  32. {
  33. $getHomeConfig = require APP_PATH . '/config/home_' . YII_ENV . '_config.php';
  34. return explode(',', $getHomeConfig['hot_search']);
  35. }
  36. /**
  37. * Des:获取搜索列表
  38. * Name: search
  39. * @param $param
  40. * @return array
  41. * @author 倪宗锋
  42. */
  43. public function search($param)
  44. {
  45. if (empty($param['prod_name'])) {
  46. return Util::returnArrSu('', ['list' => []], '', '1000');
  47. }
  48. $param['prod_name'] = str_replace([' ', '-'], '%', trim($param['prod_name']));
  49. $prodCate = new ProdCategory();
  50. $touristList = $prodCate->getSearchList($param, 4);
  51. if (empty($touristList['0'])) {
  52. $touristList = [];
  53. }
  54. $menPList = $prodCate->getSearchList($param, 2);
  55. if (empty($menPList['0'])) {
  56. $menPList = [];
  57. }
  58. $cms_category_extra = new CmsCategoryExtra();
  59. $destination_list = $cms_category_extra->getAllInfo($param['prod_name']);
  60. $destination = [];
  61. foreach ($destination_list as $val) {
  62. $destination[] = [
  63. 'category_id' => 100,
  64. 'pro_cate_name' => $val['category_name'],
  65. 'pro_cate_id' => $val['category_id'],
  66. ];
  67. }
  68. $list = [];
  69. if (count($touristList) > 0) {
  70. foreach ($touristList as $key => $val) {
  71. $touristList[$key]['pro_cate_name'] = str_replace('>', '&gt', $val['pro_cate_name']);
  72. }
  73. $list[] = [
  74. 'cate_id' => 4,
  75. 'cate_name' => '巴士自由行',
  76. 'list' => $touristList
  77. ];
  78. }
  79. if (count($menPList) > 0) {
  80. $list[] = [
  81. 'cate_id' => 2,
  82. 'cate_name' => '景区门票',
  83. 'list' => $menPList
  84. ];
  85. }
  86. if (count($destination) > 0) {
  87. $list[] = [
  88. 'cate_id' => 100,
  89. 'cate_name' => '热门目的地',
  90. 'list' => $destination
  91. ];
  92. }
  93. return Util::returnArrSu('', ['list' => $list]);
  94. }
  95. public function getProdList($prodIds){
  96. $cms_prod = new CmsCategoryProd();
  97. $hot_line_list = $cms_prod->getShowProdList($prodIds);
  98. foreach ($hot_line_list as &$v) {
  99. $v['show_price'] = $this->dealFloat($v['show_price']);
  100. $v['original_price'] = $this->dealFloat($v['original_price']);
  101. }
  102. return Util::returnArrSu('', $hot_line_list);
  103. }
  104. public function getHomeList()
  105. {
  106. $config = require APP_PATH . '/config/home_' . YII_ENV . '_config.php';
  107. $external = empty($config['external_links']) ? [] : $config['external_links'];
  108. //目的地玩乐
  109. $cms_category_extra = new CmsCategoryExtra();
  110. $destination_list = $cms_category_extra->getAllInfo();
  111. // 景区直通车
  112. $scenic_through_train = $config['scenic_through_train'];
  113. // 超值热卖 jin_pin
  114. $cms_prod = new CmsCategoryProd();
  115. $hot_line_list = $cms_prod->getRecommendList($config['jin_pin']);
  116. foreach ($hot_line_list as &$v) {
  117. $v['show_price'] = $this->dealFloat($v['show_price']);
  118. $v['original_price'] = $this->dealFloat($v['original_price']);
  119. }
  120. //滚动banner图
  121. $banner_list = $config['banner_list'];
  122. $result = [
  123. 'banner_list' => $banner_list,
  124. 'external' => $external,
  125. 'train' =>
  126. [
  127. 'cms_name' => empty($config["scenic_through_train_name"]) ? '景区直通车' : $config["scenic_through_train_name"],
  128. 'scenic_through_train' => $scenic_through_train
  129. ],
  130. "destination" =>[
  131. 'cms_name' => '目的地玩乐',
  132. 'destination_list' => $destination_list
  133. ],
  134. 'hot_line' =>
  135. [
  136. 'cms_name' => '超值热卖',
  137. 'hot_line_list' => $hot_line_list
  138. ],
  139. ];
  140. return Util::returnArrSu('', $result);
  141. }
  142. /**********************站点选择************************************/
  143. /**
  144. * Des:获取热门站点
  145. * Name: getHostStation
  146. * @param $param
  147. * @return array
  148. * @author 倪宗锋
  149. */
  150. public function getHotStation($param)
  151. {
  152. $busTicket = new BusTicket();
  153. $param['limit'] = 6;
  154. $siteConfig = Util::getSiteConfig();
  155. $param['system'] = $siteConfig['system'];//系统ID
  156. if ($param['inout_type'] == 'in') {
  157. $getList = $busTicket->getStartStation($param);//获取出发站点 poi列表
  158. } else {
  159. $getList = $busTicket->getEndStation($param);//获取终点站 poi列表
  160. }
  161. if (count($getList) == 0) {//空数组则直接返回空数组
  162. $getList = [];
  163. }
  164. $poiType = [
  165. ['id' => 0, 'name' => '全部'],
  166. ['id' => 630, 'name' => '城市'],
  167. ['id' => 405, 'name' => '景区'],
  168. ['id' => 412, 'name' => '交通枢纽'],
  169. ['id' => 408, 'name' => '酒店'],
  170. ];
  171. return ['hotPoi' => $getList, 'poiType' => $poiType];
  172. }
  173. /**
  174. * Des:获取站点列表
  175. * Name: getStation
  176. * @param $param
  177. * @return array
  178. * @author 倪宗锋
  179. */
  180. public function getStation($param)
  181. {
  182. if (empty($param['poi_type']) == false && in_array($param['poi_type'], [630, 405, 408, 412]) == false) {
  183. return [];
  184. }
  185. $siteConfig = Util::getSiteConfig();
  186. $param['system'] = $siteConfig['system'];//系统ID
  187. $busTicket = new BusTicket();
  188. if ($param['inout_type'] == 'in') {
  189. $getList = $busTicket->getStartStation($param);//获取出发站点 poi列表
  190. } else {
  191. $getList = $busTicket->getEndStation($param);//获取终点站 poi列表
  192. }
  193. if (count($getList) == 0) {//空数组则直接返回空数组
  194. return [];
  195. }
  196. $station_arr = $this->orderByPy($getList, 'name');//非空数组进行首写字母排序
  197. return $station_arr;
  198. }
  199. /**
  200. * Des:获取到结果进行首写字母排序
  201. * Name: orderByPy
  202. * @param $arr
  203. * @param $theKey
  204. * @return array
  205. * @author 倪宗锋
  206. */
  207. public function orderByPy($arr, $theKey)
  208. {
  209. //先根据poiname排序
  210. $arr1 = array();
  211. foreach ($arr as $key => $val) {
  212. $area_name = $val[$theKey];
  213. $arr1["$area_name"] = $arr["$key"];
  214. }
  215. ksort($arr1);
  216. $arr = array_merge($arr1);
  217. //排好序的数组再根据poi拼音首字排序
  218. $newarr = array();
  219. foreach ($arr as $val) {
  220. $shouzi = mb_substr(trim($val[$theKey]), 0, 1, 'utf-8');
  221. if (Util::checkPattern('', $shouzi, '/^[\x{4e00}-\x{9fa5}]$/u') == false) {
  222. $FirstPy = $shouzi;
  223. } else {
  224. $py = new zh2py();
  225. $FirstPy = $py::conv($shouzi);
  226. $FirstPy = substr($FirstPy, 0, 1);
  227. }
  228. $val['first_py'] = $FirstPy;
  229. $newarr["$FirstPy"][] = $val;
  230. }
  231. ksort($newarr);
  232. return $newarr;
  233. }
  234. /**************站点选择结束*****************************/
  235. /**
  236. * Des:根据poi获取产品信息
  237. * Name: getProdByPoi
  238. * @param $params
  239. * @return array
  240. * @author 倪宗锋
  241. */
  242. public function getProdByPoi($params)
  243. {
  244. //参数校验
  245. if (Util::checkPattern('intVal', $params['poi']) == false) {
  246. return Util::returnArrEr('请选择站点');
  247. }
  248. if ($params['cate_id'] != 1 && $params['cate_id'] != 2) {
  249. return Util::returnArrEr('参数有误');
  250. }
  251. $prodCate = new ProdCategory();
  252. $stock_logic = new Bus();
  253. if ($params['cate_id'] == 1) {
  254. $all_tickets = $stock_logic->getGoBusStockForArea('', $params['poi'], $params['date']);
  255. $prod_arr = [];
  256. $station_arr = [];
  257. $data = $all_tickets['data'];
  258. if (empty($data)) {
  259. $data = [];
  260. }
  261. foreach ($data as $run_id => $run_tickets) {
  262. foreach ($run_tickets['ticket_list'] as $ticket_id => $ticket_info) {
  263. $ticket = $prodCate->getBusProdByTicket($ticket_id);
  264. if ($ticket == null) {
  265. continue;
  266. }
  267. if (strtotime(date('Y-m-d') . ' ' . $ticket_info['start_time']) > time() || strtotime($params['date']) > time()) {
  268. $tmp_time_sort = strtotime(date('Y-m-d') . ' ' . $ticket_info['start_time']);
  269. $tmp_rand = rand(999, 9999);
  270. while (isset($prod_arr[$ticket['end_area_id']]['ticket_list'][$tmp_time_sort . $tmp_rand])) {
  271. $tmp_rand = rand(999, 9999);
  272. }
  273. $tmp_is_delay = 0;
  274. } else {
  275. $tmp_time_sort = strtotime('+1 day', strtotime(date('Y-m-d') . ' ' . $ticket_info['start_time']));
  276. $tmp_rand = rand(999, 9999);
  277. while (isset($prod_arr[$ticket['end_area_id']]['ticket_list'][$tmp_time_sort . $tmp_rand])) {
  278. $tmp_rand = rand(999, 9999);
  279. }
  280. $tmp_is_delay = 1;
  281. }
  282. $ticket_info['prod_num'] = intval($ticket_info['prod_num']);
  283. if (array_key_exists($ticket['start_area_id'], $prod_arr)) {
  284. $prod_arr[$ticket['start_area_id']]['ticket_list'][$tmp_time_sort . $tmp_rand] = [
  285. 'ticket_id' => $ticket_id,
  286. 'prod_num' => $ticket_info['prod_num'] >= 20 ? '余票充足' : ($ticket_info['prod_num'] == 0 ? '已售完' : $ticket_info['prod_num'] . '张'),
  287. 'start_time' => $ticket_info['start_time'],
  288. 'start_res_name' => $ticket['start_res_name'],
  289. 'end_res_name' => $ticket['end_res_name'],
  290. 'start_res_id' => $ticket['start_res_id'],
  291. 'end_res_id' => $ticket['end_res_id'],
  292. 'show_price' => $ticket['show_price'],
  293. 'start_area_name' => $ticket['start_area_name'],
  294. 'end_area_name' => $ticket['end_area_name'],
  295. 'start_area_id' => $ticket['start_area_id'],
  296. 'end_area_id' => $ticket['end_area_id'],
  297. 'prod_cate_id' => $ticket['pro_cate_id'],
  298. 'run_id' => $run_id,
  299. 'is_delay' => $tmp_is_delay,
  300. 'ticket_cnt' => $ticket_info['prod_num']
  301. ];
  302. } else {
  303. $prod_arr[$ticket['start_area_id']]['poi_id'] = $ticket['start_area_id'];
  304. $prod_arr[$ticket['start_area_id']]['poi_name'] = str_replace('市', '', $ticket['start_area_name']) . '出发';
  305. $prod_arr[$ticket['start_area_id']]['ticket_list'][$tmp_time_sort . $tmp_rand] = [
  306. 'ticket_id' => $ticket_id,
  307. 'prod_num' => $ticket_info['prod_num'] >= 20 ? '余票充足' : ($ticket_info['prod_num'] == 0 ? '已售完' : $ticket_info['prod_num'] . '张'),
  308. 'start_time' => $ticket_info['start_time'],
  309. 'start_res_name' => $ticket['start_res_name'],
  310. 'end_res_name' => $ticket['end_res_name'],
  311. 'start_res_id' => $ticket['start_res_id'],
  312. 'end_res_id' => $ticket['end_res_id'],
  313. 'show_price' => $ticket['show_price'],
  314. 'start_area_name' => $ticket['start_area_name'],
  315. 'end_area_name' => $ticket['end_area_name'],
  316. 'start_area_id' => $ticket['start_area_id'],
  317. 'end_area_id' => $ticket['end_area_id'],
  318. 'prod_cate_id' => $ticket['pro_cate_id'],
  319. 'run_id' => $run_id,
  320. 'is_delay' => $tmp_is_delay,
  321. 'ticket_cnt' => $ticket_info['prod_num']
  322. ];
  323. }
  324. if (array_key_exists($ticket['start_area_id'], $station_arr) && array_key_exists($ticket['start_res_id'], $station_arr[$ticket['start_area_id']])) {
  325. $station_arr[$ticket['start_area_id']][$ticket['start_res_id']]['end_station_list'][] = [
  326. 'end_res_id' => $ticket['end_res_id'],
  327. 'end_res_name' => $ticket['end_res_name']
  328. ];
  329. } else {
  330. $station_arr[$ticket['start_area_id']][$ticket['start_res_id']]['start_res_id'] = $ticket['start_res_id'];
  331. $station_arr[$ticket['start_area_id']][$ticket['start_res_id']]['start_res_name'] = $ticket['start_res_name'];
  332. $station_arr[$ticket['start_area_id']][$ticket['start_res_id']]['end_station_list'][] = [
  333. 'end_res_id' => $ticket['end_res_id'],
  334. 'end_res_name' => $ticket['end_res_name']
  335. ];
  336. }
  337. }
  338. }
  339. } else {
  340. $all_tickets = $stock_logic->getGoBusStockForArea($params['poi'], '', $params['date']);
  341. $prod_arr = [];
  342. $station_arr = [];
  343. foreach ($all_tickets['data'] as $run_id => $run_tickets) {
  344. foreach ($run_tickets['ticket_list'] as $ticket_id => $ticket_info) {
  345. $ticket = $prodCate->getBusProdByTicket($ticket_id);
  346. if ($ticket == null) {
  347. continue;
  348. }
  349. if (strtotime(date('Y-m-d') . ' ' . $ticket_info['start_time']) > time() || strtotime($params['date']) > time()) {
  350. $tmp_time_sort = strtotime(date('Y-m-d') . ' ' . $ticket_info['start_time']);
  351. $tmp_rand = rand(999, 9999);
  352. while (isset($prod_arr[$ticket['end_area_id']]['ticket_list'][$tmp_time_sort . $tmp_rand])) {
  353. $tmp_rand = rand(999, 9999);
  354. }
  355. $tmp_is_delay = 0;
  356. } else {
  357. $tmp_time_sort = strtotime('+1 day', strtotime(date('Y-m-d') . ' ' . $ticket_info['start_time']));
  358. $tmp_rand = rand(999, 9999);
  359. while (isset($prod_arr[$ticket['end_area_id']]['ticket_list'][$tmp_time_sort . $tmp_rand])) {
  360. $tmp_rand = rand(999, 9999);
  361. }
  362. $tmp_is_delay = 1;
  363. }
  364. if (array_key_exists($ticket['end_area_id'], $prod_arr)) {
  365. $prod_arr[$ticket['end_area_id']]['ticket_list'][$tmp_time_sort . $tmp_rand] = [
  366. 'ticket_id' => $ticket_id,
  367. 'prod_num' => $ticket_info['prod_num'] >= 20 ? '余票充足' : $ticket_info['prod_num'] . '张',
  368. 'start_time' => $ticket_info['start_time'],
  369. 'start_res_name' => $ticket['start_res_name'],
  370. 'end_res_name' => $ticket['end_res_name'],
  371. 'start_res_id' => $ticket['start_res_id'],
  372. 'end_res_id' => $ticket['end_res_id'],
  373. 'show_price' => $ticket['show_price'],
  374. 'start_area_name' => $ticket['start_area_name'],
  375. 'end_area_name' => $ticket['end_area_name'],
  376. 'start_area_id' => $ticket['start_area_id'],
  377. 'end_area_id' => $ticket['end_area_id'],
  378. 'prod_cate_id' => $ticket['pro_cate_id'],
  379. 'run_id' => $run_id,
  380. 'is_delay' => $tmp_is_delay,
  381. ];
  382. } else {
  383. $prod_arr[$ticket['end_area_id']]['poi_id'] = $ticket['end_area_id'];
  384. $prod_arr[$ticket['end_area_id']]['poi_name'] = '去' . str_replace('市', '', $ticket['end_area_name']);
  385. $prod_arr[$ticket['end_area_id']]['ticket_list'][$tmp_time_sort . $tmp_rand] = [
  386. 'ticket_id' => $ticket_id,
  387. 'prod_num' => $ticket_info['prod_num'] >= 20 ? '余票充足' : $ticket_info['prod_num'] . '张',
  388. 'start_time' => $ticket_info['start_time'],
  389. 'start_res_name' => $ticket['start_res_name'],
  390. 'end_res_name' => $ticket['end_res_name'],
  391. 'start_res_id' => $ticket['start_res_id'],
  392. 'end_res_id' => $ticket['end_res_id'],
  393. 'show_price' => $ticket['show_price'],
  394. 'start_area_name' => $ticket['start_area_name'],
  395. 'end_area_name' => $ticket['end_area_name'],
  396. 'start_area_id' => $ticket['start_area_id'],
  397. 'end_area_id' => $ticket['end_area_id'],
  398. 'prod_cate_id' => $ticket['pro_cate_id'],
  399. 'run_id' => $run_id,
  400. 'is_delay' => $tmp_is_delay,
  401. ];
  402. }
  403. if (array_key_exists($ticket['end_area_id'], $station_arr) && array_key_exists($ticket['start_res_id'], $station_arr[$ticket['end_area_id']])) {
  404. $station_arr[$ticket['end_area_id']][$ticket['start_res_id']]['end_station_list'][] = [
  405. 'end_res_id' => $ticket['end_res_id'],
  406. 'end_res_name' => $ticket['end_res_name']
  407. ];
  408. } else {
  409. $station_arr[$ticket['end_area_id']][$ticket['start_res_id']]['start_res_id'] = $ticket['start_res_id'];
  410. $station_arr[$ticket['end_area_id']][$ticket['start_res_id']]['start_res_name'] = $ticket['start_res_name'];
  411. $station_arr[$ticket['end_area_id']][$ticket['start_res_id']]['end_station_list'][] = [
  412. 'end_res_id' => $ticket['end_res_id'],
  413. 'end_res_name' => $ticket['end_res_name']
  414. ];
  415. }
  416. }
  417. }
  418. }
  419. if ($params['other_poi'] == 0) {
  420. $tmp_prod_arr = reset($prod_arr);
  421. $params['other_poi'] = $tmp_prod_arr['poi_id'];
  422. }
  423. $station_start_list = [];
  424. $station_end_list = [];
  425. //处理站点数组
  426. foreach ($station_arr as $key => $val) {
  427. if ($key == $params['other_poi']) {
  428. foreach ($val as $v) {
  429. $station_start_list[$v['start_res_id']] = [
  430. 'start_res_id' => $v['start_res_id'],
  431. 'start_res_name' => $v['start_res_name']
  432. ];
  433. foreach ($v['end_station_list'] as $tmp_v) {
  434. $station_end_list[$tmp_v['end_res_id']] = [
  435. 'end_res_id' => $tmp_v['end_res_id'],
  436. 'end_res_name' => $tmp_v['end_res_name'],
  437. ];
  438. }
  439. }
  440. }
  441. }
  442. //返回数组按时间排序
  443. foreach ($prod_arr as $key => $val) {
  444. ksort($prod_arr[$key]['ticket_list']);
  445. $prod_arr[$key]['ticket_list'] = array_values($prod_arr[$key]['ticket_list']);
  446. }
  447. $station_start_list = array_values($station_start_list);
  448. $station_end_list = array_values($station_end_list);
  449. $baseArea = new BaseArea();
  450. $poiInfo = $baseArea::findOne($params['poi']);
  451. $poiName = str_replace('市', '', $poiInfo['AREA_NAME']);
  452. $poiName = str_replace('唐老鸭停车场', '', $poiName);
  453. return Util::returnArrSu('', ['ticket' => array_values($prod_arr), 'poi_name' => $poiName, 'station' => ['start_station_list' => $station_start_list, 'end_station_list' => $station_end_list]]);
  454. // $result = $prodCate->getBusProdByTicket(453226);
  455. // return Util::returnArrSu('',$result);
  456. // return $all_tickets;
  457. //1、根据poi获取主线路产品信息
  458. //$getProdList = $prodCate->getBusProdByPoi_s($params);
  459. //return Util::returnArrSu('',$getProdList);
  460. /*$runProdList = [];
  461. foreach($getProdList as $endStation=>$endStationVal){
  462. $p1 = $params['poi'];
  463. $p2 = $endStationVal[array_rand($endStationVal,1)]['end_area_id'];
  464. //$getLineRunTime = Bus::getLineRunTimeByPoi($endStationVal[array_rand($endStationVal,1)]['start_area_id'],$p1,$p2,$params['date']);
  465. if ($getLineRunTime['flag'] == false) {
  466. $lineRunTime = [];
  467. } else {
  468. $lineRunTime = [];
  469. $lineRunTimeData = $getLineRunTime['data'];
  470. foreach ($lineRunTimeData as $key => $timeVal) {
  471. $lineRunTime[$timeVal['line_id']] = explode(',', $timeVal['run_time']);
  472. }
  473. }
  474. foreach ($lineRunTime as $key => $val) {
  475. if (empty($getProdList[$endStation][$key])) {
  476. continue;
  477. }
  478. if (empty($val)) {
  479. continue;
  480. }
  481. foreach ($val as $time) {
  482. if (empty($time)) {
  483. continue;
  484. }
  485. //$time:出发时间 $key:line_id
  486. $runProdList[$endStation][$time . $key] = $endStationVal[$key];
  487. $runProdList[$endStation][$time . $key]['run_time'] = $time;
  488. $pas = [
  489. 'date' => $params['date'],//出发时间
  490. 'pro_cate_id' => $runProdList[$endStation][$time . $key]['pro_cate_id'],//产品品类ID
  491. 'if_back' => 0,//是否返程
  492. 'start_poi' => $params['poi'],//上车站POI
  493. 'end_poi' =>$runProdList[$endStation][$time . $key]['end_area_id'],//下车站POI
  494. 'run_time'=> $runProdList[$endStation][$time . $key]['run_time'],//站点时间
  495. ];
  496. $stock = $stock_logic->getLineBusStock($pas);
  497. $runProdList[$endStation][$time . $key]['stock'] = $stock;
  498. }
  499. }
  500. }
  501. ksort($runProdList);
  502. //1、根据poi获取主线路产品信息
  503. $getProdList_e = $prodCate->getBusProdByPoi_e($params);
  504. $runProdList_e = [];
  505. foreach($getProdList_e as $startStation=>$startStationVal){
  506. $p3 = $startStationVal[array_rand($startStationVal,1)]['start_area_id'];
  507. $p4 = $params['poi'];
  508. $getLineRunTime_e = Bus::getLineRunTimeByPoi($p3,$p4,$params['date']);
  509. if ($getLineRunTime_e['flag'] == false) {
  510. $lineRunTime_e = [];
  511. } else {
  512. $lineRunTime_e = [];
  513. $lineRunTimeData_e = $getLineRunTime_e['data'];
  514. foreach ($lineRunTimeData_e as $key => $timeVal) {
  515. $lineRunTime_e[$timeVal['line_id']] = explode(',', $timeVal['run_time']);
  516. }
  517. }
  518. foreach ($lineRunTime_e as $key => $val) {
  519. if (empty($getProdList_e[$startStation][$key])) {
  520. continue;
  521. }
  522. if (empty($val)) {
  523. continue;
  524. }
  525. foreach ($val as $time) {
  526. if (empty($time)) {
  527. continue;
  528. }
  529. //$time:出发时间 $key:line_id
  530. $runProdList_e[$startStation][$time . $key] = $startStationVal[$key];
  531. $runProdList_e[$startStation][$time . $key]['run_time'] = $time;
  532. $pars = [
  533. 'date' => $params['date'],//出发时间
  534. 'pro_cate_id' => $runProdList_e[$startStation][$time . $key]['pro_cate_id'],//产品品类ID
  535. 'if_back' => 0,//是否返程
  536. 'start_poi' => $params['poi'],//上车站POI
  537. 'end_poi' =>$runProdList_e[$startStation][$time . $key]['end_area_id'],//下车站POI
  538. 'run_time'=> $runProdList_e[$startStation][$time . $key]['run_time'],//站点时间
  539. ];
  540. $stock_e = $stock_logic->getLineBusStock($pars);
  541. $runProdList_e[$startStation][$time . $key]['stock'] = $stock_e;
  542. }
  543. }
  544. }
  545. ksort($runProdList_e);
  546. return Util::returnArrSu('', ['Slist' => $runProdList,'Elist'=>$runProdList_e]);*/
  547. /* //2、根据POI获取线路及首站抵达时间
  548. $getLineRunTime = Bus::getLineRunTimeByPoi(791, 3226, $params['date']);
  549. //return $getLineRunTime;
  550. if ($getLineRunTime['flag'] == false) {
  551. $lineRunTime = [];
  552. } else {
  553. $lineRunTime = [];
  554. $lineRunTimeData = $getLineRunTime['data'];
  555. foreach ($lineRunTimeData as $key => $timeVal) {
  556. $lineRunTime[$timeVal['line_id']] = explode(',', $timeVal['run_time']);
  557. }
  558. }
  559. //return Util::returnArrSu('',$lineRunTime);
  560. //3、拼接需要的返回值
  561. $runProdList = [];
  562. foreach ($lineRunTime as $key => $val) {
  563. if (empty($getProdList[$key])) {
  564. continue;
  565. }
  566. if (empty($val)) {
  567. continue;
  568. }
  569. foreach ($val as $time) {
  570. if (empty($time)) {
  571. continue;
  572. }
  573. //$time:出发时间 $key:line_id
  574. $runProdList[$time . $key] = $getProdList[$key];
  575. $runProdList[$time . $key]['run_time'] = $time;
  576. }
  577. }
  578. ksort($runProdList);
  579. //4、获取推荐产品
  580. //$getRecommendList = $prodCate->getRecommendByPoi($params);*/
  581. }
  582. /**
  583. * Function Description:处理价格
  584. * Function Name: dealFloat
  585. * @param $float
  586. *
  587. * @return float
  588. *
  589. * @author LUOCJ
  590. */
  591. public function dealFloat($float)
  592. {
  593. $int = floor($float);
  594. if ($float - $int == 0) {
  595. $float = $int;
  596. }
  597. return $float;
  598. }
  599. /**
  600. * Function Description:获取最新有班次的日期
  601. * Function Name: getNewRunDate
  602. * @param $params
  603. *
  604. * @return false|string
  605. *
  606. * @author 娄梦宁
  607. */
  608. public function getNewRunDate($params)
  609. {
  610. #数据第一次请求,去后台拿cs最新的数据
  611. if ($params['init_flag'] == 0) {
  612. $stock_logic = new Bus();
  613. if ($params['cate_id'] == 1) {
  614. for ($i = 0; $i < 7; $i++) {
  615. $tmp_date = date('Y-m-d', strtotime('+' . $i . ' day', strtotime($params['date'])));
  616. $all_tickets = $stock_logic->getGoBusStockForArea('', $params['poi'], $tmp_date);
  617. if ($all_tickets['flag'] && count($all_tickets['data']) != 0) {
  618. return $tmp_date;
  619. }
  620. }
  621. }
  622. if ($params['cate_id'] == 2) {
  623. for ($i = 0; $i < 7; $i++) {
  624. $tmp_date = date('Y-m-d', strtotime('+' . $i . 'day', strtotime($params['date'])));
  625. $all_tickets = $stock_logic->getGoBusStockForArea($params['poi'], '', $tmp_date);
  626. if ($all_tickets['flag'] && count($all_tickets['data']) != 0) {
  627. return $tmp_date;
  628. }
  629. }
  630. }
  631. }
  632. return $params['date'];
  633. }
  634. }