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
f893d5ba
authored
Nov 20, 2024
by
赵增煜
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://git.imohe.com/zhaozengyu/tzt-admin
parents
f3b1efdd
60315995
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
7 deletions
+71
-7
app/Admin/Controllers/PharmacyController.php
+1
-1
app/Api/Controllers/PrescriptionController.php
+5
-6
app/Models/DoctorModel.php
+47
-0
app/Models/PharmacistModel.php
+18
-0
No files found.
app/Admin/Controllers/PharmacyController.php
View file @
f893d5ba
...
...
@@ -125,7 +125,7 @@ protected function form()
$form
->
mobile
(
'mobile'
)
->
width
(
4
)
->
required
()
->
help
(
'药店登录账号'
);
$form
->
timeRange
(
'business_start'
,
'business_end'
,
'营业时间'
)
->
required
();
$form
->
map
(
'lat'
,
'lng'
,
'经纬度坐标'
);
$form
->
select
(
'user_id'
)
->
options
(
User
::
all
()
->
pluck
(
'openid'
,
'id'
))
->
width
(
4
)
->
help
(
'实际后台操作可以不用关联'
);
//
$form->select('user_id')->options(User::all()->pluck('openid', 'id'))->width(4)->help('实际后台操作可以不用关联');
$form
->
switch
(
'status'
)
->
width
(
4
);
$form
->
display
(
'created_at'
)
->
width
(
4
);
...
...
app/Api/Controllers/PrescriptionController.php
View file @
f893d5ba
...
...
@@ -175,9 +175,8 @@ public function create(Request $request)
if
(
intval
(
$prescription_limit
)
>
0
)
{
$startOfDay
=
Carbon
::
now
()
->
startOfDay
();
$endOfDay
=
Carbon
::
now
()
->
endOfDay
();
$doctorIds
=
DoctorModel
::
query
()
->
where
(
'status'
,
1
)
->
pluck
(
'id'
)
->
toArray
();
$prescriptionCounts
=
DB
::
table
(
'prescription'
)
->
select
(
'doctor_id'
,
DB
::
raw
(
'COUNT(*) as prescription_count'
))
$doctorIds
=
DoctorModel
::
query
()
->
where
(
'status'
,
DoctorModel
::
STATUS_TRUE
)
->
pluck
(
'id'
)
->
toArray
();
$prescriptionCounts
=
PrescriptionModel
::
select
(
'doctor_id'
,
DB
::
raw
(
'COUNT(*) as prescription_count'
))
->
whereIn
(
'doctor_id'
,
$doctorIds
)
->
whereBetween
(
'created_at'
,
[
$startOfDay
,
$endOfDay
])
->
groupBy
(
'doctor_id'
)
...
...
@@ -188,13 +187,13 @@ public function create(Request $request)
return
$prescriptionCounts
->
get
(
$doctorId
,
0
)
<
$prescription_limit
;
})
->
values
()
->
all
();
// 随机取一个随机医师
$randomDoctor
=
D
B
::
table
(
'doctor'
)
->
where
In
(
'id'
,
$availableDoctors
)
$randomDoctor
=
D
octorModel
::
whereIn
(
'id'
,
$availableDoctors
)
->
where
(
'status'
,
DoctorModel
::
STATUS_TRUE
)
->
inRandomOrder
()
->
first
();
}
else
{
$randomDoctor
=
DoctorModel
::
inRandomOrder
()
->
where
(
'status'
,
1
)
->
first
();
$randomDoctor
=
DoctorModel
::
inRandomOrder
()
->
where
(
'status'
,
DoctorModel
::
STATUS_TRUE
)
->
first
();
}
$prescription
->
doctor_id
=
$randomDoctor
->
id
;
...
...
app/Models/DoctorModel.php
View file @
f893d5ba
...
...
@@ -15,6 +15,17 @@ class DoctorModel extends Model
protected
$table
=
'doctor'
;
// 医师状态[0=启用,1=禁用]
const
STATUS_FALSE
=
0
;
const
STATUS_TRUE
=
1
;
// 医师状态-文字映射
const
STATUS_MAP
=
[
self
::
STATUS_FALSE
=>
'禁用'
,
self
::
STATUS_TRUE
=>
'启用'
,
];
// 医师所属于的用户,一对一
public
function
user
()
{
...
...
@@ -29,4 +40,40 @@ public function getSignedPicAttribute($value)
return
Storage
::
url
(
$value
);
}
public
function
getLicenseNoPicAttribute
(
$value
)
{
if
(
Str
::
contains
(
$value
,
'//'
)
||
!
$value
)
{
return
$value
;
}
return
Storage
::
url
(
$value
);
}
public
function
getPhysicianLicenseAttribute
(
$value
)
{
if
(
Str
::
contains
(
$value
,
'//'
)
||
!
$value
)
{
return
$value
;
}
return
Storage
::
url
(
$value
);
}
public
function
getIdCardFrontPicAttribute
(
$value
)
{
if
(
Str
::
contains
(
$value
,
'//'
)
||
!
$value
)
{
return
$value
;
}
return
Storage
::
url
(
$value
);
}
public
function
getIdCardBackPicAttribute
(
$value
)
{
if
(
Str
::
contains
(
$value
,
'//'
)
||
!
$value
)
{
return
$value
;
}
return
Storage
::
url
(
$value
);
}
}
app/Models/PharmacistModel.php
View file @
f893d5ba
...
...
@@ -21,6 +21,24 @@ public function pharmacy()
return
$this
->
belongsTo
(
PharmacyModel
::
class
,
'pharmacy_id'
,
'id'
);
}
public
function
getPracticingLicenseAttribute
(
$value
)
{
if
(
Str
::
contains
(
$value
,
'//'
)
||
!
$value
)
{
return
$value
;
}
return
Storage
::
url
(
$value
);
}
public
function
getPhysicianLicenseAttribute
(
$value
)
{
if
(
Str
::
contains
(
$value
,
'//'
)
||
!
$value
)
{
return
$value
;
}
return
Storage
::
url
(
$value
);
}
public
function
getSignedPicAttribute
(
$value
)
{
if
(
Str
::
contains
(
$value
,
'//'
)
||
!
$value
)
{
...
...
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