/**
  * 列表
  */
 public function do_index()
 {
     /* 定义变量 */
     $user_id = I('get.user_id');
     $page_num = I('get.page_num');
     $page_num = empty($page_num) || $page_num < 0 ? 1 : $page_num;
     /* 查询数据 */
     $field = 'user.id as user_id,user.nick_name,user.upfile_head,user.sex';
     $where['user_blocked.user_id'] = array('EQ', $user_id);
     $where['user.status'] = array('EQ', 1);
     $where['user.display'] = array('EQ', 1);
     $order = 'user_blocked.create_time desc';
     $list = $this->alias('user_blocked')->field($field)->where($where)->join('__USER__ user on user_blocked.to_user_id = user.id')->order($order)->limit(C('PAGE_NUM'))->page($page_num)->select();
     /* 遍历数据 */
     foreach ($list as $k => $v) {
         /* 读取用户头像 */
         if ($v['upfile_head'] && !strstr($v['upfile_head'], 'http://')) {
             $list[$k]['upfile_head'] = C('APP_URL') . '/Uploads/Images/User/' . $v['upfile_head'];
         }
         $list[$k]['IM_username'] = C('EASEMOB.EASEMOB_PREFIX') . $v['user_id'];
     }
     /* 读取json */
     $list = empty($list) ? array() : $list;
     $jsonInfo['list'] = arr_content_replace($list);
     return $jsonInfo;
 }
 /**
  * 我的兑换 do_personal_index
  */
 public function do_personal_index()
 {
     /* 初始化变量 */
     $user_id = I('get.user_id');
     $page_num = I('get.page_num');
     $page_num = empty($page_num) || $page_num < 0 ? 1 : $page_num;
     /* 查询条件 */
     $field = 'pay_order.trade_no,pay_order.shop_coupon_info,pay_order.shop_id,pay_order.trade_state,shop.title as shop_title';
     $where['pay_order.user_id'] = array('EQ', $user_id);
     $where['pay_order.display'] = array('EQ', 1);
     $order = 'pay_order.id desc';
     /* 查询数据 */
     $list = $this->alias('pay_order')->field($field)->where($where)->join('LEFT JOIN __SHOP__ shop on pay_order.shop_id = shop.id')->order($order)->limit(C('PAGE_NUM'))->page($page_num)->select();
     foreach ($list as $k => $v) {
         $shop_coupon_info = json_decode($v['shop_coupon_info'], true);
         $list[$k]['coupon_id'] = $shop_coupon_info['id'];
         $list[$k]['coupon_title'] = $shop_coupon_info['title'];
         if ($shop_coupon_info['coupon_type'] == 1) {
             $list[$k]['coupon_tag'] = strval(0);
         } else {
             $list[$k]['coupon_tag'] = $shop_coupon_info['coupon_worth'];
         }
         $list[$k]['coupon_content'] = $shop_coupon_info['content'];
         unset($list[$k]['shop_coupon_info']);
         /* 过滤数据 */
         if (!empty($v['coupon_title'])) {
             $list[$k]['coupon_title'] = htmlspecialchars_decode($v['coupon_title']);
         }
     }
     /* 读取json */
     $list = empty($list) ? array() : $list;
     $jsonInfo['list'] = arr_content_replace($list);
     return $jsonInfo;
 }
 /**
  * 话题评论列表 do_index
  */
 public function do_index()
 {
     /* 初始化变量 */
     $topic_id = I('get.topic_id');
     $page_num = I('get.page_num');
     $page_num = empty($page_num) || $page_num < 0 ? 1 : $page_num;
     /* 查询条件 */
     $field = 'topic_comment.id,topic_comment.content,topic_comment.create_time,
               user.id as user_id,user.nick_name,user.upfile_head,
               IFNULL(response_user.id, "") as response_user_id,IFNULL(response_user.nick_name, "") as response_name';
     $where['topic_comment.topic_id'] = array('EQ', $topic_id);
     $where['topic_comment.status'] = array('EQ', 1);
     $where['topic_comment.display'] = array('EQ', 1);
     $order = 'topic_comment.id asc';
     $list = $this->alias('topic_comment')->field($field)->where($where)->join('__USER__ user on topic_comment.user_id = user.id AND user.status = 1  AND user.display = 1')->join('LEFT JOIN __USER__ response_user on (topic_comment.response_user_id = response_user.id AND response_user.status = 1  AND response_user.display = 1)')->order($order)->limit(C('PAGE_NUM'))->page($page_num)->select();
     $list_count = $this->alias('topic_comment')->where($where)->join('__USER__ user on topic_comment.user_id = user.id AND user.status = 1  AND user.display = 1')->count();
     /* 遍历数据 */
     foreach ($list as $k => $v) {
         /* 读取用户头像 */
         if ($v['upfile_head'] && !strstr($v['upfile_head'], 'http://')) {
             $list[$k]['upfile_head'] = C('APP_URL') . '/Uploads/Images/User/' . $v['upfile_head'];
         }
     }
     $jsonInfo['list_count'] = intval($list_count);
     /* 读取json */
     $list = empty($list) ? array() : $list;
     $jsonInfo['list'] = arr_content_replace($list);
     return $jsonInfo;
 }
 /**
  * 点赞列表 do_index
  */
 public function do_index()
 {
     /* 初始化变量 */
     $topic_id = I('get.topic_id');
     $user_id = I('get.user_id');
     $page_num = I('get.page_num');
     $page_num = empty($page_num) || $page_num < 0 ? 1 : $page_num;
     /* 查询条件 */
     $field = 'user.id as user_id,user.upfile_head,user.nick_name,user.sex,user.like_count as user_like_count,0 as attention_relation';
     $where['topic_like.topic_id'] = array('EQ', $topic_id);
     $where['user.status'] = array('EQ', 1);
     $where['user.display'] = array('EQ', 1);
     $order = 'topic_like.create_time desc';
     $list = $this->alias('topic_like')->field($field)->where($where)->join('__USER__ user on topic_like.user_id = user.id')->order($order)->limit(C('PAGE_NUM'))->page($page_num)->select();
     /* 遍历数据 */
     foreach ($list as $k => $v) {
         /* 读取用户头像 */
         if ($v['upfile_head'] && !strstr($v['upfile_head'], 'http://')) {
             $list[$k]['upfile_head'] = C('APP_URL') . '/Uploads/Images/User/' . $v['upfile_head'];
         }
     }
     /* 查询关注状态 */
     if ($user_id) {
         $whereAttentionRelation['user_id'] = array('EQ', $user_id);
         $listAttentionRelation = M('UserAttention')->field('to_user_id,relation')->where($whereAttentionRelation)->select();
         /* 遍历合并数组 */
         foreach ($list as $k => $v) {
             foreach ($listAttentionRelation as $key => $value) {
                 if ($v['user_id'] == $value['to_user_id']) {
                     $list[$k]['attention_relation'] = $value['relation'];
                 }
             }
         }
     }
     /* 读取json */
     $list = empty($list) ? array() : $list;
     $jsonInfo['list'] = arr_content_replace($list);
     return $jsonInfo;
 }
