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
07a77554
authored
Dec 04, 2024
by
lujunyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
麻黄素药品判断
parent
dea52978
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
6 deletions
+24
-6
app/Api/Controllers/DrugController.php
+24
-6
No files found.
app/Api/Controllers/DrugController.php
View file @
07a77554
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Carbon
;
use
Illuminate\Support\Carbon
;
use
Illuminate\Support\Facades\Log
;
use
Illuminate\Support\Facades\Log
;
use
Illuminate\Support\Str
;
// 药品控制器
// 药品控制器
class
DrugController
extends
BaseApiController
class
DrugController
extends
BaseApiController
...
@@ -141,13 +142,22 @@ public function drugLimit(Request $request)
...
@@ -141,13 +142,22 @@ public function drugLimit(Request $request)
$drugInfos_7
=
$prescription_7
->
drug_info
??
[];
$drugInfos_7
=
$prescription_7
->
drug_info
??
[];
foreach
(
$drugInfos_7
as
$drugInfo_7
)
{
foreach
(
$drugInfos_7
as
$drugInfo_7
)
{
$drugName
=
$drugInfo_7
[
'drug_name'
]
??
''
;
$drugName
=
$drugInfo_7
[
'drug_name'
]
??
''
;
if
(
$drugInfo_7
&&
in_array
(
$drugName
,
$limit_keywords
))
{
$isBlack
=
false
;
foreach
(
$limit_keywords
as
$keyword
)
{
if
(
Str
::
contains
(
$drugName
,
$keyword
))
{
$isBlack
=
true
;
break
;
}
}
if
(
$isBlack
)
{
$buyed_mahuang_counts
+=
$drugInfo_7
[
'num'
];
$buyed_mahuang_counts
+=
$drugInfo_7
[
'num'
];
}
}
}
}
}
}
$canBuyMahuangCount
=
4
-
$buyed_mahuang_counts
;
// 麻黄素药品剩余可购买数量,最多可以购买4个
// 处理麻黄素药品数据
// 处理麻黄素药品数据
$mahuangsu_
num
=
0
;
//
麻黄素药品数量
$mahuangsu_
buy_num
=
0
;
// 本次购买
麻黄素药品数量
foreach
(
$drugs
as
&
$drug
)
{
foreach
(
$drugs
as
&
$drug
)
{
$drugModel
=
DrugModel
::
find
(
$drug
[
'drug_id'
]);
$drugModel
=
DrugModel
::
find
(
$drug
[
'drug_id'
]);
if
(
!
$drugModel
)
{
if
(
!
$drugModel
)
{
...
@@ -167,11 +177,19 @@ public function drugLimit(Request $request)
...
@@ -167,11 +177,19 @@ public function drugLimit(Request $request)
return
$this
->
failed
(
$errMsg
,
[
'add_status'
=>
false
]);
return
$this
->
failed
(
$errMsg
,
[
'add_status'
=>
false
]);
}
}
if
(
$drugModel
&&
in_array
(
$drugModel
->
name
,
$limit_keywords
))
{
$mahuangsu_num
+=
$drug
[
'num'
];
$isBlack
=
false
;
foreach
(
$limit_keywords
as
$keyword
)
{
if
(
Str
::
contains
(
$drugModel
->
name
,
$keyword
))
{
$isBlack
=
true
;
break
;
}
}
if
(
$isBlack
)
{
$mahuangsu_buy_num
+=
$drug
[
'num'
];
$drug
[
'mahuangsu_status'
]
=
1
;
// 1:是麻黄素药品
$drug
[
'mahuangsu_status'
]
=
1
;
// 1:是麻黄素药品
$canBuyMahuangCount
=
4
-
$buyed_mahuang_counts
-
$mahuangsu_num
;
// 麻黄素药品剩余可购买数量,最多可以购买4个
if
(
$
canBuyMahuangCount
<
0
)
{
if
(
$
mahuangsu_buy_num
>
$canBuyMahuangCount
)
{
$errMsg
=
'药品['
.
$drugModel
->
name
.
']剩余购买数量不足~'
;
$errMsg
=
'药品['
.
$drugModel
->
name
.
']剩余购买数量不足~'
;
return
$this
->
failed
(
$errMsg
,
[
'add_status'
=>
false
]);
return
$this
->
failed
(
$errMsg
,
[
'add_status'
=>
false
]);
...
...
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