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
29296654
Commit
29296654
authored
Apr 30, 2019
by
杨苏杭
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
封存
parent
6118513a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
497 additions
and
198 deletions
+497
-198
.idea/workspace.xml
+0
-0
application/Events.php
+72
-27
application/controller/accept/AccessController.php
+17
-17
application/controller/accept/CertifyController.php
+4
-3
application/controller/business/charger/OverController.php
+7
-7
application/controller/card/charger/OverController.php
+34
-10
application/controller/card/charger/RequestController.php
+33
-13
application/controller/card/charger/StartController.php
+21
-4
lib/cdz/card_order/state/ChargerState.php
+11
-7
lib/cdz/card_order/state/ExceptionState.php
+1
-1
lib/cdz/card_order/state/OfflineNetState.php
+4
-4
lib/cdz/card_order/state/OfflinePowerState.php
+4
-4
lib/cdz/card_order/state/PowerExceedState.php
+1
-1
lib/cdz/card_order/state/PowerFullState.php
+1
-1
lib/cdz/card_order/state/ShedState.php
+37
-31
lib/cdz/card_order/state/ShedTimeoutState.php
+1
-1
lib/cdz/card_order/state/State.php
+1
-3
lib/cdz/card_order/state/TimeoutState.php
+1
-1
lib/cdz/card_order/state/WaitingState.php
+8
-13
lib/cdz/order/Order.php
+26
-6
lib/cdz/order/save/OrderSaveRedis.php
+8
-2
lib/cdz/order/state/ChargerState.php
+18
-12
lib/cdz/order/state/ShedState.php
+9
-5
lib/cdz/order/state/WaitingState.php
+18
-6
lib/order_check/DelayOrder.php
+72
-0
lib/remote/api/message/ChargerFullMessage.php
+63
-4
lib/station/gateway/port/Port.php
+18
-7
src/BroadcastToAgent.php
+5
-3
src/command/StopChargerCommand.php
+2
-5
No files found.
.idea/workspace.xml
View file @
29296654
This diff is collapsed.
Click to expand it.
application/Events.php
View file @
29296654
...
@@ -15,6 +15,9 @@ use Lib\station\gateway\Gateway;
...
@@ -15,6 +15,9 @@ use Lib\station\gateway\Gateway;
use
Lib\station\gateway\port\Port
;
use
Lib\station\gateway\port\Port
;
use
Workerman\Lib\Timer
;
use
Workerman\Lib\Timer
;
use
GuzzleHttp\Client
;
use
GuzzleHttp\Client
;
use
Lib\order_check\DelayOrder
;
use
Lib\cdz\order\Order
;
use
Src\command\StopChargerCommand
;
class
Events
class
Events
{
{
...
@@ -32,40 +35,82 @@ class Events
...
@@ -32,40 +35,82 @@ class Events
/**
/**
*
*
*/
*/
public
static
function
onWorkerStart
()
public
static
function
onWorkerStart
(
\GatewayWorker\BusinessWorker
$businessWorker
)
{
{
Timer
::
add
(
10
*
6
*
10
,
function
()
{
\Lib\log\Log
::
bootLog
();
$client
=
new
Client
([
if
(
$businessWorker
->
id
===
0
)
{
'http_errors'
=>
false
]);
$response
=
$client
->
request
(
'POST'
,
getenv
(
'PAY_HOST'
)
.
'/api/wx/order/scanner'
,
[
'form_params'
=>
[
'key'
=>
'sE5jICwtbYrhnuSAUF3JTv0xXpQMG1Bfoy4aWgLP67zqKNVmd9O2HDei8lcZRk'
]
]);
});
static
::
$db
=
new
Connection
(
getenv
(
'DB_HOST'
),
getenv
(
'DB_PORT'
),
getenv
(
'DB_USERNAME'
),
getenv
(
'DB_PASSWORD'
),
getenv
(
'DB_DATABASE'
));
Timer
::
add
(
10
*
6
*
10
,
function
()
{
static
::
$redis
=
new
\Redis
();
$client
=
new
Client
([
'http_errors'
=>
false
]);
$response
=
$client
->
request
(
'POST'
,
getenv
(
'PAY_HOST'
)
.
'/api/wx/order/scanner'
,
[
'form_params'
=>
[
'key'
=>
'sE5jICwtbYrhnuSAUF3JTv0xXpQMG1Bfoy4aWgLP67zqKNVmd9O2HDei8lcZRk'
]
]);
});
static
::
$redis
->
pconnect
(
getenv
(
'REDIS_HOST'
),
getenv
(
'REDIS_PORT'
),
0
);
static
::
$db
=
new
Connection
(
getenv
(
'DB_HOST'
),
getenv
(
'DB_PORT'
),
getenv
(
'DB_USERNAME'
),
getenv
(
'DB_PASSWORD'
),
getenv
(
'DB_DATABASE'
)
);
static
::
$redis
=
new
\Redis
();
if
(
getenv
(
'REDIS_AUTH'
)
!==
false
)
{
static
::
$redis
->
auth
(
getenv
(
'REDIS_AUTH'
)
);
static
::
$redis
->
pconnect
(
getenv
(
'REDIS_HOST'
),
getenv
(
'REDIS_PORT'
),
0
);
}
static
::
$redis
->
select
(
'4'
);
if
(
getenv
(
'REDIS_AUTH'
)
!==
false
)
{
static
::
$redis
->
auth
(
getenv
(
'REDIS_AUTH'
));
\Lib\log\Log
::
bootLog
();
}
static
::
$redis
->
select
(
'4'
);
Timer
::
add
(
2
,
function
()
{
$delayOrder
=
new
DelayOrder
();
$delayOrderIds
=
$delayOrder
->
getDelayOrder
();
$order
=
new
Order
();
$stopCommand
=
new
StopChargerCommand
();
foreach
(
$delayOrderIds
as
$delayOrderId
)
{
$order
->
setId
(
$delayOrderId
);
$order
->
getOrderCache
(
static
::
$redis
);
$orderState
=
$order
->
getStateCode
();
if
(
$orderState
==
-
1
)
{
$stopCommand
->
setOutTradeNo
(
$delayOrderId
);
$stopCommand
->
setFinishType
(
43
);
$stopCommand
->
setPortLogic
(
$order
->
getPortLogicId
());
$body
=
$stopCommand
->
getMessage
();
$length
=
sprintf
(
'%04x'
,
(
8
+
strlen
(
$body
)
/
2
));
$nonce
=
sprintf
(
'%02x'
,
dechex
(
rand
(
0
,
255
)));
$exceptCrc
=
'ffaa0405'
.
$length
.
$nonce
.
$body
;
$crc
=
substr
(
sprintf
(
'%08x'
,
Crc
::
crc
(
$exceptCrc
)),
0
,
2
);
//下发结束充电命令和释放口子
\GatewayWorker\Lib\Gateway
::
sendToUid
(
$order
->
getGatewayMac
(),
$exceptCrc
.
$crc
);
$port
=
new
Port
(
$order
->
getPortId
());
$port
->
freePort
();
}
$delayOrder
->
deleteDelayOrder
(
$delayOrderId
);
}
});
}
}
}
...
@@ -92,7 +137,7 @@ class Events
...
@@ -92,7 +137,7 @@ class Events
$crcConfirm
=
sprintf
(
'%08x'
,
Crc
::
crc
(
substr
(
$message
,
0
,
strlen
(
$message
)
-
2
)));
$crcConfirm
=
sprintf
(
'%08x'
,
Crc
::
crc
(
substr
(
$message
,
0
,
strlen
(
$message
)
-
2
)));
if
(
$crc
!=
mb_strtoupper
(
substr
(
$crcConfirm
,
0
,
2
))
)
{
if
(
$crc
!=
mb_strtoupper
(
substr
(
$crcConfirm
,
0
,
2
))
)
{
Log
::
error
(
"message crc wrong (
$message
)"
);
Log
::
error
(
"message crc wrong (
$message
)"
);
return
;
return
;
}
}
...
@@ -101,11 +146,11 @@ class Events
...
@@ -101,11 +146,11 @@ class Events
$api
=
new
Api
();
$api
=
new
Api
();
$api
->
boot
();
$api
->
boot
();
if
(
isset
(
$api
->
route
[
$command
])
)
{
if
(
isset
(
$api
->
route
[
$command
])
)
{
$route
=
$api
->
route
[
$command
];
$route
=
$api
->
route
[
$command
];
if
(
$route
instanceof
Route
)
{
if
(
$route
instanceof
Route
)
{
$reflection
=
$route
->
getController
();
$reflection
=
$route
->
getController
();
...
@@ -137,7 +182,7 @@ class Events
...
@@ -137,7 +182,7 @@ class Events
$stationName
=
isset
(
$_SESSION
[
'station_name'
])
?
$_SESSION
[
'station_name'
]
:
''
;
$stationName
=
isset
(
$_SESSION
[
'station_name'
])
?
$_SESSION
[
'station_name'
]
:
''
;
$gatewayName
=
isset
(
$_SESSION
[
'gateway_name'
])
?
$_SESSION
[
'gateway_name'
]
:
''
;
$gatewayName
=
isset
(
$_SESSION
[
'gateway_name'
])
?
$_SESSION
[
'gateway_name'
]
:
''
;
if
(
$gatewayId
===
''
||
$stationId
===
''
||
$gatewayName
===
''
||
$stationName
===
''
)
{
if
(
$gatewayId
===
''
||
$stationId
===
''
||
$gatewayName
===
''
||
$stationName
===
''
)
{
Log
::
error
(
'client close can not find station_id or gateway_id'
);
Log
::
error
(
'client close can not find station_id or gateway_id'
);
return
;
return
;
}
}
...
@@ -148,7 +193,7 @@ class Events
...
@@ -148,7 +193,7 @@ class Events
$exceptionModel
=
new
\Application\model\ExceptionModel
();
$exceptionModel
=
new
\Application\model\ExceptionModel
();
if
(
isset
(
$_SESSION
[
'station_id'
])
&&
isset
(
$_SESSION
[
'gateway_id'
])
)
{
if
(
isset
(
$_SESSION
[
'station_id'
])
&&
isset
(
$_SESSION
[
'gateway_id'
])
)
{
$exceptionModel
->
insertRow
([
$exceptionModel
->
insertRow
([
'message'
=>
'网关离线'
,
'message'
=>
'网关离线'
,
'gateway_id'
=>
$gatewayId
,
'gateway_id'
=>
$gatewayId
,
...
@@ -164,7 +209,7 @@ class Events
...
@@ -164,7 +209,7 @@ class Events
//网关状态设置为离线
//网关状态设置为离线
$gateway
->
setState
(
$gatewayId
,
0
);
$gateway
->
setState
(
$gatewayId
,
0
);
if
(
isset
(
$_SESSION
[
'port_mac_id'
])
===
false
)
{
if
(
isset
(
$_SESSION
[
'port_mac_id'
])
===
false
)
{
Log
::
error
(
'gateway close can not find port_mac_id in session'
);
Log
::
error
(
'gateway close can not find port_mac_id in session'
);
return
;
return
;
...
@@ -202,9 +247,9 @@ class Events
...
@@ -202,9 +247,9 @@ class Events
//端口当前订单记录离线时间
//端口当前订单记录离线时间
if
(
$portUsingOrderId
!=
false
&&
$portUsingOrderId
!=
''
)
{
if
(
$portUsingOrderId
!=
false
&&
$portUsingOrderId
!=
''
)
{
$order
=
new
\Lib\cdz\order\Order
(
$portUsingOrderId
);
$order
=
new
\Lib\cdz\order\Order
(
$portUsingOrderId
);
if
(
$order
->
getOrderCache
(
static
::
$redis
)
!=
false
)
{
if
(
$order
->
getOrderCache
(
static
::
$redis
)
!=
false
)
{
$order
->
setOfflineTime
(
time
());
$order
->
setOfflineTime
(
time
());
$saveOrder
=
new
\Lib\cdz\order\save\OrderSaveRedis
(
$order
);
$saveOrder
=
new
\Lib\cdz\order\save\OrderSaveRedis
(
$order
);
$saveOrder
->
save
([
'offlineTime'
]);
$saveOrder
->
save
([
'offlineTime'
]);
...
...
application/controller/accept/AccessController.php
View file @
29296654
...
@@ -65,8 +65,8 @@ class AccessController extends Controller
...
@@ -65,8 +65,8 @@ class AccessController extends Controller
$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
);
}
}
...
@@ -78,7 +78,7 @@ class AccessController extends Controller
...
@@ -78,7 +78,7 @@ class AccessController extends Controller
'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
;
}
}
...
@@ -103,14 +103,14 @@ class AccessController extends Controller
...
@@ -103,14 +103,14 @@ class AccessController extends Controller
'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
;
}
}
...
@@ -185,7 +185,7 @@ class AccessController extends Controller
...
@@ -185,7 +185,7 @@ class AccessController extends Controller
$portMacState
=
[];
$portMacState
=
[];
if
(
strlen
(
$this
->
message
)
<
(
12
*
2
+
9
*
2
*
$count
)
)
{
if
(
strlen
(
$this
->
message
)
<
(
12
*
2
+
9
*
2
*
$count
)
)
{
return
;
return
;
}
}
...
@@ -197,7 +197,7 @@ class AccessController extends Controller
...
@@ -197,7 +197,7 @@ class AccessController extends Controller
$portMacState
[
$mac
]
=
hexdec
(
$state
);
$portMacState
[
$mac
]
=
hexdec
(
$state
);
}
}
if
(
isset
(
$_SESSION
[
'port_mac_id'
])
==
false
)
{
if
(
isset
(
$_SESSION
[
'port_mac_id'
])
==
false
)
{
return
;
return
;
}
}
...
@@ -211,7 +211,7 @@ class AccessController extends Controller
...
@@ -211,7 +211,7 @@ class AccessController extends Controller
$portsId
=
[];
$portsId
=
[];
foreach
(
$portMacState
as
$mac
=>
$state
)
{
foreach
(
$portMacState
as
$mac
=>
$state
)
{
if
(
isset
(
$portsMacId
[
$mac
])
)
{
if
(
isset
(
$portsMacId
[
$mac
])
)
{
array_push
(
$portsId
,
$portsMacId
[
$mac
]);
array_push
(
$portsId
,
$portsMacId
[
$mac
]);
}
}
}
}
...
@@ -222,14 +222,14 @@ class AccessController extends Controller
...
@@ -222,14 +222,14 @@ class AccessController extends Controller
foreach
(
$portMacState
as
$mac
=>
$state
)
{
foreach
(
$portMacState
as
$mac
=>
$state
)
{
$portId
=
isset
(
$portsMacId
[
$mac
])
?
$portsMacId
[
$mac
]
:
false
;
$portId
=
isset
(
$portsMacId
[
$mac
])
?
$portsMacId
[
$mac
]
:
false
;
if
(
$portId
===
false
)
{
if
(
$portId
===
false
)
{
continue
;
continue
;
}
}
$port
->
setPortId
(
$portId
);
$port
->
setPortId
(
$portId
);
if
(
isset
(
$portsIdStatus
[
$portId
])
)
{
if
(
isset
(
$portsIdStatus
[
$portId
])
)
{
if
(
$portsIdStatus
[
$portId
]
===
8
)
{
if
(
$portsIdStatus
[
$portId
]
===
8
)
{
$state
=
8
;
$state
=
8
;
}
}
...
@@ -246,7 +246,7 @@ class AccessController extends Controller
...
@@ -246,7 +246,7 @@ class AccessController extends Controller
$deviceModel
=
new
DeviceModel
();
$deviceModel
=
new
DeviceModel
();
if
(
isset
(
$_SESSION
[
'port_logic_id'
])
)
{
if
(
isset
(
$_SESSION
[
'port_logic_id'
])
)
{
$_SESSION
[
'port_logic_id'
]
=
$_SESSION
[
'port_logic_id'
]
+
$portsLogicId
;
$_SESSION
[
'port_logic_id'
]
=
$_SESSION
[
'port_logic_id'
]
+
$portsLogicId
;
}
else
{
}
else
{
$_SESSION
[
'port_logic_id'
]
=
$portsLogicId
;
$_SESSION
[
'port_logic_id'
]
=
$portsLogicId
;
...
@@ -273,18 +273,18 @@ class AccessController extends Controller
...
@@ -273,18 +273,18 @@ class AccessController extends Controller
$port
->
setPortId
(
$portId
);
$port
->
setPortId
(
$portId
);
$orderId
=
$port
->
getPortUsingOrderId
();
$orderId
=
$port
->
getPortUsingOrderId
();
if
(
$orderId
==
false
||
$orderId
==
''
)
{
if
(
$orderId
==
false
||
$orderId
==
''
)
{
continue
;
continue
;
}
}
$order
->
setId
(
$orderId
);
$order
->
setId
(
$orderId
);
if
(
$order
->
getOrderCache
(
\Events
::
getRedis
())
==
false
)
{
if
(
$order
->
getOrderCache
(
\Events
::
getRedis
())
==
false
)
{
continue
;
continue
;
}
}
$order
->
setOnlineTime
(
time
());
$order
->
setOnlineTime
(
time
());
if
(
$offlineReason
==
0
)
{
if
(
$offlineReason
==
0
)
{
$orderState
=
new
OfflineNetState
(
$order
);
$orderState
=
new
OfflineNetState
(
$order
);
}
else
{
}
else
{
$orderState
=
new
OfflinePowerState
(
$order
);
$orderState
=
new
OfflinePowerState
(
$order
);
...
@@ -292,7 +292,7 @@ class AccessController extends Controller
...
@@ -292,7 +292,7 @@ class AccessController extends Controller
}
}
$remainTime
=
$orderState
->
getRemainChargerTime
();
$remainTime
=
$orderState
->
getRemainChargerTime
();
if
(
$remainTime
>
0
)
{
if
(
$remainTime
>
0
)
{
$logicNum
=
sprintf
(
'%02x'
,
$order
->
getPortLogicId
());
$logicNum
=
sprintf
(
'%02x'
,
$order
->
getPortLogicId
());
$orderId
=
sprintf
(
'%012x'
,
$order
->
getId
());
$orderId
=
sprintf
(
'%012x'
,
$order
->
getId
());
$time
=
sprintf
(
'%04x'
,
$remainTime
);
$time
=
sprintf
(
'%04x'
,
$remainTime
);
...
...
application/controller/accept/CertifyController.php
View file @
29296654
...
@@ -62,14 +62,15 @@ class CertifyController extends Controller
...
@@ -62,14 +62,15 @@ class CertifyController extends Controller
'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'
];
$gatewayType
=
$gatewayModelResult
[
'type_id'
];
$_SESSION
[
'gateway_type'
]
=
$gatewayType
;
$_SESSION
[
'station_id'
]
=
$stationId
;
$_SESSION
[
'station_id'
]
=
$stationId
;
$_SESSION
[
'gateway_id'
]
=
$gatewayId
;
$_SESSION
[
'gateway_id'
]
=
$gatewayId
;
...
@@ -81,7 +82,7 @@ class CertifyController extends Controller
...
@@ -81,7 +82,7 @@ class CertifyController extends Controller
$sign
=
substr
(
$sign
,
0
,
8
);
$sign
=
substr
(
$sign
,
0
,
8
);
if
(
Gateway
::
isUidOnline
(
$mac
)
===
1
)
{
if
(
Gateway
::
isUidOnline
(
$mac
)
===
1
)
{
$clients
=
Gateway
::
getclientIdByUid
(
$mac
);
$clients
=
Gateway
::
getclientIdByUid
(
$mac
);
foreach
(
$clients
as
$client
)
{
foreach
(
$clients
as
$client
)
{
...
...
application/controller/business/charger/OverController.php
View file @
29296654
...
@@ -59,22 +59,22 @@ class OverController extends Controller
...
@@ -59,22 +59,22 @@ class OverController extends Controller
$this
->
logRecord
->
setOrderId
(
$orderId
);
$this
->
logRecord
->
setOrderId
(
$orderId
);
$order
=
new
Order
(
$orderId
);
$order
=
new
Order
(
$orderId
);
if
(
$order
->
getOrderCache
(
\Events
::
getRedis
())
!=
false
)
{
if
(
$order
->
getOrderCache
(
\Events
::
getRedis
())
!=
false
)
{
$orderStateCode
=
$order
->
getStateCode
();
$orderStateCode
=
$order
->
getStateCode
();
$order
->
setEndCapacity
(
$capacity
);
$order
->
setEndCapacity
(
$capacity
);
$order
->
setEndCode
(
$state
);
$order
->
setEndCode
(
$state
);
$order
->
setFinishTime
(
time
());
$portId
=
isset
(
$_SESSION
[
'port_logic_id'
][
$logicId
])
?
$_SESSION
[
'port_logic_id'
][
$logicId
]
:
0
;
$portId
=
isset
(
$_SESSION
[
'port_logic_id'
][
$logicId
])
?
$_SESSION
[
'port_logic_id'
][
$logicId
]
:
0
;
if
(
$portId
!==
0
)
{
if
(
$portId
!==
0
)
{
$this
->
logRecord
->
setPortId
(
$portId
);
$this
->
logRecord
->
setPortId
(
$portId
);
}
}
if
(
Gateway
::
isUidOnline
(
$order
->
getUserId
())
===
1
)
{
if
(
Gateway
::
isUidOnline
(
$order
->
getUserId
())
===
1
)
{
Gateway
::
sendToUid
(
$order
->
getUserId
(),
json_encode
([
'code'
=>
10000
]));
Gateway
::
sendToUid
(
$order
->
getUserId
(),
json_encode
([
'code'
=>
10000
]));
}
}
Log
::
debug
(
'order state code '
.
$orderStateCode
);
switch
(
$orderStateCode
)
{
switch
(
$orderStateCode
)
{
case
StateCode
::
WAITING
:
case
StateCode
::
WAITING
:
$orderState
=
new
WaitingState
(
$order
);
$orderState
=
new
WaitingState
(
$order
);
...
@@ -89,7 +89,7 @@ class OverController extends Controller
...
@@ -89,7 +89,7 @@ class OverController extends Controller
break
;
break
;
}
}
if
(
isset
(
$orderState
)
)
{
if
(
isset
(
$orderState
)
)
{
switch
(
$state
)
{
switch
(
$state
)
{
case
StateCode
::
PORT_EXCEPTION
://
口子打开失败
,
适配zegbee设备
case
StateCode
::
PORT_EXCEPTION
://
口子打开失败
,
适配zegbee设备
$this
->
logRecord
->
setDesc
(
'口子打开失败结束'
);
$this
->
logRecord
->
setDesc
(
'口子打开失败结束'
);
...
@@ -134,7 +134,7 @@ class OverController extends Controller
...
@@ -134,7 +134,7 @@ class OverController extends Controller
case
StateCode
::
CHANGE_PORT
:
case
StateCode
::
CHANGE_PORT
:
if
(
isset
(
$_SESSION
[
'port_logic_id'
])
)
{
if
(
isset
(
$_SESSION
[
'port_logic_id'
])
)
{
$portId
=
isset
(
$_SESSION
[
'port_logic_id'
][
$logicId
])
?
$_SESSION
[
'port_logic_id'
][
$logicId
]
:
0
;
$portId
=
isset
(
$_SESSION
[
'port_logic_id'
][
$logicId
])
?
$_SESSION
[
'port_logic_id'
][
$logicId
]
:
0
;
$port
=
new
Port
(
$portId
);
$port
=
new
Port
(
$portId
);
...
...
application/controller/card/charger/OverController.php
View file @
29296654
...
@@ -11,9 +11,11 @@ namespace Application\controller\card\charger;
...
@@ -11,9 +11,11 @@ namespace Application\controller\card\charger;
use
Application\controller\Controller
;
use
Application\controller\Controller
;
use
Lib\cdz\order\Order
;
use
Lib\cdz\order\Order
;
use
Lib\cdz_order\state\ChargerState
;
use
Lib\cdz\card_order\state\ChargerState
;
use
Lib\cdz_order\state\ShedState
;
use
Lib\cdz\card_order\state\ShedState
;
use
Lib\cdz_order\state\WaitingState
;
use
Lib\cdz\card_order\state\WaitingState
;
use
Lib\Gateway
;
use
Lib\log\Log
;
use
Lib\StateCode
;
use
Lib\StateCode
;
use
Lib\Tool
;
use
Lib\Tool
;
...
@@ -23,9 +25,9 @@ class OverController extends Controller
...
@@ -23,9 +25,9 @@ class OverController extends Controller
protected
$parameterMap
=
[
protected
$parameterMap
=
[
'35'
=>
[
'35'
=>
[
'type'
=>
1
,
'type'
=>
1
,
'logic_id'
=>
1
,
'logic_id'
=>
1
,
'state'
=>
1
,
'state'
=>
1
,
'order_id'
=>
6
,
'order_id'
=>
6
,
'capacity'
=>
4
,
'capacity'
=>
4
,
]
]
...
@@ -42,10 +44,16 @@ class OverController extends Controller
...
@@ -42,10 +44,16 @@ class OverController extends Controller
$order
=
new
Order
(
$orderId
);
$order
=
new
Order
(
$orderId
);
$order
->
setEndCapacity
(
$capacity
);
$order
->
setEndCapacity
(
$capacity
);
Log
::
debug
(
$capacity
);
Log
::
debug
(
$state
);
Log
::
debug
(
$order
->
getEndCapacity
());
$order
->
setEndCode
(
$state
);
$order
->
setEndCode
(
$state
);
$this
->
logRecord
->
setOrderId
(
$orderId
);
$this
->
logRecord
->
setOrderId
(
$orderId
);
if
(
$order
->
getOrderCache
(
\Events
::
getRedis
())
!==
false
)
{
if
(
$order
->
getOrderCache
(
\Events
::
getRedis
())
!==
false
)
{
$orderStateCode
=
$order
->
getStateCode
();
$orderStateCode
=
$order
->
getStateCode
();
$order
->
setEndCapacity
(
$capacity
);
$this
->
logRecord
->
setPortId
(
$order
->
getPortId
());
$this
->
logRecord
->
setPortId
(
$order
->
getPortId
());
...
@@ -60,13 +68,20 @@ class OverController extends Controller
...
@@ -60,13 +68,20 @@ class OverController extends Controller
$orderState
=
new
WaitingState
(
$order
);
$orderState
=
new
WaitingState
(
$order
);
break
;
break
;
default
:
default
:
break
;
break
;
}
}
if
(
isset
(
$orderState
)
)
{
if
(
isset
(
$orderState
)
)
{
switch
(
$state
)
{
switch
(
$state
)
{
case
StateCode
::
FINISH_USER
:
$orderState
->
toUserFinish
();
break
;
case
StateCode
::
FINISH_TIME_END
:
case
StateCode
::
FINISH_TIME_END
:
$orderState
->
toTimeoutState
();
$orderState
->
toTimeoutState
();
break
;
break
;
...
@@ -76,15 +91,24 @@ class OverController extends Controller
...
@@ -76,15 +91,24 @@ class OverController extends Controller
case
StateCode
::
FINISH_EXCEED
:
case
StateCode
::
FINISH_EXCEED
:
$orderState
->
toPowerExceedState
();
$orderState
->
toPowerExceedState
();
break
;
break
;
default
:
case
StateCode
::
FINISH_REFUND
:
$orderState
->
toRefundFinish
();
break
;
break
;
}
case
StateCode
::
FINISH_FULL
:
//充满自停
$this
->
logRecord
->
setDesc
(
'充满自停结束->'
.
$state
);
$orderState
->
toPowerFullState
();
default
:
break
;
}
}
}
}
}
$this
->
response
->
send
(
'45'
,
Tool
::
padding
(
$orderId
,
6
));
Gateway
::
sendToUid
(
$order
->
getUserId
(),
json_encode
([
'command'
=>
'11'
]));
$this
->
response
->
send
(
'55'
,
Tool
::
padding
(
$orderId
,
6
));
}
}
...
...
application/controller/card/charger/RequestController.php
View file @
29296654
...
@@ -16,6 +16,8 @@ use Application\model\UserModel;
...
@@ -16,6 +16,8 @@ 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
;
use
Lib\order_check\DelayOrder
;
use
Lib\station\gateway\port\Port
;
use
Lib\Tool
;
use
Lib\Tool
;
class
RequestController
extends
Controller
class
RequestController
extends
Controller
...
@@ -42,21 +44,20 @@ class RequestController extends Controller
...
@@ -42,21 +44,20 @@ class RequestController extends Controller
$time
=
hexdec
(
$this
->
request
->
get
(
'time'
));
$time
=
hexdec
(
$this
->
request
->
get
(
'time'
));
$price
=
hexdec
(
$this
->
request
->
get
(
'price'
));
$price
=
hexdec
(
$this
->
request
->
get
(
'price'
));
if
(
(
isset
(
$_SESSION
[
'gateway_id'
])
&&
isset
(
$_SESSION
[
'station_id'
])
&&
isset
(
$_SESSION
[
'station_name'
]))
===
false
)
{
if
(
(
isset
(
$_SESSION
[
'gateway_id'
])
&&
isset
(
$_SESSION
[
'station_id'
])
&&
isset
(
$_SESSION
[
'station_name'
]))
===
false
)
{
Log
::
debug
(
'miss gateway)id'
);
Log
::
debug
(
'miss gateway)id'
);
return
;
return
;
}
}
if
(
isset
(
$_SESSION
[
'port_logic_id'
]))
{
if
(
isset
(
$_SESSION
[
'port_logic_id'
])
)
{
Log
::
debug
(
'port_logic_id'
,
$_SESSION
[
'port_logic_id'
]);
if
(
isset
(
$_SESSION
[
'port_logic_id'
][
$logicId
])
)
{
if
(
isset
(
$_SESSION
[
'port_logic_id'
][
$logicId
])
)
{
$portId
=
$_SESSION
[
'port_logic_id'
][
$logicId
];
$portId
=
$_SESSION
[
'port_logic_id'
][
$logicId
];
}
}
}
}
if
(
isset
(
$portId
)
===
false
)
{
if
(
isset
(
$portId
)
===
false
)
{
return
;
return
;
}
}
...
@@ -64,14 +65,12 @@ class RequestController extends Controller
...
@@ -64,14 +65,12 @@ class RequestController extends Controller
$userId
=
$cardModel
->
getColumn
(
'user_id'
,
'mac = '
.
"'
$cardId
'"
);
$userId
=
$cardModel
->
getColumn
(
'user_id'
,
'mac = '
.
"'
$cardId
'"
);
Log
::
debug
(
$userId
);
if
(
isset
(
$userId
)
)
{
if
(
isset
(
$userId
))
{
$userModel
=
new
UserModel
();
$userModel
=
new
UserModel
();
$balance
=
$userModel
->
getColumn
(
'wallet_balance'
,
'id = '
.
$userId
);
$balance
=
$userModel
->
getColumn
(
'wallet_balance'
,
'id = '
.
$userId
);
}
}
$balance
=
isset
(
$balance
)
?
$balance
:
0
;
$balance
=
isset
(
$balance
)
?
$balance
:
0
;
if
(
(
int
)
$balance
<
(
int
)
$price
)
{
if
(
(
int
)
$balance
<
(
int
)
$price
)
{
$orderId
=
0
;
$orderId
=
0
;
}
else
{
}
else
{
...
@@ -85,37 +84,58 @@ class RequestController extends Controller
...
@@ -85,37 +84,58 @@ class RequestController extends Controller
$orderModel
->
insertRow
([
$orderModel
->
insertRow
([
'gateway_id'
=>
$gatewayId
,
'gateway_id'
=>
$gatewayId
,
'station_id'
=>
$stationId
,
'station_id'
=>
$stationId
,
'order_amount'
=>
$price
,
'port_id'
=>
$portId
,
'port_id'
=>
$portId
,
'wx_user_id'
=>
$userId
,
'out_trade_no'
=>
$outTradeNo
,
'out_trade_no'
=>
$outTradeNo
,
'pay_amount'
=>
$price
,
'pay_amount'
=>
$price
,
'charger_time'
=>
$time
,
'charger_time'
=>
$time
,
'created_at'
=>
$date
,
'created_at'
=>
$date
,
'logic_num'
=>
$logicId
,
'logic_num'
=>
$logicId
,
'pay_type'
=>
3
,
'pay_type'
=>
2
,
'station_name'
=>
$stationName
,
'station_name'
=>
$stationName
,
]);
]);
$orderId
=
$orderModel
->
getColumn
(
'id'
,
'out_trade_no = '
.
$outTradeNo
);
$orderId
=
$orderModel
->
getColumn
(
'id'
,
'out_trade_no = '
.
"'
$outTradeNo
'"
);
}
}
$this
->
response
->
send
(
'33'
,
$type
.
Tool
::
padding
(
$logicId
,
1
)
.
Tool
::
padding
(
$time
,
2
)
.
Tool
::
padding
(
$price
,
2
)
.
Tool
::
padding
(
$orderId
,
6
)
.
Tool
::
padding
(
$balance
,
4
));
$this
->
response
->
send
(
'33'
,
$type
.
Tool
::
padding
(
$logicId
,
1
)
.
Tool
::
padding
(
$time
,
2
)
.
Tool
::
padding
(
$price
,
2
)
.
Tool
::
padding
(
$orderId
,
6
)
.
Tool
::
padding
(
$balance
,
4
));
if
(
$orderId
!=
0
)
{
if
(
$orderId
!=
0
)
{
//todo 订单缓存存储
//todo 订单缓存存储
$port
=
new
Port
();
$port
->
setPortId
(
$portId
);
$port
->
setPortUsingOrderId
(
$userId
,
$orderId
);
$port
->
setState
(
-
1
);
$port
->
updatePortState
();
$order
=
new
Order
(
$orderId
);
$order
=
new
Order
(
$orderId
);
$order
->
setStationId
(
$stationId
);
$order
->
setOutTradeNo
(
$outTradeNo
);
$order
->
setGatewayMac
(
$_SESSION
[
'gateway_mac'
]);
$order
->
setPortName
(
$_SESSION
[
'port_id_name'
][
$portId
]);
$order
->
setPortId
(
$portId
);
$order
->
setGatewayId
(
$gatewayId
);
$order
->
setGatewayId
(
$gatewayId
);
$order
->
setCardId
(
$cardId
);
$order
->
setCardId
(
$cardId
);
$order
->
setStationId
(
$stationId
);
$order
->
setStationId
(
$stationId
);
$order
->
setStationName
(
$stationName
);
$order
->
setStationName
(
$stationName
);
$order
->
setCreatedTime
(
time
());
$order
->
setCreatedTime
(
time
());
$order
->
setPayAmount
(
$price
);
$order
->
setPayAmount
(
$price
);
$order
->
setUserId
(
$userId
);
$order
->
setPurchaseTime
(
$time
);
$order
->
setPurchaseTime
(
$time
);
$order
->
setPortLogicId
(
$logicId
);
$order
->
setPortLogicId
(
$logicId
);
$order
->
setStateCode
(
-
1
);
$order
->
setStateCode
(
-
1
);
$order
->
setGatewayType
(
$_SESSION
[
'gateway_type'
]);
$saveOrder
=
new
OrderSaveRedis
(
$order
);
$saveOrder
=
new
OrderSaveRedis
(
$order
);
$saveOrder
->
saveAll
();
$saveOrder
->
saveAll
();
$delayOrder
=
new
DelayOrder
();
$delayOrder
->
setOrder
(
$order
);
$delayOrder
->
setDelay
();
}
}
...
...
application/controller/card/charger/StartController.php
View file @
29296654
...
@@ -10,8 +10,10 @@ namespace Application\controller\card\charger;
...
@@ -10,8 +10,10 @@ namespace Application\controller\card\charger;
use
Application\controller\Controller
;
use
Application\controller\Controller
;
use
Application\model\UserModel
;
use
Lib\cdz\order\Order
;
use
Lib\cdz\order\Order
;
use
Lib\cdz_order\state\WaitingState
;
use
Lib\cdz\card_order\state\WaitingState
;
use
Lib\log\Log
;
use
Lib\StateCode
;
use
Lib\StateCode
;
use
Lib\Tool
;
use
Lib\Tool
;
...
@@ -20,9 +22,9 @@ class StartController extends Controller
...
@@ -20,9 +22,9 @@ class StartController extends Controller
protected
$parameterMap
=
[
protected
$parameterMap
=
[
'34'
=>
[
'34'
=>
[
'type'
=>
1
,
'type'
=>
1
,
'logic_id'
=>
1
,
'logic_id'
=>
1
,
'state'
=>
1
,
'state'
=>
1
,
'order_id'
=>
6
,
'order_id'
=>
6
,
'capacity'
=>
4
,
'capacity'
=>
4
,
...
@@ -41,7 +43,15 @@ class StartController extends Controller
...
@@ -41,7 +43,15 @@ class StartController extends Controller
$capacity
=
hexdec
(
$this
->
request
->
get
(
'capacity'
));
$capacity
=
hexdec
(
$this
->
request
->
get
(
'capacity'
));
$order
=
new
Order
(
$orderId
);
$order
=
new
Order
(
$orderId
);
if
(
$order
->
getOrderCache
(
\Events
::
getRedis
())
!=
false
)
{
if
(
$order
->
getOrderCache
(
\Events
::
getRedis
())
!=
false
)
{
$price
=
$order
->
getPayAmount
();
$userId
=
$order
->
getUserId
();
$userModel
=
new
UserModel
();
Log
::
debug
(
'order_cache'
,
$order
->
getOrderCache
(
\Events
::
getRedis
()));
$orderStateCode
=
$order
->
getStateCode
();
$orderStateCode
=
$order
->
getStateCode
();
$order
->
setStartCapacity
(
$capacity
);
$order
->
setStartCapacity
(
$capacity
);
...
@@ -60,6 +70,13 @@ class StartController extends Controller
...
@@ -60,6 +70,13 @@ class StartController extends Controller
switch
(
$state
)
{
switch
(
$state
)
{
case
StateCode
::
PORT_CHARGER
:
case
StateCode
::
PORT_CHARGER
:
Log
::
debug
(
$price
);
$db
=
\Events
::
getDb
();
$db
->
query
(
"UPDATE `wx_users` SET `wallet_balance` = `wallet_balance` -
$price
WHERE id =
$userId
"
);
Log
::
debug
(
'decrease wallet'
);
$orderState
->
toChargerState
();
$orderState
->
toChargerState
();
break
;
break
;
case
StateCode
::
PORT_SHED
:
case
StateCode
::
PORT_SHED
:
...
...
lib/cdz/card_order/state/ChargerState.php
View file @
29296654
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Time: 上午11:21
* Time: 上午11:21
*/
*/
namespace
Lib\cdz_order\state
;
namespace
Lib\cdz
\card
_order\state
;
use
Application\model\OrderExceptionModel
;
use
Application\model\OrderExceptionModel
;
...
@@ -40,6 +40,8 @@ class ChargerState extends State
...
@@ -40,6 +40,8 @@ class ChargerState extends State
public
function
toUserFinish
()
public
function
toUserFinish
()
{
{
$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
(),
...
@@ -48,6 +50,7 @@ class ChargerState extends State
...
@@ -48,6 +50,7 @@ class ChargerState extends State
'state'
=>
1
,
'state'
=>
1
,
],
'id = '
.
$this
->
order
->
getId
());
],
'id = '
.
$this
->
order
->
getId
());
$port
=
new
Port
();
$port
=
new
Port
();
$port
->
setState
(
StateCode
::
PORT_ONLINE
);
$port
->
setState
(
StateCode
::
PORT_ONLINE
);
$port
->
setPortId
(
$this
->
order
->
getPortId
());
$port
->
setPortId
(
$this
->
order
->
getPortId
());
...
@@ -72,7 +75,7 @@ class ChargerState extends State
...
@@ -72,7 +75,7 @@ class ChargerState extends State
$finishByUserMessage
->
setOrderAmount
(
$this
->
order
->
getPayAmount
());
$finishByUserMessage
->
setOrderAmount
(
$this
->
order
->
getPayAmount
());
$sendMessage
=
new
SendMessage
();
$sendMessage
=
new
SendMessage
();
if
(
$sendMessage
->
request
(
$finishByUserMessage
)
==
false
)
{
if
(
$sendMessage
->
request
(
$finishByUserMessage
)
==
false
)
{
Log
::
error
(
'send finish by user message fail'
);
Log
::
error
(
'send finish by user message fail'
);
}
}
...
@@ -145,7 +148,7 @@ class ChargerState extends State
...
@@ -145,7 +148,7 @@ class ChargerState extends State
$sendMessage
=
new
SendMessage
();
$sendMessage
=
new
SendMessage
();
if
(
$sendMessage
->
request
(
$powerExceedMessage
)
===
false
)
{
if
(
$sendMessage
->
request
(
$powerExceedMessage
)
===
false
)
{
Log
::
error
(
'send power exceed message fail'
);
Log
::
error
(
'send power exceed message fail'
);
//todo tcp异常上报
//todo tcp异常上报
}
}
...
@@ -197,7 +200,7 @@ class ChargerState extends State
...
@@ -197,7 +200,7 @@ class ChargerState extends State
$chargerFullMessage
->
setPurchaseTime
(
$this
->
order
->
getPurchaseTime
());
$chargerFullMessage
->
setPurchaseTime
(
$this
->
order
->
getPurchaseTime
());
$chargerFullMessage
->
setRemark
(
$chargerFullMessage
->
getRemark
()
.
'\n'
.
sprintf
(
'%012x'
,
$this
->
order
->
getId
()));
$chargerFullMessage
->
setRemark
(
$chargerFullMessage
->
getRemark
()
.
'\n'
.
sprintf
(
'%012x'
,
$this
->
order
->
getId
()));
$sendMessage
=
new
SendMessage
();
$sendMessage
=
new
SendMessage
();
if
(
$sendMessage
->
request
(
$chargerFullMessage
)
===
false
)
{
if
(
$sendMessage
->
request
(
$chargerFullMessage
)
===
false
)
{
Log
::
error
(
'send charger full message fail'
);
Log
::
error
(
'send charger full message fail'
);
}
}
$port
=
new
Port
();
$port
=
new
Port
();
...
@@ -268,7 +271,7 @@ class ChargerState extends State
...
@@ -268,7 +271,7 @@ class ChargerState extends State
$chargerShedMessage
->
setDate
(
$this
->
nowDate
);
$chargerShedMessage
->
setDate
(
$this
->
nowDate
);
$sendMessage
=
new
SendMessage
();
$sendMessage
=
new
SendMessage
();
if
(
$sendMessage
->
request
(
$chargerShedMessage
)
==
false
)
{
if
(
$sendMessage
->
request
(
$chargerShedMessage
)
==
false
)
{
Log
::
error
(
'send port shed message fail'
);
Log
::
error
(
'send port shed message fail'
);
}
}
...
@@ -338,13 +341,14 @@ class ChargerState extends State
...
@@ -338,13 +341,14 @@ class ChargerState extends State
$chargerTimeoutMessage
->
setOrderAmount
(
$this
->
order
->
getPayAmount
());
$chargerTimeoutMessage
->
setOrderAmount
(
$this
->
order
->
getPayAmount
());
$chargerTimeoutMessage
->
setEndTime
(
$this
->
nowDate
);
$chargerTimeoutMessage
->
setEndTime
(
$this
->
nowDate
);
$chargerTimeoutMessage
->
setUserId
(
$this
->
order
->
getUserId
());
$chargerTimeoutMessage
->
setUserId
(
$this
->
order
->
getUserId
());
$chargerTime
=
$this
->
now
TimeStamp
-
$this
->
order
->
getStartTime
();
$chargerTime
=
$this
->
now
Date
-
$this
->
order
->
getStartTime
();
$chargerTime
/=
60
;
$chargerTime
/=
60
;
$chargerTime
=
ceil
(
$chargerTime
);
$chargerTimeoutMessage
->
setChargerTime
((
int
)
$chargerTime
);
$chargerTimeoutMessage
->
setChargerTime
((
int
)
$chargerTime
);
$sendMessage
=
new
SendMessage
();
$sendMessage
=
new
SendMessage
();
if
(
$sendMessage
->
request
(
$chargerTimeoutMessage
)
==
false
)
{
if
(
$sendMessage
->
request
(
$chargerTimeoutMessage
)
==
false
)
{
Log
::
error
(
'send charger timeout message fail'
);
Log
::
error
(
'send charger timeout message fail'
);
}
}
...
...
lib/cdz/card_order/state/ExceptionState.php
View file @
29296654
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Time: 上午11:22
* Time: 上午11:22
*/
*/
namespace
Lib\cdz_order\state
;
namespace
Lib\cdz
\card
_order\state
;
use
Lib\cdz\order\Order
;
use
Lib\cdz\order\Order
;
...
...
lib/cdz/card_order/state/OfflineNetState.php
View file @
29296654
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Time: 下午6:45
* Time: 下午6:45
*/
*/
namespace
Lib\cdz_order\state
;
namespace
Lib\cdz
\card
_order\state
;
use
Lib\cdz\order\NoticePortShed
;
use
Lib\cdz\order\NoticePortShed
;
...
@@ -28,7 +28,7 @@ class OfflineNetState extends State
...
@@ -28,7 +28,7 @@ class OfflineNetState extends State
$startTime
=
$this
->
order
->
getStartTime
();
$startTime
=
$this
->
order
->
getStartTime
();
if
(
$startTime
===
''
||
$this
->
order
->
getOfflineTime
()
==
'0'
)
{
if
(
$startTime
===
''
||
$this
->
order
->
getOfflineTime
()
==
'0'
)
{
$this
->
remainChargerTime
=
(
int
)(
$this
->
order
->
getPurchaseTime
());
$this
->
remainChargerTime
=
(
int
)(
$this
->
order
->
getPurchaseTime
());
}
else
{
}
else
{
$purchaseTime
=
$this
->
order
->
getPurchaseTime
();
$purchaseTime
=
$this
->
order
->
getPurchaseTime
();
...
@@ -57,7 +57,7 @@ class OfflineNetState extends State
...
@@ -57,7 +57,7 @@ class OfflineNetState extends State
public
function
toChargerState
()
public
function
toChargerState
()
{
{
if
(
$this
->
order
->
getIsRefund
()
===
1
)
{
if
(
$this
->
order
->
getIsRefund
()
===
1
)
{
//已经退款 下发结束充电命令
//已经退款 下发结束充电命令
$this
->
order
->
stop
(
$this
->
order
,
$_SESSION
[
'client_id'
],
43
);
$this
->
order
->
stop
(
$this
->
order
,
$_SESSION
[
'client_id'
],
43
);
return
;
return
;
...
@@ -87,7 +87,7 @@ class OfflineNetState extends State
...
@@ -87,7 +87,7 @@ class OfflineNetState extends State
*/
*/
public
function
toShedState
()
public
function
toShedState
()
{
{
if
(
$this
->
remainChargerTime
>
0
)
{
if
(
$this
->
remainChargerTime
>
0
)
{
$this
->
publishPortShed
(
$this
->
order
);
$this
->
publishPortShed
(
$this
->
order
);
}
}
...
...
lib/cdz/card_order/state/OfflinePowerState.php
View file @
29296654
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Time: 下午6:45
* Time: 下午6:45
*/
*/
namespace
Lib\cdz_order\state
;
namespace
Lib\cdz
\card
_order\state
;
use
Lib\cdz\order\Order
;
use
Lib\cdz\order\Order
;
...
@@ -21,7 +21,7 @@ class OfflinePowerState extends State
...
@@ -21,7 +21,7 @@ class OfflinePowerState extends State
public
function
__construct
(
Order
$order
)
public
function
__construct
(
Order
$order
)
{
{
parent
::
__construct
(
$order
);
parent
::
__construct
(
$order
);
if
(
$this
->
order
->
getIsRefund
()
===
1
)
{
if
(
$this
->
order
->
getIsRefund
()
===
1
)
{
//已经退款 下发结束充电命令
//已经退款 下发结束充电命令
//$this->order->stop($this->order,$_SESSION['client_id'],43);
//$this->order->stop($this->order,$_SESSION['client_id'],43);
$this
->
remainChargerTime
=
0
;
$this
->
remainChargerTime
=
0
;
...
@@ -31,7 +31,7 @@ class OfflinePowerState extends State
...
@@ -31,7 +31,7 @@ class OfflinePowerState extends State
$offlineTime
=
$this
->
order
->
getOfflineTime
();
$offlineTime
=
$this
->
order
->
getOfflineTime
();
$startTime
=
$this
->
order
->
getStartTime
();
$startTime
=
$this
->
order
->
getStartTime
();
if
(
$startTime
===
''
||
$this
->
order
->
getOfflineTime
()
==
'0'
)
{
if
(
$startTime
===
''
||
$this
->
order
->
getOfflineTime
()
==
'0'
)
{
$this
->
remainChargerTime
=
(
int
)(
$this
->
order
->
getPurchaseTime
());
$this
->
remainChargerTime
=
(
int
)(
$this
->
order
->
getPurchaseTime
());
}
else
{
}
else
{
...
@@ -56,7 +56,7 @@ class OfflinePowerState extends State
...
@@ -56,7 +56,7 @@ class OfflinePowerState extends State
public
function
toChargerState
()
public
function
toChargerState
()
{
{
if
(
$this
->
order
->
getIsRefund
()
===
1
)
{
if
(
$this
->
order
->
getIsRefund
()
===
1
)
{
//已经退款 下发结束充电命令
//已经退款 下发结束充电命令
//$this->order->stop($this->order,$_SESSION['client_id'],43);
//$this->order->stop($this->order,$_SESSION['client_id'],43);
$this
->
remainChargerTime
=
0
;
$this
->
remainChargerTime
=
0
;
...
...
lib/cdz/card_order/state/PowerExceedState.php
View file @
29296654
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Time: 上午11:22
* Time: 上午11:22
*/
*/
namespace
Lib\cdz_order\state
;
namespace
Lib\cdz
\card
_order\state
;
use
Lib\cdz\order\Order
;
use
Lib\cdz\order\Order
;
...
...
lib/cdz/card_order/state/PowerFullState.php
View file @
29296654
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Time: 上午11:22
* Time: 上午11:22
*/
*/
namespace
Lib\cdz_order\state
;
namespace
Lib\cdz
\card
_order\state
;
use
Lib\cdz\order\Order
;
use
Lib\cdz\order\Order
;
...
...
lib/cdz/card_order/state/ShedState.php
View file @
29296654
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Time: 上午11:21
* Time: 上午11:21
*/
*/
namespace
Lib\cdz_order\state
;
namespace
Lib\cdz
\card
_order\state
;
use
Application\model\OrderExceptionModel
;
use
Application\model\OrderExceptionModel
;
...
@@ -36,11 +36,11 @@ class ShedState extends State
...
@@ -36,11 +36,11 @@ class ShedState 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
();
...
@@ -64,15 +64,15 @@ class ShedState extends State
...
@@ -64,15 +64,15 @@ class ShedState extends State
$finishByUserMessage
->
setOrderAmount
(
$this
->
order
->
getPayAmount
());
$finishByUserMessage
->
setOrderAmount
(
$this
->
order
->
getPayAmount
());
$sendMessage
=
new
SendMessage
();
$sendMessage
=
new
SendMessage
();
if
(
$sendMessage
->
request
(
$finishByUserMessage
)
==
false
)
{
if
(
$sendMessage
->
request
(
$finishByUserMessage
)
==
false
)
{
Log
::
error
(
'send finish by user message fail'
);
Log
::
error
(
'send finish by user message fail'
);
}
}
$orderException
=
new
OrderExceptionModel
();
$orderException
=
new
OrderExceptionModel
();
$orderException
->
insertRow
([
$orderException
->
insertRow
([
'order_id'
=>
$this
->
order
->
getId
(),
'order_id'
=>
$this
->
order
->
getId
(),
'state'
=>
StateCode
::
PORT_SHED
.
StateCode
::
FINISH_USER
,
'state'
=>
StateCode
::
PORT_SHED
.
StateCode
::
FINISH_USER
,
'desc'
=>
'用户主动结束充电'
,
'desc'
=>
'用户主动结束充电'
,
'created_at'
=>
$this
->
nowDate
,
'created_at'
=>
$this
->
nowDate
,
]);
]);
...
@@ -115,7 +115,7 @@ class ShedState extends State
...
@@ -115,7 +115,7 @@ class ShedState extends State
$sendMessage
=
new
SendMessage
();
$sendMessage
=
new
SendMessage
();
if
(
$sendMessage
->
request
(
$chargerReloadMessage
)
===
false
)
{
if
(
$sendMessage
->
request
(
$chargerReloadMessage
)
===
false
)
{
Log
::
error
(
'send order reload message fail'
);
Log
::
error
(
'send order reload message fail'
);
}
}
...
@@ -123,10 +123,10 @@ class ShedState extends State
...
@@ -123,10 +123,10 @@ class ShedState extends State
$orderExceptionModel
=
new
OrderExceptionModel
();
$orderExceptionModel
=
new
OrderExceptionModel
();
$orderExceptionModel
->
insertRow
(
$orderExceptionModel
->
insertRow
(
[
[
'order_id'
=>
$this
->
order
->
getId
(),
'order_id'
=>
$this
->
order
->
getId
(),
'state'
=>
StateCode
::
PORT_SHED
.
StateCode
::
PORT_CHARGER
,
'state'
=>
StateCode
::
PORT_SHED
.
StateCode
::
PORT_CHARGER
,
'created_at'
=>
$this
->
nowDate
,
'created_at'
=>
$this
->
nowDate
,
'desc'
=>
'订单口子脱落重新插上'
,
'desc'
=>
'订单口子脱落重新插上'
,
]
]
);
);
...
@@ -168,18 +168,18 @@ class ShedState extends State
...
@@ -168,18 +168,18 @@ class ShedState extends State
{
{
$orderExceptionModel
=
new
OrderExceptionModel
();
$orderExceptionModel
=
new
OrderExceptionModel
();
$orderExceptionModel
->
insertRow
([
$orderExceptionModel
->
insertRow
([
'order_id'
=>
$this
->
order
->
getId
(),
'order_id'
=>
$this
->
order
->
getId
(),
'state'
=>
StateCode
::
PORT_SHED
.
StateCode
::
FINISH_SHED_TIMEOUT
,
'state'
=>
StateCode
::
PORT_SHED
.
StateCode
::
FINISH_SHED_TIMEOUT
,
'created_at'
=>
$this
->
nowDate
,
'created_at'
=>
$this
->
nowDate
,
'desc'
=>
'订单口子脱落超时结束'
,
'desc'
=>
'订单口子脱落超时结束'
,
]);
]);
$orderModel
=
new
OrderModel
();
$orderModel
=
new
OrderModel
();
$orderModel
->
update
([
$orderModel
->
update
([
'state'
=>
1
,
'state'
=>
1
,
'updated_at'
=>
$this
->
nowDate
,
'updated_at'
=>
$this
->
nowDate
,
'end_time'
=>
$this
->
nowDate
,
'end_time'
=>
$this
->
nowDate
,
'is_stop'
=>
StateCode
::
FINISH_SHED_TIMEOUT
,
'is_stop'
=>
StateCode
::
FINISH_SHED_TIMEOUT
,
'end_capacity'
=>
$this
->
order
->
getEndCapacity
(),
'end_capacity'
=>
$this
->
order
->
getEndCapacity
(),
],
'id = '
.
$this
->
order
->
getId
());
],
'id = '
.
$this
->
order
->
getId
());
...
@@ -198,16 +198,16 @@ class ShedState extends State
...
@@ -198,16 +198,16 @@ class ShedState extends State
$sendMessage
=
new
SendMessage
();
$sendMessage
=
new
SendMessage
();
if
(
$sendMessage
->
request
(
$shedTimeoutMessage
)
===
false
)
{
if
(
$sendMessage
->
request
(
$shedTimeoutMessage
)
===
false
)
{
Log
::
error
(
'send shed timeout message fail'
);
Log
::
error
(
'send shed timeout message fail'
);
}
}
$orderModel
=
new
OrderModel
();
$orderModel
=
new
OrderModel
();
$orderModel
->
update
([
$orderModel
->
update
([
'is_stop'
=>
StateCode
::
FINISH_SHED_TIMEOUT
,
'is_stop'
=>
StateCode
::
FINISH_SHED_TIMEOUT
,
'end_capacity'
=>
$this
->
order
->
getEndCapacity
(),
'end_capacity'
=>
$this
->
order
->
getEndCapacity
(),
'state'
=>
1
,
'state'
=>
1
,
],
'id = '
.
$this
->
order
->
getId
());
],
'id = '
.
$this
->
order
->
getId
());
...
@@ -224,19 +224,19 @@ class ShedState extends State
...
@@ -224,19 +224,19 @@ class ShedState extends State
{
{
$orderExceptionModel
=
new
OrderExceptionModel
();
$orderExceptionModel
=
new
OrderExceptionModel
();
$orderExceptionModel
->
insertRow
([
$orderExceptionModel
->
insertRow
([
'order_id'
=>
$this
->
order
->
getId
(),
'order_id'
=>
$this
->
order
->
getId
(),
'state'
=>
StateCode
::
PORT_SHED
.
StateCode
::
FINISH_TIME_END
,
'state'
=>
StateCode
::
PORT_SHED
.
StateCode
::
FINISH_TIME_END
,
'created_at'
=>
$this
->
nowDate
,
'created_at'
=>
$this
->
nowDate
,
'desc'
=>
'订单充电时间结束'
,
'desc'
=>
'订单充电时间结束'
,
]);
]);
$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
(),
'state'
=>
1
,
'state'
=>
1
,
'updated_at'
=>
$this
->
nowDate
,
'updated_at'
=>
$this
->
nowDate
,
'end_time'
=>
$this
->
nowDate
,
'end_time'
=>
$this
->
nowDate
,
],
'id = '
.
$this
->
order
->
getId
());
],
'id = '
.
$this
->
order
->
getId
());
$port
=
new
Port
(
$this
->
order
->
getPortId
());
$port
=
new
Port
(
$this
->
order
->
getPortId
());
...
@@ -257,7 +257,7 @@ class ShedState extends State
...
@@ -257,7 +257,7 @@ class ShedState extends State
$chargerTimeoutMessage
->
setStationName
(
$this
->
order
->
getStationName
());
$chargerTimeoutMessage
->
setStationName
(
$this
->
order
->
getStationName
());
$sendMessage
=
new
SendMessage
();
$sendMessage
=
new
SendMessage
();
if
(
$sendMessage
->
request
(
$chargerTimeoutMessage
)
===
false
)
{
if
(
$sendMessage
->
request
(
$chargerTimeoutMessage
)
===
false
)
{
Log
::
error
(
'shed state order send charger timeout message fail'
);
Log
::
error
(
'shed state order send charger timeout message fail'
);
}
}
...
@@ -270,5 +270,10 @@ class ShedState extends State
...
@@ -270,5 +270,10 @@ class ShedState extends State
// TODO: Implement stopFail() method.
// TODO: Implement stopFail() method.
}
}
public
function
toRefundFinish
()
{
}
}
}
\ No newline at end of file
lib/cdz/card_order/state/ShedTimeoutState.php
View file @
29296654
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Time: 上午11:23
* Time: 上午11:23
*/
*/
namespace
Lib\cdz_order\state
;
namespace
Lib\cdz
\card
_order\state
;
use
Lib\cdz\order\Order
;
use
Lib\cdz\order\Order
;
...
...
lib/cdz/card_order/state/State.php
View file @
29296654
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Time: 上午11:21
* Time: 上午11:21
*/
*/
namespace
Lib\cdz_order\state
;
namespace
Lib\cdz
\card
_order\state
;
use
Lib\cdz\order\Order
;
use
Lib\cdz\order\Order
;
...
@@ -82,5 +82,4 @@ abstract class State
...
@@ -82,5 +82,4 @@ abstract class State
}
}
}
}
\ No newline at end of file
lib/cdz/card_order/state/TimeoutState.php
View file @
29296654
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Time: 上午11:23
* Time: 上午11:23
*/
*/
namespace
Lib\cdz_order\state
;
namespace
Lib\cdz
\card
_order\state
;
use
Lib\cdz\order\Order
;
use
Lib\cdz\order\Order
;
...
...
lib/cdz/card_order/state/WaitingState.php
View file @
29296654
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Time: 上午11:21
* Time: 上午11:21
*/
*/
namespace
Lib\cdz_order\state
;
namespace
Lib\cdz
\card
_order\state
;
use
Application\model\OrderExceptionModel
;
use
Application\model\OrderExceptionModel
;
...
@@ -14,13 +14,8 @@ use Application\model\OrderModel;
...
@@ -14,13 +14,8 @@ use Application\model\OrderModel;
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
;
use
Lib\remote\api\message\FailMessage
;
use
Lib\remote\api\message\SendMessage
;
use
Lib\remote\api\message\StartMessage
;
use
Lib\StateCode
;
use
Lib\StateCode
;
use
Lib\station\gateway\port\Port
;
use
Lib\station\gateway\port\Port
;
use
Src\command\SendCommand
;
use
Src\command\StopChargerCommand
;
class
WaitingState
extends
State
class
WaitingState
extends
State
{
{
...
@@ -54,9 +49,9 @@ class WaitingState extends State
...
@@ -54,9 +49,9 @@ class WaitingState extends State
$orderModel
=
new
OrderModel
();
$orderModel
=
new
OrderModel
();
$orderModel
->
update
([
$orderModel
->
update
([
'is_stop'
=>
StateCode
::
FINISH_REFUND
,
'is_stop'
=>
StateCode
::
FINISH_REFUND
,
'end_capacity'
=>
$this
->
order
->
getEndCapacity
(),
'end_capacity'
=>
$this
->
order
->
getEndCapacity
(),
'end_time'
=>
date
(
'Y-m-d H:i:s'
),
'end_time'
=>
date
(
'Y-m-d H:i:s'
),
],
'id = '
.
$this
->
order
->
getId
());
],
'id = '
.
$this
->
order
->
getId
());
$port
=
new
Port
();
$port
=
new
Port
();
...
@@ -104,8 +99,8 @@ class WaitingState extends State
...
@@ -104,8 +99,8 @@ 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
(),
'start_capacity'
=>
$this
->
order
->
getStartCapacity
(),
];
];
$orderModel
=
new
OrderModel
();
$orderModel
=
new
OrderModel
();
...
@@ -144,9 +139,9 @@ class WaitingState extends State
...
@@ -144,9 +139,9 @@ class WaitingState extends State
$orderExceptionModel
=
new
OrderExceptionModel
();
$orderExceptionModel
=
new
OrderExceptionModel
();
$orderExceptionModel
->
insertRow
([
$orderExceptionModel
->
insertRow
([
'order_id'
=>
$this
->
order
->
getId
(),
'order_id'
=>
$this
->
order
->
getId
(),
'state'
=>
'-1'
.
StateCode
::
PORT_EXCEPTION
,
'state'
=>
'-1'
.
StateCode
::
PORT_EXCEPTION
,
'desc'
=>
'打开口子失败'
,
'desc'
=>
'打开口子失败'
,
'created_at'
=>
date
(
'Y-m-d H:i:s'
),
'created_at'
=>
date
(
'Y-m-d H:i:s'
),
]);
]);
//推送消息
//推送消息
...
...
lib/cdz/order/Order.php
View file @
29296654
...
@@ -20,6 +20,9 @@ class Order
...
@@ -20,6 +20,9 @@ class Order
private
$isChangeState
=
false
;
private
$isChangeState
=
false
;
private
$gatewayType
=
0
;
/**
/**
* @var int
* @var int
*/
*/
...
@@ -68,7 +71,7 @@ class Order
...
@@ -68,7 +71,7 @@ class Order
* 订单状态
* 订单状态
* @var int
* @var int
*/
*/
private
$stateCode
;
private
$stateCode
=
-
2
;
/**
/**
* @var int
* @var int
...
@@ -184,12 +187,12 @@ class Order
...
@@ -184,12 +187,12 @@ class Order
{
{
if
(
isset
(
$this
->
orderCache
)
==
false
||
(
is_array
(
$this
->
orderCache
)
&&
count
(
$this
->
orderCache
)
===
0
)
)
{
if
(
isset
(
$this
->
orderCache
)
==
false
||
(
is_array
(
$this
->
orderCache
)
&&
count
(
$this
->
orderCache
)
===
0
)
)
{
$keyName
=
$this
->
getCacheKeyName
();
$keyName
=
$this
->
getCacheKeyName
();
if
(
$redis
->
exists
(
$keyName
)
==
false
)
{
if
(
$redis
->
exists
(
$keyName
)
==
false
)
{
return
false
;
return
false
;
...
@@ -197,7 +200,7 @@ class Order
...
@@ -197,7 +200,7 @@ class Order
$this
->
orderCache
=
$redis
->
hGetAll
(
$keyName
);
$this
->
orderCache
=
$redis
->
hGetAll
(
$keyName
);
if
(
count
(
$this
->
orderCache
)
<
5
)
{
if
(
count
(
$this
->
orderCache
)
<
5
)
{
return
false
;
return
false
;
}
}
...
@@ -231,7 +234,7 @@ class Order
...
@@ -231,7 +234,7 @@ class Order
{
{
$keyName
=
$this
->
getCacheKeyName
();
$keyName
=
$this
->
getCacheKeyName
();
if
(
$redis
->
exists
(
$keyName
)
==
false
)
{
if
(
$redis
->
exists
(
$keyName
)
==
false
)
{
return
false
;
return
false
;
...
@@ -251,7 +254,7 @@ class Order
...
@@ -251,7 +254,7 @@ class Order
/**
/**
* @param \Redis $redis
* @param \Redis $redis
* @param $orderCache
* @param
$orderCache
*/
*/
public
function
setOrderCache
(
\Redis
$redis
,
$orderCache
)
:
void
public
function
setOrderCache
(
\Redis
$redis
,
$orderCache
)
:
void
{
{
...
@@ -668,5 +671,21 @@ class Order
...
@@ -668,5 +671,21 @@ class Order
$this
->
isChangeState
=
$isChangeState
;
$this
->
isChangeState
=
$isChangeState
;
}
}
/**
* @return int
*/
public
function
getGatewayType
()
:
int
{
return
$this
->
gatewayType
;
}
/**
* @param int $gatewayType
*/
public
function
setGatewayType
(
int
$gatewayType
)
:
void
{
$this
->
gatewayType
=
$gatewayType
;
}
}
}
\ No newline at end of file
lib/cdz/order/save/OrderSaveRedis.php
View file @
29296654
...
@@ -40,7 +40,7 @@ class OrderSaveRedis
...
@@ -40,7 +40,7 @@ class OrderSaveRedis
$update
=
[];
$update
=
[];
foreach
(
$keys
as
$key
)
{
foreach
(
$keys
as
$key
)
{
if
(
$this
->
order
->
$key
!==
""
)
{
if
(
$this
->
order
->
$key
!==
""
)
{
$update
[
$key
]
=
$this
->
order
->
$key
;
$update
[
$key
]
=
$this
->
order
->
$key
;
}
}
}
}
...
@@ -64,9 +64,13 @@ class OrderSaveRedis
...
@@ -64,9 +64,13 @@ class OrderSaveRedis
$reflection
=
new
\ReflectionClass
(
$this
->
order
);
$reflection
=
new
\ReflectionClass
(
$this
->
order
);
$properties
=
$reflection
->
getDefaultProperties
();
$properties
=
$reflection
->
getDefaultProperties
();
$properties
=
array_keys
(
$properties
);
foreach
(
$properties
as
$property
)
{
foreach
(
$properties
as
$property
)
{
if
(
isset
(
$this
->
order
->
$property
)
&&
$this
->
order
->
$property
!=
''
)
{
if
(
$this
->
order
->
$property
!==
''
)
{
Log
::
debug
(
'value'
.
$this
->
order
->
$property
);
$update
[
$property
]
=
$this
->
order
->
$property
;
$update
[
$property
]
=
$this
->
order
->
$property
;
}
}
}
}
...
@@ -77,6 +81,8 @@ class OrderSaveRedis
...
@@ -77,6 +81,8 @@ class OrderSaveRedis
}
}
Log
::
debug
(
'save all'
,
$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
);
...
...
lib/cdz/order/state/ChargerState.php
View file @
29296654
...
@@ -76,7 +76,7 @@ class ChargerState extends State
...
@@ -76,7 +76,7 @@ class ChargerState extends State
$finishByUserMessage
->
setOrderAmount
(
$this
->
order
->
getPayAmount
());
$finishByUserMessage
->
setOrderAmount
(
$this
->
order
->
getPayAmount
());
$sendMessage
=
new
SendMessage
();
$sendMessage
=
new
SendMessage
();
if
(
$sendMessage
->
request
(
$finishByUserMessage
)
==
false
)
{
if
(
$sendMessage
->
request
(
$finishByUserMessage
)
==
false
)
{
Log
::
error
(
'send finish by user message fail'
);
Log
::
error
(
'send finish by user message fail'
);
}
}
...
@@ -162,7 +162,7 @@ class ChargerState extends State
...
@@ -162,7 +162,7 @@ class ChargerState extends State
$sendMessage
=
new
SendMessage
();
$sendMessage
=
new
SendMessage
();
if
(
$sendMessage
->
request
(
$powerExceedMessage
)
===
false
)
{
if
(
$sendMessage
->
request
(
$powerExceedMessage
)
===
false
)
{
Log
::
error
(
'send power exceed message fail'
);
Log
::
error
(
'send power exceed message fail'
);
//todo tcp异常上报
//todo tcp异常上报
}
}
...
@@ -214,11 +214,16 @@ class ChargerState extends State
...
@@ -214,11 +214,16 @@ class ChargerState extends State
$chargerFullMessage
=
new
ChargerFullMessage
();
$chargerFullMessage
=
new
ChargerFullMessage
();
$chargerFullMessage
->
setEndTime
(
$this
->
nowDate
);
$chargerFullMessage
->
setEndTime
(
$this
->
nowDate
);
$chargerFullMessage
->
setStartTime
(
date
(
'Y-m-d H:i:s'
,
$this
->
order
->
getStartTime
()));
$chargerFullMessage
->
setStartTime
(
date
(
'Y-m-d H:i:s'
,
$this
->
order
->
getStartTime
()));
$chargerFullMessage
->
setChargerTime
(
abs
(
ceil
((
$this
->
order
->
getStartTime
()
-
$this
->
order
->
getFinishTime
())
/
60
)));
$chargerFullMessage
->
setPurchaseTime
(
$this
->
order
->
getPurchaseTime
());
$chargerFullMessage
->
setPurchaseTime
(
$this
->
order
->
getPurchaseTime
());
$chargerFullMessage
->
setUserId
(
$this
->
order
->
getUserId
());
$chargerFullMessage
->
setUserId
(
$this
->
order
->
getUserId
());
$chargerFullMessage
->
setEndTime
(
$this
->
nowDate
);
$chargerFullMessage
->
setAddress
(
$this
->
order
->
getStationName
()
.
'--'
.
$this
->
order
->
getPortName
());
$chargerFullMessage
->
setAmount
(
$this
->
order
->
getPayAmount
());
$chargerFullMessage
->
setRemark
(
$chargerFullMessage
->
getRemark
()
.
'('
.
$this
->
order
->
getOutTradeNo
()
.
')'
);
$chargerFullMessage
->
setRemark
(
$chargerFullMessage
->
getRemark
()
.
'('
.
$this
->
order
->
getOutTradeNo
()
.
')'
);
$sendMessage
=
new
SendMessage
();
$sendMessage
=
new
SendMessage
();
if
(
$sendMessage
->
request
(
$chargerFullMessage
)
===
false
)
{
if
(
$sendMessage
->
request
(
$chargerFullMessage
)
===
false
)
{
Log
::
error
(
'send charger full message fail'
);
Log
::
error
(
'send charger full message fail'
);
}
}
$port
=
new
Port
();
$port
=
new
Port
();
...
@@ -300,7 +305,7 @@ class ChargerState extends State
...
@@ -300,7 +305,7 @@ class ChargerState extends State
$chargerShedMessage
->
setDate
(
$this
->
nowDate
);
$chargerShedMessage
->
setDate
(
$this
->
nowDate
);
$sendMessage
=
new
SendMessage
();
$sendMessage
=
new
SendMessage
();
if
(
$sendMessage
->
request
(
$chargerShedMessage
)
==
false
)
{
if
(
$sendMessage
->
request
(
$chargerShedMessage
)
==
false
)
{
Log
::
error
(
'send port shed message fail'
);
Log
::
error
(
'send port shed message fail'
);
}
}
...
@@ -311,13 +316,14 @@ class ChargerState extends State
...
@@ -311,13 +316,14 @@ 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'
],
'gateway_type'
=>
$_SESSION
[
'gateway_type'
],
]);
]);
}
catch
(
\Exception
$exception
)
{
}
catch
(
\Exception
$exception
)
{
...
@@ -376,7 +382,7 @@ class ChargerState extends State
...
@@ -376,7 +382,7 @@ class ChargerState extends State
$chargerTimeoutMessage
->
setChargerTime
(
ceil
(
$chargerTime
));
$chargerTimeoutMessage
->
setChargerTime
(
ceil
(
$chargerTime
));
$sendMessage
=
new
SendMessage
();
$sendMessage
=
new
SendMessage
();
if
(
$sendMessage
->
request
(
$chargerTimeoutMessage
)
==
false
)
{
if
(
$sendMessage
->
request
(
$chargerTimeoutMessage
)
==
false
)
{
Log
::
error
(
'send charger timeout message fail'
);
Log
::
error
(
'send charger timeout message fail'
);
}
}
...
...
lib/cdz/order/state/ShedState.php
View file @
29296654
...
@@ -65,7 +65,7 @@ class ShedState extends State
...
@@ -65,7 +65,7 @@ class ShedState extends State
$finishByUserMessage
->
setOrderAmount
(
$this
->
order
->
getPayAmount
());
$finishByUserMessage
->
setOrderAmount
(
$this
->
order
->
getPayAmount
());
$sendMessage
=
new
SendMessage
();
$sendMessage
=
new
SendMessage
();
if
(
$sendMessage
->
request
(
$finishByUserMessage
)
==
false
)
{
if
(
$sendMessage
->
request
(
$finishByUserMessage
)
==
false
)
{
Log
::
error
(
'send finish by user message fail'
);
Log
::
error
(
'send finish by user message fail'
);
}
}
...
@@ -116,7 +116,7 @@ class ShedState extends State
...
@@ -116,7 +116,7 @@ class ShedState extends State
$sendMessage
=
new
SendMessage
();
$sendMessage
=
new
SendMessage
();
if
(
$sendMessage
->
request
(
$chargerReloadMessage
)
===
false
)
{
if
(
$sendMessage
->
request
(
$chargerReloadMessage
)
===
false
)
{
Log
::
error
(
'send order reload message fail'
);
Log
::
error
(
'send order reload message fail'
);
}
}
...
@@ -186,7 +186,6 @@ class ShedState extends State
...
@@ -186,7 +186,6 @@ class ShedState extends State
],
'id = '
.
$this
->
order
->
getId
());
],
'id = '
.
$this
->
order
->
getId
());
$port
=
new
Port
(
$this
->
order
->
getPortId
());
$port
=
new
Port
(
$this
->
order
->
getPortId
());
$port
->
setState
(
StateCode
::
PORT_ONLINE
);
$port
->
setState
(
StateCode
::
PORT_ONLINE
);
$port
->
setStationId
(
$this
->
order
->
getStationId
());
$port
->
setStationId
(
$this
->
order
->
getStationId
());
...
@@ -201,7 +200,7 @@ class ShedState extends State
...
@@ -201,7 +200,7 @@ class ShedState extends State
$sendMessage
=
new
SendMessage
();
$sendMessage
=
new
SendMessage
();
if
(
$sendMessage
->
request
(
$shedTimeoutMessage
)
===
false
)
{
if
(
$sendMessage
->
request
(
$shedTimeoutMessage
)
===
false
)
{
Log
::
error
(
'send shed timeout message fail'
);
Log
::
error
(
'send shed timeout message fail'
);
}
}
...
@@ -260,7 +259,7 @@ class ShedState extends State
...
@@ -260,7 +259,7 @@ class ShedState extends State
$chargerTimeoutMessage
->
setStationName
(
$this
->
order
->
getStationName
());
$chargerTimeoutMessage
->
setStationName
(
$this
->
order
->
getStationName
());
$sendMessage
=
new
SendMessage
();
$sendMessage
=
new
SendMessage
();
if
(
$sendMessage
->
request
(
$chargerTimeoutMessage
)
===
false
)
{
if
(
$sendMessage
->
request
(
$chargerTimeoutMessage
)
===
false
)
{
Log
::
error
(
'shed state order send charger timeout message fail'
);
Log
::
error
(
'shed state order send charger timeout message fail'
);
}
}
...
@@ -268,6 +267,11 @@ class ShedState extends State
...
@@ -268,6 +267,11 @@ class ShedState extends State
}
}
public
function
toRefundFinish
()
{
}
public
function
stopFail
()
public
function
stopFail
()
{
{
// TODO: Implement stopFail() method.
// TODO: Implement stopFail() method.
...
...
lib/cdz/order/state/WaitingState.php
View file @
29296654
...
@@ -11,6 +11,7 @@ namespace Lib\cdz\order\state;
...
@@ -11,6 +11,7 @@ namespace Lib\cdz\order\state;
use
Application\model\OrderExceptionModel
;
use
Application\model\OrderExceptionModel
;
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\Gateway
;
use
Lib\Gateway
;
...
@@ -88,7 +89,7 @@ class WaitingState extends State
...
@@ -88,7 +89,7 @@ class WaitingState extends State
//订单已经退款则直接结束
//订单已经退款则直接结束
if
(
$this
->
order
->
getIsRefund
()
==
1
)
{
if
(
$this
->
order
->
getIsRefund
()
==
1
)
{
// 下发结束充电命令
// 下发结束充电命令
$orderId
=
$this
->
order
->
getId
();
$orderId
=
$this
->
order
->
getId
();
$portLogic
=
$this
->
order
->
getPortLogicId
();
$portLogic
=
$this
->
order
->
getPortLogicId
();
...
@@ -108,7 +109,7 @@ class WaitingState extends State
...
@@ -108,7 +109,7 @@ 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
)
{
if
(
$this
->
order
->
isChangeState
()
===
false
)
{
$orderSaveRedis
->
save
([
'stateCode'
,
'startTime'
,
'startCapacity'
]);
$orderSaveRedis
->
save
([
'stateCode'
,
'startTime'
,
'startCapacity'
]);
}
else
{
}
else
{
$orderSaveRedis
->
save
([
'stateCode'
,
'startTime'
]);
$orderSaveRedis
->
save
([
'stateCode'
,
'startTime'
]);
...
@@ -132,18 +133,29 @@ class WaitingState extends State
...
@@ -132,18 +133,29 @@ class WaitingState extends State
$startMessage
->
setOrderId
(
$this
->
order
->
getOutTradeNo
());
$startMessage
->
setOrderId
(
$this
->
order
->
getOutTradeNo
());
$sendMessage
=
new
SendMessage
();
$sendMessage
=
new
SendMessage
();
if
(
$sendMessage
->
request
(
$startMessage
)
===
false
)
{
if
(
$sendMessage
->
request
(
$startMessage
)
===
false
)
{
Log
::
error
(
'推送开始充电失败'
);
Log
::
error
(
'推送开始充电失败'
);
}
}
if
(
$this
->
order
->
getCardId
()
!=
''
)
{
$userId
=
$this
->
order
->
getUserId
();
$price
=
$this
->
order
->
getPayAmount
();
$db
=
\Events
::
getDb
();
$db
->
query
(
"UPDATE `wx_users` SET `wallet_balance` = `wallet_balance` -
$price
WHERE id =
$userId
"
);
}
$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
()),
];
];
//更新订单状态
//更新订单状态
$startCapacity
=
$this
->
order
->
getStartCapacity
();
$startCapacity
=
$this
->
order
->
getStartCapacity
();
if
(
$startCapacity
!==
-
2
&&
$startCapacity
>=
0
)
{
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
();
...
@@ -196,7 +208,7 @@ class WaitingState extends State
...
@@ -196,7 +208,7 @@ class WaitingState extends State
$failMessage
->
setOrderId
(
$this
->
order
->
getOutTradeNo
());
$failMessage
->
setOrderId
(
$this
->
order
->
getOutTradeNo
());
$failMessage
->
setUserId
(
$this
->
order
->
getUserId
());
$failMessage
->
setUserId
(
$this
->
order
->
getUserId
());
$sendMessage
=
new
SendMessage
();
$sendMessage
=
new
SendMessage
();
if
(
$sendMessage
->
request
(
$failMessage
)
===
false
)
{
if
(
$sendMessage
->
request
(
$failMessage
)
===
false
)
{
Log
::
error
(
'充电失败,推送消息失败'
,
$this
->
order
->
getOrderCache
(
\Events
::
getRedis
()));
Log
::
error
(
'充电失败,推送消息失败'
,
$this
->
order
->
getOrderCache
(
\Events
::
getRedis
()));
}
}
...
@@ -236,7 +248,7 @@ class WaitingState extends State
...
@@ -236,7 +248,7 @@ class WaitingState extends State
Log
::
debug
(
'waiting to shed ->start_capacity'
.
$this
->
order
->
getStartCapacity
());
Log
::
debug
(
'waiting to shed ->start_capacity'
.
$this
->
order
->
getStartCapacity
());
if
(
$this
->
order
->
getStartCapacity
()
>=
0
)
{
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
());
...
...
lib/order_check/DelayOrder.php
0 → 100644
View file @
29296654
<?php
/**
* Created by PhpStorm.
* User: banice
* Date: 2019/1/26
* Time: 下午4:13
*/
namespace
Lib\order_check
;
use
Lib\cdz\order\Order
;
class
DelayOrder
{
const
DELAY_KEY
=
'cdz:delay:check_charger_start:zset'
;
/**
* @var Order
*/
private
$order
;
private
$redis
;
public
function
__construct
()
{
$this
->
redis
=
\Events
::
getRedis
();
}
public
function
deleteDelayOrder
(
int
$orderId
)
{
$this
->
redis
->
zDelete
(
self
::
DELAY_KEY
,
$orderId
);
}
public
function
getDelayOrder
()
{
return
$this
->
redis
->
zRangeByScore
(
self
::
DELAY_KEY
,
0
,
time
());
}
public
function
setDelay
()
{
$this
->
redis
->
zAdd
(
self
::
DELAY_KEY
,
time
()
+
3
*
60
,
$this
->
order
->
getId
());
}
/**
* @return Order
*/
public
function
getOrder
()
:
Order
{
return
$this
->
order
;
}
/**
* @param Order $order
*/
public
function
setOrder
(
Order
$order
)
:
void
{
$this
->
order
=
$order
;
}
}
\ No newline at end of file
lib/remote/api/message/ChargerFullMessage.php
View file @
29296654
...
@@ -21,6 +21,12 @@ class ChargerFullMessage extends Message
...
@@ -21,6 +21,12 @@ class ChargerFullMessage extends Message
private
$purchaseTime
;
private
$purchaseTime
;
private
$address
=
''
;
private
$amount
=
0
;
private
$chargerTime
=
0
;
private
$remark
=
'温馨提示:您的爱车已停止充电,如有疑问您可以在公众号后台留言或直接拨打客服热线进行咨询。
private
$remark
=
'温馨提示:您的爱车已停止充电,如有疑问您可以在公众号后台留言或直接拨打客服热线进行咨询。
感谢您的使用'
;
感谢您的使用'
;
...
@@ -41,19 +47,23 @@ class ChargerFullMessage extends Message
...
@@ -41,19 +47,23 @@ class ChargerFullMessage extends Message
],
],
'keyword1'
=>
[
'keyword1'
=>
[
'value'
=>
$this
->
start
Time
,
'value'
=>
$this
->
end
Time
,
'color'
=>
'#333'
,
'color'
=>
'#333'
,
],
],
'keyword2'
=>
[
'keyword2'
=>
[
'value'
=>
$this
->
purchaseTime
,
'value'
=>
$this
->
address
,
'color'
=>
'#333'
,
'color'
=>
'#333'
,
],
],
'keyword3'
=>
[
'keyword3'
=>
[
'value'
=>
$this
->
end
Time
,
'value'
=>
$this
->
charger
Time
,
'color'
=>
'#333'
,
'color'
=>
'#333'
,
],
],
'remark'
=>
[
'keyword4'
=>
[
'value'
=>
$this
->
amount
,
'color'
=>
'#333'
,
],
'remark'
=>
[
'value'
=>
$this
->
remark
,
'value'
=>
$this
->
remark
,
'color'
=>
'#333'
,
'color'
=>
'#333'
,
],
],
...
@@ -150,5 +160,53 @@ class ChargerFullMessage extends Message
...
@@ -150,5 +160,53 @@ class ChargerFullMessage extends Message
$this
->
remark
=
$remark
;
$this
->
remark
=
$remark
;
}
}
/**
* @return string
*/
public
function
getAddress
()
:
string
{
return
$this
->
address
;
}
/**
* @param string $address
*/
public
function
setAddress
(
string
$address
)
:
void
{
$this
->
address
=
$address
;
}
/**
* @return int
*/
public
function
getAmount
()
:
int
{
return
$this
->
amount
;
}
/**
* @param int $amount
*/
public
function
setAmount
(
int
$amount
)
:
void
{
$this
->
amount
=
$amount
;
}
/**
* @return int
*/
public
function
getChargerTime
()
:
int
{
return
$this
->
chargerTime
;
}
/**
* @param int $chargerTime
*/
public
function
setChargerTime
(
int
$chargerTime
)
:
void
{
$this
->
chargerTime
=
$chargerTime
;
}
}
}
\ No newline at end of file
lib/station/gateway/port/Port.php
View file @
29296654
...
@@ -75,11 +75,11 @@ class Port
...
@@ -75,11 +75,11 @@ class Port
public
function
isPortBan
()
public
function
isPortBan
()
{
{
if
(
isset
(
$_SESSION
[
'port_id_status'
])
)
{
if
(
isset
(
$_SESSION
[
'port_id_status'
])
)
{
$portIdStatus
=
$_SESSION
[
'port_id_status'
];
$portIdStatus
=
$_SESSION
[
'port_id_status'
];
if
(
isset
(
$portIdStatus
[
$this
->
portId
])
)
{
if
(
isset
(
$portIdStatus
[
$this
->
portId
])
)
{
if
(
$portIdStatus
[
$this
->
portId
]
===
8
)
{
if
(
$portIdStatus
[
$this
->
portId
]
===
8
)
{
return
true
;
return
true
;
}
}
}
}
...
@@ -99,8 +99,8 @@ class Port
...
@@ -99,8 +99,8 @@ class Port
$redis
->
zAdd
(
self
::
PORT_STATE
,
$this
->
state
,
$this
->
portId
);
$redis
->
zAdd
(
self
::
PORT_STATE
,
$this
->
state
,
$this
->
portId
);
if
(
$this
->
stationId
===
0
||
$this
->
gatewayId
===
0
)
{
if
(
$this
->
stationId
===
0
||
$this
->
gatewayId
===
0
)
{
if
(
isset
(
$_SESSION
[
'gateway_id'
])
&&
isset
(
$_SESSION
[
'station_id'
])
)
{
if
(
isset
(
$_SESSION
[
'gateway_id'
])
&&
isset
(
$_SESSION
[
'station_id'
])
)
{
$this
->
stationId
=
$_SESSION
[
'station_id'
];
$this
->
stationId
=
$_SESSION
[
'station_id'
];
$this
->
gatewayId
=
$_SESSION
[
'gateway_id'
];
$this
->
gatewayId
=
$_SESSION
[
'gateway_id'
];
}
else
{
}
else
{
...
@@ -118,12 +118,23 @@ class Port
...
@@ -118,12 +118,23 @@ class Port
'updated_at'
=>
date
(
'Y-m-d H:i:s'
)
'updated_at'
=>
date
(
'Y-m-d H:i:s'
)
],
'id = '
.
$this
->
portId
);
],
'id = '
.
$this
->
portId
);
if
(
$orderId
!==
0
)
{
if
(
$orderId
!==
0
)
{
$redis
->
zAdd
(
'cdz:order:state:zset'
,
$this
->
state
,
$orderId
);
$redis
->
zAdd
(
'cdz:order:state:zset'
,
$this
->
state
,
$orderId
);
}
}
}
}
public
function
setPortUsingOrderId
(
$userId
,
$orderId
)
{
$redis
=
\Events
::
getRedis
();
$redis
->
hSet
(
self
::
USING_ORDER_ID
,
$this
->
portId
,
$orderId
);
$redis
->
zAdd
(
self
::
USING_USER_ID
,
$userId
,
$this
->
portId
);
}
/**
/**
* @return string
* @return string
*/
*/
...
@@ -149,7 +160,7 @@ class Port
...
@@ -149,7 +160,7 @@ class Port
$this
->
updatePortState
(
$orderId
);
$this
->
updatePortState
(
$orderId
);
if
(
$orderId
!=
0
)
{
if
(
$orderId
!=
0
)
{
$redis
->
zRem
(
'cdz:order:state:zset'
,
$orderId
);
$redis
->
zRem
(
'cdz:order:state:zset'
,
$orderId
);
$redis
->
del
(
'cdz:order:state:'
.
$orderId
);
$redis
->
del
(
'cdz:order:state:'
.
$orderId
);
}
}
...
...
src/BroadcastToAgent.php
View file @
29296654
...
@@ -19,7 +19,7 @@ class BroadcastToAgent
...
@@ -19,7 +19,7 @@ class BroadcastToAgent
public
function
__construct
()
public
function
__construct
()
{
{
if
(
isset
(
$_SESSION
[
'agent_id'
])
)
{
if
(
isset
(
$_SESSION
[
'agent_id'
])
)
{
$this
->
agentId
=
$_SESSION
[
'agent_id'
];
$this
->
agentId
=
$_SESSION
[
'agent_id'
];
}
}
...
@@ -27,6 +27,7 @@ class BroadcastToAgent
...
@@ -27,6 +27,7 @@ class BroadcastToAgent
public
function
broadcast
(
array
$data
)
public
function
broadcast
(
array
$data
)
{
{
Log
::
debug
(
'agent_id'
.
$this
->
agentId
);
Log
::
debug
(
'agent_id'
.
$this
->
agentId
);
$redis
=
\Events
::
getRedis
();
$redis
=
\Events
::
getRedis
();
$superAgentIds
=
$redis
->
hGetAll
(
'cdz:super_agent_id:hash'
);
$superAgentIds
=
$redis
->
hGetAll
(
'cdz:super_agent_id:hash'
);
...
@@ -34,11 +35,12 @@ class BroadcastToAgent
...
@@ -34,11 +35,12 @@ class BroadcastToAgent
Gateway
::
sendToUid
(
$id
,
json_encode
(
$data
));
Gateway
::
sendToUid
(
$id
,
json_encode
(
$data
));
}
}
if
(
$this
->
agentId
!==
''
)
{
if
(
$this
->
agentId
!==
''
)
{
Gateway
::
sendToUid
(
$this
->
agentId
,
json_encode
(
$data
));
Gateway
::
sendToUid
(
$this
->
agentId
,
json_encode
(
$data
));
return
true
;
return
true
;
}
else
{
}
else
{
Log
::
error
(
'agent_id can not find'
);
Log
::
error
(
'agent_id can not find'
);
return
false
;
return
false
;
}
}
...
...
src/command/StopChargerCommand.php
View file @
29296654
...
@@ -22,12 +22,11 @@ class StopChargerCommand implements Command
...
@@ -22,12 +22,11 @@ class StopChargerCommand implements Command
public
function
getMessage
()
:
string
public
function
getMessage
()
:
string
{
{
$this
->
type
=
sprintf
(
'%02x'
,
$this
->
type
);
$this
->
portLogic
=
sprintf
(
'%02x'
,
$this
->
portLogic
);
$this
->
portLogic
=
sprintf
(
'%02x'
,
$this
->
portLogic
);
$this
->
outTradeNo
=
sprintf
(
'%12x'
,
$this
->
outTradeNo
);
$this
->
outTradeNo
=
sprintf
(
'%
0
12x'
,
$this
->
outTradeNo
);
$this
->
finishType
=
sprintf
(
'%02x'
,
$this
->
finishType
);
$this
->
finishType
=
sprintf
(
'%02x'
,
$this
->
finishType
);
return
$this
->
type
.
$this
->
portLogic
.
$this
->
outTradeNo
.
$this
->
finishType
;
return
$this
->
portLogic
.
$this
->
outTradeNo
.
$this
->
finishType
;
}
}
...
@@ -96,5 +95,4 @@ class StopChargerCommand implements Command
...
@@ -96,5 +95,4 @@ class StopChargerCommand implements Command
}
}
}
}
\ No newline at end of file
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