100], [['station_address'], 'string', 'max' => 200], [['start_time'], 'string', 'max' => 10], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id' => '主键,自增ID', 'itinerary_id' => '行程ID', 'create_time' => 'Create Time', 'create_user_id' => 'Create User ID', 'update_user_id' => 'Update User ID', 'update_time' => '记录最后更新时间', 'cancel_flag' => 'Cancel Flag', 'station_res_id' => '站点ID', 'station_seq_id' => '站点顺序', 'station_name' => '站点名称', 'station_address' => '站点地址', 'Longitude' => '经度', 'Latitude' => '纬度', 'inout_type' => '上下客类型', 'day_seq_id' => '行程中的第几天', 'start_time' => '出发/到达时间', ]; } /** * Function Description:获取行程详情 * Function Name: getStationInfo * @param $itinerary_id * * @return array|bool|\yii\db\ActiveRecord[] * * @author 张帅 */ public function getStationInfo($itinerary_id) { $result = self::find() ->select([ 'station_order_id' => 's.station_seq_id',//顺序 's.day_seq_id',//天数 's.start_time',//出发时间 'station_id' => 'station_res_id',//站点id 'station_inout_type' => 's.inout_type',//上下车类型 'station_name',//站点名称 'station_address',//详细地址 'latitude',//经度 'longitude',//纬度 ]) ->from(self::tableName() . ' as s') ->where(['and', ['=', 's.itinerary_id', $itinerary_id]]) ->orderBy(['station_order_id' => SORT_ASC]) ->asArray()->all(); if (count($result) == 0) { return false; } else { $return_result = array(); foreach( $result as $station_info ) { $new_position = $this->bd_decrypt($station_info["longitude"],$station_info["latitude"]); $station_info["longitude"] = $new_position["gg_lon"]; $station_info["latitude"] = $new_position["gg_lat"]; if( $station_info["station_inout_type"] == 114 ) { $station_info["station_name"] = "【不停靠】".$station_info["station_name"]; } $return_result[] = $station_info; } return $return_result; } } /** * Function Description:百度地图坐标转换成高德地图坐标 * Function Name: bd_decrypt * @param $itinerary_id * * @return array|bool|\yii\db\ActiveRecord[] * * @author Redstop */ function bd_decrypt($bd_lon,$bd_lat) { $x_pi = 3.14159265358979324 * 3000.0 / 180.0; $x = $bd_lon - 0.0065; $y = $bd_lat - 0.006; $z = sqrt($x * $x + $y * $y) - 0.00002 * sin($y * $x_pi); $theta = atan2($y, $x) - 0.000003 * cos($x * $x_pi); $data['gg_lon'] = $z * cos($theta); $data['gg_lat'] = $z * sin($theta); return $data; } }