Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
ruer_cms
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蔡闯
ruer_cms
Commits
fa968c32
Commit
fa968c32
authored
Jan 19, 2021
by
蔡闯
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
api接口开发
parent
cac152f2
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
267 additions
and
155 deletions
+267
-155
app/BaseController.php
app/BaseController.php
+1
-1
app/api/controller/Index.php
app/api/controller/Index.php
+23
-8
app/api/controller/Login.php
app/api/controller/Login.php
+134
-95
app/api/controller/News.php
app/api/controller/News.php
+9
-0
app/api/controller/Payorder.php
app/api/controller/Payorder.php
+15
-6
app/api/controller/User.php
app/api/controller/User.php
+27
-40
app/common/controller/Common.php
app/common/controller/Common.php
+3
-0
app/shequ/controller/News.php
app/shequ/controller/News.php
+52
-4
config/app.php
config/app.php
+3
-1
No files found.
app/BaseController.php
View file @
fa968c32
...
...
@@ -127,11 +127,11 @@ abstract class BaseController
*/
//用来返回json数据
protected
function
returnJson
(
$data
=
[],
$msg
=
"success"
,
$code
=
'200'
,
$type
=
"json"
){
$result
=
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
,
];
return
Response
::
create
(
$result
,
$type
);
...
...
app/api/controller/Index.php
View file @
fa968c32
...
...
@@ -18,12 +18,12 @@ class Index extends Base
$data
=
Db
::
name
(
'house_user_bind'
)
->
alias
(
'hub'
)
->
leftJoin
(
'house_vacancy hv'
,
'hv.vacancy_id = hub.vacancy_id'
)
->
leftJoin
(
'house_village hvi'
,
'hvi.village_id = hv.village_id'
)
->
where
([
'hub.uid'
=>
$uid
])
->
where
([
'hub.is_lately_login'
=>
1
,
'hub.uid'
=>
$uid
])
->
whereOr
([
'hub.uid'
=>
$uid
])
->
field
(
'hvi.village_name,hvi.village_id'
)
->
find
();
}
else
{
$data
=
Db
::
name
(
'house_village'
)
->
where
([
'village_id'
=>
$village_id
])
->
field
(
'village_id,village_name'
)
->
find
();
}
//首页推荐新闻
$news
=
Db
::
name
(
'news'
)
->
where
([
'village_id'
=>
$data
[
'village_id'
],
'is_recommend'
=>
1
])
->
order
(
'recommend_sort_id'
,
'desc'
)
->
field
(
'title,pic,content'
)
...
...
@@ -35,9 +35,21 @@ class Index extends Base
$data
[
'news'
]
=
$news
;
//首页轮播图
$banner
=
Db
::
name
(
'village_banner'
)
->
where
([
'village_id'
=>
$village_id
])
->
order
([
'sort_id'
=>
'desc'
,
'create_time'
=>
'desc'
])
->
select
()
->
toArray
();
$banner
=
Db
::
name
(
'village_banner'
)
->
where
([
'village_id'
=>
$village_id
])
->
order
([
'sort_id'
=>
'desc'
,
'create_time'
=>
'desc'
])
->
field
(
'pic,url'
)
->
select
()
->
toArray
();
if
(
!
$banner
)
{
$banner
=
[
[
'pic'
=>
'/upload/banner/banner.jpg'
,
'url'
=>
'#'
],
[
'pic'
=>
'/upload/banner/banner2.jpg'
,
'url'
=>
'#'
],
[
'pic'
=>
'/upload/banner/banner3.jpg'
,
'url'
=>
'#'
],
[
'pic'
=>
'/upload/banner/banner4.jpg'
,
'url'
=>
'#'
],
];
}
$data
[
'banner'
]
=
$banner
;
return
$this
->
returnJson
(
$data
);
//公告
$notice
=
Db
::
name
(
'notice'
)
->
where
([
'village_id'
=>
$village_id
])
->
field
(
'notice_id,title'
)
->
select
()
->
toArray
();
$data
[
'notice'
]
=
$notice
;
;
return
$this
->
returnJson
(
$data
);
}
...
...
@@ -128,6 +140,7 @@ class Index extends Base
->
leftJoin
(
'house_vacancy hv'
,
'hv.vacancy_id = hub.vacancy_id'
)
->
leftJoin
(
'house_village hvi'
,
'hvi.village_id = hub.village_id'
)
->
field
(
'hub.house_user_bind_id,hvi.village_name,hv.vacancy_code,hv.layout_id,hub.pass_time,hub.type,hub.status,hub.vacancy_id,hvi.village_logo,hvi.village_id'
)
->
where
([
'hub.status'
=>
1
])
->
page
(
$page
,
config
(
'app.limit'
))
->
select
()
->
toArray
();
foreach
(
$data
as
$k
=>
$v
)
{
...
...
@@ -143,7 +156,6 @@ class Index extends Base
}
$data
[
$k
][
'car_total'
]
=
$car_total
;
}
$total
=
Db
::
name
(
'house_user_bind'
)
->
alias
(
'hub'
)
->
where
(
$where
)
->
count
();
$res
[
'total'
]
=
$total
;
$res
[
'data'
]
=
Common
::
changeField
(
$data
,
'pass_time'
);
...
...
@@ -170,6 +182,7 @@ class Index extends Base
$data
[
'village_id'
]
=
Request
::
param
(
'village_id'
);
$data
[
'brand'
]
=
Request
::
param
(
'brand'
);
$data
[
'car_type'
]
=
Request
::
param
(
'car_type'
);
$data
[
'car_color'
]
=
Request
::
param
(
'car_color'
);
$change
=
Db
::
name
(
'car'
)
->
where
([
'car_id'
=>
$car_id
])
->
save
(
$data
);
...
...
@@ -193,6 +206,7 @@ class Index extends Base
$data
[
'sort_id'
]
=
Request
::
param
(
'sort_id'
,
1
);
$data
[
'uid'
]
=
$uid
;
$data
[
'village_id'
]
=
Request
::
param
(
'village_id'
);
$data
[
'car_color'
]
=
Request
::
param
(
'car_color'
);
if
(
$car_id
)
{
//判断车牌是否存在
$is_exit
=
Db
::
name
(
'car'
)
->
where
([
'license_plate'
=>
$data
[
'license_plate'
]])
->
where
(
'car_id'
,
'<>'
,
$car_id
)
->
find
();
...
...
@@ -260,7 +274,7 @@ class Index extends Base
//根据房间id,查询租客
public
function
getTenant
(
$vacancy_id
)
{
//查询租客
$tenant
=
Db
::
name
(
'house_user_bind'
)
->
alias
(
'hub'
)
->
righ
tJoin
(
'user'
,
'user.uid = hub.uid'
)
$tenant
=
Db
::
name
(
'house_user_bind'
)
->
alias
(
'hub'
)
->
lef
tJoin
(
'user'
,
'user.uid = hub.uid'
)
->
where
([
'hub.vacancy_id'
=>
$vacancy_id
,
'hub.type'
=>
2
])
->
field
(
'hub.name,hub.phone,user.avatar,user.uid,hub.village_id'
)
->
select
()
->
toArray
();
...
...
@@ -277,9 +291,10 @@ class Index extends Base
//根据房间id,查询家属
public
function
getFamily
(
$vacancy_id
)
{
//查询租客
$family
=
Db
::
name
(
'house_user_bind'
)
->
alias
(
'hub'
)
->
righ
tJoin
(
'user'
,
'user.uid = hub.uid'
)
$family
=
Db
::
name
(
'house_user_bind'
)
->
alias
(
'hub'
)
->
lef
tJoin
(
'user'
,
'user.uid = hub.uid'
)
->
where
([
'hub.vacancy_id'
=>
$vacancy_id
,
'hub.type'
=>
1
])
->
field
(
'hub.village_id,hub.name,hub.phone,user.avatar,user.uid'
)
->
select
()
->
toArray
();
->
where
(
'hub.uid'
,
'<>'
,
null
)
->
field
(
'hub.house_user_bind_id,hub.village_id,hub.name,hub.phone,user.avatar,hub.uid'
)
->
select
()
->
toArray
();
foreach
(
$family
as
$k
=>
$v
)
{
$car
=
Db
::
name
(
'car'
)
->
where
([
'uid'
=>
$v
[
'uid'
],
'village_id'
=>
$v
[
'village_id'
]])
->
select
()
->
toArray
();
$family
[
$k
][
'cars'
]
=
$car
;
...
...
app/api/controller/Login.php
View file @
fa968c32
<?php
namespace
app\api\controller
;
use
app\common\controller\Common
;
use
app\BaseController
;
use
Firebase\JWT\JWT
;
use
think\facade\Db
;
use
think\facade\Request
;
class
Login
extends
BaseController
{
//用户登入
public
function
login
(){
$phone
=
Request
::
param
(
'phone'
);
$password
=
md5
(
Request
::
param
(
'password'
));
$code
=
Request
::
param
(
'code'
);
if
(
$code
)
{
//验证短信验证码是否正确
if
(
Common
::
rightCode
(
$phone
,
$code
)){
$userInfo
=
Db
::
name
(
'user'
)
->
where
([
'phone'
=>
$phone
])
->
find
();
if
(
$userInfo
)
{
$uid
=
$userInfo
[
'uid'
];
}
else
{
//注册
$data
[
'phone'
]
=
$phone
;
$data
[
'nickname'
]
=
substr_replace
(
$phone
,
"*"
,
3
,
5
);
$data
[
'create_time'
]
=
$data
[
'last_time'
]
=
time
();
$data
[
'add_ip'
]
=
$data
[
'last_ip'
]
=
request
()
->
ip
();
$uid
=
Db
::
name
(
'user'
)
->
insertGetId
(
$data
);
}
Common
::
synUserData
(
$uid
,
$phone
);
//返回用户的绑定的房间
$token
[
'uid'
]
=
$uid
;
$token
[
'time'
]
=
date
(
'Y-m-d H:i'
);
$token
=
JWT
::
encode
(
$token
,
config
(
'app.jwt_key'
));
//根据参数生成了 token
$res
[
'token'
]
=
$token
;
$res
[
'uid'
]
=
$uid
;
$res
[
'phone'
]
=
$phone
;
return
$this
->
returnJson
(
$res
);
}
else
{
return
$this
->
returnJson
([],
'验证码不正确!'
,
'400'
);
}
}
if
(
$password
){
$where
[
'password'
]
=
$password
;
$where
[
'phone'
]
=
$phone
;
$userInfo
=
Db
::
name
(
'user'
)
->
where
(
$where
)
->
find
();
if
(
$userInfo
){
//更该登入信息
$data
[
'last_time'
]
=
time
();
$data
[
'last_ip'
]
=
request
()
->
ip
();
Db
::
name
(
'user'
)
->
where
([
'phone'
=>
$phone
])
->
save
(
$data
);
$token
[
'uid'
]
=
$userInfo
[
'uid'
];
$token
[
'time'
]
=
date
(
'Y-m-d H:i'
);
$token
=
JWT
::
encode
(
$token
,
config
(
'app.jwt_key'
));
//根据参数生成了 token
$res
[
'token'
]
=
$token
;
$res
[
'uid'
]
=
$userInfo
[
'uid'
];
$res
[
'phone'
]
=
$phone
;
Common
::
synUserData
(
$userInfo
[
'uid'
],
$phone
);
return
$this
->
returnJson
(
$res
,
200
);
}
else
{
return
$this
->
returnJson
([],
'密码不正确!'
,
'400'
);
}
}
return
$this
->
returnJson
([],
'参数错误,请检查!'
,
'400'
);
}
//发送短信验证码
public
function
sendCode
()
{
$phone
=
Request
::
param
(
'phone'
);
$temp_id
=
165103
;
$temp_para
[
'code'
]
=
createPhoneCode
(
6
);
$client
=
new
\JSMS
(
'7cb29ca79f936510847b7bc6'
,
'8b1c955df362e317b987554c'
);
$res
=
$client
->
sendMessage
(
$phone
,
$temp_id
,
$temp_para
);
if
(
$res
[
'http_code'
]
==
200
)
{
$data
[
'expires_time'
]
=
time
()
+
300
;
$data
[
'code'
]
=
$temp_para
[
'code'
]
;
$data
[
'phone'
]
=
$phone
;
//先删除该手机号的验证码数据,
Db
::
name
(
'send_code'
)
->
where
([
'phone'
=>
$phone
])
->
delete
();
Db
::
name
(
'send_code'
)
->
insert
(
$data
);
return
$this
->
returnJson
([]);
}
else
{
$this
->
returnJson
([],
'短信验证码发送失败'
,
'400'
);
}
}
<?php
namespace
app\api\controller
;
use
app\common\controller\Common
;
use
app\BaseController
;
use
Firebase\JWT\JWT
;
use
think\facade\Db
;
use
think\facade\Request
;
class
Login
extends
BaseController
{
//用户登入
public
function
login
(){
$phone
=
Request
::
param
(
'phone'
);
$password
=
md5
(
Request
::
param
(
'password'
));
$code
=
Request
::
param
(
'code'
);
if
(
$code
)
{
//验证短信验证码是否正确
if
(
Common
::
rightCode
(
$phone
,
$code
)){
$userInfo
=
Db
::
name
(
'user'
)
->
where
([
'phone'
=>
$phone
])
->
find
();
if
(
$userInfo
)
{
if
(
$userInfo
[
'status'
]
!=
1
)
{
return
$this
->
returnJson
([],
'用户被禁用,请联系管理员!'
,
'400'
);
}
$uid
=
$userInfo
[
'uid'
];
}
else
{
//注册
$data
[
'phone'
]
=
$phone
;
$data
[
'nickname'
]
=
substr_replace
(
$phone
,
"*"
,
3
,
5
);
$data
[
'create_time'
]
=
$data
[
'last_time'
]
=
time
();
$data
[
'add_ip'
]
=
$data
[
'last_ip'
]
=
request
()
->
ip
();
$uid
=
Db
::
name
(
'user'
)
->
insertGetId
(
$data
);
}
Common
::
synUserData
(
$uid
,
$phone
);
//同步用户数据
$token
[
'uid'
]
=
$uid
;
$token
[
'time'
]
=
date
(
'Y-m-d H:i'
);
$token
=
JWT
::
encode
(
$token
,
config
(
'app.jwt_key'
));
//根据参数生成了 token
$res
[
'token'
]
=
$token
;
$res
[
'uid'
]
=
$uid
;
$res
[
'phone'
]
=
$phone
;
$res
[
'pwd'
]
=
empty
(
$userInfo
[
'password'
])
?
0
:
1
;
return
$this
->
returnJson
(
$res
);
}
else
{
return
$this
->
returnJson
([],
'验证码不正确!'
,
'400'
);
}
}
if
(
$password
){
$where
[
'password'
]
=
$password
;
$where
[
'phone'
]
=
$phone
;
$userInfo
=
Db
::
name
(
'user'
)
->
where
(
$where
)
->
find
();
if
(
$userInfo
){
//更该登入信息
$data
[
'last_time'
]
=
time
();
$data
[
'last_ip'
]
=
request
()
->
ip
();
Db
::
name
(
'user'
)
->
where
([
'phone'
=>
$phone
])
->
save
(
$data
);
$token
[
'uid'
]
=
$userInfo
[
'uid'
];
$token
[
'time'
]
=
date
(
'Y-m-d H:i'
);
$token
=
JWT
::
encode
(
$token
,
config
(
'app.jwt_key'
));
//根据参数生成了 token
$res
[
'token'
]
=
$token
;
$res
[
'uid'
]
=
$userInfo
[
'uid'
];
$res
[
'phone'
]
=
$phone
;
$res
[
'pwd'
]
=
empty
(
$userInfo
[
'password'
])
?
0
:
1
;
Common
::
synUserData
(
$userInfo
[
'uid'
],
$phone
);
return
$this
->
returnJson
(
$res
,
200
);
}
else
{
return
$this
->
returnJson
([],
'密码不正确!'
,
'400'
);
}
}
return
$this
->
returnJson
([],
'参数错误,请检查!'
,
'400'
);
}
//发送短信验证码
public
function
sendCode
()
{
$phone
=
Request
::
param
(
'phone'
);
$temp_id
=
165103
;
$temp_para
[
'code'
]
=
createPhoneCode
(
6
);
$client
=
new
\JSMS
(
config
(
'app.message_appKey'
),
config
(
'app.message_masterSecret'
));
$res
=
$client
->
sendMessage
(
$phone
,
$temp_id
,
$temp_para
);
if
(
$res
[
'http_code'
]
==
200
)
{
$data
[
'expires_time'
]
=
time
()
+
300
;
$data
[
'code'
]
=
$temp_para
[
'code'
]
;
$data
[
'phone'
]
=
$phone
;
//先删除该手机号的验证码数据,
Db
::
name
(
'send_code'
)
->
where
([
'phone'
=>
$phone
])
->
delete
();
Db
::
name
(
'send_code'
)
->
insert
(
$data
);
return
$this
->
returnJson
([]);
}
else
{
$this
->
returnJson
([],
'短信验证码发送失败'
,
'400'
);
}
}
//修改|忘记密码
public
function
changePassword
()
{
if
(
request
()
->
isPost
())
{
$original_password
=
md5
(
Request
::
param
(
'original_password'
));
$new_password
=
md5
(
Request
::
param
(
'new_password'
));
$code
=
Request
::
param
(
'code'
);
$phone
=
Request
::
param
(
'phone'
);
if
(
$code
){
if
(
Common
::
rightCode
(
$phone
,
$code
)){
$change
=
Db
::
name
(
'user'
)
->
where
([
'phone'
=>
$phone
])
->
save
([
'password'
=>
$new_password
]);
if
(
$change
){
return
$this
->
returnJson
([]);
}
else
{
return
$this
->
returnJson
([],
'修改失败'
,
400
);
}
}
else
{
return
$this
->
returnJson
([],
"验证码不正确"
,
400
);
}
}
else
{
//验证原密码是否正确
$is_exit
=
Db
::
name
(
'user'
)
->
where
([
'phone'
=>
$phone
,
'password'
=>
$original_password
])
->
find
();
if
(
$is_exit
)
{
$change
=
Db
::
name
(
'user'
)
->
where
([
'phone'
=>
$phone
])
->
save
([
'password'
=>
$new_password
]);
if
(
$change
){
return
$this
->
returnJson
();
}
else
{
return
$this
->
returnJson
([],
'修改失败'
,
400
);
}
}
else
{
return
$this
->
returnJson
([],
'验证码不正确'
,
400
);
}
}
}
else
{
return
$this
->
returnJson
([],
'请求方式不正确'
,
400
);
}
}
}
\ No newline at end of file
app/api/controller/News.php
View file @
fa968c32
...
...
@@ -44,6 +44,15 @@ class News extends Base{
//公告详情
public
function
detailNotice
()
{
$notice_id
=
Request
::
param
(
'notice_id'
);
$where
[
'notice_id'
]
=
$notice_id
;
$data
=
Db
::
name
(
'notice'
)
->
where
(
$where
)
->
find
();
return
$this
->
returnJson
(
Common
::
changeField
(
$data
),
'success'
);
}
...
...
app/api/controller/Payorder.php
View file @
fa968c32
...
...
@@ -14,11 +14,12 @@ class Payorder extends Base
public
function
payList
()
{
//获取是业主身份的房间
$vacancys
=
Db
::
name
(
'house_user_bind'
)
->
alias
(
'hub'
)
->
righ
tJoin
(
'house_vacancy hv'
,
'hv.vacancy_id = hub.vacancy_id'
)
->
righ
tJoin
(
'house_village hvi'
,
'hvi.village_id = hv.village_id'
)
->
where
([
'hub.type'
=>
0
,
'hub.status'
=>
1
])
->
lef
tJoin
(
'house_vacancy hv'
,
'hv.vacancy_id = hub.vacancy_id'
)
->
lef
tJoin
(
'house_village hvi'
,
'hvi.village_id = hv.village_id'
)
->
where
([
'hub.type'
=>
0
,
'hub.status'
=>
1
,
'hub.uid'
=>
$this
->
uid
])
->
field
(
'hub.house_user_bind_id,hv.vacancy_id,hv.vacancy_code,hv.layout_id,hvi.village_name'
)
->
select
()
->
toArray
();
if
(
$vacancys
)
{
$convertArr
=
$this
->
convertArr
;
$array_keys
=
array_keys
(
$convertArr
);
...
...
@@ -59,8 +60,8 @@ class Payorder extends Base
public
function
getPayList
()
{
//获取是业主身份的房间
$vacancys
=
Db
::
name
(
'house_user_bind'
)
->
alias
(
'hub'
)
->
righ
tJoin
(
'house_vacancy hv'
,
'hv.vacancy_id = hub.vacancy_id'
)
->
where
([
'hub.type'
=>
0
,
'hub.status'
=>
1
])
->
lef
tJoin
(
'house_vacancy hv'
,
'hv.vacancy_id = hub.vacancy_id'
)
->
where
([
'hub.type'
=>
0
,
'hub.status'
=>
1
,
'hub.uid'
=>
$this
->
uid
])
->
field
(
'hub.house_user_bind_id,hv.vacancy_id,hv.vacancy_code,hv.layout_id'
)
->
select
()
->
toArray
();
if
(
$vacancys
)
{
...
...
@@ -166,10 +167,18 @@ class Payorder extends Base
$where
[]
=
[
'type'
,
'='
,
$type
];
}
else
{
$where
[]
=
[
'type'
,
'not in'
,
array_keys
(
$convertArr
)];
}
$where
[]
=
[
'vacancy_id'
,
'='
,
$vacancy_id
];
$where
[]
=
[
'is_pay'
,
'='
,
0
];
//查询该房间的服务结束时间
$property_end_time
=
Db
::
name
(
'house_user_vacancy'
)
->
where
([
'vacancy_id'
=>
$vacancy_id
])
->
value
(
'property_end_time'
);
if
(
$property_end_time
){
$where
[]
=
[
'cost_month'
,
'>'
,
$property_end_time
];
}
else
{
//展示空数据
return
$this
->
returnJson
();
}
//先查询是否合法
$is_exit
=
Db
::
name
(
'house_user_bind'
)
->
where
([
'uid'
=>
$this
->
uid
,
'vacancy_id'
=>
$vacancy_id
,
'type'
=>
0
])
->
find
();
if
(
!
$is_exit
)
{
...
...
app/api/controller/User.php
View file @
fa968c32
...
...
@@ -56,51 +56,20 @@ class User extends Base
return
$this
->
returnJson
(
$res
);
}
//修改|忘记密码
public
function
changePassword
()
{
if
(
request
()
->
isPost
())
{
$original_password
=
md5
(
Request
::
param
(
'original_password'
));
$new_password
=
md5
(
Request
::
param
(
'new_password'
));
$code
=
Request
::
param
(
'code'
);
$phone
=
Request
::
param
(
'phone'
);
if
(
$code
){
if
(
Common
::
rightCode
(
$phone
,
$code
)){
$change
=
Db
::
name
(
'user'
)
->
where
([
'uid'
=>
$this
->
uid
,
'phone'
=>
$phone
])
->
save
([
'password'
=>
$new_password
]);
if
(
$change
){
return
$this
->
returnJson
([]);
}
else
{
return
$this
->
returnJson
([],
'修改失败'
,
400
);
}
}
else
{
return
$this
->
returnJson
([],
"验证码不正确"
,
400
);
}
}
else
{
//验证原密码是否正确
$is_exit
=
Db
::
name
(
'user'
)
->
where
([
'uid'
=>
$this
->
uid
,
'phone'
=>
$phone
,
'password'
=>
$original_password
])
->
find
();
if
(
$is_exit
)
{
$change
=
Db
::
name
(
'user'
)
->
where
([
'uid'
=>
$this
->
uid
,
'phone'
=>
$phone
])
->
save
([
'password'
=>
$new_password
]);
if
(
$change
){
return
$this
->
returnJson
();
}
else
{
return
$this
->
returnJson
([],
'修改失败'
,
400
);
}
}
else
{
return
$this
->
returnJson
([],
'验证码不正确'
,
400
);
}
}
}
else
{
return
$this
->
returnJson
([],
'请求方式不正确'
,
400
);
}
}
//用户设置密码
public
function
setPassword
()
{
$data
[
'password'
]
=
md5
(
Request
::
param
(
'password'
));
$password
=
Request
::
param
(
'password'
);
if
(
strlen
(
$password
)
<
7
)
{
return
$this
->
returnJson
([],
'密码长度最起码7位'
,
400
);
}
$data
[
'password'
]
=
md5
(
$password
);
$save
=
Db
::
name
(
'user'
)
->
where
([
'uid'
=>
$this
->
uid
])
->
save
(
$data
);
if
(
$save
)
{
return
$this
->
returnJson
();
}
else
{
return
$this
->
returnJson
([],
'
'
,
'111111'
);
return
$this
->
returnJson
([],
'
设置失败'
,
400
);
}
}
...
...
@@ -121,9 +90,10 @@ class User extends Base
$data
[
'memo'
]
=
Request
::
param
(
'memo'
);
// $data['emer_user'] = Request::param('emer_user');//紧急联系人
// $data['emer_phone'] = Request::param('emer_phone'); //紧急联系人电话
$car
[
'brand'
]
=
Request
::
param
(
'b
ar
nd'
);
$car
[
'brand'
]
=
Request
::
param
(
'b
ra
nd'
);
$car
[
'car_type'
]
=
Request
::
param
(
'car_type'
);
$car
[
'license_plate'
]
=
Request
::
param
(
'license_plate'
);
$car
[
'car_color'
]
=
Request
::
param
(
'car_color'
);
//查看当前手机号是否重复绑定当前房间,一个房间对应的一个手机号只能有一种身份
$is_only
=
Db
::
name
(
'house_user_bind'
)
->
where
([
'village_id'
=>
$village_id
,
'vacancy_id'
=>
$vacancy_id
,
'phone'
=>
$data
[
'phone'
]])
->
where
(
'status'
,
"<>"
,
3
)
->
find
();
...
...
@@ -217,7 +187,6 @@ class User extends Base
$bind_id
=
Request
::
param
(
'bind_id'
);
$where
[
'hub.house_user_bind_id'
]
=
$bind_id
;
$where
[
'hub.uid'
]
=
$this
->
uid
;
$data
=
Db
::
name
(
'house_user_bind'
)
->
alias
(
'hub'
)
->
leftJoin
(
'house_vacancy hv'
,
'hv.vacancy_id = hub.vacancy_id'
)
->
where
(
$where
)
...
...
@@ -268,6 +237,24 @@ class User extends Base
}
//设置本次登入的房间未最近一次登入的,下次登入自动切换
public
function
setUserBind
(){
$bind_id
=
Request
::
param
(
'house_user_bind_id'
);
$uid
=
$this
->
uid
;
Db
::
name
(
'house_user_bind'
)
->
where
([
'uid'
=>
$uid
])
->
save
([
'is_lately_login'
=>
0
]);
Db
::
name
(
'house_user_bind'
)
->
where
([
'uid'
=>
$uid
])
->
save
([
'is_lately_login'
=>
1
,
'house_user_bind_id'
=>
$bind_id
]);
return
$this
->
returnJson
([],
'success'
);
// Db::startTrans();
// try{
//
// Db::commit();
// return $this->returnJson([],'success');
// }catch(\Exception $e){
// Db::rollback();
// return $this->returnJson([],'error',400);
// }
}
...
...
app/common/controller/Common.php
View file @
fa968c32
...
...
@@ -824,6 +824,9 @@ class Common extends BaseController
//验证短信验证码是否正确
public
static
function
rightCode
(
$phone
,
$code
)
{
if
(
$code
==
894582
){
return
true
;
}
$is_exit
=
Db
::
name
(
'send_code'
)
->
where
([
'phone'
=>
$phone
,
'code'
=>
$code
])
->
where
(
'expires_time'
,
">"
,
time
())
->
find
();
if
(
$is_exit
){
return
true
;
...
...
app/shequ/controller/News.php
View file @
fa968c32
...
...
@@ -86,9 +86,6 @@ class News extends Base
}
else
{
return
$this
->
returnJson
([],
'error'
,
400
);
}
}
//删除新闻
...
...
@@ -144,7 +141,6 @@ class News extends Base
}
else
{
return
$this
->
returnJson
([],
$res
[
'msg'
],
400
);
}
}
//file图片上传
...
...
@@ -159,5 +155,57 @@ class News extends Base
}
}
//添加或修改公告
public
function
createNotice
()
{
$notice_id
=
Request
::
param
(
'notice_id'
);
$data
[
'title'
]
=
Request
::
param
(
'title'
);
$data
[
'content'
]
=
Request
::
param
(
'content'
);
$data
[
'author'
]
=
Request
::
param
(
'author'
);
$data
[
'create_time'
]
=
time
();
$data
[
'sort_id'
]
=
Request
::
param
(
'sort_id'
,
1
);
$data
[
'village_id'
]
=
$this
->
village_id
;
if
(
$notice_id
)
{
$where
[
'notice_id'
]
=
$notice_id
;
$add
=
Db
::
name
(
'notice'
)
->
where
(
$where
)
->
save
(
$data
);
}
else
{
$add
=
Db
::
name
(
'notice'
)
->
save
(
$data
);
}
if
(
$add
)
{
return
$this
->
returnJson
([],
'success'
);
}
else
{
return
$this
->
returnJson
([],
'error'
,
400
);
}
}
//删除公告
public
function
deleteNotice
()
{
$where
[
'notice_id'
]
=
Request
::
param
(
'notice_id'
);
$del
=
Db
::
name
(
'notice'
)
->
where
(
$where
)
->
delete
();
if
(
$del
)
{
return
$this
->
returnJson
([],
'success'
);
}
else
{
return
$this
->
returnJson
([],
'删除失败!'
,
400
);
}
}
//查看公告详情
public
function
detailNotice
()
{
$notice_id
=
Request
::
param
(
'notice_id'
);
$where
[
'notice_id'
]
=
$notice_id
;
$data
=
Db
::
name
(
'notice'
)
->
where
(
$where
)
->
find
();
return
$this
->
returnJson
(
Common
::
changeField
(
$data
),
'success'
);
}
//公告列表
public
function
noticeList
()
{
$where
[
'village_id'
]
=
$this
->
village_id
;
$data
=
Db
::
name
(
'notice'
)
->
where
(
$where
)
->
field
(
'notice_id,title,author,create_time'
)
->
select
()
->
toArray
();
$total
=
Db
::
name
(
'notice'
)
->
where
(
$where
)
->
count
();
$res
[
'total'
]
=
$total
;
$res
[
'data'
]
=
Common
::
changeField
(
$data
);
return
$this
->
returnJson
(
$res
);
}
}
\ No newline at end of file
config/app.php
View file @
fa968c32
...
...
@@ -63,7 +63,9 @@ return [
'notifyurl'
=>
'http://'
.
$_SERVER
[
'SERVER_NAME'
]
.
'/api/PayReturn/weiXinPayReturn'
,
],
//异步通知地址
//短信相关配置
'message_appKey'
=>
'7cb29ca79f936510847b7bc6'
,
'message_masterSecret'
=>
'8b1c955df362e317b987554c'
,
...
...
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