Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵增煜
/
tzt-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1dcd0214
authored
Nov 30, 2024
by
赵增煜
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of
http://git.imohe.com/zhaozengyu/tzt-admin
into develop
parents
5c577a59
a7704c1f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
5 deletions
+36
-5
app/Api/Controllers/PharmacyController.php
+12
-0
app/Api/Controllers/UserController.php
+23
-4
app/Http/Middleware/CheckRoleChangeMiddleware.php
+1
-1
No files found.
app/Api/Controllers/PharmacyController.php
View file @
1dcd0214
...
...
@@ -24,6 +24,9 @@ public function test()
public
function
PharmacyList
(
Request
$request
)
{
$search_input
=
$request
->
input
(
'search_input'
);
$lat
=
$request
->
input
(
'lat'
);
$lng
=
$request
->
input
(
'lng'
);
$distance
=
$request
->
input
(
'distance_sort'
,
0
);
// 经纬度排序规则[0=从近到远,1=从远到近]
$query
=
PharmacyModel
::
query
();
if
(
$search_input
)
{
$query
->
where
(
'name'
,
'like'
,
"%
{
$search_input
}
%"
);
...
...
@@ -35,6 +38,15 @@ public function PharmacyList(Request $request)
->
where
(
'business_start'
,
'<='
,
Carbon
::
now
()
->
format
(
'H:i'
))
->
where
(
'business_end'
,
'>='
,
Carbon
::
now
()
->
format
(
'H:i'
));
if
(
$lat
&&
$lng
&&
is_numeric
(
$lat
)
&&
is_numeric
(
$lng
))
{
$distancesql
=
" * , ACOS(SIN((
$lat
* 3.1415) / 180 ) *SIN((lat * 3.1415) / 180 ) +COS((
$lat
* 3.1415) / 180 ) * COS((lat * 3.1415) / 180 ) *COS((
$lng
* 3.1415) / 180 - (lng * 3.1415) / 180 ) ) * 6380"
;
if
(
$distance_sort
==
1
)
{
$query
=
$query
->
addSelect
(
DB
::
raw
(
$distancesql
.
' as distance'
))
->
orderBy
(
'distance'
,
'DESC'
);
}
else
{
$query
=
$query
->
addSelect
(
DB
::
raw
(
$distancesql
.
' as distance'
))
->
orderBy
(
'distance'
,
'ASC'
);
}
}
$data
=
$query
->
paginate
(
10
);
return
$this
->
success
(
$data
);
...
...
app/Api/Controllers/UserController.php
View file @
1dcd0214
...
...
@@ -3,6 +3,7 @@
namespace
App\Api\Controllers
;
use
App\Http\Controllers\BaseApiController
;
use
App\Models\AdminUsers
;
use
App\Models\DoctorModel
;
use
App\Models\PharmacyModel
;
use
App\Models\User
;
...
...
@@ -138,14 +139,23 @@ public function bindRole(Request $request)
$mobile
=
$request
->
input
(
'mobile'
);
$login_type
=
$request
->
input
(
'login_type'
);
$code
=
$request
->
input
(
'code'
);
if
(
!
$mobile
||
!
$login_type
||
!
$code
)
{
return
$this
->
failed
(
'参数错误'
);
$password
=
$request
->
input
(
'password'
);
// 只有药店登录会传passowrd
if
(
!
$mobile
)
{
return
$this
->
failed
(
'请填写手机号'
);
}
if
(
!
$login_type
)
{
return
$this
->
failed
(
'登录类型错误'
);
}
if
((
$login_type
!=
User
::
LOGIN_TYPE_PHARMACY
)
&&
!
$code
)
{
return
$this
->
failed
(
'请填写短信验证码'
);
}
$verificationCode
=
cache
()
->
get
(
"sms_verification_code_
{
$mobile
}
"
);
if
(
$verificationCode
!=
$code
)
{
return
$this
->
failed
(
'验证码错误,请重新获取!'
);
// 有密码说明是药店密码登录
if
(
!
$password
&&
(
$verificationCode
!=
$code
))
{
return
$this
->
failed
(
'验证码错误,请重新发送!'
);
}
// 验证通过清除验证码
cache
()
->
forget
(
"sms_verification_code_
{
$mobile
}
"
);
...
...
@@ -155,6 +165,15 @@ public function bindRole(Request $request)
if
(
!
$pharmacy
)
{
return
$this
->
failed
(
'手机号不存在'
);
}
// 密码验证
if
(
$password
)
{
$adminUserInfo
=
AdminUsers
::
where
(
'pharmacy_id'
,
$pharmacy
->
id
)
->
first
();
$databasePassword
=
$adminUserInfo
->
password
;
$flag
=
app
(
'hash'
)
->
driver
(
'bcrypt'
)
->
check
(
$password
,
$databasePassword
);
if
(
!
$flag
)
{
return
$this
->
failed
(
'手机号或者密码错误!'
);
}
}
// 先把普通用户状态清除
if
(
$pharmacy
->
user_id
>
0
)
{
$user
=
User
::
query
()
->
find
(
$pharmacy
->
user_id
);
...
...
app/Http/Middleware/CheckRoleChangeMiddleware.php
View file @
1dcd0214
...
...
@@ -15,7 +15,7 @@ class CheckRoleChangeMiddleware
public
function
handle
(
$request
,
Closure
$next
)
{
$lastLoginType
=
auth
(
'api'
)
->
user
()
->
last_login_type
;
$requestLastLoginType
=
$request
->
headers
->
get
(
'last
_login_
type'
)
?:
0
;
$requestLastLoginType
=
$request
->
headers
->
get
(
'last
-login-
type'
)
?:
0
;
if
(
$lastLoginType
!=
$requestLastLoginType
)
{
return
response
()
->
json
([
'status'
=>
false
,
'code'
=>
600
,
'message'
=>
'您的角色切换错误~'
,
'data'
=>
[]]);
}
...
...
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