Share.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. if ($where['source_uid'] == $where['uid']) {
  37. //return false;
  38. }
  39. $where['data_id'] = $id;
  40. $where['type'] = $type;
  41. $share = Dever::db('act/share')->one($where);
  42. if ($share) {
  43. $where['share_id'] = $share['id'];
  44. $info = Dever::db('act/share_reflux')->one($where);
  45. if (!$info) {
  46. Dever::db('act/share_reflux')->insert($where);
  47. return true;
  48. }
  49. }
  50. return false;
  51. }
  52. }