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
8f850ad7
Commit
8f850ad7
authored
Feb 09, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增和编辑客户
parent
161e2500
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
94 additions
and
2 deletions
+94
-2
Client.php
application/api_broker/controller/Client.php
+36
-1
Users.php
application/model/Users.php
+55
-0
route.php
application/route.php
+3
-1
No files found.
application/api_broker/controller/Client.php
View file @
8f850ad7
...
...
@@ -3,7 +3,7 @@
namespace
app\api_broker\controller
;
use
app\api_broker\extend\Basic
;
use
think\Request
;
use
app\model\Users
;
/**
* Created by PhpStorm.
...
...
@@ -14,13 +14,48 @@ use think\Request;
*/
class
Client
extends
Basic
{
protected
$user
;
protected
$data
=
[];
protected
$code
=
200
;
protected
$msg
=
''
;
function
__construct
(
$request
=
null
)
{
parent
::
__construct
(
$request
);
$this
->
user
=
new
Users
();
}
public
function
selectUser
(){
}
/**
* 新增或编辑客户
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
editClient
()
{
if
(
$this
->
params
[
'user_nick'
]
||
$this
->
params
[
'user_nick'
]
||
$this
->
params
[
'id'
])
{
if
(
$this
->
request
->
isPost
())
{
if
(
$this
->
params
[
'id'
])
{
$this
->
data
=
$this
->
user
->
edit
(
$this
->
params
,
$this
->
params
[
'id'
]);
}
else
{
$this
->
data
=
$this
->
user
->
edit
(
$this
->
params
);
if
(
$this
->
data
==
-
1
)
{
$this
->
code
=
101
;
$this
->
msg
=
'该用户已存在'
;
}
}
}
else
{
$this
->
data
=
$this
->
user
->
getClient
(
$this
->
params
[
'id'
]);
}
}
else
{
$this
->
code
=
101
;
$this
->
msg
=
'user_nick or user_phone or id is null'
;
}
return
$this
->
response
(
$this
->
code
,
$this
->
msg
,
$this
->
data
);
}
}
application/model/Users.php
View file @
8f850ad7
...
...
@@ -91,4 +91,59 @@ class Users extends Model
return
[
"code"
=>
"101"
,
"msg"
=>
"没有该用户"
,
'data'
=>
''
];
}
}
/**
* 用户新增和编辑
*
* @param $data
* @param int $id
* @return false|int
*/
public
function
edit
(
$data
,
$id
=
0
)
{
$insert_data
[
'user_nick'
]
=
$data
[
'user_nick'
];
$insert_data
[
'user_phone'
]
=
$data
[
'user_phone'
];
$insert_data
[
'sex'
]
=
$data
[
'sex'
];
if
(
$id
)
{
$this
->
save
(
$insert_data
,[
'id'
=>
$id
]);
$return_id
=
$id
;
}
else
{
$is_exist
=
$this
->
where
(
'user_phone'
,
$data
[
'user_phone'
])
->
count
();
if
(
empty
(
$is_exist
))
{
$insert_data
[
'referrer_id'
]
=
$data
[
'agents_id'
];
$insert_data
[
'agent_id'
]
=
$data
[
'agents_id'
];
$insert_data
[
'referrer_source'
]
=
20
;
$insert_data
[
'status'
]
=
-
1
;
$insert_data
[
'create_time'
]
=
date
(
'Y-m-d H:i:s'
);
$return_id
=
$this
->
save
(
$insert_data
);
}
else
{
$return_id
=
-
1
;
}
}
return
$return_id
;
}
/**
* 跟进id获取客户和经纪人信息
*
* @param $id
* @return array|bool|false|\PDOStatement|string|Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
getClient
(
$id
)
{
if
(
$id
)
{
$data
=
$this
->
field
(
'a.user_nick,a.user_phone,a.sex,b.id as agents_id,b.name,b.phone'
)
->
alias
(
'a'
)
->
join
(
'a_agents b'
,
'a.agent_id=b.id'
,
'left'
)
->
where
(
'a.id'
,
$id
)
->
find
();
$data
[
'agents'
]
=
$data
[
'name'
]
.
'-'
.
$data
[
'phone'
];
unset
(
$data
[
'name'
]);
unset
(
$data
[
'phone'
]);
}
else
{
$data
=
false
;
}
return
$data
;
}
}
application/route.php
View file @
8f850ad7
...
...
@@ -213,7 +213,8 @@ Route::group('broker', [
'refund'
=>
[
'api_broker/OrderLog/refund'
,
[
'method'
=>
'get|post'
]
],
'bargain'
=>
[
'api_broker/OrderLog/bargain'
,
[
'method'
=>
'get|post'
]
],
'statusBargain'
=>
[
'api_broker/OrderLog/statusBargain'
,
[
'method'
=>
'get|post'
]
],
'login'
=>
[
'api_broker/Broker/login'
,
[
'method'
=>
'get'
]
],
'login'
=>
[
'api_broker/Broker/login'
,
[
'method'
=>
'get'
]
],
//经纪人登陆
'editClient'
=>
[
'api_broker/Client/editClient'
,
[
'method'
=>
'get|post'
]
],
//添加和编辑客户
]);
//Route::miss('api/index/miss');//处理错误的url
\ 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