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