123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace Act\Lib;
- use Dever;
- class Share
- {
- # 获取某个用户在某个图文的分享回流数
- public function getRefluxNum($uid, $id, $type)
- {
- $where['source_uid'] = $uid;
- $where['type'] = $type;
- $where['data_id'] = $id;
- return Dever::db('act/share_reflux')->total($where);
- }
- # 提交分享
- public function submit($uid, $id, $type)
- {
- $where['uid'] = $uid;
- $where['data_id'] = $id;
- $where['type'] = $type;
- $info = Dever::db('act/share')->one($where);
- if (!$info) {
- $where['num'] = 1;
- Dever::db('act/share')->insert($where);
- } else {
- $where['num'] = $info['num'] + 1;
- $where['where_id'] = $info['id'];
- Dever::db('act/share')->update($where);
- }
- return true;
- }
- # 回流
- public function submit_reflux($source_uid, $uid, $id, $type)
- {
- $where['source_uid'] = $source_uid;
- $where['uid'] = $uid;
- if ($where['source_uid'] == $where['uid']) {
- //return false;
- }
- $where['data_id'] = $id;
- $where['type'] = $type;
- $share = Dever::db('act/share')->one($where);
- if ($share) {
- $where['share_id'] = $share['id'];
- $info = Dever::db('act/share_reflux')->one($where);
- if (!$info) {
- Dever::db('act/share_reflux')->insert($where);
- return true;
- }
- }
- return false;
- }
- }
|