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
b1a69b5b
authored
Nov 14, 2022
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
品牌和分类数据修复
parent
3dedd5ff
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
15 deletions
app/Http/Controllers/BrandController.php
app/Http/Services/BrandService.php
app/Http/Services/ClassService.php
app/Http/Controllers/BrandController.php
View file @
b1a69b5b
...
...
@@ -33,7 +33,7 @@ class BrandController extends Controller
public
function
info
(
Request
$request
)
{
$id
=
$request
->
route
(
'id'
);
$brand
=
BrandService
::
getStandardBrand
List
()
return
view
(
'brand.list'
);
$brand
=
BrandService
::
getStandardBrand
Info
(
$id
);
return
view
(
'brand.list'
,
compact
(
'brand'
)
);
}
}
app/Http/Services/BrandService.php
View file @
b1a69b5b
...
...
@@ -13,7 +13,7 @@ class BrandService
$redisKey
=
'semour_standard_brand_map'
;
$standardBrandList
=
Redis
::
get
(
$redisKey
);
if
(
$standardBrandList
)
{
return
json_decode
(
$standardBrandList
,
true
);
return
json_decode
(
$standardBrandList
,
true
);
}
$standardBrandCache
=
Redis
::
hgetall
(
'standard_brand'
);
$standardBrandCache
=
array_map
(
function
(
$value
)
{
...
...
@@ -24,24 +24,29 @@ class BrandService
foreach
(
$standardBrandCache
as
$standardBrand
)
{
$matchLetter
=
false
;
foreach
(
$letters
as
$letter
)
{
if
(
start_with
(
strtoupper
(
$standardBrand
[
'brand_name'
]),
$letter
))
{
if
(
start_with
(
strtoupper
(
$standardBrand
[
'brand_name'
]),
$letter
))
{
if
(
empty
(
$standardBrand
[
'brand_name_en'
]))
{
continue
;
}
$standardBrandList
[
$letter
][]
=
$standardBrand
;
$matchLetter
=
true
;
}
}
if
(
!
$matchLetter
)
{
if
(
!
$matchLetter
&&
!
empty
(
$standardBrand
[
'brand_name_en'
])
)
{
$standardBrandList
[
'#'
][]
=
$standardBrand
;
}
}
$data
=
[];
ksort
(
$standardBrandList
);
Redis
::
set
(
$redisKey
,
json_encode
(
$standardBrandList
),
60
);
Redis
::
set
(
$redisKey
,
json_encode
(
$standardBrandList
));
Redis
::
expire
(
$redisKey
,
60
);
return
$standardBrandList
;
}
public
static
function
get
BrandInfo
(
$
)
public
static
function
get
StandardBrandInfo
(
$brandId
)
{
$standardBrand
=
Redis
::
hget
(
'standard_brand'
,
$brandId
);
$standardBrand
=
json_decode
(
$standardBrand
,
true
);
return
$standardBrand
;
}
}
app/Http/Services/ClassService.php
View file @
b1a69b5b
...
...
@@ -32,19 +32,22 @@ class ClassService
}
$topClassMapping
=
config
(
'field.top_class_mapping'
);
$topFields
=
array_map
(
function
(
$value
){
return
[
'class_name'
=>
$value
,
];
},
$topClassMapping
);
$topFields
=
[];
foreach
(
$topClassMapping
as
$key
=>
$mapping
)
{
$topFields
[
$key
]
=
[
'class_name'
=>
$key
,
];
}
foreach
(
$topClassMapping
as
$key
=>
$mapping
)
{
foreach
(
$topClassList
as
$topClass
)
{
if
(
in_array
(
$topClass
[
'class_id'
],
$topClassMapping
[
$key
]))
{
if
(
empty
(
$topClass
[
'class_name_en'
]))
{
continue
;
}
$topFields
[
$key
][
'children'
][]
=
$topClass
;
}
}
}
return
array_values
(
$topFields
);
}
...
...
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