Commit 93410bf8 by banice

修复开始充电无开始用电量问题

parent 29a8f66c
...@@ -357,7 +357,7 @@ class AccessController extends Controller ...@@ -357,7 +357,7 @@ class AccessController extends Controller
} }
$order->setOnlineTime(time()); $order->setOnlineTime(time());
if ($offlineReason == 1) { if ($offlineReason == 0) {
$orderState = new OfflineNetState($order); $orderState = new OfflineNetState($order);
} else { } else {
$orderState = new OfflinePowerState($order); $orderState = new OfflinePowerState($order);
......
...@@ -24,9 +24,9 @@ class StartController extends Controller ...@@ -24,9 +24,9 @@ class StartController extends Controller
'04' => [ '04' => [
'type' => 1, 'type' => 1,
'logic_id' => 1, 'logic_id' => 1,
'state' => 1, 'state' => 1,
'order_id' => 6, 'order_id' => 6,
'capacity' => 4, 'capacity' => 4,
], ],
...@@ -49,9 +49,7 @@ class StartController extends Controller ...@@ -49,9 +49,7 @@ class StartController extends Controller
$this->logRecord->setOrderId($orderId); $this->logRecord->setOrderId($orderId);
$capacity = hexdec($this->getRequest()->get('capacity')); $capacity = hexdec($this->getRequest()->get('capacity'));
Log::debug('order_id-->' . $orderId);
Log::debug($this->getRequest()->get('capacity'));
Log::debug('capacity-->' . $capacity); Log::debug('capacity-->' . $capacity);
if ($type == 1) { if ($type == 1) {
...@@ -87,29 +85,24 @@ class StartController extends Controller ...@@ -87,29 +85,24 @@ class StartController extends Controller
} }
} }
$lastState = $order->getStateCode(); $lastState = $order->getStateCode();
$orderState = new WaitingState($order); $orderState = new WaitingState($order);
// break;
// case StateCode::PORT_CHARGER;
// $orderState = new ChargerState($order);
// break;
//
// }
$portId = $orderState->getOrder()->getPortId(); $portId = $orderState->getOrder()->getPortId();
$this->logRecord->setPortId($portId); $this->logRecord->setPortId($portId);
switch ($state) { switch ($state) {
case StateCode::PORT_CHARGER: case StateCode::PORT_CHARGER:
$orderState->toChargerState(); $orderState->toChargerState();
break; break;
case StateCode::PORT_EXCEPTION: case StateCode::PORT_EXCEPTION:
$orderState->toExceptionState(); $orderState->toExceptionState();
break; break;
case StateCode::PORT_SHED: case StateCode::PORT_SHED:
Log::debug('port_shed');
$orderState->toShedState(); $orderState->toShedState();
break; break;
case StateCode::FINISH_EXCEED: case StateCode::FINISH_EXCEED:
Log::debug('exceed');
$orderState->toPowerExceedState(); $orderState->toPowerExceedState();
break; break;
......
...@@ -111,6 +111,7 @@ class PowerController extends Controller ...@@ -111,6 +111,7 @@ class PowerController extends Controller
public function plural() public function plural()
{ {
//todo 最近的用电量作为结束用电量更新
$logicId = hexdec($this->request->get('logic_id')); $logicId = hexdec($this->request->get('logic_id'));
$startTime = hexdec($this->request->get('start_time')); $startTime = hexdec($this->request->get('start_time'));
$intervalTime = hexdec($this->request->get('interval_time')); $intervalTime = hexdec($this->request->get('interval_time'));
...@@ -170,6 +171,13 @@ class PowerController extends Controller ...@@ -170,6 +171,13 @@ class PowerController extends Controller
]); ]);
$startTime += $intervalTime; $startTime += $intervalTime;
//更新结束充电用电量
if ($i === ($count - 1)) {
$orderModel = new OrderModel();
$orderModel->update([
'end_capacity' => hexdec($capacitys[$i]),
], 'id = ' . $orderId);
}
} }
} else { } else {
......
...@@ -10,6 +10,7 @@ namespace Application\controller\update; ...@@ -10,6 +10,7 @@ namespace Application\controller\update;
use Application\controller\Controller; use Application\controller\Controller;
use Application\model\DeviceModel;
use Application\model\GatewayModel; use Application\model\GatewayModel;
use Application\model\GatewayUpdateModel; use Application\model\GatewayUpdateModel;
use GatewayWorker\Lib\Gateway; use GatewayWorker\Lib\Gateway;
...@@ -23,6 +24,10 @@ class QueryController extends Controller ...@@ -23,6 +24,10 @@ class QueryController extends Controller
'D1' => [ 'D1' => [
'hardware_version' => 4, 'hardware_version' => 4,
'software_version' => 4, 'software_version' => 4,
],
'CD' => [
'hardware_version' => 4,
'software_version' => 4,
] ]
]; ];
...@@ -36,6 +41,19 @@ class QueryController extends Controller ...@@ -36,6 +41,19 @@ class QueryController extends Controller
parent::__destruct(); parent::__destruct();
} }
public function currentVersion()
{
$gatewayModel = new GatewayModel();
$gatewayModel->update([
'hardware_version' => $this->request->get('hardware_version'),
'software_version' => $this->request->get('software_version'),
], 'id = ' . $_SESSION['gateway_id']);
}
/** /**
* @throws \Exception * @throws \Exception
*/ */
...@@ -85,11 +103,20 @@ class QueryController extends Controller ...@@ -85,11 +103,20 @@ class QueryController extends Controller
$urlHex .= $hex; $urlHex .= $hex;
} }
Log::debug($updateSoftwareVersion);
Log::debug($updateHardwareVersion);
Log::debug($sign);
Log::debug($urlHex);
$this->response->send('d1', $returnCode . $updateHardwareVersion . $updateSoftwareVersion . $sign . $urlHex); $this->response->send('d1', $returnCode . $updateHardwareVersion . $updateSoftwareVersion . $sign . $urlHex);
return;
} }
$this->response->send('d1', $returnCode);
return;
} }
$this->response->send('d1', '11');
return;
} }
......
...@@ -45,6 +45,8 @@ class Api ...@@ -45,6 +45,8 @@ class Api
$this->add('0E', 'setting\DeviceMacController@getAll'); $this->add('0E', 'setting\DeviceMacController@getAll');
$this->add('D1', 'update\QueryController@check'); $this->add('D1', 'update\QueryController@check');
$this->add('CD', 'update\QueryController@currentVersion');
} }
......
...@@ -41,11 +41,11 @@ class ChargerState extends State ...@@ -41,11 +41,11 @@ class ChargerState extends State
{ {
$orderModel = new OrderModel(); $orderModel = new OrderModel();
$orderModel->update([ $orderModel->update([
'is_stop' => $this->order->getEndCode(), 'is_stop' => $this->order->getEndCode(),
'end_capacity' => $this->order->getEndCapacity(), 'end_capacity' => $this->order->getEndCapacity(),
'updated_at' => $this->nowDate, 'updated_at' => $this->nowDate,
'end_time' => $this->nowDate, 'end_time' => $this->nowDate,
'state' => 1, 'state' => 1,
], 'id = ' . $this->order->getId()); ], 'id = ' . $this->order->getId());
$port = new Port(); $port = new Port();
...@@ -78,9 +78,9 @@ class ChargerState extends State ...@@ -78,9 +78,9 @@ class ChargerState extends State
$orderException = new OrderExceptionModel(); $orderException = new OrderExceptionModel();
$orderException->insertRow([ $orderException->insertRow([
'order_id' => $this->order->getId(), 'order_id' => $this->order->getId(),
'state' => StateCode::PORT_CHARGER . StateCode::FINISH_USER, 'state' => StateCode::PORT_CHARGER . StateCode::FINISH_USER,
'desc' => '用户主动结束充电', 'desc' => '用户主动结束充电',
'created_at' => $this->nowDate, 'created_at' => $this->nowDate,
]); ]);
...@@ -122,17 +122,17 @@ class ChargerState extends State ...@@ -122,17 +122,17 @@ class ChargerState extends State
//更新订单状态 //更新订单状态
$orderModel = new OrderModel(); $orderModel = new OrderModel();
$orderModel->update([ $orderModel->update([
'is_stop' => StateCode::FINISH_EXCEED, 'is_stop' => StateCode::FINISH_EXCEED,
'end_capacity' => $this->order->getEndCapacity(), 'end_capacity' => $this->order->getEndCapacity(),
'end_time' => $this->nowDate, 'end_time' => $this->nowDate,
'state' => 1, 'state' => 1,
], 'id = ' . $this->order->getId()); ], 'id = ' . $this->order->getId());
$orderExceptionModel = new OrderExceptionModel(); $orderExceptionModel = new OrderExceptionModel();
$orderExceptionModel->insertRow([ $orderExceptionModel->insertRow([
'order_id' => $this->order->getId(), 'order_id' => $this->order->getId(),
'state' => StateCode::PORT_CHARGER . StateCode::FINISH_EXCEED, 'state' => StateCode::PORT_CHARGER . StateCode::FINISH_EXCEED,
'desc' => '功率超限', 'desc' => '功率超限',
'created_at' => date('Y-m-d H:i:s', $this->nowTimeStamp), 'created_at' => date('Y-m-d H:i:s', $this->nowTimeStamp),
]); ]);
...@@ -177,17 +177,17 @@ class ChargerState extends State ...@@ -177,17 +177,17 @@ class ChargerState extends State
$orderModel = new OrderModel(); $orderModel = new OrderModel();
$orderModel->update([ $orderModel->update([
'is_stop' => StateCode::FINISH_FULL, 'is_stop' => StateCode::FINISH_FULL,
'end_time' => $this->nowDate, 'end_time' => $this->nowDate,
'end_capacity' => $this->order->getEndCapacity(), 'end_capacity' => $this->order->getEndCapacity(),
'state' => 1, 'state' => 1,
], 'id = ' . $this->order->getId()); ], 'id = ' . $this->order->getId());
$orderExceptionModel = new OrderExceptionModel(); $orderExceptionModel = new OrderExceptionModel();
$orderExceptionModel->insertRow([ $orderExceptionModel->insertRow([
'order_id' => $this->order->getId(), 'order_id' => $this->order->getId(),
'state' => StateCode::PORT_CHARGER . StateCode::FINISH_FULL, 'state' => StateCode::PORT_CHARGER . StateCode::FINISH_FULL,
'desc' => '订单充电自停', 'desc' => '订单充电自停',
'created_at' => $this->nowDate, 'created_at' => $this->nowDate,
]); ]);
...@@ -241,16 +241,16 @@ class ChargerState extends State ...@@ -241,16 +241,16 @@ class ChargerState extends State
$orderModel = new OrderModel(); $orderModel = new OrderModel();
$orderModel->update([ $orderModel->update([
'updated_at' => $this->nowDate, 'updated_at' => $this->nowDate,
'shed_time' => $this->nowDate, 'shed_time' => $this->nowDate,
], 'id = ' . $this->order->getId()); ], 'id = ' . $this->order->getId());
$orderExceptionModel = new OrderExceptionModel(); $orderExceptionModel = new OrderExceptionModel();
$orderExceptionModel->insertRow([ $orderExceptionModel->insertRow([
'order_id' => $this->order->getId(), 'order_id' => $this->order->getId(),
'state' => StateCode::PORT_CHARGER . StateCode::PORT_SHED, 'state' => StateCode::PORT_CHARGER . StateCode::PORT_SHED,
'desc' => '口子脱落', 'desc' => '口子脱落',
'created_at' => $this->nowDate, 'created_at' => $this->nowDate,
]); ]);
...@@ -279,13 +279,13 @@ class ChargerState extends State ...@@ -279,13 +279,13 @@ class ChargerState extends State
$publish = new PublishPortShed(); $publish = new PublishPortShed();
$publish->publishOrder([ $publish->publishOrder([
'order_id' => $this->order->getId(), 'order_id' => $this->order->getId(),
'shed_time' => $this->nowTimeStamp, 'shed_time' => $this->nowTimeStamp,
'port_id' => $this->order->getPortId(), 'port_id' => $this->order->getPortId(),
'gateway_mac' => $this->order->getGatewayMac(), 'gateway_mac' => $this->order->getGatewayMac(),
'check_times' => 1, 'check_times' => 1,
'gateway_id' => $this->order->getGatewayId(), 'gateway_id' => $this->order->getGatewayId(),
'station_id' => $_SESSION['station_id'], 'station_id' => $_SESSION['station_id'],
]); ]);
} catch (\Exception $exception) { } catch (\Exception $exception) {
...@@ -317,11 +317,11 @@ class ChargerState extends State ...@@ -317,11 +317,11 @@ class ChargerState extends State
{ {
$orderModel = new OrderModel(); $orderModel = new OrderModel();
$orderModel->update([ $orderModel->update([
'is_stop' => StateCode::FINISH_TIME_END, 'is_stop' => StateCode::FINISH_TIME_END,
'end_capacity' => $this->order->getEndCapacity(), 'end_capacity' => $this->order->getEndCapacity(),
'end_time' => $this->nowDate, 'end_time' => $this->nowDate,
'updated_at' => $this->nowDate, 'updated_at' => $this->nowDate,
'state' => 1, 'state' => 1,
], 'id = ' . $this->order->getId()); ], 'id = ' . $this->order->getId());
$port = new Port(); $port = new Port();
...@@ -352,6 +352,12 @@ class ChargerState extends State ...@@ -352,6 +352,12 @@ class ChargerState extends State
} }
public function toRefundFinish()
{
Log::error('charger state can not change to refund finish');
}
/** /**
* 关闭失败 * 关闭失败
*/ */
......
...@@ -44,11 +44,11 @@ class ChargerState extends State ...@@ -44,11 +44,11 @@ class ChargerState extends State
{ {
$orderModel = new OrderModel(); $orderModel = new OrderModel();
$orderModel->update([ $orderModel->update([
'is_stop' => $this->order->getEndCode(), 'is_stop' => $this->order->getEndCode(),
'end_capacity' => $this->order->getEndCapacity(), 'end_capacity' => $this->order->getEndCapacity(),
'updated_at' => $this->nowDate, 'updated_at' => $this->nowDate,
'end_time' => $this->nowDate, 'end_time' => $this->nowDate,
'state' => 1, 'state' => 1,
], 'id = ' . $this->order->getId()); ], 'id = ' . $this->order->getId());
$port = new Port(); $port = new Port();
...@@ -81,9 +81,9 @@ class ChargerState extends State ...@@ -81,9 +81,9 @@ class ChargerState extends State
$orderException = new OrderExceptionModel(); $orderException = new OrderExceptionModel();
$orderException->insertRow([ $orderException->insertRow([
'order_id' => $this->order->getId(), 'order_id' => $this->order->getId(),
'state' => StateCode::PORT_CHARGER . StateCode::FINISH_USER, 'state' => StateCode::PORT_CHARGER . StateCode::FINISH_USER,
'desc' => '用户主动结束充电', 'desc' => '用户主动结束充电',
'created_at' => $this->nowDate, 'created_at' => $this->nowDate,
]); ]);
...@@ -125,29 +125,29 @@ class ChargerState extends State ...@@ -125,29 +125,29 @@ class ChargerState extends State
//更新订单状态 //更新订单状态
$orderModel = new OrderModel(); $orderModel = new OrderModel();
$orderModel->update([ $orderModel->update([
'is_stop' => StateCode::FINISH_EXCEED, 'is_stop' => StateCode::FINISH_EXCEED,
'end_capacity' => $this->order->getEndCapacity(), 'end_capacity' => $this->order->getEndCapacity(),
'end_time' => $this->nowDate, 'end_time' => $this->nowDate,
'state' => 1, 'state' => 1,
], 'id = ' . $this->order->getId()); ], 'id = ' . $this->order->getId());
$orderExceptionModel = new OrderExceptionModel(); $orderExceptionModel = new OrderExceptionModel();
$orderExceptionModel->insertRow([ $orderExceptionModel->insertRow([
'order_id' => $this->order->getId(), 'order_id' => $this->order->getId(),
'state' => StateCode::PORT_CHARGER . StateCode::FINISH_EXCEED, 'state' => StateCode::PORT_CHARGER . StateCode::FINISH_EXCEED,
'desc' => '功率超限', 'desc' => '功率超限',
'created_at' => date('Y-m-d H:i:s', $this->nowTimeStamp), 'created_at' => date('Y-m-d H:i:s', $this->nowTimeStamp),
]); ]);
$exceptionModel = new ExceptionModel(); $exceptionModel = new ExceptionModel();
$exceptionModel->insertRow([ $exceptionModel->insertRow([
'message' => '功率超限', 'message' => '功率超限',
'gateway_id' => isset($_SESSION['gateway_id']) ? $_SESSION['gateway_id'] : '', 'gateway_id' => isset($_SESSION['gateway_id']) ? $_SESSION['gateway_id'] : '',
'station_id' => isset($_SESSION['station_id']) ? $_SESSION['station_id'] : '', 'station_id' => isset($_SESSION['station_id']) ? $_SESSION['station_id'] : '',
'port_id' => $this->order->getPortId(), 'port_id' => $this->order->getPortId(),
'created_at' => date('Y-m-d H:i:s'), 'created_at' => date('Y-m-d H:i:s'),
'type' => 2, 'type' => 2,
]); ]);
...@@ -192,17 +192,17 @@ class ChargerState extends State ...@@ -192,17 +192,17 @@ class ChargerState extends State
$orderModel = new OrderModel(); $orderModel = new OrderModel();
$orderModel->update([ $orderModel->update([
'is_stop' => StateCode::FINISH_FULL, 'is_stop' => StateCode::FINISH_FULL,
'end_time' => $this->nowDate, 'end_time' => $this->nowDate,
'end_capacity' => $this->order->getEndCapacity(), 'end_capacity' => $this->order->getEndCapacity(),
'state' => 1, 'state' => 1,
], 'id = ' . $this->order->getId()); ], 'id = ' . $this->order->getId());
$orderExceptionModel = new OrderExceptionModel(); $orderExceptionModel = new OrderExceptionModel();
$orderExceptionModel->insertRow([ $orderExceptionModel->insertRow([
'order_id' => $this->order->getId(), 'order_id' => $this->order->getId(),
'state' => StateCode::PORT_CHARGER . StateCode::FINISH_FULL, 'state' => StateCode::PORT_CHARGER . StateCode::FINISH_FULL,
'desc' => '订单充满自停', 'desc' => '订单充满自停',
'created_at' => $this->nowDate, 'created_at' => $this->nowDate,
]); ]);
...@@ -259,27 +259,27 @@ class ChargerState extends State ...@@ -259,27 +259,27 @@ class ChargerState extends State
$orderModel = new OrderModel(); $orderModel = new OrderModel();
$orderModel->update([ $orderModel->update([
'updated_at' => $this->nowDate, 'updated_at' => $this->nowDate,
'shed_time' => $this->nowDate, 'shed_time' => $this->nowDate,
], 'id = ' . $this->order->getId()); ], 'id = ' . $this->order->getId());
$orderExceptionModel = new OrderExceptionModel(); $orderExceptionModel = new OrderExceptionModel();
$orderExceptionModel->insertRow([ $orderExceptionModel->insertRow([
'order_id' => $this->order->getId(), 'order_id' => $this->order->getId(),
'state' => StateCode::PORT_CHARGER . StateCode::PORT_SHED, 'state' => StateCode::PORT_CHARGER . StateCode::PORT_SHED,
'desc' => '口子脱落', 'desc' => '口子脱落',
'created_at' => $this->nowDate, 'created_at' => $this->nowDate,
]); ]);
$exceptionModel = new ExceptionModel(); $exceptionModel = new ExceptionModel();
$exceptionModel->insertRow([ $exceptionModel->insertRow([
'message' => '口子脱落', 'message' => '口子脱落',
'gateway_id' => isset($_SESSION['gateway_id']) ? $_SESSION['gateway_id'] : '', 'gateway_id' => isset($_SESSION['gateway_id']) ? $_SESSION['gateway_id'] : '',
'station_id' => isset($_SESSION['station_id']) ? $_SESSION['station_id'] : '', 'station_id' => isset($_SESSION['station_id']) ? $_SESSION['station_id'] : '',
'port_id' => $this->order->getPortId(), 'port_id' => $this->order->getPortId(),
'created_at' => date('Y-m-d H:i:s'), 'created_at' => date('Y-m-d H:i:s'),
'type' => 2, 'type' => 2,
]); ]);
//更新端口状态和订单状态 //更新端口状态和订单状态
...@@ -300,20 +300,20 @@ class ChargerState extends State ...@@ -300,20 +300,20 @@ class ChargerState extends State
Log::error('send port shed message fail'); Log::error('send port shed message fail');
} }
//todo publish 十分钟的延迟任务 // publish 十分钟的延迟任务
try { try {
$publish = new PublishPortShed(); $publish = new PublishPortShed();
$publish->publishOrder([ $publish->publishOrder([
'order_id' => $this->order->getId(), 'order_id' => $this->order->getId(),
'shed_time' => $this->nowTimeStamp, 'shed_time' => $this->nowTimeStamp,
'port_id' => $this->order->getPortId(), 'port_id' => $this->order->getPortId(),
'gateway_mac' => $this->order->getGatewayMac(), 'gateway_mac' => $this->order->getGatewayMac(),
'check_times' => 1, 'check_times' => 1,
'gateway_id' => $this->order->getGatewayId(), 'gateway_id' => $this->order->getGatewayId(),
'station_id' => $_SESSION['station_id'], 'station_id' => $_SESSION['station_id'],
]); ]);
} catch (\Exception $exception) { } catch (\Exception $exception) {
...@@ -345,11 +345,11 @@ class ChargerState extends State ...@@ -345,11 +345,11 @@ class ChargerState extends State
{ {
$orderModel = new OrderModel(); $orderModel = new OrderModel();
$orderModel->update([ $orderModel->update([
'is_stop' => StateCode::FINISH_TIME_END, 'is_stop' => StateCode::FINISH_TIME_END,
'end_capacity' => $this->order->getEndCapacity(), 'end_capacity' => $this->order->getEndCapacity(),
'end_time' => $this->nowDate, 'end_time' => $this->nowDate,
'updated_at' => $this->nowDate, 'updated_at' => $this->nowDate,
'state' => 1, 'state' => 1,
], 'id = ' . $this->order->getId()); ], 'id = ' . $this->order->getId());
$port = new Port(); $port = new Port();
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
namespace Lib\cdz\order\state; namespace Lib\cdz\order\state;
use GuzzleHttp\Psr7\LazyOpenStream;
use Lib\cdz\order\NoticePortShed; use Lib\cdz\order\NoticePortShed;
use Lib\cdz\order\Order; use Lib\cdz\order\Order;
use Lib\log\Log; use Lib\log\Log;
...@@ -35,14 +36,20 @@ class OfflineNetState extends State ...@@ -35,14 +36,20 @@ class OfflineNetState extends State
} }
$startTime = $this->order->getStartTime(); $startTime = $this->order->getStartTime();
$stateCode = $this->order->getStateCode();
if ($startTime === '' || $this->order->getOfflineTime() == '0') { if ($startTime === '') {
Log::debug('time equal purchase time');
$this->remainChargerTime = (int)($this->order->getPurchaseTime()); $this->remainChargerTime = (int)($this->order->getPurchaseTime());
} else { } else {
$purchaseTime = $this->order->getPurchaseTime(); $purchaseTime = $this->order->getPurchaseTime();
$this->remainChargerTime = $purchaseTime * 60 - ((int)$this->order->getOnlineTime() - $startTime); $this->remainChargerTime = $purchaseTime * 60 - ((int)$this->order->getOnlineTime() - $startTime);
Log::debug('off net');
Log::debug($this->order->getOnlineTime());
Log::debug($startTime . 'start_time');
Log::debug('remain charger time' . $this->remainChargerTime); Log::debug('remain charger time' . $this->remainChargerTime);
Log::debug('remain time' . ceil($this->remainChargerTime / 60));
$this->remainChargerTime = ceil($this->remainChargerTime / 60); $this->remainChargerTime = ceil($this->remainChargerTime / 60);
......
...@@ -40,6 +40,8 @@ class OfflinePowerState extends State ...@@ -40,6 +40,8 @@ class OfflinePowerState extends State
$purchaseTime = $this->order->getPurchaseTime(); $purchaseTime = $this->order->getPurchaseTime();
$this->remainChargerTime = $purchaseTime * 60 - ($offlineTime - $startTime); $this->remainChargerTime = $purchaseTime * 60 - ($offlineTime - $startTime);
Log::debug($offlineTime . '---' . $startTime . '-----' . $this->remainChargerTime);
$this->order->setStartTime(strval((int)$startTime + ((int)time() - (int)$offlineTime))); $this->order->setStartTime(strval((int)$startTime + ((int)time() - (int)$offlineTime)));
$this->remainChargerTime = ceil($this->remainChargerTime / 60); $this->remainChargerTime = ceil($this->remainChargerTime / 60);
$saveOrder = new OrderSaveRedis($this->order); $saveOrder = new OrderSaveRedis($this->order);
......
...@@ -84,6 +84,8 @@ class WaitingState extends State ...@@ -84,6 +84,8 @@ class WaitingState extends State
*/ */
public function toChargerState(): void public function toChargerState(): void
{ {
//订单已经退款则直接结束 //订单已经退款则直接结束
if ($this->order->getIsRefund() == 1) { if ($this->order->getIsRefund() == 1) {
// 下发结束充电命令 // 下发结束充电命令
...@@ -130,13 +132,15 @@ class WaitingState extends State ...@@ -130,13 +132,15 @@ class WaitingState extends State
} }
//更新订单状态
$update = [ $update = [
'is_charger' => StateCode::PORT_CHARGER,
'is_charger' => StateCode::PORT_CHARGER, 'start_time' => date('Y-m-d H:i:s', $this->order->getStartTime()),
'start_time' => date('Y-m-d H:i:s', $this->order->getStartTime()),
'start_capacity' => $this->order->getStartCapacity(),
]; ];
//更新订单状态
if ($this->order->getStartCapacity() !== -2) {
$update['start_capacity'] = (int)$this->order->getStartCapacity();
}
$orderModel = new OrderModel(); $orderModel = new OrderModel();
$orderModel->update($update, 'id = ' . $this->order->getId()); $orderModel->update($update, 'id = ' . $this->order->getId());
......
...@@ -44,7 +44,7 @@ class PublishPortShed ...@@ -44,7 +44,7 @@ class PublishPortShed
} }
public function publishOrder(array $message, string $routeKey = 'delay_check_port_charger_state') public function publishOrder(array $message, string $routeKey = 'delay_check_port_charger_state')
{ {
......
...@@ -69,6 +69,11 @@ class Bintohex ...@@ -69,6 +69,11 @@ class Bintohex
Log::error('encode error'); Log::error('encode error');
return; return;
} }
if (ctype_xdigit($buffer) === false) {
Log::error('not hex fomat', ['buffer' => $buffer]);
return;
}
return pack('H*', bin2hex(hex2bin($buffer))); return pack('H*', bin2hex(hex2bin($buffer)));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment