public function __construct()
 {
     parent::__construct();
     require_once APP_PATH . "SDK/Payment/alipay_server/alipay.config.php";
     var_dump(GetSmallAvatar(1));
     $this->alipay_config = $alipay_config;
 }
Exemplo n.º 2
0
 public function follow_get()
 {
     $follow = M("follow");
     $uid = I("get.uid", 0, 'intval');
     if ($uid <= 0) {
         $this->check_token();
         $uid = $this->uid;
     }
     $pageCount = 1;
     //构造sql
     //互相关注is_mutual
     $options = array('alias' => 'f', 'join' => array("LEFT JOIN follow f2 ON f2.to_member_id = f.from_member_id AND f2.from_member_id = f.to_member_id", "LEFT JOIN pillow_talk_time t ON ((t.member_id_s = f.to_member_id AND t.member_id_b = f.from_member_id) OR(t.member_id_b = f.to_member_id AND t.member_id_s = f.from_member_id))", "INNER JOIN member m on f.to_member_id = m.id"), 'where' => array("f.from_member_id" => $uid), 'field' => "UNIX_TIMESTAMP(f.add_time) as add_time,m.id AS to_member_id,m.id AS member_id,\r\n\t\t\tm.nickname AS from_member_nickname,m.nickname AS name,\r\n\t\t\tmax(t.time) AS last_pillow_talk_time, IF(f2.id IS NOT NULL, '1', '0') as is_mutual", 'order' => "is_mutual desc, t.time desc", 'group' => "f.id");
     $pageNum = intval(I("get.page", 1));
     if ($pageNum) {
         $follow->options = $options;
         unset($follow->options['group']);
         unset($follow->options['field']);
         $count = $follow->count();
         $_GET["p"] = max(1, $pageNum);
         $Page = new \Think\Page($count, $this->follow_page_size);
         $follow->limit($Page->firstRow . ',' . $Page->listRows);
         $pageCount = ceil($Page->totalRows / $Page->listRows);
     }
     $data = $follow->select($options);
     foreach ($data as &$value) {
         $value["avatar"] = GetSmallAvatar($value['to_member_id']);
         //$value["community"] = D("Community")->communities($value["to_member_id"]);
     }
     $data = array('list' => $data, 'count' => count($data), 'next_page' => null);
     if ($pageCount > 1 && $pageNum < $pageCount) {
         $data['next_page'] = $this->url("/v1/follow/page/" . ++$pageNum);
     }
     $this->success($data);
 }
Exemplo n.º 3
0
 /**
  * 获取群成员列表
  * @param $gid
  * @param $page_num
  * @param $page_size
  * @return array
  */
 public function getMembers($gid, $page_num = 1, $page_size = 10)
 {
     $group_member_model = M('group_member');
     $group_member_list = $group_member_model->alias('gm')->field('gm.member_id, m.nickname')->join('left join member m on m.id = gm.member_id')->where(array('group_id' => $gid))->order('m.nickname asc')->select();
     foreach ($group_member_list as &$member) {
         $member['avatar'] = GetSmallAvatar($member['member_id']);
     }
     return $group_member_list;
 }
Exemplo n.º 4
0
 public function detail($id)
 {
     $this_user = $this->where(array('id' => $id))->find();
     $this_apps = M('member_bind')->field('type, keyid, info')->where(array('uid' => $id))->select();
     foreach ($this_apps as &$value) {
         $value['info'] = json_decode($value['info']);
     }
     $this_user['avator'] = GetSmallAvatar($id);
     $this_user['apps'] = $this_apps;
     return $this->filter($this_user);
 }
Exemplo n.º 5
0
 /**
  * 获取发给某用户的未读信息
  * @param $uid
  * @param string|null $type
  * @param string|int|null $from_id
  * @param int $page_num
  * @param int $page_size
  * @return array
  */
 public function get_no_read($uid, $type = null, $from_id = null, $start_time = null, $page_num = 1, $page_size = 10)
 {
     $group_in = M('group_member')->where(array('member_id' => $uid))->getField('group_id', true);
     $single_condition = array('m.to_id' => $uid, 'm.is_to_group' => 0, 'm.is_read' => 0, 'm.type' => 1);
     $group_condition = array('m.to_id' => !empty($group_in) ? array('in', $group_in) : 'no_id', 'm.is_to_group' => 1, 'm.type' => 1, 'm.from_member_id' => array('neq', $uid), '_string' => 'm.add_time > gm.last_read_time or gm.last_read_time is null');
     $condition = null;
     if ($from_id) {
         $single_condition['m.from_member_id'] = array('eq', $from_id);
         $group_condition['m.to_id'] = array('eq', $from_id);
     }
     if ($type == 'single') {
         //获取用户发来的未读消息,或用户没有加入任何群
         $condition = $single_condition;
     } elseif ($type == 'group') {
         $condition = $group_condition;
     } else {
         $condition = array($single_condition, $group_condition, '_logic' => 'OR');
     }
     if (!empty($start_time)) {
         $condition = array($condition, 'm.add_time' => array('gt', $start_time));
     }
     $this->alias('m')->join("left join group_member gm on gm.group_id = m.to_id and gm.member_id = '{$uid}' and m.is_to_group = 1")->join('left join member mb on mb.id = m.from_member_id')->join('left join `group` grp on grp.id = m.to_id and m.is_to_group = 1')->where($condition);
     if ($page_num) {
         $this->page($page_num, $page_size);
     }
     $no_read = $this->field("m.id, m.mime_type, if(m.is_to_group = 1, '1','0') as is_to_group, if(m.is_read = 1, '1', '0') as is_read,\r\n        m.content,\r\n        m.from_member_id, m.to_id, m.add_time,\r\n        mb.nickname as name,\r\n        grp.name as group_name,\r\n        grp.image as group_image\r\n        ")->order('add_time desc')->select();
     //获取相关用户和群的信息
     foreach ($no_read as &$msg) {
         $from_member = M('member')->find($msg['from_member_id']);
         if (!empty($from_member)) {
             $from_member['avatar'] = GetSmallAvatar($from_member['id']);
         }
         $msg['from_member'] = $from_member;
     }
     return $no_read;
 }
Exemplo n.º 6
0
 public function get_by_school($role, $demand_type, $province_id, $university_id, $college_id, $page_num = 1)
 {
     $condition = array('role_type' => $role, 'city' => $province_id, 'university' => $university_id, 'college' => $college_id, 'demand_type' => $demand_type);
     $condition['status'] = array('neq', -1);
     // if ($province_id == 0) {
     // unset($condition['city']);
     // unset($condition['university']);
     // unset($condition['college']);
     // } else {
     // $this_city = M('school')->where(array('id' => $province_id))->find();
     // if (!$this_city) {
     // return 3008;
     // }
     // if ($university_id == 0) {
     // unset($condition['university']);
     // unset($condition['college']);
     // } else {
     // $this_university = M('school')->where(array('id' =>
     // $university_id))->find();
     // if (!$this_university) {
     // return 3009;
     // }
     // if ($college_id == 0) {
     // unset($condition['college']);
     // } else {
     // $this_college = M('school')->where(array('id' =>
     // $college_id))->find();
     // if (!$this_college) {
     // return 3010;
     // }
     // }
     // }
     // }
     if (empty($province_id)) {
         unset($condition['city']);
     } else {
         $this_city = M('school')->where(array('id' => $province_id))->find();
         if (!$this_city) {
             return 3008;
         }
     }
     if (empty($university_id)) {
         unset($condition['university']);
     } else {
         $this_university = M('school')->where(array('id' => $university_id))->find();
         if (!$this_university) {
             return 3009;
         }
     }
     if ($college_id == 0) {
         unset($condition['college']);
     } else {
         $this_college = M('school')->where(array('id' => $college_id))->find();
         if (!$this_college) {
             return 3010;
         }
     }
     if (!in_array($role, array(0, 1, 2))) {
         return 3027;
     }
     if ($role == 0) {
         unset($condition['role_type']);
     }
     if (!in_array($demand_type, array(0, 1, 2, 3, 4))) {
         return 3012;
     }
     if ($demand_type == 0) {
         unset($condition['demand_type']);
     }
     $page_num = $page_num == 0 ? 1 : $page_num;
     $_GET["p"] = $page_num;
     $options = array('where' => $condition);
     $demand = M('demand');
     $demand->options = $options;
     $count = $demand->count();
     $page = new \Think\Page($count, $this->page_size);
     $options = array('where' => $condition, 'order' => 'id desc');
     $data = $demand->limit($page->firstRow . ',' . $page->listRows)->select($options);
     foreach ($data as &$demand) {
         $demand['city_string'] = M('school')->getFieldById($demand['city'], 'title_fix');
         $demand['university_string'] = M('school')->getFieldById($demand['university'], 'title_fix');
         $demand['college_string'] = M('school')->getFieldById($demand['college'], 'title_fix');
         $demand['major_string'] = M('school')->getFieldById($demand['major'], 'title_fix');
         $demand['member'] = M('member')->where(array('id' => $demand['member_id']))->find();
         $demand['avator'] = GetSmallAvatar($demand['member_id']);
         //备注
         $profes_type = $demand['profes_type'];
         if ($profes_type == 1) {
             $demand['memo'] = '非统考 ' . $demand['university_string'] . ' ' . $demand['college_string'] . ' ' . $demand['major_string'];
         } elseif ($profes_type == 2) {
             $demand['memo'] = '统考 ' . $demand['major_string'];
         } elseif ($profes_type == 3) {
             $demand['memo'] = '公共课';
         }
     }
     $page_count = ceil($page->totalRows / $page->listRows);
     $data = array('list' => $data, 'count' => count($data), 'next_page' => null);
     if ($page_count > 1 && $page_num < $page_count) {
         $data['next_page'] = $this->url('/v1/demands/by/school/role/' . $role . '/type/' . $demand_type . '/province/' . $province_id . '/university/' . $university_id . '/college/' . $college_id . '/page/' . ++$page_num);
     }
     return $data;
 }
Exemplo n.º 7
0
 public function talk_mslist_get()
 {
     $page = intval(I('get.page'));
     $page = empty($page) ? 1 : $page;
     $mp = M("member_post");
     $lwhere = array("mp.pid" => 0, "mp.status" => array("neq", "-1"));
     $lwhere['_string'] = " m.is_vip_order>0 ";
     //提交了community_id(member_post字段community_id,实际为school的id)则只查询指定圈子的说说
     $school_id = $this->get_request_data('community_id');
     if ($school_id) {
         $lwhere['s.id'] = $school_id;
     }
     $options = array("alias" => "mp", "where" => $lwhere, "join" => array("inner join member m on m.id = mp.member_id and m.status = 1", "left join community c on c.id = mp.community_id", "left join school s on s.id = c.table_id and c.table_type = 'school'"), "field" => "mp.*, if(s.group_member_id != 0 and s.group_member_id = mp.member_id, '1', '0') as is_com_owner", "order" => "mp.time_announcement desc ,mp.time_top desc,mp.time_hot desc,mp.add_time desc");
     $_GET["p"] = $page;
     $mp->options = $options;
     $total = $mp->count();
     $pageCount = ceil($total / $this->pageSize);
     if ($pageCount < $_GET['p']) {
         $_GET['p'] = $pageCount;
     }
     $pageObj = new \Think\Page($total, $this->pageSize);
     $options['limit'] = $pageObj->firstRow . ',' . $pageObj->listRows;
     $data = $mp->select($options);
     // print_r($mp->_sql());
     foreach ($data as &$talk) {
         // 附件相关
         $att = M('attachments');
         $att = $att->where(array('table' => "member_post", 'table_id' => $talk['id'], 'status' => 1))->field('sha1')->select();
         foreach ($att as &$a) {
             $a = GetImage($a['sha1']);
         }
         $talk['attachments'] = $att;
         $talk["community"] = D("Community")->getcommunityInfo($talk["community_id"]);
         $talk["avatar"] = GetSmallAvatar($talk['member_id']);
         $c_where = array('mp.pid' => $talk["id"], 'mp.status' => 1);
         $talk['is_hot'] = $talk['time_hot'] > 0 ? 1 : 0;
         $talk['is_top'] = $talk['time_top'] > 0 ? 1 : 0;
         $talk['is_announcement'] = $talk['time_announcement'] > 0 ? 1 : 0;
         //如果在登陆状态,需要查询该用户是否赞过该说说
         if ($this->uid) {
             $is_praised = M('praise')->where(array('table_name' => 'member_post', 'member_id' => $this->uid, 'catid' => $talk['id'], 'status' => '1'))->count() ? '1' : '0';
             $talk['is_praised'] = $is_praised;
         }
         // if ($this->uid && $this->uid != $talk['member_id']) {
         // $_c_where = array();
         // $_c_where['mp.hide'] = 0;
         // $_c_where["mp.member_id"] = $this->uid;
         // $_c_where["_logic"] = "or";
         // $c_where["_complex"] = $_c_where;
         // } else {
         // $c_where['mp.hide'] = 0;
         // }
         // 回复相关
         // $comment = $mp
         // ->alias('mp')
         // ->join("left join member m on m.id=mp.member_id")
         // ->join("left join member_post_message mpm on mpm.new_id=mp.id and
         // mpm.type=2")
         // ->field("mp.*")
         // ->where($c_where)
         // ->order('mp.add_time desc')
         // ->select();
         // dump($mp->_sql());
         // foreach ($comment as &$c) {
         // $c['avatar'] = GetSmallAvatar($c['member_id']);
         // if ($c['type'] >= 2 && $c['to_member_id'] != $talk['member_id'])
         // {
         // $c['to'] = $c['to_member_id'];
         // } else {
         // $c['to'] = null;
         // }
         // unset($c['type']);
         // unset($c['to_member_id']);
         // }
         // $talk["comment"] = $comment;
     }
     $data = array('list' => $data, 'count' => $total, 'next_page' => null);
     if ($pageCount > 1 && $page < $pageCount) {
         $data['next_page'] = $this->url('/v1/talks/list/master/page/' . ++$page);
     }
     $this->success($data);
 }
Exemplo n.º 8
0
 /**
  * 获取会员token(客户端)
  */
 public function token_post()
 {
     $auth = $this->get_request_data();
     // $auth['passwordCredentials']=array('username'=>'*****@*****.**','password'=>0);
     if ($auth && count($auth)) {
         $user = false;
         // 使用密码凭据登陆
         if (array_key_exists('passwordCredentials', $auth)) {
             // 凭据数据
             $user = $this->___passwordCredentials($auth['passwordCredentials']);
         } else {
             if (array_key_exists('qqCredentials', $auth)) {
                 // 凭据数据
                 $user = $this->__credentials($auth['qqCredentials'], 'Qq');
             } else {
                 if (array_key_exists("weiboCredentials", $auth)) {
                     $user = $this->__credentials($auth['weiboCredentials'], 'Weibo');
                 } else {
                     if (array_key_exists("weixinCredentials", $auth)) {
                         $user = $this->__credentials($auth['weixinCredentials'], 'weixin');
                     }
                 }
             }
         }
         if ($user) {
             $user['avatar'] = GetSmallAvatar($user['id']);
             $this->return_user_info($user);
         }
     }
     // 无效请求
     $this->error(1001);
 }
 /**
  * 获取好友列表
  */
 public function friend_list_get()
 {
     $follow_model = M('Follow');
     $uid = I("get.uid", 0, 'intval');
     if ($uid <= 0) {
         $this->check_token();
         $uid = $this->uid;
     }
     //构造sql
     //互相关注is_mutual
     $options = array('alias' => 'f', 'join' => array("LEFT JOIN follow f2 ON f2.to_member_id = f.from_member_id AND f2.from_member_id = f.to_member_id", "INNER JOIN member m on f.to_member_id = m.id"), 'where' => array("f.from_member_id" => $uid), 'field' => "UNIX_TIMESTAMP(f.add_time) as add_time,m.id AS member_id,m.nickname, IF(f2.id IS NOT NULL, '1', '0') as is_mutual", 'order' => "nickname desc");
     $page_num = I("get.page", 1, 'intval');
     $page_size = I('get.ps', 20, 'intval');
     $follow_model->options = $options;
     unset($follow_model->options['group']);
     unset($follow_model->options['field']);
     $total_rows = $follow_model->count();
     $total_pages = 1;
     if ($page_num) {
         $follow_model->page($page_num, $page_size);
         $total_pages = ceil($total_rows / $page_size);
     }
     $data = $follow_model->select($options);
     foreach ($data as &$value) {
         $value["avatar"] = GetSmallAvatar($value['to_member_id']);
         //$value["community"] = D("Community")->communities($value["to_member_id"]);
     }
     $data = array('list' => $data, 'count' => count($data), 'total_pages' => $total_pages, 'total_rows' => $total_rows, 'next_page' => null);
     if ($total_pages > 1 && $page_num < $total_pages) {
         $data['next_page'] = $this->url("/v1/follow/page/" . ($page_num + 1));
     }
     $this->success($data);
 }