<?php
/**
 * Created by PhpStorm.
 * User: xmy 280564871@qq.com
 * Date: 2017/4/6
 * Time: 16:36
 */

namespace Admin\Controller;

use Admin\Model\PointShopRecordModel;

class PointShopRecordController extends ThinkController{


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

	public function lists($p=1)
	{
		$model = new PointShopRecordModel();
		I('good_id') == "" || $map['sr.good_id'] = I('good_id');
		empty(I("account")) || $map['u.account'] = ["like","%".I("account")."%"];
		// empty(I("time_start")) || $map['sr.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['sr.create_time'] = array('between',[strtotime($_REQUEST['time_start']),strtotime($_REQUEST['time_end'])+86399]);}
		elseif (!empty($_REQUEST['time_start']) && empty($_REQUEST['time_end'])) {$map['sr.create_time'] = array('between',[strtotime($_REQUEST['time_start']),time()]);}
		elseif (empty($_REQUEST['time_start']) && !empty($_REQUEST['time_end'])) {$map['sr.create_time'] = array('elt',strtotime($_REQUEST['time_end'])+86399);}
		$data = $model->getLists($map,"create_time desc",$p);
		$this->assign("data",$data['data']);

		//分页
		$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->display();
	}
}