Example #5
0
 /**
  * 话题详情 do_article
  */
 public function do_article()
 {
     /* 初始化变量 */
     $topic_id = I('get.topic_id');
     $user_id = I('get.user_id');
     $user_id = empty($user_id) ? 0 : $user_id;
     /* 判断是否存在缓存 */
     $cache = S('TOPIC_ARTICLE_ID_' . $topic_id);
     if ($cache) {
         $data = $cache;
     } else {
         /* 查询条件 */
         $field = 'topic.upfile,topic.content,topic.province,topic.city,topic.longitude,topic.latitude,topic.comment_count,topic.create_time,
                   user.id as user_id,user.nick_name,user.top_times,user.top_best,user.chat_level,user.sex,user.upfile_head as user_upfile_head,0 as is_be_shielded,user.upfile_head_m as user_upfile_head_m';
         $where['topic.id'] = array('EQ', $topic_id);
         $where['topic.status'] = array('EQ', 1);
         $where['topic.display'] = array('EQ', 1);
         $where['user.status'] = array('EQ', 1);
         $where['user.display'] = array('EQ', 1);
         /* 查询数据 */
         $data = $this->alias('topic')->field($field)->where($where)->join('__USER__ user on topic.user_id = user.id')->find();
         if ($data) {
             /* 读取用户头像 */
             if ($data['user_upfile_head'] && !strstr($data['user_upfile_head'], 'http://')) {
                 $data['user_upfile_head'] = C('APP_URL') . '/Uploads/Images/User/' . $data['user_upfile_head'];
             }
             /* 读取用户头像 */
             if ($data['user_upfile_head_m'] && !strstr($data['user_upfile_head_m'], 'http://')) {
                 $data['user_upfile_head_m'] = C('APP_URL') . '/Uploads/Images/User/' . $data['user_upfile_head_m'];
             }
             /* 读取图片 */
             if ($data['upfile']) {
                 $data['upfile'] = C('APP_URL') . '/Uploads/Images/Topic/' . $data['upfile'];
             }
         }
         /* 设置缓存 */
         S('TOPIC_ARTICLE_ID_' . $topic_id, $data);
     }
     if ($data) {
         /* 查询评论数 */
         $where_comment['id'] = array('EQ', $topic_id);
         $data['comment_count'] = $this->where($where_comment)->getField('comment_count');
         /* 判断用户是否点过赞 */
         $userLikeCount = strval(0);
         if ($user_id) {
             $whereUserLike['user_id'] = array('EQ', $user_id);
             $whereUserLike['topic_id'] = array('EQ', $topic_id);
             $userLikeCount = M('TopicLike')->where($whereUserLike)->count();
         }
         $data['is_like'] = $userLikeCount;
         /* 查询点赞总数 */
         $where_like_count['id'] = array('EQ', $topic_id);
         $like_count = $this->where($where_like_count)->getField('like_count');
         $data['like_count'] = $like_count;
         /* 查询点赞 */
         $fieldLike = 'topic_like.user_id,user.upfile_head,user.upfile_head_m';
         $whereLike['topic_like.topic_id'] = array('EQ', $topic_id);
         $whereLike['user.status'] = array('EQ', 1);
         $whereLike['user.display'] = array('EQ', 1);
         $orderLike = 'topic_like.create_time desc';
         $listLike = M('TopicLike')->alias('topic_like')->field($fieldLike)->where($whereLike)->join('__USER__ user on topic_like.user_id = user.id')->order($orderLike)->limit(30)->select();
         foreach ($listLike as $k => $v) {
             if ($v['upfile_head'] && !strstr($v['upfile_head'], 'http://')) {
                 $listLike[$k]['upfile_head'] = C('APP_URL') . '/Uploads/Images/User/' . $v['upfile_head'];
             }
             if ($v['upfile_head_m'] && !strstr($v['upfile_head_m'], 'http://')) {
                 $listLike[$k]['upfile_head_m'] = C('APP_URL') . '/Uploads/Images/User/' . $v['upfile_head_m'];
             }
         }
         $data['list_like'] = $listLike;
         /* 查询关注状态 */
         if ($user_id) {
             $whereAttentionRelation['user_id'] = array('EQ', $user_id);
             $whereAttentionRelation['to_user_id'] = array('EQ', $data['user_id']);
             $userAttentionRelation = M('UserAttention')->where($whereAttentionRelation)->getField('relation');
         }
         $userAttentionRelation = empty($userAttentionRelation) ? strval(0) : $userAttentionRelation;
         $data['attention_relation'] = $userAttentionRelation;
         /* 查询是否被屏蔽 */
         if ($user_id) {
             $where_is_be_shielded['user_id'] = array('EQ', $data['user_id']);
             $where_is_be_shielded['to_user_id'] = array('EQ', $user_id);
             $count_is_be_shielded = M('UserBlocked')->where($where_is_be_shielded)->count();
             $data['is_be_shielded'] = $count_is_be_shielded;
         }
     }
     $return_data['data'] = arr_content_replace($data);
     /* 读取json */
     return $return_data;
 }
