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
0b69f017
Commit
0b69f017
authored
Jan 08, 2019
by
杨苏杭
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
card mac 修改为5字节
parent
00730ff9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
66 additions
and
53 deletions
+66
-53
.idea/workspace.xml
+0
-0
application/Events.php
+1
-0
application/controller/business/charger/OverController.php
+8
-6
application/controller/business/power/PowerController.php
+1
-1
application/controller/card/BalanceController.php
+9
-3
application/controller/card/charger/RequestController.php
+5
-3
lib/Gateway.php
+37
-37
lib/remote/api/message/StartMessage.php
+5
-3
No files found.
.idea/workspace.xml
View file @
0b69f017
This diff is collapsed.
Click to expand it.
application/Events.php
View file @
0b69f017
...
...
@@ -64,6 +64,7 @@ class Events
static
::
$redis
->
select
(
'4'
);
\Lib\log\Log
::
bootLog
();
...
...
application/controller/business/charger/OverController.php
View file @
0b69f017
...
...
@@ -108,27 +108,27 @@ class OverController extends Controller
break
;
case
StateCode
::
FINISH_USER
:
//用户主动结束
$this
->
logRecord
->
setDesc
(
'用户主动结束充电
'
);
$this
->
logRecord
->
setDesc
(
'用户主动结束充电
->'
.
$state
);
$orderState
->
toUserFinish
();
break
;
case
StateCode
::
FINISH_SHED_TIMEOUT
:
//端口脱落超时
$this
->
logRecord
->
setDesc
(
'端口脱落超时结束
'
);
$this
->
logRecord
->
setDesc
(
'端口脱落超时结束
->'
.
$state
);
$orderState
->
toShedTimeoutState
();
break
;
case
StateCode
::
FINISH_REFUND
:
//充电失败退款
$this
->
logRecord
->
setDesc
(
'充电失败退款结束
'
);
$this
->
logRecord
->
setDesc
(
'充电失败退款结束
->'
.
$state
);
$orderState
->
toRefundFinish
();
break
;
case
StateCode
::
FINISH_EXCEED
:
//功率超限
$this
->
logRecord
->
setDesc
(
'功率超限充电结束
'
);
$this
->
logRecord
->
setDesc
(
'功率超限充电结束
->'
.
$state
);
$orderState
->
toPowerExceedState
();
break
;
case
StateCode
::
FINISH_FULL
:
//充满自停
$this
->
logRecord
->
setDesc
(
'充满自停结束
'
);
$this
->
logRecord
->
setDesc
(
'充满自停结束
->'
.
$state
);
$orderState
->
toPowerFullState
();
break
;
case
StateCode
::
FINISH_TIME_END
:
//充电时间结束
$this
->
logRecord
->
setDesc
(
'充电时间完结束
'
);
$this
->
logRecord
->
setDesc
(
'充电时间完结束
->'
.
$state
);
$orderState
->
toTimeoutState
();
break
;
...
...
@@ -164,6 +164,8 @@ class OverController extends Controller
}
}
else
{
Log
::
error
(
'redis can not find'
);
$this
->
logRecord
->
setException
(
0
);
$this
->
logRecord
->
setDesc
(
'redis副本订单状态异常,非可结束订单状态'
);
...
...
application/controller/business/power/PowerController.php
View file @
0b69f017
...
...
@@ -176,7 +176,7 @@ class PowerController extends Controller
if
(
$i
===
(
$count
-
1
))
{
$orderModel
=
new
OrderModel
();
$capacity
=
hexdec
(
$capacitys
[
$i
]);
$orderModel
->
update
([
'start_capacity'
=>
hexdec
(
$capacitys
[
0
])],
'id ='
.
$orderId
.
'and start_capacity = -1'
);
$orderModel
->
update
([
'start_capacity'
=>
hexdec
(
$capacitys
[
0
])],
'id ='
.
$orderId
.
'
and start_capacity = -1'
);
$orderModel
->
update
([
'end_capacity'
=>
$capacity
,
],
'id = '
.
$orderId
);
...
...
application/controller/card/BalanceController.php
View file @
0b69f017
...
...
@@ -12,6 +12,7 @@ namespace Application\controller\card;
use
Application\controller\Controller
;
use
Application\model\CardModel
;
use
Application\model\UserModel
;
use
Lib\log\Log
;
class
BalanceController
extends
Controller
{
...
...
@@ -19,7 +20,7 @@ class BalanceController extends Controller
'32'
=>
[
'card_id'
=>
4
'card_id'
=>
5
,
]
];
...
...
@@ -33,11 +34,16 @@ class BalanceController extends Controller
$cardModel
=
new
CardModel
();
$userId
=
$cardModel
->
getColumn
(
'user_id'
,
'card_number = '
.
$cardId
);
Log
::
debug
(
$cardId
);
$userId
=
$cardModel
->
getColumn
(
'user_id'
,
'mac = '
.
"'
$cardId
'"
);
Log
::
debug
(
$userId
);
if
(
isset
(
$userId
))
{
$userModel
=
new
UserModel
();
$balance
=
$userModel
->
getColumn
(
'balance'
,
'id = '
.
$userId
);
$balance
=
$userModel
->
getColumn
(
'
wallet_
balance'
,
'id = '
.
$userId
);
}
$balance
=
isset
(
$balance
)
?
$balance
:
0
;
...
...
application/controller/card/charger/RequestController.php
View file @
0b69f017
...
...
@@ -25,7 +25,7 @@ class RequestController extends Controller
'33'
=>
[
'type'
=>
1
,
'logic_id'
=>
1
,
'card_id'
=>
4
,
'card_id'
=>
5
,
'time'
=>
2
,
'price'
=>
2
,
],
...
...
@@ -62,11 +62,13 @@ class RequestController extends Controller
$cardModel
=
new
CardModel
();
$userId
=
$cardModel
->
getColumn
(
'user_id'
,
'card_number = '
.
$cardId
);
$userId
=
$cardModel
->
getColumn
(
'user_id'
,
'mac = '
.
"'
$cardId
'"
);
Log
::
debug
(
$userId
);
if
(
isset
(
$userId
))
{
$userModel
=
new
UserModel
();
$balance
=
$userModel
->
getColumn
(
'balance'
,
'id = '
.
$userId
);
$balance
=
$userModel
->
getColumn
(
'
wallet_
balance'
,
'id = '
.
$userId
);
}
$balance
=
isset
(
$balance
)
?
$balance
:
0
;
if
((
int
)
$balance
<
(
int
)
$price
)
{
...
...
lib/Gateway.php
View file @
0b69f017
...
...
@@ -11,10 +11,10 @@ use \Exception;
* For full copyright and license information, please see the MIT-LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @author walkor<walkor@workerman.net>
* @author
walkor<walkor@workerman.net>
* @copyright walkor<walkor@workerman.net>
* @link http://www.workerman.net/
* @license http://www.opensource.org/licenses/mit-license.php MIT License
* @link
http://www.workerman.net/
* @license
http://www.opensource.org/licenses/mit-license.php MIT License
*/
/**
...
...
@@ -35,7 +35,7 @@ class Gateway
*
* @var string
*/
public
static
$registerAddress
=
'
webapppush.default
:1239'
;
public
static
$registerAddress
=
'
100.124.0.5
:1239'
;
//public static $registerAddress = '127.0.0.1:1236';
...
...
@@ -60,10 +60,10 @@ class Gateway
/**
* 向所有客户端连接(或者 client_id_array 指定的客户端连接)广播消息
*
* @param string $message 向客户端发送的消息
* @param array
$client_id_array
客户端 id 数组
* @param array $exclude_client_id 不给这些client_id发
* @param bool
$raw
是否发送原始数据(即不调用gateway的协议的encode方法)
* @param string $message
向客户端发送的消息
* @param array
$client_id_array
客户端 id 数组
* @param array
$exclude_client_id 不给这些client_id发
* @param bool
$raw
是否发送原始数据(即不调用gateway的协议的encode方法)
* @return void
* @throws Exception
*/
...
...
@@ -144,7 +144,7 @@ class Gateway
/**
* 向某个client_id对应的连接发消息
*
* @param int $client_id
* @param int
$client_id
* @param string $message
* @return void
*/
...
...
@@ -796,7 +796,7 @@ class Gateway
/**
* 踢掉某个客户端,并以$message通知被踢掉客户端
*
* @param int $client_id
* @param int
$client_id
* @param string $message
* @return void
*/
...
...
@@ -870,7 +870,7 @@ class Gateway
/**
* 将 client_id 与 uid 绑定
*
* @param int $client_id
* @param int
$client_id
* @param int|string $uid
* @return void
*/
...
...
@@ -882,7 +882,7 @@ class Gateway
/**
* 将 client_id 与 uid 解除绑定
*
* @param int $client_id
* @param int
$client_id
* @param int|string $uid
* @return void
*/
...
...
@@ -894,7 +894,7 @@ class Gateway
/**
* 将 client_id 加入组
*
* @param int $client_id
* @param int
$client_id
* @param int|string $group
* @return void
*/
...
...
@@ -907,7 +907,7 @@ class Gateway
/**
* 将 client_id 离开组
*
* @param int $client_id
* @param int
$client_id
* @param int|string $group
*
* @return void
...
...
@@ -940,7 +940,7 @@ class Gateway
* 向所有 uid 发送
*
* @param int|string|array $uid
* @param string $message
* @param string
$message
*
* @return void
*/
...
...
@@ -962,10 +962,10 @@ class Gateway
/**
* 向 group 发送
*
* @param int|string|array $group 组(不允许是 0 '0' false null array()等为空的值)
* @param string
$message
消息
* @param array $exclude_client_id 不给这些client_id发
* @param bool
$raw
发送原始数据(即不调用gateway的协议的encode方法)
* @param int|string|array $group
组(不允许是 0 '0' false null array()等为空的值)
* @param string
$message
消息
* @param array
$exclude_client_id 不给这些client_id发
* @param bool
$raw
发送原始数据(即不调用gateway的协议的encode方法)
*
* @return void
*/
...
...
@@ -1026,7 +1026,7 @@ class Gateway
/**
* 更新 session,框架自动调用,开发者不要调用
*
* @param int $client_id
* @param int
$client_id
* @param string $session_str
* @return bool
*/
...
...
@@ -1038,7 +1038,7 @@ class Gateway
/**
* 设置 session,原session值会被覆盖
*
* @param int $client_id
* @param int
$client_id
* @param array $session
*
* @return void
...
...
@@ -1055,7 +1055,7 @@ class Gateway
/**
* 更新 session,实际上是与老的session合并
*
* @param int $client_id
* @param int
$client_id
* @param array $session
*
* @return void
...
...
@@ -1096,8 +1096,8 @@ class Gateway
/**
* 向某个用户网关发送命令和消息
*
* @param int $client_id
* @param int $cmd
* @param int
$client_id
* @param int
$cmd
* @param string $message
* @param string $ext_data
* @return boolean
...
...
@@ -1130,7 +1130,7 @@ class Gateway
/**
* 发送数据并返回
*
* @param int $address
* @param int
$address
* @param mixed $data
* @return bool
* @throws Exception
...
...
@@ -1184,7 +1184,7 @@ class Gateway
* 发送数据到网关
*
* @param string $address
* @param array $gateway_data
* @param array
$gateway_data
* @return bool
*/
protected
static
function
sendToGateway
(
$address
,
$gateway_data
)
...
...
@@ -1248,7 +1248,7 @@ class Gateway
* 踢掉某个网关的 socket
*
* @param string $address
* @param int $connection_id
* @param int
$connection_id
* @return bool
*/
protected
static
function
kickAddress
(
$address
,
$connection_id
,
$message
)
...
...
@@ -1264,7 +1264,7 @@ class Gateway
* 销毁某个网关的 socket
*
* @param string $address
* @param int $connection_id
* @param int
$connection_id
* @return bool
*/
protected
static
function
destroyAddress
(
$address
,
$connection_id
)
...
...
@@ -1543,16 +1543,16 @@ class GatewayProtocol
*/
const
HEAD_LEN
=
28
;
public
static
$empty
=
array
(
'cmd'
=>
0
,
'local_ip'
=>
0
,
'local_port'
=>
0
,
'client_ip'
=>
0
,
'client_port'
=>
0
,
'cmd'
=>
0
,
'local_ip'
=>
0
,
'local_port'
=>
0
,
'client_ip'
=>
0
,
'client_port'
=>
0
,
'connection_id'
=>
0
,
'flag'
=>
0
,
'gateway_port'
=>
0
,
'ext_data'
=>
''
,
'body'
=>
''
,
'flag'
=>
0
,
'gateway_port'
=>
0
,
'ext_data'
=>
''
,
'body'
=>
''
,
);
/**
...
...
lib/remote/api/message/StartMessage.php
View file @
0b69f017
...
...
@@ -16,7 +16,7 @@ class StartMessage extends Message
/**
* @var string
*/
private
$first
=
'
充电已经开始,请注意接收消息
'
;
private
$first
=
'
您的爱车已开始充电,预计在%s结束喔
'
;
/**
* @var string
...
...
@@ -38,6 +38,8 @@ class StartMessage extends Message
*/
private
$remark
=
'感谢您的使用'
;
private
$purchaseTime
=
0
;
/**
* StartMessage constructor.
*/
...
...
@@ -74,10 +76,10 @@ class StartMessage extends Message
'color'
=>
'#333'
,
],
'keyword3'
=>
[
'value'
=>
number_format
(
$this
->
amount
/
100
,
2
),
'value'
=>
'¥'
.
number_format
(
$this
->
amount
/
100
,
2
),
'color'
=>
'#333'
,
],
'remark'
=>
[
'remark'
=>
[
'value'
=>
$this
->
remark
.
"(
$this->orderId
)"
,
'color'
=>
'#333'
,
],
...
...
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