diff --git a/app/api/controller/balance/Log.php b/app/api/controller/balance/Log.php index 5d1e6459..27f6e8eb 100644 --- a/app/api/controller/balance/Log.php +++ b/app/api/controller/balance/Log.php @@ -32,7 +32,7 @@ class Log extends Controller public function list(): Json { $model = new BalanceLogModel; - $list = $model->getList(); + $list = $model->getList($this->request->param()); return $this->renderSuccess(compact('list')); } } \ No newline at end of file diff --git a/app/api/model/user/BalanceLog.php b/app/api/model/user/BalanceLog.php index 7a80f46a..e56a46ac 100644 --- a/app/api/model/user/BalanceLog.php +++ b/app/api/model/user/BalanceLog.php @@ -36,13 +36,20 @@ class BalanceLog extends BalanceLogModel * @throws \cores\exception\BaseException * @throws \think\db\exception\DbException */ - public function getList(): \think\Paginator + public function getList($params): \think\Paginator { // 当前用户ID $userId = UserService::getCurrentLoginUserId(); // 获取列表数据 - return $this->where('user_id', '=', $userId) - ->order(['create_time' => 'desc']) + $query = $this->where('user_id', '=', $userId); + if(!empty($params['type'])){ + $query = $query->where('scene','=',$params['type']); + } + if(!empty($params['start_at']) && empty($params['end_at'])){ + $query = $query->where('create_time','>=',strtotime($params['start_at'])); + $query = $query->where('create_time','<=',strtotime($params['end_at'])); + } + return $query->order(['create_time' => 'desc']) ->paginate(15); } } \ No newline at end of file