<?php
/** 
 * 人脸识别回调
 * @Copyright (C) 2018 汉潮 All rights reserved.
 * @License http://www.hanchao9999.com
 * @Author xiaogg <xiaogg@sina.cn>
 * http://665.shop6.thinkp2p.cn/home/face/notify.html
 */
namespace Home\Controller;
class FaceController extends BaseController {
    public function notify(){
        $face = new \Common\Vendor\Face();
        $result=$face->notify();//响应回调
    }
    public function index(){
        $param=I('param.');
        if($param['shop_id'] && $param['device_id']){
            $ip=idtoname($param['device_id'],'ShopsFacedevice','ip','device_id',false);
            if(!empty($ip)){
                $source='rtsp://'.$ip;
                $this->assign('source',$source);
            }
            $data=D('Common/Face')->get_member_customer($param);
            if(!empty($data['list'])){
                $this->assign($data);
                $this->assign($data['default_right']);
            }
        }else{
            $this->error("参数错误！");
        }
        $this->assign($param);
        $this->display();
    }
    public function get_member_customer(){
        $param=I('param.');
        $return=array('status'=>0,'info'=>'','data'=>'');
        if($param['shop_id']){
            $data=D('Common/Face')->get_member_customer($param);
            $html='';
            if($data['list']){
                foreach ($data['list'] as $key => $value) {
                    $html.='<div class="comment_item"><div class="member_list" onclick="get_member_customer_right('.$value['uid'].')"><ul><li>';
                    if($value['wdzpicurl']){
                        $html.='<img src="'.$value["wdzpicurl"].'" class="member_header_img">';
                    }else{
                        $html.='<img src="'.$param['lj'].'common/images/mer_logo.jpg" class="member_header_img">';
                    }
                    $html.='<div class="member_text flex_inside"><h3>';
                    if($value['uid']>0){
                        $html.='<span>'.$value['username'].'</span><img src="'.$param['lj'].'common/images/v'.$value['rank_id'].'.'.'png" alt="">';
                    }else{
                        if($value['customer_count']>1){
                            $html.='<span>老顾客</span>';
                        }else{
                            $html.='<span>新顾客</span>';
                        }
                    }
                    $html.='</h3><p>到店时间：'.$value["uptime"].'</p><p class="height7">';
                    if($value['uid']>0){
                        $html.='<span>到店次数:'.$value["customer_count"].'次</span><span>总消费金额:'.$value['lj_xf'].'元</span>';
                    }else{
                        if($value['customer_count']>1){
                            $html.='<span>到店次数:'.$value["customer_count"].'次</span>';
                        }
                    }
                    $html.='</p></div></li></ul></div></div>';
                }
                $return['status']=1;
                $return['data']['html']=$html;
                $return['customer_ids']=$data['data']['customer_ids'];
            }
        }else{
           $return['info']="参数错误";
        }
        $this->ajaxReturn($return);
    }
    public function get_member_customer_right(){
        $param=I('param.');
        $return=array('status'=>0,'info'=>'','data'=>'');
        if($param['uid']){
            $data=D('Common/Face')->get_member_customer_right($param['uid']);
            if(!empty($data)){
                $html.='';
                $html='<div class="mesg_tupian"><div class="mesg_img">';
                    if($data['wdzpicurl_before']){
                        $html.='<img src="'.$data['wdzpicurl_before'].'" alt="">';
                    }else{
                        $html.='<img src="'.$param['lj'].'common/images/tou.jpg" alt="">';
                    }
                $html.='</div><div class="mesg_img1"><img src="'.$data['wdzpicurl'].'" alt=""></div></div><ul class="mesg_message"><li><a class="f_r"><span class="color_999 mr5">'.$data['username'].'</span></a><span>姓名</span></li><li><a class="f_r"><span class="color_999 mr5">'.$data['uptime'].'</span></a><span>到店时间</span></li><li>
                        <a class="f_r"><span class="color_999 mr5">'.$data['rank_id'].'级</span></a>
                        <span>会员等级</span></li><li class="wushi"><a class="f_r"><span class="color_999 mr5">'.$data['money'].'元</span></a>
                        <span>余额</span></li><li class="wushi"><a class="f_r"><span class="color_999 mr5">'.$data['usepoints'].'积分</span></a><span>积分</span></li></ul>';   
                $return['data']=$html;
                $return['status']=1;
            }
        }else{
            $return['info']="参数错误";
        }
        $this->ajaxReturn($return);
    }
    public function txt(){
        $face = new \Common\Vendor\Face();
        $data=$face->queryGroup();
        print_r($data);
    }
    public function txt1(){
        $face = new \Common\Vendor\Face();
        $data=$face->queryDevice();
        print_r($data);
    }
    public function txt2(){
    
        $pay_info = M("shops")->where('id=1')->field(true)->find();
        print_r(M('shops')->getLastSql());die;
    }

    
    
}
?>