<?php 
namespace Common\Model;
use Think\Model;
class LogGoldModel extends Model
{
	protected $_validate = array(
		//array('title','require','问题标题必须填写！',1),
	);
 
	protected $_auto = array (
		//array('issolve','0'),
	);
	public function log_list($map='',$page=true,$limit=10)
	{
		if ($page)
		{
		$count = $this->where($map)->count();
		$Page  = pager($count,limit);
		$list  = $this->where($map)->order('id DESC')->limit($Page->firstRow.','.$Page->listRows)->select();
		}
		else
		{
		$list  = $this->where($map)->order('id DESC')->limit($limit)->select();
		}
		$return['list']=$list;
		$return['count']=$page?$count:count($list);
		$return['page']=$page?$Page->fshow():'';
		return $return;
	}
	//增加积分/经验变更日志
	public function add_log($type='1',$uid='',$var='0',$logtxt='',$addition=true)
	{
		$var=intval($var);
		$data['type']=$type;
		$data['uid']=intval($uid);
		if ($type=='1')
		{
		$data['gold']=$addition?$var:("-".$var);
		$data['exp']=0;
		}
		if ($type=='2')
		{
		$data['gold']=0;
		$data['exp']=$addition?$var:("-".$var);
		}
		$data['addtime']=time();
		$data['txt']=$logtxt;
		$data['entrance'] = C('UU_LOG_ENTRANCE');
		$this->add($data);
		return true;
	}
	 
}
?>