Invite.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace Act\Lib;
  3. use Dever;
  4. class Invite
  5. {
  6. # 获取小刊的邀请排行
  7. public function getList($uid, $id, $type = 4, $num = false)
  8. {
  9. $key = 'invite_' . $uid . '_' . $type . '_' . $id;
  10. $data = Dever::cache($key);
  11. if (!$data) {
  12. $where['source_uid'] = $uid;
  13. $where['type'] = $type;
  14. $where['data_id'] = $id;
  15. if ($num > 0) {
  16. $where['page'] = array(6, 'list');
  17. }
  18. $where['avatar'] = 'null';
  19. $data = Dever::db('act/invite')->getAll($where);
  20. if ($data) {
  21. Dever::cache($key, $data, 900);
  22. }
  23. }
  24. /*
  25. if ($data) {
  26. foreach ($data as $k => $v) {
  27. $user = Dever::load('passport/api')->info($v['uid']);
  28. $data[$k]['username'] = $user['username'];
  29. $data[$k]['avatar'] = $user['avatar'];
  30. }
  31. }
  32. */
  33. return $data;
  34. }
  35. # 获取小刊的邀请数量
  36. public function getTotal($uid, $id, $type = 4)
  37. {
  38. $where['source_uid'] = $uid;
  39. $where['type'] = $type;
  40. $where['data_id'] = $id;
  41. $data = Dever::db('act/invite')->total($where);
  42. return $data;
  43. }
  44. public function submit($source_uid, $uid, $id, $type = 4)
  45. {
  46. $where['source_uid'] = $source_uid;
  47. $where['uid'] = $uid;
  48. $where['data_id'] = $id;
  49. $where['type'] = $type;
  50. $table = 'act/invite';
  51. $info = Dever::db($table)->one($where);
  52. if (!$info) {
  53. Dever::db($table)->insert($where);
  54. }
  55. return true;
  56. }
  57. }