Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
tl_estate
Commits
2dd72272
Commit
2dd72272
authored
Jul 18, 2018
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
app绑定逻辑判断放到service
parent
2230b89b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
57 deletions
+88
-57
Broker.php
application/api_broker/controller/Broker.php
+8
-57
BrokerService.php
application/api_broker/service/BrokerService.php
+75
-0
Login.php
application/index/controller/Login.php
+5
-0
No files found.
application/api_broker/controller/Broker.php
View file @
2dd72272
...
@@ -13,6 +13,7 @@ use app\api\untils\GenerateCodeUntils;
...
@@ -13,6 +13,7 @@ use app\api\untils\GenerateCodeUntils;
use
app\api\untils\JwtUntils
;
use
app\api\untils\JwtUntils
;
use
app\api\untils\MessageUntils
;
use
app\api\untils\MessageUntils
;
use
app\api_broker\extend\Basic
;
use
app\api_broker\extend\Basic
;
use
app\api_broker\service\BrokerService
;
use
app\api_broker\service\OrderLogService
;
use
app\api_broker\service\OrderLogService
;
use
app\model\AAgents
;
use
app\model\AAgents
;
use
app\model\ABindingDevice
;
use
app\model\ABindingDevice
;
...
@@ -28,12 +29,14 @@ class Broker extends Basic
...
@@ -28,12 +29,14 @@ class Broker extends Basic
{
{
protected
$a_agents
;
protected
$a_agents
;
protected
$aBD
;
protected
$aBD
;
protected
$brokerService
;
public
function
__construct
(
Request
$request
=
null
)
public
function
__construct
(
Request
$request
=
null
)
{
{
parent
::
__construct
(
$request
);
parent
::
__construct
(
$request
);
$this
->
a_agents
=
new
AAgents
();
$this
->
a_agents
=
new
AAgents
();
$this
->
aBD
=
new
ABindingDevice
();
$this
->
aBD
=
new
ABindingDevice
();
$this
->
brokerService
=
new
BrokerService
();
}
}
/**
/**
...
@@ -138,7 +141,7 @@ class Broker extends Basic
...
@@ -138,7 +141,7 @@ class Broker extends Basic
return
$this
->
response
(
101
,
'密码错误'
);
return
$this
->
response
(
101
,
'密码错误'
);
}
}
//判断设备id是否存在
//判断设备id是否存在
$is_login
=
$this
->
judgeBand
(
$params
[
"device_id"
],
$agents_data
[
'id'
],
$params
[
"model"
],
0
,
$params
[
"push_id"
]);
$is_login
=
$this
->
brokerService
->
judgeBand
(
$params
[
"device_id"
],
$agents_data
[
'id'
],
$params
[
"model"
],
0
,
$params
[
"push_id"
]);
if
(
!
$is_login
)
{
if
(
!
$is_login
)
{
return
$this
->
response
(
"102"
,
"该账号没有绑定该手机,请致电人事进行绑定。"
);
return
$this
->
response
(
"102"
,
"该账号没有绑定该手机,请致电人事进行绑定。"
);
}
}
...
@@ -181,7 +184,7 @@ class Broker extends Basic
...
@@ -181,7 +184,7 @@ class Broker extends Basic
return
$this
->
response
(
"101"
,
$checkResult
);
return
$this
->
response
(
"101"
,
$checkResult
);
}
}
$is_visit
=
$this
->
judgeBand
(
$params
[
"device_id"
],
$params
[
"agent_id"
],
""
,
1
,
""
);
$is_visit
=
$this
->
brokerService
->
judgeBand
(
$params
[
"device_id"
],
$params
[
"agent_id"
],
""
,
1
,
""
);
if
(
$is_visit
)
{
if
(
$is_visit
)
{
return
$this
->
response
(
"200"
,
"success"
,
[]);
return
$this
->
response
(
"200"
,
"success"
,
[]);
}
else
{
}
else
{
...
@@ -189,57 +192,6 @@ class Broker extends Basic
...
@@ -189,57 +192,6 @@ class Broker extends Basic
}
}
}
}
/**
* 判断设备绑定关系
* @param string $device_id
* @param int $agent_id
* @param string $model
* @param int $type 0提交记录到后台, 1仅仅判断
* @param string $push_id
* @return bool
*/
private
function
judgeBand
(
string
$device_id
,
int
$agent_id
,
string
$model
,
int
$type
,
string
$push_id
)
:
bool
{
$params
[
"agent_id"
]
=
$agent_id
;
$result
=
$this
->
aBD
->
getDeviceByAgentId
(
$params
);
if
(
count
(
$result
)
<=
0
)
{
//新增设备绑定关系 默认直接登陆
if
(
$type
==
0
)
$this
->
aBD
->
addDevice
([
"device_id"
=>
$device_id
,
"agent_id"
=>
$agent_id
,
"model"
=>
$model
,
"push_id"
=>
$push_id
,
"is_forbidden"
=>
0
]);
return
true
;
}
$is_exits
=
false
;
foreach
(
$result
as
$item
)
{
if
(
$device_id
==
$item
[
"device_id"
])
{
//当个推返回的id改变时则更新记录
if
(
!
empty
(
$push_id
)
&&
$push_id
!=
$item
[
"push_id"
]){
$this
->
aBD
->
updateDevice
([
"id"
=>
$item
[
"id"
],
"push_id"
=>
$push_id
]);
}
if
(
$item
[
"is_forbidden"
]
==
0
)
{
return
true
;
}
elseif
(
$item
[
"is_forbidden"
]
==
1
)
{
//已存在申请关系
$is_exits
=
true
;
}
}
}
if
(
!
$is_exits
&&
$type
==
0
)
//新增申请绑定关系,需要后台同意登陆
$this
->
aBD
->
addDevice
([
"device_id"
=>
$device_id
,
"agent_id"
=>
$agent_id
,
"model"
=>
$model
,
"push_id"
=>
$push_id
,
"is_forbidden"
=>
1
]);
return
false
;
}
/**
/**
* 绑定或者解绑
* 绑定或者解绑
* @return \think\Response
* @return \think\Response
...
@@ -417,7 +369,6 @@ class Broker extends Basic
...
@@ -417,7 +369,6 @@ class Broker extends Basic
}
}
/**
/**
* 客户动态展示加搜索加客户详情
* 客户动态展示加搜索加客户详情
*
*
...
@@ -465,7 +416,7 @@ class Broker extends Basic
...
@@ -465,7 +416,7 @@ class Broker extends Basic
}*/
}*/
$user
=
new
Users
();
$user
=
new
Users
();
$user_res
=
$user
->
useraction_search_user_res
(
$user_id
,
1
);
$user_res
=
$user
->
useraction_search_user_res
(
$user_id
,
1
);
$user_res
[
'user_pic'
]
=
HEADERIMGURL
.
$user_res
[
'user_pic'
];
$user_res
[
'user_pic'
]
=
HEADERIMGURL
.
$user_res
[
'user_pic'
];
...
@@ -487,8 +438,8 @@ class Broker extends Basic
...
@@ -487,8 +438,8 @@ class Broker extends Basic
$get_params
[
'agents_id'
]
=
$params
[
"agent_id"
];
$get_params
[
'agents_id'
]
=
$params
[
"agent_id"
];
$get_params
[
'user_id'
]
=
$params
[
"user_id"
];
$get_params
[
'user_id'
]
=
$params
[
"user_id"
];
$collect_house
=
new
ACollectUser
();
$collect_house
=
new
ACollectUser
();
$res
=
$collect_house
->
getCollectUser
(
$field
,
$get_params
);
$res
=
$collect_house
->
getCollectUser
(
$field
,
$get_params
);
if
(
$res
&&
(
$res
[
0
][
'status'
]
==
1
))
{
//如果存在
if
(
$res
&&
(
$res
[
0
][
'status'
]
==
1
))
{
//如果存在
$data
[
"is_collect"
]
=
1
;
$data
[
"is_collect"
]
=
1
;
}
}
return
$this
->
response
(
"200"
,
"success!"
,
$data
);
return
$this
->
response
(
"200"
,
"success!"
,
$data
);
...
...
application/api_broker/service/BrokerService.php
0 → 100644
View file @
2dd72272
<?php
namespace
app\api_broker\service
;
use
app\model\ABindingDevice
;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/7/18
* Time : 18:37
* Intro:
*/
class
BrokerService
{
protected
$aBD
;
public
function
__construct
()
{
$this
->
aBD
=
new
ABindingDevice
();
}
/**
* 判断设备绑定关系
* @param string $device_id
* @param int $agent_id
* @param string $model
* @param int $type 0提交记录到后台, 1仅仅判断
* @param string $push_id
* @return bool
*/
public
function
judgeBand
(
string
$device_id
,
int
$agent_id
,
string
$model
,
int
$type
,
string
$push_id
)
:
bool
{
$params
[
"agent_id"
]
=
$agent_id
;
$result
=
$this
->
aBD
->
getDeviceByAgentId
(
$params
);
if
(
count
(
$result
)
<=
0
)
{
//新增设备绑定关系 默认直接登陆
if
(
$type
==
0
)
$this
->
aBD
->
addDevice
([
"device_id"
=>
$device_id
,
"agent_id"
=>
$agent_id
,
"model"
=>
$model
,
"push_id"
=>
$push_id
,
"is_forbidden"
=>
0
]);
return
true
;
}
$is_exits
=
false
;
foreach
(
$result
as
$item
)
{
if
(
$device_id
==
$item
[
"device_id"
])
{
//当个推返回的id改变时则更新记录
if
(
!
empty
(
$push_id
)
&&
$push_id
!=
$item
[
"push_id"
])
{
$this
->
aBD
->
updateDevice
([
"id"
=>
$item
[
"id"
],
"push_id"
=>
$push_id
]);
}
if
(
$item
[
"is_forbidden"
]
==
0
)
{
return
true
;
}
elseif
(
$item
[
"is_forbidden"
]
==
1
)
{
//已存在申请关系
$is_exits
=
true
;
}
}
}
if
(
!
$is_exits
&&
$type
==
0
)
//新增申请绑定关系,需要后台同意登陆
$this
->
aBD
->
addDevice
([
"device_id"
=>
$device_id
,
"agent_id"
=>
$agent_id
,
"model"
=>
$model
,
"push_id"
=>
$push_id
,
"is_forbidden"
=>
1
]);
return
false
;
}
}
\ No newline at end of file
application/index/controller/Login.php
View file @
2dd72272
...
@@ -127,6 +127,11 @@ class Login extends Basic
...
@@ -127,6 +127,11 @@ class Login extends Basic
return
;
return
;
}
}
public
function
userVerify
(){
//todo
}
/**
/**
* 退出
* 退出
*
*
...
...
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