Invite.php 1.7 KB

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