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
7edd98b5
authored
Dec 05, 2022
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
品牌和分类通过APi获取
parent
db68fc6b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
17 deletions
.env
app/Http/Services/BrandService.php
app/Http/Services/ClassService.php
config/website.php
.env
View file @
7edd98b5
...
...
@@ -59,3 +59,5 @@ PUBLIC_URL=
GOODS_INFO_URL=http://192.168.1.237:60014
#深茂搜索地址
SO_URL=http://so.semourdev.net
#基石地址
FOOTSTONE_URL=http://footstone.liexindev.net
app/Http/Services/BrandService.php
View file @
7edd98b5
...
...
@@ -10,10 +10,9 @@ class BrandService
public
static
function
getStandardBrandList
(
$map
)
{
$standardBrandCache
=
Redis
::
hgetall
(
'standard_brand'
);
$standardBrandCache
=
array_map
(
function
(
$value
)
{
return
json_decode
(
$value
,
true
);
},
$standardBrandCache
);
$standardBrandData
=
\Http
::
get
(
config
(
'website.footstone_url'
)
.
'/open/getStandardBrandList'
)
->
json
();
if
(
isset
(
$standardBrandData
[
'code'
])
&&
$standardBrandData
[
'code'
]
==
0
)
{
$standardBrandCache
=
$standardBrandData
[
'data'
];
ksort
(
$standardBrandCache
);
$standardBrandCache
=
array_values
(
$standardBrandCache
);
$standardBrandCache
=
array_map
(
function
(
$item
)
{
...
...
@@ -29,6 +28,8 @@ class BrandService
}
return
$standardBrandCache
;
}
return
[];
}
//获取品牌页的数据(标准品牌)
...
...
@@ -39,10 +40,9 @@ class BrandService
if
(
$standardBrandList
)
{
return
json_decode
(
$standardBrandList
,
true
);
}
$standardBrandCache
=
Redis
::
hgetall
(
'standard_brand'
);
$standardBrandCache
=
array_map
(
function
(
$value
)
{
return
json_decode
(
$value
,
true
);
},
$standardBrandCache
);
$standardBrandData
=
\Http
::
get
(
config
(
'website.footstone_url'
)
.
'/open/getStandardBrandList'
)
->
json
();
if
(
isset
(
$standardBrandData
[
'code'
])
&&
$standardBrandData
[
'code'
]
==
0
)
{
$standardBrandCache
=
$standardBrandData
[
'data'
];
$letters
=
generate_letters
();
$standardBrandList
=
[];
foreach
(
$standardBrandCache
as
$standardBrand
)
{
...
...
@@ -65,6 +65,8 @@ class BrandService
Redis
::
expire
(
$redisKey
,
60
);
return
$standardBrandList
;
}
return
[];
}
public
static
function
getStandardBrandInfo
(
$brandId
)
{
...
...
app/Http/Services/ClassService.php
View file @
7edd98b5
...
...
@@ -10,10 +10,11 @@ class ClassService
public
static
function
getClassificationForHome
()
{
//先获取所有分类
$class
Cache
=
Redis
::
hgetall
(
'pool_class_info'
);
$class
Data
=
\Http
::
get
(
config
(
'website.footstone_url'
)
.
'/open/getClassification'
)
->
json
(
);
$secondClassList
=
[];
if
(
isset
(
$classData
[
'code'
])
&&
$classData
[
'code'
]
==
0
)
{
$classCache
=
$classData
[
'data'
];
foreach
(
$classCache
as
$key
=>
&
$class
)
{
$class
=
json_decode
(
$class
,
true
);
if
(
!
$class
[
'parent_id'
])
{
if
(
empty
(
$class
[
'class_name_en'
]))
{
continue
;
...
...
@@ -31,7 +32,6 @@ class ClassService
if
(
empty
(
$class
[
'class_name_en'
]))
{
continue
;
}
$class
[
'sku_number'
]
=
Redis
::
hget
(
'pool_class_info_count'
,
$class
[
'class_id'
])
?:
0
;
$secondClass
[
'children'
][]
=
$class
;
}
}
...
...
@@ -58,24 +58,30 @@ class ClassService
}
return
array_values
(
$topFields
);
}
return
[];
}
public
static
function
getClassificationById
(
$classId
,
$includeChildren
=
false
)
public
static
function
getClassificationById
(
$classId
,
$includeChildren
=
false
)
{
$classification
=
Redis
::
hget
(
'pool_class_info'
,
$classId
);
$classification
=
json_decode
(
$classification
,
true
);
$classData
=
\Http
::
get
(
config
(
'website.footstone_url'
)
.
'/open/getClassification'
)
->
json
();
if
(
isset
(
$classData
[
'code'
])
&&
$classData
[
'code'
]
==
0
)
{
$classificationCache
=
$classData
[
'data'
];
$classification
=
[];
foreach
(
$classificationCache
as
$class
)
{
if
(
$class
[
'class_id'
]
==
$classId
)
{
$classification
=
$class
;
}
}
if
(
$classification
[
'parent_id'
])
{
return
$classification
;
}
//获取子分类
$classificationCache
=
Redis
::
hgetall
(
'pool_class_info'
);
$totalSkuNumber
=
0
;
foreach
(
$classificationCache
as
$classCache
)
{
$classCache
=
json_decode
(
$classCache
,
true
);
if
(
$classCache
[
'parent_id'
]
==
$classId
)
{
if
(
empty
(
$classCache
[
'class_name_en'
]))
{
continue
;
}
$classCache
[
'sku_number'
]
=
Redis
::
hget
(
'pool_class_info_count'
,
$classCache
[
'class_id'
])
?:
0
;
$totalSkuNumber
+=
$classCache
[
'sku_number'
];
$classification
[
'children'
][]
=
$classCache
;
}
...
...
@@ -83,5 +89,7 @@ class ClassService
$classification
[
'sku_number'
]
=
$totalSkuNumber
;
return
$classification
;
}
return
[];
}
}
config/website.php
0 → 100644
View file @
7edd98b5
<?php
return
[
'footstone_url'
=>
env
(
'FOOTSTONE_URL'
),
];
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