Commit e567922c by 杨树贤

标准品牌输出

parent 5ebfdcd9
...@@ -19,7 +19,7 @@ QUEUE_CONNECTION=sync ...@@ -19,7 +19,7 @@ QUEUE_CONNECTION=sync
SESSION_DRIVER=file SESSION_DRIVER=file
SESSION_LIFETIME=120 SESSION_LIFETIME=120
REDIS_HOST=192.168.1.235 REDIS_HOST=192.168.1.234
REDIS_PASSWORD=icDb29mLy2s REDIS_PASSWORD=icDb29mLy2s
REDIS_PORT=6379 REDIS_PORT=6379
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="fb90add0-1393-48c2-9f26-72365d42cd03" name="变更" comment=""> <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$/.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/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$/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/.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/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" /> <change beforePath="$PROJECT_DIR$/storage/framework/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/storage/framework/.gitignore" afterDir="false" />
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Http\Services\BrandService;
use Illuminate\Http\Request; use Illuminate\Http\Request;
class BrandController extends Controller class BrandController extends Controller
...@@ -23,7 +24,8 @@ class BrandController extends Controller ...@@ -23,7 +24,8 @@ class BrandController extends Controller
*/ */
public function map() public function map()
{ {
return view('brand.map'); $brandList = BrandService::getStandardBrandList();
return view('brand.map',compact('brandList'));
} }
public function list() public function list()
{ {
......
...@@ -2,20 +2,41 @@ ...@@ -2,20 +2,41 @@
namespace App\Http\Services; namespace App\Http\Services;
use Illuminate\Support\Facades\Redis;
class BrandService class BrandService
{ {
//获取首页需要的所有分类,没有英文名称的不要 //获取品牌页的数据(标准品牌)
public static function getClassificationForHome() public static function getStandardBrandList()
{ {
$classification = []; $redisKey = 'semour_standard_brand_map';
$standardBrandList = Redis::get($redisKey);
//先获取所有分类 if ($standardBrandList) {
return $standardBrandList;
$topClassMapping = config('field.top_class_mapping'); }
foreach ($topClassMapping as $key=>$mapping) { $standardBrandCache = Redis::hgetall('standard_brand');
$classification[$key] = []; $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;
} }
} }
<?php <?php
function test_helper() { function test_helper()
{
return 'OK'; 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;
}
}
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