<?php
/** 店铺登录
 * @Copyright (C) 2016 汉潮 All rights reserved.
 * @License http://www.hanchao9999.com
 * @Author xiaoq <570035208@qq.com>
 */

namespace Pad\Model;
use Think\Model;
class CallLogModel extends Model{

    public function call_list($param){
    	$return=array('status'=>3);
    	if($param['shop_id']){
    		$map['shop_id']=$param['shop_id'];
	        $map['membertype']=array('neq',2);
	        if(!empty($param['pagesize']))$pagesize=$param['pagesize'];
	        else $pagesize=6;
	        if($param['p']){
	        	$p=$param['p'];
	        }else{
	        	$p=1;
	        }
	    	$list=page_list('CallLog',$map,'id desc',true,$pagesize,'',$p);
	    	if($list['list']){
	    		foreach ($list['list'] as $key => $value) {
		            $list['list'][$key]['addtime_format']=time_format($value['addtime']);
		            if($value['uid']>0){
		                $list['list'][$key]['nickname']=show_user_name($value['id']);
		            }
	        	}
	        	$return['status']=1;
	        	$return['list']=$list['list'];
	    	}else{
	    		$return['status']=2;
	    		$return['msg']="暂无数据";
	    	}
    	}else{
    		$return['msg']="参数错误！";
    	}
    	return $return;
    }
    public function call_info($param){
    	$return=array('status'=>3,'msg'=>'参数错误','data'=>'');
    	if($param['call_id']){
    		$map=array();
    		$map['id']=$param['call_id'];
    		$call_info=M('CallLog')->where($map)->find();
    		if($call_info){
    			$call_info['addtime']=time_format($call_info['addtime']);
    			if($call_info['uid']){
    				$map=array();
    				$map['id']=$call_info['uid'];
    				$user_info=M('Member')->where($map)->field(true)->find();
    				if($user_info){
    					$wdzpicurl=idtoname($call_info['uid'],'MemberCustomer','wdzpicurl','uid',false);
    					if($wdzpicurl)$user_info['wdzpicurl']=$wdzpicurl;
    					$user_info['rank_img']='../../image/v'.$user_info['rank_id'].'.png';
    					$user_info['reg_time']=time_format($user_info['reg_time']);
    					$last_buy=D('Pad/Face')->last_buy($call_info['uid']);
    					$consume=D('Pad/Face')->cunsume($call_info['uid'],$user_info['reg_time']);
    				}
    			}
    			$return['data']['last_buy']=$last_buy['data'];
				$return['data']['call_info']=$call_info;
				$return['data']['user_info']=$user_info;
				$return['data']['consume']=$consume['data'];
				$return['status']=1;
				$return['msg']='';
    		}
    	}
    	return $return;
    }
	
}
?>