95 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
		
		
			
		
	
	
			95 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| 
								 | 
							
								<?php
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								namespace app\admin\controller\xilufitness\user;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								use app\admin\controller\xilufitness\traits\Fitness;
							 | 
						|||
| 
								 | 
							
								use app\common\controller\Backend;
							 | 
						|||
| 
								 | 
							
								use think\exception\DbException;
							 | 
						|||
| 
								 | 
							
								use think\response\Json;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								/**
							 | 
						|||
| 
								 | 
							
								 * 积分规则
							 | 
						|||
| 
								 | 
							
								 *
							 | 
						|||
| 
								 | 
							
								 * @icon fa fa-circle-o
							 | 
						|||
| 
								 | 
							
								 */
							 | 
						|||
| 
								 | 
							
								class PointRule extends Backend
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    use Fitness;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    /**
							 | 
						|||
| 
								 | 
							
								     * PointRule模型对象
							 | 
						|||
| 
								 | 
							
								     * @var \app\admin\model\xilufitness\user\PointRule
							 | 
						|||
| 
								 | 
							
								     */
							 | 
						|||
| 
								 | 
							
								    protected $model = null;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    /**
							 | 
						|||
| 
								 | 
							
								     * 开启关联查询
							 | 
						|||
| 
								 | 
							
								     */
							 | 
						|||
| 
								 | 
							
								    protected $relationSearch = true;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    /**
							 | 
						|||
| 
								 | 
							
								     * 快捷查询
							 | 
						|||
| 
								 | 
							
								     */
							 | 
						|||
| 
								 | 
							
								    protected $searchFields = 'brand.brand_name,point_rule.title';
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    public function _initialize()
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        parent::_initialize();
							 | 
						|||
| 
								 | 
							
								        $this->model = new \app\admin\model\xilufitness\user\PointRule;
							 | 
						|||
| 
								 | 
							
								        $this->view->assign("statusList", $this->model->getStatusList());
							 | 
						|||
| 
								 | 
							
								        $this->view->assign('typeList',$this->model->getTypeList());
							 | 
						|||
| 
								 | 
							
								        $this->assign('fitness_brand_id',$this->getFitnessBrandId());
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    /**
							 | 
						|||
| 
								 | 
							
								     * 查看
							 | 
						|||
| 
								 | 
							
								     *
							 | 
						|||
| 
								 | 
							
								     * @return string|Json
							 | 
						|||
| 
								 | 
							
								     * @throws \think\Exception
							 | 
						|||
| 
								 | 
							
								     * @throws DbException
							 | 
						|||
| 
								 | 
							
								     */
							 | 
						|||
| 
								 | 
							
								    public function index()
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        //设置过滤方法
							 | 
						|||
| 
								 | 
							
								        $this->request->filter(['strip_tags', 'trim']);
							 | 
						|||
| 
								 | 
							
								        if (false === $this->request->isAjax()) {
							 | 
						|||
| 
								 | 
							
								            return $this->view->fetch();
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        //如果发送的来源是 Selectpage,则转发到 Selectpage
							 | 
						|||
| 
								 | 
							
								        if ($this->request->request('keyField')) {
							 | 
						|||
| 
								 | 
							
								            return $this->selectpage();
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        [$where, $sort, $order, $offset, $limit] = $this->buildparams();
							 | 
						|||
| 
								 | 
							
								        $fitness_brand_id = $this->getFitnessBrandId();
							 | 
						|||
| 
								 | 
							
								        $list = $this->model
							 | 
						|||
| 
								 | 
							
								            ->with(['brand'])
							 | 
						|||
| 
								 | 
							
								            ->where($where)
							 | 
						|||
| 
								 | 
							
								            ->where(function ($query) use($fitness_brand_id){
							 | 
						|||
| 
								 | 
							
								                if($fitness_brand_id > 0){
							 | 
						|||
| 
								 | 
							
								                    $query->where('brand_id','eq',$fitness_brand_id);
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            })
							 | 
						|||
| 
								 | 
							
								            ->order($sort, $order)
							 | 
						|||
| 
								 | 
							
								            ->paginate($limit);
							 | 
						|||
| 
								 | 
							
								        $result = ['total' => $list->total(), 'rows' => $list->items()];
							 | 
						|||
| 
								 | 
							
								        return json($result);
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //回收站列表
							 | 
						|||
| 
								 | 
							
								    public function recyclebin() {
							 | 
						|||
| 
								 | 
							
								        return;
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								    //回收站(真实删除或清空)
							 | 
						|||
| 
								 | 
							
								    public function destroy($ids = null) {
							 | 
						|||
| 
								 | 
							
								        return;
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								    //回收站还原
							 | 
						|||
| 
								 | 
							
								    public function restore($ids = null) {
							 | 
						|||
| 
								 | 
							
								        return;
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								}
							 |