|
@@ -6,7 +6,7 @@ use Dever;
|
|
|
|
|
|
class Collection
|
|
|
{
|
|
|
- # 保存信息
|
|
|
+ # 保存信息 收费
|
|
|
public function up($ticket_id, $uid, $source_uid, $info_id, $num = 1)
|
|
|
{
|
|
|
$ticket = Dever::db('user/ticket')->one($ticket_id);
|
|
@@ -14,32 +14,44 @@ class Collection
|
|
|
return false;
|
|
|
}
|
|
|
if ($ticket['num'] > 0 && $ticket['num'] >= $num) {
|
|
|
- $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;
|
|
|
- $where['source_uid'] = $source_uid;
|
|
|
- $state = Dever::db('user/collection')->insert($where);
|
|
|
- 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));
|
|
|
+
|
|
|
+ $state = $this->upAct($uid, $info_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, $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;
|
|
|
+ }
|
|
|
+ if ($ticket_id) {
|
|
|
+ $where['ticket_id'] = $ticket_id;
|
|
|
+ }
|
|
|
+ return Dever::db('user/collection')->insert($where);
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
# 获取信息
|