Commit cce8796c by mushishixian

gix

parent 62ff3ad4
Showing with 8 additions and 10 deletions
...@@ -40,23 +40,21 @@ class BrandModel extends Model ...@@ -40,23 +40,21 @@ class BrandModel extends Model
$data = $redis->hgetall('Self_Brand'); $data = $redis->hgetall('Self_Brand');
foreach ($data as $key => $item) { foreach ($data as $key => $item) {
$item = json_decode($item, true); $item = json_decode($item, true);
if (!$item['brand_id'])continue; if (!$item['brand_id']) {
continue;
}
$brandList[] = [ $brandList[] = [
'brand_id' => $item['brand_id'], 'brand_id' => $item['brand_id'],
'brand_name' => $item['brand_name'], 'brand_name' => $item['brand_name'],
]; ];
} }
} else { } else {
$data = $redis->get('brand_select'); $data = DB::connection('spu')->table('brand')->where('status', 1)->orderBy('brand_id',
if (empty($data)) { 'asc')->pluck('brand_name', 'brand_id');
$data = DB::connection('spu')->table('brand')->where('status',1)->orderBy('brand_id','asc')->pluck('brand_name', 'brand_id');
$redis->set('brand_select', json_encode($data));
$redis->expire('brand_select', 3600);
}else{
$data = json_decode($data, true);
}
foreach ($data as $brandId => $brandName) { foreach ($data as $brandId => $brandName) {
if (!$brandId)continue; if (!$brandId) {
continue;
}
$brandList[] = [ $brandList[] = [
'brand_id' => $brandId, 'brand_id' => $brandId,
'brand_name' => trim($brandName), 'brand_name' => trim($brandName),
......
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