V1.php
<?php
namespace app\evcs\controller;
use app\evcs\library\utils\AesUtil;
use app\evcs\model\CustomerOperator;
use Firebase\JWT\JWT;
use think\Cache;
use think\Exception;
use think\Request;
class V1 extends Base
{
protected $noNeedLogin = ['query_token'];
protected $config = [];
/**
* 分布式认证接口
* @return void
*/
public function query_token(){
$params = $this->request->post();
$operator_id = $params['OperatorID'];
$operatorInfo = CustomerOperator::getInfo($operator_id);
if (!$operatorInfo){
$this->error('无此运营商',['OperatorID'=>$operator_id,'SuccStat'=>1,'FailReason'=>1]);
}
$this->config = $operatorInfo;
$data = json_decode(AesUtil::decrypt($params['Data'], $operatorInfo['data_secret'], $operatorInfo['data_secret_iv']),true);
if (!$data){
$this->error('密钥错误',['OperatorID'=>$operator_id,'SuccStat'=>1,'FailReason'=>3]);
}
if ($data['OperatorSecret'] != $operatorInfo['operator_secret']){
$this->error('密钥错误',['OperatorID'=>$operator_id,'SuccStat'=>1,'FailReason'=>2]);
}
try {
$result = CustomerOperator::queryToken($data);
$this->success('ok',$result);
}catch (Exception $e){
$this->error($e->getMessage());
}
}
// 贵州省平台
/**
* 2.2.1 查询运营商信息
* 此接口用于主动查询服务运营商、设备所属方的信息。
* @return void
*/
public function supervise_query_operator_info(){
$params = $this->getRequestData();
try {
$result = CustomerOperator::superviseQueryOperatorInfo($params);
$this->success('ok',$result);
}catch (Exception $e){
$this->error($e->getMessage());
}
}
// 102.2 部分
/**
* 6.2
* 查询充电站接口
* 此接口用于查询运营商的充电站信息
* 接口使用方法:由基础设施运营商方实现此接口,数据需求方调用。
* 查询时需要比对电站、充电设备、充电接口的基本信息的最后修改时间,三者只要有一处修改,就认为是最新修改时间,然后与输入参数lastQueryTime进行对比。
* @return void
*/
public function query_stations_info(){
$params = $this->getRequestData();
try {
$result = CustomerOperator::getStationsInfo($params);
$this->success('ok',$result);
}catch (Exception $e){
$this->error($e->getMessage());
}
}
// 贵州省平台
/**
* 2.2.2 查询充换电站信息
* 此接口用于主动查询充换电站信息、充电设备信息、充电设备接口信息。
* @return void
*/
public function supervise_query_stations_info(){
$params = $this->getRequestData();
try {
$result = CustomerOperator::superviseQueryStationsInfo($params);
$this->success('ok',$result);
}catch (Exception $e){
$this->error($e->getMessage());
}
}
/**
* 推送充电站接口
* @return void
*/
public function notification_stationInfo(){
$params = $this->getRequestData();
try {
$result = CustomerOperator::notificationStationsInfo($params);
$this->success('ok',$result);
}catch (Exception $e){
$this->error($e->getMessage());
}
}
/**
* 6.3
* 设备状态变化推送
* 当设备状态发生变化时,推送最新的状态
* 接口使用方法:由数据需求方实现此接口,基础设施运营商方调用。
* @return void
*/
public function notification_stationStatus(){
$params = $this->getRequestData();
try {
$result = CustomerOperator::notificationStationStatus($params);
$this->success('ok',$result);
}catch (Exception $e){
$this->error($e->getMessage());
}
}
/**
* 6.4
* 设备接口状态查询接口
* 此接口用于批量查询设备实时状态。
* 接口使用方法:由基础设施运营商方实现此接口,数据需求方调用
* @return void
*/
public function query_station_status(){
$params = $this->getRequestData();
try {
$result = CustomerOperator::getStationStatus($params);
$this->success('ok',$result);
}catch (Exception $e){
$this->error($e->getMessage());
}
}
// 贵州省平台
/**
* 2.2.7 查询充电站状态信息
* 此接口用于数据需求方批量查询数据提供方的充换电站状态信息。
* @return void
*/
public function supervise_query_station_status(){
$params = $this->getRequestData();
try {
$result = CustomerOperator::superviseQueryStationStatus($params);
$this->success('ok',$result);
}catch (Exception $e){
$this->error($e->getMessage());
}
}
/**
* 6.5
* 查询统计信息接口
* 此查询用于定期获取每个充电站,在某个周期内的统计信息。
* 接口使用方法:由基础设施运营商方实现此接口,数据需求方调用。
* @return void
*/
public function query_station_stats(){
$params = $this->getRequestData();
try {
$result = CustomerOperator::getStationStats($params);
$this->success('ok',$result);
}catch (Exception $e){
$this->error($e->getMessage());
}
}
// 102.3 部分
/**
* 6.2
* 请求设备认证
* 此接口用于客户归属运营商请求充电基础设施的认证信息。
* @return void
*/
public function query_equip_auth(){
$params = $this->getRequestData();
try {
$result = CustomerOperator::queryEquipAuth($params);
$this->success('ok',$result);
}catch (Exception $e){
$this->error($e->getMessage());
}
}
/**
* 6.3
* 查询业务策略信息结果
* 此接口用于设备归属运营商(客户归属运营商)向客户归属运营商(设备归属运营商)查询充电桩业务策略信息。
* @return void
*/
public function query_equip_business_policy(){
$params = $this->getRequestData();
try {
$result = CustomerOperator::queryEquipBusinessPolicy($params);
$this->success('ok',$result);
}catch (Exception $e){
$this->error($e->getMessage());
}
}
/**
* 6.4
* 请求启动充电
* 此接口用于客户归属运营商请求设备归属运营商启动充电信息,充电模式为充满为止。
* @return void
*/
public function query_start_charge(){
$params = $this->getRequestData();
try {
$result = CustomerOperator::queryStartCharge($params);
$this->success('ok',$result);
}catch (Exception $e){
$this->error($e->getMessage());
}
}
/**
* 6.5
* 推送启动充电结果
* 此接口用于设备归属运营商向客户归属运营商推送启动充电结果信息。
* 接口使用方法:由客户归属运营商服务平台实现此接口,基础设施运营商服务平台方调用。
* @return void
*/
public function notification_start_charge_result(){
$params = $this->getRequestData();
try {
$result = CustomerOperator::notificationStartChargeResult($params);
$this->success('ok',$result);
}catch (Exception $e){
$this->error($e->getMessage());
}
}
/**
* 6.6
* 查询充电状态
* 此接口用于客户归属运营商请求设备归属运营商充电设备的状态信息。
* 接口使用方法:由基础设施运营商服务平台实现此接口,客户归属运营商服务平台方调用。
* @return void
*/
public function query_equip_charge_status(){
$params = $this->getRequestData();
try {
$result = CustomerOperator::queryEquipChargeStatus($params);
$this->success('ok',$result);
}catch (Exception $e){
$this->error($e->getMessage());
}
}
/**
* 6.7 推送充电状态
* 此接口用于设备归属运营商向客户归属运营商推送充电设备的充电状态。
* 接口使用方法:由客户归属运营商服务平台实现此接口,基础设施运营商服务平台方调用。
* @return void
* @throws Exception
*/
public function notification_equip_charge_status(){
$params = $this->getRequestData();
try {
$result = CustomerOperator::notificationEquipChargeStatus($params);
$this->success('ok',$result);
}catch (Exception $e){
$this->error($e->getMessage());
}
}
/**
* 6.8
* 请求停止充电
* 此接口用于客户归属运营商请求设备归属运营商设备停止充电信息。
* @return void
*/
public function query_stop_charge(){
$params = $this->getRequestData();
try {
$result = CustomerOperator::queryStopCharge($params);
$this->success('ok',$result);
}catch (Exception $e){
$this->error($e->getMessage());
}
}
/**
* 6.9 推送停止充电结果
* 此接口用于设备归属运营商向客户归属运营商推送启动充电结果信息。
* 由客户归属运营商平台实现此接口,设备归属运营商平台方调用。
* @return void
*/
public function notification_stop_charge_result(){
$params = $this->getRequestData();
try {
$result = CustomerOperator::notificationStopChargeResult($params);
$this->success('ok',$result);
}catch (Exception $e){
$this->error($e->getMessage());
}
}
/**
* 6.10 推送充电订单信息
* 此接口用于设备归属运营商向客户归属运营商推送充电订单信息
* 由客户归属运营商平台实现此接口,设备归属运营商平台方调用
* @return void
*/
public function notification_charge_order_info(){
$params = $this->getRequestData();
try {
$result = CustomerOperator::notificationChargeOrderInfo($params);
$this->success('ok',$result);
}catch (Exception $e){
$this->error($e->getMessage());
}
}
/**
* 6.11 推送订单对账结果信息
* 此接口用于设备归属运营商向客户归属运营商推送充电订单对账信息。
* 由客户归属运营商平台实现此接口,设备归属运营商平台方调用。
* @return void
* @throws Exception
*/
public function check_charge_orders(){
$params = $this->getRequestData();
try {
$result = CustomerOperator::checkChargeOrders($params);
$this->success('ok',$result);
}catch (Exception $e){
$this->error($e->getMessage());
}
}
public function supervise_query_accident_info(){
$params = $this->getRequestData();
try {
$result = CustomerOperator::superviseQueryAccidentInfo($params);
$this->success('ok',$result);
}catch (Exception $e){
$this->error($e->getMessage());
}
}
}