Commit 0b01c7ed by banice

更新开始充,用电量错误

parent 93410bf8
...@@ -138,6 +138,7 @@ class Events ...@@ -138,6 +138,7 @@ class Events
'gateway_id' => $gatewayId, 'gateway_id' => $gatewayId,
'station_id' => $stationId, 'station_id' => $stationId,
'type' => 1, 'type' => 1,
'created_at' => date('Y-m-d H:i:s'),
]); ]);
} }
...@@ -163,8 +164,6 @@ class Events ...@@ -163,8 +164,6 @@ class Events
$orderExceptionModel = new \Application\model\OrderExceptionModel(); $orderExceptionModel = new \Application\model\OrderExceptionModel();
$date = date('Y-m-d H:i:s'); $date = date('Y-m-d H:i:s');
foreach ($portsId as $portId) { foreach ($portsId as $portId) {
//所有端口状态设置为离线 //所有端口状态设置为离线
......
...@@ -11,7 +11,9 @@ namespace Application\controller\accept; ...@@ -11,7 +11,9 @@ namespace Application\controller\accept;
use Application\controller\Controller; use Application\controller\Controller;
use Application\model\DeviceModel; use Application\model\DeviceModel;
use Application\model\GatewayLogModel;
use Application\model\GatewayModel; use Application\model\GatewayModel;
use Application\model\OrderExceptionModel;
use Application\model\ParkModel; use Application\model\ParkModel;
use Application\model\StationModel; use Application\model\StationModel;
use Lib\cdz\order\Order; use Lib\cdz\order\Order;
...@@ -48,93 +50,95 @@ class AccessController extends Controller ...@@ -48,93 +50,95 @@ class AccessController extends Controller
} }
private function test($mac) // private function test($mac)
{ // {
//
//
Gateway::bindUid($this->clientId, $mac); // Gateway::bindUid($this->clientId, $mac);
//
$_SESSION['gateway_mac'] = $mac; // $_SESSION['gateway_mac'] = $mac;
$gatewayModel = new GatewayModel(); // $gatewayModel = new GatewayModel();
//
//
if (isset($_SESSION['gateway_mac'])) { // if (isset($_SESSION['gateway_mac'])) {
if ($_SESSION['gateway_mac'] != $mac) { // if ($_SESSION['gateway_mac'] != $mac) {
Gateway::closeClient($this->clientId); // Gateway::closeClient($this->clientId);
//
} // }
//
$gatewayModelResult = $gatewayModel->getColumns([ // $gatewayModelResult = $gatewayModel->getColumns([
'station_id', // 'station_id',
'id', // 'id',
'name', // 'name',
'type_id' // 'type_id'
], 'mac_address = ' . "'$mac'"); // ], 'mac_address = ' . "'$mac'");
//
if ($gatewayModelResult == false) { // if ($gatewayModelResult == false) {
Gateway::closeClient($this->clientId); // Gateway::closeClient($this->clientId);
return; // return;
} // }
$stationId = $gatewayModelResult['station_id']; // $stationId = $gatewayModelResult['station_id'];
//
$gatewayId = $gatewayModelResult['id']; // $gatewayId = $gatewayModelResult['id'];
//
$_SESSION['gateway_name'] = $gatewayModelResult['name']; // $_SESSION['gateway_name'] = $gatewayModelResult['name'];
//
$_SESSION['gateway_id'] = $gatewayModelResult['id']; // $_SESSION['gateway_id'] = $gatewayModelResult['id'];
//
$_SESSION['gateway_type'] = $gatewayModelResult['type_id']; // $_SESSION['gateway_type'] = $gatewayModelResult['type_id'];
//
$stationModel = new StationModel(); // $stationModel = new StationModel();
$stationData = $stationModel->getColumns([ // $stationData = $stationModel->getColumns([
'park_id', // 'park_id',
'name', // 'name',
], 'id = ' . $stationId); // ], 'id = ' . $stationId);
//
if (isset($stationData['park_id']) && isset($stationData['name'])) { // if (isset($stationData['park_id']) && isset($stationData['name'])) {
$parkId = $stationData['park_id']; // $parkId = $stationData['park_id'];
$_SESSION['station_name'] = $stationData['name']; // $_SESSION['station_name'] = $stationData['name'];
if (isset($parkId)) { // if (isset($parkId)) {
$parkModel = new ParkModel(); // $parkModel = new ParkModel();
$_SESSION['park_id'] = $parkId; // $_SESSION['park_id'] = $parkId;
$agentId = $parkModel->getColumn('agent_id', 'id = ' . $parkId); // $agentId = $parkModel->getColumn('agent_id', 'id = ' . $parkId);
if (isset($agentId)) { // if (isset($agentId)) {
$_SESSION['agent_id'] = $agentId; // $_SESSION['agent_id'] = $agentId;
} // }
//
} // }
//
} // }
//
//
$deviceModel = new DeviceModel(); // $deviceModel = new DeviceModel();
//
$deviceModelResult = $deviceModel->getAllColumns([ // $deviceModelResult = $deviceModel->getAllColumns([
//
'id', // 'id',
'device_mac', // 'device_mac',
'name', // 'name',
], 'gateway_id = ' . $gatewayId); // 'status_id',
// ], 'gateway_id = ' . $gatewayId);
$tmp = []; //
$portsIdName = []; // $tmp = [];
// $portsIdName = [];
foreach ($deviceModelResult as $item) { // $portsStatus = [];
// foreach ($deviceModelResult as $item) {
$tmp[$item['device_mac']] = $item['id']; //
$portsIdName[$item['id']] = $item['name']; // $tmp[$item['device_mac']] = $item['id'];
// $portsIdName[$item['id']] = $item['name'];
} // $portsStatus[$item['id']] = $item['status_id'];
$_SESSION['port_id_name'] = $portsIdName; // }
$_SESSION['port_mac_id'] = $tmp; // $_SESSION['port_id_status'] = $portsStatus;
$_SESSION['port_id_mac'] = array_flip($tmp); // $_SESSION['port_id_name'] = $portsIdName;
// $_SESSION['port_mac_id'] = $tmp;
$_SESSION['station_id'] = $stationId; // $_SESSION['port_id_mac'] = array_flip($tmp);
$_SESSION['gateway_id'] = $gatewayId; //
$_SESSION['client_id'] = $this->clientId; // $_SESSION['station_id'] = $stationId;
// $_SESSION['gateway_id'] = $gatewayId;
} // $_SESSION['client_id'] = $this->clientId;
} //
// }
// }
/** /**
* 请求入网 * 请求入网
...@@ -212,19 +216,22 @@ class AccessController extends Controller ...@@ -212,19 +216,22 @@ class AccessController extends Controller
'id', 'id',
'device_mac', 'device_mac',
'name', 'name',
'status_id'
], 'gateway_id = ' . $gatewayId); ], 'gateway_id = ' . $gatewayId);
$tmp = []; $tmp = [];
$portsIdName = []; $portsIdName = [];
$portsStatus = [];
foreach ($deviceModelResult as $item) { foreach ($deviceModelResult as $item) {
$tmp[$item['device_mac']] = $item['id']; $tmp[$item['device_mac']] = $item['id'];
$portsIdName[$item['id']] = $item['name']; $portsIdName[$item['id']] = $item['name'];
$portsStatus[$item['id']] = $item['status_id'];
} }
$_SESSION['port_id_name'] = $portsIdName; $_SESSION['port_id_name'] = $portsIdName;
$_SESSION['port_mac_id'] = $tmp; $_SESSION['port_mac_id'] = $tmp;
$_SESSION['port_id_status'] = $portsStatus;
$_SESSION['port_id_mac'] = array_flip($tmp); $_SESSION['port_id_mac'] = array_flip($tmp);
$_SESSION['station_id'] = $stationId; $_SESSION['station_id'] = $stationId;
...@@ -300,6 +307,8 @@ class AccessController extends Controller ...@@ -300,6 +307,8 @@ class AccessController extends Controller
} }
$logicStartTmp = $logicStart; $logicStartTmp = $logicStart;
$portsIdStatus = $_SESSION['port_id_status'];
foreach ($portMacState as $mac => $state) { foreach ($portMacState as $mac => $state) {
$portId = isset($portsMacId[$mac]) ? $portsMacId[$mac] : false; $portId = isset($portsMacId[$mac]) ? $portsMacId[$mac] : false;
...@@ -307,9 +316,14 @@ class AccessController extends Controller ...@@ -307,9 +316,14 @@ class AccessController extends Controller
continue; continue;
} }
$port->setPortId($portId); $port->setPortId($portId);
if (isset($portsIdStatus[$portId])) {
if ($portsIdStatus[$portId] === 8) {
$state = 8;
}
}
//设置端口状态 //设置端口状态
$port->setState($state); $port->setState($state);
$port->setGatewayId($_SESSION['gateway_id']); $port->setGatewayId($_SESSION['gateway_id']);
...@@ -339,6 +353,9 @@ class AccessController extends Controller ...@@ -339,6 +353,9 @@ class AccessController extends Controller
$orderCount = '00'; $orderCount = '00';
$orderExceptionModel = new OrderExceptionModel();
$gatewayLod = new GatewayLogModel();
foreach ($portsId as $portId) { foreach ($portsId as $portId) {
$order = new Order(); $order = new Order();
...@@ -370,13 +387,25 @@ class AccessController extends Controller ...@@ -370,13 +387,25 @@ class AccessController extends Controller
$orderId = sprintf('%012x', $order->getId()); $orderId = sprintf('%012x', $order->getId());
$time = sprintf('%04x', $remainTime); $time = sprintf('%04x', $remainTime);
$orderExceptionModel->insertRow([
'order_id' => $orderId,
'state' => '1011',
'created_at' => date('Y-m-d H:i:s'),
'desc' => '口子离线或断网后重新上线',
'data' => json_encode([
'remain_time' => $time,
'offline_reason' => $offlineReason,
])
]);
array_push($responseOrder, $logicNum . $orderId . $time); array_push($responseOrder, $logicNum . $orderId . $time);
} }
$port->setPortId($portId); $port->setPortId($portId);
$port->setGatewayId($_SESSION['gateway_id']); $port->setGatewayId($_SESSION['gateway_id']);
$port->setStationId($_SESSION['station_id']); $port->setStationId($_SESSION['station_id']);
$port->setState(StateCode::PORT_CHARGER); // $port->setState(StateCode::PORT_CHARGER);
$port->setState($order->getStateCode());
$port->updatePortState(); $port->updatePortState();
......
...@@ -67,10 +67,12 @@ class OverController extends Controller ...@@ -67,10 +67,12 @@ class OverController extends Controller
if ($portId !== 0) { if ($portId !== 0) {
$this->logRecord->setPortId($portId); $this->logRecord->setPortId($portId);
} }
// 逻辑地址不相同则认为已经更换过口子 // 逻辑地址不相同则认为已经更换过口子
// if ($logicId != $order->getPortLogicId()) { if ($logicId != $order->getPortLogicId()) {
// $this->response->send('15', sprintf('%02x', $logicId) . sprintf('%012x', $orderId)); $this->response->send('15', sprintf('%02x', $logicId) . sprintf('%012x', $orderId));
// }
return;
}
if (Gateway::isUidOnline($order->getUserId()) === 1) { if (Gateway::isUidOnline($order->getUserId()) === 1) {
......
...@@ -46,14 +46,9 @@ class StartController extends Controller ...@@ -46,14 +46,9 @@ class StartController extends Controller
$logic = $this->getRequest()->get('logic_id'); $logic = $this->getRequest()->get('logic_id');
$state = hexdec($this->getRequest()->get('state')); $state = hexdec($this->getRequest()->get('state'));
$orderId = hexdec($this->getRequest()->get('order_id')); $orderId = hexdec($this->getRequest()->get('order_id'));
$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('capacity-->' . $capacity);
if ($type == 1) { if ($type == 1) {
$order = new Order($orderId); $order = new Order($orderId);
if ($order->getOrderCache(\Events::getRedis()) == false) { if ($order->getOrderCache(\Events::getRedis()) == false) {
$this->response->send('14', sprintf('%012x', $orderId)); $this->response->send('14', sprintf('%012x', $orderId));
......
...@@ -85,6 +85,9 @@ class OfflineController extends Controller ...@@ -85,6 +85,9 @@ class OfflineController extends Controller
Log::debug('offline port_id' . $portId); Log::debug('offline port_id' . $portId);
$port->setPortId($portId); $port->setPortId($portId);
if ($port->isPortBan() === true) {
continue;
}
$port->setStationId($_SESSION['station_id']); $port->setStationId($_SESSION['station_id']);
$port->setGatewayId($_SESSION['gateway_id']); $port->setGatewayId($_SESSION['gateway_id']);
$port->setState(StateCode::PORT_OFFLINE); $port->setState(StateCode::PORT_OFFLINE);
......
...@@ -72,6 +72,9 @@ class OnlineController extends Controller ...@@ -72,6 +72,9 @@ class OnlineController extends Controller
if (isset($portsMacId[$portMac])) { if (isset($portsMacId[$portMac])) {
$portId = $portsMacId[$portMac]; $portId = $portsMacId[$portMac];
if ($port->isPortBan() === true) {
continue;
}
$port->setPortId($portId); $port->setPortId($portId);
$port->setStationId($_SESSION['station_id']); $port->setStationId($_SESSION['station_id']);
$port->setGatewayId($_SESSION['gateway_id']); $port->setGatewayId($_SESSION['gateway_id']);
......
...@@ -68,7 +68,10 @@ class StateController extends Controller ...@@ -68,7 +68,10 @@ class StateController extends Controller
$port = new Port($portId); $port = new Port($portId);
if ($port->isPortBan() === true) {
return;
}
$usingOrderId = $port->getPortUsingOrderId(); $usingOrderId = $port->getPortUsingOrderId();
if ($usingOrderId == false || $usingOrderId == '') { if ($usingOrderId == false || $usingOrderId == '') {
...@@ -83,6 +86,8 @@ class StateController extends Controller ...@@ -83,6 +86,8 @@ class StateController extends Controller
$order = new Order((int)$usingOrderId); $order = new Order((int)$usingOrderId);
$order->setIsChangeState(true);
if ($order->getOrderCache(\Events::getRedis()) == false) { if ($order->getOrderCache(\Events::getRedis()) == false) {
$port->setState($state); $port->setState($state);
......
...@@ -11,6 +11,7 @@ namespace Application\controller\card; ...@@ -11,6 +11,7 @@ namespace Application\controller\card;
use Application\controller\Controller; use Application\controller\Controller;
use Application\model\CardModel; use Application\model\CardModel;
use Application\model\UserModel;
class BalanceController extends Controller class BalanceController extends Controller
{ {
...@@ -18,7 +19,7 @@ class BalanceController extends Controller ...@@ -18,7 +19,7 @@ class BalanceController extends Controller
'32' => [ '32' => [
'card_id' => 3 'card_id' => 4
] ]
]; ];
...@@ -32,14 +33,17 @@ class BalanceController extends Controller ...@@ -32,14 +33,17 @@ class BalanceController extends Controller
$cardModel = new CardModel(); $cardModel = new CardModel();
$balance = $cardModel->getColumn('balance', 'card_number = ' . $cardId); $userId = $cardModel->getColumn('user_id', 'card_number = ' . $cardId);
if (isset($userId)) {
$userModel = new UserModel();
$balance = $userModel->getColumn('balance', 'id = ' . $userId);
}
$balance = isset($balance) ? $balance : 0; $balance = isset($balance) ? $balance : 0;
$balance = sprintf('%08x', $balance); $balance = sprintf('%08x', $balance);
var_dump($balance);
$this->response->send('32', $cardId . $balance); $this->response->send('32', $cardId . $balance);
} }
......
...@@ -37,12 +37,7 @@ class PayRuleController extends Controller ...@@ -37,12 +37,7 @@ class PayRuleController extends Controller
Gateway::closeClient($this->clientId); Gateway::closeClient($this->clientId);
} }
Log::debug($_SESSION['station_id']);
$rule = $billingTmp->getColumn('context', 'id = ' . $_SESSION['station_id']); $rule = $billingTmp->getColumn('context', 'id = ' . $_SESSION['station_id']);
Log::debug($rule);
if (isset($rule)) { if (isset($rule)) {
$rule = json_decode($rule, true); $rule = json_decode($rule, true);
......
...@@ -12,6 +12,7 @@ namespace Application\controller\card\charger; ...@@ -12,6 +12,7 @@ namespace Application\controller\card\charger;
use Application\controller\Controller; use Application\controller\Controller;
use Application\model\CardModel; use Application\model\CardModel;
use Application\model\OrderModel; use Application\model\OrderModel;
use Application\model\UserModel;
use Lib\cdz\order\Order; use Lib\cdz\order\Order;
use Lib\cdz\order\save\OrderSaveRedis; use Lib\cdz\order\save\OrderSaveRedis;
use Lib\log\Log; use Lib\log\Log;
...@@ -24,7 +25,7 @@ class RequestController extends Controller ...@@ -24,7 +25,7 @@ class RequestController extends Controller
'33' => [ '33' => [
'type' => 1, 'type' => 1,
'logic_id' => 1, 'logic_id' => 1,
'card_id' => 3, 'card_id' => 4,
'time' => 2, 'time' => 2,
'price' => 2, 'price' => 2,
], ],
...@@ -61,14 +62,13 @@ class RequestController extends Controller ...@@ -61,14 +62,13 @@ class RequestController extends Controller
$cardModel = new CardModel(); $cardModel = new CardModel();
$balance = $cardModel->getColumn('balance', 'card_number = ' . $cardId); $userId = $cardModel->getColumn('user_id', 'card_number = ' . $cardId);
Log::debug($balance); if (isset($userId)) {
$userModel = new UserModel();
if (isset($balance) === false || $balance == '') { $balance = $userModel->getColumn('balance', 'id = ' . $userId);
return;
} }
$balance = isset($balance) ? $balance : 0;
if ((int)$balance < (int)$price) { if ((int)$balance < (int)$price) {
$orderId = 0; $orderId = 0;
......
...@@ -62,7 +62,6 @@ class QueryController extends Controller ...@@ -62,7 +62,6 @@ class QueryController extends Controller
$hardwareVersion = $this->request->get('hardware_version'); $hardwareVersion = $this->request->get('hardware_version');
$softwareVersion = $this->request->get('software_version'); $softwareVersion = $this->request->get('software_version');
$response = ''; $response = '';
Log::debug('session', Gateway::getSession($this->clientId));
$gatewayType = isset($_SESSION['gateway_type']) ? $_SESSION['gateway_type'] : false; $gatewayType = isset($_SESSION['gateway_type']) ? $_SESSION['gateway_type'] : false;
...@@ -74,14 +73,23 @@ class QueryController extends Controller ...@@ -74,14 +73,23 @@ class QueryController extends Controller
$gatewayUpdateModel = new GatewayUpdateModel(); $gatewayUpdateModel = new GatewayUpdateModel();
$updateInfo = $gatewayUpdateModel->getColumns(['hardware_version', 'software_version', 'sign'], 'gateway_type = ' . $gatewayType); $updateInfo = $gatewayUpdateModel->getColumns(['hardware_version', 'software_version', 'sign'], 'gateway_type = ' . $gatewayType);
if (count($updateInfo) !== 0) { $returnCode = '10';
if ($gatewayType == 4 && $hardwareVersion == '01010201') {
$returnCode = '10';
} else if ($updateInfo == false) {
$returnCode = '10';
} else if (count($updateInfo) !== 0) {
$updateHardwareVersion = $updateInfo['hardware_version']; $updateHardwareVersion = $updateInfo['hardware_version'];
$sign = $updateInfo['sign']; $sign = $updateInfo['sign'];
// $updateSoftwareVersion = sprintf('%08x', $updateInfo['software_version']); // $updateSoftwareVersion = sprintf('%08x', $updateInfo['software_version']);
$updateSoftwareVersion = sprintf($updateInfo['software_version']); $updateSoftwareVersion = sprintf($updateInfo['software_version']);
if ($updateHardwareVersion == $hardwareVersion && $updateSoftwareVersion == $softwareVersion) { if ($updateHardwareVersion === null || $updateSoftwareVersion === null) {
$returnCode = '10';
} else if ($updateHardwareVersion == $hardwareVersion && $updateSoftwareVersion == $softwareVersion) {
$returnCode = '10'; $returnCode = '10';
} else { } else {
...@@ -93,7 +101,9 @@ class QueryController extends Controller ...@@ -93,7 +101,9 @@ class QueryController extends Controller
if ($host === false) { if ($host === false) {
throw new \Exception('can not find download host'); throw new \Exception('can not find download host');
} }
$downloadUrl = $host . '/update/' . $updateHardwareVersion . $updateSoftwareVersion . '.bin'; $downloadUrl = $host . '/gateway/' . $updateHardwareVersion . '_' . $updateSoftwareVersion . '.bin';
Log::debug($downloadUrl);
$urlHex = ''; $urlHex = '';
for ($i = 0; $i < strlen($downloadUrl); $i++) { for ($i = 0; $i < strlen($downloadUrl); $i++) {
...@@ -115,7 +125,7 @@ class QueryController extends Controller ...@@ -115,7 +125,7 @@ class QueryController extends Controller
$this->response->send('d1', $returnCode); $this->response->send('d1', $returnCode);
return; return;
} }
$this->response->send('d1', '11'); $this->response->send('d1', $returnCode);
return; return;
......
...@@ -12,5 +12,5 @@ namespace Application\model; ...@@ -12,5 +12,5 @@ namespace Application\model;
class CardModel extends Model class CardModel extends Model
{ {
protected $table = 'cards'; protected $table = 'unreal_cards';
} }
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: banice
* Date: 2018/11/14
* Time: 下午2:20
*/
namespace Application\model;
class UserModel extends Model
{
protected $table = 'wx_users';
}
\ No newline at end of file
...@@ -18,6 +18,8 @@ class Order ...@@ -18,6 +18,8 @@ class Order
const ORDER_HASH_PREFIX = 'cdz:order:state:'; const ORDER_HASH_PREFIX = 'cdz:order:state:';
private $isChangeState = false;
/** /**
* @var int * @var int
*/ */
...@@ -650,5 +652,21 @@ class Order ...@@ -650,5 +652,21 @@ class Order
$this->cardId = $cardId; $this->cardId = $cardId;
} }
/**
* @return bool
*/
public function isChangeState(): bool
{
return $this->isChangeState;
}
/**
* @param bool $isChangeState
*/
public function setIsChangeState(bool $isChangeState): void
{
$this->isChangeState = $isChangeState;
}
} }
\ No newline at end of file
...@@ -45,8 +45,6 @@ class OrderSaveRedis ...@@ -45,8 +45,6 @@ class OrderSaveRedis
} }
} }
Log::debug('update', $update);
$this->redis->hMset($this->order->getCacheKeyName(), $update); $this->redis->hMset($this->order->getCacheKeyName(), $update);
$this->redis->expire($this->order->getCacheKeyName(), 60 * 60 * 24); $this->redis->expire($this->order->getCacheKeyName(), 60 * 60 * 24);
......
...@@ -107,7 +107,11 @@ class WaitingState extends State ...@@ -107,7 +107,11 @@ class WaitingState extends State
$this->order->setStateCode(12); $this->order->setStateCode(12);
\Events::pipe(); \Events::pipe();
$orderSaveRedis = new OrderSaveRedis($this->order); $orderSaveRedis = new OrderSaveRedis($this->order);
if ($this->order->isChangeState() === false) {
$orderSaveRedis->save(['stateCode', 'startTime', 'startCapacity']); $orderSaveRedis->save(['stateCode', 'startTime', 'startCapacity']);
} else {
$orderSaveRedis->save(['stateCode', 'startTime']);
}
//更新口子状态 //更新口子状态
$port = new Port(); $port = new Port();
...@@ -137,11 +141,12 @@ class WaitingState extends State ...@@ -137,11 +141,12 @@ class WaitingState extends State
'start_time' => date('Y-m-d H:i:s', $this->order->getStartTime()), 'start_time' => date('Y-m-d H:i:s', $this->order->getStartTime()),
]; ];
//更新订单状态 //更新订单状态
if ($this->order->getStartCapacity() !== -2) { $startCapacity = $this->order->getStartCapacity();
if ($startCapacity !== -2 && $startCapacity > 0) {
$update['start_capacity'] = (int)$this->order->getStartCapacity(); $update['start_capacity'] = (int)$this->order->getStartCapacity();
} }
$orderModel = new OrderModel(); $orderModel = new OrderModel();
Log::debug('update_order_state -> ' . $this->order->getId(), $update);
$orderModel->update($update, 'id = ' . $this->order->getId()); $orderModel->update($update, 'id = ' . $this->order->getId());
...@@ -169,6 +174,7 @@ class WaitingState extends State ...@@ -169,6 +174,7 @@ class WaitingState extends State
$orderModel->update([ $orderModel->update([
'is_charger' => StateCode::PORT_EXCEPTION, 'is_charger' => StateCode::PORT_EXCEPTION,
'start_capacity' => $this->order->getStartCapacity(),
], 'id = ' . $this->order->getId()); ], 'id = ' . $this->order->getId());
//添加订单异常 //添加订单异常
...@@ -227,23 +233,26 @@ class WaitingState extends State ...@@ -227,23 +233,26 @@ class WaitingState extends State
public function toShedState() public function toShedState()
{ {
$this->order->setStateCode(-1);
$orderSave = new OrderSaveRedis($this->order);
$orderSave->save(['stateCode']);
$orderSave->deleteHashKey(['startTime', 'startCapacity']);
$orderModel = new OrderModel(); $orderModel = new OrderModel();
Log::debug('waiting to shed' . $this->order->getStartCapacity()); Log::debug('waiting to shed ->start_capacity' . $this->order->getStartCapacity());
if ($this->order->getStartCapacity() >= 0) {
$orderModel->update([ $orderModel->update([
'start_capacity' => (int)$this->order->getStartCapacity(), 'start_capacity' => (int)$this->order->getStartCapacity(),
], 'id = ' . $this->order->getId()); ], 'id = ' . $this->order->getId());
}
Log::debug('update shed start_capacity' . $this->order->getId()); Log::debug('update shed start_capacity' . $this->order->getId());
$this->order->setStateCode(-1);
$orderSave = new OrderSaveRedis($this->order);
$orderSave->save(['stateCode']);
// $orderSave->deleteHashKey(['startTime', 'startCapacity']);
} }
public function toShedTimeoutState() public function toShedTimeoutState()
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
namespace Lib\log; namespace Lib\log;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\RotatingFileHandler; use Monolog\Handler\RotatingFileHandler;
use Monolog\Logger; use Monolog\Logger;
......
...@@ -73,6 +73,22 @@ class Port ...@@ -73,6 +73,22 @@ class Port
} }
public function isPortBan()
{
if (isset($_SESSION['port_id_status'])) {
$portIdStatus = $_SESSION['port_id_status'];
if (isset($portIdStatus[$this->portId])) {
if ($portIdStatus[$this->portId] === 8) {
return true;
}
}
}
return false;
}
/** /**
* 更新端口状态 * 更新端口状态
* @param int $orderId * @param int $orderId
......
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