<?php
/**
 * Created by PhpStorm.
 * User: xmy 280564871@qq.com
 * Date: 2017/4/1
 * Time: 10:22
 */

namespace Admin\Controller;


use Admin\Model\PointRecordModel;

class PointRecordController extends ThinkController{

	public function _initialize()
	{
		$this->meta_title = "积分记录";
		return parent::_initialize(); // TODO: Change the autogenerated stub
	}

	public function lists($p=1){
		$model = new PointRecordModel();
		empty(I('type_id')) || $map['pr.type_id'] = I('type_id');
		empty(I("account")) || $map['u.account'] = ["like","%".I("account")."%"];
		//empty(I("time_start")) || $map['pr.create_time'] = ["between",[strtotime(I("time_start")),empty(I("time_end"))?time():strtotime(I("time_end"))+86400-1]];
		
		if(!empty($_REQUEST['time_start']) && !empty($_REQUEST['time_end'])) {$map['pr.create_time'] = array('between',[strtotime($_REQUEST['time_start']),strtotime($_REQUEST['time_end'])+86399]);}
		elseif (!empty($_REQUEST['time_start']) && empty($_REQUEST['time_end'])) {$map['pr.create_time'] = array('between',[strtotime($_REQUEST['time_start']),time()]);}
		elseif (empty($_REQUEST['time_start']) && !empty($_REQUEST['time_end'])) {$map['pr.create_time'] = array('elt',strtotime($_REQUEST['time_end'])+86399);}
		
		
		$data = $model->getLists($map,'create_time desc',$p);

		//分页
		$count = $data['count'];
		
		if(isset($_REQUEST['row'])) {$row = $_REQUEST['row'];}else{$row = 10;}
		
		$page = set_pagination($count,$row);
		if($page) {$this->assign('_page', $page);}

		$this->m_title = '积分商城';
		$this->assign('commonset',M('Kuaijieicon')->where(['url'=>'PointType/lists','status'=>1])->find());
			
		
		$this->assign("data",$data['data']);
		$this->display();
	}

}