Example #6
0
 /**
  * 商家详情 do_article
  */
 public function do_article()
 {
     /* 初始化变量 */
     $shop_id = I('get.shop_id');
     $user_id = I('get.user_id');
     $user_id = empty($user_id) ? 0 : $user_id;
     /* 判断是否存在缓存 */
     $cache = S('SHOP_ARTICLE_ID_' . $shop_id);
     if ($cache) {
         $data = $cache;
     } else {
         /* 查询条件 */
         $field = 'title,address,longitude,latitude,telephone,per_capita,upfile,upfile_list';
         $where['id'] = array('EQ', $shop_id);
         $where['status'] = array('EQ', 1);
         $where['display'] = array('EQ', 1);
         /* 查询数据 */
         $data = $this->alias('topic')->field($field)->where($where)->find();
         if ($data) {
             /* 过滤数据 */
             $data['title'] = htmlspecialchars_decode($data['title']);
             /* 读取图片 */
             if ($data['upfile']) {
                 $data['upfile'] = C('APP_URL') . '/Uploads/Images/Shop/' . $data['upfile'];
             }
             $data['upfile_album'] = array();
             if ($data['upfile_list']) {
                 foreach (explode(',', $data['upfile_list']) as $v) {
                     $data['upfile_album'][] = C('APP_URL') . '/Uploads/Images/Shop/' . $v;
                 }
             }
             unset($data['upfile_list']);
         }
         /* 设置缓存 */
         S('SHOP_ARTICLE_ID_' . $shop_id, $data, C('CACHE_TIME'));
     }
     if ($data) {
         /* 查询优惠劵 */
         $fieldCoupon = 'id as coupon_id,title as coupon_title,coupon_type,coupon_worth,content as coupon_content,like_consume_count';
         $whereCoupon['shop_id'] = array('EQ', $shop_id);
         $whereCoupon['status'] = array('EQ', 1);
         $whereCoupon['display'] = array('EQ', 1);
         $orderCoupon = 'coupon_type asc,coupon_worth asc,id desc';
         $listCoupon = M('ShopCoupon')->field($fieldCoupon)->where($whereCoupon)->order($orderCoupon)->limit(8)->select();
         foreach ($listCoupon as $k => $v) {
             /* 过滤数据 */
             $listCoupon[$k]['coupon_title'] = htmlspecialchars_decode($v['coupon_title']);
             $listCoupon[$k]['coupon_content'] = htmlspecialchars_decode($v['coupon_content']);
             if ($v['coupon_type'] == 1) {
                 $listCoupon[$k]['coupon_tag'] = strval(0);
             } else {
                 $listCoupon[$k]['coupon_tag'] = $v['coupon_worth'];
             }
             unset($listCoupon[$k]['coupon_type']);
             unset($listCoupon[$k]['coupon_worth']);
         }
         $data['list_coupon'] = $listCoupon;
         /* 判断用户是否点过我想去和我去过 */
         if ($user_id) {
             $whereUserLike['shop_id'] = array('EQ', $shop_id);
             $whereUserLike['user_id'] = array('EQ', $user_id);
             $listUserLike = M('ShopUserWent')->where($whereUserLike)->getField('content', true);
         }
         $data['is_want'] = in_array('想去', $listUserLike) ? strval(1) : strval(0);
         //我想去
         $data['is_been'] = in_array('去过', $listUserLike) ? strval(1) : strval(0);
         //我去过
         /* 查询去向的数量 */
         $whereUserLikeCount['shop_id'] = array('IN', $shop_id);
         $whereUserLikeCount['user.status'] = array('EQ', 1);
         $whereUserLikeCount['user.display'] = array('EQ', 1);
         $listUserLikeCount = M('ShopUserWent')->alias('shop_user_went')->where($whereUserLikeCount)->join('__USER__ user on shop_user_went.user_id = user.id')->count();
         $data['want_count'] = $listUserLikeCount;
     }
     $return_data['data'] = arr_content_replace($data);
     /* 读取json */
     return $return_data;
 }
 /**
  * 去向通知列表 do_index_notice
  */
 public function do_index_notice($user_id = NULL)
 {
     /* 初始化变量 */
     $page_num = I('get.page_num');
     $page_num = empty($page_num) || $page_num < 0 ? 1 : $page_num;
     /* 获取关注用户 */
     $where_user_create_time['id'] = array('EQ', $user_id);
     $user_create_time = M('User')->where($where_user_create_time)->getField('create_time');
     $where_attention['user_id'] = array('EQ', $user_id);
     $attention_user_id = M('UserAttention')->where($where_attention)->getField('to_user_id', true);
     $attention_user_id = implode(',', $attention_user_id);
     if ($attention_user_id) {
         $field = 'user.id as user_id,user.upfile_head as user_upfile_head,user.nick_name,user.sex,
                   shop_user_went.shop_id,shop_user_went.content,shop_user_went.create_time,
                   shop.title as shop_title,shop.upfile as shop_upfile';
         $where['shop_user_went.user_id'] = array('IN', $attention_user_id);
         $where['shop_user_went.create_time'] = array('GT', $user_create_time);
         $where['user.status'] = array('EQ', 1);
         $where['user.display'] = array('EQ', 1);
         $where['shop.status'] = array('EQ', 1);
         $where['shop.display'] = array('EQ', 1);
         $order = 'shop_user_went.create_time desc';
         $list = $this->alias('shop_user_went')->field($field)->where($where)->join('__USER__ user on shop_user_went.user_id = user.id')->join('__SHOP__ shop on shop.id = shop_user_went.shop_id')->order($order)->limit(C('PAGE_NUM'))->page($page_num)->select();
         /* 遍历数据 */
         foreach ($list as $k => $v) {
             /* 读取用户头像 */
             if ($v['user_upfile_head'] && !strstr($v['user_upfile_head'], 'http://')) {
                 $list[$k]['user_upfile_head'] = C('APP_URL') . '/Uploads/Images/User/' . $v['user_upfile_head'];
             }
             /* 读取商家头像 */
             if ($v['shop_upfile']) {
                 $list[$k]['shop_upfile'] = C('APP_URL') . '/Uploads/Images/Shop/' . $v['shop_upfile'];
             }
             /* 过滤数据 */
             $list[$k]['shop_title'] = htmlspecialchars_decode($v['shop_title']);
         }
     }
     /* 读取json */
     $list = empty($list) ? array() : $list;
     $jsonInfo['list'] = arr_content_replace($list);
     return $jsonInfo;
 }
 /**
  * 获取我的上榜记录
  */
 public function do_list()
 {
     $user_id = I('get.user_id');
     $model = M('TopicLog');
     $where['user_id'] = array('EQ', $user_id);
     $order = 'id desc,type desc';
     $list = $model->where($where)->order($order)->select();
     $_list = array();
     if (!empty($list)) {
         /* 遍历每个数组 */
         foreach ($list as $v) {
             $v['create_time'] = date("Y-m-d H:i:s", $v['create_time']);
             $_list[] = $v;
         }
     }
     /* 读取json */
     $_list = empty($_list) ? array() : $_list;
     $jsonInfo['list'] = arr_content_replace($_list);
     return $jsonInfo;
 }
Example #9
0
function arr_content_replace($array)
{
    if (is_array($array)) {
        foreach ($array as $k => $v) {
            $array[$k] = arr_content_replace($array[$k]);
        }
    } else {
        $array = str_filter($array);
    }
    return $array;
}