1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- namespace Act\Lib;
- use Dever;
- class Watch
- {
- # 获取当前小刊的观看数
- public function get($id, $type = 3)
- {
- $where['type'] = $type;
- $where['data_id'] = $id;
- $where['state'] = 1;
- $info = Dever::db('act/watch')->total($where);
- return $info;
- }
- # 观看
- public function submit($uid, $id, $type = 3)
- {
- $where['uid'] = $uid;
- $where['data_id'] = $id;
- $where['type'] = $type;
- $info = Dever::db('act/watch')->one($where);
- if (!$info) {
- Dever::db('act/watch')->insert($where);
- }
- if ($type == 3) {
- # 更新观看数
- $where = array();
- $where['data_id'] = $id;
- $where['type'] = $type;
- $where['state'] = 1;
- $total = Dever::db('act/watch')->total($where);
- $table = Dever::config('base')->type_table[$type];
- Dever::db($table)->update(array('where_id' => $id, 'num_user' => $total));
- Dever::score($uid, 'submit_watch', '观看直播');
- }
-
- return true;
- }
- }
|