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