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
e567922c
authored
Nov 09, 2022
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
标准品牌输出
parent
5ebfdcd9
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
16 deletions
.env
.idea/workspace.xml
app/Http/Controllers/BrandController.php
app/Http/Services/BrandService.php
app/helpers.php
.env
View file @
e567922c
...
...
@@ -19,7 +19,7 @@ QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
REDIS_HOST=192.168.1.23
5
REDIS_HOST=192.168.1.23
4
REDIS_PASSWORD=icDb29mLy2s
REDIS_PORT=6379
...
...
.idea/workspace.xml
View file @
e567922c
...
...
@@ -2,13 +2,13 @@
<project
version=
"4"
>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"fb90add0-1393-48c2-9f26-72365d42cd03"
name=
"变更"
comment=
""
>
<change
beforePath=
"$PROJECT_DIR$/.env"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.env"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/app/Providers/ViewServiceProvider.php"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/app/Providers/ViewServiceProvider.php"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/app/Http/Controllers/BrandController.php"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/app/Http/Controllers/BrandController.php"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/app/Http/Services/BrandService.php"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/app/Http/Services/BrandService.php"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/app/helpers.php"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/app/helpers.php"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/bootstrap/app.php"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/bootstrap/app.php"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/bootstrap/cache/.gitignore"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/bootstrap/cache/.gitignore"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/resources/views/common/header.blade.php"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/resources/views/common/header.blade.php"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/resources/views/common/headerNav.php"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/resources/views/common/headerNav.php"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/resources/views/common/mallHeaderNav.blade.php"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/resources/views/common/mallHeaderNav.blade.php"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/storage/app/.gitignore"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/storage/app/.gitignore"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/storage/app/public/.gitignore"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/storage/app/public/.gitignore"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/storage/framework/.gitignore"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/storage/framework/.gitignore"
afterDir=
"false"
/>
...
...
app/Http/Controllers/BrandController.php
View file @
e567922c
...
...
@@ -2,6 +2,7 @@
namespace
App\Http\Controllers
;
use
App\Http\Services\BrandService
;
use
Illuminate\Http\Request
;
class
BrandController
extends
Controller
...
...
@@ -23,7 +24,8 @@ class BrandController extends Controller
*/
public
function
map
()
{
return
view
(
'brand.map'
);
$brandList
=
BrandService
::
getStandardBrandList
();
return
view
(
'brand.map'
,
compact
(
'brandList'
));
}
public
function
list
()
{
...
...
app/Http/Services/BrandService.php
View file @
e567922c
...
...
@@ -2,20 +2,41 @@
namespace
App\Http\Services
;
use
Illuminate\Support\Facades\Redis
;
class
BrandService
{
//获取
首页需要的所有分类,没有英文名称的不要
public
static
function
get
ClassificationForHome
()
//获取
品牌页的数据(标准品牌)
public
static
function
get
StandardBrandList
()
{
$classification
=
[];
//先获取所有分类
$topClassMapping
=
config
(
'field.top_class_mapping'
);
foreach
(
$topClassMapping
as
$key
=>
$mapping
)
{
$classification
[
$key
]
=
[];
$redisKey
=
'semour_standard_brand_map'
;
$standardBrandList
=
Redis
::
get
(
$redisKey
);
if
(
$standardBrandList
)
{
return
$standardBrandList
;
}
$standardBrandCache
=
Redis
::
hgetall
(
'standard_brand'
);
$standardBrandCache
=
array_map
(
function
(
$value
)
{
return
json_decode
(
$value
,
true
);
},
$standardBrandCache
);
$letters
=
generate_letters
();
$standardBrandList
=
[];
foreach
(
$standardBrandCache
as
$standardBrand
)
{
$matchLetter
=
false
;
foreach
(
$letters
as
$letter
)
{
if
(
start_with
(
strtoupper
(
$standardBrand
[
'brand_name'
]),
$letter
))
{
$standardBrandList
[
$letter
][]
=
$standardBrand
;
$matchLetter
=
true
;
}
}
if
(
!
$matchLetter
)
{
$standardBrandList
[
'#'
][]
=
$standardBrand
;
}
}
$data
=
[];
ksort
(
$standardBrandList
);
Redis
::
set
(
$redisKey
,
json_encode
(
$standardBrandList
),
60
);
return
$standardBrandList
;
}
}
app/helpers.php
View file @
e567922c
<?php
function
test_helper
()
{
function
test_helper
()
{
return
'OK'
;
}
if
(
!
function_exists
(
'start_with'
))
{
function
start_with
(
$str
,
$pattern
)
{
return
strpos
(
$str
,
$pattern
)
===
0
;
}
}
if
(
!
function_exists
(
'generate_letters'
))
{
function
generate_letters
(
$upper
=
true
)
{
$letters
=
[];
for
(
$i
=
65
;
$i
<
91
;
$i
++
)
{
$letters
[]
=
$upper
?
strtoupper
(
chr
(
$i
))
:
strtolower
(
chr
(
$i
));
}
return
$letters
;
}
}
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