From ff52c3fee9251c75daa725a452d122fd14c17629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Wed, 7 Jan 2026 20:30:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=BF=E9=97=B4=E6=B5=81=E6=B0=B4=E8=AF=A6?= =?UTF-8?q?=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/model/GiveGiftBases.php | 50 ++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/application/api/model/GiveGiftBases.php b/application/api/model/GiveGiftBases.php index a6f2db2a..00bf233b 100644 --- a/application/api/model/GiveGiftBases.php +++ b/application/api/model/GiveGiftBases.php @@ -53,10 +53,10 @@ class GiveGiftBases extends Model // 时间范围 if (!empty($params['start_time'])) { - $options['start_time'] = intval($params['start_time']); + $options['start_time'] = strtotime($params['start_time']); } if (!empty($params['end_time'])) { - $options['end_time'] = intval($params['end_time']); + $options['end_time'] = strtotime($params['end_time']); } // 分页参数 @@ -298,4 +298,50 @@ class GiveGiftBases extends Model ]); } + public function getGiftList() + { + $params = $this->request->param(); + + $where = []; + $options = []; + + // 构建查询条件 + $searchFields = ['from_id', 'user_id', 'gift_user', 'gift_id', 'type', 'from', 'gift_type']; + foreach ($searchFields as $field) { + if (!empty($params[$field])) { + $where[$field] = $params[$field]; + } + } + + // 时间范围 + if (!empty($params['start_time'])) { + $options['start_time'] = strtotime($params['start_time']); + } + if (!empty($params['end_time'])) { + $options['end_time'] = strtotime($params['end_time']); + } + + // 搜索关键词 + if (!empty($params['search'])) { + // 可以扩展搜索逻辑 + } + + // 分页参数 + $options['page'] = $params['page'] ?? 1; + $options['limit'] = $params['limit'] ?? $this->pageSize; + + // 查询数据 + $result = $this->giftModel->getGiftRecords($where, $options); + + // 转换时间格式 + foreach ($result['data'] as &$item) { + $item['createtime_text'] = $item['createtime'] ? date('Y-m-d H:i:s', $item['createtime']) : ''; + $item['updatetime_text'] = $item['updatetime'] ? date('Y-m-d H:i:s', $item['updatetime']) : ''; + } + + $total = $result['total']; + $data = $result['data']; + $result = array("total" => $total, "rows" => $data); + } + } \ No newline at end of file