Commit b1a69b5b by 杨树贤

品牌和分类数据修复

parent 3dedd5ff
......@@ -33,7 +33,7 @@ class BrandController extends Controller
public function info(Request $request)
{
$id = $request->route('id');
$brand = BrandService::getStandardBrandList()
return view('brand.list');
$brand = BrandService::getStandardBrandInfo($id);
return view('brand.list',compact('brand'));
}
}
......@@ -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 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
}
$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);
}
......
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