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
d72da319
authored
Dec 04, 2024
by
赵增煜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
初始化指定药店中药数据
parent
9f39985f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
0 deletions
+50
-0
app/Console/Commands/InitPharmacyDrugTcm.php
+50
-0
No files found.
app/Console/Commands/InitPharmacyDrugTcm.php
0 → 100644
View file @
d72da319
<?php
namespace
App\Console\Commands
;
use
Illuminate\Console\Command
;
use
App\Models\DrugModel
;
use
App\Models\PharmacyDrugModel
;
class
InitPharmacyDrugTcm
extends
Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected
$signature
=
'mohe:init-pharmacy-drug-tcm {pharmacy_id}'
;
/**
* The console command description.
*
* @var string
*/
protected
$description
=
'同步中药到指定药店'
;
/**
* Execute the console command.
*/
public
function
handle
()
{
//
$pharmacy_id
=
$this
->
argument
(
'pharmacy_id'
)
??
0
;
if
(
intval
(
$pharmacy_id
)
<
1
)
{
$this
->
info
(
'请输入正确的药店id'
);
return
;
}
$this
->
info
(
'开始同步药库中药到指定药店...'
);
$drugs
=
DrugModel
::
query
()
->
where
(
'drug_type'
,
DrugModel
::
DRUG_TYPE_TCM
)
->
get
();
if
(
$drugs
->
count
()
>
0
){
foreach
(
$drugs
as
$drug
)
{
$pharmacyDrug
=
PharmacyDrugModel
::
where
(
'pharmacy_id'
,
$pharmacy_id
)
->
where
(
'drug_id'
,
$drug
->
id
)
->
first
();
if
(
empty
(
$pharmacyDrug
)
){
$pharmacyDrug
=
new
PharmacyDrugModel
();
$pharmacyDrug
->
drug_id
=
$drug
->
id
;
$pharmacyDrug
->
pharmacy_id
=
$pharmacy_id
;
$pharmacyDrug
->
unit
=
$drug
->
unit
;
$pharmacyDrug
->
save
();
}
}
}
}
}
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