Commit e2a313c2 by 杨树贤

添加对redis缓存里面的兑换配置type的过滤

parent c13fb89d
......@@ -42,7 +42,9 @@ class ExchangeSettingsController extends Controller
$page = $request->has('page') ? $request->page : self::DEFAULT_PAGE;
$pageSize = $request->has('page_size') ? $request->page_size : self::DEFAULT_PAGE_SIZE;
if ($request->has('is_api') && $request->is_api) {
$result = $exchangeSetting->getExchangeSettingListForApi();
//判断type
$type = $request->get('type');
$result = $exchangeSetting->getExchangeSettingListForApi(['type'=>$type]);
} else {
$result = $exchangeSetting->getExchangeSettingList($page, $pageSize, $filter);
}
......
......@@ -16,7 +16,7 @@ class ExchangeSettingFilter extends QueryFilter
return $this->builder->whereStatus($status);
}
public function type($type)
public function type($type = 0)
{
return $this->builder->whereType($type);
}
......
......@@ -8,6 +8,7 @@ use App\Http\Filters\QueryFilter;
use Common\Model\RedisModel;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class ExchangeSetting extends Model
{
......@@ -34,7 +35,7 @@ class ExchangeSetting extends Model
return ['data' => $settings, 'count' => $count];
}
public function getExchangeSettingListForApi()
public function getExchangeSettingListForApi($map = [])
{
//先从redis里面查询是否有列表,没有的话从MySQL里面取出并且放入redis
$redis = new RedisModel();
......@@ -50,7 +51,16 @@ class ExchangeSetting extends Model
} else {
$count = $redis->hlen('ic_welfare_integrals');
}
$settings = arraySequence($settings, 'id', 'SORT_ASC');
//如果需要过滤type
if ($map['type']) {
$settings = array_filter($settings, function ($value) use ($map) {
return $value['type'] == $map['type'] ? true : false;
});
}
if ($settings) {
$settings = arraySequence($settings, 'id', 'SORT_ASC');
}
return ['data' => array_values($settings), 'count' => $count];
}
......
3352
\ No newline at end of file
4820
\ No newline at end of file
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