MatchLike.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. /**
  5. * 划卡喜欢记录模型
  6. */
  7. class MatchLike extends Model
  8. {
  9. // 开启自动写入时间戳字段
  10. protected $autoWriteTimestamp = 'int';
  11. // 定义时间戳字段名
  12. protected $createTime = 'createtime';
  13. /**
  14. * 获取喜欢列表
  15. */
  16. public function getVoiceUserList($user_id,$pageStart=1,$pageNum=10) {
  17. $where = [];
  18. $where["a.fans_id"] = $user_id;
  19. $list = $this->alias("a")
  20. ->field("a.id,a.user_id,a.fans_id,u.nickname,u.avatar,v.voice,v.voice_time,t.name as type_name")
  21. ->join("hx_user u","u.id = a.user_id","left")
  22. ->join("hx_match_voice v","v.user_id = a.user_id","left")
  23. ->join("hx_match_type t","t.id = v.type_id","left")
  24. ->where($where)
  25. ->limit($pageStart,$pageNum)
  26. ->select();
  27. if(!$list) return [];
  28. foreach($list as $k => &$v) {
  29. $v["voice"] || $v["voice"] = "";
  30. $v["voice_time"] || $v["voice_time"] = 0;
  31. $v["type_name"] || $v["type_name"] = "";
  32. }
  33. return $list;
  34. }
  35. /**
  36. * 获取喜欢列表
  37. */
  38. public function getVoiceFansList($user_id,$pageStart=1,$pageNum=10) {
  39. $where = [];
  40. $where["a.user_id"] = $user_id;
  41. $list = $this->alias("a")
  42. ->field("a.id,a.fans_id as user_id,u.nickname,u.avatar,v.voice,v.voice_time,t.name as type_name")
  43. ->join("hx_user u","u.id = a.fans_id","left")
  44. ->join("hx_match_voice v","v.user_id = a.fans_id","left")
  45. ->join("hx_match_type t","t.id = v.type_id","left")
  46. ->where($where)
  47. ->limit($pageStart,$pageNum)
  48. ->select();
  49. if(!$list) return [];
  50. foreach($list as $k => &$v) {
  51. $v["voice"] || $v["voice"] = "";
  52. $v["voice_time"] || $v["voice_time"] = 0;
  53. $v["type_name"] || $v["type_name"] = "";
  54. }
  55. return $list;
  56. }
  57. }