<?php 
namespace Common\Model;
use Think\Model;
class UserPmsChatModel extends Model
{
	//获取最新一条回复
	public function get_one($pid='')
	{
		$map['pid']=intval($pid);
		$info=$this->where($map)->order('id desc')->find();
		return $info;
	}
	//获取回复
	public function get_list($pid='',$uid='')
	{
		$pms=D('UserPms')->get_pms_one($pid);
		if ($pms['send_uid']==$uid)//我是发件人
		{
		$map['send_display']=1;
		}else{
		$map['to_display']=1;
		}
		$sort="id ASC";
		$map['pid']=intval($pid);
		$result = $this->where($map)->order($sort)->select();
		foreach ($result as $key => $v){
				$v['addtime_str']=daterange($v['addtime']);
				$v['user']=D('User')->get_user_one($v['send_uid'],true,1);
				$list[]=$v;
			}
		$return['list']=$list;
		$return['count']=count($list);
		$return['page']=$page_str;
		//print_r($return);
		return $return;
	}
	 
}
?>