diff --git a/application/api/model/GiveGiftBases.php b/application/api/model/GiveGiftBases.php index 370a20b0..3d08bbd3 100644 --- a/application/api/model/GiveGiftBases.php +++ b/application/api/model/GiveGiftBases.php @@ -21,12 +21,14 @@ class GiveGiftBases extends Model /** * 获取送礼记录 */ + public function getGiftRecords($params) { // $params = $this->request->param(); $where = []; $options = []; + // 构建查询条件 if (!empty($params['from_id'])) { $where['from_id'] = $params['from_id']; @@ -52,10 +54,10 @@ class GiveGiftBases extends Model // 时间范围 if (!empty($params['start_time'])) { - $options['start_time'] = strtotime($params['start_time']); + $options['start_time'] = intval($params['start_time']); } if (!empty($params['end_time'])) { - $options['end_time'] = strtotime($params['end_time'] . ' 23:59:59'); + $options['end_time'] = intval($params['end_time']); } // 分页参数 diff --git a/application/common/model/GiveGiftBase.php b/application/common/model/GiveGiftBase.php index ce58497c..d7ae41e0 100644 --- a/application/common/model/GiveGiftBase.php +++ b/application/common/model/GiveGiftBase.php @@ -154,12 +154,12 @@ class GiveGiftBase extends Model public function getGiftRecords($where = [], $options = []) { $defaultOptions = [ - 'fields' => '*', - 'order' => 'createtime desc', - 'page' => 1, - 'limit' => 20, - 'start_time'=> null, - 'end_time' => null, + 'fields' => '*', + 'order' => 'createtime desc', + 'page' => 1, + 'limit' => 20, + 'start_time' => null, + 'end_time' => null, ]; $options = array_merge($defaultOptions, $options); @@ -191,13 +191,13 @@ class GiveGiftBase extends Model $conditions = []; $fieldMap = [ - 'user_id' => 'user_id', - 'gift_user' => 'gift_user', - 'from_id' => 'from_id', - 'gift_id' => 'gift_id', - 'type' => 'type', - 'from' => 'from', - 'gift_type' => 'gift_type', + 'user_id' => 'user_id', + 'gift_user' => 'gift_user', + 'from_id' => 'from_id', + 'gift_id' => 'gift_id', + 'type' => 'type', + 'from' => 'from', + 'gift_type' => 'gift_type', 'createtime' => 'createtime', ]; @@ -276,7 +276,7 @@ class GiveGiftBase extends Model $data = []; if ($total > 0) { $offset = ($options['page'] - 1) * $options['limit']; - $dataSql = "{$unionSql} ORDER BY {$options['order']} DESC LIMIT {$offset}, {$options['limit']}"; + $dataSql = "{$unionSql} ORDER BY {$options['order']} LIMIT {$offset}, {$options['limit']}"; try { $data = Db::query($dataSql, $params); @@ -288,8 +288,8 @@ class GiveGiftBase extends Model return [ 'total' => $total, - 'data' => $data, - 'page' => $options['page'], + 'data' => $data, + 'page' => $options['page'], 'limit' => $options['limit'] ]; } @@ -303,9 +303,9 @@ class GiveGiftBase extends Model public function getGiftStatistics($where = [], $options = []) { $defaultOptions = [ - 'group_by' => null, // 分组字段 + 'group_by' => null, // 分组字段 'start_time' => null, - 'end_time' => null, + 'end_time' => null, ]; $options = array_merge($defaultOptions, $options);