|
@@ -155,16 +155,17 @@ class MotionService extends BaseService
|
|
|
->where(['mark'=> 1,'status'=> 1])
|
|
->where(['mark'=> 1,'status'=> 1])
|
|
|
->groupBy('user_id')
|
|
->groupBy('user_id')
|
|
|
->orderBy('create_time', 'asc')
|
|
->orderBy('create_time', 'asc')
|
|
|
- ->select([\DB::raw('count(id) as total'),'days','id',\DB::raw('(@rank:=@rank+1) as rank')]);
|
|
|
|
|
|
|
+ ->select([\DB::raw('count(id) as total'),'days','user_id',\DB::raw('(@rank:=@rank+1) as rank')]);
|
|
|
$binds = $model->getBindings();
|
|
$binds = $model->getBindings();
|
|
|
$sql = str_replace('?', '%s', $model->toSql());
|
|
$sql = str_replace('?', '%s', $model->toSql());
|
|
|
$sql = sprintf($sql, ...$binds);
|
|
$sql = sprintf($sql, ...$binds);
|
|
|
|
|
|
|
|
$ranks = $this->model::from(\DB::raw("({$sql}) as a"))
|
|
$ranks = $this->model::from(\DB::raw("({$sql}) as a"))
|
|
|
->where(['id'=> $userId])
|
|
->where(['id'=> $userId])
|
|
|
- ->select([\DB::raw('count(id) as total'),'id','rank'])
|
|
|
|
|
|
|
+ ->select([\DB::raw('count(id) as total'),'user_id','rank'])
|
|
|
->first();
|
|
->first();
|
|
|
if($ranks){
|
|
if($ranks){
|
|
|
|
|
+ $ranks['rank'] = $ranks['rank']? $ranks['rank'] : 0;
|
|
|
$counts['ranks'] = $ranks;
|
|
$counts['ranks'] = $ranks;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|