diff --git a/app/Controller/Api/V1/Group/GiftController.php b/app/Controller/Api/V1/Group/GiftController.php index 0228c245c1a85d9da0027b6cbdc44c28f225c365..c5415aef523ce12946dba3c51ca1f1b9977bf687 100644 --- a/app/Controller/Api/V1/Group/GiftController.php +++ b/app/Controller/Api/V1/Group/GiftController.php @@ -39,12 +39,6 @@ class GiftController extends CController // $this->groupMemberService = $groupMemberService; // } - public function uid(): int - { - $guard = $this->guard('jwt'); - - return $guard->check() ? $guard->user()->getId() : 0; - } /** * 获取所有礼物 * @@ -166,6 +160,25 @@ class GiftController extends CController if ($data) { foreach ($data as $k => $v) { $j = json_decode($v, true); + + $model = Players::where('players.id', '=', $j['player_id']) + ->leftjoin('signups as o', 'o.id', '=', 'players.sign_id') + ->select('o.mine_id') + ->first() + ->toArray(); + + $is_follow = 0; + // 关注状态 + if ($user_id) { + $follow_user = DB::table('user_follow') + ->where('user_id',$user_id) + ->where('to_user_id',$model['mine_id']) + ->first(); + if (!empty($follow_user)) { + $is_follow = 1; + } + } + $j['is_follow'] = $is_follow; $return[] = $j; } } else { @@ -176,6 +189,25 @@ class GiftController extends CController if ($data) { foreach ($data as $k => $v) { $j = json_decode($v, true); + + $model = Players::where('players.id', '=', $j['player_id']) + ->leftjoin('signups as o', 'o.id', '=', 'players.sign_id') + ->select('o.mine_id') + ->first() + ->toArray(); + + $is_follow = 0; + // 关注状态 + if ($user_id) { + $follow_user = DB::table('user_follow') + ->where('user_id',$user_id) + ->where('to_user_id',$model['mine_id']) + ->first(); + if (!empty($follow_user)) { + $is_follow = 1; + } + } + $j['is_follow'] = $is_follow; $return[] = $j; } } @@ -202,7 +234,7 @@ class GiftController extends CController if ($count > 0) { $model->orderBy('pg.points', 'desc'); - $rows = $model->forPage($page, $pageSize)->get(['players.id as player_id', 'players.head_img', 'players.name', 'pg.points', 'o.id_num'])->toArray(); + $rows = $model->forPage($page, $pageSize)->get(['players.id as player_id', 'players.head_img', 'players.name', 'pg.points','o.mine_id', 'o.id_num'])->toArray(); foreach ($rows as $k => $v) { @@ -218,6 +250,19 @@ class GiftController extends CController if (empty($img)) { $rows[$k]['head_img'] = 'https://cdn.rockysports.cn/%E5%BE%AE%E6%AD%A5%E8%AE%A1%E6%97%B6.png'; } + + $is_follow = 0; + // 关注状态 + if ($user_id) { + $mine_id = data_get($v, 'mine_id', 0); + $follow_user = DB::table('user_follow') + ->where('user_id',$user_id) + ->where('to_user_id',$mine_id) + ->first(); + if (!empty($follow_user)) { + $is_follow = 1; + } + } } }