Invite.php 1.4 KB

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