public function register_device()
 {
     $device = isset($_POST['device']) ? (int) htmlspecialchars($_POST['device']) : '';
     //1 android  2 ios
     $dev_id = isset($_POST['dev_id']) ? htmlspecialchars($_POST['dev_id']) : '';
     $session_id = $_POST['session_id'];
     $member_id = $this->session_handle->getsession_userid($session_id, 1);
     $systemid = CommonController::getSystemUserid($member_id['id'], $member_id['type']);
     if (empty($device) || $device != '1' || $device != '2') {
         $this->jsonUtils->echo_json_msg(4, '设备不正确');
         exit;
     }
     if (empty($dev_id)) {
         $this->jsonUtils->echo_json_msg(4, '设备号为空');
         exit;
     }
     $db = M('Device');
     //判断
     $data = $db->where(array('dev_id' => $dev_id, 'device' => $device))->getField('id');
     if ($data) {
     }
 }
 /**
  * 商家头像上传
  * 
  * @return [type] [description]
  */
 public function merchantHeader()
 {
     $mer_session_id = isset($_POST['mer_session_id']) ? htmlspecialchars(trim($_POST['mer_session_id'])) : '';
     $merchant_id = $this->session_handle->getsession_userid($mer_session_id, 1);
     if ($_FILES) {
         $result = mul_upload('/Header/', 3);
         // 			Log::write(json_encode($result),'ERR');
         if ($result) {
             $data['header'] = $result[0];
             $id = $merchant_id['id'];
             $this->dao->where(array('id' => $merchant_id['id']))->save($data);
             CommonController::saveHeader($merchant_id['id'], $merchant_id['type'], $result[0]);
             $header = imgUrl($result[0]);
             $this->jsonUtils->echo_json_data(0, '上传成功!', array('header' => $header));
             exit;
         } else {
             $this->jsonUtils->echo_json_msg(1, '上传失败!');
             exit;
         }
     } else {
         $this->jsonUtils->echo_json_msg(1, '无文件上传!');
         exit;
     }
 }
 /**
  * 执行审核通过
  * @param int $id
  */
 function execAction()
 {
     $id = $_REQUEST['id'];
     if (empty($id)) {
         return '';
     }
     $arr = C('AUTH_DB_CONFIG');
     $db = M('Auth');
     $data = $db->where("id ={$id}")->find();
     if ($data['status'] == 0) {
         $check_data = json_decode($data['check_data'], true);
         $db_no = $data['db_no'];
         $action = $data['check_action'];
         //商家操作 只能支持save 有触发器 关联聊天
         if ($db_no == 0) {
             if ($action != 'save') {
                 die('错误操作');
             }
         }
         $where = array('id' => $data['mark_id']);
         $exec_db = M($arr[$db_no]);
         switch ($action) {
             case 'save':
                 $exec = $exec_db->where($where)->save($check_data);
                 break;
             case 'add':
                 //未启用
                 $exec = $exec_db->add($check_data);
                 break;
             case 'del':
                 $exec = $exec_db->where($where)->delete();
                 break;
             default:
                 die('错误数据:action');
                 break;
         }
         if ($exec === false) {
             $this->ajaxReturn(array('code' => 1, 'msg' => $exec_db->getLastSql()));
             exit;
         } else {
             if ($db_no == 0) {
                 //同步更新 商户名称和头像
                 if (!empty($check_data["merchant_name"])) {
                     CommonController::saveName($data['mark_id'], 2, $check_data["merchant_name"]);
                 }
                 if (!empty($check_data["header"])) {
                     CommonController::saveHeader($data['mark_id'], 2, $check_data["header"]);
                 }
             }
             $db->where("id ={$id}")->save(array('status' => 1));
             //审核通过
             $this->ajaxReturn(array('code' => 0, 'msg' => '审核成功'));
             exit;
         }
     } else {
         $this->ajaxReturn(array('code' => 1, 'msg' => '已操作过,无需审核'));
         exit;
     }
 }
 /**
  * 添加服务项目
  */
 public function add_service()
 {
     $intro = isset($_POST['intro']) ? htmlspecialchars($_POST['intro']) : '';
     $price = isset($_POST['price']) ? htmlspecialchars($_POST['price']) : '';
     $sub_id = isset($_POST['sub_id']) ? htmlspecialchars($_POST['sub_id']) : '';
     $timeout = isset($_POST['timeout']) ? htmlspecialchars($_POST['timeout']) : '';
     $mer_session_id = isset($_POST['mer_session_id']) ? htmlspecialchars($_POST['mer_session_id']) : '';
     $merchant_id = $this->session_handle->getsession_userid($mer_session_id);
     if ($price == null || $price == '' || !is_numeric($price)) {
         $this->jsonUtils->echo_json_msg(4, "项目价格不符合格式!");
         exit;
     }
     if ($this->dao->where(array('cat_id' => $sub_id, 'merchant_id' => $merchant_id))->field('id')->find()) {
         $this->jsonUtils->echo_json_msg(1, '已添加过该服务!');
         exit;
     }
     $cate = CategoryController::getCategoryById($sub_id);
     $postion = CommonController::getMerchantPosition($merchant_id);
     $data['province_id'] = $postion['province_id'];
     $data['city_id'] = $postion['city_id'];
     $data['area_id'] = $postion['area_id'];
     $data['name'] = $cate['name'];
     $data['merchant_id'] = $merchant_id;
     $data['intro'] = $intro;
     $data['price'] = $price;
     $data['pcat_id'] = $cate['pid'];
     $data['cat_id'] = $sub_id;
     $data['timeout'] = $timeout;
     $data['addtime'] = time();
     $data['pics'] = "[]";
     $result = $this->dao->add($data);
     if ($_FILES) {
         $arr = mul_upload('/Service/', 1);
         if ($arr) {
             $data1['pics'] = json_encode($arr);
             // 把多张图片数组格式转json保存数据库
             $this->dao->where("id={$result}")->save($data1);
         }
     }
     if ($result) {
         $this->jsonUtils->echo_json_msg(0, '添加成功!');
         exit;
     } else {
         $this->jsonUtils->echo_json_msg(1, '添加失败!');
         exit;
     }
 }
 /**
  * 举报  system_user_id
  * type 1 色情 2暴力 3 发动 4 广告 5 骚扰信息 6资料不当 7 侵犯版权 8 其他
  * 
  * position 1 举报问题 2 举报问题回复 3举报问题评论 4举报遇见 5 举报遇见的评论 6举报个人 
  * obj_id  1 问题id 2 回复id 3评论id 4 遇见id 5遇见评论id 6 system_user_id
  */
 public function report()
 {
     $session_id = isset($_POST['session_id']) ? htmlspecialchars($_POST['session_id']) : '';
     $member_id = $this->session_handle->getsession_userid($session_id, 1);
     $systemid = CommonController::getSystemUserid($member_id['id'], $member_id['type']);
     $position = isset($_POST['position']) ? htmlspecialchars($_POST['position']) : '';
     $type = isset($_POST['type']) ? htmlspecialchars($_POST['type']) : '';
     //
     $obj_id = isset($_POST['obj_id']) ? htmlspecialchars($_POST['obj_id']) : '';
     if (empty($position)) {
         $this->jsonUtils->echo_json_msg(4, '举报来源为空...');
         exit;
     }
     if (empty($type)) {
         $this->jsonUtils->echo_json_msg(4, '举报分类为空...');
         exit;
     }
     if (empty($obj_id)) {
         $this->jsonUtils->echo_json_msg(4, '举报对象为空...');
         exit;
     }
     $db = M('Report');
     $unique = $db->where(array('reporter' => $systemid, 'position' => $position, 'obj_id' => $obj_id))->getField('id');
     if ($unique) {
         $this->jsonUtils->echo_json_msg(0, '你已举报过');
         exit;
     } else {
         $data = $db->add(array('reporter' => $systemid, 'position' => $position, 'obj_id' => $obj_id, 'type' => $type, 'addtime' => time()));
         if ($data) {
             $this->jsonUtils->echo_json_msg(0, '举报成功');
             exit;
         } else {
             $this->jsonUtils->echo_json_msg(1, '举报失败');
             exit;
         }
     }
 }
 public function jpush()
 {
     $jid = isset($_REQUEST['jid']) ? htmlspecialchars($_REQUEST['jid']) : '';
     $content = isset($_POST['content']) ? htmlspecialchars($_POST['content']) : '';
     $session_id = isset($_POST['session_id']) ? htmlspecialchars($_POST['session_id']) : '';
     $member_id = $this->session_handle->getsession_userid($session_id, 1);
     $systemid = CommonController::getSystemUserid($member_id['id'], $member_id['type']);
     $user = M('SystemUser')->where(array('id' => $jid))->field('type,name')->find();
     //jpush
     $jpush = new \App\Model\JpushModel();
     $jpush->user = $user['type'];
     $string = $content;
     $jpush->push(5, array($jid), array('content' => $string, 'jid' => $systemid, 'title' => $user['name']));
     $this->jsonUtils->echo_json_msg(0, 'ok');
     exit;
 }
 public function get_order()
 {
     $order_no = isset($_POST['order_no']) ? htmlspecialchars($_POST['order_no']) : '';
     $member_session_id = $_POST['member_session_id'];
     $member_id = $this->session_handle->getsession_userid($member_session_id);
     if (empty($order_no)) {
         $this->jsonUtils->echo_json_msg(4, '订单号为空...');
         exit;
     }
     $arr = $this->dao->table(C('DB_PREFIX') . "order as a")->field("a.order_no,a.addtime,b.id as merchant_id,b.header,b.merchant_name,a.reach_time,a.cart_data,a.member_remark,a.merchant_remark,a.total_price,a.total_time,a.type,a.sub_data,a.member_comment,a.merchant_comment,a.fail_content,a.status,b.tel")->join(C('DB_PREFIX') . 'merchant as b on a.merchant_id = b.id')->where("a.order_no={$order_no} and a.member_id = {$member_id} ")->find();
     if ($arr) {
         $cart = json_decode($arr['cart_data'], true);
         unset($arr['cart_data']);
         $arr['system_user_id'] = CommonController::getSystemUserid($arr['merchant_id'], 2);
         $arr['header'] = imgUrl($arr['header']);
         $arr['cart_model'] = $cart['cart_model'];
         $arr['reach_time'] = date('Y-m-d H:i:s', $arr['reach_time']);
         $arr['addtime'] = date('Y-m-d H:i:s', $arr['addtime']);
         // $arr ['header'] = imgUrl ( $arr ['header'] );
         $model = new Model();
         $sub_data = json_decode($arr['sub_data'], true);
         switch ($arr['type']) {
             // 0 预约 1需求 2活动
             case '0':
                 $arr['pics'] = imgUrl($sub_data['pics']);
                 //	$arr ['distance'] = '';
                 $arr['list'] = $sub_data['list'];
                 break;
             case '1' or '3':
                 // 需求
                 $arr['pics'] = imgUrl($sub_data['pics']);
                 //	$arr ['distance'] = $sub_data ['distance'];
                 $arr['list'] = $sub_data['list'];
                 break;
             case '2':
                 // 活动
                 //	$arr ['distance'] = '';
                 $arr['list'] = array();
                 break;
             default:
                 $this->jsonUtils->echo_json_msg(4, '数据异常');
                 exit;
                 break;
         }
         unset($arr['sub_data']);
         if ($arr['status'] != 0) {
             if ($arr['member_comment'] > 0) {
                 $sql = "select a.desc,c.header,c.nick_name,a.pics,from_unixtime(a.addtime,'%Y-%m-%d %H:%i:%s') as addtime,\r\n\t\t\t\t\ta.service_attitude,a.service_quality,a.merchant_setting\r\n\t\t\t\t\tfrom " . C('DB_PREFIX') . "comment as a  left join\r\n\t\t\t\t\t" . C('DB_PREFIX') . "member as c on a.member_id=c.id\r\n\t\t\t\t\twhere a.order_no={$arr['order_no']} and type=0 limit 1";
                 $arro = $this->dao->query($sql);
                 $arro[0]['header'] = imgUrl($arro[0]['header']);
                 $arro[0]['pics'] = imgUrl(json_decode($arro[0]['pics'], true));
                 $arr['member_comment'] = '1';
                 $arr['member_comment_info'] = empty($arro[0]) ? '' : $arro[0];
             } else {
                 $arr['member_comment'] = '0';
                 $arr['member_comment_info'] = '';
             }
             if ($arr['merchant_comment'] > 0) {
                 $sql = "select a.desc,c.header,a.pics,c.merchant_name as nick_name,a.service_attitude,from_unixtime(a.addtime,'%Y-%m-%d %H:%i:%s') as addtime \r\n\t\t\t\t\tfrom " . C('DB_PREFIX') . "comment as a  left join " . C('DB_PREFIX') . "merchant as c \r\n\t\t\t\t\ton a.merchant_id=c.id where a.order_no={$arr['order_no']} and type=2 limit 1";
                 $arro = $this->dao->query($sql);
                 $arro[0]['header'] = imgUrl($arro[0]['header']);
                 $arro[0]['pics'] = imgUrl(json_decode($arro[0]['pics'], true));
                 $arr['merchant_comment'] = '1';
                 $arr['merchant_comment_info'] = empty($arro[0]) ? '' : $arro[0];
             } else {
                 $arr['merchant_comment'] = '0';
                 $arr['merchant_comment_info'] = '';
             }
         } else {
             $arr['merchant_comment_info'] = '';
             $arr['member_comment_info'] = '';
         }
         $this->jsonUtils->echo_json_data(0, 'ok', $arr);
         exit;
     } else {
         $this->jsonUtils->echo_json_msg(1, '该订单不存在..');
         exit;
     }
 }
 /**
  * 收藏列表
  */
 public function collect_listV2()
 {
     $member_session_id = $_POST['session_id'];
     $page = isset($_POST['page']) ? htmlspecialchars($_POST['page']) : '1';
     $num = isset($_POST['num']) ? htmlspecialchars($_POST['num']) : '6';
     // 1 收藏商家 3用户收藏问答 4 商家收藏问答
     $type = isset($_POST['type']) ? htmlspecialchars($_POST['type']) : '1';
     $limit = ($page - 1) * $num . ',' . $num;
     if ($type == 1) {
         $member_id = $this->session_handle->getsession_userid($member_session_id);
         $model = new Model();
         $sql = "select b.id as merchant_id ,b.header,b.merchant_name,d.name as city_name,c.name as area_name,b.address\r\n\t\t\tfrom " . C('DB_PREFIX') . "collect as a  left join\r\n\t\t\t" . C('DB_PREFIX') . "merchant as b on a.obj_id=b.id\r\n\t\t\tleft join " . C('DB_PREFIX') . "city as c on c.id=b.area_id\r\n\t\t\tleft join " . C('DB_PREFIX') . "city as d on d.id=b.city_id\r\n\t\t\twhere a.member_id={$member_id} and a.type = 1 limit {$limit}";
         $arr = $model->query($sql);
         if ($arr) {
             foreach ($arr as $key => $value) {
                 $arr[$key]['header'] = imgUrl($value['header']);
             }
             $data['list'] = $arr;
             $this->jsonUtils->echo_json_data(0, 'ok', $data);
             exit;
         } else {
             $data['list'] = array();
             $this->jsonUtils->echo_json_msg(0, 'ok', $data);
             exit;
         }
     } elseif ($type == 3 || $type == 4) {
         $member_id = $this->session_handle->getsession_userid($member_session_id, 1);
         $systemid = CommonController::getSystemUserid($member_id['id'], $member_id['type']);
         $model = new Model();
         $sql = "select c.title,c.id as problem_id,d.name as category_name,e.header,b.id as reply_id,b.reply_content,b.laud_count,b.collect_count\r\n\t\t\tfrom " . C('DB_PREFIX') . "collect as a  left join\r\n\t\t\t" . C('DB_PREFIX') . "answer_reply as b on a.obj_id=b.id\r\n\t\t\tleft join " . C('DB_PREFIX') . "system_user as e on e.id=b.reply_id\r\n\t\t\tleft join " . C('DB_PREFIX') . "answer_problem as c on c.id=b.issue_id\r\n\t\t\tleft join " . C('DB_PREFIX') . "answer_category as d on d.id=c.pid\r\n\t\t\twhere a.member_id={$systemid} and a.type = {$type}  order by a.addtime desc limit {$limit}";
         $arr = $model->query($sql);
         if (!$arr) {
             $arr = array();
         } else {
             foreach ($arr as $key => $row) {
                 $arr[$key]['header'] = imgUrl($row['header']);
             }
         }
         $data['list'] = $arr;
         $this->jsonUtils->echo_json_data(0, 'ok', $data);
         exit;
     }
 }
 /**
  * 用户确定需求
  */
 public function confirm_demand()
 {
     $id = (int) $_POST['id'];
     $merchant_id = isset($_POST['merchant_id']) ? htmlspecialchars($_POST['merchant_id']) : '';
     $member_session_id = $_POST['member_session_id'];
     $member_id = $this->session_handle->getsession_userid($member_session_id);
     if (empty($id)) {
         $this->jsonUtils->echo_json_msg(4, '需求ID为空...');
         exit;
     }
     if (empty($merchant_id)) {
         $this->jsonUtils->echo_json_msg(4, '商家ID为空...');
         exit;
     }
     $order = M('order');
     // 需求是否属于这个用户
     $demand = $this->dao->where(array('id' => $id, 'member_id' => $member_id))->find();
     if (!$demand) {
         $this->jsonUtils->echo_json_msg(4, '数据异常1');
         exit;
     }
     if (time() > $demand['expire_time']) {
         $this->jsonUtils->echo_json_msg(4, '已过期');
         exit;
     }
     if (time() > $demand['reach_time']) {
         $this->jsonUtils->echo_json_msg(4, '到店时间已过期');
         exit;
     }
     if ($demand['merchant_id']) {
         $this->jsonUtils->echo_json_msg(4, '已选择商户');
         exit;
     }
     // 检测商家是否有报价
     $bidding = M('MerchantBidding')->where(array('demand_id' => $id, 'merchant_id' => $merchant_id))->find();
     if (!$bidding) {
         $this->jsonUtils->echo_json_msg(4, '数据异常2');
         exit;
     }
     $o_arr = $order->where("sub_id={$id} and member_id={$member_id}")->select();
     if ($o_arr) {
         $this->jsonUtils->echo_json_msg(1, '此需求你已经提交过订单');
         exit;
     }
     // 查询需求
     $arr = $this->dao->query("select id,reach_time  as reach_time ,cart_data,description,pics,publish,member_id,longitude,latitude,cart_id ,merchant_id as demand_status from " . C('DB_PREFIX') . "member_demand  where id={$id}");
     if ($arr) {
         $arr[0]['demand_status'] = $arr[0]['demand_status'] > 0 ? 1 : 0;
         $model = new Model();
         $merchant = M('merchant');
         $mer_arr = $merchant->field("longitude,latitude")->where("id={$merchant_id}")->select();
         $longitude = $arr[0]['longitude'];
         // 用户发布需求的经纬度
         $latitude = $arr[0]['latitude'];
         $demand_id = $arr[0]['id'];
         // 计算商家店铺和用户需求距离
         $arr[0]['distance'] = getDistance($latitude, $longitude, $mer_arr[0]['latitude'], $mer_arr[0]['longitude']);
         // 需求详情项目
         if ($arr[0]['publish'] == 0) {
             $s_arr = $model->query("select b.name,b.id from " . C('DB_PREFIX') . "member_demand_subitems as a left join " . C('DB_PREFIX') . "category as b on a.category_id=b.id  where a.demand_id={$demand_id} ");
         } else {
             $s_arr = $model->query("select b.name,b.id from " . C('DB_PREFIX') . "member_demand_subitems as a left join " . C('DB_PREFIX') . "car_maintain_category as b on a.category_id=b.id  where a.demand_id={$demand_id} ");
         }
         $perlist = array();
         if ($s_arr) {
             // 查询 商家已有的服务 ,商家未有的服务 不允许报价
             // $server_ids = CommonController::getServerListByMer (
             // $merchant_id );
             // $string = implode ( ',', $server_ids );
             // 允许报价 所提示的价格
             // 已报价 bidding
             $arr[0]['merchant_remark'] = M('MerchantBiddingRemark')->where(array('demand_id' => $id))->getField('remark');
             $merchant_remark = empty($arr[0]['merchant_remark']) ? '' : $arr[0]['merchant_remark'];
             $map['demand_id'] = $id;
             // $map ['sub_id'] = array (
             // 'in',
             // $string
             // );
             $map['merchant_id'] = $merchant_id;
             $alert_price = M('MerchantBidding')->where($map)->field('id as bidding_id,price,sub_id as cat_id,out_time as time')->select();
             foreach ($alert_price as $tem) {
                 $price[$tem['cat_id']] = $tem;
             }
             // 区分是报价为0 还是未报价,-1标识未报价
             // foreach ( $server_ids as $tem => $row ) {
             // if (! isset ( $price [$row] )) {
             // $price [$row] = array (
             // 'cat_id' => $row,
             // 'price' => - 1,
             // 'bidding_id' => '-1'
             // );
             // }
             // }
             $total_price = 0;
             $total_time = 0;
             $service_name = array();
             // dump($price);
             foreach ($s_arr as $key => $row) {
                 $perlist[$key]['id'] = $row['id'];
                 $perlist[$key]['name'] = $row['name'];
                 $service_name[] = $row['name'];
                 // if (in_array ( $row ['id'], $server_ids )) {
                 $perlist[$key]['is_server'] = 1;
                 $perlist[$key]['time'] = !isset($price[$row['id']]['time']) ? '-1' : $price[$row['id']]['time'];
                 $perlist[$key]['price'] = !isset($price[$row['id']]['price']) ? '-1' : $price[$row['id']]['price'];
                 $perlist[$key]['bidding_id'] = !isset($price[$row['id']]['bidding_id']) ? '-1' : $price[$row['id']]['bidding_id'];
                 // } else {
                 // $perlist [$key] ['is_server'] = 0;
                 // $perlist [$key] ['price'] = 0;
                 // }
                 if ($perlist[$key]['price'] > 0) {
                     $total_price += $perlist[$key]['price'];
                 }
                 if ($perlist[$key]['price'] > 0) {
                     $total_time += $perlist[$key]['time'];
                 }
             }
         }
         // 拼接过程
         $arr[0]['list'] = $perlist;
         if ($arr[0]['pics']) {
             $json_obj = json_decode($arr[0]['pics'], true);
         } else {
             $json_obj = array();
         }
     } else {
         $this->jsonUtils->echo_json_msg(1, '没有该用户需求...');
         exit;
     }
     $param = json_decode($demand['param'], true);
     $rel['param'] = count($param) > 0 ? $param : array();
     $rel['distance'] = $arr[0]['distance'];
     $rel['pics'] = $json_obj;
     $rel['list'] = $perlist;
     $order_no = time() . rand(1000, 9999);
     $data['order_no'] = $order_no;
     $data['service_name'] = !empty($service_name) ? implode('、', $service_name) : '';
     $data['status'] = 0;
     $data['merchant_id'] = $merchant_id;
     $data['member_id'] = $member_id;
     if ($arr[0]['publish'] == 0) {
         $data['type'] = 1;
         // 项目需求订单
     } else {
         $data['type'] = 3;
         // 保养需求订单
     }
     $data['goods_count'] = 1;
     $data['total_price'] = $total_price;
     $data['unit_price'] = $total_price;
     $data['total_time'] = $total_time;
     $data['sub_id'] = $id;
     $data['sub_data'] = json_encode($rel);
     $data['reach_time'] = $arr[0]['reach_time'];
     $data['cart_id'] = $arr[0]['cart_id'];
     $data['cart_data'] = $arr[0]['cart_data'];
     // dump($arr[0]['cart_data']);
     $data['merchant_remark'] = $merchant_remark;
     $data['member_remark'] = $arr[0]['description'];
     $data['addtime'] = time();
     $result = $order->add($data);
     // echo $order->getLastSql();
     if ($result) {
         // 修改需求 确认订单已被商家完成
         CommonController::order_done($id, $merchant_id);
         $jid = CommonController::getJid($merchant_id, 2);
         //云推送
         $jpush = new \App\Model\JpushModel();
         $jpush->user = 2;
         $jpush->push(3, array($jid), array('order_no' => $order_no));
         $xmpp = new \App\Model\XmppApiModel();
         $xmpp->requestPush(3, array($jid), array('order_no' => $order_no));
         $this->jsonUtils->echo_json_msg(0, 'ok');
         exit;
     } else {
         $this->jsonUtils->echo_json_msg(1, '确认需求错误...');
         exit;
     }
 }
 /**
  * 获取某人动态
  * 公共查看
  */
 public function getSomeoneRecentV2()
 {
     $session_id = isset($_POST['session_id']) ? htmlspecialchars($_POST['session_id']) : '';
     if (!empty($session_id)) {
         $member_id = $this->session_handle->getsession_userid($session_id, 1);
         $systemid = CommonController::getSystemUserid($member_id['id'], $member_id['type']);
     }
     $system_user_id = isset($_POST['system_user_id']) ? (int) htmlspecialchars($_POST['system_user_id']) : '';
     $longitude = isset($_POST['longitude']) ? htmlspecialchars($_POST['longitude']) : '';
     $latitude = isset($_POST['latitude']) ? htmlspecialchars($_POST['latitude']) : '';
     $page = isset($_POST['page']) ? htmlspecialchars($_POST['page']) : '1';
     $num = isset($_POST['num']) ? htmlspecialchars($_POST['num']) : '6';
     if (empty($system_user_id) && empty($systemid)) {
         $this->jsonUtils->echo_json_msg(4, '参数不全');
         exit;
     }
     if (empty($system_user_id) && !empty($systemid)) {
         $system_user_id = $systemid;
     }
     if (!empty($longitude) && !empty($latitude)) {
         $disable = true;
     } else {
         $disable = false;
     }
     $time = time();
     $db = M('AnswerUserRecent');
     $count = $db->where(array('system_user_id' => $system_user_id, 'status' => 0))->count();
     $data = $db->table(C('DB_PREFIX') . "answer_user_recent as a")->join(C('DB_PREFIX') . "system_user as b on b.id = a.system_user_id")->join(C('DB_PREFIX') . "member as c on (c.id = b.sub_id and b.type = 0)")->where(array('a.system_user_id' => $system_user_id, 'a.status' => 0))->field('a.id,a.system_user_id,a.content,a.pics,a.addtime,a.laud_count,a.comment_count,a.longitude,a.latitude,b.name,b.header,b.brand_icon,c.gender')->page($page)->order('addtime desc')->limit($num)->select();
     if ($data) {
         if ($disable) {
             foreach ($data as $key => $row) {
                 $data[$key]['addtime'] = dealtime($row['addtime']);
                 $data[$key]['header'] = imgUrl($row['header']);
                 $data[$key]['gender'] = !empty($row['gender']) ? $row['gender'] : '0';
                 $data[$key]['brand_icon'] = imgUrl($row['brand_icon']);
                 $data[$key]['pics'] = imgUrl(json_decode($row['pics'], true));
                 $data[$key]['distance'] = getDistance($longitude, $latitude, $row['longitude'], $row['latitude']);
                 unset($data[$key]['longitude']);
                 unset($data[$key]['latitude']);
             }
         } else {
             foreach ($data as $key => $row) {
                 $data[$key]['addtime'] = date('Y-m-d H:i:s', $row['addtime']);
                 $data[$key]['header'] = imgUrl($row['header']);
                 $data[$key]['gender'] = !empty($row['gender']) ? $row['gender'] : '0';
                 $data[$key]['brand_icon'] = imgUrl($row['brand_icon']);
                 $data[$key]['pics'] = imgUrl(json_decode($row['pics'], true));
             }
         }
     } else {
         $data = array();
     }
     $arr['count'] = empty($count) ? 0 : $count;
     $arr['list'] = $data;
     $this->jsonUtils->echo_json_data(0, 'ok', $arr);
     exit;
 }