123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- // +----------------------------------------------------------------------
- // | 文件说明:幻灯片
- // +----------------------------------------------------------------------
- // | Copyright (c) 2013-2017 http://www.thinkcmf.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Author: wuwu <15093565100@163.com>
- // +----------------------------------------------------------------------
- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
- // +----------------------------------------------------------------------
- // | Date: 2017-5-25
- // +----------------------------------------------------------------------
- namespace api\activity\controller;
- use api\activity\model\ActivityModel;
- use api\activity\model\ActivitySiteModel;
- use cmf\controller\RestBaseController;
- class SiteController extends RestBaseController
- {
- /**
- * 列表
- */
- public function index()
- {
- $param = $this->request->param();
- $page = empty($param['page']) ? 1 : $param['page'];
- $size = empty($param['size']) ? 10 : $param['size'];
- //搜索条件
- $where = [];
- if (!empty($param['keyword'])) {
- $where[] = ['site_name', 'like', "%{$param['keyword']}%"];
- }
- $list = ActivitySiteModel::where($where)->order('create_time', 'DESC')->page($page, $size)->select();
- $this->success('成功', $list);
- }
- /**
- * 所有列表
- */
- public function all()
- {
- $where = [];
- $is_map = $this->request->param('is_map', 0);
- $keyword = $this->request->param('keyword', '');
- if (!empty($is_map)) {
- $where[] = ['latitude', '>', 0];
- }
- if (!empty($keyword)) {
- $where[] = ['site_name', 'like', "%{$keyword}%"];
- }
- $list = ActivitySiteModel::order('list_order', 'ASC')->where($where)->select();
- //数据处理
- if (!$list->isEmpty()) {
- foreach ($list as $v) {
- $v['main_image'] = cmf_get_image_preview_url($v['main_image']);
- }
- }
- $this->success('成功', $list);
- }
- /**
- * 详情
- */
- public function detail()
- {
- $id = $this->request->post('id');
- $info = ActivitySiteModel::get($id);
- $info['main_image'] = cmf_get_image_preview_url($info['main_image']);
- $this->success('成功', $info);
- }
- /**
- * 统计
- */
- public function getCount()
- {
- $id = $this->request->param('id');
- $total = ActivityModel::where('user_id', $id)->count();
- $month_start = strtotime(date('Y-m-01'));
- $month_end = strtotime(date('Y-m-01') . ' +1 month') - 1;
- $month_total = ActivityModel::where('user_id', $id)->where('create_time', 'between', [$month_start, $month_end])->count();
- $year_start = strtotime(date('Y-01-01'));
- $year_end = strtotime(date('Y-01-01') . ' +1 year') - 1;
- $year_total = ActivityModel::where('user_id', $id)->where('create_time', 'between', [$year_start, $year_end])->count();
- $this->success('成功', [
- 'total' => $total,
- 'month_total' => $month_total,
- 'year_total' => $year_total,
- ]);
- }
- }
|