|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674 |
- <?php
- /**
- *
- * ============================================================================
- * * 版权所有 蜘蛛出行 * *
- * 网站地址: http://www.zhizhuchuxing.com
- * ----------------------------------------------------------------------------
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
- * 使用;不允许对程序代码以任何形式任何目的的再发布。
- * ============================================================================
- * Author By: 倪宗锋
- * PhpStorm Home.php
- * Create By 2017/6/20 19:47 $
- */
-
- namespace zzcx\service\home;
-
- use common\models\BaseArea;
- use common\models\BusTicket;
- use common\models\CmsCategoryExtra;
- use common\models\CmsCategoryProd;
- use common\models\ProdCategory;
- use common\util\Util;
- use common\util\zh2py;
-
- class Home
- {
-
- /**
- * Des:获取热门搜索
- * Name: getHost
- * @return array
- * @author 倪宗锋
- */
- public function getHost()
- {
- $getHomeConfig = require APP_PATH . '/config/home_' . YII_ENV . '_config.php';
- return explode(',', $getHomeConfig['hot_search']);
- }
-
- /**
- * Des:获取搜索列表
- * Name: search
- * @param $param
- * @return array
- * @author 倪宗锋
- */
- public function search($param)
- {
- if (empty($param['prod_name'])) {
- return Util::returnArrSu('', ['list' => []], '', '1000');
- }
- $param['prod_name'] = str_replace([' ', '-'], '%', trim($param['prod_name']));
- $prodCate = new ProdCategory();
- $touristList = $prodCate->getSearchList($param, 4);
- if (empty($touristList['0'])) {
- $touristList = [];
- }
- $menPList = $prodCate->getSearchList($param, 2);
- if (empty($menPList['0'])) {
- $menPList = [];
- }
- $cms_category_extra = new CmsCategoryExtra();
- $destination_list = $cms_category_extra->getAllInfo($param['prod_name']);
- $destination = [];
- foreach ($destination_list as $val) {
- $destination[] = [
- 'category_id' => 100,
- 'pro_cate_name' => $val['category_name'],
- 'pro_cate_id' => $val['category_id'],
- ];
- }
- $list = [];
- if (count($touristList) > 0) {
- foreach ($touristList as $key => $val) {
- $touristList[$key]['pro_cate_name'] = str_replace('>', '>', $val['pro_cate_name']);
- }
- $list[] = [
- 'cate_id' => 4,
- 'cate_name' => '巴士自由行',
- 'list' => $touristList
- ];
- }
- if (count($menPList) > 0) {
- $list[] = [
- 'cate_id' => 2,
- 'cate_name' => '景区门票',
- 'list' => $menPList
- ];
- }
- if (count($destination) > 0) {
- $list[] = [
- 'cate_id' => 100,
- 'cate_name' => '热门目的地',
- 'list' => $destination
- ];
- }
- return Util::returnArrSu('', ['list' => $list]);
- }
-
- public function getProdList($prodIds){
- $cms_prod = new CmsCategoryProd();
- $hot_line_list = $cms_prod->getShowProdList($prodIds);
- foreach ($hot_line_list as &$v) {
- $v['show_price'] = $this->dealFloat($v['show_price']);
- $v['original_price'] = $this->dealFloat($v['original_price']);
- }
-
- return Util::returnArrSu('', $hot_line_list);
- }
-
- public function getHomeList()
- {
- $config = require APP_PATH . '/config/home_' . YII_ENV . '_config.php';
- $external = empty($config['external_links']) ? [] : $config['external_links'];
- //目的地玩乐
- $cms_category_extra = new CmsCategoryExtra();
- $destination_list = $cms_category_extra->getAllInfo();
- // 景区直通车
- $scenic_through_train = $config['scenic_through_train'];
-
- // 超值热卖 jin_pin
- $cms_prod = new CmsCategoryProd();
- $hot_line_list = $cms_prod->getRecommendList($config['jin_pin']);
- foreach ($hot_line_list as &$v) {
- $v['show_price'] = $this->dealFloat($v['show_price']);
- $v['original_price'] = $this->dealFloat($v['original_price']);
- }
- //滚动banner图
- $banner_list = $config['banner_list'];
- $result = [
- 'banner_list' => $banner_list,
- 'external' => $external,
- 'train' =>
- [
- 'cms_name' => empty($config["scenic_through_train_name"]) ? '景区直通车' : $config["scenic_through_train_name"],
- 'scenic_through_train' => $scenic_through_train
- ],
- "destination" =>[
- 'cms_name' => '目的地玩乐',
- 'destination_list' => $destination_list
- ],
- 'hot_line' =>
- [
- 'cms_name' => '超值热卖',
- 'hot_line_list' => $hot_line_list
- ],
- ];
- return Util::returnArrSu('', $result);
- }
-
-
- /**********************站点选择************************************/
-
- /**
- * Des:获取热门站点
- * Name: getHostStation
- * @param $param
- * @return array
- * @author 倪宗锋
- */
- public function getHotStation($param)
- {
- $busTicket = new BusTicket();
- $param['limit'] = 6;
- $siteConfig = Util::getSiteConfig();
- $param['system'] = $siteConfig['system'];//系统ID
- if ($param['inout_type'] == 'in') {
- $getList = $busTicket->getStartStation($param);//获取出发站点 poi列表
- } else {
- $getList = $busTicket->getEndStation($param);//获取终点站 poi列表
- }
- if (count($getList) == 0) {//空数组则直接返回空数组
- $getList = [];
- }
- $poiType = [
- ['id' => 0, 'name' => '全部'],
- ['id' => 630, 'name' => '城市'],
- ['id' => 405, 'name' => '景区'],
- ['id' => 412, 'name' => '交通枢纽'],
- ['id' => 408, 'name' => '酒店'],
- ];
- return ['hotPoi' => $getList, 'poiType' => $poiType];
- }
-
- /**
- * Des:获取站点列表
- * Name: getStation
- * @param $param
- * @return array
- * @author 倪宗锋
- */
- public function getStation($param)
- {
- if (empty($param['poi_type']) == false && in_array($param['poi_type'], [630, 405, 408, 412]) == false) {
- return [];
- }
- $siteConfig = Util::getSiteConfig();
- $param['system'] = $siteConfig['system'];//系统ID
- $busTicket = new BusTicket();
- if ($param['inout_type'] == 'in') {
- $getList = $busTicket->getStartStation($param);//获取出发站点 poi列表
- } else {
- $getList = $busTicket->getEndStation($param);//获取终点站 poi列表
- }
- if (count($getList) == 0) {//空数组则直接返回空数组
- return [];
- }
- $station_arr = $this->orderByPy($getList, 'name');//非空数组进行首写字母排序
- return $station_arr;
- }
-
- /**
- * Des:获取到结果进行首写字母排序
- * Name: orderByPy
- * @param $arr
- * @param $theKey
- * @return array
- * @author 倪宗锋
- */
- public function orderByPy($arr, $theKey)
- {
- //先根据poiname排序
- $arr1 = array();
- foreach ($arr as $key => $val) {
- $area_name = $val[$theKey];
- $arr1["$area_name"] = $arr["$key"];
- }
- ksort($arr1);
- $arr = array_merge($arr1);
- //排好序的数组再根据poi拼音首字排序
- $newarr = array();
- foreach ($arr as $val) {
- $shouzi = mb_substr(trim($val[$theKey]), 0, 1, 'utf-8');
- if (Util::checkPattern('', $shouzi, '/^[\x{4e00}-\x{9fa5}]$/u') == false) {
- $FirstPy = $shouzi;
- } else {
- $py = new zh2py();
- $FirstPy = $py::conv($shouzi);
- $FirstPy = substr($FirstPy, 0, 1);
- }
- $val['first_py'] = $FirstPy;
- $newarr["$FirstPy"][] = $val;
- }
- ksort($newarr);
- return $newarr;
- }
-
-
- /**************站点选择结束*****************************/
-
- /**
- * Des:根据poi获取产品信息
- * Name: getProdByPoi
- * @param $params
- * @return array
- * @author 倪宗锋
- */
- public function getProdByPoi($params)
- {
- //参数校验
- if (Util::checkPattern('intVal', $params['poi']) == false) {
- return Util::returnArrEr('请选择站点');
- }
-
- if ($params['cate_id'] != 1 && $params['cate_id'] != 2) {
- return Util::returnArrEr('参数有误');
- }
- $prodCate = new ProdCategory();
- $stock_logic = new Bus();
- if ($params['cate_id'] == 1) {
- $all_tickets = $stock_logic->getGoBusStockForArea('', $params['poi'], $params['date']);
- $prod_arr = [];
- $station_arr = [];
- $data = $all_tickets['data'];
- if (empty($data)) {
- $data = [];
- }
- foreach ($data as $run_id => $run_tickets) {
- foreach ($run_tickets['ticket_list'] as $ticket_id => $ticket_info) {
- $ticket = $prodCate->getBusProdByTicket($ticket_id);
- if ($ticket == null) {
- continue;
- }
- if (strtotime(date('Y-m-d') . ' ' . $ticket_info['start_time']) > time() || strtotime($params['date']) > time()) {
- $tmp_time_sort = strtotime(date('Y-m-d') . ' ' . $ticket_info['start_time']);
- $tmp_rand = rand(999, 9999);
- while (isset($prod_arr[$ticket['end_area_id']]['ticket_list'][$tmp_time_sort . $tmp_rand])) {
- $tmp_rand = rand(999, 9999);
- }
- $tmp_is_delay = 0;
- } else {
- $tmp_time_sort = strtotime('+1 day', strtotime(date('Y-m-d') . ' ' . $ticket_info['start_time']));
- $tmp_rand = rand(999, 9999);
- while (isset($prod_arr[$ticket['end_area_id']]['ticket_list'][$tmp_time_sort . $tmp_rand])) {
- $tmp_rand = rand(999, 9999);
- }
- $tmp_is_delay = 1;
- }
- $ticket_info['prod_num'] = intval($ticket_info['prod_num']);
- if (array_key_exists($ticket['start_area_id'], $prod_arr)) {
- $prod_arr[$ticket['start_area_id']]['ticket_list'][$tmp_time_sort . $tmp_rand] = [
- 'ticket_id' => $ticket_id,
- 'prod_num' => $ticket_info['prod_num'] >= 20 ? '余票充足' : ($ticket_info['prod_num'] == 0 ? '已售完' : $ticket_info['prod_num'] . '张'),
- 'start_time' => $ticket_info['start_time'],
- 'start_res_name' => $ticket['start_res_name'],
- 'end_res_name' => $ticket['end_res_name'],
- 'start_res_id' => $ticket['start_res_id'],
- 'end_res_id' => $ticket['end_res_id'],
- 'show_price' => $ticket['show_price'],
- 'start_area_name' => $ticket['start_area_name'],
- 'end_area_name' => $ticket['end_area_name'],
- 'start_area_id' => $ticket['start_area_id'],
- 'end_area_id' => $ticket['end_area_id'],
- 'prod_cate_id' => $ticket['pro_cate_id'],
- 'run_id' => $run_id,
- 'is_delay' => $tmp_is_delay,
- 'ticket_cnt' => $ticket_info['prod_num']
- ];
-
- } else {
- $prod_arr[$ticket['start_area_id']]['poi_id'] = $ticket['start_area_id'];
- $prod_arr[$ticket['start_area_id']]['poi_name'] = str_replace('市', '', $ticket['start_area_name']) . '出发';
- $prod_arr[$ticket['start_area_id']]['ticket_list'][$tmp_time_sort . $tmp_rand] = [
- 'ticket_id' => $ticket_id,
- 'prod_num' => $ticket_info['prod_num'] >= 20 ? '余票充足' : ($ticket_info['prod_num'] == 0 ? '已售完' : $ticket_info['prod_num'] . '张'),
- 'start_time' => $ticket_info['start_time'],
- 'start_res_name' => $ticket['start_res_name'],
- 'end_res_name' => $ticket['end_res_name'],
- 'start_res_id' => $ticket['start_res_id'],
- 'end_res_id' => $ticket['end_res_id'],
- 'show_price' => $ticket['show_price'],
- 'start_area_name' => $ticket['start_area_name'],
- 'end_area_name' => $ticket['end_area_name'],
- 'start_area_id' => $ticket['start_area_id'],
- 'end_area_id' => $ticket['end_area_id'],
- 'prod_cate_id' => $ticket['pro_cate_id'],
- 'run_id' => $run_id,
- 'is_delay' => $tmp_is_delay,
- 'ticket_cnt' => $ticket_info['prod_num']
- ];
- }
- if (array_key_exists($ticket['start_area_id'], $station_arr) && array_key_exists($ticket['start_res_id'], $station_arr[$ticket['start_area_id']])) {
- $station_arr[$ticket['start_area_id']][$ticket['start_res_id']]['end_station_list'][] = [
- 'end_res_id' => $ticket['end_res_id'],
- 'end_res_name' => $ticket['end_res_name']
-
- ];
- } else {
- $station_arr[$ticket['start_area_id']][$ticket['start_res_id']]['start_res_id'] = $ticket['start_res_id'];
- $station_arr[$ticket['start_area_id']][$ticket['start_res_id']]['start_res_name'] = $ticket['start_res_name'];
- $station_arr[$ticket['start_area_id']][$ticket['start_res_id']]['end_station_list'][] = [
- 'end_res_id' => $ticket['end_res_id'],
- 'end_res_name' => $ticket['end_res_name']
- ];
- }
- }
- }
- } else {
- $all_tickets = $stock_logic->getGoBusStockForArea($params['poi'], '', $params['date']);
-
- $prod_arr = [];
- $station_arr = [];
- foreach ($all_tickets['data'] as $run_id => $run_tickets) {
- foreach ($run_tickets['ticket_list'] as $ticket_id => $ticket_info) {
- $ticket = $prodCate->getBusProdByTicket($ticket_id);
- if ($ticket == null) {
- continue;
- }
- if (strtotime(date('Y-m-d') . ' ' . $ticket_info['start_time']) > time() || strtotime($params['date']) > time()) {
- $tmp_time_sort = strtotime(date('Y-m-d') . ' ' . $ticket_info['start_time']);
- $tmp_rand = rand(999, 9999);
- while (isset($prod_arr[$ticket['end_area_id']]['ticket_list'][$tmp_time_sort . $tmp_rand])) {
- $tmp_rand = rand(999, 9999);
- }
- $tmp_is_delay = 0;
- } else {
- $tmp_time_sort = strtotime('+1 day', strtotime(date('Y-m-d') . ' ' . $ticket_info['start_time']));
- $tmp_rand = rand(999, 9999);
- while (isset($prod_arr[$ticket['end_area_id']]['ticket_list'][$tmp_time_sort . $tmp_rand])) {
- $tmp_rand = rand(999, 9999);
- }
- $tmp_is_delay = 1;
- }
- if (array_key_exists($ticket['end_area_id'], $prod_arr)) {
-
- $prod_arr[$ticket['end_area_id']]['ticket_list'][$tmp_time_sort . $tmp_rand] = [
- 'ticket_id' => $ticket_id,
- 'prod_num' => $ticket_info['prod_num'] >= 20 ? '余票充足' : $ticket_info['prod_num'] . '张',
- 'start_time' => $ticket_info['start_time'],
- 'start_res_name' => $ticket['start_res_name'],
- 'end_res_name' => $ticket['end_res_name'],
- 'start_res_id' => $ticket['start_res_id'],
- 'end_res_id' => $ticket['end_res_id'],
- 'show_price' => $ticket['show_price'],
- 'start_area_name' => $ticket['start_area_name'],
- 'end_area_name' => $ticket['end_area_name'],
- 'start_area_id' => $ticket['start_area_id'],
- 'end_area_id' => $ticket['end_area_id'],
- 'prod_cate_id' => $ticket['pro_cate_id'],
- 'run_id' => $run_id,
- 'is_delay' => $tmp_is_delay,
- ];
- } else {
- $prod_arr[$ticket['end_area_id']]['poi_id'] = $ticket['end_area_id'];
- $prod_arr[$ticket['end_area_id']]['poi_name'] = '去' . str_replace('市', '', $ticket['end_area_name']);
- $prod_arr[$ticket['end_area_id']]['ticket_list'][$tmp_time_sort . $tmp_rand] = [
- 'ticket_id' => $ticket_id,
- 'prod_num' => $ticket_info['prod_num'] >= 20 ? '余票充足' : $ticket_info['prod_num'] . '张',
- 'start_time' => $ticket_info['start_time'],
- 'start_res_name' => $ticket['start_res_name'],
- 'end_res_name' => $ticket['end_res_name'],
- 'start_res_id' => $ticket['start_res_id'],
- 'end_res_id' => $ticket['end_res_id'],
- 'show_price' => $ticket['show_price'],
- 'start_area_name' => $ticket['start_area_name'],
- 'end_area_name' => $ticket['end_area_name'],
- 'start_area_id' => $ticket['start_area_id'],
- 'end_area_id' => $ticket['end_area_id'],
- 'prod_cate_id' => $ticket['pro_cate_id'],
- 'run_id' => $run_id,
- 'is_delay' => $tmp_is_delay,
- ];
- }
-
- if (array_key_exists($ticket['end_area_id'], $station_arr) && array_key_exists($ticket['start_res_id'], $station_arr[$ticket['end_area_id']])) {
- $station_arr[$ticket['end_area_id']][$ticket['start_res_id']]['end_station_list'][] = [
- 'end_res_id' => $ticket['end_res_id'],
- 'end_res_name' => $ticket['end_res_name']
-
- ];
- } else {
- $station_arr[$ticket['end_area_id']][$ticket['start_res_id']]['start_res_id'] = $ticket['start_res_id'];
- $station_arr[$ticket['end_area_id']][$ticket['start_res_id']]['start_res_name'] = $ticket['start_res_name'];
- $station_arr[$ticket['end_area_id']][$ticket['start_res_id']]['end_station_list'][] = [
- 'end_res_id' => $ticket['end_res_id'],
- 'end_res_name' => $ticket['end_res_name']
- ];
-
- }
- }
- }
- }
- if ($params['other_poi'] == 0) {
- $tmp_prod_arr = reset($prod_arr);
- $params['other_poi'] = $tmp_prod_arr['poi_id'];
- }
- $station_start_list = [];
- $station_end_list = [];
- //处理站点数组
- foreach ($station_arr as $key => $val) {
- if ($key == $params['other_poi']) {
- foreach ($val as $v) {
- $station_start_list[$v['start_res_id']] = [
- 'start_res_id' => $v['start_res_id'],
- 'start_res_name' => $v['start_res_name']
- ];
- foreach ($v['end_station_list'] as $tmp_v) {
- $station_end_list[$tmp_v['end_res_id']] = [
- 'end_res_id' => $tmp_v['end_res_id'],
- 'end_res_name' => $tmp_v['end_res_name'],
- ];
- }
- }
- }
- }
- //返回数组按时间排序
- foreach ($prod_arr as $key => $val) {
- ksort($prod_arr[$key]['ticket_list']);
- $prod_arr[$key]['ticket_list'] = array_values($prod_arr[$key]['ticket_list']);
- }
- $station_start_list = array_values($station_start_list);
- $station_end_list = array_values($station_end_list);
- $baseArea = new BaseArea();
- $poiInfo = $baseArea::findOne($params['poi']);
- $poiName = str_replace('市', '', $poiInfo['AREA_NAME']);
- $poiName = str_replace('唐老鸭停车场', '', $poiName);
- return Util::returnArrSu('', ['ticket' => array_values($prod_arr), 'poi_name' => $poiName, 'station' => ['start_station_list' => $station_start_list, 'end_station_list' => $station_end_list]]);
-
- // $result = $prodCate->getBusProdByTicket(453226);
- // return Util::returnArrSu('',$result);
- // return $all_tickets;
-
- //1、根据poi获取主线路产品信息
- //$getProdList = $prodCate->getBusProdByPoi_s($params);
- //return Util::returnArrSu('',$getProdList);
- /*$runProdList = [];
- foreach($getProdList as $endStation=>$endStationVal){
- $p1 = $params['poi'];
- $p2 = $endStationVal[array_rand($endStationVal,1)]['end_area_id'];
- //$getLineRunTime = Bus::getLineRunTimeByPoi($endStationVal[array_rand($endStationVal,1)]['start_area_id'],$p1,$p2,$params['date']);
-
- if ($getLineRunTime['flag'] == false) {
- $lineRunTime = [];
- } else {
- $lineRunTime = [];
- $lineRunTimeData = $getLineRunTime['data'];
- foreach ($lineRunTimeData as $key => $timeVal) {
- $lineRunTime[$timeVal['line_id']] = explode(',', $timeVal['run_time']);
- }
- }
-
- foreach ($lineRunTime as $key => $val) {
- if (empty($getProdList[$endStation][$key])) {
- continue;
- }
- if (empty($val)) {
- continue;
- }
- foreach ($val as $time) {
- if (empty($time)) {
- continue;
- }
- //$time:出发时间 $key:line_id
- $runProdList[$endStation][$time . $key] = $endStationVal[$key];
- $runProdList[$endStation][$time . $key]['run_time'] = $time;
- $pas = [
- 'date' => $params['date'],//出发时间
- 'pro_cate_id' => $runProdList[$endStation][$time . $key]['pro_cate_id'],//产品品类ID
- 'if_back' => 0,//是否返程
- 'start_poi' => $params['poi'],//上车站POI
- 'end_poi' =>$runProdList[$endStation][$time . $key]['end_area_id'],//下车站POI
- 'run_time'=> $runProdList[$endStation][$time . $key]['run_time'],//站点时间
- ];
- $stock = $stock_logic->getLineBusStock($pas);
- $runProdList[$endStation][$time . $key]['stock'] = $stock;
- }
- }
-
- }
- ksort($runProdList);
-
- //1、根据poi获取主线路产品信息
- $getProdList_e = $prodCate->getBusProdByPoi_e($params);
-
- $runProdList_e = [];
- foreach($getProdList_e as $startStation=>$startStationVal){
- $p3 = $startStationVal[array_rand($startStationVal,1)]['start_area_id'];
- $p4 = $params['poi'];
- $getLineRunTime_e = Bus::getLineRunTimeByPoi($p3,$p4,$params['date']);
-
- if ($getLineRunTime_e['flag'] == false) {
- $lineRunTime_e = [];
- } else {
- $lineRunTime_e = [];
- $lineRunTimeData_e = $getLineRunTime_e['data'];
- foreach ($lineRunTimeData_e as $key => $timeVal) {
- $lineRunTime_e[$timeVal['line_id']] = explode(',', $timeVal['run_time']);
- }
- }
-
- foreach ($lineRunTime_e as $key => $val) {
- if (empty($getProdList_e[$startStation][$key])) {
- continue;
- }
- if (empty($val)) {
- continue;
- }
- foreach ($val as $time) {
- if (empty($time)) {
- continue;
- }
- //$time:出发时间 $key:line_id
- $runProdList_e[$startStation][$time . $key] = $startStationVal[$key];
- $runProdList_e[$startStation][$time . $key]['run_time'] = $time;
- $pars = [
- 'date' => $params['date'],//出发时间
- 'pro_cate_id' => $runProdList_e[$startStation][$time . $key]['pro_cate_id'],//产品品类ID
- 'if_back' => 0,//是否返程
- 'start_poi' => $params['poi'],//上车站POI
- 'end_poi' =>$runProdList_e[$startStation][$time . $key]['end_area_id'],//下车站POI
- 'run_time'=> $runProdList_e[$startStation][$time . $key]['run_time'],//站点时间
- ];
- $stock_e = $stock_logic->getLineBusStock($pars);
- $runProdList_e[$startStation][$time . $key]['stock'] = $stock_e;
- }
- }
-
- }
- ksort($runProdList_e);
-
- return Util::returnArrSu('', ['Slist' => $runProdList,'Elist'=>$runProdList_e]);*/
- /* //2、根据POI获取线路及首站抵达时间
- $getLineRunTime = Bus::getLineRunTimeByPoi(791, 3226, $params['date']);
- //return $getLineRunTime;
- if ($getLineRunTime['flag'] == false) {
- $lineRunTime = [];
- } else {
- $lineRunTime = [];
- $lineRunTimeData = $getLineRunTime['data'];
- foreach ($lineRunTimeData as $key => $timeVal) {
- $lineRunTime[$timeVal['line_id']] = explode(',', $timeVal['run_time']);
- }
- }
-
- //return Util::returnArrSu('',$lineRunTime);
- //3、拼接需要的返回值
- $runProdList = [];
- foreach ($lineRunTime as $key => $val) {
- if (empty($getProdList[$key])) {
- continue;
- }
- if (empty($val)) {
- continue;
- }
- foreach ($val as $time) {
- if (empty($time)) {
- continue;
- }
- //$time:出发时间 $key:line_id
- $runProdList[$time . $key] = $getProdList[$key];
- $runProdList[$time . $key]['run_time'] = $time;
- }
- }
- ksort($runProdList);
-
- //4、获取推荐产品
- //$getRecommendList = $prodCate->getRecommendByPoi($params);*/
- }
-
- /**
- * Function Description:处理价格
- * Function Name: dealFloat
- * @param $float
- *
- * @return float
- *
- * @author LUOCJ
- */
- public function dealFloat($float)
- {
- $int = floor($float);
- if ($float - $int == 0) {
- $float = $int;
- }
- return $float;
- }
-
- /**
- * Function Description:获取最新有班次的日期
- * Function Name: getNewRunDate
- * @param $params
- *
- * @return false|string
- *
- * @author 娄梦宁
- */
- public function getNewRunDate($params)
- {
- #数据第一次请求,去后台拿cs最新的数据
- if ($params['init_flag'] == 0) {
- $stock_logic = new Bus();
- if ($params['cate_id'] == 1) {
- for ($i = 0; $i < 7; $i++) {
- $tmp_date = date('Y-m-d', strtotime('+' . $i . ' day', strtotime($params['date'])));
- $all_tickets = $stock_logic->getGoBusStockForArea('', $params['poi'], $tmp_date);
- if ($all_tickets['flag'] && count($all_tickets['data']) != 0) {
- return $tmp_date;
- }
- }
- }
- if ($params['cate_id'] == 2) {
- for ($i = 0; $i < 7; $i++) {
- $tmp_date = date('Y-m-d', strtotime('+' . $i . 'day', strtotime($params['date'])));
- $all_tickets = $stock_logic->getGoBusStockForArea($params['poi'], '', $tmp_date);
- if ($all_tickets['flag'] && count($all_tickets['data']) != 0) {
- return $tmp_date;
- }
- }
- }
- }
- return $params['date'];
- }
- }
|