Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cdz_gateway_v2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨苏杭
cdz_gateway_v2
Commits
0b01c7ed
Commit
0b01c7ed
authored
Nov 16, 2018
by
banice
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新开始充,用电量错误
parent
93410bf8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
242 additions
and
136 deletions
+242
-136
.idea/workspace.xml
+0
-0
application/Events.php
+1
-2
application/controller/accept/AccessController.php
+119
-90
application/controller/business/charger/OverController.php
+6
-4
application/controller/business/charger/StartController.php
+0
-5
application/controller/business/port/OfflineController.php
+3
-0
application/controller/business/port/OnlineController.php
+3
-0
application/controller/business/port/StateController.php
+5
-0
application/controller/card/BalanceController.php
+8
-4
application/controller/card/PayRuleController.php
+0
-5
application/controller/card/charger/RequestController.php
+7
-7
application/controller/update/QueryController.php
+15
-5
application/model/CardModel.php
+2
-1
application/model/UserModel.php
+19
-0
lib/cdz/order/Order.php
+19
-0
lib/cdz/order/save/OrderSaveRedis.php
+0
-2
lib/cdz/order/state/WaitingState.php
+19
-10
lib/log/Log.php
+0
-1
lib/station/gateway/port/Port.php
+16
-0
No files found.
.idea/workspace.xml
View file @
0b01c7ed
This diff is collapsed.
Click to expand it.
application/Events.php
View file @
0b01c7ed
...
...
@@ -138,6 +138,7 @@ class Events
'gateway_id'
=>
$gatewayId
,
'station_id'
=>
$stationId
,
'type'
=>
1
,
'created_at'
=>
date
(
'Y-m-d H:i:s'
),
]);
}
...
...
@@ -163,8 +164,6 @@ class Events
$orderExceptionModel
=
new
\Application\model\OrderExceptionModel
();
$date
=
date
(
'Y-m-d H:i:s'
);
foreach
(
$portsId
as
$portId
)
{
//所有端口状态设置为离线
...
...
application/controller/accept/AccessController.php
View file @
0b01c7ed
...
...
@@ -11,7 +11,9 @@ namespace Application\controller\accept;
use
Application\controller\Controller
;
use
Application\model\DeviceModel
;
use
Application\model\GatewayLogModel
;
use
Application\model\GatewayModel
;
use
Application\model\OrderExceptionModel
;
use
Application\model\ParkModel
;
use
Application\model\StationModel
;
use
Lib\cdz\order\Order
;
...
...
@@ -48,93 +50,95 @@ class AccessController extends Controller
}
private
function
test
(
$mac
)
{
Gateway
::
bindUid
(
$this
->
clientId
,
$mac
);
$_SESSION
[
'gateway_mac'
]
=
$mac
;
$gatewayModel
=
new
GatewayModel
();
if
(
isset
(
$_SESSION
[
'gateway_mac'
]))
{
if
(
$_SESSION
[
'gateway_mac'
]
!=
$mac
)
{
Gateway
::
closeClient
(
$this
->
clientId
);
}
$gatewayModelResult
=
$gatewayModel
->
getColumns
([
'station_id'
,
'id'
,
'name'
,
'type_id'
],
'mac_address = '
.
"'
$mac
'"
);
if
(
$gatewayModelResult
==
false
)
{
Gateway
::
closeClient
(
$this
->
clientId
);
return
;
}
$stationId
=
$gatewayModelResult
[
'station_id'
];
$gatewayId
=
$gatewayModelResult
[
'id'
];
$_SESSION
[
'gateway_name'
]
=
$gatewayModelResult
[
'name'
];
$_SESSION
[
'gateway_id'
]
=
$gatewayModelResult
[
'id'
];
$_SESSION
[
'gateway_type'
]
=
$gatewayModelResult
[
'type_id'
];
$stationModel
=
new
StationModel
();
$stationData
=
$stationModel
->
getColumns
([
'park_id'
,
'name'
,
],
'id = '
.
$stationId
);
if
(
isset
(
$stationData
[
'park_id'
])
&&
isset
(
$stationData
[
'name'
]))
{
$parkId
=
$stationData
[
'park_id'
];
$_SESSION
[
'station_name'
]
=
$stationData
[
'name'
];
if
(
isset
(
$parkId
))
{
$parkModel
=
new
ParkModel
();
$_SESSION
[
'park_id'
]
=
$parkId
;
$agentId
=
$parkModel
->
getColumn
(
'agent_id'
,
'id = '
.
$parkId
);
if
(
isset
(
$agentId
))
{
$_SESSION
[
'agent_id'
]
=
$agentId
;
}
}
}
$deviceModel
=
new
DeviceModel
();
$deviceModelResult
=
$deviceModel
->
getAllColumns
([
'id'
,
'device_mac'
,
'name'
,
],
'gateway_id = '
.
$gatewayId
);
$tmp
=
[];
$portsIdName
=
[];
foreach
(
$deviceModelResult
as
$item
)
{
$tmp
[
$item
[
'device_mac'
]]
=
$item
[
'id'
];
$portsIdName
[
$item
[
'id'
]]
=
$item
[
'name'
];
}
$_SESSION
[
'port_id_name'
]
=
$portsIdName
;
$_SESSION
[
'port_mac_id'
]
=
$tmp
;
$_SESSION
[
'port_id_mac'
]
=
array_flip
(
$tmp
);
$_SESSION
[
'station_id'
]
=
$stationId
;
$_SESSION
[
'gateway_id'
]
=
$gatewayId
;
$_SESSION
[
'client_id'
]
=
$this
->
clientId
;
}
}
// private function test($mac)
// {
//
//
// Gateway::bindUid($this->clientId, $mac);
//
// $_SESSION['gateway_mac'] = $mac;
// $gatewayModel = new GatewayModel();
//
//
// if (isset($_SESSION['gateway_mac'])) {
// if ($_SESSION['gateway_mac'] != $mac) {
// Gateway::closeClient($this->clientId);
//
// }
//
// $gatewayModelResult = $gatewayModel->getColumns([
// 'station_id',
// 'id',
// 'name',
// 'type_id'
// ], 'mac_address = ' . "'$mac'");
//
// if ($gatewayModelResult == false) {
// Gateway::closeClient($this->clientId);
// return;
// }
// $stationId = $gatewayModelResult['station_id'];
//
// $gatewayId = $gatewayModelResult['id'];
//
// $_SESSION['gateway_name'] = $gatewayModelResult['name'];
//
// $_SESSION['gateway_id'] = $gatewayModelResult['id'];
//
// $_SESSION['gateway_type'] = $gatewayModelResult['type_id'];
//
// $stationModel = new StationModel();
// $stationData = $stationModel->getColumns([
// 'park_id',
// 'name',
// ], 'id = ' . $stationId);
//
// if (isset($stationData['park_id']) && isset($stationData['name'])) {
// $parkId = $stationData['park_id'];
// $_SESSION['station_name'] = $stationData['name'];
// if (isset($parkId)) {
// $parkModel = new ParkModel();
// $_SESSION['park_id'] = $parkId;
// $agentId = $parkModel->getColumn('agent_id', 'id = ' . $parkId);
// if (isset($agentId)) {
// $_SESSION['agent_id'] = $agentId;
// }
//
// }
//
// }
//
//
// $deviceModel = new DeviceModel();
//
// $deviceModelResult = $deviceModel->getAllColumns([
//
// 'id',
// 'device_mac',
// 'name',
// 'status_id',
// ], 'gateway_id = ' . $gatewayId);
//
// $tmp = [];
// $portsIdName = [];
// $portsStatus = [];
// foreach ($deviceModelResult as $item) {
//
// $tmp[$item['device_mac']] = $item['id'];
// $portsIdName[$item['id']] = $item['name'];
// $portsStatus[$item['id']] = $item['status_id'];
// }
// $_SESSION['port_id_status'] = $portsStatus;
// $_SESSION['port_id_name'] = $portsIdName;
// $_SESSION['port_mac_id'] = $tmp;
// $_SESSION['port_id_mac'] = array_flip($tmp);
//
// $_SESSION['station_id'] = $stationId;
// $_SESSION['gateway_id'] = $gatewayId;
// $_SESSION['client_id'] = $this->clientId;
//
// }
// }
/**
* 请求入网
...
...
@@ -212,19 +216,22 @@ class AccessController extends Controller
'id'
,
'device_mac'
,
'name'
,
'status_id'
],
'gateway_id = '
.
$gatewayId
);
$tmp
=
[];
$portsIdName
=
[];
$portsStatus
=
[];
foreach
(
$deviceModelResult
as
$item
)
{
$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
[
'station_id'
]
=
$stationId
;
...
...
@@ -300,6 +307,8 @@ class AccessController extends Controller
}
$logicStartTmp
=
$logicStart
;
$portsIdStatus
=
$_SESSION
[
'port_id_status'
];
foreach
(
$portMacState
as
$mac
=>
$state
)
{
$portId
=
isset
(
$portsMacId
[
$mac
])
?
$portsMacId
[
$mac
]
:
false
;
...
...
@@ -307,9 +316,14 @@ class AccessController extends Controller
continue
;
}
$port
->
setPortId
(
$portId
);
if
(
isset
(
$portsIdStatus
[
$portId
]))
{
if
(
$portsIdStatus
[
$portId
]
===
8
)
{
$state
=
8
;
}
}
//设置端口状态
$port
->
setState
(
$state
);
$port
->
setGatewayId
(
$_SESSION
[
'gateway_id'
]);
...
...
@@ -339,6 +353,9 @@ class AccessController extends Controller
$orderCount
=
'00'
;
$orderExceptionModel
=
new
OrderExceptionModel
();
$gatewayLod
=
new
GatewayLogModel
();
foreach
(
$portsId
as
$portId
)
{
$order
=
new
Order
();
...
...
@@ -370,13 +387,25 @@ class AccessController extends Controller
$orderId
=
sprintf
(
'%012x'
,
$order
->
getId
());
$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
);
}
$port
->
setPortId
(
$portId
);
$port
->
setGatewayId
(
$_SESSION
[
'gateway_id'
]);
$port
->
setStationId
(
$_SESSION
[
'station_id'
]);
$port
->
setState
(
StateCode
::
PORT_CHARGER
);
// $port->setState(StateCode::PORT_CHARGER);
$port
->
setState
(
$order
->
getStateCode
());
$port
->
updatePortState
();
...
...
application/controller/business/charger/OverController.php
View file @
0b01c7ed
...
...
@@ -67,10 +67,12 @@ class OverController extends Controller
if
(
$portId
!==
0
)
{
$this
->
logRecord
->
setPortId
(
$portId
);
}
// 逻辑地址不相同则认为已经更换过口子
// if ($logicId != $order->getPortLogicId()) {
// $this->response->send('15', sprintf('%02x', $logicId) . sprintf('%012x', $orderId));
// }
// 逻辑地址不相同则认为已经更换过口子
if
(
$logicId
!=
$order
->
getPortLogicId
())
{
$this
->
response
->
send
(
'15'
,
sprintf
(
'%02x'
,
$logicId
)
.
sprintf
(
'%012x'
,
$orderId
));
return
;
}
if
(
Gateway
::
isUidOnline
(
$order
->
getUserId
())
===
1
)
{
...
...
application/controller/business/charger/StartController.php
View file @
0b01c7ed
...
...
@@ -46,14 +46,9 @@ class StartController extends Controller
$logic
=
$this
->
getRequest
()
->
get
(
'logic_id'
);
$state
=
hexdec
(
$this
->
getRequest
()
->
get
(
'state'
));
$orderId
=
hexdec
(
$this
->
getRequest
()
->
get
(
'order_id'
));
$this
->
logRecord
->
setOrderId
(
$orderId
);
$capacity
=
hexdec
(
$this
->
getRequest
()
->
get
(
'capacity'
));
Log
::
debug
(
'order_id-->'
.
$orderId
);
Log
::
debug
(
'capacity-->'
.
$capacity
);
if
(
$type
==
1
)
{
$order
=
new
Order
(
$orderId
);
if
(
$order
->
getOrderCache
(
\Events
::
getRedis
())
==
false
)
{
$this
->
response
->
send
(
'14'
,
sprintf
(
'%012x'
,
$orderId
));
...
...
application/controller/business/port/OfflineController.php
View file @
0b01c7ed
...
...
@@ -85,6 +85,9 @@ class OfflineController extends Controller
Log
::
debug
(
'offline port_id'
.
$portId
);
$port
->
setPortId
(
$portId
);
if
(
$port
->
isPortBan
()
===
true
)
{
continue
;
}
$port
->
setStationId
(
$_SESSION
[
'station_id'
]);
$port
->
setGatewayId
(
$_SESSION
[
'gateway_id'
]);
$port
->
setState
(
StateCode
::
PORT_OFFLINE
);
...
...
application/controller/business/port/OnlineController.php
View file @
0b01c7ed
...
...
@@ -72,6 +72,9 @@ class OnlineController extends Controller
if
(
isset
(
$portsMacId
[
$portMac
]))
{
$portId
=
$portsMacId
[
$portMac
];
if
(
$port
->
isPortBan
()
===
true
)
{
continue
;
}
$port
->
setPortId
(
$portId
);
$port
->
setStationId
(
$_SESSION
[
'station_id'
]);
$port
->
setGatewayId
(
$_SESSION
[
'gateway_id'
]);
...
...
application/controller/business/port/StateController.php
View file @
0b01c7ed
...
...
@@ -68,7 +68,10 @@ class StateController extends Controller
$port
=
new
Port
(
$portId
);
if
(
$port
->
isPortBan
()
===
true
)
{
return
;
}
$usingOrderId
=
$port
->
getPortUsingOrderId
();
if
(
$usingOrderId
==
false
||
$usingOrderId
==
''
)
{
...
...
@@ -83,6 +86,8 @@ class StateController extends Controller
$order
=
new
Order
((
int
)
$usingOrderId
);
$order
->
setIsChangeState
(
true
);
if
(
$order
->
getOrderCache
(
\Events
::
getRedis
())
==
false
)
{
$port
->
setState
(
$state
);
...
...
application/controller/card/BalanceController.php
View file @
0b01c7ed
...
...
@@ -11,6 +11,7 @@ namespace Application\controller\card;
use
Application\controller\Controller
;
use
Application\model\CardModel
;
use
Application\model\UserModel
;
class
BalanceController
extends
Controller
{
...
...
@@ -18,7 +19,7 @@ class BalanceController extends Controller
'32'
=>
[
'card_id'
=>
3
'card_id'
=>
4
]
];
...
...
@@ -32,14 +33,17 @@ class BalanceController extends Controller
$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
=
sprintf
(
'%08x'
,
$balance
);
var_dump
(
$balance
);
$this
->
response
->
send
(
'32'
,
$cardId
.
$balance
);
}
...
...
application/controller/card/PayRuleController.php
View file @
0b01c7ed
...
...
@@ -37,12 +37,7 @@ class PayRuleController extends Controller
Gateway
::
closeClient
(
$this
->
clientId
);
}
Log
::
debug
(
$_SESSION
[
'station_id'
]);
$rule
=
$billingTmp
->
getColumn
(
'context'
,
'id = '
.
$_SESSION
[
'station_id'
]);
Log
::
debug
(
$rule
);
if
(
isset
(
$rule
))
{
$rule
=
json_decode
(
$rule
,
true
);
...
...
application/controller/card/charger/RequestController.php
View file @
0b01c7ed
...
...
@@ -12,6 +12,7 @@ namespace Application\controller\card\charger;
use
Application\controller\Controller
;
use
Application\model\CardModel
;
use
Application\model\OrderModel
;
use
Application\model\UserModel
;
use
Lib\cdz\order\Order
;
use
Lib\cdz\order\save\OrderSaveRedis
;
use
Lib\log\Log
;
...
...
@@ -24,7 +25,7 @@ class RequestController extends Controller
'33'
=>
[
'type'
=>
1
,
'logic_id'
=>
1
,
'card_id'
=>
3
,
'card_id'
=>
4
,
'time'
=>
2
,
'price'
=>
2
,
],
...
...
@@ -61,14 +62,13 @@ class RequestController extends Controller
$cardModel
=
new
CardModel
();
$
balance
=
$cardModel
->
getColumn
(
'balance
'
,
'card_number = '
.
$cardId
);
$
userId
=
$cardModel
->
getColumn
(
'user_id
'
,
'card_number = '
.
$cardId
);
Log
::
debug
(
$balance
);
if
(
isset
(
$balance
)
===
false
||
$balance
==
''
)
{
return
;
if
(
isset
(
$userId
))
{
$userModel
=
new
UserModel
();
$balance
=
$userModel
->
getColumn
(
'balance'
,
'id = '
.
$userId
);
}
$balance
=
isset
(
$balance
)
?
$balance
:
0
;
if
((
int
)
$balance
<
(
int
)
$price
)
{
$orderId
=
0
;
...
...
application/controller/update/QueryController.php
View file @
0b01c7ed
...
...
@@ -62,7 +62,6 @@ class QueryController extends Controller
$hardwareVersion
=
$this
->
request
->
get
(
'hardware_version'
);
$softwareVersion
=
$this
->
request
->
get
(
'software_version'
);
$response
=
''
;
Log
::
debug
(
'session'
,
Gateway
::
getSession
(
$this
->
clientId
));
$gatewayType
=
isset
(
$_SESSION
[
'gateway_type'
])
?
$_SESSION
[
'gateway_type'
]
:
false
;
...
...
@@ -74,14 +73,23 @@ class QueryController extends Controller
$gatewayUpdateModel
=
new
GatewayUpdateModel
();
$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'
];
$sign
=
$updateInfo
[
'sign'
];
// $updateSoftwareVersion = sprintf('%08x', $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'
;
}
else
{
...
...
@@ -93,7 +101,9 @@ class QueryController extends Controller
if
(
$host
===
false
)
{
throw
new
\Exception
(
'can not find download host'
);
}
$downloadUrl
=
$host
.
'/update/'
.
$updateHardwareVersion
.
$updateSoftwareVersion
.
'.bin'
;
$downloadUrl
=
$host
.
'/gateway/'
.
$updateHardwareVersion
.
'_'
.
$updateSoftwareVersion
.
'.bin'
;
Log
::
debug
(
$downloadUrl
);
$urlHex
=
''
;
for
(
$i
=
0
;
$i
<
strlen
(
$downloadUrl
);
$i
++
)
{
...
...
@@ -115,7 +125,7 @@ class QueryController extends Controller
$this
->
response
->
send
(
'd1'
,
$returnCode
);
return
;
}
$this
->
response
->
send
(
'd1'
,
'11'
);
$this
->
response
->
send
(
'd1'
,
$returnCode
);
return
;
...
...
application/model/CardModel.php
View file @
0b01c7ed
...
...
@@ -12,5 +12,5 @@ namespace Application\model;
class
CardModel
extends
Model
{
protected
$table
=
'cards'
;
protected
$table
=
'
unreal_
cards'
;
}
\ No newline at end of file
application/model/UserModel.php
0 → 100644
View file @
0b01c7ed
<?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
lib/cdz/order/Order.php
View file @
0b01c7ed
...
...
@@ -18,6 +18,8 @@ class Order
const
ORDER_HASH_PREFIX
=
'cdz:order:state:'
;
private
$isChangeState
=
false
;
/**
* @var int
*/
...
...
@@ -650,5 +652,21 @@ class Order
$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
lib/cdz/order/save/OrderSaveRedis.php
View file @
0b01c7ed
...
...
@@ -45,8 +45,6 @@ class OrderSaveRedis
}
}
Log
::
debug
(
'update'
,
$update
);
$this
->
redis
->
hMset
(
$this
->
order
->
getCacheKeyName
(),
$update
);
$this
->
redis
->
expire
(
$this
->
order
->
getCacheKeyName
(),
60
*
60
*
24
);
...
...
lib/cdz/order/state/WaitingState.php
View file @
0b01c7ed
...
...
@@ -107,7 +107,11 @@ class WaitingState extends State
$this
->
order
->
setStateCode
(
12
);
\Events
::
pipe
();
$orderSaveRedis
=
new
OrderSaveRedis
(
$this
->
order
);
if
(
$this
->
order
->
isChangeState
()
===
false
)
{
$orderSaveRedis
->
save
([
'stateCode'
,
'startTime'
,
'startCapacity'
]);
}
else
{
$orderSaveRedis
->
save
([
'stateCode'
,
'startTime'
]);
}
//更新口子状态
$port
=
new
Port
();
...
...
@@ -137,11 +141,12 @@ class WaitingState extends State
'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
();
}
$orderModel
=
new
OrderModel
();
Log
::
debug
(
'update_order_state -> '
.
$this
->
order
->
getId
(),
$update
);
$orderModel
->
update
(
$update
,
'id = '
.
$this
->
order
->
getId
());
...
...
@@ -169,6 +174,7 @@ class WaitingState extends State
$orderModel
->
update
([
'is_charger'
=>
StateCode
::
PORT_EXCEPTION
,
'start_capacity'
=>
$this
->
order
->
getStartCapacity
(),
],
'id = '
.
$this
->
order
->
getId
());
//添加订单异常
...
...
@@ -227,23 +233,26 @@ class WaitingState extends State
public
function
toShedState
()
{
$this
->
order
->
setStateCode
(
-
1
);
$orderSave
=
new
OrderSaveRedis
(
$this
->
order
);
$orderSave
->
save
([
'stateCode'
]);
$orderSave
->
deleteHashKey
([
'startTime'
,
'startCapacity'
]);
$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
([
'start_capacity'
=>
(
int
)
$this
->
order
->
getStartCapacity
(),
],
'id = '
.
$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
()
...
...
lib/log/Log.php
View file @
0b01c7ed
...
...
@@ -9,7 +9,6 @@
namespace
Lib\log
;
use
Monolog\Formatter\LineFormatter
;
use
Monolog\Handler\RotatingFileHandler
;
use
Monolog\Logger
;
...
...
lib/station/gateway/port/Port.php
View file @
0b01c7ed
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment