Share.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Act\Lib;
  3. use Dever;
  4. class Share
  5. {
  6. # 获取某个用户在某个图文的分享回流数
  7. public function getRefluxNum($uid, $id, $type)
  8. {
  9. $where['source_uid'] = $uid;
  10. $where['type'] = $type;
  11. $where['data_id'] = $id;
  12. return Dever::db('act/share_reflux')->total($where);
  13. }
  14. # 提交分享
  15. public function submit($uid, $id, $type)
  16. {
  17. $where['uid'] = $uid;
  18. $where['data_id'] = $id;
  19. $where['type'] = $type;
  20. $info = Dever::db('act/share')->one($where);
  21. if (!$info) {
  22. $where['num'] = 1;
  23. Dever::db('act/share')->insert($where);
  24. } else {
  25. $where['num'] = $info['num'] + 1;
  26. $where['where_id'] = $info['id'];
  27. Dever::db('act/share')->update($where);
  28. }
  29. return true;
  30. }
  31. # 回流
  32. public function submit_reflux($source_uid, $uid, $id, $type)
  33. {
  34. $where['source_uid'] = $source_uid;
  35. $where['uid'] = $uid;
  36. $where['data_id'] = $id;
  37. $where['type'] = $type;
  38. $info = Dever::db('act/share_reflux')->one($where);
  39. if (!$info) {
  40. Dever::db('act/share_reflux')->insert($where);
  41. return true;
  42. }
  43. return false;
  44. }
  45. }