Commit b1a69b5b by 杨树贤

品牌和分类数据修复

parent 3dedd5ff
...@@ -33,7 +33,7 @@ class BrandController extends Controller ...@@ -33,7 +33,7 @@ class BrandController extends Controller
public function info(Request $request) public function info(Request $request)
{ {
$id = $request->route('id'); $id = $request->route('id');
$brand = BrandService::getStandardBrandList() $brand = BrandService::getStandardBrandInfo($id);
return view('brand.list'); return view('brand.list',compact('brand'));
} }
} }
...@@ -13,7 +13,7 @@ class BrandService ...@@ -13,7 +13,7 @@ class BrandService
$redisKey = 'semour_standard_brand_map'; $redisKey = 'semour_standard_brand_map';
$standardBrandList = Redis::get($redisKey); $standardBrandList = Redis::get($redisKey);
if ($standardBrandList) { if ($standardBrandList) {
return json_decode($standardBrandList,true); return json_decode($standardBrandList, true);
} }
$standardBrandCache = Redis::hgetall('standard_brand'); $standardBrandCache = Redis::hgetall('standard_brand');
$standardBrandCache = array_map(function ($value) { $standardBrandCache = array_map(function ($value) {
...@@ -24,24 +24,29 @@ class BrandService ...@@ -24,24 +24,29 @@ class BrandService
foreach ($standardBrandCache as $standardBrand) { foreach ($standardBrandCache as $standardBrand) {
$matchLetter = false; $matchLetter = false;
foreach ($letters as $letter) { 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; $standardBrandList[$letter][] = $standardBrand;
$matchLetter = true; $matchLetter = true;
} }
} }
if (!$matchLetter) { if (!$matchLetter && !empty($standardBrand['brand_name_en'])) {
$standardBrandList['#'][] = $standardBrand; $standardBrandList['#'][] = $standardBrand;
} }
} }
$data = [];
ksort($standardBrandList); ksort($standardBrandList);
Redis::set($redisKey, json_encode($standardBrandList), 60); Redis::set($redisKey, json_encode($standardBrandList));
Redis::expire($redisKey, 60);
return $standardBrandList; return $standardBrandList;
} }
public static function getBrandInfo($) public static function getStandardBrandInfo($brandId)
{ {
$standardBrand = Redis::hget('standard_brand', $brandId);
$standardBrand = json_decode($standardBrand, true);
return $standardBrand;
} }
} }
...@@ -32,19 +32,22 @@ class ClassService ...@@ -32,19 +32,22 @@ class ClassService
} }
$topClassMapping = config('field.top_class_mapping'); $topClassMapping = config('field.top_class_mapping');
$topFields = array_map(function ($value){ $topFields = [];
return [ foreach ($topClassMapping as $key => $mapping) {
'class_name' => $value, $topFields[$key] = [
]; 'class_name' => $key,
},$topClassMapping); ];
}
foreach ($topClassMapping as $key => $mapping) { foreach ($topClassMapping as $key => $mapping) {
foreach ($topClassList as $topClass) { foreach ($topClassList as $topClass) {
if (in_array($topClass['class_id'], $topClassMapping[$key])) { if (in_array($topClass['class_id'], $topClassMapping[$key])) {
if (empty($topClass['class_name_en'])) {
continue;
}
$topFields[$key]['children'][] = $topClass; $topFields[$key]['children'][] = $topClass;
} }
} }
} }
return array_values($topFields); return array_values($topFields);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment