one($ticket_id); if (!$ticket) { return false; } if ($ticket['num'] > 0 && $ticket['num'] >= $num) { $state = $this->upAct($uid, $info_id, $cate_id, $num, $source_uid, $ticket_id); if ($state) { Dever::score($uid, 'use_ticket', '使用门票', false, false, false, 'collection', $info_id); if ($source_uid && $source_uid != $uid) { # 添加积分 Dever::score($source_uid, 'give_ticket', '赠送门票', false, false, false, 'collection', $info_id); } # 减少门票 Dever::db('user/ticket')->des(array('where_id' => $ticket_id, 'num' => $num)); } return true; } else { return false; } } # 保存信息 免费 public function upAct($uid, $info_id, $cate_id, $num = 1, $source_uid = false, $ticket_id = false) { $where['uid'] = $uid; $where['info_id'] = $info_id; //$where['ticket_id'] = $ticket_id; $info = Dever::db('user/collection')->one($where); if (!$info) { $where['num'] = $num; if ($source_uid) { $where['source_uid'] = $source_uid; # 更新邀请榜单 Dever::load('collection/lib/ranking')->up($source_uid, $info_id, 3, 1); } if ($ticket_id) { $where['ticket_id'] = $ticket_id; } $where['cate_id'] = $cate_id; return Dever::db('user/collection')->insert($where); } return false; } # 获取信息 public function check($uid, $info_id) { $where['uid'] = $uid; $where['info_id'] = $info_id; $info = Dever::db('user/collection')->one($where); return $info; } # 获取用户拥有的合集 public function getList($uid, $cate_id = false) { $where['uid'] = $uid; if ($cate_id) { $where['cate_id'] = $cate_id; } $info = Dever::db('user/collection')->getAll($where); return $info; } # 获取用户拥有的合集分类 public function getCateList($uid) { $where['uid'] = $uid; $info = Dever::db('user/collection')->getCateAll($where); return $info; } # 获取某个合集的拥有数量 public function getNum($info_id) { $where['info_id'] = $info_id; $info = Dever::db('user/collection')->num($where); if (!$info) { $info['num'] = 0; } return $info['num']; } }