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
e86e5a05
Commit
e86e5a05
authored
Oct 18, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增编辑经纪人
parent
af481456
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
76 additions
and
8 deletions
+76
-8
Broker.php
application/index/controller/Broker.php
+25
-0
BrokerService.php
application/index/service/BrokerService.php
+35
-5
AAgentValidate.php
application/index/validate/AAgentValidate.php
+6
-1
AAgents.php
application/model/AAgents.php
+9
-1
route.php
application/route.php
+1
-1
No files found.
application/index/controller/Broker.php
View file @
e86e5a05
...
...
@@ -9,6 +9,7 @@
namespace
app\index\controller
;
use
app\index\service\BrokerService
;
use
app\api_broker\service\CallPhoneService
;
use
app\api_broker\service\PushMessageService
;
use
app\extra\RedisExt
;
...
...
@@ -498,6 +499,30 @@ class Broker extends Basic
}
}
/**
* 新增or修改or查看
*
* @return \think\Response
*/
public
function
saveAgentV2
()
{
$result
[
'code'
]
=
200
;
$result
[
'msg'
]
=
""
;
$result
[
'data'
]
=
[];
if
(
$this
->
request
->
isPost
())
{
$broker_service
=
new
BrokerService
();
$data
=
$broker_service
->
saveAgentData
(
$this
->
params
,
$this
->
params
[
'site_id'
],
$this
->
userId
);
if
(
$result
[
'status'
]
==
'fail'
)
{
$result
[
'code'
]
=
101
;
$result
[
'msg'
]
=
$data
[
'msg'
];
}
}
else
{
//查看
$m_agent
=
new
AAgents
();
$result
[
'data'
]
=
$m_agent
->
verifyUser
(
'id,name,phone,password,district_id,store_id,sex,admin_off,remarks'
,
''
,
[
'id'
=>
$this
->
params
[
'id'
]]);
}
return
$this
->
response
(
$result
[
'code'
],
$result
[
'msg'
],
$result
[
'data'
]);
}
/**
* 删除(冻结)
*
...
...
application/index/service/BrokerService.php
View file @
e86e5a05
...
...
@@ -15,6 +15,7 @@ use app\model\AAgents;
class
BrokerService
{
public
$m_agent
;
public
function
__construct
()
{
$this
->
m_agent
=
new
AAgents
();
...
...
@@ -25,28 +26,58 @@ class BrokerService
*
* @param array $data
* @param int $operation_id
* @param int $site_id
* @return mixed
*/
public
function
saveAgentData
(
array
$data
,
int
$operation_id
)
{
public
function
saveAgentData
(
array
$data
,
int
$site_id
,
int
$operation_id
)
{
$result
[
'status'
]
=
'fail'
;
$validate
=
new
AAgentValidate
();
$check
=
$validate
->
scene
(
'add'
)
->
check
(
$data
);
if
(
empty
(
$data
[
'id'
]))
{
$check
=
$validate
->
scene
(
'add'
)
->
check
(
$data
);
}
else
{
$check
=
$validate
->
scene
(
'edit'
)
->
check
(
$data
);
}
if
(
!
$check
)
{
$result
[
'msg'
]
=
$validate
->
getError
();
return
$result
;
}
$where
[
'phone'
]
=
$data
[
'phone'
];
$where
[
'site_id'
]
=
$site_id
;
$agent_data
=
$this
->
m_agent
->
verifyUser
(
'id,phone,password,site_id'
,
''
,
$where
);
if
(
empty
(
$data
[
'id'
]))
{
$msg
=
'新增成功'
;
$data
[
'status'
]
=
0
;
}
else
{
if
(
empty
(
$agent_data
))
{
$result
[
'msg'
]
=
'没有该用户'
;
return
$result
;
}
$msg
=
'编辑成功'
;
if
(
!
empty
(
$data
[
'password'
]))
{
$md5_password
=
md5
(
$data
[
'password'
]);
if
((
$md5_password
==
$agent_data
[
'password'
])
||
(
$agent_data
[
'password'
]
==
$data
[
'password'
]))
{
unset
(
$data
[
'password'
]);
}
}
}
$id
=
$this
->
m_agent
->
saveAgent
(
$data
);
if
(
$id
>
0
)
{
$result
[
'status'
]
=
'successful'
;
$result
[
'data'
]
=
[
'id'
=>
$id
];
$result
[
'data'
]
=
[
'id'
=>
$id
];
$result
[
'msg'
]
=
$msg
;
}
else
{
$result
[
'msg'
]
=
'新增或编辑失败'
;
}
return
$result
;
}
}
\ No newline at end of file
application/index/validate/AAgentValidate.php
View file @
e86e5a05
...
...
@@ -15,6 +15,7 @@ class AAgentValidate extends Validate
{
protected
$rule
=
[
'id'
=>
'require|between:1,9999999999'
,
'site_id'
=>
'require|between:1,9999999999'
,
'device_id'
=>
'require|length:1,50'
,
'store_id'
=>
'require|between:1,9999999999'
,
'auth_group_id'
=>
'require|between:1,9999999999'
,
...
...
@@ -33,6 +34,8 @@ class AAgentValidate extends Validate
protected
$message
=
[
'id.require'
=>
'缺少id'
,
'id.between'
=>
'id参数错误'
,
'site_id.require'
=>
'所属区域必填'
,
'site_id.between'
=>
'区域参数错误'
,
'device_id.require'
=>
'缺少设备id'
,
'device_id.length'
=>
'设备id参数错误'
,
'store_id.require'
=>
'缺少门店id'
,
...
...
@@ -60,6 +63,7 @@ class AAgentValidate extends Validate
'remarks.length'
=>
'备注参数错误'
];
protected
$scene
=
[
'add'
=>
'name,phone,store_id,district_id,level,password,sex,status,admin_off'
'add'
=>
'name,phone,store_id,district_id,level,password,sex,status,admin_off,site_id'
,
'edit'
=>
'id,name,phone,store_id,district_id,level,password,sex,status,admin_off,site_id'
,
];
}
\ No newline at end of file
application/model/AAgents.php
View file @
e86e5a05
...
...
@@ -1305,7 +1305,7 @@ class AAgents extends BaseModel
//密码
if
(
!
empty
(
$params
[
'password'
]))
{
$save_data
[
'password'
]
=
md5
(
$params
[
'password'
]);
$save_data
[
'password'
]
=
md5
(
substr
(
$params
[
'phone'
],
-
6
));
//默认号码后6位
}
//性别 0保密 1男 2女
...
...
@@ -1353,9 +1353,17 @@ class AAgents extends BaseModel
$save_data
[
'quit_time'
]
=
$params
[
'quit_time'
];
}
//所属站点
if
(
!
empty
(
$params
[
'site_id'
]))
{
$save_data
[
'site_id'
]
=
$params
[
'site_id'
];
}
if
(
empty
(
$params
[
'id'
]))
{
$save_data
[
'create_time'
]
=
date
(
'Y-m-d H:i:s'
,
time
());
$save_data
[
'auth_group_id'
]
=
5
;
$id
=
$this
->
insertGetId
(
$save_data
);
}
else
{
$save_data
[
'update_time'
]
=
date
(
'Y-m-d H:i:s'
,
time
());
$num
=
$this
->
where
(
'id'
,
$params
[
'id'
])
->
update
(
$save_data
);
$id
=
$num
>
0
?
$params
[
'id'
]
:
0
;
}
...
...
application/route.php
View file @
e86e5a05
...
...
@@ -146,7 +146,7 @@ Route::group('index', [
'agent'
=>
[
'index/broker/agent'
,
[
'method'
=>
'get'
]
],
//首页列表界面
'saveAgentIndex'
=>
[
'index/broker/saveAgentIndex'
,
[
'method'
=>
'get'
]
],
//编辑列表列表界面
'AgentList'
=>
[
'index/broker/AgentList'
,
[
'method'
=>
'get'
]
],
//首页列表【接口】
'saveAgent'
=>
[
'index/broker/saveAgent'
,
[
'method'
=>
'get|post'
]
],
//修改经纪人【接口】
'saveAgent'
=>
[
'index/broker/saveAgent
V2
'
,
[
'method'
=>
'get|post'
]
],
//修改经纪人【接口】
'updateStatus'
=>
[
'index/broker/updateStatus'
,
[
'method'
=>
'post'
]
],
//状态修改【接口】
'updateRole'
=>
[
'index/broker/updateRole'
,
[
'method'
=>
'post'
]
],
//经纪人角色修改【接口】
'deviceList'
=>
[
'index/broker/deviceList'
,
[
'method'
=>
'post|get'
]
],
//经纪人设备id绑定列表
...
...
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