Commit 5b1b1964 by 杨树贤

返回红包活动列表带上已经添加的次数

parent 87b5ca90
......@@ -7,7 +7,6 @@ namespace App\Http\Controllers;
use App\Http\Filters\IntegralFilter;
use App\Models\Integral;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
/**
......@@ -41,9 +40,9 @@ class IntegralsController extends Controller
{
$page = $request->has('page') ? $request->page : self::DEFAULT_PAGE;
$pageSize = $request->has('page_size') ? $request->page_size : self::DEFAULT_PAGE_SIZE;
$userId = $request->get('user_id');
if ($request->has('is_api') && $request->is_api) {
$result = $integral->getIntegralListForApi();
$result = $integral->getIntegralListForApi($userId);
} else {
$result = $integral->getIntegralList($page, $pageSize, $filter);
}
......@@ -154,6 +153,7 @@ class IntegralsController extends Controller
$ids = $request->get('ids');
if (!is_array($ids)) {
Log::Info('批量修改参数不是数组');
return $this->Export(44, '批量修改参数不是数组');
}
$status = $request->status;
......
......@@ -53,7 +53,7 @@ class Integral extends Model
}
//获取红包活动列表,给API使用
public function getIntegralListForApi()
public function getIntegralListForApi($userId)
{
//先从redis里面查询是否有列表,没有的话从MySQL里面取出并且放入redis
$redis = new RedisModel();
......@@ -66,10 +66,17 @@ class Integral extends Model
$count = Integral::where('status', 1)->count();
$integrals = $this->addIntegralListToRedis();
}
} else {
$count = $redis->hlen('ic_welfare_integrals');
}
//处理列表,把不同红包活动今天已使用次数显示出来
foreach ($integrals as $key => $integral) {
$addCount = $redis->hget('ic_welfare_integral_limit_' . $integral['id'], $userId);
$integrals[$key]['add_count'] = empty($addCount) ? 0 : (int)$addCount;
}
if ($integrals) {
$integrals = arraySequence($integrals, 'id', 'SORT_ASC');
}
......
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