Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
semour
/
semour_web
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ba2c5366
authored
Nov 16, 2022
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
分类数量返回
parent
90af3681
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
app/Http/Services/ClassService.php
app/Http/Services/ClassService.php
View file @
ba2c5366
...
...
@@ -11,14 +11,14 @@ class ClassService
{
//先获取所有分类
$classCache
=
Redis
::
hgetall
(
'pool_class_info'
);
$
top
ClassList
=
[];
$
second
ClassList
=
[];
foreach
(
$classCache
as
$key
=>
&
$class
)
{
$class
=
json_decode
(
$class
,
true
);
if
(
!
$class
[
'parent_id'
])
{
if
(
empty
(
$class
[
'class_name_en'
]))
{
continue
;
}
$
top
ClassList
[]
=
$class
;
$
second
ClassList
[]
=
$class
;
}
}
unset
(
$class
);
...
...
@@ -26,15 +26,16 @@ class ClassService
if
(
!
$class
[
'parent_id'
])
{
continue
;
}
foreach
(
$
topClassList
as
&
$top
Class
)
{
if
(
$
top
Class
[
'class_id'
]
==
$class
[
'parent_id'
])
{
foreach
(
$
secondClassList
as
&
$second
Class
)
{
if
(
$
second
Class
[
'class_id'
]
==
$class
[
'parent_id'
])
{
if
(
empty
(
$class
[
'class_name_en'
]))
{
continue
;
}
$topClass
[
'children'
][]
=
$class
;
$class
[
'sku_number'
]
=
Redis
::
hget
(
'pool_class_info_count'
,
$class
[
'class_id'
])
?:
0
;
$secondClass
[
'children'
][]
=
$class
;
}
}
unset
(
$
top
Class
);
unset
(
$
second
Class
);
}
$topClassMapping
=
config
(
'field.top_class_mapping'
);
...
...
@@ -45,12 +46,12 @@ class ClassService
];
}
foreach
(
$topClassMapping
as
$key
=>
$mapping
)
{
foreach
(
$
topClassList
as
$top
Class
)
{
if
(
in_array
(
$
top
Class
[
'class_id'
],
$topClassMapping
[
$key
]))
{
if
(
empty
(
$
top
Class
[
'class_name_en'
]))
{
foreach
(
$
secondClassList
as
$second
Class
)
{
if
(
in_array
(
$
second
Class
[
'class_id'
],
$topClassMapping
[
$key
]))
{
if
(
empty
(
$
second
Class
[
'class_name_en'
]))
{
continue
;
}
$topFields
[
$key
][
'children'
][]
=
$
top
Class
;
$topFields
[
$key
][
'children'
][]
=
$
second
Class
;
}
}
}
...
...
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