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

namespace Admin\Controller;

use Admin\Model\ShareRecordModel;

class ShareRecordController extends ThinkController{

	public function _initialize()
	{
		$this->meta_title = "邀请好友奖励";
		return parent::_initialize(); // TODO: Change the autogenerated stub
	}

	public function lists($p=1){
		$model = new ShareRecordModel();
		empty(I("invite_account")) || $map['invite_account'] = ["like","%".I("invite_account")."%"];
		//empty(I("time_start")) || $map['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['create_time'] = array('between',[strtotime($_REQUEST['time_start']),strtotime($_REQUEST['time_end'])+86399]);}
		elseif (!empty($_REQUEST['time_start']) && empty($_REQUEST['time_end'])) {$map['create_time'] = array('between',[strtotime($_REQUEST['time_start']),time()]);}
		elseif (empty($_REQUEST['time_start']) && !empty($_REQUEST['time_end'])) {$map['create_time'] = array('elt',strtotime($_REQUEST['time_end'])+86399);}
		
		
		$data = $model->getInviteRecord($map,$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->assign("data",$data['data']);
		
		$this->m_title = '积分商城';
		$this->assign('commonset',M('Kuaijieicon')->where(['url'=>'PointType/lists','status'=>1])->find());
			
		
		$this->display();
	}

	public function detail($id,$p=1){
		$model = new ShareRecordModel();
		$map['invite_id'] = $id;
		$data = $model->getDetail($map,$p);
		$this->assign("data",$data['data']);
		$this->display();
	}
}