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
263aea97
authored
Dec 01, 2024
by
赵增煜
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'bug-fix-1201' into develop
parents
73d49388
216d1b53
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
8 deletions
+31
-8
app/Api/Controllers/PharmacistController.php
+5
-0
app/Api/Controllers/PrescriptionController.php
+17
-8
app/Models/PharmacistModel.php
+9
-0
No files found.
app/Api/Controllers/PharmacistController.php
View file @
263aea97
...
...
@@ -205,6 +205,11 @@ public function delete(Request $request)
if
(
!
$pharmacy
)
{
return
$this
->
failed
(
'该药店不存在'
);
}
# 判断该药店下是否有几个开启的药师
$pharmacist
=
PharmacistModel
::
where
(
'pharmacy_id'
,
$pharmacy
->
id
)
->
where
(
'status'
,
1
)
->
count
();
if
(
$pharmacist
<=
1
){
return
$this
->
failed
(
'无法删除,至少需要一个开启的药师!'
);
}
$id
=
$request
->
input
(
'id'
);
$data
=
PharmacistModel
::
where
(
'id'
,
$id
)
->
where
(
'pharmacy_id'
,
$pharmacy
->
id
)
->
first
();
if
(
!
$data
)
{
...
...
app/Api/Controllers/PrescriptionController.php
View file @
263aea97
...
...
@@ -262,17 +262,26 @@ public function create(Request $request)
$prescription
->
pharmacy_id
=
$pharmacy
->
id
;
$prescription
->
pharmacy_name
=
$pharmacy
->
name
;
// 分派药师,先搜索是否存在默认药师,如果不存在则随机抽取一个
$pharmacist
=
PharmacistModel
::
where
(
'status'
,
1
)
->
where
(
'pharmacy_id'
,
$pharmacy_id
)
->
where
(
function
(
$query
)
{
$query
->
where
(
'is_default'
,
1
)
->
orWhere
(
'is_default'
,
0
);
})
->
inRandomOrder
()
$pharmacist
=
PharmacistModel
::
where
(
'status'
,
PharmacistModel
::
IS_STATUS_TRUE
)
->
where
(
'is_default'
,
PharmacistModel
::
IS_DEFAULT_TRUE
)
->
first
();
if
(
!
$pharmacist
)
{
$pharmacist
=
PharmacistModel
::
where
(
'status'
,
PharmacistModel
::
IS_STATUS_TRUE
)
->
inRandomOrder
()
->
first
();
}
// $pharmacist = PharmacistModel::where('status', 1)
// ->where('pharmacy_id', $pharmacy_id)
// ->where(function ($query) {
// $query->where('is_default', 1)
// ->orWhere('is_default', 0);
// })
// ->inRandomOrder()
// ->first();
if
(
!
$pharmacist
)
{
return
$this
->
failed
(
'
药师信息不存在
'
);
return
$this
->
failed
(
'
该药店暂无可审方药师,请联系管理员!
'
);
}
Log
::
info
(
'药师:'
.
json_encode
(
$pharmacist
));
$prescription
->
pharmacist_id
=
$pharmacist
->
id
;
...
...
app/Models/PharmacistModel.php
View file @
263aea97
...
...
@@ -32,6 +32,15 @@ class PharmacistModel extends Model
self
::
IS_DEFAULT_TRUE
=>
'success'
,
];
// 是否启用[0=否,1=是]
const
IS_STATUS_FALSE
=
0
;
const
IS_STATUS_TRUE
=
1
;
const
IS_STATUS_MAP
=
[
self
::
IS_STATUS_FALSE
=>
'否'
,
self
::
IS_STATUS_TRUE
=>
'是'
,
];
// 药师关联的药店,多对一
public
function
pharmacy
()
{
...
...
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